public static void main(String[] args) { Point3d[] pts = SecondaryStructTools.obtain(NAME); if (smooth) pts = CS.getSmoothedPoints(pts); SecondaryStruct s = new SecondaryStruct(pts, smooth); File f = new File("data/smooth_" + NAME + ".pdb"); Chain c = new ChainImpl(); c.setChainID(NAME.split("\\.")[1]); try (PrintWriter pw = new PrintWriter(f)) { for (int i = 0; i < pts.length; i++) { Atom a = new AtomImpl(); a = new AtomImpl(); a.setName(CA_NAME); a.setAltLoc(' '); Group g = new AminoAcidImpl(); g.setPDBName(GROUP_NAME); g.addAtom(a); g.setResidueNumber(chainID, i + 1, null); c.addGroup(g); a.setX(pts[i].x); a.setY(pts[i].y); a.setZ(pts[i].z); pw.print(a.toPDB()); } } catch (FileNotFoundException e) { e.printStackTrace(); } // SecondaryStructureSequenceFeature sf = s.getSequenceFeature(); System.out.println("Start"); System.out.println(NAME); System.out.println(s.getAlphaLength()); try (Scanner scan = new Scanner(System.in)) { String in; while (!(in = scan.next()).equals("X")) { if (in.equals("g")) { int st = scan.nextInt(); System.out.println( SecondaryStructTools.distsToString(s.getRange(st - 1, scan.nextInt()), st)); } else if (in.equals("a")) s.printHelices(); else if (in.equals("b")) s.printStrands(); else if (in.equals("l")) System.out.println(s.length()); else if (in.equals("c")) s.printPoints(); // else if (in.equals("sf")) // for (int i = 0; i < s.length(); i++) // System.out.println((i + 1) + ":\t" + sf.toString(i)); else if (in.equals("test")) s.printVectors(s.getAlpha().getFeatures()); else if (in.equals("test1")) System.out.println("=(0,0,0)\t=" + s.normP + "*50\t=" + s.normX + "*50"); else if (in.equals("test2")) SecondaryStruct.printProjection(s.getAlphaNormProjection((byte) 0b00000000)); } } // sc.close(); }
/** * Makes dummy CA atoms at 1A intervals. Only the x coordinate increments by one at each * consecutive Atom. */ private Atom[] makeDummyCA(int len) { Atom[] ca1; Chain chain1 = new ChainImpl(); ca1 = new Atom[len]; for (int i = 0; i < len; i++) { ca1[i] = new AtomImpl(); ca1[i].setName("CA"); ca1[i].setCoords(new double[] {i, 0, 0}); Group aa = new AminoAcidImpl(); aa.setPDBName("GLY"); aa.setResidueNumber(ResidueNumber.fromString(i + "")); aa.addAtom(ca1[i]); chain1.addGroup(aa); } return ca1; }
/** * Returns a {@link Structure} corresponding to the CATH identifier supplied in {@code * structureName}, using the specified {@link CathDatabase}. */ public Structure getStructureForCathDomain(StructureName structureName, CathDatabase cathInstall) throws IOException, StructureException { CathDomain cathDomain = cathInstall.getDomainByCathId(structureName.getIdentifier()); Structure s = getStructureForPdbId(cathDomain.getIdentifier()); Structure n = cathDomain.reduce(s); // add the ligands of the chain... Chain newChain = n.getChainByPDB(structureName.getChainId()); Chain origChain = s.getChainByPDB(structureName.getChainId()); List<Group> ligands = origChain.getAtomLigands(); for (Group g : ligands) { if (!newChain.getAtomGroups().contains(g)) { newChain.addGroup(g); } } return n; }
/** * Returns the representation of a {@link ScopDomain} as a BioJava {@link Structure} object. * * @param domain a SCOP domain * @param scopDatabase A {@link ScopDatabase} to use * @param strictLigandHandling If set to false, hetero-atoms are included if and only if they * belong to a chain to which the SCOP domain belongs; if set to true, hetero-atoms are * included if and only if they are strictly within the definition (residue numbers) of the * SCOP domain * @return a Structure object * @throws IOException * @throws StructureException */ public Structure getStructureForDomain( ScopDomain domain, ScopDatabase scopDatabase, boolean strictLigandHandling) throws IOException, StructureException { String pdbId = domain.getPdbId(); Structure fullStructure = getStructureForPdbId(pdbId); Structure structure = domain.reduce(fullStructure); // TODO It would be better to move all of this into the reduce method, // but that would require ligand handling properties in StructureIdentifiers // because ligands sometimes occur after TER records in PDB files, we may need to add some // ligands back in // specifically, we add a ligand if and only if it occurs within the domain AtomPositionMap map = null; List<ResidueRangeAndLength> rrs = null; if (strictLigandHandling) { map = new AtomPositionMap( StructureTools.getAllAtomArray(fullStructure), AtomPositionMap.ANYTHING_MATCHER); rrs = ResidueRangeAndLength.parseMultiple(domain.getRanges(), map); } for (Chain chain : fullStructure.getChains()) { if (!structure.hasChain(chain.getChainID())) { continue; // we can't do anything with a chain our domain } // doesn't contain Chain newChain = structure.getChainByPDB(chain.getChainID()); List<Group> ligands = StructureTools.filterLigands(chain.getAtomGroups()); for (Group group : ligands) { boolean shouldContain = true; if (strictLigandHandling) { shouldContain = false; // whether the ligand occurs within the domain for (ResidueRange rr : rrs) { if (rr.contains(group.getResidueNumber(), map)) { shouldContain = true; } } } boolean alreadyContains = newChain.getAtomGroups().contains(group); // we don't want to add duplicate // ligands if (shouldContain && !alreadyContains) { newChain.addGroup(group); } } } // build a more meaningful description for the new structure StringBuilder header = new StringBuilder(); header.append(domain.getClassificationId()); if (scopDatabase != null) { int sf = domain.getSuperfamilyId(); ScopDescription description = scopDatabase.getScopDescriptionBySunid(sf); if (description != null) { header.append(" | "); header.append(description.getDescription()); } } structure.getPDBHeader().setDescription(header.toString()); return structure; }