use of org.jbei.ice.lib.dto.DNAFeature in project ice by JBEI.
the class Annotations method generate.
/**
* Auto generate annotations for specified entry
*
* @param entryId unique (local) identifier for entry
* @param ownerFeatures whether to only include the features created by the requesting user
* @return wrapper around generated annotations, if any are found
*/
public FeaturedDNASequence generate(long entryId, boolean ownerFeatures) {
Entry entry = entryDAO.get(entryId);
if (entry == null)
throw new IllegalArgumentException("Could not retrieve entry with id \"" + entryId + "\"");
Sequence sequence = sequenceDAO.getByEntry(entry);
if (sequence == null)
return null;
String sequenceString = sequence.getSequence();
BlastQuery query = new BlastQuery();
query.setSequence(sequenceString);
try {
List<DNAFeature> features = BlastPlus.runCheckFeatures(query);
FeaturedDNASequence dnaSequence = new FeaturedDNASequence();
// check permissions
Account account = accountDAO.getByEmail(userId);
List<Group> groups = this.groupDAO.retrieveMemberGroups(account);
for (DNAFeature dnaFeature : features) {
Feature feature = this.featureDAO.get(dnaFeature.getId());
if (feature == null)
continue;
List<Long> entries = this.sequenceFeatureDAO.getEntryIdsByFeature(feature);
if (entries.isEmpty())
continue;
if (!isAdministrator()) {
entries = this.permissionDAO.getCanReadEntries(account, groups, entries);
if (entries.isEmpty())
continue;
}
if (ownerFeatures) {
entries = this.entryDAO.filterByUserId(this.userId, entries);
}
if (entries != null && !entries.isEmpty()) {
dnaFeature.getEntries().addAll(entries);
dnaSequence.getFeatures().add(dnaFeature);
}
}
dnaSequence.setLength(sequenceString.length());
return dnaSequence;
} catch (BlastException e) {
Logger.error(e);
return null;
}
}
use of org.jbei.ice.lib.dto.DNAFeature in project ice by JBEI.
the class Annotations method get.
/**
* Retrieves list of annotations that are available
*
* @param offset paging start
* @param limit maximum number of annotations to return
* @param sort paging sort
* @return available annotations that conform to parameters along with the total number that are available
* @throws PermissionException if the requesting user's account does not have administrative privileges
*/
public Results<DNAFeatures> get(int offset, int limit, String sort) {
if (!isAdministrator())
throw new PermissionException("Administrative privileges required to retrieve features");
long count = this.featureDAO.getFeaturesGroupByCount();
Results<DNAFeatures> results = new Results<>();
results.setResultCount(count);
Map<String, List<Feature>> map = this.featureDAO.getFeaturesGroupBy(offset, limit);
for (String key : map.keySet()) {
DNAFeatures features = new DNAFeatures(key);
for (Feature feature : map.get(key)) {
DNAFeature dnaFeature = feature.toDataTransferObject();
dnaFeature.setSequence(feature.getSequence());
List<Long> entries = this.sequenceFeatureDAO.getEntryIdsByFeature(feature);
if (entries != null)
dnaFeature.getEntries().addAll(entries);
features.getFeatures().add(dnaFeature);
}
results.getData().add(features);
}
return results;
}
use of org.jbei.ice.lib.dto.DNAFeature in project ice by JBEI.
the class Annotations method filter.
public Results<DNAFeature> filter(int offset, int limit, String filter) {
Account account = accountDAO.getByEmail(userId);
List<Group> groups = new GroupController().getAllGroups(account);
List<SequenceFeature> features = sequenceFeatureDAO.getSequenceFeatures(this.userId, groups, filter, offset, limit);
int count = sequenceFeatureDAO.getSequenceFeaturesCount(this.userId, groups, filter);
Results<DNAFeature> results = new Results<>();
results.setResultCount(count);
for (SequenceFeature feature : features) {
DNAFeature dnaFeature = feature.toDataTransferObject();
Entry entry = feature.getSequence().getEntry();
dnaFeature.setIdentifier(entry.getPartNumber());
DNAFeatureLocation location = new DNAFeatureLocation();
location.setGenbankStart(feature.getUniqueGenbankStart());
location.setEnd(feature.getUniqueEnd());
dnaFeature.getLocations().add(location);
dnaFeature.getEntries().add(entry.getId());
results.getData().add(dnaFeature);
}
return results;
}
Aggregations