Search in sources :

Example 1 with SequenceFeature

use of org.nextprot.api.isoform.mapper.domain.SequenceFeature in project nextprot-api by calipho-sib.

the class IsoformMappingServiceImpl method validateFeature.

@Override
public BaseFeatureQueryResult validateFeature(SingleFeatureQuery query) {
    try {
        SequenceFeature sequenceFeature = SequenceFeatureBase.newFeature(query);
        if (Strings.isNullOrEmpty(query.getAccession()))
            query.setAccession(findAccessionFromGeneName(query, sequenceFeature.getGeneName()));
        Entry entry = entryBuilderService.build(EntryConfig.newConfig(query.getAccession()).withTargetIsoforms().withOverview());
        SequenceFeatureValidator validator = new SequenceFeatureValidator(entry, query);
        return validator.validate(sequenceFeature);
    } catch (FeatureQueryException e) {
        return new FeatureQueryFailureImpl(e);
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) SequenceFeatureValidator(org.nextprot.api.isoform.mapper.service.SequenceFeatureValidator) SequenceFeature(org.nextprot.api.isoform.mapper.domain.SequenceFeature) FeatureQueryException(org.nextprot.api.isoform.mapper.domain.FeatureQueryException) FeatureQueryFailureImpl(org.nextprot.api.isoform.mapper.domain.impl.FeatureQueryFailureImpl)

Example 2 with SequenceFeature

use of org.nextprot.api.isoform.mapper.domain.SequenceFeature in project nextprot-api by calipho-sib.

the class IsoformMappingServiceImpl method propagate.

// TODO: refactor this method, it is too complex (probably a propagator object with strategy pattern for the mapping)
private void propagate(SingleFeatureQuerySuccessImpl successResults) throws ParseException {
    SingleFeatureQuery query = successResults.getQuery();
    query.setPropagableFeature(true);
    SequenceFeature isoFeature = successResults.getIsoformSequenceFeature();
    Isoform featureIsoform = isoFeature.getIsoform(successResults.getEntry());
    SequenceVariation variation = isoFeature.getProteinVariation();
    OriginalAminoAcids originalAminoAcids = getOriginalAminoAcids(featureIsoform.getSequence(), variation);
    GeneMasterCodonPosition originalFirstMasterCodonPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(originalAminoAcids.getFirstAAPos(), featureIsoform);
    GeneMasterCodonPosition originalLastMasterCodonPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(originalAminoAcids.getLastAAPos(), featureIsoform);
    // try to propagate the feature to other isoforms
    for (Isoform otherIsoform : IsoformUtils.getOtherIsoforms(successResults.getEntry(), featureIsoform.getIsoformAccession())) {
        Integer firstIsoPos = IsoformSequencePositionMapper.getProjectedPosition(featureIsoform, originalAminoAcids.getFirstAAPos(), otherIsoform);
        Integer lastIsoPos = IsoformSequencePositionMapper.getProjectedPosition(featureIsoform, originalAminoAcids.getLastAAPos(), otherIsoform);
        boolean propagable = false;
        if (firstIsoPos != null && lastIsoPos != null) {
            if (variation.getVaryingSequence().isMultipleAminoAcids()) {
                int originalSequenceLength = lastIsoPos - firstIsoPos + 1;
                int isoformSequenceLength = originalAminoAcids.getAas().length();
                if (originalSequenceLength == isoformSequenceLength) {
                    String isoformSequence = otherIsoform.getSequence().substring(firstIsoPos - 1, lastIsoPos);
                    if (isoformSequence.equals(originalAminoAcids.getAas())) {
                        GeneMasterCodonPosition firstMasterCodonPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(firstIsoPos, otherIsoform);
                        GeneMasterCodonPosition lastMasterCodonPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(lastIsoPos, otherIsoform);
                        propagable = firstMasterCodonPos.getNucleotidePosition(0).intValue() == originalFirstMasterCodonPos.getNucleotidePosition(0) && lastMasterCodonPos.getNucleotidePosition(2).intValue() == originalLastMasterCodonPos.getNucleotidePosition(2);
                    }
                }
            } else // check a single amino-acid
            {
                propagable = IsoformSequencePositionMapper.checkAminoAcidsFromPosition(otherIsoform, firstIsoPos, originalAminoAcids.getAas());
            }
        }
        if (propagable) {
            addPropagation(otherIsoform, firstIsoPos, lastIsoPos, originalAminoAcids.isExtensionTerminal(), successResults);
        } else {
            successResults.addUnmappedFeature(otherIsoform);
        }
    }
}
Also used : SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) GeneMasterCodonPosition(org.nextprot.api.core.utils.seqmap.GeneMasterCodonPosition) SequenceVariation(org.nextprot.api.commons.bio.variation.prot.SequenceVariation) SequenceFeature(org.nextprot.api.isoform.mapper.domain.SequenceFeature) Isoform(org.nextprot.api.core.domain.Isoform)

Aggregations

SequenceFeature (org.nextprot.api.isoform.mapper.domain.SequenceFeature)2 SequenceVariation (org.nextprot.api.commons.bio.variation.prot.SequenceVariation)1 Entry (org.nextprot.api.core.domain.Entry)1 Isoform (org.nextprot.api.core.domain.Isoform)1 GeneMasterCodonPosition (org.nextprot.api.core.utils.seqmap.GeneMasterCodonPosition)1 FeatureQueryException (org.nextprot.api.isoform.mapper.domain.FeatureQueryException)1 SingleFeatureQuery (org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery)1 FeatureQueryFailureImpl (org.nextprot.api.isoform.mapper.domain.impl.FeatureQueryFailureImpl)1 SequenceFeatureValidator (org.nextprot.api.isoform.mapper.service.SequenceFeatureValidator)1