public void basicLoad() { try { PDBFileReader reader = new PDBFileReader(); // the path to the local PDB installation reader.setPath("/tmp"); // are all files in one directory, or are the files split, // as on the PDB ftp servers? reader.setPdbDirectorySplit(true); // should a missing PDB id be fetched automatically from the FTP servers? reader.setAutoFetch(true); // 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.getChainByPDB("C"); System.out.print(c); System.out.println(c.getHeader()); } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) { try { FileParsingParameters params = new FileParsingParameters(); params.setParseSecStruc(true); AtomCache cache = new AtomCache(); cache.setFileParsingParams(params); Structure s = cache.getStructure("4hhb"); for (Chain c : s.getChains()) { for (Group g : c.getAtomGroups()) { if (g instanceof AminoAcid) { AminoAcid aa = (AminoAcid) g; Map<String, String> sec = aa.getSecStruc(); System.out.println( c.getChainID() + " " + g.getResidueNumber() + " " + g.getPDBName() + " " + " " + sec); } } } } catch (Exception e) { e.printStackTrace(); } }
public static Structure createArtificalStructure(AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws Exception { if (afpChain.getNrEQR() < 1) { return GuiWrapper.getAlignedStructure(ca1, ca2); } Group[] twistedGroups = GuiWrapper.prepareGroupsForDisplay(afpChain, ca1, ca2); List<Atom> twistedAs = new ArrayList<Atom>(); for (Group g : twistedGroups) { if (g == null) continue; if (g.size() < 1) continue; Atom a = g.getAtom(0); twistedAs.add(a); } Atom[] twistedAtoms = (Atom[]) twistedAs.toArray(new Atom[twistedAs.size()]); List<Group> hetatms = new ArrayList<Group>(); List<Group> nucs1 = new ArrayList<Group>(); Group g1 = ca1[0].getParent(); Chain c1 = null; if (g1 != null) { c1 = g1.getParent(); if (c1 != null) { hetatms = c1.getAtomGroups("hetatm"); ; nucs1 = c1.getAtomGroups("nucleotide"); } } List<Group> hetatms2 = new ArrayList<Group>(); List<Group> nucs2 = new ArrayList<Group>(); Group g2 = ca2[0].getParent(); Chain c2 = null; if (g2 != null) { c2 = g2.getParent(); if (c2 != null) { hetatms2 = c2.getAtomGroups("hetatm"); nucs2 = c2.getAtomGroups("nucleotide"); } } Atom[] arr1 = GuiWrapper.getAtomArray(ca1, hetatms, nucs1); Atom[] arr2 = GuiWrapper.getAtomArray(twistedAtoms, hetatms2, nucs2); Structure artificial = GuiWrapper.getAlignedStructure(arr1, arr2); return artificial; }
private void runSCOPTests() { ScopDatabase scop = ScopFactory.getSCOP(); List<ScopDomain> domains = scop.getDomainsForPDB("4HHB"); assertTrue(domains.size() == 4); // test case sensitivity; List<ScopDomain> domains2 = scop.getDomainsForPDB("4hhb"); assertTrue(domains2.size() == domains.size()); // System.out.println(domains); String scop1m02 = "d1m02a_ 1m02 A: k.36.1.1 74353 cl=58788,cf=75796,sf=75797,fa=75798,dm=75799,sp=75800,px=74353"; List<ScopDomain> domains1m02 = scop.getDomainsForPDB("1m02"); assertTrue(domains1m02.size() == 1); ScopDomain d1 = domains1m02.get(0); assertNotNull(d1); assertEquals( "The toString() methods for ScopDomains don't match the scop display", d1.toString(), scop1m02); List<ScopDomain> domains1cdg = scop.getDomainsForPDB("1CDG"); assertTrue(domains1cdg.size() == 4); ScopDomain d2 = domains1cdg.get(0); AtomCache cache = new AtomCache(); try { Structure s = cache.getStructureForDomain(d2); // checkRange(s,"A:496-581"); // now with ligands! checkRange(s, "A:496-692"); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } // check a domain with multiple ranges List<ScopDomain> domains1xzp = scop.getDomainsForPDB("1xzp"); assertTrue(domains1xzp.size() == 4); try { Structure s = cache.getStructureForDomain(domains1xzp.get(0)); Chain a = s.getChainByPDB("A"); // now with ligands... assertEquals(a.getAtomGroups().size(), 176); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } // check insertion codes List<ScopDomain> domains2bq6 = scop.getDomainsForPDB("2bq6"); assertTrue(domains2bq6.size() == 2); ScopDomain target = scop.getDomainByScopID("d2bq6a1"); assertNotNull(target); try { Structure s = cache.getStructureForDomain(target); Chain a = s.getChainByPDB("A"); assertEquals(a.getAtomGroups().size(), 52); checkRange(s, "A:1A-49"); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
/** * Identify a set of modifications in a a list of chains. * * @param chains query {@link Chain}s. * @param potentialModifications query {@link ProteinModification}s. */ public void identify( final List<Chain> chains, final Set<ProteinModification> potentialModifications) { if (chains == null) { throw new IllegalArgumentException("Null structure."); } if (potentialModifications == null) { throw new IllegalArgumentException("Null potentialModifications."); } reset(); if (potentialModifications.isEmpty()) { return; } Map<String, Chain> mapChainIdChain = new HashMap<String, Chain>(chains.size()); residues = new ArrayList<Group>(); List<Group> ligands = new ArrayList<Group>(); Map<Component, Set<Group>> mapCompGroups = new HashMap<Component, Set<Group>>(); for (Chain chain : chains) { mapChainIdChain.put(chain.getChainID(), chain); List<Group> ress = StructureUtil.getAminoAcids(chain); // List<Group> ligs = chain.getAtomLigands(); List<Group> ligs = StructureTools.filterLigands(chain.getAtomGroups()); residues.addAll(ress); residues.removeAll(ligs); ligands.addAll(ligs); addModificationGroups(potentialModifications, ress, ligs, mapCompGroups); } if (residues.isEmpty()) { String pdbId = "?"; if (chains.size() > 0) { Structure struc = chains.get(0).getParent(); if (struc != null) pdbId = struc.getPDBCode(); } System.err.println( "WARNING: no amino acids found for " + pdbId + ". Either you did not parse the PDB file with alignSEQRES records, or this record does not contain any amino acids."); } List<ModifiedCompound> modComps = new ArrayList<ModifiedCompound>(); for (ProteinModification mod : potentialModifications) { ModificationCondition condition = mod.getCondition(); List<Component> components = condition.getComponents(); if (!mapCompGroups.keySet().containsAll(components)) { // not all components exist for this mod. continue; } int sizeComps = components.size(); if (sizeComps == 1) { processCrosslink1(mapCompGroups, modComps, mod, components); } else { processMultiCrosslink(mapCompGroups, modComps, mod, condition); } } if (recordAdditionalAttachments) { // identify additional groups that are not directly attached to amino acids. for (ModifiedCompound mc : modComps) { identifyAdditionalAttachments(mc, ligands, mapChainIdChain); } } mergeModComps(modComps); identifiedModifiedCompounds.addAll(modComps); // record unidentifiable linkage if (recordUnidentifiableModifiedCompounds) { recordUnidentifiableAtomLinkages(modComps, ligands); recordUnidentifiableModifiedResidues(modComps); } }