Search in sources :

Example 11 with SBOLValidationException

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

the class ParticipationTest method test_ParticipantMethods.

@Test
public void test_ParticipantMethods() throws SBOLValidationException {
    TetR.addRole(SystemsBiologyOntology.INHIBITOR);
    Interaction TetR_Interaction = TetRInverter_MD.createInteraction("TetR_Interaction", SystemsBiologyOntology.NON_COVALENT_BINDING);
    Participation TetR_part = TetR_Interaction.createParticipation("TetR", "TetR", SystemsBiologyOntology.PRODUCT);
    assertTrue(TetR_Interaction.getParticipation("TetR").equals(TetR_part));
    assertTrue(TetR_part.addRole(SystemsBiologyOntology.COMPETITIVE_INHIBITOR));
    assertTrue(TetR_part.containsRole(SystemsBiologyOntology.COMPETITIVE_INHIBITOR));
    assertTrue(TetR_part.getRoles().size() == 2);
    assertTrue(TetR_part.removeRole(SystemsBiologyOntology.COMPETITIVE_INHIBITOR));
    assertFalse(TetR_part.containsRole(SystemsBiologyOntology.COMPETITIVE_INHIBITOR));
    assertTrue(TetR_part.getParticipantDefinition().getIdentity().equals(TetR.getIdentity()));
    assertTrue(TetR_part.getParticipant().getIdentity().equals(TetRInverter_MD.getFunctionalComponent("TetR").getIdentity()));
    assertNotNull(TetR_part);
}
Also used : Participation(org.sbolstandard.core2.Participation) Interaction(org.sbolstandard.core2.Interaction) Test(org.junit.Test)

Example 12 with SBOLValidationException

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

the class AnnotationTest method test_pubConstructors.

@Test
public void test_pubConstructors() throws SBOLValidationException, URISyntaxException {
    Annotation CD_annot = gRNA_b_gene.createAnnotation(new QName(prURI, "protein", "pr"), true);
    assertTrue(gRNA_b_gene.getAnnotation(CD_annot.getQName()).getBooleanValue());
    assertTrue(gRNA_b_gene.getAnnotations().size() == 1);
    assertTrue(CD_annot.isBooleanValue());
    CD_annot.setBooleanValue(false);
    assertFalse(gRNA_b_gene.getAnnotation(CD_annot.getQName()).getBooleanValue());
    gRNA_b_gene.removeAnnotation(CD_annot);
    assertTrue(gRNA_b_gene.getAnnotations().size() == 0);
    // test constructor with double
    CD_annot = gRNA_b_gene.createAnnotation(new QName(prURI, "protein", "pr"), 1.0);
    assertTrue(gRNA_b_gene.getAnnotation(CD_annot.getQName()).getDoubleValue() == 1.0);
    assertTrue(gRNA_b_gene.getAnnotations().size() == 1);
    assertTrue(CD_annot.isDoubleValue());
    CD_annot.setDoubleValue(5.0);
    assertTrue(CD_annot.getDoubleValue() == 5.0);
    gRNA_b_gene.removeAnnotation(CD_annot);
    assertTrue(gRNA_b_gene.getAnnotations().size() == 0);
    // test constructor with int
    CD_annot = gRNA_b_gene.createAnnotation(new QName(prURI, "protein", "pr"), 2);
    assertTrue(gRNA_b_gene.getAnnotation(CD_annot.getQName()).getIntegerValue() == 2);
    assertTrue(gRNA_b_gene.getAnnotations().size() == 1);
    assertTrue(CD_annot.isIntegerValue());
    CD_annot.setIntegerValue(7);
    assertTrue(CD_annot.getIntegerValue() == 7);
    gRNA_b_gene.removeAnnotation(CD_annot);
    assertTrue(gRNA_b_gene.getAnnotations().size() == 0);
    // test constructor with string
    CD_annot = gRNA_b_gene.createAnnotation(new QName(prURI, "protein", "pr"), "protein");
    assertTrue(gRNA_b_gene.getAnnotation(CD_annot.getQName()).getStringValue().equals("protein"));
    assertTrue(gRNA_b_gene.getAnnotations().size() == 1);
    assertTrue(CD_annot.isStringValue());
    CD_annot.setStringValue("notAProtein");
    assertTrue(CD_annot.getStringValue().equals("notAProtein"));
    gRNA_b_gene.removeAnnotation(CD_annot);
    assertTrue(gRNA_b_gene.getAnnotations().size() == 0);
    // test constructor with URI
    CD_annot = gRNA_b_gene.createAnnotation(new QName(prURI, "protein", "pr"), new URI("http://www.sbolstandard.org/protein"));
    assertTrue(gRNA_b_gene.getAnnotation(CD_annot.getQName()).getURIValue().equals(new URI("http://www.sbolstandard.org/protein")));
    assertTrue(gRNA_b_gene.getAnnotations().size() == 1);
    assertTrue(CD_annot.isURIValue());
    CD_annot.setURIValue(new URI("http://www.sbolstandard.org/gene"));
    assertTrue(CD_annot.getURIValue().equals(new URI("http://www.sbolstandard.org/gene")));
    gRNA_b_gene.removeAnnotation(CD_annot);
    assertTrue(gRNA_b_gene.getAnnotations().size() == 0);
}
Also used : QName(javax.xml.namespace.QName) URI(java.net.URI) Annotation(org.sbolstandard.core2.Annotation) Test(org.junit.Test)

Example 13 with SBOLValidationException

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

the class SequenceTest method test_deep_copy.

@Test
public void test_deep_copy() throws SBOLValidationException {
    Sequence gen_seq = doc.createSequence("CRa_U6_seq", CRa_U6_seq, Sequence.IUPAC_DNA);
    Sequence copy_seq = (Sequence) doc.createCopy(gen_seq, "copy_seq");
    // assertTrue(copy_seq.equals(gen_seq));
    assertTrue(copy_seq.getElements().equals(CRa_U6_seq));
}
Also used : Sequence(org.sbolstandard.core2.Sequence) Test(org.junit.Test)

Example 14 with SBOLValidationException

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

the class ComponentTest method test_ComponentMapsTo.

@Test
public void test_ComponentMapsTo() throws SBOLValidationException {
    MapsTo geneMapsTo = gene.createMapsTo("local_gene", RefinementType.USELOCAL, target_gene.getDisplayId(), protein.getDisplayId());
    assertTrue(gene.getMapsTos().size() == 1);
    assertNotNull(gene.getMapsTo("local_gene"));
    assertEquals(gene.getMapsTo("local_gene"), geneMapsTo);
    gene.removeMapsTo(geneMapsTo);
    assertTrue(gene.getMapsTos().size() == 0);
    geneMapsTo = gene.createMapsTo("local_gene", RefinementType.USELOCAL, target_gene.getIdentity(), protein.getIdentity());
    assertNotNull(gene.getMapsTo(geneMapsTo.getIdentity()));
    assertTrue(gene.getMapsTos().size() == 1);
    gene.clearMapsTos();
    assertTrue(gene.getMapsTos().size() == 0);
}
Also used : MapsTo(org.sbolstandard.core2.MapsTo) Test(org.junit.Test)

Example 15 with SBOLValidationException

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

the class Activity method copy.

/* (non-Javadoc)
	 * @see org.sbolstandard.core2.abstract_classes.TopLevel#copy(java.lang.String, java.lang.String, java.lang.String)
	 */
/**
 * @throws SBOLValidationException if an SBOL validation rule violation occurred in
 * any of the following methods:
 * <ul>
 * <li>{@link #deepCopy()},</li>
 * <li>{@link URIcompliance#createCompliantURI(String, String, String)},</li>
 * <li>{@link #setDisplayId(String)},</li>
 * <li>{@link #setVersion(String)},</li>
 * <li>{@link #setWasDerivedFrom(URI)}, or</li>
 * <li>{@link #setIdentity(URI)}.</li>
 * </ul>
 */
@Override
Activity copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    Activity cloned = this.deepCopy();
    cloned.setPersistentIdentity(createCompliantURI(URIprefix, displayId, ""));
    cloned.setDisplayId(displayId);
    cloned.setVersion(version);
    URI newIdentity = createCompliantURI(URIprefix, displayId, version);
    if (!this.getIdentity().equals(newIdentity)) {
        cloned.addWasDerivedFrom(this.getIdentity());
    } else {
        cloned.setWasDerivedFroms(this.getWasDerivedFroms());
    }
    cloned.setIdentity(newIdentity);
    return cloned;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Aggregations

URI (java.net.URI)81 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)75 QName (javax.xml.namespace.QName)36 HashSet (java.util.HashSet)35 ArrayList (java.util.ArrayList)31 Literal (org.sbolstandard.core.datatree.Literal)30 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)30 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)17 Test (org.junit.Test)16 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)13 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)9 SBOLDocument (org.sbolstandard.core2.SBOLDocument)9 ModuleDefinition (org.sbolstandard.core2.ModuleDefinition)6 Sequence (org.sbolstandard.core2.Sequence)5 Interaction (org.sbolstandard.core2.Interaction)4 GenericTopLevel (org.sbolstandard.core2.GenericTopLevel)3 MapsTo (org.sbolstandard.core2.MapsTo)3 Set (java.util.Set)2 Annotation (org.sbolstandard.core2.Annotation)2 GenericLocation (org.sbolstandard.core2.GenericLocation)2