use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class ModuleDefinitionOutput method addSubComponents.
private static void addSubComponents(SBOLDocument document, ComponentDefinition componentDef, List<ComponentDefinition> subComponents) throws Exception {
int i = 1;
int start = 0;
int end = 0;
for (ComponentDefinition subComponent : subComponents) {
Component component = componentDef.createComponent(subComponent.getDisplayId(), AccessType.PUBLIC, subComponent.getIdentity());
start = end + 1;
end = start + getSequenceLength(document, subComponent);
SequenceAnnotation annotation = componentDef.createSequenceAnnotation("anno" + i, "location" + i, start, end, OrientationType.INLINE);
annotation.setComponent(component.getIdentity());
i++;
}
}
use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class ModuleDefinitionOutput method getSequenceLength.
private static int getSequenceLength(SBOLDocument document, ComponentDefinition componentDef) throws Exception {
if (componentDef.getSequences() != null && componentDef.getSequences().size() > 0) {
Sequence sequence = componentDef.getSequences().iterator().next();
return sequence.getElements().length();
} else {
int total = 0;
for (SequenceAnnotation annotation : componentDef.getSequenceAnnotations()) {
if (annotation.getComponent() != null) {
Component component = annotation.getComponent();
ComponentDefinition subComponentDef = component.getDefinition();
total = total + getSequenceLength(document, subComponentDef);
} else {
throw new Exception("Can't get sequence length for an incomplete design");
}
}
return total;
}
}
use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class SequenceConstraintOutput method main.
public static void main(String[] args) throws Exception {
String prURI = "http://partsregistry.org/";
SBOLDocument document = new SBOLDocument();
document.setDefaultURIprefix(prURI);
document.setTypesInURIs(true);
ComponentDefinition promoter = document.createComponentDefinition("BBa_K174004", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
promoter.addRole(SequenceOntology.PROMOTER);
promoter.setName("pspac promoter");
promoter.setDescription("LacI repressible promoter");
ComponentDefinition constPromoter = document.createComponentDefinition("pspac", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
constPromoter.addRole(SequenceOntology.PROMOTER);
constPromoter.setName("constitutive promoter");
constPromoter.setDescription("pspac core promoter region");
ComponentDefinition operator = document.createComponentDefinition("LacI_operator", "", new HashSet<URI>(Arrays.asList(ComponentDefinition.DNA)));
operator.addRole(SequenceOntology.OPERATOR);
operator.setName("LacI operator");
operator.setDescription("LacI binding site");
Component promoterComponent = promoter.createComponent("promoter", AccessType.PUBLIC, constPromoter.getIdentity());
Component operatorComponent = promoter.createComponent("operator", AccessType.PUBLIC, operator.getIdentity());
promoter.createSequenceConstraint("r1", RestrictionType.PRECEDES, promoterComponent.getIdentity(), operatorComponent.getIdentity());
SBOLWriter.write(document, (System.out));
}
use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class MapsToExample method main.
public static void main(String[] args) throws URISyntaxException, SBOLValidationException {
SBOLDocument doc = new SBOLDocument();
doc.setDefaultURIprefix("http://sbols.org/MapsToExample/");
doc.setComplete(true);
doc.setCreateDefaults(true);
String version = "";
ModuleDefinition md1 = doc.createModuleDefinition("md1", version);
ComponentDefinition fc1_def = doc.createComponentDefinition("fc1_def", version, ComponentDefinition.DNA);
ComponentDefinition fc2_def = doc.createComponentDefinition("fc2_def", version, ComponentDefinition.DNA);
FunctionalComponent fc1 = md1.createFunctionalComponent("fc1", AccessType.PUBLIC, "fc1_def", version, DirectionType.NONE);
FunctionalComponent fc2 = md1.createFunctionalComponent("fc2", AccessType.PUBLIC, "fc2_def", version, DirectionType.NONE);
ComponentDefinition cd = doc.createComponentDefinition("cd", version, ComponentDefinition.DNA);
fc1_def.createComponent("component", AccessType.PUBLIC, "cd");
fc1.createMapsTo("mapsTo", RefinementType.USELOCAL, "fc2", "component");
SBOLValidate.validateSBOL(doc, true, true, true);
if (SBOLValidate.getNumErrors() > 0) {
for (String error : SBOLValidate.getErrors()) {
System.out.println(error);
}
return;
}
}
use of org.sbolstandard.core2.Component in project libSBOLj by SynBioDex.
the class SequenceAnnotation method setComponent.
/**
* Sets this sequence annotation's reference component (its identity URI) to the one matching
* the given display ID.
* <p>
* This method first creates a compliant URI for the reference component. It starts with this sequence
* annotation's parent component defintion's persistent identity URI, followed by the given display ID,
* and ends with this sequence annotation's parent component defintion's version.
*
* @param displayId the given display ID for the reference component
* @throws SBOLValidationException if either of the following conditions is satisfied:
* <ul>
* <li>either of the following SBOL validation rules was violated: 10204, 10206; or</li>
* <li>if an SBOL validation rule violation occurred in any of the following constructors or methods:
* <ul>
* <li>{@link ComponentDefinition#createComponent(String, AccessType, String, String)}, or</li>
* <li>{@link #setComponent(URI)}.</li>
* </ul>
* </li>
* </ul>
*/
public void setComponent(String displayId) throws SBOLValidationException {
URI componentURI = URIcompliance.createCompliantURI(componentDefinition.getPersistentIdentity().toString(), displayId, componentDefinition.getVersion());
if (this.getSBOLDocument() != null && this.getSBOLDocument().isCreateDefaults() && componentDefinition != null && componentDefinition.getComponent(componentURI) == null) {
componentDefinition.createComponent(displayId, AccessType.PUBLIC, displayId, "");
}
setComponent(componentURI);
}
Aggregations