- models = new TreeMap<String, ScoreModelI>(String.CASE_INSENSITIVE_ORDER);
- registerScoreModel(new ScoreMatrix("BLOSUM62",
- ResidueProperties.BLOSUM62, 0));
- registerScoreModel(new ScoreMatrix("PAM250", ResidueProperties.PAM250,
- 0));
- registerScoreModel(new ScoreMatrix("DNA", ResidueProperties.DNA, 1));
- registerScoreModel(new FeatureScoreModel());
- registerScoreModel(new PIDScoreModel());
+ models = new LinkedHashMap<>();
+ BLOSUM62 = loadScoreMatrix("scoreModel/blosum62.scm");
+ PAM250 = loadScoreMatrix("scoreModel/pam250.scm");
+ DNA = loadScoreMatrix("scoreModel/dna.scm");
+ registerScoreModel(new PIDModel());
+ registerScoreModel(new FeatureDistanceModel());
+ }
+
+ /**
+ * Tries to load a score matrix from the given resource file, and if
+ * successful, registers it.
+ *
+ * @param string
+ * @return
+ */
+ ScoreMatrix loadScoreMatrix(String resourcePath)
+ {
+ try
+ {
+ /*
+ * delegate parsing to ScoreMatrixFile
+ */
+ FileParse fp = new FileParse(resourcePath,
+ DataSourceType.CLASSLOADER);
+ ScoreMatrix sm = new ScoreMatrixFile(fp).parseMatrix();
+ registerScoreModel(sm);
+ return sm;
+ } catch (IOException e)
+ {
+ System.err.println(
+ "Error reading " + resourcePath + ": " + e.getMessage());
+ }
+ return null;