From 6a99631de459c9ba52894900d08be0a2d6500488 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 30 Jan 2018 15:57:03 +0000 Subject: [PATCH] JAL-2898 show 'stop_gained' variants on peptide sequences --- src/jalview/analysis/AlignmentUtils.java | 12 ++++-- src/jalview/analysis/Dna.java | 10 ++--- src/jalview/io/gff/SequenceOntologyI.java | 3 ++ src/jalview/schemes/ResidueProperties.java | 52 ++++++++++++------------ test/jalview/analysis/AlignmentUtilsTests.java | 34 ++++++++-------- 5 files changed, 61 insertions(+), 50 deletions(-) diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 3d22115..bdc5fc1 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -465,7 +465,7 @@ public class AlignmentUtils { String lastCodon = String.valueOf(cdnaSeqChars, cdnaLength - CODON_LENGTH, CODON_LENGTH).toUpperCase(); - for (String stop : ResidueProperties.STOP) + for (String stop : ResidueProperties.STOP_CODONS) { if (lastCodon.equals(stop)) { @@ -536,7 +536,8 @@ public class AlignmentUtils * allow * in protein to match untranslatable in dna */ final char aaRes = aaSeqChars[aaPos]; - if ((translated == null || "STOP".equals(translated)) && aaRes == '*') + if ((translated == null || ResidueProperties.STOP.equals(translated)) + && aaRes == '*') { continue; } @@ -568,7 +569,8 @@ public class AlignmentUtils if (dnaPos == cdnaSeqChars.length - CODON_LENGTH) { String codon = String.valueOf(cdnaSeqChars, dnaPos, CODON_LENGTH); - if ("STOP".equals(ResidueProperties.codonTranslate(codon))) + if (ResidueProperties.STOP + .equals(ResidueProperties.codonTranslate(codon))) { return true; } @@ -2532,6 +2534,10 @@ public class AlignmentUtils { featureType = SequenceOntologyI.SYNONYMOUS_VARIANT; } + else if (ResidueProperties.STOP.equals(trans)) + { + featureType = SequenceOntologyI.STOP_GAINED; + } else { String residue3Char = StringUtils diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index f3088ea..ef05a58 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -161,7 +161,7 @@ public class Dna int s; int sSize = selection.size(); - List pepseqs = new ArrayList(); + List pepseqs = new ArrayList<>(); for (s = 0; s < sSize; s++) { SequenceI newseq = translateCodingRegion(selection.get(s), @@ -213,7 +213,7 @@ public class Dna if (dnarefs != null) { // intersect with pep - List mappedrefs = new ArrayList(); + List mappedrefs = new ArrayList<>(); DBRefEntry[] refs = dna.getDBRefs(); for (int d = 0; d < refs.length; d++) { @@ -391,7 +391,7 @@ public class Dna String seqstring, AlignedCodonFrame acf, List proteinSeqs) { - List skip = new ArrayList(); + List skip = new ArrayList<>(); int skipint[] = null; ShiftList vismapping = new ShiftList(); // map from viscontigs to seqstring // intervals @@ -544,7 +544,7 @@ public class Dna skip.add(skipint); skipint = null; } - if (aa.equals("STOP")) + if (aa.equals(ResidueProperties.STOP)) { aa = STOP_ASTERIX; } @@ -800,7 +800,7 @@ public class Dna public AlignmentI reverseCdna(boolean complement) { int sSize = selection.size(); - List reversed = new ArrayList(); + List reversed = new ArrayList<>(); for (int s = 0; s < sSize; s++) { SequenceI newseq = reverseSequence(selection.get(s).getName(), diff --git a/src/jalview/io/gff/SequenceOntologyI.java b/src/jalview/io/gff/SequenceOntologyI.java index 10ca7ec..307e1d1 100644 --- a/src/jalview/io/gff/SequenceOntologyI.java +++ b/src/jalview/io/gff/SequenceOntologyI.java @@ -48,6 +48,9 @@ public interface SequenceOntologyI // SO:0001992 public static final String NONSYNONYMOUS_VARIANT = "nonsynonymous_variant"; + // SO:0001587 + public static final String STOP_GAINED = "stop_gained"; + // SO:0000147 public static final String EXON = "exon"; diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 55df1d1..a4e6480 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -39,14 +39,14 @@ public class ResidueProperties public static final int[] purinepyrimidineIndex; - public static final Map aa3Hash = new HashMap(); + public static final Map aa3Hash = new HashMap<>(); - public static final Map aa2Triplet = new HashMap(); + public static final Map aa2Triplet = new HashMap<>(); - public static final Map nucleotideName = new HashMap(); + public static final Map nucleotideName = new HashMap<>(); // lookup from modified amino acid (e.g. MSE) to canonical form (e.g. MET) - public static final Map modifications = new HashMap(); + public static final Map modifications = new HashMap<>(); static { @@ -496,25 +496,27 @@ public class ResidueProperties * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap */ - public static List STOP = Arrays.asList("TGA", "TAA", "TAG"); + public static String STOP = "STOP"; + + public static List STOP_CODONS = Arrays.asList("TGA", "TAA", "TAG"); public static String START = "ATG"; /** * Nucleotide Ambiguity Codes */ - public static final Map ambiguityCodes = new Hashtable(); + public static final Map ambiguityCodes = new Hashtable<>(); /** * Codon triplets with additional symbols for unambiguous codons that include * ambiguity codes */ - public static final Hashtable codonHash2 = new Hashtable(); + public static final Hashtable codonHash2 = new Hashtable<>(); /** * all ambiguity codes for a given base */ - public final static Hashtable> _ambiguityCodes = new Hashtable>(); + public final static Hashtable> _ambiguityCodes = new Hashtable<>(); static { @@ -638,7 +640,7 @@ public class ResidueProperties List codesfor = _ambiguityCodes.get(r); if (codesfor == null) { - _ambiguityCodes.put(r, codesfor = new ArrayList()); + _ambiguityCodes.put(r, codesfor = new ArrayList<>()); } if (!codesfor.contains(acode.getKey())) { @@ -755,27 +757,27 @@ public class ResidueProperties } // Stores residue codes/names and colours and other things - public static Map> propHash = new Hashtable>(); + public static Map> propHash = new Hashtable<>(); - public static Map hydrophobic = new Hashtable(); + public static Map hydrophobic = new Hashtable<>(); - public static Map polar = new Hashtable(); + public static Map polar = new Hashtable<>(); - public static Map small = new Hashtable(); + public static Map small = new Hashtable<>(); - public static Map positive = new Hashtable(); + public static Map positive = new Hashtable<>(); - public static Map negative = new Hashtable(); + public static Map negative = new Hashtable<>(); - public static Map charged = new Hashtable(); + public static Map charged = new Hashtable<>(); - public static Map aromatic = new Hashtable(); + public static Map aromatic = new Hashtable<>(); - public static Map aliphatic = new Hashtable(); + public static Map aliphatic = new Hashtable<>(); - public static Map tiny = new Hashtable(); + public static Map tiny = new Hashtable<>(); - public static Map proline = new Hashtable(); + public static Map proline = new Hashtable<>(); static { @@ -1149,7 +1151,7 @@ public class ResidueProperties String cdn = codonHash2.get(lccodon.toUpperCase()); if ("*".equals(cdn)) { - return "STOP"; + return STOP; } return cdn; } @@ -1157,7 +1159,7 @@ public class ResidueProperties public static Hashtable toDssp3State; static { - toDssp3State = new Hashtable(); + toDssp3State = new Hashtable<>(); toDssp3State.put("H", "H"); toDssp3State.put("E", "E"); toDssp3State.put("C", " "); @@ -2525,7 +2527,7 @@ public class ResidueProperties // / cut here public static void main(String[] args) { - Hashtable> aaProps = new Hashtable>(); + Hashtable> aaProps = new Hashtable<>(); System.out.println("my %aa = {"); // invert property hashes for (String pname : propHash.keySet()) @@ -2536,7 +2538,7 @@ public class ResidueProperties Vector aprops = aaProps.get(rname); if (aprops == null) { - aprops = new Vector(); + aprops = new Vector<>(); aaProps.put(rname, aprops); } Integer hasprop = phash.get(rname); @@ -2578,7 +2580,7 @@ public class ResidueProperties public static List getResidues(boolean forNucleotide, boolean includeAmbiguous) { - List result = new ArrayList(); + List result = new ArrayList<>(); if (forNucleotide) { for (String nuc : nucleotideName.keySet()) diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 3e8390f..be6ba60 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -2157,23 +2157,8 @@ public class AlignmentUtilsTests sf.links.get(0)); assertEquals(ensembl, sf.getFeatureGroup()); - // AAA -> TAA -> stop codon - sf = sfs.get(1); - assertEquals(1, sf.getBegin()); - assertEquals(1, sf.getEnd()); - assertEquals("nonsynonymous_variant", sf.getType()); - assertEquals("p.Lys1null", sf.getDescription()); // stop codon badly handled - assertEquals("var3", sf.getValue("ID")); - assertEquals("Bad", sf.getValue("clinical_significance")); - assertEquals("ID=var3;clinical_significance=Bad", sf.getAttributes()); - assertEquals(1, sf.links.size()); - assertEquals( - "p.Lys1null var3|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var3", - sf.links.get(0)); - assertEquals(dbSnp, sf.getFeatureGroup()); - // AAA -> CAA -> K/Q - sf = sfs.get(2); + sf = sfs.get(1); assertEquals(1, sf.getBegin()); assertEquals(1, sf.getEnd()); assertEquals("nonsynonymous_variant", sf.getType()); @@ -2188,7 +2173,7 @@ public class AlignmentUtilsTests assertEquals(dbSnp, sf.getFeatureGroup()); // AAA -> GAA -> K/E - sf = sfs.get(3); + sf = sfs.get(2); assertEquals(1, sf.getBegin()); assertEquals(1, sf.getEnd()); assertEquals("nonsynonymous_variant", sf.getType()); @@ -2203,6 +2188,21 @@ public class AlignmentUtilsTests sf.links.get(0)); assertEquals(ensembl, sf.getFeatureGroup()); + // AAA -> TAA -> stop codon + sf = sfs.get(3); + assertEquals(1, sf.getBegin()); + assertEquals(1, sf.getEnd()); + assertEquals("stop_gained", sf.getType()); + assertEquals("TAA", sf.getDescription()); + assertEquals("var3", sf.getValue("ID")); + assertEquals("Bad", sf.getValue("clinical_significance")); + assertEquals("ID=var3;clinical_significance=Bad", sf.getAttributes()); + assertEquals(1, sf.links.size()); + assertEquals( + "TAA var3|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var3", + sf.links.get(0)); + assertEquals(dbSnp, sf.getFeatureGroup()); + // AAA -> AAG synonymous sf = sfs.get(4); assertEquals(1, sf.getBegin()); -- 1.7.10.2