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;
}
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());
}
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());
}
}
}
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;
}
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);
}
}
}
Aggregations