Search in sources :

Example 1 with BlastQuery

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

the class Annotations method generate.

/**
     * Using existing and potentially curated annotations on this ICE instance,
     * this generates matching features for the passed sequence
     *
     * @param sequence wrapper around dna sequence
     * @return wrapper around passed sequence and now with list if annotations for that sequence
     */
public FeaturedDNASequence generate(FeaturedDNASequence sequence) {
    BlastQuery query = new BlastQuery();
    query.setSequence(sequence.getSequence());
    try {
        List<DNAFeature> features = BlastPlus.runCheckFeatures(query);
        sequence.getFeatures().addAll(features);
        return sequence;
    } catch (BlastException e) {
        Logger.error(e);
        return null;
    }
}
Also used : BlastQuery(org.jbei.ice.lib.dto.search.BlastQuery) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) BlastException(org.jbei.ice.lib.search.blast.BlastException)

Example 2 with BlastQuery

use of org.jbei.ice.lib.dto.search.BlastQuery 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;
    }
}
Also used : FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) BlastQuery(org.jbei.ice.lib.dto.search.BlastQuery) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) BlastException(org.jbei.ice.lib.search.blast.BlastException)

Aggregations

DNAFeature (org.jbei.ice.lib.dto.DNAFeature)2 BlastQuery (org.jbei.ice.lib.dto.search.BlastQuery)2 BlastException (org.jbei.ice.lib.search.blast.BlastException)2 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1