Java Code Examples for org.biojava.nbio.structure.io.FileParsingParameters#setParseBioAssembly()

The following examples show how to use org.biojava.nbio.structure.io.FileParsingParameters#setParseBioAssembly() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MmtfUtils.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Set up the configuration parameters for BioJava.
 */
public static AtomCache setUpBioJava() {
	// Set up the atom cache etc
	AtomCache cache = new AtomCache();
	cache.setUseMmCif(true);
	FileParsingParameters params = cache.getFileParsingParams();
	params.setCreateAtomBonds(true);
	params.setAlignSeqRes(true);
	params.setParseBioAssembly(true);
	DownloadChemCompProvider cc = new DownloadChemCompProvider();
	ChemCompGroupFactory.setChemCompProvider(cc);
	cc.checkDoFirstInstall();
	cache.setFileParsingParams(params);
	StructureIO.setAtomCache(cache);
	return cache;
}
 
Example 2
Source File: MmtfUtils.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Set up the configuration parameters for BioJava.
 * @param extraUrl the string describing the URL (or file path) from which
 * to get missing CCD entries.
 */
public static AtomCache setUpBioJava(String extraUrl) {
	// Set up the atom cache etc
	AtomCache cache = new AtomCache();
	cache.setUseMmCif(true);
	FileParsingParameters params = cache.getFileParsingParams();
	params.setCreateAtomBonds(true);
	params.setAlignSeqRes(true);
	params.setParseBioAssembly(true);
	DownloadChemCompProvider.serverBaseUrl = extraUrl;
	DownloadChemCompProvider.useDefaultUrlLayout = false;
	DownloadChemCompProvider cc = new DownloadChemCompProvider();
	ChemCompGroupFactory.setChemCompProvider(cc);
	cc.checkDoFirstInstall();
	cache.setFileParsingParams(params);
	StructureIO.setAtomCache(cache);
	return cache;
}
 
Example 3
Source File: TestMmtfRoundTrip.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Test that we can round trip a simple structure.
 *
 * @throws IOException an error reading the file
 * @throws StructureException an error parsing the structure
 */
@Test
public void testRoundTrip() throws IOException, StructureException {

	// Load a structure in MMCIF format
	AtomCache cache = new AtomCache();
	FileParsingParameters params = new FileParsingParameters();
	params.setParseBioAssembly(true);
	cache.setFileParsingParams(params);
	cache.setUseMmCif(true);
	
	StructureIO.setAtomCache(cache);

	ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider());

	// test case for biojava issue #770, order of subunits
	Structure structure1 = StructureIO.getStructure("3BW1");
	AdapterToStructureData writerToEncoder = new AdapterToStructureData();
	new MmtfStructureWriter(structure1, writerToEncoder);
	MmtfStructureReader mmtfStructureReader = new MmtfStructureReader();
	new StructureDataToAdapter(writerToEncoder, mmtfStructureReader);
	Structure structure2 = mmtfStructureReader.getStructure();

	assertTrue(checkIfAtomsSame(structure1, structure2));

	checkBioAssemblies1(structure1, structure2);
}
 
Example 4
Source File: DemoShowLargeAssembly.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** Load a specific biological assembly for a PDB entry
 *
 * @param pdbId .. the PDB ID
 * @param bioAssemblyId .. the first assembly has the bioAssemblyId 1
 * @return a Structure object or null if something went wrong.
 */
public static Structure  readStructure(String pdbId, int bioAssemblyId) {

	// pre-computed files use lower case PDB IDs
	pdbId = pdbId.toLowerCase();

	// we just need this to track where to store PDB files
	// this checks the PDB_DIR property (and uses a tmp location if not set)
	AtomCache cache = new AtomCache();
	cache.setUseMmCif(true);
	FileParsingParameters p = cache.getFileParsingParams();

	// some bio assemblies are large, we want an all atom representation and avoid
	// switching to a Calpha-only representation for large molecules
	// note, this requires several GB of memory for some of the largest assemblies, such a 1MX4
	p.setAtomCaThreshold(Integer.MAX_VALUE);

	// parse remark 350
	p.setParseBioAssembly(true);

	// download missing files

	Structure structure = null;
	try {
		structure = StructureIO.getBiologicalAssembly(pdbId,bioAssemblyId);
	} catch (Exception e){
		e.printStackTrace();
		return null;
	}
	return structure;
}
 
Example 5
Source File: TestQuatSymmetryDetectorExamples.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * A performance test that demonstrates how the SubunitClustererParameters.setUseEntityIdForSeqIdentityDetermination()
 * has a dramatic effect in runtime versus doing alignments.
 */
@Ignore("This is a performance test to be run manually")
@Test
public void testSymDetectionPerformanceLargeCapsid() throws IOException, StructureException {
	AtomCache cache = new AtomCache();
	cache.setUseMmtf(false);
	cache.setUseMmCif(true);
	FileParsingParameters params = new FileParsingParameters();
	params.setAlignSeqRes(true);
	params.setParseBioAssembly(true);
	cache.setFileParsingParams(params);
	StructureIO.setAtomCache(cache);

	// making sure we remove all atoms but representative before we expand, otherwise memory requirements are huge
	// 6Q1F is another good example
	Structure au = StructureIO.getStructure("6NHJ");
	StructureTools.reduceToRepresentativeAtoms(au);
	BiologicalAssemblyBuilder builder = new BiologicalAssemblyBuilder();
	List<BiologicalAssemblyTransformation> transforms = au.getPDBHeader().getBioAssemblies().get(1).getTransforms();
	Structure pdb = builder.rebuildQuaternaryStructure(au, transforms, true, false);

	SubunitClustererParameters cp = new SubunitClustererParameters();

	// This is the parameter that makes this fast, set it to false to see the difference.
	// As of git commit ed322e387cd46344a7864a, the difference in runtime is not that huge:
	// 2 minutes with true, 10 minutes with false. I observed a much larger difference before, but can't reproduce anymore - JD 2020-01-23
	cp.setUseEntityIdForSeqIdentityDetermination(true);

	cp.setClustererMethod(SubunitClustererMethod.SEQUENCE);
	QuatSymmetryParameters symmParams = new QuatSymmetryParameters();
	QuatSymmetryResults symmetry = QuatSymmetryDetector.calcGlobalSymmetry(
			pdb, symmParams, cp);

	assertEquals("I", symmetry.getSymmetry());
	assertEquals("A960B960C600D480E300", symmetry.getStoichiometry().toString());
}
 
Example 6
Source File: TestChemCompProvider.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void testNormalStructure() throws StructureException, IOException {
	// we just need this to track where to store PDB files
	// this checks the PDB_DIR property (and uses a tmp location if not set)
	UserConfiguration config = new UserConfiguration();
	String cachePath = config.getCacheFilePath();

	// Setup a ChemCompProvider
	Path pdbdir = Paths.get(cachePath);
	Path chemComp = pdbdir.resolve("chemcomp.zip");

	System.out.println("Using PDB_DIR=" + pdbdir.toString() + " as temporary file directory");

	AtomCache cache = new AtomCache();
	StructureIO.setAtomCache(cache);
	FileParsingParameters params = cache.getFileParsingParams();
	params.setParseBioAssembly(true);

	/*
	ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider());
	StructureIO.setAtomCache(cache);
	cache.setUseMmCif(true);
	long startTime = System.currentTimeMillis();
	Structure sCif = StructureIO.getStructure("4HHM");
	long finishTime = System.currentTimeMillis();
	s_logger.info("DownloadChemComp time: "+(finishTime-startTime)+ " ms");
	*/

	ZipChemCompProvider zp = new ZipChemCompProvider(chemComp.toString(), pdbdir.toString());
	// Keep the .cif.gz files - avoid re-downloading for unit testing.
	zp.setRemoveCif(false);
	ChemCompGroupFactory.setChemCompProvider(zp);

	long startTime = System.currentTimeMillis();
	StructureIO.getStructure("4HHM");
	long finishTime = System.currentTimeMillis();
	s_logger.info("ZipChemComp time: "+(finishTime-startTime)+ " ms");

	// Not wanted here for testing, but useful for cleaning up downloaded .cif.gz files.
	// ZipChemCompProvider.purgeTempFiles(pdbdir.toString());
}
 
Example 7
Source File: TestBondFinding.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Find all of the inter group bonds in a structure.
 *
 * @param pdbId the pdb id of the structure to determine
 * @return the number of inter group bonds (double counted) in a structure
 * @throws IOException
 * @throws StructureException
 */
public int getInterBonds(String pdbId) throws IOException, StructureException {

	// Download parameters
	AtomCache cache = new AtomCache();
	cache.setUseMmCif(true);
	cache.setFetchBehavior(FetchBehavior.FETCH_FILES);
	FileParsingParameters params = cache.getFileParsingParams();
	params.setCreateAtomBonds(true);
	params.setAlignSeqRes(true);
	params.setParseBioAssembly(true);
	DownloadChemCompProvider dcc = new DownloadChemCompProvider();
	ChemCompGroupFactory.setChemCompProvider(dcc);
	dcc.checkDoFirstInstall();
	cache.setFileParsingParams(params);
	StructureIO.setAtomCache(cache);

	// Get the structure
	Structure newStruc = StructureIO.getStructure(pdbId);

	int counter =0;

	// Loop through the atoms and count the bonds
	for(Chain c: newStruc.getChains()){
		for(Group g: c.getAtomGroups()){
			List<Atom> theseAtoms = g.getAtoms();
			for(Atom a: theseAtoms){
				List<Bond> theseBonds = a.getBonds();
				if(theseBonds != null){
					for(Bond b: a.getBonds()){
						Atom other = b.getOther(a);
						int indexOther = theseAtoms.indexOf(other);
						// Check if the index is within the group
						if(indexOther<0 || indexOther >= theseAtoms.size()){
							counter++;
						}
					}
				}
			}
		}
	}
	return counter;
}