From 66661cc185c91bbd78af8ead50f9730b76d70a7d Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 17 Feb 2017 17:44:56 +0000 Subject: [PATCH] JAL-2416 removed DNA and PAM250 matrices from ResidueProperties --- src/jalview/analysis/AlignSeq.java | 29 ++++++--- src/jalview/api/SiftsClientI.java | 2 +- src/jalview/schemes/ResidueProperties.java | 93 ---------------------------- src/jalview/ws/sifts/SiftsClient.java | 28 +++++---- 4 files changed, 37 insertions(+), 115 deletions(-) diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index f623a96..61ff012 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -20,6 +20,7 @@ */ package jalview.analysis; +import jalview.analysis.scoremodels.PairwiseSeqScoreModel; import jalview.analysis.scoremodels.ScoreMatrix; import jalview.analysis.scoremodels.ScoreModels; import jalview.datamodel.AlignmentAnnotation; @@ -117,7 +118,10 @@ public class AlignSeq int gapExtend = 20; - float[][] lookup = ResidueProperties.getBLOSUM62(); + float[][] lookup = ((ScoreMatrix) ScoreModels.getInstance().forName( + ScoreModels.BLOSUM62)).getMatrix(); + + // ResidueProperties.getBLOSUM62(); String[] intToStr = pep; @@ -600,6 +604,9 @@ public class AlignSeq .append(String.valueOf(s2str.length())).append(")") .append(NEWLINE).append(NEWLINE); + PairwiseSeqScoreModel pam250 = (PairwiseSeqScoreModel) ScoreModels + .getInstance().forName(ScoreModels.PAM250); + for (int j = 0; j < nochunks; j++) { // Print the first aligned sequence @@ -616,25 +623,27 @@ public class AlignSeq output.append(NEWLINE); output.append(new Format("%" + (maxid) + "s").form(" ")).append(" "); - // Print out the matching chars + /* + * Print out the match symbols: + * | for exact match (ignoring case) + * . if PAM250 score is positive + * else a space + */ for (int i = 0; i < len; i++) { if ((i + (j * len)) < astr1.length()) { - boolean sameChar = Comparison.isSameResidue( - astr1.charAt(i + (j * len)), astr2.charAt(i + (j * len)), - false); - if (sameChar - && !jalview.util.Comparison.isGap(astr1.charAt(i - + (j * len)))) + char c1 = astr1.charAt(i + (j * len)); + char c2 = astr2.charAt(i + (j * len)); + boolean sameChar = Comparison.isSameResidue(c1, c2, false); + if (sameChar && !Comparison.isGap(c1)) { pid++; output.append("|"); } else if (type.equals("pep")) { - if (ResidueProperties.getPAM250(astr1.charAt(i + (j * len)), - astr2.charAt(i + (j * len))) > 0) + if (pam250.getPairwiseScore(c1, c2) > 0) { output.append("."); } diff --git a/src/jalview/api/SiftsClientI.java b/src/jalview/api/SiftsClientI.java index c795f3f..367a0de 100644 --- a/src/jalview/api/SiftsClientI.java +++ b/src/jalview/api/SiftsClientI.java @@ -100,7 +100,7 @@ public interface SiftsClientI * @return Sequence<->Structure mapping as int[][] * @throws SiftsException */ - public StringBuffer getMappingOutput(MappingOutputPojo mop) + public StringBuilder getMappingOutput(MappingOutputPojo mop) throws SiftsException; /** diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 0b1b7cc..77fa9e8 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -521,56 +521,6 @@ public class ResidueProperties { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 1 }, }; - public static final float[][] PAM250 = { - { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3, - 0, 0, 0, 0, -8 }, - { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4, - -2, -1, 0, -1, -8 }, - { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2, - 2, 1, 0, -8 }, - { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4, - -2, 3, 3, -1, -8 }, - { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2, - -8, 0, -2, -4, -5, -3, -8 }, - { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4, - -2, 1, 3, -1, -8 }, - { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4, - -2, 3, 3, -1, -8 }, - { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5, - -1, 0, 0, -1, -8 }, - { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0, - -2, 1, 2, -1, -8 }, - { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5, - -1, 4, -2, -2, -1, -8 }, - { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2, - -1, 2, -3, -3, -1, -8 }, - { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4, - -2, 1, 0, -1, -8 }, - { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4, - -2, 2, -2, -2, -1, -8 }, - { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0, - 7, -1, -4, -5, -2, -8 }, - { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5, - -1, -1, 0, -1, -8 }, - { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3, - -1, 0, 0, 0, -8 }, - { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3, - 0, 0, -1, 0, -8 }, - { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5, - 17, 0, -6, -5, -6, -4, -8 }, - { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0, - 10, -2, -3, -4, -2, -8 }, - { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6, - -2, 4, -2, -2, -1, -8 }, - { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3, - -2, 3, 2, -1, -8 }, - { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4, - -2, 2, 3, -1, -8 }, - { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4, - -2, -1, -1, -1, -1, -8 }, - { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, - -8, -8, -8, -8, -8, -8, 1 }, }; - // not currently used // public static final Map ssHash = new Hashtable(); @@ -592,34 +542,6 @@ public class ResidueProperties * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap */ - // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA. - // Will equate sequences if working with mixed nucleotide sets. - // treats T and U identically. R and Y weak equivalence with AG and CTU. - // N matches any other base weakly - // - public static final float[][] DNA = { - { 10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1 }, // A - { -8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C - { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // G - { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // T - { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // U - { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I - { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X - { 1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1 }, // R - { -8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1 }, // Y - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // - - }; - /** - * register matrices in list - */ - static - { - // scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62)); - // scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250)); - // scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA)); - } - public static List STOP = Arrays.asList("TGA", "TAA", "TAG"); public static String START = "ATG"; @@ -1270,11 +1192,6 @@ public class ResidueProperties return ResidueProperties.BLOSUM62; } - public static float getPAM250(String A1, String A2) - { - return getPAM250(A1.charAt(0), A2.charAt(0)); - } - public static String codonTranslate(String lccodon) { String cdn = codonHash2.get(lccodon.toUpperCase()); @@ -1285,16 +1202,6 @@ public class ResidueProperties return cdn; } - public static float getPAM250(char c, char d) - { - int a = aaIndex[c]; - int b = aaIndex[d]; - - float pog = ResidueProperties.PAM250[a][b]; - - return pog; - } - public static Hashtable toDssp3State; static { diff --git a/src/jalview/ws/sifts/SiftsClient.java b/src/jalview/ws/sifts/SiftsClient.java index 8bae5ba..6d961c0 100644 --- a/src/jalview/ws/sifts/SiftsClient.java +++ b/src/jalview/ws/sifts/SiftsClient.java @@ -21,6 +21,8 @@ package jalview.ws.sifts; import jalview.analysis.AlignSeq; +import jalview.analysis.scoremodels.PairwiseSeqScoreModel; +import jalview.analysis.scoremodels.ScoreModels; import jalview.api.DBRefEntryI; import jalview.api.SiftsClientI; import jalview.datamodel.DBRefEntry; @@ -943,7 +945,7 @@ public class SiftsClient implements SiftsClientI } @Override - public StringBuffer getMappingOutput(MappingOutputPojo mp) + public StringBuilder getMappingOutput(MappingOutputPojo mp) throws SiftsException { String seqRes = mp.getSeqResidue(); @@ -965,7 +967,7 @@ public class SiftsClient implements SiftsClientI int nochunks = ((seqRes.length()) / len) + ((seqRes.length()) % len > 0 ? 1 : 0); // output mappings - StringBuffer output = new StringBuffer(); + StringBuilder output = new StringBuilder(512); output.append(NEWLINE); output.append("Sequence \u27f7 Structure mapping details").append( NEWLINE); @@ -986,6 +988,8 @@ public class SiftsClient implements SiftsClientI output.append(String.valueOf(pdbEnd)); output.append(NEWLINE).append(NEWLINE); + PairwiseSeqScoreModel pam250 = (PairwiseSeqScoreModel) ScoreModels + .getInstance().forName(ScoreModels.PAM250); int matchedSeqCount = 0; for (int j = 0; j < nochunks; j++) { @@ -1004,27 +1008,29 @@ public class SiftsClient implements SiftsClientI output.append(NEWLINE); output.append(new Format("%" + (maxid) + "s").form(" ")).append(" "); - // Print out the matching chars + /* + * Print out the match symbols: + * | for exact match (ignoring case) + * . if PAM250 score is positive + * else a space + */ for (int i = 0; i < len; i++) { try { if ((i + (j * len)) < seqRes.length()) { - boolean sameChar = Comparison.isSameResidue( - seqRes.charAt(i + (j * len)), - strRes.charAt(i + (j * len)), false); - if (sameChar - && !jalview.util.Comparison.isGap(seqRes.charAt(i - + (j * len)))) + char c1 = seqRes.charAt(i + (j * len)); + char c2 = strRes.charAt(i + (j * len)); + boolean sameChar = Comparison.isSameResidue(c1, c2, false); + if (sameChar && !Comparison.isGap(c1)) { matchedSeqCount++; output.append("|"); } else if (type.equals("pep")) { - if (ResidueProperties.getPAM250(seqRes.charAt(i + (j * len)), - strRes.charAt(i + (j * len))) > 0) + if (pam250.getPairwiseScore(c1, c2) > 0) { output.append("."); } -- 1.7.10.2