Search in sources :

Example 11 with AminoAcidCode

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

the class FrameshiftHGVSFormat method parseWithMode.

@Override
public SequenceVariation parseWithMode(String source, SequenceVariationBuilder.FluentBuilding builder, ParsingMode mode) throws ParseException {
    Matcher m = PATTERN.matcher(source);
    if (m.matches()) {
        AminoAcidCode affectedAA = AminoAcidCode.parseAminoAcidCode(StringUtils.concat(m.group(1), m.group(2)));
        int affectedAAPos = Integer.parseInt(m.group(3));
        AminoAcidCode newAA = AminoAcidCode.parseAminoAcidCode(StringUtils.concat(m.group(4), m.group(5)));
        int shift = Integer.parseInt(m.group(6));
        if (shift <= 1)
            throw new ParseException("the description of a frame shift variant can not contain " + "“fsTer1”, such a variant is a nonsense variant (see Substitution). The shortest frame shift variant " + "possible contains 'fsTer2' (see http://varnomen.hgvs.org/recommendations/protein/variant/frameshift/)", 0);
        return builder.selectAminoAcid(affectedAA, affectedAAPos).thenFrameshift(newAA, shift).build();
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode) ParseException(java.text.ParseException)

Example 12 with AminoAcidCode

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

the class SubstitutionHGVSFormat method parseWithMode.

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

Example 13 with AminoAcidCode

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

the class DeletionHGVSFormat 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));
        if (m.group(4) == null) {
            return builder.selectAminoAcid(affectedAAFirst, affectedAAPosFirst).thenDelete().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).thenDelete().build();
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode)

Example 14 with AminoAcidCode

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

the class ExtensionInitiationHGVSFormat method parseWithMode.

@Override
public SequenceVariation parseWithMode(String source, SequenceVariationBuilder.FluentBuilding builder, ParsingMode mode) throws ParseException {
    Matcher m = PATTERN.matcher(source);
    if (m.matches()) {
        AminoAcidCode newAminoAcid = AminoAcidCode.METHIONINE;
        if (m.group(1) != null) {
            newAminoAcid = AminoAcidCode.parseAminoAcidCode(m.group(1));
        }
        int newUpstreamPos = Integer.parseInt(m.group(2));
        return builder.selectAminoAcid(AminoAcidCode.METHIONINE, 1).thenInitiationExtension(newUpstreamPos, newAminoAcid).build();
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode)

Example 15 with AminoAcidCode

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

the class ExtensionTerminationHGVSFormat method parseWithMode.

@Override
public SequenceVariation parseWithMode(String source, SequenceVariationBuilder.FluentBuilding builder, ParsingMode mode) throws ParseException {
    Matcher m = PATTERN.matcher(source);
    if (m.matches()) {
        int affectedStopPos = Integer.parseInt(m.group(1));
        AminoAcidCode newAminoAcid = AminoAcidCode.parseAminoAcidCode(m.group(2));
        int newDownstreamPos = Integer.parseInt(m.group(3));
        return builder.selectAminoAcid(AminoAcidCode.STOP, affectedStopPos).thenTerminationExtension(newDownstreamPos, newAminoAcid).build();
    }
    return null;
}
Also used : Matcher(java.util.regex.Matcher) AminoAcidCode(org.nextprot.api.commons.bio.AminoAcidCode)

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