Skip to content

Commit 0a31add

Browse files
committed
Merge branch 'master' of github.com:biojava/biojava into dev
2 parents b9d78c6 + ed563e3 commit 0a31add

48 files changed

Lines changed: 887 additions & 449 deletions

Some content is hidden

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void testReadPDBFile() throws Exception {
119119
assertEquals(64, c2.getAtomGroups(GroupType.HETATM).size());
120120
assertEquals(0, c2.getAtomGroups(GroupType.NUCLEOTIDE).size());
121121

122-
List<EntityInfo> compounds= structure.getEntityInformation();
122+
List<EntityInfo> compounds= structure.getEntityInfos();
123123

124124
// from Biojava 4.2 on we are creating compounds whenever an entity is found to be without an assigned compound in the file
125125
// see issues https://github.com/biojava/biojava/issues/305 and https://github.com/biojava/biojava/pull/394
@@ -203,7 +203,7 @@ public void testPDBHeader(){
203203
assertEquals("the technique in the Header is " + technique, techShould, technique);
204204

205205

206-
List <EntityInfo> compounds = structure.getEntityInformation();
206+
List <EntityInfo> compounds = structure.getEntityInfos();
207207

208208
// from Biojava 4.2 on we are creating compounds whenever an entity is found to be without an assigned compound in the file
209209
// see issues https://github.com/biojava/biojava/issues/305 and https://github.com/biojava/biojava/pull/394

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

Lines changed: 31 additions & 14 deletions
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("1bcr"));
127+
testAll(Arrays.asList("3hbx"));
128128
}
129129

130130
@After
@@ -207,19 +207,36 @@ private void testStructureMethods(Structure sPdb, Structure sCif) {
207207
// TODO journal article not parsed in mmCIF parser
208208
//assertEquals("failed hasJournalArticle",sPdb.hasJournalArticle(),sCif.hasJournalArticle());
209209

210-
// compounds: there's quite some inconsistencies here between pdb and cif:
210+
// entity type should always be present
211+
for (EntityInfo e: sPdb.getEntityInfos()) {
212+
assertNotNull(e.getType());
213+
}
214+
215+
for (EntityInfo e: sCif.getEntityInfos()) {
216+
assertNotNull(e.getType());
217+
}
218+
219+
// entities: there's quite some inconsistencies here between pdb and cif:
211220
// sugar polymers are not in pdb at all: we avoid them
212-
boolean canCompareCompoundsSize = true;
213-
for (EntityInfo compound: sCif.getEntityInformation()) {
214-
if (compound.getDescription()==null || compound.getDescription().contains("SUGAR")) {
215-
canCompareCompoundsSize = false;
216-
break;
217-
}
221+
boolean canCompareEntityCounts = true;
222+
for (EntityInfo e:sCif.getEntityInfos()) {
223+
if (e.getDescription().contains("SUGAR")) canCompareEntityCounts = false;
218224
}
225+
if (canCompareEntityCounts) {
226+
int entCountCif = 0;
227+
for (EntityInfo e: sCif.getEntityInfos()) {
228+
if (e.getType() == EntityType.POLYMER)
229+
entCountCif++;
219230

220-
if (canCompareCompoundsSize)
221-
assertEquals("failed number of Compounds pdb vs cif", sPdb.getEntityInformation().size(), sCif.getEntityInformation().size());
231+
}
232+
int entCountPdb = 0;
233+
for (EntityInfo e:sPdb.getEntityInfos()) {
234+
if (e.getType() == EntityType.POLYMER)
235+
entCountPdb++;
236+
}
222237

238+
assertEquals("failed number of non-sugar polymeric Entities pdb vs cif", entCountPdb, entCountCif);
239+
}
223240

224241
// ss bonds
225242
// 4ab9 contains an error in ssbond in pdb file (misses 1 ssbond)
@@ -410,13 +427,13 @@ private void testSingleChain(Chain cPdb, Chain cCif) {
410427

411428
// getCompound() is some times null for badly formatted PDB files (e.g. 4a10, all waters are in a separate chain F)
412429
if (isPolymer(cPdb)) {
413-
assertNotNull("getCompound is null in pdb (chain "+chainId+")",cPdb.getCompound());
414-
assertNotNull("getCompound is null in cif (chain "+chainId+")",cCif.getCompound());
430+
assertNotNull("getCompound is null in pdb (chain "+chainId+")",cPdb.getEntityInfo());
431+
assertNotNull("getCompound is null in cif (chain "+chainId+")",cCif.getEntityInfo());
415432

416433
// for some badly formatted entries there are mismatches of mol_ids on pdb cs mmcif, e.g. 2efw
417434
// we thus count them and only warn at the end
418-
int molIdPdb = cPdb.getCompound().getMolId();
419-
int molIdCif = cCif.getCompound().getMolId();
435+
int molIdPdb = cPdb.getEntityInfo().getMolId();
436+
int molIdCif = cCif.getEntityInfo().getMolId();
420437
if (molIdPdb!=molIdCif) {
421438
logger.warn("Mismatching mol_id (entity_id) for {}. pdb: {}, mmCIF: {}",pdbId,molIdPdb,molIdCif);
422439
pdbIdsWithMismatchingMolIds.add(pdbId);

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import org.biojava.nbio.structure.jama.Matrix;
4242
import org.jcolorbrewer.ColorBrewer;
4343
import org.jmol.api.JmolViewer;
44+
import org.slf4j.Logger;
45+
import org.slf4j.LoggerFactory;
4446

4547
/**
4648
* An Abstract Class to generalize the visualization of AFP and
@@ -52,6 +54,7 @@
5254
public abstract class AbstractAlignmentJmol
5355
implements MouseMotionListener, MouseListener, WindowListener, ActionListener {
5456

57+
private static final Logger logger = LoggerFactory.getLogger(AbstractAlignmentJmol.class);
5558
protected Structure structure;
5659
protected ColorBrewer colorPalette = ColorBrewer.Spectral;
5760

@@ -81,7 +84,7 @@ public abstract class AbstractAlignmentJmol
8184
* Set all the member variables to null.
8285
*/
8386
public void destroy(){
84-
System.err.println("cleaning up AlignmentJmol window");
87+
logger.debug("cleaning up AlignmentJmol window");
8588
jmolPanel.removeMouseListener(this);
8689
jmolPanel.removeMouseMotionListener(this);
8790
jmolPanel.destroy();
@@ -135,7 +138,7 @@ public void setJmolPanel(JmolPanel jmolPanel) {
135138
*/
136139
public void evalString(String rasmolScript){
137140
if ( jmolPanel == null ){
138-
System.err.println("please install Jmol first");
141+
logger.error("please install Jmol first");
139142
return;
140143
}
141144
jmolPanel.evalString(rasmolScript);
@@ -148,7 +151,7 @@ public void evalString(String rasmolScript){
148151
public void setStructure(Structure s) {
149152

150153
if (jmolPanel == null){
151-
System.err.println("please install Jmol first");
154+
logger.error("please install Jmol first");
152155
return;
153156
}
154157
setTitle(s.getPDBCode());

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

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
package org.biojava.nbio.structure.symmetry.gui;
2222

2323
import java.awt.event.KeyEvent;
24+
import java.util.ArrayList;
25+
import java.util.Arrays;
2426
import java.util.List;
27+
import java.util.Set;
28+
import java.util.TreeSet;
2529

2630
import javax.swing.JMenu;
2731
import javax.swing.JMenuBar;
@@ -40,10 +44,12 @@
4044
import org.biojava.nbio.structure.symmetry.core.AxisAligner;
4145
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
4246
import org.biojava.nbio.structure.symmetry.internal.CeSymmResult;
47+
import org.biojava.nbio.structure.symmetry.internal.SymmetryAxes;
4348
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGenerator;
4449
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGeneratorPointGroup;
4550
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
46-
import org.jmol.util.Logger;
51+
import org.slf4j.Logger;
52+
import org.slf4j.LoggerFactory;
4753

4854
/**
4955
* Class that provides visualizations methods for symmetry alignments. Call the
@@ -54,6 +60,9 @@
5460
*
5561
*/
5662
public class SymmetryDisplay {
63+
64+
private static final Logger logger = LoggerFactory
65+
.getLogger(SymmetryDisplay.class);
5766

5867
/**
5968
* Displays a multiple alignment of the symmetry repeats.
@@ -110,12 +119,12 @@ public static AbstractAlignmentJmol display(CeSymmResult symmResult)
110119
jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle());
111120
addSymmetryMenu(jmol, symmResult);
112121
jmol.evalString(printSymmetryGroup(symmResult));
113-
jmol.evalString(printSymmetryAxes(symmResult, false));
122+
jmol.evalString(printSymmetryAxes(symmResult));
114123
jmol.setTitle(getSymmTitle(symmResult));
115124
return jmol;
116125
} else {
117126
// Show the optimal self-alignment
118-
Logger.info("Showing optimal self-alignment");
127+
logger.info("Showing optimal self-alignment");
119128
Atom[] cloned = StructureTools
120129
.cloneAtomArray(symmResult.getAtoms());
121130
AbstractAlignmentJmol jmol = StructureAlignmentDisplay.display(
@@ -177,30 +186,31 @@ private static void addSymmetryMenu(MultipleAlignmentJmol jmol,
177186
/**
178187
* Generates a String that displays the symmetry axes of a structure.
179188
*
180-
* @param msa
181-
* @param axes
182-
* @param elementary
183-
* only print elementary axes if true
189+
* @param symm CeSymmResult
184190
* @return
191+
* @throws StructureException
185192
*/
186-
public static String printSymmetryAxes(CeSymmResult symm, boolean elementary) {
193+
public static String printSymmetryAxes(CeSymmResult symm)
194+
throws StructureException {
187195

188196
int id = 0;
189197
String script = "";
190-
Atom[] atoms = symm.getAtoms();
191-
192-
List<Matrix4d> symmAxes = null;
193-
if (elementary) {
194-
symmAxes = symm.getAxes().getElementaryAxes();
195-
} else {
196-
symmAxes = symm.getAxes().getSymmetryAxes();
197-
}
198-
199-
for (Matrix4d axis : symmAxes) {
200-
RotationAxis rot = new RotationAxis(axis);
201-
script += rot.getJmolScript(atoms, id);
198+
SymmetryAxes axes = symm.getAxes();
199+
List<Atom[]> repeats = SymmetryTools.toRepeatsAlignment(symm).getAtomArrays();
200+
201+
List<Matrix4d> symmAxes = axes.getElementaryAxes();
202+
for (int a = 0; a < symmAxes.size(); a++) {
203+
RotationAxis rot = new RotationAxis(symmAxes.get(a));
204+
Set<Integer> repIndex = new TreeSet<Integer>(axes.getRepeatRelation(a).get(0));
205+
repIndex.addAll(axes.getRepeatRelation(a).get(1));
206+
List<Atom> repAtoms = new ArrayList<Atom>();
207+
for (Integer r : repIndex)
208+
repAtoms.addAll(Arrays.asList(repeats.get(r)));
209+
210+
script += rot.getJmolScript(repAtoms.toArray(new Atom[repAtoms.size()]), id);
202211
id++;
203212
}
213+
204214
return script;
205215
}
206216

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ public void actionPerformed(ActionEvent ae) {
6666
try {
6767
if (cmd.equals("Repeats Superposition")) {
6868
MultipleAlignmentJmol j = SymmetryDisplay.displayRepeats(symm);
69-
String s = SymmetryDisplay.printSymmetryAxes(symm, true);
69+
String s = SymmetryDisplay.printSymmetryAxes(symm);
7070
j.evalString(s);
7171

7272
} else if (cmd.equals("Multiple Structure Alignment")) {
7373
MultipleAlignmentJmol j = SymmetryDisplay.displayFull(symm);
74-
String s = SymmetryDisplay.printSymmetryAxes(symm, false);
74+
String s = SymmetryDisplay.printSymmetryAxes(symm);
7575
j.evalString(s);
7676

7777
} else if (cmd.equals("Optimal Self Alignment")) {
@@ -87,7 +87,7 @@ public void actionPerformed(ActionEvent ae) {
8787
jmol.evalString(script);
8888

8989
} else if (cmd.equals("Show Symmetry Axes")) {
90-
String s = SymmetryDisplay.printSymmetryAxes(symm, false);
90+
String s = SymmetryDisplay.printSymmetryAxes(symm);
9191
jmol.evalString(s);
9292
}
9393

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void basicLoad(){
105105

106106
System.out.print(c);
107107

108-
System.out.println(c.getCompound());
108+
System.out.println(c.getEntityInfo());
109109

110110
} catch (Exception e){
111111
e.printStackTrace();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void loadFromDirectAccess(){
102102
System.out.println(h.getAtomSequence());
103103
System.out.println(h.getAtomGroups(GroupType.HETATM));
104104

105-
System.out.println("Compounds: " + s.getEntityInformation());
105+
System.out.println("Compounds: " + s.getEntityInfos());
106106

107107
} catch (Exception e) {
108108
e.printStackTrace();

biojava-structure/src/main/java/org/biojava/nbio/structure/Chain.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,17 @@ public interface Chain {
193193
/**
194194
* Sets the Compound
195195
* @param compound the Compound
196-
* @see #getCompound()
196+
* @see #getEntityInfo()
197197
*/
198-
public void setCompound(EntityInfo compound);
198+
public void setEntityInfo(EntityInfo compound);
199199

200200
/**
201201
* Returns the Compound for this chain.
202202
*
203203
* @return the Compound object
204-
* @see #setCompound(EntityInfo)
204+
* @see #setEntityInfo(EntityInfo)
205205
*/
206-
public EntityInfo getCompound();
206+
public EntityInfo getEntityInfo();
207207

208208
/**
209209
* Sets the name of this chain (Chain id in PDB file ).

biojava-structure/src/main/java/org/biojava/nbio/structure/ChainImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public Object clone() {
159159

160160
// NOTE the Compound will be reset at the parent level (Structure) if cloning is happening from parent level
161161
// here we don't deep-copy it and just keep the same reference, in case the cloning is happening at the Chain level only
162-
n.setCompound(this.mol);
162+
n.setEntityInfo(this.mol);
163163

164164
n.setInternalChainID(internalChainID);
165165

@@ -217,15 +217,15 @@ private static int findMathingGroupIndex(List<Group> atomGroups, Group g) {
217217
*
218218
*/
219219
@Override
220-
public void setCompound(EntityInfo mol) {
220+
public void setEntityInfo(EntityInfo mol) {
221221
this.mol = mol;
222222
}
223223

224224
/** {@inheritDoc}
225225
*
226226
*/
227227
@Override
228-
public EntityInfo getCompound() {
228+
public EntityInfo getEntityInfo() {
229229
return this.mol;
230230
}
231231

0 commit comments

Comments
 (0)