Skip to content

Commit 156a6e2

Browse files
committed
Merge branch 'master' of github.com:biojava/biojava
# By lafita (20) and others # Via Spencer Bliven (3) and Aleix Lafita (1) * 'master' of github.com:biojava/biojava: (27 commits) Fix ArrayIndexOutOfBounds due to iterating over too-short proteins biojava#320 updating API setting timeout when talking to Hmmer server biojava#320 updating API adding icon (for display e.g. in SourceTree) Bond and SSBond now implemented as interfaces backed by BondImpl and SSBondImpl, respectively. Change logger messages of CeSymm to info level Fix NullPointer bug in CeSymm Add all scores to non-optimized symmetry results Fix small bug with short non-symmetric alignments Fix bug when result was not symmetric in CeSymm Set title when displaying symmetry alignment Disallow MC optimization in parallel Method to clone parameters in CeSymm Port two tests for internal symmetry package Improve symmetry error messages Check for symmetry significance in MultipleAlignment Add new parameter for distance cutoff to MC optimization Fix bug in CeSymm iteration process Add demo for point group internal symmetry calculation ...
2 parents 1570e12 + d7133ca commit 156a6e2

36 files changed

Lines changed: 1655 additions & 1127 deletions

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package demo;
22

33
import java.io.IOException;
4-
import java.util.ArrayList;
5-
import java.util.List;
6-
74
import org.biojava.nbio.structure.Atom;
85
import org.biojava.nbio.structure.Structure;
96
import org.biojava.nbio.structure.StructureException;
@@ -55,13 +52,11 @@ public static void main(String[] args)
5552

5653
//Set the name of the protein structure to analyze
5754
String name = "1vym";
58-
List<Atom[]> atoms = new ArrayList<Atom[]>();
5955

6056
//Download the atoms
6157
AtomCache cache = new AtomCache();
6258
Structure s = cache.getStructure(name);
63-
Atom[] array = StructureTools.getRepresentativeAtomArray(s);
64-
atoms.add(array);
59+
Atom[] atoms = StructureTools.getRepresentativeAtomArray(s);
6560

6661
CeSymm ceSymm = new CeSymm();
6762

@@ -73,7 +68,7 @@ public static void main(String[] args)
7368
params.setMultipleAxes(true);
7469

7570
//Run the alignment
76-
MultipleAlignment symmetry = ceSymm.align(atoms, params);
71+
MultipleAlignment symmetry = ceSymm.analyze(atoms, params);
7772

7873
//Display the results in jmol
7974
SymmetryDisplay.display(symmetry, ceSymm.getSymmetryAxes());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.biojava.nbio.structure.Atom;
1010
import org.biojava.nbio.structure.StructureException;
1111
import org.biojava.nbio.structure.align.StructureAlignment;
12-
import org.biojava.nbio.structure.align.fatcat.FatCatFlexible;
12+
import org.biojava.nbio.structure.align.ce.CeMain;
1313
import org.biojava.nbio.structure.align.gui.MultipleAlignmentDisplay;
1414
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
1515
import org.biojava.nbio.structure.align.multiple.mc.MultipleMcMain;
@@ -78,8 +78,8 @@ public static void main(String[] args) throws IOException, StructureException, I
7878
}
7979

8080
//Here the multiple structural alignment algorithm comes in place to generate the alignment object
81-
StructureAlignment pairwise = new FatCatFlexible();
82-
//StructureAlignment pairwise = new CeMain();
81+
//StructureAlignment pairwise = new FatCatFlexible();
82+
StructureAlignment pairwise = new CeMain();
8383
MultipleMcMain algorithm = new MultipleMcMain(pairwise);
8484
MultipleMcParameters params = (MultipleMcParameters) algorithm.getParameters();
8585
params.setMinBlockLen(10);

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.biojava.nbio.structure.align.webstart.AligUIManager;
3737
import org.biojava.nbio.structure.jama.Matrix;
3838
import org.jcolorbrewer.ColorBrewer;
39+
import org.slf4j.Logger;
40+
import org.slf4j.LoggerFactory;
3941

4042
/**
4143
* A class that provides a 3D visualization Frame in Jmol for
@@ -54,6 +56,9 @@ public class MultipleAlignmentJmol extends AbstractAlignmentJmol {
5456

5557
private static final String LIGAND_DISPLAY_SCRIPT =
5658
"select ligand; wireframe 40; spacefill 120; color CPK;";
59+
60+
private static final Logger logger =
61+
LoggerFactory.getLogger(MultipleAlignmentJmol.class);
5762

5863
/**
5964
* Default constructor creates an empty JmolPanel window,
@@ -235,7 +240,7 @@ public void actionPerformed(ActionEvent e) {
235240

236241
@Override
237242
public void actionPerformed(ActionEvent e) {
238-
System.out.println("reset!!");
243+
logger.info("reset!!");
239244
jmolPanel.executeCmd("restore STATE state_1");
240245

241246
}
@@ -315,25 +320,24 @@ protected void initCoords(){
315320
if ( structure != null)
316321
setStructure(structure);
317322
else {
318-
System.err.println("could not find anything to display!");
323+
logger.error("Could not find anything to display!");
319324
return;
320325
}
321326
}
322-
Structure artificial = MultipleAlignmentDisplay.
323-
getAlignedStructure(transformedAtoms);
324-
325327
PDBHeader header = new PDBHeader();
326328
String title = multAln.getEnsemble().getAlgorithmName() +
327329
" V." +multAln.getEnsemble().getVersion() + " : ";
328330

329331
for (String name:multAln.getEnsemble().getStructureNames()){
330332
title += name + " ";
331333
}
334+
Structure artificial = MultipleAlignmentDisplay.
335+
getAlignedStructure(transformedAtoms);
332336

333-
System.out.println(title);
334-
header.setTitle(title);
335337
artificial.setPDBHeader(header);
336338
setStructure(artificial);
339+
header.setTitle(title);
340+
logger.info(title);
337341

338342
} catch (StructureException e){
339343
e.printStackTrace();
@@ -352,23 +356,22 @@ public void actionPerformed(ActionEvent e) {
352356
String cmd = e.getActionCommand();
353357
if ( cmd.equals(MenuCreator.TEXT_ONLY)) {
354358
if ( multAln == null) {
355-
System.err.println("Currently not viewing an alignment!");
359+
logger.error("Currently not viewing an alignment!");
356360
return;
357361
}
358-
System.out.println(
359-
"Option currently not available for Multiple Alignments");
362+
logger.warn("Option not available for MultipleAlignments");
360363

361364
} else if ( cmd.equals(MenuCreator.PAIRS_ONLY)) {
362365
if ( multAln == null) {
363-
System.err.println("Currently not viewing an alignment!");
366+
logger.error("Currently not viewing an alignment!");
364367
return;
365368
}
366369
String result = MultipleAlignmentWriter.toAlignedResidues(multAln);
367370
MultipleAlignmentDisplay.showAlignmentImage(multAln, result);
368371

369372
} else if (cmd.equals(MenuCreator.ALIGNMENT_PANEL)){
370373
if ( multAln == null) {
371-
System.err.println("Currently not viewing an alignment!");
374+
logger.error("Currently not viewing an alignment!");
372375
return;
373376
}
374377
try {
@@ -380,7 +383,7 @@ public void actionPerformed(ActionEvent e) {
380383

381384
} else if (cmd.equals(MenuCreator.FATCAT_TEXT)){
382385
if ( multAln == null) {
383-
System.err.println("Currently not viewing an alignment!");
386+
logger.error("Currently not viewing an alignment!");
384387
return;
385388
}
386389
String result = MultipleAlignmentWriter.toFatCat(multAln)+"\n";
@@ -516,7 +519,7 @@ public void resetDisplay() {
516519
if (multAln != null && transformedAtoms != null) {
517520
String script = getJmolString(multAln, transformedAtoms,
518521
colorPalette, colorByBlocks.isSelected());
519-
//System.out.println(script);
522+
logger.debug(script);
520523
evalString(script);
521524
jmolPanel.evalString("save STATE state_1");
522525
}

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/gui/SymmetryCalc.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ public SymmetryCalc(SymmetryGui p, Structure s, String n) {
4848
public void run() {
4949

5050
//The structure has been downloaded, now calculate the alignment ...
51-
CeSymm algorithm = parent.getSymmetryAlgorithm();
52-
CESymmParameters params = (CESymmParameters) algorithm.getParameters();
51+
CeSymm ceSymm = parent.getSymmetryAlgorithm();
52+
CESymmParameters params = (CESymmParameters) ceSymm.getParameters();
5353

5454
try {
5555

56-
List<Atom[]> atoms = new ArrayList<Atom[]>();
57-
atoms.add(StructureTools.getRepresentativeAtomArray(structure));
56+
Atom[] atoms = StructureTools.getRepresentativeAtomArray(structure);
5857

59-
MultipleAlignment msa = algorithm.align(atoms);
58+
MultipleAlignment msa = ceSymm.analyze(atoms);
6059

6160
List<String> names = new ArrayList<String>();
6261
for (int su=0; su<msa.size(); su++){
@@ -65,7 +64,7 @@ public void run() {
6564
msa.getEnsemble().setStructureNames(names);
6665

6766
MultipleAlignmentJmol jmol =
68-
SymmetryDisplay.display(msa, algorithm.getSymmetryAxes());
67+
SymmetryDisplay.display(msa, ceSymm.getSymmetryAxes());
6968
String title = jmol.getTitle();
7069

7170
if (params != null)

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/gui/SymmetryDisplay.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,19 @@ public static MultipleAlignmentJmol displayFull(MultipleAlignment msa)
7272
public static MultipleAlignmentJmol display(MultipleAlignment msa,
7373
SymmetryAxes axes) throws StructureException {
7474

75-
List<Atom[]> atoms = msa.getAtomArrays();
76-
77-
MultipleAlignmentJmol jmol = new MultipleAlignmentJmol(msa, atoms);
78-
79-
addSymmetryMenu(jmol, axes);
80-
81-
//Show point group symmetry
82-
jmol.evalString(printPointGroupAxes(msa));
75+
MultipleAlignmentJmol jmol = null;
76+
77+
if (SymmetryTools.isRefined(msa)){
78+
List<Atom[]> atoms = msa.getAtomArrays();
79+
jmol = new MultipleAlignmentJmol(msa, atoms);
80+
jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle());
81+
addSymmetryMenu(jmol, axes);
82+
jmol.evalString(printPointGroupAxes(msa));
83+
} else {
84+
//Show the optimal alignment if it was not refined
85+
jmol = MultipleAlignmentDisplay.display(msa);
86+
jmol.setColorByBlocks(true);
87+
}
8388

8489
return jmol;
8590
}

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/gui/SymmetryListener.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.biojava.nbio.structure.align.gui.jmol.MultipleAlignmentJmol;
88
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
99
import org.biojava.nbio.structure.symmetry.internal.SymmetryAxes;
10+
import org.slf4j.Logger;
11+
import org.slf4j.LoggerFactory;
1012

1113
/**
1214
* Action Listener for the symmetry menu.
@@ -21,10 +23,13 @@ public class SymmetryListener implements ActionListener{
2123
private MultipleAlignmentJmol jmol;
2224
private MultipleAlignment msa;
2325
private SymmetryAxes axes;
26+
27+
private static final Logger logger =
28+
LoggerFactory.getLogger(SymmetryListener.class);
2429

2530
public SymmetryListener(MultipleAlignmentJmol jmol, SymmetryAxes axes) {
2631
this.jmol = jmol;
27-
this.msa = jmol.getMultipleAlignment();
32+
if (jmol != null) this.msa = jmol.getMultipleAlignment();
2833
this.axes = axes;
2934
}
3035

@@ -34,7 +39,7 @@ public void actionPerformed(ActionEvent ae) {
3439
String cmd = ae.getActionCommand();
3540
if (cmd.equals("Subunit Superposition")){
3641
if (msa == null) {
37-
System.err.println("Currently not displaying a symmetry!");
42+
logger.error("Currently not displaying a symmetry!");
3843
return;
3944
}
4045
try {
@@ -47,7 +52,7 @@ public void actionPerformed(ActionEvent ae) {
4752

4853
} else if (cmd.equals("Multiple Structure Alignment")){
4954
if (msa == null) {
50-
System.err.println("Currently not displaying a symmetry!");
55+
logger.error("Currently not displaying a symmetry!");
5156
return;
5257
}
5358
try {
@@ -59,18 +64,20 @@ public void actionPerformed(ActionEvent ae) {
5964
}
6065

6166
} else if (cmd.equals("Point Group Symmetry")){
62-
if (msa != null) {
63-
String script = SymmetryDisplay.printPointGroupAxes(msa);
64-
jmol.evalString(script);
67+
if (msa == null) {
68+
logger.error("Currently not displaying a symmetry!");
6569
return;
6670
}
71+
String script = SymmetryDisplay.printPointGroupAxes(msa);
72+
jmol.evalString(script);
73+
return;
6774

6875
} else if (cmd.equals("Show Symmetry Axes")){
6976
if (axes != null) {
7077
String s = SymmetryDisplay.printSymmetryAxes(msa, axes, false);
7178
jmol.evalString(s);
7279
return;
73-
} else System.err.println("No axes for this symmetry");
80+
} else logger.error("No axes found for this symmetry result");
7481

7582
} else if (cmd.equals("New Symmetry Analysis")){
7683
SymmetryGui.getInstance();

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package demo;
22

33
import java.io.IOException;
4-
import java.util.ArrayList;
5-
import java.util.List;
64

75
import org.biojava.nbio.structure.Atom;
86
import org.biojava.nbio.structure.Structure;
@@ -11,10 +9,12 @@
119
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
1210
import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentWriter;
1311
import org.biojava.nbio.structure.align.util.AtomCache;
12+
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
1413
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters;
1514
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters.RefineMethod;
1615
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters.SymmetryType;
1716
import org.biojava.nbio.structure.symmetry.internal.CeSymm;
17+
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
1818

1919
/**
2020
* Quick demo of how to call CE-Symm programmatically.
@@ -55,13 +55,11 @@ public static void main(String[] args)
5555

5656
//Set the name of the protein structure to analyze
5757
String name = "1u6d";
58-
List<Atom[]> atoms = new ArrayList<Atom[]>();
5958

6059
//Download the atoms
6160
AtomCache cache = new AtomCache();
6261
Structure s = cache.getStructure(name);
63-
Atom[] array = StructureTools.getRepresentativeAtomArray(s);
64-
atoms.add(array);
62+
Atom[] atoms = StructureTools.getRepresentativeAtomArray(s);
6563

6664
CeSymm ceSymm = new CeSymm();
6765

@@ -73,10 +71,14 @@ public static void main(String[] args)
7371
params.setMultipleAxes(true);
7472

7573
//Run the alignment
76-
MultipleAlignment symmetry = ceSymm.align(atoms, params);
77-
74+
MultipleAlignment symmetry = ceSymm.analyze(atoms, params);
75+
7876
//Display the results in FatCat format
7977
System.out.println(MultipleAlignmentWriter.toFatCat(symmetry));
78+
79+
//Obtain the point group symmetry
80+
QuatSymmetryResults pg = SymmetryTools.getQuaternarySymmetry(symmetry);
81+
System.out.println("Point group internal symmetry: "+pg.getSymmetry());
8082
}
8183

8284
}

0 commit comments

Comments
 (0)