Java Code Examples for org.biojava.nbio.structure.io.FileParsingParameters#setAlignSeqRes()
The following examples show how to use
org.biojava.nbio.structure.io.FileParsingParameters#setAlignSeqRes() .
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: TestQuatSymmetryDetectorExamples.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testSymDetectionWithClusteringByEntityId() throws IOException, StructureException { AtomCache cache = new AtomCache(); cache.setUseMmtf(false); cache.setUseMmCif(true); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); cache.setFileParsingParams(params); StructureIO.setAtomCache(cache); Structure pdb = StructureIO.getStructure("BIO:1SMT:1"); SubunitClustererParameters cp = new SubunitClustererParameters(); cp.setUseEntityIdForSeqIdentityDetermination(true); cp.setClustererMethod(SubunitClustererMethod.SEQUENCE); QuatSymmetryParameters symmParams = new QuatSymmetryParameters(); QuatSymmetryResults symmetry = QuatSymmetryDetector.calcGlobalSymmetry( pdb, symmParams, cp); // C2 symmetry, A2 stoichiometry assertEquals("C2", symmetry.getSymmetry()); assertEquals("A2", symmetry.getStoichiometry().toString()); }
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. */ 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 3
Source File: PdbFileFormat30Test.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
private Structure getStructure(String fileName) throws IOException{ InputStream inStream = this.getClass().getResourceAsStream(fileName); assertNotNull(inStream); ChemCompGroupFactory.setChemCompProvider(new ReducedChemCompProvider()); PDBFileParser pdbpars = new PDBFileParser(); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(false); pdbpars.setFileParsingParameters(params); Structure structure = null; structure = pdbpars.parsePDBFile(inStream) ; return structure; }
Example 4
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 5
Source File: TestEntityResIndexMapping.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void test1SMT() throws IOException, StructureException { AtomCache cache = new AtomCache(); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); cache.setFileParsingParams(params); StructureIO.setAtomCache(cache); cache.setUseMmCif(false); Structure s = StructureIO.getStructure("1SMT"); Chain chainA = s.getPolyChainByPDB("A"); int i = chainA.getEntityInfo().getAlignedResIndex(chainA.getAtomGroup(0),chainA); assertEquals("First residue in 1smtA "+chainA.getAtomGroup(0).toString()+" should map to 24 in SEQRES",24,i); Chain chainB = s.getPolyChainByPDB("B"); i = chainB.getEntityInfo().getAlignedResIndex(chainB.getAtomGroup(0),chainB); assertEquals("First residue in 1smtB "+chainB.getAtomGroup(0).toString()+" should map to 20 in SEQRES",20,i); // group with seqres index 19 is observed in chain B but not in chain A, we should still get the index back from getAlignedResIndex i = chainA.getEntityInfo().getAlignedResIndex(chainA.getSeqResGroup(19),chainA); assertEquals("Seqres residue 20 in 1smtA "+chainA.getSeqResGroup(19).toString()+" should map to 20 in SEQRES",20,i); checkAllResidues(s); }
Example 6
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 7
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 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: TestStructureCrossReferences.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testCrossReferencesPdbAlignSeqRes() throws IOException, StructureException { boolean emptySeqRes = false; AtomCache cache = new AtomCache(); cache.setUseMmCif(false); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); cache.setFileParsingParams(params); StructureIO.setAtomCache(cache); //System.out.println("Testing references in PDB loading with alignSeqRes"); Structure structure = StructureIO.getStructure(PDBCODE1); doFullTest(structure, emptySeqRes); structure = StructureIO.getStructure(PDBCODE2); // an NMR entry with 2 chains doFullTest(structure, emptySeqRes); }
Example 10
Source File: TestStructureCrossReferences.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testCrossReferencesMmCif() throws IOException, StructureException { boolean emptySeqRes = true; AtomCache cache = new AtomCache(); cache.setUseMmCif(true); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(false); // Store empty seqres groups. cache.setFileParsingParams(params); StructureIO.setAtomCache(cache); Structure structure = StructureIO.getStructure(PDBCODE1); //System.out.println("Testing references in mmCIF loading with NO alignSeqRes"); doFullTest(structure, emptySeqRes); structure = StructureIO.getStructure(PDBCODE2); // an NMR entry with 2 chains doFullTest(structure, emptySeqRes); }
Example 11
Source File: TestEntityResIndexMapping.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void test1B8G() throws IOException, StructureException { AtomCache cache = new AtomCache(); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); cache.setFileParsingParams(params); StructureIO.setAtomCache(cache); cache.setUseMmCif(false); Structure s = StructureIO.getStructure("1B8G"); Chain chainA = s.getPolyChainByPDB("A"); int i = chainA.getEntityInfo().getAlignedResIndex(chainA.getAtomGroup(0),chainA); assertEquals("First residue in 1b8gA "+chainA.getAtomGroup(0).toString()+" should map to 1 in SEQRES",1,i); checkAllResidues(s); }
Example 12
Source File: TestAltLocs.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void test3U7Tmmcif() throws IOException, StructureException{ // this test intends to check that the mmCIF parser doesn't read twice residues 22 and 25 // which are annotated as "microheterogeneity" in the SEQRES (entity_poly_seq), see #160 AtomCache cache = new AtomCache(); StructureIO.setAtomCache(cache); cache.setUseMmCif(true); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); cache.setFileParsingParams(params); Structure structure = StructureIO.getStructure("3U7T"); assertNotNull(structure); Atom[] ca = StructureTools.getRepresentativeAtomArray(structure); //System.out.println(structure.getPdbId() + " has # CA atoms: " + ca.length); List<Atom> caList = new ArrayList<Atom>(); for ( Chain c: structure.getChains()){ // notice here we test the seqresgroups, because we want to check if microheterogeinity is treated correctly for (Group g: c.getSeqResGroups()){ for (Group altLocGroup:g.getAltLocs()) { ensureAllAtomsSameAltCode(altLocGroup, g); } List<Atom> atoms = g.getAtoms(); boolean caInMain = false; for (Atom a: atoms){ if ( a.getName().equals(StructureTools.CA_ATOM_NAME)) { caList.add(a); caInMain = true; break; } } if (! caInMain && g.hasAtom(StructureTools.CA_ATOM_NAME)){ // g.hasAtom checks altLocs fail("CA is not in main group, but in altLoc"); } } } assertEquals(ca.length, caList.size()); }
Example 13
Source File: DemoDomainsplit.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
public void basicLoad(String pdbId){ try { // This utility class can automatically download missing PDB files. AtomCache cache = new AtomCache(); // // configure the parameters of file parsing (optional) FileParsingParameters params = new FileParsingParameters(); // should the ATOM and SEQRES residues be aligned when creating the internal data model? params.setAlignSeqRes(true); // should secondary structure get parsed from the file params.setParseSecStruc(false); // and set the params in the cache. cache.setFileParsingParams(params); // end of optional part Structure struc = cache.getStructure(pdbId); System.out.println("structure loaded: " + struc); List<Domain> domains = LocalProteinDomainParser.suggestDomains(struc); System.out.println("RESULTS: ====="); for ( Domain dom : domains){ System.out.println("DOMAIN:" + dom.getSize() + " " + dom.getScore()); List<Segment> segments = dom.getSegments(); for ( Segment s : segments){ System.out.println(" Segment: " + s); } } } catch (Exception e){ e.printStackTrace(); } }
Example 14
Source File: DemoSCOP.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
public void alignSuperfamily(){ // download SCOP if required and load into memory ScopDatabase scop = ScopFactory.getSCOP(); List<ScopDescription> superfams = scop.getByCategory(ScopCategory.Superfamily); System.out.println("Total nr. of superfamilies:" + superfams.size()); // configure where to load PDB files from and // what information to load AtomCache cache = new AtomCache(); FileParsingParameters fileparams = new FileParsingParameters() ; fileparams.setAlignSeqRes(false); fileparams.setParseSecStruc(false); cache.setFileParsingParams(fileparams); // get tge first superfamily ScopDescription superfam1 = superfams.get(0); System.out.println("First superfamily: " + superfam1); ScopNode node = scop.getScopNode(superfam1.getSunID()); System.out.println("scopNode for first superfamily:" + node); List<ScopDomain> doms4superfam1 = scop.getScopDomainsBySunid(superfam1.getSunID()); ScopDomain dom1 = doms4superfam1.get(0); // align the first domain against all others members of this superfamily for ( int i = 1 ; i < doms4superfam1.size() ; i ++){ ScopDomain dom2 = doms4superfam1.get(i); try { Structure s1 = cache.getStructureForDomain(dom1); Structure s2 = cache.getStructureForDomain(dom2); Atom[] ca1 = StructureTools.getAtomCAArray(s1); Atom[] ca2 = StructureTools.getAtomCAArray(s2); StructureAlignment ce = StructureAlignmentFactory.getAlgorithm(CeMain.algorithmName); AFPChain afpChain = ce.align(ca1, ca2); //System.out.println(afpChain.toCE(ca1, ca2)); //StructureAlignmentDisplay.display(afpChain, ca1, ca2); System.out.println(dom1.getScopId() + " vs. " + dom2.getScopId()+ " :" + afpChain.getProbability()); double tmScore = AFPChainScorer.getTMScore(afpChain, ca1, ca2); afpChain.setTMScore(tmScore); System.out.println(AfpChainWriter.toScoresList(afpChain)); } catch (Exception e){ e.printStackTrace(); } } }
Example 15
Source File: TestInterfaceClustering.java From biojava with GNU Lesser General Public License v2.1 | 3 votes |
@Test public void test3C5FWithSeqresPdb() throws IOException, StructureException { InputStream inStream = new GZIPInputStream(this.getClass().getResourceAsStream("/org/biojava/nbio/structure/io/3c5f_raw.pdb.gz")); assertNotNull(inStream); PDBFileParser pdbpars = new PDBFileParser(); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); pdbpars.setFileParsingParameters(params); Structure s = pdbpars.parsePDBFile(inStream) ; assertNotNull(s); assertEquals(8, s.getPolyChains().size()); // 1 protein, 3 nucleotide chains, 1 NA nonpoly chain, 1 water: 6 entities assertEquals(6, s.getEntityInfos().size()); CrystalBuilder cb = new CrystalBuilder(s); StructureInterfaceList interfaces = cb.getUniqueInterfaces(5.5); interfaces.calcAsas(100, 1, 0); interfaces.removeInterfacesBelowArea(); List<StructureInterfaceCluster> clusters = interfaces.getClusters(); // 23 if below 35A2 interfaces are filtered assertEquals(23,interfaces.size()); // we simply want to test that some interfaces cluster together assertTrue("Expected fewer than 23 interfaces (some interfaces should cluster together)",clusters.size()<23); // third cluster (index 2) is of size 2 assertEquals("Cluster 3 should have 2 members",2,clusters.get(2).getMembers().size()); assertTrue("Interface 3 should be isologous",interfaces.get(3).isIsologous()); }
Example 16
Source File: DemoChangeChemCompProvider.java From biojava with GNU Lesser General Public License v2.1 | 3 votes |
public void basicLoad(PDBFileReader reader, boolean loadChemComp, String pdbId){ try { // configure the parameters of file parsing FileParsingParameters params = new FileParsingParameters(); // should the ATOM and SEQRES residues be aligned when creating the internal data model? // only do this if you need to work with SEQRES sequences. If all you need are ATOMs, then // set it to false to have quicker file loading. params.setAlignSeqRes(true); // // should secondary structure get parsed from the file params.setParseSecStruc(false); reader.setFileParsingParameters(params); Structure struc = reader.getStructureById(pdbId); printStructure(struc); } catch (Exception e){ e.printStackTrace(); } }
Example 17
Source File: DemoLoadStructure.java From biojava with GNU Lesser General Public License v2.1 | 3 votes |
public void basicLoad(){ try { PDBFileReader reader = new PDBFileReader(); // the path to the local PDB installation reader.setPath("/tmp"); // configure the parameters of file parsing FileParsingParameters params = new FileParsingParameters(); // should the ATOM and SEQRES residues be aligned when creating the internal data model? params.setAlignSeqRes(true); // should secondary structure get parsed from the file params.setParseSecStruc(false); reader.setFileParsingParameters(params); Structure structure = reader.getStructureById("4hhb"); System.out.println(structure); Chain c = structure.getPolyChainByPDB("C"); System.out.print(c); System.out.println(c.getEntityInfo()); } catch (Exception e){ e.printStackTrace(); } }
Example 18
Source File: TestInterfaceClustering.java From biojava with GNU Lesser General Public License v2.1 | 2 votes |
@Test public void test3DDO() throws IOException, StructureException { // 3DDO is special in that it contains 6 chains in 1 entity, all of them with different residue numbering AtomCache cache = new AtomCache(); FileParsingParameters params = new FileParsingParameters(); params.setAlignSeqRes(true); cache.setFileParsingParams(params); cache.setUseMmCif(true); StructureIO.setAtomCache(cache); Structure s = StructureIO.getStructure("3DDO"); CrystalBuilder cb = new CrystalBuilder(s); StructureInterfaceList interfaces = cb.getUniqueInterfaces(5.5); interfaces.calcAsas(100, 1, 0); interfaces.removeInterfacesBelowArea(); List<StructureInterfaceCluster> clusters = interfaces.getClusters(); // 22 if below 35A2 interfaces are filtered assertEquals(22,interfaces.size()); // we simply want to test that some interfaces cluster together, for this entry // it is problematic because of different residue numbering between different chains of same entity assertTrue("Expected fewer than 22 interfaces (some interfaces should cluster together)",clusters.size()<22); // first 2 clusters are of size 3 assertEquals("Cluster 1 should have 3 members",3,clusters.get(0).getMembers().size()); assertEquals("Cluster 2 should have 3 members",3,clusters.get(1).getMembers().size()); // detection of isologous test: first 3 interfaces should be isologous assertTrue("Interface 1 should be isologous",interfaces.get(1).isIsologous()); assertTrue("Interface 2 should be isologous",interfaces.get(2).isIsologous()); assertTrue("Interface 3 should be isologous",interfaces.get(3).isIsologous()); }
Example 19
Source File: Test1a4w.java From biojava with GNU Lesser General Public License v2.1 | 2 votes |
@Test public void testChemComps() throws IOException, StructureException { AtomCache cache = new AtomCache(); FileParsingParameters params = cache.getFileParsingParams(); params.setAlignSeqRes(true); Structure s = cache.getStructure("1a4w"); Assert.assertEquals(3, s.getPolyChains().size()); Chain c2 = s.getChainByIndex(1); Assert.assertEquals("H", c2.getName()); List<Group> hChainLigandGroups = new ArrayList<>(); for (Chain ch : s.getNonPolyChains()) { if (ch.getName().equals("H")) { hChainLigandGroups.addAll(ch.getAtomGroups()); } } boolean noWater = true; boolean darPresent = false; for ( Group g : hChainLigandGroups){ String pdbName = g.getPDBName(); if ( pdbName.equals("QWE")) darPresent = true; else if ( pdbName.equals("H2O")) noWater = false; } Assert.assertTrue("Found water in ligands list!", noWater); Assert.assertTrue("Did not find QWE in ligands list!", darPresent); Assert.assertEquals("Did not find the correct nr of ligands in chain! ", 3, hChainLigandGroups.size()); }
Example 20
Source File: TestNucleotides.java From biojava with GNU Lesser General Public License v2.1 | 2 votes |
@Test public void test3T5N() throws IOException, StructureException{ String pdbId = "3T5N"; Structure s = getStructure(pdbId); assertEquals(2,s.getPolyChains().size()); Chain c = s.getChains().get(1); System.out.println(c); assertEquals("C", c.getName()); List<Group> ngr = c.getAtomGroups(GroupType.NUCLEOTIDE); assertEquals(6,ngr.size()); // now test if we download all definitions correctly for this one... PDBFileReader reader = new PDBFileReader(); FileParsingParameters params = new FileParsingParameters(); params.setParseSecStruc(true); params.setAlignSeqRes(true); params.setParseCAOnly(false); reader.setFileParsingParameters(params); ChemCompProvider chemProv = ChemCompGroupFactory.getChemCompProvider(); DownloadChemCompProvider download = new DownloadChemCompProvider(); ChemCompGroupFactory.setChemCompProvider(download); Structure s1 = reader.getStructureById(pdbId); assertNotNull(s1); assertEquals(2,s1.getPolyChains().size()); Chain c1 = s1.getChains().get(1); assertEquals("C", c1.getName()); Group g = c1.getAtomGroup(0); assertNotNull(g); assertNotNull(g.getChemComp()); assertNotNull(g.getChemComp().getPolymerType()); assertNotNull(g.getChemComp().getPolymerType().name()); assertTrue("Found an unknown polymertype!", (! g.getChemComp().getPolymerType().equals(PolymerType.unknown))); //System.out.println(g.getChemComp().getPolymerType()); List<Group> ngr1 = c1.getAtomGroups(GroupType.NUCLEOTIDE); assertEquals(6,ngr1.size()); ChemCompGroupFactory.setChemCompProvider(chemProv); }