Java Code Examples for org.biojava.nbio.structure.io.FileParsingParameters#setCreateAtomBonds()
The following examples show how to use
org.biojava.nbio.structure.io.FileParsingParameters#setCreateAtomBonds() .
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 |
/** * 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 |
/** * 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: TestAltLocs.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
/** * Actually perform the test to see all alt locs are the same size as the main group * @throws StructureException * @throws IOException * */ private void doTestAllAltLocsSamAtomsMainGroup(String pdbId) throws IOException, StructureException { AtomCache cache = new AtomCache(); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); params.setCreateAtomBonds(true); cache.setFileParsingParams(params); StructureIO.setAtomCache(cache); Structure structure = StructureIO.getStructure(pdbId); // Loop through the atoms for ( Chain c: structure.getChains()){ for (Group g: c.getAtomGroups()){ for (Group altLocGroup:g.getAltLocs()) { assertEquals(g.size(), altLocGroup.size()); } } } }
Example 4
Source File: StructureTest.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
@BeforeClass public static void setUp() throws IOException { InputStream inStream = StructureTest.class.getResourceAsStream("/5pti_old.pdb"); assertNotNull(inStream); PDBFileParser pdbpars = new PDBFileParser(); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); params.setCreateAtomBonds(true); pdbpars.setFileParsingParameters(params); structure = pdbpars.parsePDBFile(inStream) ; assertNotNull(structure); assertEquals("structure does not contain one chain ", 1 ,structure.size()); }
Example 5
Source File: Test4v5a.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
@Test @Ignore public void test4v5aInternalChainIds() throws StructureException, IOException { AtomCache cache = new AtomCache(); FileParsingParameters params = cache.getFileParsingParams(); params.setCreateAtomBonds(true); StructureIO.setAtomCache(cache); // this would throw an exception when making ss bonds from struct_conn because // chain id "AD" is both an author chain id and an asym chain id and the chains were // getting mixed StructureIO.getStructure("4v5a"); //for (Chain c : s.getChains()) { // System.out.println(c.getChainID()+" "+c.getInternalChainID()+" "+c.getAtomLength()); //} }
Example 6
Source File: TestCloning.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testBondCloning() throws IOException, StructureException { final AtomCache cache = new AtomCache(); cache.setUseMmCif(true); final FileParsingParameters params = cache.getFileParsingParams(); params.setCreateAtomBonds(true); cache.setFileParsingParams(params); final Structure s = cache.getStructure("2I13"); List<Bond> bonds = s.getNonPolyChain("G").getAtomGroup(0).getAtom(0).getBonds(); assertNotNull(bonds); Structure s2 = s.clone(); List<Bond> bonds2 = s2.getNonPolyChain("G").getAtomGroup(0).getAtom(0).getBonds(); assertNotNull(bonds2); assertEquals(bonds.toString(), bonds2.toString()); // But the objects should be different as the atoms are clones assertNotEquals(bonds.toArray(), bonds2.toArray()); // Also test for polymeric chains bonds = s.getPolyChain("E").getAtomGroup(0).getAtom(0).getBonds(); assertNotNull(bonds); s2 = s.clone(); bonds2 = s2.getPolyChain("E").getAtomGroup(0).getAtom(0).getBonds(); assertNotNull(bonds2); }
Example 7
Source File: TestBond.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
@BeforeClass public static void setUp() { // important: without this the tests can fail when running in maven (but not in IDE) // that's because it depends on the order on how tests were run - JD 2018-03-10 ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider()); cache = new AtomCache(); cache.setUseMmCif(true); FileParsingParameters params = cache.getFileParsingParams(); params.setAlignSeqRes(true); params.setCreateAtomBonds(true); StructureIO.setAtomCache(cache); }
Example 8
Source File: TestAltLocs.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** * A test that adding bonds to atoms between groups - doesn't change the size of the groups * @throws StructureException * @throws IOException */ @Test public void testAddBondsDoesntChangeGroups() throws IOException, StructureException { AtomCache cache = new AtomCache(); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); params.setCreateAtomBonds(true); cache.setFileParsingParams(params); StructureIO.setAtomCache(cache); Structure structure = StructureIO.getStructure("4CUP"); // Loop through and find for (Chain chain : structure.getChains()) { List<Group> groups = chain.getAtomGroups(); for (Group mainGroup : groups) { // atoms with no residue number don't have atom information if (mainGroup.getResidueNumber() == null) { continue; } if (mainGroup.getAltLocs().isEmpty()) { continue; } int oldSize = mainGroup.size(); // Now add support for altLocGroup List<Atom> atomsList = new ArrayList<>(mainGroup.getAtoms()); for(Group altLocOne: mainGroup.getAltLocs()){ for(Atom atomAltLocOne: altLocOne.getAtoms()){ atomsList.add(atomAltLocOne); } } // Get the chem copm ChemComp aminoChemComp = ChemCompGroupFactory.getChemComp(mainGroup .getPDBName()); // Now iterate through this list for(Atom atomA : atomsList){ for (ChemCompBond chemCompBond : aminoChemComp.getBonds()) { // if(chemCompBond.getAtom_id_1().equals(atomA.getName())){ // Get the other atom in the group for(Atom atomB : atomsList) { if(chemCompBond.getAtom_id_2().equals(atomB.getName())){ int bondOrder = chemCompBond.getNumericalBondOrder(); new BondImpl(atomA, atomB, bondOrder); } } } } } assertEquals(oldSize, mainGroup.size()); } } }
Example 9
Source File: TestBondFinding.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** * 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; }
Example 10
Source File: Test4v5a.java From biojava with GNU Lesser General Public License v2.1 | 3 votes |
@Test @Ignore public void test4v5a() throws StructureException, IOException { AtomCache cache = new AtomCache(); FileParsingParameters params = cache.getFileParsingParams(); params.setCreateAtomBonds(true); StructureIO.setAtomCache(cache); StructureIO.getStructure("4v5a"); }