* for a peptide-to-CDS mapping
*/
int[] codonIntervals = mapping.getMap().locateInFrom(toPosition, toPosition);
- if (codonIntervals != null)
+ int[] codonPositions = codonIntervals == null ? null
+ : MappingUtils.flattenRanges(codonIntervals);
+ if (codonPositions != null && codonPositions.length == 3)
{
- codonPos = MappingUtils.flattenRanges(codonIntervals);
- if (codonPos.length == 3)
- {
- baseCodon = new char[3];
- int cdsStart = fromSeq.getStart();
- baseCodon[0] = fromSeq.getCharAt(codonPos[0] - cdsStart);
- baseCodon[1] = fromSeq.getCharAt(codonPos[1] - cdsStart);
- baseCodon[2] = fromSeq.getCharAt(codonPos[2] - cdsStart);
- }
- else
- {
- baseCodon = null;
- }
+ codonPos = codonPositions;
+ baseCodon = new char[3];
+ int cdsStart = fromSeq.getStart();
+ baseCodon[0] = fromSeq.getCharAt(codonPos[0] - cdsStart);
+ baseCodon[1] = fromSeq.getCharAt(codonPos[1] - cdsStart);
+ baseCodon[2] = fromSeq.getCharAt(codonPos[2] - cdsStart);
}
else
{
codonPos = null;
- baseCodon = null; // todo tidy!
+ baseCodon = null;
}
}
if (colonPos >= 0)
{
String var = hgvsp.substring(colonPos + 1);
- return var;
+ if (var.contains("p.")) // sanity check
+ {
+ return var;
+ }
}
}
/*
* otherwise, compute codon and peptide variant
*/
- // todo avoid duplication of code in AlignmentUtils.buildDnaVariantsMap
int cdsPos = sf.getBegin();
if (cdsPos != sf.getEnd())
{