Search in sources :

Example 6 with Location

use of org.sbolstandard.core2.Location 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 7 with Location

use of org.sbolstandard.core2.Location in project java-client by appium.

the class IOSDriverTest method geolocationTest.

@Test
public void geolocationTest() {
    Location location = new Location(45, 45, 100);
    driver.setLocation(location);
}
Also used : Location(org.openqa.selenium.html5.Location) Test(org.junit.Test)

Example 8 with Location

use of org.sbolstandard.core2.Location in project java-client by appium.

the class AndroidDriverTest method geolocationTest.

@Test
public void geolocationTest() {
    Location location = new Location(45, 45, 100);
    driver.setLocation(location);
}
Also used : Location(org.openqa.selenium.html5.Location) Test(org.junit.Test)

Example 9 with Location

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

the class SBOLReader method parseSequenceAnnotation.

/**
 * @param sequenceAnnotation
 * @param nested
 * @return
 * @throws SBOLValidationException if either of the following conditions is satisfied:
 * <ul>
 * <li>any of the following SBOL validation rules was violated:
 * 10203, 10204, 10206, 10208, 10212, 10213,
 * 10512,
 * 10904; or
 *</li>
 * <li>an SBOL validation rule violation occurred in the following constructor or methods:
 * 	<ul>
 * 		<li>{@link #parseLocation(NestedDocument)},</li>
 * 		<li>{@link SequenceAnnotation#SequenceAnnotation(URI, Set)},</li>
 * 		<li>{@link SequenceAnnotation#setDisplayId(String)},</li>
 * 		<li>{@link SequenceAnnotation#setVersion(String)},</li>
 * 		<li>{@link SequenceAnnotation#setComponent(URI)},</li>
 * 		<li>{@link SequenceAnnotation#setWasDerivedFrom(URI)}, or</li>
 * 		<li>{@link Identified#setAnnotations(List)}.</li>
 * 	</ul>
 * </li>
 * </ul>
 */
private static SequenceAnnotation parseSequenceAnnotation(NestedDocument<QName> sequenceAnnotation, Map<URI, NestedDocument<QName>> nested) throws SBOLValidationException {
    // URIcompliance.extractDisplayId(sequenceAnnotation.getIdentity());
    String displayId = null;
    String name = null;
    String description = null;
    // URI.create(URIcompliance.extractPersistentId(sequenceAnnotation.getIdentity()));
    URI persistentIdentity = null;
    Location location = null;
    URI componentURI = null;
    String version = null;
    Set<URI> wasDerivedFroms = new HashSet<>();
    Set<URI> wasGeneratedBys = new HashSet<>();
    Set<URI> roles = new HashSet<>();
    Set<Location> locations = new HashSet<>();
    List<Annotation> annotations = new ArrayList<>();
    for (NamedProperty<QName> namedProperty : sequenceAnnotation.getProperties()) {
        if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
            if (!(namedProperty.getValue() instanceof Literal) || persistentIdentity != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10203", sequenceAnnotation.getIdentity());
            }
            persistentIdentity = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.displayId)) {
            if (!(namedProperty.getValue() instanceof Literal) || displayId != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10204", sequenceAnnotation.getIdentity());
            }
            displayId = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.version)) {
            if (!(namedProperty.getValue() instanceof Literal) || version != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10206", sequenceAnnotation.getIdentity());
            }
            version = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.SequenceAnnotation.roles)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10906", sequenceAnnotation.getIdentity());
            }
            roles.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.Location.Location)) {
            if (namedProperty.getValue() instanceof NestedDocument) {
                NestedDocument<QName> nestedDocument = ((NestedDocument<QName>) namedProperty.getValue());
                if (nestedDocument.getType() == null || !(nestedDocument.getType().equals(Sbol2Terms.Range.Range) || nestedDocument.getType().equals(Sbol2Terms.Cut.Cut) || nestedDocument.getType().equals(Sbol2Terms.GenericLocation.GenericLocation))) {
                    throw new SBOLValidationException("sbol-10902", sequenceAnnotation.getIdentity());
                }
                location = parseLocation((NestedDocument<QName>) namedProperty.getValue());
            } else {
                URI uri = (URI) ((Literal<QName>) namedProperty.getValue()).getValue();
                NestedDocument<QName> nestedDocument = nested.get(uri);
                if (nestedDocument == null || nestedDocument.getType() == null || !(nestedDocument.getType().equals(Sbol2Terms.Range.Range) || nestedDocument.getType().equals(Sbol2Terms.Cut.Cut) || nestedDocument.getType().equals(Sbol2Terms.GenericLocation.GenericLocation))) {
                    throw new SBOLValidationException("sbol-10902", sequenceAnnotation.getIdentity());
                }
                location = parseLocation(nested.get(uri));
            }
            locations.add(location);
        } else if (namedProperty.getName().equals(Sbol2Terms.SequenceAnnotation.hasComponent)) {
            if (!(namedProperty.getValue() instanceof Literal) || componentURI != null || (!(((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(Sbol2Terms.Identified.title)) {
            if (!(namedProperty.getValue() instanceof Literal) || name != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10212", sequenceAnnotation.getIdentity());
            }
            name = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
            if (!(namedProperty.getValue() instanceof Literal) || description != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10213", sequenceAnnotation.getIdentity());
            }
            description = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasDerivedFrom)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10208", sequenceAnnotation.getIdentity());
            }
            wasDerivedFroms.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasGeneratedBy)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10221", sequenceAnnotation.getIdentity());
            }
            wasGeneratedBys.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else {
            annotations.add(new Annotation(namedProperty));
        }
    }
    SequenceAnnotation s = new SequenceAnnotation(sequenceAnnotation.getIdentity(), locations);
    if (persistentIdentity != null)
        s.setPersistentIdentity(persistentIdentity);
    if (version != null)
        s.setVersion(version);
    if (displayId != null)
        s.setDisplayId(displayId);
    if (componentURI != null)
        s.setComponent(componentURI);
    if (name != null)
        s.setName(name);
    if (description != null)
        s.setDescription(description);
    s.setWasDerivedFroms(wasDerivedFroms);
    s.setWasGeneratedBys(wasGeneratedBys);
    if (!annotations.isEmpty())
        s.setAnnotations(annotations);
    if (!roles.isEmpty())
        s.setRoles(roles);
    // }
    return s;
}
Also used : StringifyQName(org.sbolstandard.core.io.json.StringifyQName) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) URI(java.net.URI) NestedDocument(org.sbolstandard.core.datatree.NestedDocument) Literal(org.sbolstandard.core.datatree.Literal) HashSet(java.util.HashSet)

Example 10 with Location

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

the class SBOLReader method parseRange.

/**
 * @param typeRange
 * @return
 * @throws SBOLValidationException if either of the following conditions is satisfied:
 * <ul>
 * <li>any of the following SBOL validation rules was violated:
 * 10201, 10203, 10204, 10206, 10208, 10212, 10213, 11002, 11102, 11103; or
 *</li>
 * <li>an SBOL validation rule violation occurred in the following constructor or methods:
 * 	<ul>
 * 		<li>{@link Range#Range(URI, int, int)},</li>
 * 		<li>{@link Range#setDisplayId(String)},</li>
 * 		<li>{@link Range#setVersion(String)},</li>
 * 		<li>{@link Range#setWasDerivedFrom(URI)}, or</li>
 * 		<li>{@link Identified#setAnnotations(List)}.</li>
 * 	</ul>
 * </li>
 * </ul>
 */
private static Location parseRange(NestedDocument<QName> typeRange) throws SBOLValidationException {
    // URIcompliance.extractDisplayId(typeRange.getIdentity());
    String displayId = null;
    String name = null;
    String description = null;
    // URI.create(URIcompliance.extractPersistentId(typeRange.getIdentity()));
    URI persistentIdentity = null;
    Integer start = null;
    Integer end = null;
    URI orientation = null;
    String version = null;
    Set<URI> wasDerivedFroms = new HashSet<>();
    Set<URI> wasGeneratedBys = new HashSet<>();
    List<Annotation> annotations = new ArrayList<>();
    for (NamedProperty<QName> namedProperty : typeRange.getProperties()) {
        String temp;
        if (namedProperty.getName().equals(Sbol2Terms.Range.start)) {
            if (!(namedProperty.getValue() instanceof Literal) || start != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-11102", typeRange.getIdentity());
            }
            temp = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
            // start = Integer.parseInt(temp);
            try {
                start = Integer.parseInt(temp);
            } catch (NumberFormatException e) {
                throw new SBOLValidationException("sbol-11102", typeRange.getIdentity());
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
            if (!(namedProperty.getValue() instanceof Literal) || persistentIdentity != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10203", typeRange.getIdentity());
            }
            persistentIdentity = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.displayId)) {
            if (!(namedProperty.getValue() instanceof Literal) || displayId != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10204", typeRange.getIdentity());
            }
            displayId = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.title)) {
            if (!(namedProperty.getValue() instanceof Literal) || name != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10212", typeRange.getIdentity());
            }
            name = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
            if (!(namedProperty.getValue() instanceof Literal) || description != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10213", typeRange.getIdentity());
            }
            description = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Range.end)) {
            if (!(namedProperty.getValue() instanceof Literal) || end != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-11103", typeRange.getIdentity());
            }
            temp = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
            // end  = Integer.parseInt(temp);
            try {
                end = Integer.parseInt(temp);
            } catch (NumberFormatException e) {
                throw new SBOLValidationException("sbol-11103", typeRange.getIdentity());
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.Range.orientation)) {
            if (!(namedProperty.getValue() instanceof Literal) || orientation != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-11002", typeRange.getIdentity());
            }
            orientation = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.version)) {
            if (!(namedProperty.getValue() instanceof Literal) || version != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10206", typeRange.getIdentity());
            }
            version = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasDerivedFrom)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10208", typeRange.getIdentity());
            }
            wasDerivedFroms.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasGeneratedBy)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10221", typeRange.getIdentity());
            }
            wasGeneratedBys.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else {
            annotations.add(new Annotation(namedProperty));
        }
    }
    Location r = new Range(typeRange.getIdentity(), start, end);
    if (displayId != null)
        r.setDisplayId(displayId);
    if (name != null)
        r.setName(name);
    if (description != null)
        r.setDescription(description);
    if (persistentIdentity != null)
        r.setPersistentIdentity(persistentIdentity);
    if (orientation != null)
        try {
            r.setOrientation(OrientationType.convertToOrientationType(orientation));
        } catch (SBOLValidationException e) {
            throw new SBOLValidationException("sbol-11002", r);
        }
    if (version != null)
        r.setVersion(version);
    r.setWasDerivedFroms(wasDerivedFroms);
    r.setWasGeneratedBys(wasGeneratedBys);
    if (!annotations.isEmpty())
        r.setAnnotations(annotations);
    return r;
}
Also used : StringifyQName(org.sbolstandard.core.io.json.StringifyQName) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) URI(java.net.URI) Literal(org.sbolstandard.core.datatree.Literal) HashSet(java.util.HashSet)

Aggregations

URI (java.net.URI)10 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)10 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 QName (javax.xml.namespace.QName)3 Literal (org.sbolstandard.core.datatree.Literal)3 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)3 Location (org.openqa.selenium.html5.Location)2 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)2 GenericLocation (org.sbolstandard.core2.GenericLocation)2 Location (org.sbolstandard.core2.Location)2 Component (org.sbolstandard.core2.Component)1 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)1 Cut (org.sbolstandard.core2.Cut)1 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)1 Range (org.sbolstandard.core2.Range)1 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)1