use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class GettingStartedExample method main.
public static void main(String[] args) throws IOException, SBOLValidationException, SBOLConversionException {
String prURI = "http://partsregistry.org/";
String prPrefix = "pr";
String myersLabURI = "http://www.async.ece.utah.edu/";
String myersLabPrefix = "myersLab";
SBOLDocument document = new SBOLDocument();
document.setDefaultURIprefix(prURI);
document.setTypesInURIs(true);
document.setComplete(true);
document.setCreateDefaults(true);
document.addNamespace(URI.create(prURI), prPrefix);
document.addNamespace(URI.create(myersLabURI), myersLabPrefix);
// Creating a Top-level SBOL Data Object
HashSet<URI> types = new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA, URI.create("http://identifiers.org/chebi/CHEBI:4705")));
ComponentDefinition TetR_promoter = document.createComponentDefinition("BBa_R0040", types);
ComponentDefinition LacI_repressor = document.createComponentDefinition("BBa_C0012", types);
ComponentDefinition pIKELeftCassette = document.createComponentDefinition("pIKELeftCassette", types);
Sequence seq_187 = document.createSequence("partseq_187", "tccctatcagtgatagagattgacatccctatcagtgatagagatactgagcac", Sequence.IUPAC_DNA);
String element2 = "atggtgaatgtgaaaccagtaacgttatacgatgtcgcagagtatgccggtgtc" + "tcttatcagaccgtttcccgcgtggtgaaccaggccagccacgtttctgcgaaaacgcggga" + "aaaagtggaagcggcgatggcggagctgaattacattcccaaccgcgtggcacaacaactgg" + "cgggcaaacagtcgttgctgattggcgttgccacctccagtctggccctgcacgcgccgtcg" + "caaattgtcgcggcgattaaatctcgcgccgatcaactgggtgccagcgtggtggtgtcgat" + "ggtagaacgaagcggcgtcgaagcctgtaaagcggcggtgcacaatcttctcgcgcaacgcg" + "tcagtgggctgatcattaactatccgctggatgaccaggatgccattgctgtggaagctgcc" + "tgcactaatgttccggcgttatttcttgatgtctctgaccagacacccatcaacagtattat" + "tttctcccatgaagacggtacgcgactgggcgtggagcatctggtcgcattgggtcaccagc" + "aaatcgcgctgttagcgggcccattaagttctgtctcggcgcgtctgcgtctggctggctgg" + "cataaatatctcactcgcaatcaaattcagccgatagcggaacgggaaggcgactggagtgc" + "catgtccggttttcaacaaaccatgcaaatgctgaatgagggcatcgttcccactgcgatgc" + "tggttgccaacgatcagatggcgctgggcgcaatgcgcgccattaccgagtccgggctgcgc" + "gttggtgcggatatctcggtagtgggatacgacgataccgaagacagctcatgttatatccc" + "gccgttaaccaccatcaaacaggattttcgcctgctggggcaaaccagcgtggaccgcttgc" + "tgcaactctctcagggccaggcggtgaagggcaatcagctgttgcccgtctcactggtgaaa" + "agaaaaaccaccctggcgcccaatacgcaaaccgcctctccccgcgcgttggccgattcatt" + "aatgcagctggcacgacaggtttcccgactggaaagcgggcaggctgcaaacgacgaaaact" + "acgctttagtagcttaataa";
Sequence seq_153 = document.createSequence("partseq_153", element2, Sequence.IUPAC_DNA);
// Setting and editing optional fields
TetR_promoter.setName("p(tetR)");
LacI_repressor.setName("lacI");
TetR_promoter.setDescription("TetR repressible promoter");
LacI_repressor.setDescription("lacI repressor from E. coli (+LVA)");
if (TetR_promoter.isSetName()) {
TetR_promoter.unsetName();
}
TetR_promoter.setName("p(tetR)");
TetR_promoter.addRole(SequenceOntology.PROMOTER);
LacI_repressor.addRole(SequenceOntology.CDS);
URI TetR_promoter_role2 = URI.create("http://identifiers.org/so/SO:0000613");
TetR_promoter.addRole(TetR_promoter_role2);
if (TetR_promoter.containsRole(TetR_promoter_role2)) {
TetR_promoter.removeRole(TetR_promoter_role2);
}
TetR_promoter.clearRoles();
if (!TetR_promoter.getRoles().isEmpty()) {
System.out.println("TetR_promoter set is not empty");
}
TetR_promoter.setRoles(new HashSet<URI>(Arrays.asList(SequenceOntology.PROMOTER)));
// Creating and editing references
TetR_promoter.addSequence(seq_187);
LacI_repressor.addSequence(seq_153);
pIKELeftCassette.addSequence(seq_187);
pIKELeftCassette.clearSequences();
// Adding the sequence below causes an exception because it cannot be found
// pIKELeftCassette.addSequence(URI.create("http://partsregistry.org/seq/partseq_154"));
// Creating Annotations
TetR_promoter.createAnnotation(new QName(prURI, "experience", prPrefix), URI.create("http://parts.igem.org/Part:BBa_R0040"));
// Creating Generic TopLevel Object
GenericTopLevel datasheet = document.createGenericTopLevel("datasheet", "1.0", new QName(myersLabURI, "datasheet", myersLabPrefix));
datasheet.setName("Datasheet for Custom Parameters");
datasheet.createAnnotation(new QName(myersLabURI, "characterizationData", myersLabPrefix), URI.create(myersLabURI + "/measurement/Part:BBa_R0040"));
datasheet.createAnnotation(new QName(myersLabURI, "transcriptionRate", myersLabPrefix), "0.75");
TetR_promoter.createAnnotation(new QName(myersLabURI, "datasheet", myersLabPrefix), datasheet.getIdentity());
// Creating and editing Child Objects
// For pIKELeftCassette, create sequence constraint that says BBa_R0040 precedes BBa_C0012.
// Note that with CreateDefaults that components get created automatically.
// The position of the subject Component MUST precede that of the object Component.
pIKELeftCassette.createSequenceConstraint("pIKELeftCassette_sc", RestrictionType.PRECEDES, TetR_promoter.getDisplayId(), LacI_repressor.getDisplayId());
if (pIKELeftCassette.getComponent("BBa_R0040") == null) {
System.out.println("TetR_promoter component is missing");
}
if (pIKELeftCassette.getComponent("BBa_C0012") == null) {
System.out.println("LacI_repressor component is missing");
}
// Removing the subject component below causes an exception.
// pIKELeftCassette.removeComponent(pIKELeftCassette.getComponent("BBa_R0040"));
// Copying objects
ComponentDefinition TetR_promoter_copy = (ComponentDefinition) document.createCopy(TetR_promoter, "BBa_K137046");
Sequence seq = document.createSequence("seq_K137046", "gtgctcagtatctctatcactgatagggatgtcaatctctatcactgatagggactctagtatat" + "aaacgcagaaaggcccacccgaaggtgagccagtgtgactctagtagagagcgttcaccgaca" + "aacaacagataaaacgaaaggc", Sequence.IUPAC_DNA);
TetR_promoter_copy.addSequence(seq);
SBOLWriter.write(document, "GettingStartedExample.rdf");
writeThenRead(document);
}
use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class ComponentDefinitionOutput method createComponentDefinitionOutput.
public static SBOLDocument createComponentDefinitionOutput() throws SBOLValidationException {
String prURI = "http://partsregistry.org/";
String prPrefix = "pr";
SBOLDocument document = new SBOLDocument();
document.setTypesInURIs(true);
document.addNamespace(URI.create(prURI), prPrefix);
document.setDefaultURIprefix(prURI);
Sequence seqpTetR = document.createSequence("BBa_R0040", "", "tccctatcagtgatagagattgacatccctatcagtgatagagatactgagcac", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
Sequence seqRbs = document.createSequence("BBa_B0034", "", "aaagaggagaaa", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
Sequence seqCds = document.createSequence("BBa_C0062", "", "atgcttatctgatatgactaaaatggtacattgtgaatattatttactcgcgatcatttatcctcattctatggttaaatctgatatttcaatcctagataattaccctaaaaaatggaggcaatattatgatgacgctaatttaataaaatatgatcctatagtagattattctaactccaatcattcaccaattaattggaatatatttgaaaacaatgctgtaaataaaaaatctccaaatgtaattaaagaagcgaaaacatcaggtcttatcactgggtttagtttccctattcatacggctaacaatggcttcggaatgcttagttttgcacattcagaaaaagacaactatatagatagtttatttttacatgcgtgtatgaacataccattaattgttccttctctagttgataattatcgaaaaataaatatagcaaataataaatcaaacaacgatttaaccaaaagagaaaaagaatgtttagcgtgggcatgcgaaggaaaaagctcttgggatatttcaaaaatattaggttgcagtgagcgtactgtcactttccatttaaccaatgcgcaaatgaaactcaatacaacaaaccgctgccaaagtatttctaaagcaattttaacaggagcaattgattgcccatactttaaaaattaataacactgatagtgctagtgtagatcac", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
Sequence seqTer = document.createSequence("BBa_B0015", "", "ccaggcatcaaataaaacgaaaggctcagtcgaaagactgggcctttcgttttatctgttgtttgtcggtgaacgctctctactagagtcacactggctcaccttcgggtgggcctttctgcgtttata", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
Sequence seqPluxR = document.createSequence("BBa_R0062", "", "acctgtaggatcgtacaggtttacgcaagaaaatggtttgttatagtcgaataaa", URI.create("http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html"));
ComponentDefinition pTetR = document.createComponentDefinition("BBa_R0040", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
pTetR.addRole(SequenceOntology.PROMOTER);
pTetR.setName("pTetR");
pTetR.setDescription("TetR repressible promoter");
pTetR.addSequence(seqpTetR.getIdentity());
ComponentDefinition rbs = document.createComponentDefinition("BBa_B0034", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
rbs.addRole(SequenceOntology.RIBOSOME_ENTRY_SITE);
rbs.setName("BBa_B0034");
rbs.setDescription("RBS based on Elowitz repressilator");
rbs.addSequence(seqRbs.getIdentity());
ComponentDefinition cds = document.createComponentDefinition("BBa_C0062", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
cds.addRole(SequenceOntology.CDS);
cds.setName("luxR");
cds.setDescription("luxR coding sequence");
cds.addSequence(seqCds.getIdentity());
ComponentDefinition ter = document.createComponentDefinition("BBa_B0015", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
ter.addRole(URI.create("http://identifiers.org/so/SO:0000141"));
ter.setName("BBa_B0015");
ter.setDescription("Double terminator");
ter.addSequence(seqTer.getIdentity());
ComponentDefinition pluxR = document.createComponentDefinition("BBa_R0062", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
//
pluxR.addRole(SequenceOntology.PROMOTER);
pluxR.setName("pLuxR");
pluxR.setDescription("LuxR inducible promoter");
pluxR.addSequence(seqPluxR.getIdentity());
ComponentDefinition device = document.createComponentDefinition("BBa_F2620", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
// biological region
device.addRole(URI.create("http://identifiers.org/so/SO:00001411"));
device.setName("BBa_F2620");
device.setDescription("3OC6HSL -> PoPS Receiver");
Component comPtetR = device.createComponent("pTetR", AccessType.PUBLIC, pTetR.getIdentity());
Component comRbs = device.createComponent("rbs", AccessType.PUBLIC, rbs.getIdentity());
Component comCds = device.createComponent("luxR", AccessType.PUBLIC, cds.getIdentity());
Component comTer = device.createComponent("ter", AccessType.PUBLIC, ter.getIdentity());
Component comPluxR = device.createComponent("pLuxR", AccessType.PUBLIC, pluxR.getIdentity());
int start = 1;
int end = seqPluxR.getElements().length();
SequenceAnnotation anno = device.createSequenceAnnotation("anno1", "location1", start, end, OrientationType.INLINE);
anno.setComponent(comPtetR.getIdentity());
start = end + 1;
end = seqRbs.getElements().length() + end + 1;
SequenceAnnotation anno2 = device.createSequenceAnnotation("anno2", "location2", start, end, OrientationType.INLINE);
anno2.setComponent(comRbs.getIdentity());
start = end + 1;
end = seqCds.getElements().length() + end + 1;
SequenceAnnotation anno3 = device.createSequenceAnnotation("anno3", "location3", start, end, OrientationType.INLINE);
anno3.setComponent(comCds.getIdentity());
start = end + 1;
end = seqTer.getElements().length() + end + 1;
SequenceAnnotation anno4 = device.createSequenceAnnotation("anno4", "location4", start, end, OrientationType.INLINE);
anno4.setComponent(comTer.getIdentity());
start = end + 1;
end = seqPluxR.getElements().length() + end + 1;
SequenceAnnotation anno5 = device.createSequenceAnnotation("anno5", "location5", start, end, OrientationType.INLINE);
anno5.setComponent(comPluxR.getIdentity());
return document;
}
use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class Provenance_CodonOptimization method main.
public static void main(String[] args) throws Exception {
NamespaceBinding myAppNs = NamespaceBinding("http://myapp.com/", "myapp");
SBOLDocument document = new SBOLDocument();
document.addNamespace(URI.create(myAppNs.getNamespaceURI()), myAppNs.getPrefix());
document.setDefaultURIprefix(myAppNs.getNamespaceURI());
ComponentDefinition optimizedCds = getCds(document, "codon_optimized", "Codon optimised CDS");
ComponentDefinition sourceCds = getCds(document, "non_codon_optimized", "Non Codon optimised CDS");
optimizedCds.addWasDerivedFrom(sourceCds.getIdentity());
// Create the agent definition for the codon optimization software
Agent agent = document.createAgent("codon_optimization_software");
agent.setName("Codon Optimization Software");
// Create the generic top level entity for the codon optimization activity
Activity activity = document.createActivity("codon_optimization_activity");
activity.setName("Codon Optimization Activity");
// Create the qualifiedUsage annotation to describe the use of the non codon optimized CDS component
activity.createUsage("usage", sourceCds.getIdentity()).addRole(URI.create("http://sbols.org/v2#source"));
// Create the qualifiedAssociation annotation to describe the use of the software agent used in the activity
activity.createAssociation("association", agent.getIdentity()).addRole(myAppNs.namespacedUri("codonoptimiser"));
optimizedCds.addWasGeneratedBy(activity.getIdentity());
SBOLWriter.write(document, System.out);
}
use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class CombinatorialDerivation method addVariableComponentNoCheck.
/**
* Adds the given variable component to the list of variable components.
*
* @param variableComponent
*/
private void addVariableComponentNoCheck(VariableComponent variableComponent) throws SBOLValidationException {
variableComponent.setSBOLDocument(this.getSBOLDocument());
variableComponent.setCombinatorialDerivation(this);
ComponentDefinition template = this.getTemplate();
if (template != null) {
if (template.getComponent(variableComponent.getVariableURI()) == null) {
throw new SBOLValidationException("sbol-13005", this);
}
}
for (URI cdURI : variableComponent.getVariantDerivationURIs()) {
if (this.getSBOLDocument() != null && this.getSBOLDocument().isComplete()) {
CombinatorialDerivation cd = this.getSBOLDocument().getCombinatorialDerivation(cdURI);
if (cd != null && this.getIdentity().equals(cd.getIdentity())) {
throw new SBOLValidationException("sbol-13015", variableComponent);
}
}
}
addChildSafely(variableComponent, variableComponents, "variableComponent");
}
use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class SBOLReader method parseSequenceAnnotationV1.
/**
* @param SBOLDoc
* @param sequenceAnnotation
* @param precedePairs
* @param parentURI
* @param sa_num
* @param instantiatedComponents
* @return
* @throws SBOLValidationException if either of the following conditions is satisfied:
* <ul>
* <li>if an SBOL validation rule violation occurred in any of the following constructors or methods:
* <ul>
* <li>{@link URIcompliance#createCompliantURI(String, String, String)}, </li>
* <li>{@link #parseDnaComponentV1(SBOLDocument, IdentifiableDocument)}, </li>
* <li>{@link Range#Range(URI, int, int)}, </li>
* <li>{@link Range#setDisplayId(String)}, </li>
* <li>{@link Range#setVersion(String)}, </li>
* <li>{@link GenericLocation#GenericLocation(URI)}, </li>
* <li>{@link SequenceAnnotation#SequenceAnnotation(URI, Set)}, </li>
* <li>{@link SequenceAnnotation#setDisplayId(String)}, </li>
* <li>{@link SequenceAnnotation#setVersion(String)}, </li>
* <li>{@link SequenceAnnotation#setWasDerivedFrom(URI)}, </li>
* <li>{@link SequenceAnnotation#setComponent(URI)}, or </li>
* <li>{@link SequenceAnnotation#setAnnotations(List)}; or</li>
* </ul>
* </li>
* <li>the following SBOL validation rule was violated: 11002.</li>
* </ul>
* @throws SBOLConversionException
*/
private static SequenceAnnotation parseSequenceAnnotationV1(SBOLDocument SBOLDoc, NestedDocument<QName> sequenceAnnotation, List<SBOLPair> precedePairs, String parentURI, int sa_num, Set<String> instantiatedComponents) throws SBOLValidationException, SBOLConversionException {
Integer start = null;
Integer end = null;
String strand = null;
URI componentURI = null;
URI identity = sequenceAnnotation.getIdentity();
String persIdentity = sequenceAnnotation.getIdentity().toString();
List<Annotation> annotations = new ArrayList<>();
if (URIPrefix != null) {
persIdentity = createCompliantURI(parentURI, "annotation" + sa_num, "").toString();
identity = createCompliantURI(parentURI, "annotation" + sa_num, version);
}
if (!sequenceAnnotation.getType().equals(Sbol1Terms.SequenceAnnotations.SequenceAnnotation)) {
throw new SBOLConversionException("QName has to be" + Sbol1Terms.SequenceAnnotations.SequenceAnnotation.toString());
}
for (NamedProperty<QName> namedProperty : sequenceAnnotation.getProperties()) {
if (namedProperty.getName().equals(Sbol1Terms.SequenceAnnotations.bioStart)) {
if (!(namedProperty.getValue() instanceof Literal) || start != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
throw new SBOLValidationException("sbol-11102", sequenceAnnotation.getIdentity());
}
String temp = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
start = Integer.parseInt(temp);
} else if (namedProperty.getName().equals(Sbol1Terms.SequenceAnnotations.bioEnd)) {
if (!(namedProperty.getValue() instanceof Literal) || end != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
throw new SBOLValidationException("sbol-11103", sequenceAnnotation.getIdentity());
}
String temp2 = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
end = Integer.parseInt(temp2);
} else if (namedProperty.getName().equals(Sbol1Terms.SequenceAnnotations.strand)) {
if (!(namedProperty.getValue() instanceof Literal) || strand != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
throw new SBOLValidationException("sbol-11002", sequenceAnnotation.getIdentity());
}
strand = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
} else if (namedProperty.getName().equals(Sbol1Terms.SequenceAnnotations.subComponent)) {
if (componentURI != null) {
throw new SBOLValidationException("sbol-10904", sequenceAnnotation.getIdentity());
}
if (namedProperty.getValue() instanceof NestedDocument) {
componentURI = parseDnaComponentV1(SBOLDoc, (NestedDocument<QName>) namedProperty.getValue()).getIdentity();
} else {
if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
throw new SBOLValidationException("sbol-10904", sequenceAnnotation.getIdentity());
}
componentURI = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
}
} else if (namedProperty.getName().equals(Sbol1Terms.SequenceAnnotations.precedes)) {
URI left = sequenceAnnotation.getIdentity();
URI right = null;
if (namedProperty.getValue() instanceof NestedDocument) {
// TODO: need to check if ++sa_num here okay
right = parseSequenceAnnotationV1(SBOLDoc, (NestedDocument<QName>) namedProperty.getValue(), precedePairs, parentURI, ++sa_num, instantiatedComponents).getIdentity();
} else {
if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
throw new SBOLValidationException("sbol-11404", sequenceAnnotation.getIdentity());
}
right = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
}
SBOLPair pair = new SBOLPair(left, right);
precedePairs.add(pair);
} else {
annotations.add(new Annotation(namedProperty));
}
}
String componentDisplayId = URIcompliance.extractDisplayId(componentURI);
String displayId = "annotation" + sa_num;
if (compliant && componentDisplayId != null && !instantiatedComponents.contains(componentDisplayId)) {
identity = createCompliantURI(parentURI, componentDisplayId + "_annotation", version);
persIdentity = createCompliantURI(parentURI, componentDisplayId + "_annotation", "").toString();
displayId = componentDisplayId + "_annotation";
}
// Note: Do not create a seqAnnotation if Location is empty
Location location = null;
if (// create SequenceAnnotation & Component
start != null && end != null) {
URI range_identity = createCompliantURI(persIdentity, "range", version);
location = new Range(range_identity, start, end);
if (!persIdentity.equals("")) {
location.setPersistentIdentity(createCompliantURI(persIdentity, "range", ""));
location.setDisplayId("range");
location.setVersion(version);
}
if (strand != null) {
if (strand.equals("+")) {
location.setOrientation(OrientationType.INLINE);
} else if (strand.equals("-")) {
location.setOrientation(OrientationType.REVERSECOMPLEMENT);
}
}
} else {
URI dummyGenericLoc_id = createCompliantURI(persIdentity, "genericLocation", version);
location = new GenericLocation(dummyGenericLoc_id);
if (!persIdentity.equals("")) {
location.setPersistentIdentity(createCompliantURI(persIdentity, "genericLocation", ""));
location.setDisplayId("genericLocation");
location.setVersion(version);
}
if (strand != null) {
if (strand.equals("+")) {
location.setOrientation(OrientationType.INLINE);
} else if (strand.equals("-")) {
location.setOrientation(OrientationType.REVERSECOMPLEMENT);
}
}
}
Set<Location> locations = new HashSet<>();
locations.add(location);
SequenceAnnotation s = new SequenceAnnotation(identity, locations);
if (!persIdentity.equals("")) {
s.setPersistentIdentity(URI.create(persIdentity));
s.setDisplayId(displayId);
s.setVersion(version);
}
if (identity != sequenceAnnotation.getIdentity())
s.addWasDerivedFrom(sequenceAnnotation.getIdentity());
if (componentURI != null)
s.setComponent(componentURI);
if (!annotations.isEmpty())
s.setAnnotations(annotations);
return s;
}
Aggregations