Search in sources :

Example 6 with DNAFeature

use of org.jbei.ice.lib.dto.DNAFeature in project ice by JBEI.

the class Feature method toDataTransferObject.

@Override
public DNAFeature toDataTransferObject() {
    DNAFeature dnaFeature = new DNAFeature();
    dnaFeature.setId(this.id);
    dnaFeature.setAnnotationType(this.genbankType);
    dnaFeature.setName(this.name);
    dnaFeature.setUri(this.uri);
    if (this.curation != null) {
        dnaFeature.setCuration(this.curation.toDataTransferObject());
    }
    return dnaFeature;
}
Also used : DNAFeature(org.jbei.ice.lib.dto.DNAFeature)

Example 7 with DNAFeature

use of org.jbei.ice.lib.dto.DNAFeature in project ice by JBEI.

the class AnnotationsTest method testCurate.

@Test
public void testCurate() throws Exception {
    Account account = AccountCreator.createTestAccount("AnnotationsTest.testCurate", true);
    Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
    SequenceDAO sequenceDAO = new SequenceDAO();
    Assert.assertFalse(sequenceDAO.hasSequence(plasmid.getId()));
    DNASequence dnaSequence = GeneralParser.getInstance().parse(sequenceString);
    Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
    sequence.setEntry(plasmid);
    sequence = sequenceDAO.saveSequence(sequence);
    Assert.assertNotNull(sequence);
    SequenceFeatureDAO sequenceFeatureDAO = new SequenceFeatureDAO();
    List<SequenceFeature> sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
    Assert.assertEquals(1, sequenceFeatures.size());
    Feature feature = sequenceFeatures.get(0).getFeature();
    DNAFeature dnaFeature = feature.toDataTransferObject();
    Curation curation = new Curation();
    curation.setExclude(true);
    dnaFeature.setCuration(curation);
    List<DNAFeature> features = new ArrayList<>();
    features.add(dnaFeature);
    Annotations annotations = new Annotations(account.getEmail());
    annotations.curate(features);
    sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
    feature = sequenceFeatures.get(0).getFeature();
    Assert.assertTrue(feature.getCuration().isExclude());
}
Also used : Curation(org.jbei.ice.lib.dto.Curation) ArrayList(java.util.ArrayList) DNASequence(org.jbei.ice.lib.dto.DNASequence) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) SequenceFeatureDAO(org.jbei.ice.storage.hibernate.dao.SequenceFeatureDAO) DNASequence(org.jbei.ice.lib.dto.DNASequence) SequenceDAO(org.jbei.ice.storage.hibernate.dao.SequenceDAO) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) Test(org.junit.Test)

Example 8 with DNAFeature

use of org.jbei.ice.lib.dto.DNAFeature 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)

Example 9 with DNAFeature

use of org.jbei.ice.lib.dto.DNAFeature in project ice by JBEI.

the class SequenceFeature method toDataTransferObject.

@Override
public DNAFeature toDataTransferObject() {
    DNAFeature dnaFeature = new DNAFeature();
    dnaFeature.setName(this.name);
    dnaFeature.setType(this.genbankType);
    return dnaFeature;
}
Also used : DNAFeature(org.jbei.ice.lib.dto.DNAFeature)

Example 10 with DNAFeature

use of org.jbei.ice.lib.dto.DNAFeature in project ice by JBEI.

the class Annotations method curate.

/**
     * Curates a specified set of annotations. The curation properties are contained in each annotation (feature)
     * object
     *
     * @param features set of features to be curated
     */
public void curate(List<DNAFeature> features) {
    if (!isAdministrator())
        throw new PermissionException("Administrative privileges required to curate features");
    for (DNAFeature dnaFeature : features) {
        if (dnaFeature.getCuration() == null)
            continue;
        Feature feature = featureDAO.get(dnaFeature.getId());
        if (feature == null)
            continue;
        FeatureCurationModel curationModel = feature.getCuration();
        if (feature.getCuration() == null) {
            if (dnaFeature.getCuration().isExclude()) {
                curationModel = new FeatureCurationModel();
                curationModel.setFeature(feature);
                curationModel.setExclude(true);
                curationModel = curationModelDAO.create(curationModel);
            }
        } else {
            curationModel.setExclude(dnaFeature.getCuration().isExclude());
            curationModel = curationModelDAO.update(curationModel);
        }
        if (curationModel != null) {
            feature.setCuration(curationModel);
            featureDAO.update(feature);
        }
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) DNAFeature(org.jbei.ice.lib.dto.DNAFeature)

Aggregations

DNAFeature (org.jbei.ice.lib.dto.DNAFeature)13 DNAFeatureLocation (org.jbei.ice.lib.dto.DNAFeatureLocation)5 PermissionException (org.jbei.ice.lib.access.PermissionException)3 ArrayList (java.util.ArrayList)2 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)2 Results (org.jbei.ice.lib.dto.common.Results)2 BlastQuery (org.jbei.ice.lib.dto.search.BlastQuery)2 BlastException (org.jbei.ice.lib.search.blast.BlastException)2 SequenceAnnotation (org.sbolstandard.core.SequenceAnnotation)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 CSVReader (com.opencsv.CSVReader)1 Type (java.lang.reflect.Type)1 List (java.util.List)1 MediaType (javax.ws.rs.core.MediaType)1 Curation (org.jbei.ice.lib.dto.Curation)1 DNAFeatures (org.jbei.ice.lib.dto.DNAFeatures)1 DNASequence (org.jbei.ice.lib.dto.DNASequence)1 Annotations (org.jbei.ice.lib.entry.sequence.annotation.Annotations)1 GroupController (org.jbei.ice.lib.group.GroupController)1