Java Code Examples for org.biojava.nbio.structure.Structure#addModel()
The following examples show how to use
org.biojava.nbio.structure.Structure#addModel() .
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: BiologicalAssemblyBuilder.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
/** * Adds a chain to the given structure to form a biological assembly, * adding the symmetry expanded chains as new models per transformId. * @param s * @param newChain * @param transformId */ private void addChainMultiModel(Structure s, Chain newChain, String transformId) { // multi-model bioassembly if ( modelIndex.size() == 0) modelIndex.add("PLACEHOLDER FOR ASYM UNIT"); int modelCount = modelIndex.indexOf(transformId); if ( modelCount == -1) { modelIndex.add(transformId); modelCount = modelIndex.indexOf(transformId); } if (modelCount == 0) { s.addChain(newChain); } else if (modelCount > s.nrModels()) { List<Chain> newModel = new ArrayList<>(); newModel.add(newChain); s.addModel(newModel); } else { s.addChain(newChain, modelCount-1); } }
Example 2
Source File: MultipleAlignmentTools.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * Get an artificial Structure containing a different model for every * input structure, so that the alignment result can be viewed in Jmol. * The Atoms have to be rotated beforehand. * * @param atomArrays an array of Atoms for every aligned structure * @return a structure object containing a set of models, * one for each input array of Atoms. * @throws StructureException */ public static final Structure getAlignedStructure(List<Atom[]> atomArrays) throws StructureException { Structure s = new StructureImpl(); for (int i=0; i<atomArrays.size(); i++){ List<Chain> model = AlignmentTools.getAlignedModel(atomArrays.get(i)); s.addModel(model); } return s; }
Example 3
Source File: TestSecStrucCalc.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test that calculating the secondary structure for multi-model systems works. * Combine two PDBs into one multi-model system * Calculate the secondary structure * Combine with the combined list fetching from the server * @throws StructureException * @throws IOException */ @Test public void testMultiModelPred() throws StructureException, IOException { String pdbId = "5pti"; String pdbIdTwo = "4hhb"; SecStrucCalc sec = new SecStrucCalc(); // Combine these into one structure with two models AtomCache cache = new AtomCache(); Structure structure = cache.getStructure(pdbId); Structure structureTwo = cache.getStructure(pdbIdTwo); // Join them together structure.addModel(structureTwo.getChains()); List<SecStrucState> biojava = sec.calculate(structure, true); // Download the original DSSP implementation output List<SecStrucState> dssp = DSSPParser.parseInputStream(new GZIPInputStream( this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+pdbId+".dssp.gz")),cache.getStructure(pdbId), false); dssp.addAll(DSSPParser.parseInputStream(new GZIPInputStream( this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+pdbIdTwo+".dssp.gz")), cache.getStructure(pdbIdTwo), false)); assertEquals("SS assignment lengths do not match", biojava.size(), dssp.size()); for (int i=0; i<dssp.size(); i++){ assertEquals("SS assignment position "+(i+1)+" does not match", biojava.get(i), dssp.get(i)); } }
Example 4
Source File: SymmetryTools.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** * Method that converts the symmetric units of a structure into different * structures, so that they can be individually visualized. * * @param symmetry * CeSymmResult * @throws StructureException * @result List of structures, by repeat index sequentially * */ public static List<Structure> divideStructure(CeSymmResult symmetry) throws StructureException { if (!symmetry.isRefined()) throw new IllegalArgumentException("The symmetry result " + "is not refined, repeats cannot be defined"); int order = symmetry.getMultipleAlignment().size(); Atom[] atoms = symmetry.getAtoms(); Set<Group> allGroups = StructureTools.getAllGroupsFromSubset(atoms, GroupType.HETATM); List<StructureIdentifier> repeatsId = symmetry.getRepeatsID(); List<Structure> repeats = new ArrayList<Structure>(order); // Create new structure containing the repeat atoms for (int i = 0; i < order; i++) { Structure s = new StructureImpl(); s.addModel(new ArrayList<Chain>(1)); s.setStructureIdentifier(repeatsId.get(i)); Block align = symmetry.getMultipleAlignment().getBlock(0); // Get the start and end of the repeat // Repeats are always sequential blocks int res1 = align.getStartResidue(i); int res2 = align.getFinalResidue(i); // All atoms from the repeat, used for ligand search // AA have an average of 8.45 atoms, so guess capacity with that List<Atom> repeat = new ArrayList<>(Math.max(9*(res2-res1+1),9)); // speedy chain lookup Chain prevChain = null; for(int k=res1;k<=res2; k++) { Group g = atoms[k].getGroup(); prevChain = StructureTools.addGroupToStructure(s, g, 0, prevChain,true); repeat.addAll(g.getAtoms()); } List<Group> ligands = StructureTools.getLigandsByProximity( allGroups, repeat.toArray(new Atom[repeat.size()]), StructureTools.DEFAULT_LIGAND_PROXIMITY_CUTOFF); logger.warn("Adding {} ligands to {}",ligands.size(), symmetry.getMultipleAlignment().getStructureIdentifier(i)); for( Group ligand : ligands) { prevChain = StructureTools.addGroupToStructure(s, ligand, 0, prevChain,true); } repeats.add(s); } return repeats; }