Skip to content

Commit fac2101

Browse files
committed
Merge branch 'master' of github.com:biojava/biojava
# By lafita (44) and others # Via Andreas Prlic (6) and others * 'master' of github.com:biojava/biojava: (62 commits) Minor: removing extraneous try block Removing broken test of home directory Fix additional potential resource leaks in DownloadChemCompProvider Include test for StructureImpl object linking Clearing ChemComp cache whenever provider changes Fix resource leak in ReducedChemCompProvider Small fix to improve behavior for #398 Change substitution matrix to SDM for symmetry phylogeny Print a summary of internal symmetry in Jmol display Fix bug with ~ in StructureName Addin serializable interface Use HSDM substitution matrix instead of BLOSUM45 in MSA trees Change all references to Subunits to Repeats for consistency in CeSymm Move unused OpenRefiner to the symmetry project Create TestCeSymm with some easy examples that must be correct Bumping up java version as discussed in mailing list Updates for Joses request Handle symmetry refinement Exceptions Fix bugs in Phylogenetic tree display Superimpose freely at the end in case more than one symmetry level ...
2 parents 03f7646 + e0f5c73 commit fac2101

File tree

66 files changed

+3568
-1853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3568
-1853
lines changed

biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.io.BufferedOutputStream;
3434
import java.io.FileInputStream;
3535
import java.io.FileOutputStream;
36+
import java.io.IOException;
3637
import java.io.OutputStream;
3738
import java.util.Collection;
3839
import java.util.LinkedHashMap;
@@ -90,7 +91,7 @@ public void setLineSeparator(String lineSeparator){
9091
lineSep = lineSeparator.getBytes();
9192
}
9293

93-
public void process() throws Exception {
94+
public void process() throws IOException {
9495
// boolean closeit = false;
9596

9697

@@ -152,7 +153,7 @@ public static void main(String[] args) {
152153
fileOutputStream.close();
153154

154155

155-
} catch (Exception e) {
156+
} catch (IOException e) {
156157
logger.warn("Exception: ", e);
157158
}
158159
}

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/StructureTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import java.util.List;
3131
import java.util.Set;
3232

33-
import org.junit.Before;
33+
import org.junit.BeforeClass;
3434
import org.junit.Test;
3535

3636
import static org.junit.Assert.*;
@@ -44,10 +44,10 @@
4444

4545
public class StructureTest {
4646

47-
private Structure structure;
47+
private static Structure structure;
4848

49-
@Before
50-
public void setUp() throws IOException {
49+
@BeforeClass
50+
public static void setUp() throws IOException {
5151
InputStream inStream = StructureTest.class.getResourceAsStream("/5pti_old.pdb");
5252
assertNotNull(inStream);
5353

@@ -113,7 +113,10 @@ public void testReadPDBFile() throws Exception {
113113
assertTrue(c2.getAtomGroups(GroupType.NUCLEOTIDE).size() == 0 );
114114

115115
List<Compound> compounds= structure.getCompounds();
116-
assertTrue(compounds.size() == 1);
116+
117+
// from Biojava 4.2 on we are creating compounds whenever an entity is found to be without an assigned compound in the file
118+
// see issues https://github.com/biojava/biojava/issues/305 and https://github.com/biojava/biojava/pull/394
119+
assertEquals(2, compounds.size());
117120
Compound mol = compounds.get(0);
118121
assertTrue(mol.getMolName().startsWith("TRYPSIN INHIBITOR"));
119122
}
@@ -183,7 +186,10 @@ public void testPDBHeader(){
183186

184187

185188
List <Compound> compounds = structure.getCompounds();
186-
assertEquals("did not find the right number of compounds! ", 1, compounds.size());
189+
190+
// from Biojava 4.2 on we are creating compounds whenever an entity is found to be without an assigned compound in the file
191+
// see issues https://github.com/biojava/biojava/issues/305 and https://github.com/biojava/biojava/pull/394
192+
assertEquals("did not find the right number of compounds! ", 2, compounds.size());
187193

188194
Compound comp = compounds.get(0);
189195
assertEquals("did not get the right compounds info",true,comp.getMolName().startsWith("TRYPSIN INHIBITOR"));

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/TestAtomCachePerformance.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ public class TestAtomCachePerformance {
4949
private static final String[] PDB_IDS = {
5050
"1zjo", "2dqc", "4af2", "1r52", "4f3u", "1f9v", "3kuq", "2yr4", "3m4f", "4j5p",
5151
"7ccp", "4kro", "1x7q", "2gaw", "2kli", "2bdo", "3csf", "1muu", "190l", "2ecm"
52-
};//,
53-
//"2f0y", "3ind", "3uu6", "1p9j", "1vm7", "2y2c", "2hez", "1yrm", "1yzx", "1ps9",
54-
//"3ue0", "2o0o", "2g59", "4ees", "2yfc", "2anr", "3cxk", "2e7t", "3kmh", "3h00",
55-
//"3gdm", "1c0t", "1fi0", "2kqt", "1ky8", "169l", "1z6h", "1wbm", "4g1j", "1v3c",
56-
//"2chm", "4f0n", "2vxb", "2w0q", "1g1n", "3o6g", "4eug", "3nrm", "3heo", "4ewe",
57-
//"2xjb", "1vgj", "3tpp", "2gnl", "3jpz", "2pgt", "1fn2", "2h13", "1xyj", "1ds7",
58-
//"2x93", "4j5y", "2bk2", "1v83", "4lj9", "4ahc", "1m34", "1jo4", "3flb", "2cb2",
59-
//"4k3p", "1yq8", "2h7z", "2lbp", "3vas", "4jwn", "2e47", "3r43", "3edd", "3kss",
60-
//"2dnk", "1kg2", "2pwh", "1sjh", "4cc0", "3a7c", "1o5a", "4fu7", "3hc4", "3hoz"
61-
//};
52+
,
53+
"2f0y", "3ind", "3uu6", "1p9j", "1vm7", "2y2c", "2hez", "1yrm", "1yzx", "1ps9",
54+
"3ue0", "2o0o", "2g59", "4ees", "2yfc", "2anr", "3cxk", "2e7t", "3kmh", "3h00",
55+
"3gdm", "1c0t", "1fi0", "2kqt", "1ky8", "169l", "1z6h", "1wbm", "4g1j", "1v3c",
56+
"2chm", "4f0n", "2vxb", "2w0q", "1g1n", "3o6g", "4eug", "3nrm", "3heo", "4ewe",
57+
"2xjb", "1vgj", "3tpp", "2gnl", "3jpz", "2pgt", "1fn2", "2h13", "1xyj", "1ds7",
58+
"2x93", "4j5y", "2bk2", "1v83", "4lj9", "4ahc", "1m34", "1jo4", "3flb", "2cb2",
59+
"4k3p", "1yq8", "2h7z", "2lbp", "3vas", "4jwn", "2e47", "3r43", "3edd", "3kss",
60+
"2dnk", "1kg2", "2pwh", "1sjh", "4cc0", "3a7c", "1o5a", "4fu7", "3hc4", "3hoz"
61+
};
6262

6363
private static AtomCache cache;
6464

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/TestLongPdbVsMmCifParsing.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void testVeryLongPdbVsMmCif() throws IOException, StructureException {
124124

125125
@Test
126126
public void testSingle() throws IOException, StructureException {
127-
testAll(Arrays.asList("4a10"));
127+
testAll(Arrays.asList("2h5d"));
128128
}
129129

130130
@After
@@ -221,6 +221,12 @@ private void testStructureMethods(Structure sPdb, Structure sCif) {
221221
assertEquals("failed number of Compounds pdb vs cif", sPdb.getCompounds().size(), sCif.getCompounds().size());
222222

223223

224+
// ss bonds
225+
// 4ab9 contains an error in ssbond in pdb file (misses 1 ssbond)
226+
// 2bdi contains also errors, the counts in both differ a lot 80 vs 92
227+
if (!sPdb.getPDBCode().equals("4AB9") && !sPdb.getPDBCode().equals("2BDI"))
228+
assertEquals("number of ss bonds should coincide pdb vs cif", sPdb.getSSBonds().size(), sCif.getSSBonds().size());
229+
224230
}
225231

226232
private void testHeader(Structure sPdb, Structure sCif) {

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

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package org.biojava.nbio.phylo;
22

3+
import java.io.IOException;
34
import java.util.List;
4-
5-
import org.biojava.nbio.core.alignment.matrices.SubstitutionMatrixHelper;
65
import org.biojava.nbio.core.alignment.template.SubstitutionMatrix;
76
import org.biojava.nbio.core.sequence.MultipleSequenceAlignment;
8-
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound;
97
import org.biojava.nbio.core.sequence.template.Compound;
108
import org.biojava.nbio.core.sequence.template.Sequence;
119
import org.forester.evoinference.distance.PairwiseDistanceCalculator;
@@ -17,10 +15,7 @@
1715

1816
/**
1917
* 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.
18+
* {@link MultipleSequenceAlignment} or other indirect distance infomation (RMSD).
2419
*
2520
* @author Aleix Lafita
2621
* @since 4.1.1
@@ -32,8 +27,7 @@ public class DistanceMatrixCalculator {
3227
.getLogger(DistanceMatrixCalculator.class);
3328

3429
/** Prevent instantiation */
35-
private DistanceMatrixCalculator() {
36-
}
30+
private DistanceMatrixCalculator() {}
3731

3832
/**
3933
* The fractional dissimilarity (D) is defined as the percentage of sites
@@ -51,17 +45,12 @@ private DistanceMatrixCalculator() {
5145
* @param msa
5246
* MultipleSequenceAlignment
5347
* @return DistanceMatrix
48+
* @throws Exception
5449
*/
5550
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-
}
51+
MultipleSequenceAlignment<C, D> msa) throws IOException {
6452

53+
Msa fMsa = ForesterWrapper.convert(msa);
6554
DistanceMatrix DM = PairwiseDistanceCalculator
6655
.calcFractionalDissimilarities(fMsa);
6756

@@ -83,17 +72,12 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix fractio
8372
* @param msa
8473
* MultipleSequenceAlignment
8574
* @return DistanceMatrix
75+
* @throws IOException
8676
*/
8777
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-
}
78+
MultipleSequenceAlignment<C, D> msa) throws IOException {
9679

80+
Msa fMsa = ForesterWrapper.convert(msa);
9781
DistanceMatrix DM = PairwiseDistanceCalculator
9882
.calcPoissonDistances(fMsa);
9983

@@ -120,17 +104,12 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix poisson
120104
* @param msa
121105
* MultipleSequenceAlignment
122106
* @return DistanceMatrix
107+
* @throws IOException
123108
*/
124109
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-
}
110+
MultipleSequenceAlignment<C, D> msa) throws IOException {
133111

112+
Msa fMsa = ForesterWrapper.convert(msa);
134113
DistanceMatrix DM = PairwiseDistanceCalculator
135114
.calcPoissonDistances(fMsa);
136115

@@ -260,6 +239,7 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix fractio
260239
}
261240
}
262241
}
242+
263243
return DM;
264244
}
265245

@@ -327,12 +307,13 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix dissimi
327307
.get(j).getCompoundAt(k + 1));
328308
}
329309

330-
if (i != j)
310+
if (i != j){
311+
score = Math.max(score, 0.0);
331312
DM.setValue(i, j, score);
313+
}
332314

333-
if (score > maxscore) {
315+
if (score > maxscore)
334316
maxscore = score;
335-
}
336317
}
337318
}
338319

@@ -344,7 +325,7 @@ public static <C extends Sequence<D>, D extends Compound> DistanceMatrix dissimi
344325
if (i == j)
345326
DM.setValue(i, j, 0.0);
346327
else {
347-
double dS = maxscore - DM.getValue(i, j);
328+
double dS = Math.max(maxscore - DM.getValue(i, j), 0);
348329
DM.setValue(i, j, dS);
349330
DM.setValue(j, i, dS);
350331
}
@@ -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
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.biojava.nbio.phylo;
22

33
import java.io.ByteArrayOutputStream;
4+
import java.io.IOException;
45
import java.io.OutputStream;
5-
66
import org.biojava.nbio.core.sequence.MultipleSequenceAlignment;
77
import org.biojava.nbio.core.sequence.io.FastaWriter;
88
import org.biojava.nbio.core.sequence.io.template.FastaHeaderFormatInterface;
@@ -36,12 +36,12 @@ private ForesterWrapper() {
3636
* @param msa
3737
* BioJava MultipleSequenceAlignment
3838
* @return forester Msa object
39-
* @throws Exception
39+
* @throws IOException
4040
* if the conversion was not possible
4141
*/
4242
public static <C extends Sequence<D>, D extends Compound> Msa convert(
43-
MultipleSequenceAlignment<C, D> msa) throws Exception {
44-
43+
MultipleSequenceAlignment<C, D> msa) throws IOException {
44+
4545
// Convert the biojava MSA to a FASTA String
4646
OutputStream os = new ByteArrayOutputStream();
4747
FastaWriter<C, D> fastaW = new FastaWriter<C, D>(os,
@@ -52,6 +52,7 @@ public String getHeader(C sequence) {
5252
return sequence.getAccession().toString();
5353
};
5454
});
55+
5556
fastaW.process();
5657
String fastaMSA = os.toString();
5758

@@ -68,10 +69,10 @@ public String getHeader(C sequence) {
6869
* @param writeDistances
6970
* write the branch lengths if true
7071
* @return
71-
* @throws Exception
72+
* @throws IOException
7273
*/
7374
public static String getNewickString(Phylogeny phylo,
74-
boolean writeDistances) throws Exception {
75+
boolean writeDistances) throws IOException {
7576

7677
PhylogenyWriter w = new PhylogenyWriter();
7778
StringBuffer newickString = w.toNewHampshire(phylo, writeDistances);

biojava-structure-gui/src/main/java/demo/DemoCeSymm.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
import org.biojava.nbio.structure.Structure;
2626
import org.biojava.nbio.structure.StructureException;
2727
import org.biojava.nbio.structure.StructureTools;
28-
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
2928
import org.biojava.nbio.structure.align.util.AtomCache;
3029
import org.biojava.nbio.structure.symmetry.gui.SymmetryDisplay;
3130
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters;
3231
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters.RefineMethod;
3332
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters.SymmetryType;
3433
import org.biojava.nbio.structure.symmetry.internal.CeSymm;
34+
import org.biojava.nbio.structure.symmetry.internal.CeSymmResult;
3535

3636
/**
3737
* Quick demo of how to call CE-Symm programmatically.
@@ -78,21 +78,19 @@ public static void main(String[] args)
7878
Structure s = cache.getStructure(name);
7979
Atom[] atoms = StructureTools.getRepresentativeAtomArray(s);
8080

81-
CeSymm ceSymm = new CeSymm();
82-
8381
//Choose some parameters
84-
CESymmParameters params = ceSymm.getParameters();
85-
params.setRefineMethod(RefineMethod.SINGLE);
82+
CESymmParameters params = new CESymmParameters();
83+
params.setRefineMethod(RefineMethod.SEQUENCE_FUNCTION);
8684
params.setSymmType(SymmetryType.AUTO);
8785
params.setOptimization(true);
8886
params.setSymmLevels(0);
8987
params.setSSEThreshold(2);
9088

9189
//Run the alignment
92-
MultipleAlignment symmetry = ceSymm.analyze(atoms, params);
90+
CeSymmResult result = CeSymm.analyze(atoms, params);
9391

9492
//Display the results in jmol
95-
SymmetryDisplay.display(symmetry, ceSymm.getSymmetryAxes());
93+
SymmetryDisplay.display(result);
9694
}
9795

9896
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class MenuCreator {
6565
public static final String DOT_PLOT = "Show Dot Plot";
6666
public static final String PAIRWISE_ALIGN = "New Pairwise Alignment";
6767
public static final String MULTIPLE_ALIGN = "New Multiple Alignment";
68+
public static final String PHYLOGENETIC_TREE = "Phylogenetic Tree";
6869
protected static final int keyMask =
6970
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
7071

@@ -179,6 +180,12 @@ public static JMenuBar initJmolMenu(JFrame frame,
179180
dotplot.addActionListener(new DotPlotListener(afpChain));
180181
view.add(dotplot);
181182
}
183+
//Phylogenetics - only if it is a MultipleAlignment
184+
if (afpChain == null){
185+
JMenuItem tree = getIcon(parent, PHYLOGENETIC_TREE);
186+
tree.setMnemonic(KeyEvent.VK_T);
187+
view.add(tree);
188+
}
182189
}
183190
menu.add(view);
184191

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import org.biojava.nbio.structure.align.gui.jmol.MultipleAlignmentJmol;
4242
import org.biojava.nbio.structure.align.multiple.Block;
4343
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
44-
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentUtils;
44+
import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentDisplay;
4545
import org.slf4j.Logger;
4646
import org.slf4j.LoggerFactory;
4747

@@ -186,7 +186,7 @@ public static void showAlignmentImage(MultipleAlignment multAln,
186186
public static MultipleAlignmentJmol display(MultipleAlignment multAln)
187187
throws StructureException {
188188

189-
List<Atom[]> rotatedAtoms = MultipleAlignmentUtils.getRotatedAtoms(multAln);
189+
List<Atom[]> rotatedAtoms = MultipleAlignmentDisplay.getRotatedAtoms(multAln);
190190

191191
MultipleAlignmentJmol jmol =
192192
new MultipleAlignmentJmol(multAln, rotatedAtoms);

0 commit comments

Comments
 (0)