Search in sources :

Example 16 with AminoAcidCode

use of org.nextprot.api.commons.bio.AminoAcidCode in project nextprot-api by calipho-sib.

the class InsertionHGVSFormat method parseWithMode.

@Override
public SequenceVariation parseWithMode(String source, SequenceVariationBuilder.FluentBuilding builder, ParsingMode mode) throws ParseException {
    Matcher m = PATTERN.matcher(source);
    if (m.matches()) {
        AminoAcidCode affectedAAFirst = AminoAcidCode.parseAminoAcidCode(StringUtils.concat(m.group(1), m.group(2)));
        int affectedAAPosFirst = Integer.parseInt(m.group(3));
        AminoAcidCode affectedAALast = AminoAcidCode.parseAminoAcidCode(StringUtils.concat(m.group(4), m.group(5)));
        int affectedAAPosLast = Integer.parseInt(m.group(6));
        if (affectedAAPosLast != (affectedAAPosFirst + 1)) {
            throw new ParseException("should contain two flanking residues, e.g. Lys23 and Leu24", 0);
        }
        AminoAcidCode[] insertedAAs = AminoAcidCode.valueOfAminoAcidCodeSequence(m.group(7));
        return builder.selectAminoAcidRange(affectedAAFirst, affectedAAPosFirst, affectedAALast, affectedAAPosLast).thenInsert(insertedAAs).build();
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode) ParseException(java.text.ParseException)

Example 17 with AminoAcidCode

use of org.nextprot.api.commons.bio.AminoAcidCode in project nextprot-api by calipho-sib.

the class SingleModificationBEDFormat method parse.

@Override
public SequenceVariation parse(String source, SequenceVariationBuilder.FluentBuilding builder) throws ParseException {
    Matcher m = PATTERN.matcher(source);
    if (m.matches()) {
        AminoAcidModification aaChange = AminoAcidModification.valueOfAminoAcidModification(m.group(1));
        AminoAcidCode affectedAA = AminoAcidCode.parseAminoAcidCode(m.group(2) + ((m.group(3) != null) ? m.group(3) : ""));
        int affectedAAPos = Integer.parseInt(m.group(4));
        return builder.selectAminoAcid(affectedAA, affectedAAPos).thenAddModification(aaChange).build();
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) AminoAcidModification(org.nextprot.api.commons.bio.variation.prot.impl.seqchange.AminoAcidModification) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode)

Example 18 with AminoAcidCode

use of org.nextprot.api.commons.bio.AminoAcidCode in project nextprot-api by calipho-sib.

the class DuplicationHGVSFormat method parseWithMode.

@Override
public SequenceVariation parseWithMode(String source, SequenceVariationBuilder.FluentBuilding builder, ParsingMode mode) throws ParseException {
    Matcher m = PATTERN.matcher(source);
    if (m.matches()) {
        AminoAcidCode affectedAAFirst = AminoAcidCode.parseAminoAcidCode(StringUtils.concat(m.group(1), m.group(2)));
        int affectedAAPosFirst = Integer.parseInt(m.group(3));
        if (m.group(4) == null) {
            return builder.selectAminoAcid(affectedAAFirst, affectedAAPosFirst).thenDuplicate().build();
        }
        AminoAcidCode affectedAALast = AminoAcidCode.parseAminoAcidCode(StringUtils.concat(m.group(4), m.group(5)));
        int affectedAAPosLast = Integer.parseInt(m.group(6));
        return builder.selectAminoAcidRange(affectedAAFirst, affectedAAPosFirst, affectedAALast, affectedAAPosLast).thenDuplicate().build();
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode)

Example 19 with AminoAcidCode

use of org.nextprot.api.commons.bio.AminoAcidCode in project nextprot-api by calipho-sib.

the class DeletionInsertionHGVSFormat method parseWithMode.

@Override
public SequenceVariation parseWithMode(String source, SequenceVariationBuilder.FluentBuilding builder, ParsingMode mode) throws ParseException {
    Matcher m = (mode == ParsingMode.STRICT) ? PATTERN.matcher(source) : PATTERN_PERMISSIVE.matcher(source);
    if (m.matches()) {
        AminoAcidCode affectedAAFirst = AminoAcidCode.parseAminoAcidCode(StringUtils.concat(m.group(1), m.group(2)));
        int affectedAAPosFirst = Integer.parseInt(m.group(3));
        AminoAcidCode[] insertedAAs = AminoAcidCode.valueOfAminoAcidCodeSequence(m.group(7));
        if (m.group(4) == null) {
            return builder.selectAminoAcid(affectedAAFirst, affectedAAPosFirst).thenDeleteAndInsert(insertedAAs).build();
        }
        AminoAcidCode affectedAALast = AminoAcidCode.parseAminoAcidCode(StringUtils.concat(m.group(4), m.group(5)));
        int affectedAAPosLast = Integer.parseInt(m.group(6));
        return builder.selectAminoAcidRange(affectedAAFirst, affectedAAPosFirst, affectedAALast, affectedAAPosLast).thenDeleteAndInsert(insertedAAs).build();
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode)

Example 20 with AminoAcidCode

use of org.nextprot.api.commons.bio.AminoAcidCode in project nextprot-api by calipho-sib.

the class IsoformMappingServiceTest method shouldNotValidateIncorrectAAVariantIsoform.

@Test
public void shouldNotValidateIncorrectAAVariantIsoform() throws Exception {
    FeatureQueryResult result = service.validateFeature(new SingleFeatureQuery("SCN11A-p.Met1158Pro", AnnotationCategory.VARIANT.getApiTypeName(), "NX_Q9UI33"));
    SingleFeatureQuery query = Mockito.mock(SingleFeatureQuery.class);
    when(query.getAccession()).thenReturn("NX_Q9UI33");
    when(query.getFeature()).thenReturn("SCN11A-p.Met1158Pro");
    assertIsoformFeatureNotValid((FeatureQueryFailure) result, new UnexpectedFeatureQueryAminoAcidException(query, 1158, new AminoAcidCode[] { AminoAcidCode.LEUCINE }, new AminoAcidCode[] { AminoAcidCode.METHIONINE }));
}
Also used : FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode) IsoformMappingBaseTest(org.nextprot.api.isoform.mapper.IsoformMappingBaseTest) Test(org.junit.Test)

Aggregations

AminoAcidCode (org.nextprot.api.commons.bio.AminoAcidCode)28 Test (org.junit.Test)19 SequenceVariation (org.nextprot.api.commons.bio.variation.prot.SequenceVariation)18 Matcher (java.util.regex.Matcher)9 ParseException (java.text.ParseException)2 AminoAcidModification (org.nextprot.api.commons.bio.variation.prot.impl.seqchange.AminoAcidModification)1 IsoformMappingBaseTest (org.nextprot.api.isoform.mapper.IsoformMappingBaseTest)1 FeatureQueryResult (org.nextprot.api.isoform.mapper.domain.FeatureQueryResult)1 SingleFeatureQuery (org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery)1