11package org .biojava .nbio .phylo ;
22
3+ import java .io .IOException ;
34import java .util .List ;
45
5- import org .biojava .nbio .core .alignment .matrices .SubstitutionMatrixHelper ;
66import org .biojava .nbio .core .alignment .template .SubstitutionMatrix ;
77import org .biojava .nbio .core .sequence .MultipleSequenceAlignment ;
8- import org .biojava .nbio .core .sequence .compound .AminoAcidCompound ;
98import org .biojava .nbio .core .sequence .template .Compound ;
109import org .biojava .nbio .core .sequence .template .Sequence ;
1110import org .forester .evoinference .distance .PairwiseDistanceCalculator ;
1716
1817/**
1918 * The DistanceMatrixCalculator methods generate a {@link DistanceMatrix} from a
20- * {@link MultipleSequenceAlignment}.
21- * <p>
22- * The implementations differ in the information required to calculate the
23- * distances. Thus, the difference resides in their constructor.
19+ * {@link MultipleSequenceAlignment} or other indirect distance infomation (RMSD).
2420 *
2521 * @author Aleix Lafita
2622 * @since 4.1.1
@@ -51,17 +47,12 @@ private DistanceMatrixCalculator() {
5147 * @param msa
5248 * MultipleSequenceAlignment
5349 * @return DistanceMatrix
50+ * @throws Exception
5451 */
5552 public static <C extends Sequence <D >, D extends Compound > DistanceMatrix fractionalDissimilarity (
56- MultipleSequenceAlignment <C , D > msa ) {
57-
58- Msa fMsa = null ;
59- try {
60- fMsa = ForesterWrapper .convert (msa );
61- } catch (Exception e ) {
62- logger .warn ("Could not convert BioJava MSA to forester MSA" , e );
63- }
53+ MultipleSequenceAlignment <C , D > msa ) throws IOException {
6454
55+ Msa fMsa = ForesterWrapper .convert (msa );
6556 DistanceMatrix DM = PairwiseDistanceCalculator
6657 .calcFractionalDissimilarities (fMsa );
6758
@@ -83,17 +74,12 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix fractio
8374 * @param msa
8475 * MultipleSequenceAlignment
8576 * @return DistanceMatrix
77+ * @throws IOException
8678 */
8779 public static <C extends Sequence <D >, D extends Compound > DistanceMatrix poissonDistance (
88- MultipleSequenceAlignment <C , D > msa ) {
89-
90- Msa fMsa = null ;
91- try {
92- fMsa = ForesterWrapper .convert (msa );
93- } catch (Exception e ) {
94- logger .warn ("Could not convert BioJava MSA to forester MSA" , e );
95- }
80+ MultipleSequenceAlignment <C , D > msa ) throws IOException {
9681
82+ Msa fMsa = ForesterWrapper .convert (msa );
9783 DistanceMatrix DM = PairwiseDistanceCalculator
9884 .calcPoissonDistances (fMsa );
9985
@@ -120,17 +106,12 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix poisson
120106 * @param msa
121107 * MultipleSequenceAlignment
122108 * @return DistanceMatrix
109+ * @throws IOException
123110 */
124111 public static <C extends Sequence <D >, D extends Compound > DistanceMatrix kimuraDistance (
125- MultipleSequenceAlignment <C , D > msa ) {
126-
127- Msa fMsa = null ;
128- try {
129- fMsa = ForesterWrapper .convert (msa );
130- } catch (Exception e ) {
131- logger .warn ("Could not convert BioJava MSA to forester MSA" , e );
132- }
112+ MultipleSequenceAlignment <C , D > msa ) throws IOException {
133113
114+ Msa fMsa = ForesterWrapper .convert (msa );
134115 DistanceMatrix DM = PairwiseDistanceCalculator
135116 .calcPoissonDistances (fMsa );
136117
@@ -388,8 +369,7 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix pamMLdi
388369 MultipleSequenceAlignment <C , D > msa ) {
389370
390371 // Need to import PAM1 matrix to biojava TODO
391- SubstitutionMatrix <AminoAcidCompound > PAM1 = SubstitutionMatrixHelper
392- .getPAM250 ();
372+ //SubstitutionMatrix<AminoAcidCompound> PAM1 = SubstitutionMatrixHelper.getPAM250();
393373
394374 return null ;
395375 }
@@ -437,6 +417,7 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix structu
437417 * Math .log ((rmsdMax * rmsdMax - rmsd0 * rmsd0 )
438418 / (rmsdMax * rmsdMax - rmsdMat [i ][j ]
439419 * rmsdMat [i ][j ]));
420+ d = Math .max (d , 0.0 );
440421 DM .setValue (i , j , d );
441422 DM .setValue (j , i , d );
442423 }
0 commit comments