use of com.github.lindenb.jvarkit.util.bio.structure.Transcript in project jvarkit by lindenb.
the class BackLocate method run.
private void run(final PrintStream out, final BufferedReader in) throws IOException {
final CharSplitter tab = CharSplitter.TAB;
String line;
while ((line = in.readLine()) != null) {
if (line.startsWith("#") || StringUtils.isBlank(line))
continue;
final String[] tokens = JvarkitException.TokenErrors.atLeast(2, tab.split(line, 3));
final String geneName = tokens[0].trim();
if (StringUtils.isBlank(geneName))
throw new IOException("Bad line. No gene in " + geneName);
final String mut = tokens[1].trim();
int x0 = 0, x1 = 0;
while (x1 < mut.length() && Character.isLetter(mut.charAt(x1))) {
++x1;
}
String substr = mut.substring(x0, x1);
final AminoAcids.AminoAcid aa1 = substr.length() == 1 ? AminoAcids.getAminoAcidFromOneLetterCode(substr.charAt(0)) : AminoAcids.getAminoAcidFromThreeLettersCode(substr);
if (aa1 == null)
throw new JvarkitException.UserError("Bad mutation " + mut + " (cannot parse left AA)");
x0 = x1;
while (x1 < mut.length() && Character.isDigit(mut.charAt(x1))) {
++x1;
}
substr = mut.substring(x0, x1);
if (!StringUtils.isInteger(substr))
throw new JvarkitException.UserError("Bad mutation " + mut + " (cannot parse position)");
final int position1 = Integer.parseInt(substr);
if (position1 == 0)
throw new IOException("Bad position in protein (" + substr + ") in " + line);
substr = mut.substring(x1);
final AminoAcids.AminoAcid aa2 = substr.length() == 1 ? AminoAcids.getAminoAcidFromOneLetterCode(substr.charAt(0)) : AminoAcids.getAminoAcidFromThreeLettersCode(substr);
if (aa2 == null)
throw new JvarkitException.UserError("Bad mutation " + mut + " (cannot parse right AA)");
final List<Transcript> transcripts = this.name2transcripts.get(geneName.toUpperCase());
if (transcripts == null || transcripts.isEmpty()) {
LOG.warn("no transcript found for " + geneName);
continue;
}
for (final Transcript transcript : transcripts) {
backLocate(out, transcript, geneName, aa1, aa2, position1, tokens.length > 2 ? tokens[2] : ".");
}
}
}
Aggregations