Search in sources :

Example 46 with SBOLValidationException

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

the class SequenceAnnotation method addCut.

/**
 * Creates a cut with the given arguments and then adds it to this sequence annotation's
 * list of locations.
 * <p>
 * This method first creates a compliant URI for the cut to be created.
 * It starts with this sequence annotation's persistent identity URI,
 * followed by the given display ID, and ends an empty string for version.
 *
 * @param displayId the display ID for the cut to be created
 * @param at the at property for the cut to be created
 * @param orientation the orientation type
 * @return the created cut
 * @throws SBOLValidationException if any of the following SBOL validation rules was violated:
 * 10201, 10202, 10204, 10206, 11202.
 */
public Cut addCut(String displayId, int at, OrientationType orientation) throws SBOLValidationException {
    URI identity = createCompliantURI(this.getPersistentIdentity().toString(), displayId, this.getVersion());
    Cut cut = new Cut(identity, at);
    cut.setPersistentIdentity(createCompliantURI(this.getPersistentIdentity().toString(), displayId, ""));
    cut.setDisplayId(displayId);
    cut.setVersion(this.getVersion());
    cut.setOrientation(orientation);
    addLocation(cut);
    return cut;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 47 with SBOLValidationException

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

the class SequenceAnnotation method copy.

void copy(SequenceAnnotation sequenceAnnotation) throws SBOLValidationException {
    ((Identified) this).copy((Identified) sequenceAnnotation);
    for (Location location : sequenceAnnotation.getLocations()) {
        String displayId = URIcompliance.findDisplayId(location);
        if (location instanceof Range) {
            Range range = (Range) location;
            Range newRange;
            if (range.isSetOrientation()) {
                newRange = this.addRange(displayId, range.getStart(), range.getEnd(), range.getOrientation());
            } else {
                newRange = this.addRange(displayId, range.getStart(), range.getEnd());
            }
            newRange.copy(range);
        } else if (location instanceof Cut) {
            Cut cut = (Cut) location;
            Cut newCut;
            if (cut.isSetOrientation()) {
                newCut = this.addCut(displayId, cut.getAt(), cut.getOrientation());
            } else {
                newCut = this.addCut(displayId, cut.getAt());
            }
            newCut.copy(cut);
        } else if (location instanceof GenericLocation) {
            GenericLocation genericLocation = (GenericLocation) location;
            GenericLocation newGenericLocation;
            if (genericLocation.isSetOrientation()) {
                newGenericLocation = this.addGenericLocation(displayId, genericLocation.getOrientation());
            } else {
                newGenericLocation = this.addGenericLocation(displayId);
            }
            newGenericLocation.copy(genericLocation);
        }
    }
    Location location = this.getLocation("DUMMY__LOCATION");
    if (location != null) {
        this.removeLocation(location);
    }
    if (sequenceAnnotation.isSetComponent()) {
        String componentDisplayId = URIcompliance.findDisplayId(sequenceAnnotation.getComponent());
        this.setComponent(componentDisplayId);
    }
    this.roles = new HashSet<>();
    for (URI role : sequenceAnnotation.getRoles()) {
        this.addRole(URI.create(role.toString()));
    }
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 48 with SBOLValidationException

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

the class SequenceAnnotation method addCut.

/**
 * Creates a cut with the given arguments and then adds it to this sequence annotation's
 * list of locations.
 * <p>
 * This method first creates a compliant URI for the cut to be created.
 * It starts with this sequence annotation's persistent identity URI,
 * followed by the given display ID, and ends an empty string for version.
 *
 * @param displayId the display ID for the cut to be created
 * @param at the at property for the cut to be created
 * @return the created cut
 * @throws SBOLValidationException if any of the following SBOL validation rules was violated:
 * 10201, 10202, 10204, 10206, 11202.
 */
public Cut addCut(String displayId, int at) throws SBOLValidationException {
    URI identity = createCompliantURI(this.getPersistentIdentity().toString(), displayId, this.getVersion());
    Cut cut = new Cut(identity, at);
    cut.setPersistentIdentity(createCompliantURI(this.getPersistentIdentity().toString(), displayId, ""));
    cut.setDisplayId(displayId);
    cut.setVersion(this.getVersion());
    addLocation(cut);
    return cut;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 49 with SBOLValidationException

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

the class SequenceAnnotation method addGenericLocation.

/**
 * Creates a generic location with the given arguments and then adds it to this sequence annotation's
 * list of locations.
 * <p>
 * This method first creates a compliant URI for the generic location to be created.
 * It starts with this sequence annotation's persistent identity URI,
 * followed by the given display ID, and ends an empty string for version.
 *
 * @param displayId the display ID for the generic location to be created
 * @return the created generic location instance
 * @throws SBOLValidationException if any of the following SBOL validation rules was violated:
 * 10201, 10202, 10204, 10206.
 */
public GenericLocation addGenericLocation(String displayId) throws SBOLValidationException {
    URI identity = createCompliantURI(this.getPersistentIdentity().toString(), displayId, this.getVersion());
    GenericLocation genericLocation = new GenericLocation(identity);
    genericLocation.setPersistentIdentity(createCompliantURI(this.getPersistentIdentity().toString(), displayId, ""));
    genericLocation.setDisplayId(displayId);
    genericLocation.setVersion(this.getVersion());
    addLocation(genericLocation);
    return genericLocation;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 50 with SBOLValidationException

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

the class Model 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
Model copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    Model 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