From 454f89f88d84083b9b654367f728b4a9dcb43e65 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 7 Feb 2017 13:20:12 +0000 Subject: [PATCH] JAL-2397 flag provided for 2.10.1 PCA gap calculation treatment --- examples/groovy/pcaMode.groovy | 55 ----------------------------------- src/jalview/viewmodel/PCAModel.java | 10 ++++++- 2 files changed, 9 insertions(+), 56 deletions(-) delete mode 100644 examples/groovy/pcaMode.groovy diff --git a/examples/groovy/pcaMode.groovy b/examples/groovy/pcaMode.groovy deleted file mode 100644 index 817e6e1..0000000 --- a/examples/groovy/pcaMode.groovy +++ /dev/null @@ -1,55 +0,0 @@ -/* - * PCA calculation treatment of gaps (and C->R score) changed in Jalview 2.10.2. - * To restore behaviour prior as at 2.10.1, run the script below - * NB this will change Tree calculations using similarity matrices - */ - -/* - * START 2.10.1 mode script - */ -import jalview.schemes.ResidueProperties - -for (int row = 0 ; row <= ResidueProperties.maxProteinIndex; row++) -{ - ResidueProperties.BLOSUM62[row][23] = ResidueProperties.BLOSUM62[row][22] - ResidueProperties.BLOSUM62[23][row] = ResidueProperties.BLOSUM62[row][22] - ResidueProperties.PAM250[row][23] = ResidueProperties.PAM250[row][22] - ResidueProperties.PAM250[23][row] = ResidueProperties.PAM250[row][22] -} -ResidueProperties.BLOSUM62[4][1]=3 // C-R score -for (int row = 0 ; row <= ResidueProperties.maxNucleotideIndex; row++) -{ - ResidueProperties.DNA[row][10] = ResidueProperties.DNA[row][9] - ResidueProperties.DNA[10][row] = ResidueProperties.DNA[row][9] -} -/* - * END 2.10.1 mode script - */ - -/* - * To reinstate 2.10.2 calculation mode, including Tree calculations, - * run the script below - */ -/* - * START 2.10.2 mode script - */ - import jalview.schemes.ResidueProperties - -for (int row = 0 ; row < ResidueProperties.maxProteinIndex; row++) -{ - ResidueProperties.BLOSUM62[row][23] = -4 - ResidueProperties.BLOSUM62[23][row] = -4 - ResidueProperties.PAM250[row][23] = -8 - ResidueProperties.PAM250[23][row] = -8 -} -ResidueProperties.BLOSUM62[23][23] = 1 -ResidueProperties.PAM250[23][23] = 1 -ResidueProperties.BLOSUM62[4][1]=-3 // C-R score -for (int row = 0 ; row <= ResidueProperties.maxNucleotideIndex; row++) -{ - ResidueProperties.DNA[row][10] = 1 - ResidueProperties.DNA[10][row] = 1 -} -/* - * END 2.10.2 mode script - */ diff --git a/src/jalview/viewmodel/PCAModel.java b/src/jalview/viewmodel/PCAModel.java index 55e7300..0623dab 100644 --- a/src/jalview/viewmodel/PCAModel.java +++ b/src/jalview/viewmodel/PCAModel.java @@ -30,6 +30,13 @@ import java.util.Vector; public class PCAModel { + /* + * Jalview 2.10.1 treated gaps as X (peptide) or N (nucleotide) + * for pairwise scoring; 2.10.2 uses gap score (last column) in + * score matrix (JAL-2397) + * Set this flag to true (via Groovy) for 2.10.1 behaviour + */ + private static boolean scoreGapAsAny = false; public PCAModel(AlignmentView seqstrings2, SequenceI[] seqs2, boolean nucleotide2) @@ -69,7 +76,8 @@ public class PCAModel public void run() { - String[] sequenceStrings = seqstrings.getSequenceStrings(' '); + char gapChar = scoreGapAsAny ? (nucleotide ? 'N' : 'X') : ' '; + String[] sequenceStrings = seqstrings.getSequenceStrings(gapChar); pca = new PCA(sequenceStrings, nucleotide, score_matrix); pca.setJvCalcMode(jvCalcMode); -- 1.7.10.2