Skip to content

Commit 36b9bf2

Browse files
committed
Fix bugs in Phylogenetic tree display
1 parent e152348 commit 36b9bf2

File tree

7 files changed

+39
-22
lines changed

7 files changed

+39
-22
lines changed

biojava-phylo/src/main/java/org/biojava/nbio/phylo/DistanceMatrixCalculator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.io.IOException;
44
import java.util.List;
5-
65
import org.biojava.nbio.core.alignment.template.SubstitutionMatrix;
76
import org.biojava.nbio.core.sequence.MultipleSequenceAlignment;
87
import org.biojava.nbio.core.sequence.template.Compound;
@@ -240,6 +239,7 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix fractio
240239
}
241240
}
242241
}
242+
243243
return DM;
244244
}
245245

biojava-phylo/src/main/java/org/biojava/nbio/phylo/ForesterWrapper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.ByteArrayOutputStream;
44
import java.io.IOException;
55
import java.io.OutputStream;
6-
76
import org.biojava.nbio.core.sequence.MultipleSequenceAlignment;
87
import org.biojava.nbio.core.sequence.io.FastaWriter;
98
import org.biojava.nbio.core.sequence.io.template.FastaHeaderFormatInterface;
@@ -38,12 +37,11 @@ private ForesterWrapper() {
3837
* BioJava MultipleSequenceAlignment
3938
* @return forester Msa object
4039
* @throws IOException
41-
* @throws Exception
4240
* if the conversion was not possible
4341
*/
4442
public static <C extends Sequence<D>, D extends Compound> Msa convert(
4543
MultipleSequenceAlignment<C, D> msa) throws IOException {
46-
44+
4745
// Convert the biojava MSA to a FASTA String
4846
OutputStream os = new ByteArrayOutputStream();
4947
FastaWriter<C, D> fastaW = new FastaWriter<C, D>(os,

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/MenuCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public static JMenuBar initJmolMenu(JFrame frame,
182182
}
183183
//Phylogenetics - only if it is a MultipleAlignment
184184
if (afpChain == null){
185-
JMenuItem tree = new JMenuItem(PHYLOGENETIC_TREE);
185+
JMenuItem tree = getIcon(parent, PHYLOGENETIC_TREE);
186186
tree.setMnemonic(KeyEvent.VK_T);
187187
view.add(tree);
188188
}

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public void actionPerformed(ActionEvent ae) {
415415
Phylogeny kimura = MultipleAlignmentTools
416416
.getKimuraTree(multAln);
417417
Phylogeny blosum = MultipleAlignmentTools
418-
.getFDSBLOSUM40Tree(multAln);
418+
.getBLOSUM40Tree(multAln);
419419
Phylogeny structural = MultipleAlignmentTools
420420
.getStructuralTree(multAln);
421421

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/SelectMultiplePanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public SelectMultiplePanel(boolean show2boxes){
6363

6464
Box vBox = Box.createVerticalBox();
6565

66-
input = new JTextField("1mbc 1hlb 1dlw 1ith.A 1thb.A 1kr7.A_0-110");
66+
input = new JTextField("1mbc 1hlb 1dlw 1ith.A 1thb.A 1kr7.A_0-109");
6767
Box b = getDomainPanel(input);
6868
vBox.add(b);
6969

biojava-structure/src/main/java/org/biojava/nbio/structure/align/multiple/util/MultipleAlignmentTools.java

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
import java.util.Arrays;
2626
import java.util.Collections;
2727
import java.util.Comparator;
28+
import java.util.HashMap;
2829
import java.util.List;
30+
import java.util.Map;
2931
import java.util.SortedSet;
3032
import java.util.TreeSet;
3133

@@ -794,13 +796,20 @@ public static MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound> toPr
794796

795797
MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound> msa = new MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound>();
796798

797-
// Extract the sequences and add them to the MSA
799+
Map<String, Integer> uniqueID = new HashMap<String, Integer>();
798800
List<String> seqs = getSequenceAlignment(msta);
799801
for (int i = 0; i < msta.size(); i++) {
800-
AccessionID id = new AccessionID(msta.getStructureIdentifier(i)
801-
.toString());
802+
// Make sure the identifiers are unique (required by AccessionID)
803+
String id = msta.getStructureIdentifier(i).toString();
804+
if (uniqueID.containsKey(id)) {
805+
uniqueID.put(id, uniqueID.get(id) + 1);
806+
id += "_" + uniqueID.get(id);
807+
} else
808+
uniqueID.put(id, 1);
809+
810+
AccessionID acc = new AccessionID(id);
802811
ProteinSequence pseq = new ProteinSequence(seqs.get(i));
803-
pseq.setAccession(id);
812+
pseq.setAccession(acc);
804813
msa.addAlignedSequence(pseq);
805814
}
806815
return msa;
@@ -857,8 +866,8 @@ public static Phylogeny getKimuraTree(MultipleAlignment msta)
857866
}
858867

859868
/**
860-
* Calculate a phylogenetic tree of the MultipleAlignment using fractional
861-
* dissimilarity scores (FDS), based in BLOSUM40 Substitution Matrix (ideal
869+
* Calculate a phylogenetic tree of the MultipleAlignment using
870+
* dissimilarity scores (DS), based in BLOSUM40 Substitution Matrix (ideal
862871
* for distantly related proteins, often the case in structural alignments)
863872
* and the Neighbor Joining algorithm from forester.
864873
*
@@ -868,16 +877,15 @@ public static Phylogeny getKimuraTree(MultipleAlignment msta)
868877
* @throws CompoundNotFoundException
869878
* @throws IOException
870879
*/
871-
public static Phylogeny getFDSBLOSUM40Tree(MultipleAlignment msta)
880+
public static Phylogeny getBLOSUM40Tree(MultipleAlignment msta)
872881
throws CompoundNotFoundException, IOException {
873882
MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound> msa = MultipleAlignmentTools
874883
.toProteinMSA(msta);
875884
BasicSymmetricalDistanceMatrix distmat = (BasicSymmetricalDistanceMatrix) DistanceMatrixCalculator
876-
.fractionalDissimilarityScore(msa,
877-
SubstitutionMatrixHelper.getBlosum40());
885+
.dissimilarityScore(msa, SubstitutionMatrixHelper.getBlosum40());
878886
Phylogeny tree = TreeConstructor.distanceTree(distmat,
879887
TreeConstructorType.NJ);
880-
tree.setName("FDS-BLOSUM40 Tree");
888+
tree.setName("BLOSUM40 Tree");
881889
return tree;
882890
}
883891

@@ -895,8 +903,18 @@ public static Phylogeny getStructuralTree(MultipleAlignment msta) {
895903
.getArray();
896904
BasicSymmetricalDistanceMatrix rmsdDist = (BasicSymmetricalDistanceMatrix) DistanceMatrixCalculator
897905
.structuralDistance(rmsdMat, 1, 5, 0.4);
898-
for (int i = 0; i < msta.size(); i++)
899-
rmsdDist.setIdentifier(i, msta.getStructureIdentifier(i).toString());
906+
// Set the identifiers of the matrix
907+
Map<String, Integer> alreadySeen = new HashMap<String, Integer>();
908+
for (int i = 0; i < msta.size(); i++) {
909+
// Make sure the identifiers are unique
910+
String id = msta.getStructureIdentifier(i).toString();
911+
if (alreadySeen.containsKey(id)) {
912+
alreadySeen.put(id, alreadySeen.get(id) + 1);
913+
id += "_" + alreadySeen.get(id);
914+
} else
915+
alreadySeen.put(id, 1);
916+
rmsdDist.setIdentifier(i, id);
917+
}
900918
Phylogeny tree = TreeConstructor.distanceTree(rmsdDist,
901919
TreeConstructorType.NJ);
902920
tree.setName("Structural Tree");

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/CeSymm.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ public static CeSymmResult analyze(Atom[] atoms, CESymmParameters params)
410410
if (result.isSignificant()) {
411411
// Optimize the global alignment freely once more (final step)
412412
if (params.getOptimization() && result.getSymmLevels() > 1) {
413+
//Remove the axes to do free superposition optimization
414+
SymmetryAxes axes = result.getAxes();
415+
result.setAxes(null);
413416
try {
414-
//Remove the axes to do free superposition optimization
415-
SymmetryAxes axes = result.getAxes();
416-
result.setAxes(null);
417417
SymmOptimizer optimizer = new SymmOptimizer(result);
418418
MultipleAlignment optimized = optimizer.optimize();
419419
// Set the optimized MultipleAlignment and the axes
@@ -422,6 +422,7 @@ public static CeSymmResult analyze(Atom[] atoms, CESymmParameters params)
422422
} catch (RefinerFailedException e) {
423423
logger.info("Final optimization failed:" + e.getMessage());
424424
// Return the un-optimized result instead
425+
result.setAxes(axes);
425426
return result;
426427
}
427428
}

0 commit comments

Comments
 (0)