FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Docs, a new StructureTools method and a new performance test (ignored) · biojava/biojava@ed322e3 · GitHub

Commit ed322e3

Browse files
committed
Docs, a new StructureTools method and a new performance test (ignored)
1 parent f54b625 commit ed322e3

3 files changed

Lines changed: 70 additions & 7 deletions

File tree

‎biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/symmetry/TestQuatSymmetryDetectorExamples.java‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,19 @@
2828
import org.biojava.nbio.structure.Structure;
2929
import org.biojava.nbio.structure.StructureException;
3030
import org.biojava.nbio.structure.StructureIO;
31+
import org.biojava.nbio.structure.StructureTools;
3132
import org.biojava.nbio.structure.align.util.AtomCache;
3233
import org.biojava.nbio.structure.cluster.SubunitClusterer;
3334
import org.biojava.nbio.structure.cluster.SubunitClustererMethod;
3435
import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
3536
import org.biojava.nbio.structure.io.FileParsingParameters;
37+
import org.biojava.nbio.structure.quaternary.BiologicalAssemblyBuilder;
38+
import org.biojava.nbio.structure.quaternary.BiologicalAssemblyTransformation;
3639
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryDetector;
3740
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryParameters;
3841
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
3942
import org.biojava.nbio.structure.symmetry.core.Stoichiometry;
43+
import org.junit.Ignore;
4044
import org.junit.Test;
4145
import org.slf4j.Logger;
4246
import org.slf4j.LoggerFactory;
@@ -369,7 +373,7 @@ public void testPseudoIdentity95() throws IOException, StructureException {
369373
}
370374

371375
@Test
372-
public void testSymDetectionWithSubunitClusterByEntityId() throws IOException, StructureException {
376+
public void testSymDetectionWithClusteringByEntityId() throws IOException, StructureException {
373377
AtomCache cache = new AtomCache();
374378
cache.setUseMmtf(false);
375379
cache.setUseMmCif(true);
@@ -390,4 +394,39 @@ public void testSymDetectionWithSubunitClusterByEntityId() throws IOException, S
390394
assertEquals("C2", symmetry.getSymmetry());
391395
assertEquals("A2", symmetry.getStoichiometry().toString());
392396
}
397+
398+
/**
399+
* A performance test that demonstrates how the SubunitClustererParameters.setUseEntityIdForSeqIdentityDetermination()
400+
* has a dramatic effect in runtime versus doing alignments.
401+
* This takes minutes with the parameter on, but hours without the parameter.
402+
*/
403+
@Ignore("This is a performance test to be run manually")
404+
@Test
405+
public void testSymDetectionPerformanceLargeCapsid() throws IOException, StructureException {
406+
AtomCache cache = new AtomCache();
407+
cache.setUseMmtf(false);
408+
cache.setUseMmCif(true);
409+
FileParsingParameters params = new FileParsingParameters();
410+
params.setAlignSeqRes(true);
411+
params.setParseBioAssembly(true);
412+
cache.setFileParsingParams(params);
413+
StructureIO.setAtomCache(cache);
414+
415+
// making sure we remove all atoms but representative before we expand, otherwise memory requirements are huge
416+
Structure au = StructureIO.getStructure("6NHJ");
417+
StructureTools.reduceToRepresentativeAtoms(au);
418+
BiologicalAssemblyBuilder builder = new BiologicalAssemblyBuilder();
419+
List<BiologicalAssemblyTransformation> transforms = au.getPDBHeader().getBioAssemblies().get(1).getTransforms();
420+
Structure pdb =builder.rebuildQuaternaryStructure(au, transforms, true, false);
421+
422+
SubunitClustererParameters cp = new SubunitClustererParameters();
423+
cp.setUseEntityIdForSeqIdentityDetermination(true); // this is the parameter that makes this fast
424+
cp.setClustererMethod(SubunitClustererMethod.SEQUENCE);
425+
QuatSymmetryParameters symmParams = new QuatSymmetryParameters();
426+
QuatSymmetryResults symmetry = QuatSymmetryDetector.calcGlobalSymmetry(
427+
pdb, symmParams, cp);
428+
429+
assertEquals("I", symmetry.getSymmetry());
430+
assertEquals("A960B960C600D480E300", symmetry.getStoichiometry().toString());
431+
}
393432
}

‎biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ public static final Character get1LetterCode(String groupCode3) {
12641264
* 3-character code for a group.
12651265
*
12661266
*/
1267-
public static final boolean isNucleotide(String groupCode3) {
1267+
public static boolean isNucleotide(String groupCode3) {
12681268
String code = groupCode3.trim();
12691269
return nucleotides30.containsKey(code)
12701270
|| nucleotides23.containsKey(code);
@@ -1283,7 +1283,7 @@ public static final boolean isNucleotide(String groupCode3) {
12831283
* @deprecated Use {@link StructureIdentifier#reduce(Structure)} instead (v. 4.2.0)
12841284
*/
12851285
@Deprecated
1286-
public static final Structure getReducedStructure(Structure s,
1286+
public static Structure getReducedStructure(Structure s,
12871287
String chainId) throws StructureException {
12881288
// since we deal here with structure alignments,
12891289
// only use Model 1...
@@ -1338,7 +1338,7 @@ public static final Structure getReducedStructure(Structure s,
13381338
return newS;
13391339
}
13401340

1341-
public static final String convertAtomsToSeq(Atom[] atoms) {
1341+
public static String convertAtomsToSeq(Atom[] atoms) {
13421342

13431343
StringBuilder buf = new StringBuilder();
13441344
Group prevGroup = null;
@@ -1374,7 +1374,7 @@ public static final String convertAtomsToSeq(Atom[] atoms) {
13741374
* @throws StructureException
13751375
* if the group cannot be found.
13761376
*/
1377-
public static final Group getGroupByPDBResidueNumber(Structure struc,
1377+
public static Group getGroupByPDBResidueNumber(Structure struc,
13781378
ResidueNumber pdbResNum) throws StructureException {
13791379
if (struc == null || pdbResNum == null) {
13801380
throw new IllegalArgumentException("Null argument(s).");
@@ -1447,7 +1447,7 @@ public static AtomContactSet getAtomsInContact(Chain chain, double cutoff) {
14471447
* @param chain
14481448
* @param cutoff
14491449
* @return
1450-
* @see {@link #getRepresentativeAtomsInContact(Chain, double)}
1450+
* @see #getRepresentativeAtomsInContact(Chain, double)
14511451
*/
14521452
public static AtomContactSet getAtomsCAInContact(Chain chain, double cutoff) {
14531453
Grid grid = new Grid(cutoff);
@@ -1921,4 +1921,24 @@ private static String replaceFirstChar(String name, char c, char d) {
19211921
return name;
19221922
}
19231923

1924+
/**
1925+
* Remove all atoms but the representative atoms (C alphas or phosphates) from the given structure.
1926+
* @param structure the structure
1927+
* @since 5.4.0
1928+
*/
1929+
public static void reduceToRepresentativeAtoms(Structure structure) {
1930+
for (int modelIdx = 0; modelIdx<structure.nrModels(); modelIdx++) {
1931+
for (Chain c : structure.getPolyChains(modelIdx)) {
1932+
for (Group g : c.getAtomGroups()) {
1933+
List<Atom> atoms = g.getAtoms();
1934+
if (g.isAminoAcid()) {
1935+
atoms.removeIf(a->!a.getName().equals(CA_ATOM_NAME));
1936+
} else if (g.isNucleotide()) {
1937+
atoms.removeIf(a->!a.getName().equals(NUCLEOTIDE_REPRESENTATIVE));
1938+
}
1939+
// else we keep all other atoms. We are concerned only about aminoacids and nucleotides that make up the bulk of the structures
1940+
}
1941+
}
1942+
}
1943+
}
19241944
}

‎biojava-structure/src/main/java/org/biojava/nbio/structure/cluster/SubunitClustererParameters.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ public boolean isHighConfidenceScores(double sequenceIdentity, double sequenceCo
511511
/**
512512
* Whether to use the entity id of subunits to infer that sequences are identical.
513513
* Only applies if the {@link SubunitClustererMethod} is a sequence based one.
514-
* @return
514+
* @return the flag
515+
* @since 5.4.0
515516
*/
516517
public boolean isUseEntityIdForSeqIdentityDetermination() {
517518
return useEntityIdForSeqIdentityDetermination;
@@ -520,7 +521,10 @@ public boolean isUseEntityIdForSeqIdentityDetermination() {
520521
/**
521522
* Whether to use the entity id of subunits to infer that sequences are identical.
522523
* Only applies if the {@link SubunitClustererMethod} is a sequence based one.
524+
* Note this requires {@link org.biojava.nbio.structure.io.FileParsingParameters#setAlignSeqRes(boolean)} to be
525+
* set to true.
523526
* @param useEntityIdForSeqIdentityDetermination the flag to be set
527+
* @since 5.4.0
524528
*/
525529
public void setUseEntityIdForSeqIdentityDetermination(boolean useEntityIdForSeqIdentityDetermination) {
526530
this.useEntityIdForSeqIdentityDetermination = useEntityIdForSeqIdentityDetermination;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL