Search in sources :

Example 6 with NamedProperty

use of org.sbolstandard.core.datatree.Datatree.NamedProperty in project libSBOLj by SynBioDex.

the class SBOLWriter method formatParticipations.

private static List<NestedDocument<QName>> formatParticipations(Set<Participation> participations) {
    List<NestedDocument<QName>> nestedDoc = new ArrayList<>();
    for (Participation p : participations) {
        List<NamedProperty<QName>> list = new ArrayList<>();
        formatCommonIdentifiedData(list, p);
        for (URI r : p.getRoles()) list.add(NamedProperty(Sbol2Terms.Participation.role, r));
        list.add(NamedProperty(Sbol2Terms.Participation.hasParticipant, p.getParticipantURI()));
        nestedDoc.add(NestedDocument(Sbol2Terms.Participation.Participation, p.getIdentity(), NamedProperties(list)));
    }
    return nestedDoc;
}
Also used : NamedProperty(org.sbolstandard.core.datatree.NamedProperty) NamedProperty(org.sbolstandard.core.datatree.Datatree.NamedProperty) ArrayList(java.util.ArrayList) NestedDocument(org.sbolstandard.core.datatree.NestedDocument) NestedDocument(org.sbolstandard.core.datatree.Datatree.NestedDocument) URI(java.net.URI)

Example 7 with NamedProperty

use of org.sbolstandard.core.datatree.Datatree.NamedProperty in project libSBOLj by SynBioDex.

the class SBOLWriter method getSubComponent.

private static NestedDocument<QName> getSubComponent(ComponentDefinition componentDefinition) throws SBOLConversionException {
    List<NamedProperty<QName>> list = new ArrayList<>();
    if (componentDefinition == null) {
        throw new SBOLConversionException("ComponentDefinition not found.\n:");
    }
    if (!componentDefinition.getTypes().contains(ComponentDefinition.DNA)) {
        throw new SBOLConversionException("SBOL 1.1 only supports DNA ComponentDefinitions.\n:" + componentDefinition.getIdentity());
    }
    if (componentDefinition.isSetDisplayId())
        list.add(NamedProperty(Sbol1Terms.DNAComponent.displayId, componentDefinition.getDisplayId()));
    if (componentDefinition.isSetName())
        list.add(NamedProperty(Sbol1Terms.DNAComponent.name, componentDefinition.getName()));
    if (componentDefinition.isSetDescription())
        list.add(NamedProperty(Sbol1Terms.DNAComponent.description, componentDefinition.getDescription()));
    for (Annotation annotation : componentDefinition.getAnnotations()) {
        if (!annotation.getValue().getName().getPrefix().equals("sbol"))
            list.add(annotation.getValue());
    }
    for (URI role : componentDefinition.getRoles()) {
        URI purlRole = URI.create(role.toString().replace("http://identifiers.org/so/SO:", "http://purl.obolibrary.org/obo/SO_"));
        list.add(NamedProperty(Sbol1Terms.DNAComponent.type, purlRole));
    }
    Sequence sequence = componentDefinition.getSequenceByEncoding(Sequence.IUPAC_DNA);
    if ((sequence == null && componentDefinition.getSequences().size() > 0) || (componentDefinition.getSequences().size() > 1)) {
        if (keepGoing) {
            errors.add("SBOL 1.1 only supports a single IUPAC_DNA Sequence.\n:" + componentDefinition.getIdentity());
        } else {
            throw new SBOLConversionException("SBOL 1.1 only supports a single IUPAC_DNA Sequence.\n:" + componentDefinition.getIdentity());
        }
    }
    if (sequence != null) {
        list.add(NamedProperty(Sbol1Terms.DNAComponent.dnaSequence, getSequenceV1(sequence)));
    }
    for (Component component : componentDefinition.getComponents()) {
        SequenceAnnotation sequenceAnnotation = componentDefinition.getSequenceAnnotation(component);
        if (sequenceAnnotation != null) {
            list.add(NamedProperty(Sbol1Terms.DNAComponent.annotations, getSequenceAnnotationV1(sequenceAnnotation, componentDefinition)));
        } else {
            list.add(NamedProperty(Sbol1Terms.DNAComponent.annotations, getComponentV1(component, componentDefinition)));
        }
    }
    for (SequenceAnnotation sequenceAnnotation : componentDefinition.getSequenceAnnotations()) {
        if (!sequenceAnnotation.isSetComponent()) {
            if (keepGoing) {
                errors.add("Dropping SequenceAnnotation without a Component.\n:" + sequenceAnnotation.getIdentity());
            } else {
                throw new SBOLConversionException("Dropping SequenceAnnotation without a Component.\n:" + sequenceAnnotation.getIdentity());
            }
        }
    }
    return NestedDocument(Sbol1Terms.DNAComponent.DNAComponent, componentDefinition.getIdentity(), NamedProperties(list));
}
Also used : NamedProperty(org.sbolstandard.core.datatree.NamedProperty) NamedProperty(org.sbolstandard.core.datatree.Datatree.NamedProperty) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 8 with NamedProperty

use of org.sbolstandard.core.datatree.Datatree.NamedProperty in project libSBOLj by SynBioDex.

the class SBOLWriter method formatInteractions.

/**
 * formatInteractions for Module
 * @param interactions
 * @param properties
 */
private static void formatInteractions(Set<Interaction> interactions, List<NamedProperty<QName>> properties) {
    for (Interaction i : interactions) {
        List<NamedProperty<QName>> list = new ArrayList<>();
        formatCommonIdentifiedData(list, i);
        for (URI type : i.getTypes()) {
            list.add(NamedProperty(Sbol2Terms.Interaction.type, type));
        }
        List<NestedDocument<QName>> participantList = formatParticipations(i.getParticipations());
        for (NestedDocument<QName> n : participantList) {
            list.add(NamedProperty(Sbol2Terms.Interaction.hasParticipations, n));
        }
        properties.add(NamedProperty(Sbol2Terms.ModuleDefinition.hasInteractions, NestedDocument(Sbol2Terms.Interaction.Interaction, i.getIdentity(), NamedProperties(list))));
    }
}
Also used : StringifyQName(org.sbolstandard.core.io.json.StringifyQName) QName(javax.xml.namespace.QName) NamedProperty(org.sbolstandard.core.datatree.NamedProperty) NamedProperty(org.sbolstandard.core.datatree.Datatree.NamedProperty) ArrayList(java.util.ArrayList) URI(java.net.URI) NestedDocument(org.sbolstandard.core.datatree.NestedDocument) NestedDocument(org.sbolstandard.core.datatree.Datatree.NestedDocument)

Example 9 with NamedProperty

use of org.sbolstandard.core.datatree.Datatree.NamedProperty in project libSBOLj by SynBioDex.

the class SBOLWriter method formatUsages.

private static void formatUsages(Set<Usage> usages, List<NamedProperty<QName>> properties) {
    for (Usage usage : usages) {
        List<NamedProperty<QName>> list = new ArrayList<>();
        formatCommonIdentifiedData(list, usage);
        for (URI role : usage.getRoles()) {
            list.add(NamedProperty(Sbol2Terms.Usage.role, role));
        }
        list.add(NamedProperty(Sbol2Terms.Usage.entity, usage.getEntityURI()));
        properties.add(NamedProperty(Sbol2Terms.Activity.qualifiedUsage, NestedDocument(Sbol2Terms.Usage.Usage, usage.getIdentity(), NamedProperties(list))));
    }
}
Also used : NamedProperty(org.sbolstandard.core.datatree.NamedProperty) NamedProperty(org.sbolstandard.core.datatree.Datatree.NamedProperty) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 10 with NamedProperty

use of org.sbolstandard.core.datatree.Datatree.NamedProperty in project libSBOLj by SynBioDex.

the class SBOLWriter method formatDNAComponent.

private static void formatDNAComponent(ComponentDefinition componentDefinition, List<TopLevelDocument<QName>> topLevelDoc) throws SBOLConversionException {
    List<NamedProperty<QName>> list = new ArrayList<>();
    if (componentDefinition.isSetDisplayId())
        list.add(NamedProperty(Sbol1Terms.DNAComponent.displayId, componentDefinition.getDisplayId()));
    if (componentDefinition.isSetName())
        list.add(NamedProperty(Sbol1Terms.DNAComponent.name, componentDefinition.getName()));
    if (componentDefinition.isSetDescription())
        list.add(NamedProperty(Sbol1Terms.DNAComponent.description, componentDefinition.getDescription()));
    for (Annotation annotation : componentDefinition.getAnnotations()) {
        if (!annotation.getValue().getName().getPrefix().equals("sbol"))
            list.add(annotation.getValue());
    }
    for (URI role : componentDefinition.getRoles()) {
        URI purlRole = URI.create(role.toString().replace("http://identifiers.org/so/SO:", "http://purl.obolibrary.org/obo/SO_"));
        list.add(NamedProperty(Sbol1Terms.DNAComponent.type, purlRole));
    }
    Sequence sequence = componentDefinition.getSequenceByEncoding(Sequence.IUPAC_DNA);
    if ((sequence == null && componentDefinition.getSequences().size() > 0) || (componentDefinition.getSequences().size() > 1)) {
        if (keepGoing) {
            errors.add("SBOL 1.1 only supports a single IUPAC_DNA Sequence.\n:" + componentDefinition.getIdentity());
        } else {
            throw new SBOLConversionException("SBOL 1.1 only supports a single IUPAC_DNA Sequence.\n:" + componentDefinition.getIdentity());
        }
    }
    if (sequence != null) {
        list.add(NamedProperty(Sbol1Terms.DNAComponent.dnaSequence, getSequenceV1(sequence)));
    }
    for (Component component : componentDefinition.getComponents()) {
        SequenceAnnotation sequenceAnnotation = componentDefinition.getSequenceAnnotation(component);
        if (sequenceAnnotation != null) {
            list.add(NamedProperty(Sbol1Terms.DNAComponent.annotations, getSequenceAnnotationV1(sequenceAnnotation, componentDefinition)));
        } else {
            list.add(NamedProperty(Sbol1Terms.DNAComponent.annotations, getComponentV1(component, componentDefinition)));
        }
    }
    for (SequenceAnnotation sequenceAnnotation : componentDefinition.getSequenceAnnotations()) {
        if (!sequenceAnnotation.isSetComponent()) {
            if (keepGoing) {
                errors.add("Dropping SequenceAnnotation without a Component.\n:" + sequenceAnnotation.getIdentity());
            } else {
                throw new SBOLConversionException("Dropping SequenceAnnotation without a Component.\n:" + sequenceAnnotation.getIdentity());
            }
        }
    }
    topLevelDoc.add(TopLevelDocument(Sbol1Terms.DNAComponent.DNAComponent, componentDefinition.getIdentity(), NamedProperties(list)));
}
Also used : NamedProperty(org.sbolstandard.core.datatree.NamedProperty) NamedProperty(org.sbolstandard.core.datatree.Datatree.NamedProperty) ArrayList(java.util.ArrayList) URI(java.net.URI)

Aggregations

URI (java.net.URI)12 ArrayList (java.util.ArrayList)12 NamedProperty (org.sbolstandard.core.datatree.Datatree.NamedProperty)12 NamedProperty (org.sbolstandard.core.datatree.NamedProperty)12 NestedDocument (org.sbolstandard.core.datatree.Datatree.NestedDocument)3 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)3 QName (javax.xml.namespace.QName)2 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)2