Search in sources :

Example 1 with DnaSequence

use of org.sbolstandard.core.DnaSequence in project ice by JBEI.

the class ICESBOLParserVisitor method visit.

@Override
public void visit(DnaComponent component) {
    if (featuredDNASequence == null) {
        featuredDNASequence = new FeaturedDNASequence();
        if (update != null) {
            String name = component.getName();
            if (name == null || name.trim().isEmpty())
                update.getKeyValue().put(EntryFieldLabel.NAME, name);
            else {
                update.getKeyValue().put(EntryFieldLabel.NAME, name);
                update.getKeyValue().put(EntryFieldLabel.ALIAS, component.getDisplayId());
            }
            update.getKeyValue().put(EntryFieldLabel.SUMMARY, component.getDescription());
        }
        featuredDNASequence.setName(component.getName());
        featuredDNASequence.setIdentifier(component.getDisplayId());
        featuredDNASequence.setDescription(component.getDescription());
        featuredDNASequence.setDcUri(component.getURI().toString());
        DnaSequence sequence = component.getDnaSequence();
        if (sequence != null) {
            featuredDNASequence.setSequence(sequence.getNucleotides());
            featuredDNASequence.setUri(sequence.getURI().toString());
        }
    }
    List<SequenceAnnotation> annotations = component.getAnnotations();
    Logger.debug("Encountered DC " + component.getDisplayId());
    if (!annotations.isEmpty()) {
        // iterate sorted annotations for top level
        for (SequenceAnnotation sequenceAnnotation : annotations) {
            int strand;
            if (sequenceAnnotation.getStrand() == null) {
                strand = 1;
            } else {
                strand = sequenceAnnotation.getStrand() == StrandType.POSITIVE ? 1 : -1;
            }
            Pair relative = new Pair(sequenceAnnotation.getBioStart(), sequenceAnnotation.getBioEnd(), strand);
            walkTree(sequenceAnnotation, relative);
            DNAFeature feature = createDNAFeature(sequenceAnnotation, relative);
            DNAFeatureLocation location = feature.getLocations().get(0);
            featuredDNASequence.getFeatures().add(feature);
            Logger.debug("Adding feature [" + location.getGenbankStart() + ", " + location.getEnd() + "] for " + feature.getIdentifier());
        }
    }
}
Also used : DNAFeatureLocation(org.jbei.ice.lib.dto.DNAFeatureLocation) SequenceAnnotation(org.sbolstandard.core.SequenceAnnotation) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) DnaSequence(org.sbolstandard.core.DnaSequence)

Aggregations

DNAFeature (org.jbei.ice.lib.dto.DNAFeature)1 DNAFeatureLocation (org.jbei.ice.lib.dto.DNAFeatureLocation)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 DnaSequence (org.sbolstandard.core.DnaSequence)1 SequenceAnnotation (org.sbolstandard.core.SequenceAnnotation)1