Search in sources :

Example 1 with SequenceAnnotation

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

the class ICESBOLParserVisitor method walkTree.

private void walkTree(SequenceAnnotation parent, Pair relativePair) {
    List<SequenceAnnotation> annotations = parent.getSubComponent().getAnnotations();
    if (!annotations.isEmpty()) {
        for (SequenceAnnotation sequenceAnnotation : annotations) {
            int strand;
            if (sequenceAnnotation.getStrand() == null) {
                strand = relativePair.getStrand();
            } else {
                strand = sequenceAnnotation.getStrand() == StrandType.POSITIVE ? relativePair.getStrand() : relativePair.getStrand() * -1;
            }
            Pair newRelativePair;
            if (strand > 0)
                newRelativePair = calculatePairForPositiveStrand(sequenceAnnotation, relativePair);
            else
                newRelativePair = calculatePairForNegativeStrand(sequenceAnnotation, relativePair);
            walkTree(sequenceAnnotation, newRelativePair);
            DNAFeature feature = createDNAFeature(sequenceAnnotation, newRelativePair);
            DNAFeatureLocation location = feature.getLocations().get(0);
            featuredDNASequence.getFeatures().add(feature);
            Logger.debug("Adding feature " + strand + "[" + 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)

Example 2 with SequenceAnnotation

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

the class PigeonSBOLv method toPigeon.

private static String toPigeon(DnaComponent component, StrandType strandType, boolean addLabel) {
    if (component == null)
        return "";
    StringBuilder sb = new StringBuilder();
    if (component.getAnnotations() == null || component.getAnnotations().isEmpty()) {
        Iterator<URI> it = component.getTypes().iterator();
        if (!it.hasNext())
            return "";
        URI uri = it.next();
        String soType = uri.getPath().substring(uri.getPath().lastIndexOf("/") + 1);
        String pigeonTypeAndColor = map.get(soType);
        if (pigeonTypeAndColor != null && !pigeonTypeAndColor.isEmpty()) {
            String[] split = pigeonTypeAndColor.split(",");
            String pigeonType;
            if (strandType != null && strandType == StrandType.NEGATIVE && !split[0].equalsIgnoreCase("s") && !split[0].equalsIgnoreCase("x") && !split[0].equalsIgnoreCase("z"))
                pigeonType = "<" + split[0];
            else
                pigeonType = split[0];
            String replacedSpaces = component.getName().replaceAll(" ", "_");
            if (replacedSpaces.trim().isEmpty())
                replacedSpaces = "unnamed";
            sb.append(pigeonType).append(" ").append(replacedSpaces).append(" ").append(split[1]);
            if (!addLabel)
                sb.append(" nl");
            sb.append(NEWLINE);
        }
    } else {
        for (SequenceAnnotation sa : component.getAnnotations()) {
            sb.append(toPigeon(sa.getSubComponent(), sa.getStrand(), false));
        }
    }
    return sb.toString();
}
Also used : SequenceAnnotation(org.sbolstandard.core.SequenceAnnotation) URI(java.net.URI)

Example 3 with SequenceAnnotation

use of org.sbolstandard.core.SequenceAnnotation 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(EntryField.NAME, name);
            else {
                update.getKeyValue().put(EntryField.NAME, name);
                update.getKeyValue().put(EntryField.ALIAS, component.getDisplayId());
            }
            update.getKeyValue().put(EntryField.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

SequenceAnnotation (org.sbolstandard.core.SequenceAnnotation)3 DNAFeature (org.jbei.ice.lib.dto.DNAFeature)2 DNAFeatureLocation (org.jbei.ice.lib.dto.DNAFeatureLocation)2 URI (java.net.URI)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 DnaSequence (org.sbolstandard.core.DnaSequence)1