| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f54b625 commit ed322e3
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,15 +28,19 @@ | |||
| 28 | 28 | import org.biojava.nbio.structure.Structure; | |
| 29 | 29 | import org.biojava.nbio.structure.StructureException; | |
| 30 | 30 | import org.biojava.nbio.structure.StructureIO; | |
| 31 | + import org.biojava.nbio.structure.StructureTools; | ||
| 31 | 32 | import org.biojava.nbio.structure.align.util.AtomCache; | |
| 32 | 33 | import org.biojava.nbio.structure.cluster.SubunitClusterer; | |
| 33 | 34 | import org.biojava.nbio.structure.cluster.SubunitClustererMethod; | |
| 34 | 35 | import org.biojava.nbio.structure.cluster.SubunitClustererParameters; | |
| 35 | 36 | import org.biojava.nbio.structure.io.FileParsingParameters; | |
| 37 | + import org.biojava.nbio.structure.quaternary.BiologicalAssemblyBuilder; | ||
| 38 | + import org.biojava.nbio.structure.quaternary.BiologicalAssemblyTransformation; | ||
| 36 | 39 | import org.biojava.nbio.structure.symmetry.core.QuatSymmetryDetector; | |
| 37 | 40 | import org.biojava.nbio.structure.symmetry.core.QuatSymmetryParameters; | |
| 38 | 41 | import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults; | |
| 39 | 42 | import org.biojava.nbio.structure.symmetry.core.Stoichiometry; | |
| 43 | + import org.junit.Ignore; | ||
| 40 | 44 | import org.junit.Test; | |
| 41 | 45 | import org.slf4j.Logger; | |
| 42 | 46 | import org.slf4j.LoggerFactory; | |
@@ -369,7 +373,7 @@ public void testPseudoIdentity95() throws IOException, StructureException { | |||
| 369 | 373 | } | |
| 370 | 374 | ||
| 371 | 375 | @Test | |
| 372 | - public void testSymDetectionWithSubunitClusterByEntityId() throws IOException, StructureException { | ||
| 376 | + public void testSymDetectionWithClusteringByEntityId() throws IOException, StructureException { | ||
| 373 | 377 | AtomCache cache = new AtomCache(); | |
| 374 | 378 | cache.setUseMmtf(false); | |
| 375 | 379 | cache.setUseMmCif(true); | |
@@ -390,4 +394,39 @@ public void testSymDetectionWithSubunitClusterByEntityId() throws IOException, S | |||
| 390 | 394 | assertEquals("C2", symmetry.getSymmetry()); | |
| 391 | 395 | assertEquals("A2", symmetry.getStoichiometry().toString()); | |
| 392 | 396 | } | |
| 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 | + } | ||
| 393 | 432 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1264,7 +1264,7 @@ public static final Character get1LetterCode(String groupCode3) { | |||
| 1264 | 1264 | * 3-character code for a group. | |
| 1265 | 1265 | * | |
| 1266 | 1266 | */ | |
| 1267 | - public static final boolean isNucleotide(String groupCode3) { | ||
| 1267 | + public static boolean isNucleotide(String groupCode3) { | ||
| 1268 | 1268 | String code = groupCode3.trim(); | |
| 1269 | 1269 | return nucleotides30.containsKey(code) | |
| 1270 | 1270 | || nucleotides23.containsKey(code); | |
@@ -1283,7 +1283,7 @@ public static final boolean isNucleotide(String groupCode3) { | |||
| 1283 | 1283 | * @deprecated Use {@link StructureIdentifier#reduce(Structure)} instead (v. 4.2.0) | |
| 1284 | 1284 | */ | |
| 1285 | 1285 | @Deprecated | |
| 1286 | - public static final Structure getReducedStructure(Structure s, | ||
| 1286 | + public static Structure getReducedStructure(Structure s, | ||
| 1287 | 1287 | String chainId) throws StructureException { | |
| 1288 | 1288 | // since we deal here with structure alignments, | |
| 1289 | 1289 | // only use Model 1... | |
@@ -1338,7 +1338,7 @@ public static final Structure getReducedStructure(Structure s, | |||
| 1338 | 1338 | return newS; | |
| 1339 | 1339 | } | |
| 1340 | 1340 | ||
| 1341 | - public static final String convertAtomsToSeq(Atom[] atoms) { | ||
| 1341 | + public static String convertAtomsToSeq(Atom[] atoms) { | ||
| 1342 | 1342 | ||
| 1343 | 1343 | StringBuilder buf = new StringBuilder(); | |
| 1344 | 1344 | Group prevGroup = null; | |
@@ -1374,7 +1374,7 @@ public static final String convertAtomsToSeq(Atom[] atoms) { | |||
| 1374 | 1374 | * @throws StructureException | |
| 1375 | 1375 | * if the group cannot be found. | |
| 1376 | 1376 | */ | |
| 1377 | - public static final Group getGroupByPDBResidueNumber(Structure struc, | ||
| 1377 | + public static Group getGroupByPDBResidueNumber(Structure struc, | ||
| 1378 | 1378 | ResidueNumber pdbResNum) throws StructureException { | |
| 1379 | 1379 | if (struc == null || pdbResNum == null) { | |
| 1380 | 1380 | throw new IllegalArgumentException("Null argument(s)."); | |
@@ -1447,7 +1447,7 @@ public static AtomContactSet getAtomsInContact(Chain chain, double cutoff) { | |||
| 1447 | 1447 | * @param chain | |
| 1448 | 1448 | * @param cutoff | |
| 1449 | 1449 | * @return | |
| 1450 | - * @see {@link #getRepresentativeAtomsInContact(Chain, double)} | ||
| 1450 | + * @see #getRepresentativeAtomsInContact(Chain, double) | ||
| 1451 | 1451 | */ | |
| 1452 | 1452 | public static AtomContactSet getAtomsCAInContact(Chain chain, double cutoff) { | |
| 1453 | 1453 | Grid grid = new Grid(cutoff); | |
@@ -1921,4 +1921,24 @@ private static String replaceFirstChar(String name, char c, char d) { | |||
| 1921 | 1921 | return name; | |
| 1922 | 1922 | } | |
| 1923 | 1923 | ||
| 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 | + } | ||
| 1924 | 1944 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -511,7 +511,8 @@ public boolean isHighConfidenceScores(double sequenceIdentity, double sequenceCo | |||
| 511 | 511 | /** | |
| 512 | 512 | * Whether to use the entity id of subunits to infer that sequences are identical. | |
| 513 | 513 | * Only applies if the {@link SubunitClustererMethod} is a sequence based one. | |
| 514 | - * @return | ||
| 514 | + * @return the flag | ||
| 515 | + * @since 5.4.0 | ||
| 515 | 516 | */ | |
| 516 | 517 | public boolean isUseEntityIdForSeqIdentityDetermination() { | |
| 517 | 518 | return useEntityIdForSeqIdentityDetermination; | |
@@ -520,7 +521,10 @@ public boolean isUseEntityIdForSeqIdentityDetermination() { | |||
| 520 | 521 | /** | |
| 521 | 522 | * Whether to use the entity id of subunits to infer that sequences are identical. | |
| 522 | 523 | * 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. | ||
| 523 | 526 | * @param useEntityIdForSeqIdentityDetermination the flag to be set | |
| 527 | + * @since 5.4.0 | ||
| 524 | 528 | */ | |
| 525 | 529 | public void setUseEntityIdForSeqIdentityDetermination(boolean useEntityIdForSeqIdentityDetermination) { | |
| 526 | 530 | this.useEntityIdForSeqIdentityDetermination = useEntityIdForSeqIdentityDetermination; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments