Search in sources :

Example 51 with SBOLDocument

use of org.sbolstandard.core2.SBOLDocument in project libSBOLj by SynBioDex.

the class FunctionalComponent method createMapsTo.

/**
 * Creates a child MapsTo instance for this module with the given arguments, and then adds to this module's list of mapsTos.
 * <p>
 * This method creates compliant local and remote URIs first.
 * The compliant local URI is created with this module's persistent identity URI, followed by
 * the given local component's display ID, followed by this module's version.
 * The compliant remote URI is created following the same pattern.
 * It then calls {@link #createMapsTo(String, RefinementType, URI, URI)} to create
 * a MapsTo instance.
 * <p>
 * This method automatically creates a local functional component if all of the following conditions are satisfied:
 * <ul>
 * <li>the associated SBOLDocument instance for this module is not {@code null};</li>
 * <li>if default functional components should be automatically created when not present for the associated SBOLDocument instance,
 * i.e., {@link SBOLDocument#isCreateDefaults} returns {@code true};</li>
 * <li>if this module's parent module definition exists; and</li>
 * <li>if this module's parent module definition does not already have a functional component
 * with the created compliant local functional component URI.</li>
 * </ul>
 * @param displayId the display ID of the mapsTo to be created
 * @param refinement the relationship between the local and remote functional components
 * @param localId the display ID of the local functional component
 * @param remoteId the display ID of the remote functional component
 * @return the created mapsTo
 * @throws SBOLValidationException if any of the following conditions is satisfied:
 * <ul>
 * <li>if either of the following SBOL validation rules was violated: 10204, 10206;</li>
 * <li>an SBOL validation rule violation occurred in {@link ModuleDefinition#createFunctionalComponent(String, AccessType, String, String, DirectionType)}; or</li>
 * <li>an SBOL validation rule violation occurred in {@link #createMapsTo(String, RefinementType, URI, URI)}.</li>
 * </ul>
 */
public MapsTo createMapsTo(String displayId, RefinementType refinement, String localId, String remoteId) throws SBOLValidationException {
    URI localURI = URIcompliance.createCompliantURI(moduleDefinition.getPersistentIdentity().toString(), localId, moduleDefinition.getVersion());
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isCreateDefaults() && moduleDefinition != null && moduleDefinition.getFunctionalComponent(localURI) == null) {
        moduleDefinition.createFunctionalComponent(localId, AccessType.PUBLIC, localId, "", DirectionType.INOUT);
    }
    URI remoteURI = URIcompliance.createCompliantURI(getDefinition().getPersistentIdentity().toString(), remoteId, getDefinition().getVersion());
    return createMapsTo(displayId, refinement, localURI, remoteURI);
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 52 with SBOLDocument

use of org.sbolstandard.core2.SBOLDocument in project libSBOLj by SynBioDex.

the class SBOLDocumentTest method setUp.

@Before
public void setUp() throws Exception {
    doc = new SBOLDocument();
    doc.setDefaultURIprefix(prURI);
    doc.setTypesInURIs(false);
    doc.setComplete(true);
    doc.createComponentDefinition("http://partsregistry.org", "gRNA_promoter", "", ComponentDefinition.DNA);
    doc.createComponentDefinition(prURI, "CRa_promoter", "", ComponentDefinition.DNA);
    doc.createComponentDefinition(prURI, "TetR_promoter", "", ComponentDefinition.DNA);
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) Before(org.junit.Before)

Example 53 with SBOLDocument

use of org.sbolstandard.core2.SBOLDocument in project libSBOLj by SynBioDex.

the class SBOLDocumentTest method test_createCopy.

@Test
public void test_createCopy() throws SBOLValidationException, IOException, SBOLConversionException {
    SBOLDocument repression_doc = new SBOLDocument();
    repression_doc.setDefaultURIprefix(prURI);
    repression_doc.setTypesInURIs(false);
    // repression_doc.setComplete(true);
    SBOLDocument copied_doc = new SBOLDocument();
    copied_doc.setDefaultURIprefix(prURI);
    copied_doc.setTypesInURIs(false);
    // copied_doc.setComplete(true);
    // /core2/src/test/java/org/sbolstandard/core2/Testing/RepressionModel.xml"
    InputStream docAsStream = SequenceConstraintTest.class.getResourceAsStream("/SBOLTestSuite/SBOL2/RepressionModel.xml");
    repression_doc.read(docAsStream);
    // repression_doc.read("C:/Users/meher/Documents/workspace/libSBOLj/core2/src/test/resources/SBOL2/RepressionModel.xml");
    copied_doc.createCopy(repression_doc);
    assertTrue(repression_doc.equals(copied_doc));
}
Also used : InputStream(java.io.InputStream) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Test(org.junit.Test)

Example 54 with SBOLDocument

use of org.sbolstandard.core2.SBOLDocument in project libSBOLj by SynBioDex.

the class AnnotationTest method setUp.

@Before
public void setUp() throws Exception {
    doc = new SBOLDocument();
    doc.setDefaultURIprefix(prURI);
    doc.setTypesInURIs(false);
    doc.setComplete(true);
    gRNA_b_gene = doc.createComponentDefinition("gRNA_b_gene", ComponentDefinition.DNA);
    gRNA_b_gene.addRole(SequenceOntology.ENGINEERED_GENE);
    gRNA_b_gene.setName("gRNA_b_gene");
    gRNA_b_gene.setDescription("protein");
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) Before(org.junit.Before)

Example 55 with SBOLDocument

use of org.sbolstandard.core2.SBOLDocument in project libSBOLj by SynBioDex.

the class SequenceConstraintTest method setUp.

@Before
public void setUp() throws Exception {
    repression_doc = new SBOLDocument();
    repression_doc.setDefaultURIprefix(prURI);
    repression_doc.setTypesInURIs(false);
    repression_doc.setComplete(true);
    InputStream docAsStream = SequenceConstraintTest.class.getResourceAsStream("/SBOLTestSuite/SBOL2/RepressionModel.xml");
    repression_doc.read(docAsStream);
}
Also used : InputStream(java.io.InputStream) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Before(org.junit.Before)

Aggregations

SBOLDocument (org.sbolstandard.core2.SBOLDocument)44 URI (java.net.URI)39 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)27 QName (javax.xml.namespace.QName)26 ArrayList (java.util.ArrayList)23 HashSet (java.util.HashSet)23 Literal (org.sbolstandard.core.datatree.Literal)22 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)22 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)20 Before (org.junit.Before)17 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)17 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)11 Sequence (org.sbolstandard.core2.Sequence)8 ModuleDefinition (org.sbolstandard.core2.ModuleDefinition)7 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)6 Activity (org.sbolstandard.core2.Activity)5 Component (org.sbolstandard.core2.Component)4 GenericTopLevel (org.sbolstandard.core2.GenericTopLevel)3 Interaction (org.sbolstandard.core2.Interaction)3 Module (org.sbolstandard.core2.Module)3