package jalview.analysis;
import jalview.analysis.scoremodels.ScoreMatrix;
+import jalview.analysis.scoremodels.ScoreModels;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Mapping;
if (type.equals(AlignSeq.PEP))
{
- lookup = ResidueProperties.getDefaultPeptideMatrix();
+ lookup = ScoreModels.getInstance().getDefaultModel(true).getMatrix();
}
else if (type.equals(AlignSeq.DNA))
{
- lookup = ResidueProperties.getDefaultDnaMatrix();
+ lookup = ScoreModels.getInstance().getDefaultModel(false).getMatrix();
}
}
return true;
}
+ @Override
+ public String toString()
+ {
+ return "Percentage identity of sequences";
+ }
}
*/
public class ScoreModels
{
- private static ScoreModels instance = new ScoreModels();
+ /*
+ * constants for built-in score model names
+ * NB! these have to match names in loaded score matrix files
+ */
+ public static final String BLOSUM62 = "BLOSUM62";
+
+ public static final String PAM250 = "PAM250";
+ public static final String DNA = "DNA";
+
+ private static ScoreModels instance = new ScoreModels();
private Map<String, ScoreModelI> models;
public static ScoreModels getInstance()
}
models.put(sm.getName(), sm);
}
+
+ /**
+ * Returns the default peptide or nucleotide score model, currently BLOSUM62
+ * or DNA
+ *
+ * @param forPeptide
+ * @return
+ */
+ public PairwiseSeqScoreModel getDefaultModel(boolean forPeptide)
+ {
+ return (PairwiseSeqScoreModel) (forPeptide ? forName("BLOSUM62")
+ : forName("DNA"));
+ }
}
package jalview.appletgui;
import jalview.analysis.NJTree;
+import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.ViewBasedAnalysisI;
import jalview.datamodel.Alignment;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.SequenceI;
import jalview.io.NewickFile;
-import jalview.schemes.ResidueProperties;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
return tree;
}
+ @Override
public void finalize() throws Throwable
{
ap = null;
this.newtree = newtree;
}
+ @Override
public void run()
{
if (newtree != null)
seqs = av.getSelectionGroup().getSequencesInOrder(
av.getAlignment());
}
- ScoreModelI sm = ResidueProperties.getScoreModel(pwtype);
+ ScoreModelI sm = ScoreModels.getInstance().forName(pwtype);
if (sm instanceof ViewBasedAnalysisI)
{
try
}
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == newickOutput)
}
}
+ @Override
public void itemStateChanged(ItemEvent evt)
{
if (evt.getSource() == fitToWindow)
*/
package jalview.schemes;
+import jalview.analysis.scoremodels.PairwiseSeqScoreModel;
+import jalview.analysis.scoremodels.ScoreModels;
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceI;
public Color findColour(char res, int j, SequenceI seq,
String consensusResidue, float pid)
{
+ PairwiseSeqScoreModel sm = (PairwiseSeqScoreModel) ScoreModels
+ .getInstance().forName(ScoreModels.BLOSUM62);
+
/*
* compare as upper case; note consensusResidue is
* always computed as uppercase
for (char consensus : consensusResidue.toCharArray())
{
- score += ResidueProperties.getBLOSUM62(consensus, res);
+ score += sm.getPairwiseScore(consensus, res);
+ // score += ResidueProperties.getBLOSUM62(consensus, res);
}
if (score > 0)
*/
package jalview.schemes;
-import jalview.analysis.scoremodels.FeatureScoreModel;
-import jalview.analysis.scoremodels.PIDScoreModel;
-import jalview.analysis.scoremodels.ScoreMatrix;
-import jalview.api.analysis.ScoreModelI;
-
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
public class ResidueProperties
{
- public static Hashtable<String, ScoreModelI> scoreMatrices = new Hashtable<String, ScoreModelI>();
-
// Stores residue codes/names and colours and other things
public static final int[] aaIndex; // aaHash version 2.1.1 and below
propMatrixPos[i][i] = maxP;
propMatrixEpos[i][i] = maxEP;
}
- // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
- // scoreMatrices.put("Conservation Pos", new
- // ScoreMatrix("Conservation Pos",propMatrixPos,0));
- // scoreMatrices.put("Conservation Both", new
- // ScoreMatrix("Conservation Both",propMatrixF,0));
- // scoreMatrices.put("Conservation EnhPos", new
- // ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
- scoreMatrices.put("PID", new PIDScoreModel());
- scoreMatrices.put("Sequence Feature Similarity",
- new FeatureScoreModel());
}
private ResidueProperties()
return aa3Hash;
}
- public static float[][] getDNA()
- {
- return ResidueProperties.DNA;
- }
-
public static float[][] getBLOSUM62()
{
return ResidueProperties.BLOSUM62;
return getPAM250(A1.charAt(0), A2.charAt(0));
}
- public static float getBLOSUM62(char c1, char c2)
- {
- float pog = 0;
-
- try
- {
- int a = aaIndex[c1];
- int b = aaIndex[c2];
-
- pog = ResidueProperties.BLOSUM62[a][b];
- } catch (Exception e)
- {
- // System.out.println("Unknown residue in " + A1 + " " + A2);
- }
-
- return pog;
- }
-
public static String codonTranslate(String lccodon)
{
String cdn = codonHash2.get(lccodon.toUpperCase());
return cdn;
}
- public static float[][] getDefaultPeptideMatrix()
- {
- return ResidueProperties.getBLOSUM62();
- }
-
- public static float[][] getDefaultDnaMatrix()
- {
- return ResidueProperties.getDNA();
- }
-
- /**
- * get a ScoreMatrix based on its string name
- *
- * @param pwtype
- * @return matrix in scoreMatrices with key pwtype or null
- */
- public static ScoreMatrix getScoreMatrix(String pwtype)
- {
- Object val = scoreMatrices.get(pwtype);
- if (val != null && val instanceof ScoreMatrix)
- {
- return (ScoreMatrix) val;
- }
- return null;
- }
-
- /**
- * get a ScoreModel based on its string name
- *
- * @param pwtype
- * @return scoremodel of type pwtype or null
- */
- public static ScoreModelI getScoreModel(String pwtype)
- {
- return scoreMatrices.get(pwtype);
- }
-
public static float getPAM250(char c, char d)
{
int a = aaIndex[c];
package jalview.schemes;
import jalview.analysis.scoremodels.ScoreMatrix;
+import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.analysis.ScoreModelI;
import jalview.gui.JvOptionPane;
-import java.util.Map;
-
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = { "Functional" })
public void printAllMatrices()
{
- for (Map.Entry<String, ScoreModelI> sm : ResidueProperties.scoreMatrices
- .entrySet())
+ for (ScoreModelI sm : ScoreModels.getInstance().getModels())
{
- System.out.println("Matrix " + sm.getKey());
- System.out.println(sm.getValue().toString());
+ System.out.println("Matrix " + sm.getName());
+ System.out.println(sm.toString());
}
}
@Test(groups = { "Functional" })
public void printHTMLMatrices()
{
- for (Map.Entry<String, ScoreModelI> _sm : ResidueProperties.scoreMatrices
- .entrySet())
+ for (ScoreModelI sm : ScoreModels.getInstance().getModels())
{
- if (_sm.getValue() instanceof ScoreMatrix)
+ if (sm instanceof ScoreMatrix)
{
- ScoreMatrix sm = (ScoreMatrix) _sm.getValue();
- System.out.println("Matrix " + _sm.getKey());
- System.out.println(sm.outputMatrix(true));
+ System.out.println("Matrix " + sm.getName());
+ System.out.println(((ScoreMatrix) sm).outputMatrix(true));
}
}
}