int gapExtend = 20;
- float[][] lookup = ((ScoreMatrix) ScoreModels.getInstance().forName(
- ScoreModels.BLOSUM62)).getMatrix();
+ float[][] lookup = ScoreModels.getInstance().getBlosum62().getMatrix();
// ResidueProperties.getBLOSUM62();
.append(String.valueOf(s2str.length())).append(")")
.append(NEWLINE).append(NEWLINE);
- PairwiseSeqScoreModel pam250 = (PairwiseSeqScoreModel) ScoreModels
- .getInstance().forName(ScoreModels.PAM250);
+ PairwiseSeqScoreModel pam250 = ScoreModels.getInstance().getPam250();
for (int j = 0; j < nochunks; j++)
{
*/
package jalview.analysis;
-import jalview.analysis.scoremodels.PairwiseSeqScoreModel;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
quality = new Vector<Double>();
double max = -10000;
- float[][] BLOSUM62 = ((PairwiseSeqScoreModel) ScoreModels.getInstance()
- .forName(ScoreModels.BLOSUM62)).getMatrix();
+ float[][] BLOSUM62 = ScoreModels.getInstance().getBlosum62()
+ .getMatrix();
// Loop over columns // JBPNote Profiling info
// long ts = System.currentTimeMillis();
*/
public class 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";
+ private final ScoreMatrix BLOSUM62;
- public static final String DNA = "DNA";
+ private final ScoreMatrix PAM250;
private static ScoreModels instance = new ScoreModels();
+
private Map<String, ScoreModelI> models;
public static ScoreModels getInstance()
* using LinkedHashMap keeps models ordered as added
*/
models = new LinkedHashMap<String, ScoreModelI>();
- loadScoreMatrix("scoreModel/blosum62.scm");
- loadScoreMatrix("scoreModel/pam250.scm");
- loadScoreMatrix("scoreModel/seqspace.scm");
+ BLOSUM62 = loadScoreMatrix("scoreModel/blosum62.scm");
+ PAM250 = loadScoreMatrix("scoreModel/pam250.scm");
loadScoreMatrix("scoreModel/dna.scm");
+ loadScoreMatrix("scoreModel/seqspace.scm");
registerScoreModel(new FeatureScoreModel());
registerScoreModel(new PIDScoreModel());
}
/**
- * Try to load a score matrix from the given resource file, and if successful,
- * register it. Answers true if successful, else false.
+ * Tries to load a score matrix from the given resource file, and if
+ * successful, registers it.
*
* @param string
+ * @return
*/
- boolean loadScoreMatrix(String resourcePath)
+ ScoreMatrix loadScoreMatrix(String resourcePath)
{
try
{
FileParse fp = new FileParse(resourcePath, DataSourceType.CLASSLOADER);
ScoreMatrix sm = new ScoreMatrixFile(fp).parseMatrix();
registerScoreModel(sm);
- return true;
+ return sm;
} catch (IOException e)
{
System.err.println("Error reading " + resourcePath + ": "
+ e.getMessage());
}
- return false;
+ return null;
}
/**
return (PairwiseSeqScoreModel) (forPeptide ? forName("BLOSUM62")
: forName("DNA"));
}
+
+ public ScoreMatrix getBlosum62()
+ {
+ return BLOSUM62;
+ }
+
+ public ScoreMatrix getPam250()
+ {
+ return PAM250;
+ }
}
public Color findColour(char res, int j, SequenceI seq,
String consensusResidue, float pid)
{
- PairwiseSeqScoreModel sm = (PairwiseSeqScoreModel) ScoreModels
- .getInstance().forName(ScoreModels.BLOSUM62);
+ PairwiseSeqScoreModel sm = ScoreModels.getInstance().getBlosum62();
/*
* compare as upper case; note consensusResidue is