public static Monomer validateAndAllocate(Chain chain, string group3, int seqcode, int firstIndex, int lastIndex, int[] specialAtomIndexes, Atom[] atoms) { // System.out.println("PhosphorusMonomer.validateAndAllocate"); if (firstIndex != lastIndex || specialAtomIndexes[JmolConstants.ATOMID_NUCLEIC_PHOSPHORUS] != firstIndex) return null; return new PhosphorusMonomer(chain, group3, seqcode, firstIndex, lastIndex, phosphorusOffsets); }
public static new Monomer validateAndAllocate(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex, int[] specialAtomIndexes, Atom[] atoms) { sbyte[] offsets = scanForOffsets(firstAtomIndex, specialAtomIndexes, interestingAminoAtomIDs); if (offsets == null) return null; if (specialAtomIndexes[JmolConstants.ATOMID_CARBONYL_OXYGEN] < 0) { int carbonylOxygenIndex = specialAtomIndexes[JmolConstants.ATOMID_O1]; System.Console.Out.WriteLine("I see someone who does not have a carbonyl oxygen"); if (carbonylOxygenIndex < 0) return null; offsets[1] = (sbyte) (carbonylOxygenIndex - firstAtomIndex); } if (!isBondedCorrectly(firstAtomIndex, offsets, atoms)) return null; AminoMonomer aminoMonomer = new AminoMonomer(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, offsets); return aminoMonomer; }
public Chain getOrAllocateChain(char chainID) { // System.out.println("chainID=" + chainID + " -> " + (chainID + 0)); Chain chain = getChain(chainID); if (chain != null) return chain; if (chainCount == chains.Length) chains = (Chain[]) Util.doubleLength(chains); return chains[chainCount++] = new Chain(mmset.frame, this, chainID); }
//////////////////////////////////////////////////////////////// public NucleicMonomer(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex, sbyte[] offsets) : base(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, offsets) { if (offsets[0] == - 1) { sbyte leadOffset = offsets[20]; if (leadOffset == - 1) leadOffset = offsets[21]; if (leadOffset == - 1) leadOffset = offsets[22]; offsets[0] = leadOffset; } this.hasRnaO2Prime = offsets[2] != - 1; this.isPyrimidine_Renamed_Field = offsets[9] != - 1; this.isPurine_Renamed_Field = offsets[10] != - 1 && offsets[11] != - 1 && offsets[12] != - 1; /* System.out.println("NucleicMonomer(" + this + ")" + " hasRnaO2Prime=" + hasRnaO2Prime + " isPyrimidine=" + isPyrimidine + " isPurine=" + isPurine + " offsets[3]=" + offsets[3]); */ }
public static new Monomer validateAndAllocate(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex, int[] specialAtomIndexes, Atom[] atoms) { sbyte[] offsets = scanForOffsets(firstAtomIndex, specialAtomIndexes, interestingNucleicAtomIDs); if (offsets == null) return null; NucleicMonomer nucleicMonomer = new NucleicMonomer(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, offsets); return nucleicMonomer; }
public Monomer(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex, sbyte[] interestingAtomOffsets) : base(chain, group3, seqcode, firstAtomIndex, lastAtomIndex) { offsets = interestingAtomOffsets; }
private void finalizeBuild() { currentModel = null; currentChain = null; htAtomMap.Clear(); }
private void distinguishAndPropogateGroup(int groupIndex, Chain chain, string group3, int seqcode, int firstAtomIndex, int maxAtomIndex) { // System.out.println("distinguish & propogate group:" + // " group3:" + group3 + // " seqcode:" + Group.getSeqcodeString(seqcode) + // " firstAtomIndex:" + firstAtomIndex + // " maxAtomIndex:" + maxAtomIndex); int distinguishingBits = 0; // clear previous specialAtomIndexes for (int i = JmolConstants.ATOMID_MAX; --i >= 0; ) specialAtomIndexes[i] = Int32.MinValue; if (specialAtomIDs != null) { for (int i = maxAtomIndex; --i >= firstAtomIndex; ) { int specialAtomID = specialAtomIDs[i]; if (specialAtomID > 0) { if (specialAtomID < JmolConstants.ATOMID_DISTINGUISHING_ATOM_MAX) distinguishingBits |= 1 << specialAtomID; specialAtomIndexes[specialAtomID] = i; } } } int lastAtomIndex = maxAtomIndex - 1; if (lastAtomIndex < firstAtomIndex) throw new System.NullReferenceException(); Group group = null; // System.out.println("distinguishingBits=" + distinguishingBits); if ((distinguishingBits & JmolConstants.ATOMID_PROTEIN_MASK) == JmolConstants.ATOMID_PROTEIN_MASK) { // System.out.println("may be an AminoMonomer"); group = AminoMonomer.validateAndAllocate(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, specialAtomIndexes, atoms); } else if (distinguishingBits == JmolConstants.ATOMID_ALPHA_ONLY_MASK) { // System.out.println("AlphaMonomer.validateAndAllocate"); group = AlphaMonomer.validateAndAllocate(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, specialAtomIndexes, atoms); } else if (((distinguishingBits & JmolConstants.ATOMID_NUCLEIC_MASK) == JmolConstants.ATOMID_NUCLEIC_MASK)) { group = NucleicMonomer.validateAndAllocate(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, specialAtomIndexes, atoms); } else if (distinguishingBits == JmolConstants.ATOMID_PHOSPHORUS_ONLY_MASK) { // System.out.println("PhosphorusMonomer.validateAndAllocate"); group = PhosphorusMonomer.validateAndAllocate(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, specialAtomIndexes, atoms); } if (group == null) group = new Group(chain, group3, seqcode, firstAtomIndex, lastAtomIndex); chain.addGroup(group); groups[groupIndex] = group; //////////////////////////////////////////////////////////////// for (int i = maxAtomIndex; --i >= firstAtomIndex; ) atoms[i].Group = group; }
private void startGroup(Chain chain, string group3, int groupSequenceNumber, char groupInsertionCode, int firstAtomIndex) { if (groupCount == group3s.Length) { chains = (Chain[])Util.doubleLength(chains); group3s = Util.doubleLength(group3s); seqcodes = Util.doubleLength(seqcodes); firstAtomIndexes = Util.doubleLength(firstAtomIndexes); } firstAtomIndexes[groupCount] = firstAtomIndex; chains[groupCount] = chain; group3s[groupCount] = group3; seqcodes[groupCount] = Group.getSeqcode(groupSequenceNumber, groupInsertionCode); ++groupCount; }
private Atom AddAtom(int modelIndex, object atomUid, sbyte atomicNumber, string atomName, int formalCharge, float partialCharge, int occupancy, float bfactor, float x, float y, float z, bool isHetero, int atomSerial, char chainID, string group3, int groupSequenceNumber, char groupInsertionCode, float vectorX, float vectorY, float vectorZ, char alternateLocationID, object clientAtomReference) { if (modelIndex != currentModelIndex) { currentModel = mmset.getModel(modelIndex); currentModelIndex = modelIndex; currentChainID = '\uFFFF'; } if (chainID != currentChainID) { currentChainID = chainID; currentChain = currentModel.getOrAllocateChain(chainID); currentGroupInsertionCode = '\uFFFF'; } if (groupSequenceNumber != currentGroupSequenceNumber || groupInsertionCode != currentGroupInsertionCode) { currentGroupSequenceNumber = groupSequenceNumber; currentGroupInsertionCode = groupInsertionCode; startGroup(currentChain, group3, groupSequenceNumber, groupInsertionCode, atomCount); } if (atomCount == atoms.Length) growAtomArrays(); Atom atom = new Atom(this, currentModelIndex, atomCount, atomicNumber, atomName, formalCharge, partialCharge, occupancy, bfactor, x, y, z, isHetero, atomSerial, chainID, vectorX, vectorY, vectorZ, alternateLocationID, clientAtomReference); atoms[atomCount] = atom; ++atomCount; htAtomMap[atomUid] = atom; return atom; }
public /*Chem*/Frame(Org.OpenScience.CDK.Interfaces.IChemFile chemFile, Device graphicsDevice) { shapes = new Shape[JmolConstants.SHAPE_MAX]; this.g3d = new NuGraphics3D(graphicsDevice); this.frameRenderer = new FrameRenderer(); for (int i = MAX_BONDS_LENGTH_TO_CACHE; --i > 0; ) // .GT. 0 freeBonds[i] = new Bond[MAX_NUM_TO_CACHE][]; // convert to jmol native mmset = new Mmset(this); // set properties mmset.ModelSetProperties = new System.Collections.Specialized.NameValueCollection(); // init build currentModelIndex = -1; currentModel = null; currentChainID = '\uFFFF'; currentChain = null; currentGroupSequenceNumber = -1; currentGroupInsertionCode = '\uFFFF'; int atomCountEstimate = 0; for (int seq = 0; seq < chemFile.ChemSequenceCount; seq++) { for (int model = 0; model < chemFile.ChemSequences[seq].ChemModelCount; model++) { Org.OpenScience.CDK.Interfaces.IChemModel chemModel = chemFile.ChemSequences[seq].ChemModels[model]; for (int atomC = 0; atomC < chemModel.SetOfMolecules.AtomContainerCount; atomC++) { atomCountEstimate += chemModel.SetOfMolecules.AtomContainers[atomC].AtomCount; } } } if (atomCountEstimate <= 0) atomCountEstimate = ATOM_GROWTH_INCREMENT; atoms = new Atom[atomCountEstimate]; bonds = new Bond[2 * atomCountEstimate]; htAtomMap.Clear(); // translate IChemSequence[] into Model[] mmset.ModelCount = chemFile.ChemSequenceCount; for (int seq = 0; seq < chemFile.ChemSequenceCount; ++seq) { int modelNumber = seq + 1; string modelName = modelNumber.ToString(); NameValueCollection modelProperties = new NameValueCollection(); // FIXME: Loading property values mmset.setModelNameNumberProperties(seq, modelName, modelNumber, modelProperties); } // translate Atoms Dictionary<Org.OpenScience.CDK.Interfaces.IAtom, Atom> atomsList = new Dictionary<Org.OpenScience.CDK.Interfaces.IAtom, Atom>(); //try //{ for (int seq = 0; seq < chemFile.ChemSequenceCount; seq++) { for (int model = 0; model < chemFile.ChemSequences[seq].ChemModelCount; model++) { Org.OpenScience.CDK.Interfaces.IChemModel chemModel = chemFile.ChemSequences[seq].ChemModels[model]; for (int atomC = 0; atomC < chemModel.SetOfMolecules.AtomContainerCount; atomC++) { for (int atomIdx = 0; atomIdx < chemModel.SetOfMolecules.AtomContainers[atomC].AtomCount; atomIdx++) { Org.OpenScience.CDK.Interfaces.IAtom atom = chemModel.SetOfMolecules.AtomContainers[atomC].Atoms[atomIdx]; sbyte elementNumber = (sbyte)atom.AtomicNumber; if (elementNumber <= 0) elementNumber = JmolConstants.elementNumberFromSymbol(atom.Symbol); char alternateLocation = '\0'; int sequenceNumber = int.MinValue; char groupInsertionCode = '\0'; string atomName = null; string group3Name = null; char chainID = '\0'; if (atom is PDBAtom) { PDBAtom pdbAtom = (PDBAtom)atom; if (pdbAtom.ResSeq != null && pdbAtom.ResSeq.Length > 0) sequenceNumber = int.Parse(pdbAtom.ResSeq); if (pdbAtom.ICode != null && pdbAtom.ICode.Length > 0) groupInsertionCode = pdbAtom.ICode[0]; atomName = pdbAtom.Name; group3Name = pdbAtom.ResName; if (pdbAtom.ChainID != null && pdbAtom.ChainID.Length >= 1) chainID = pdbAtom.ChainID[0]; } else atomName = atom.AtomTypeName; atomsList[atom] = AddAtom(model, atom, elementNumber, atomName, atom.getFormalCharge(), (float)atom.getCharge(), 100, float.NaN, (float)atom.X3d, (float)atom.Y3d, (float)atom.Z3d, false, int.MinValue, chainID, group3Name, sequenceNumber, groupInsertionCode, float.NaN, float.NaN, float.NaN, alternateLocation, null); } } } } //} //catch (Exception e) //{ // throw new ApplicationException("Problem translating atoms", e); //} fileHasHbonds = false; // translate bonds try { for (int seq = 0; seq < chemFile.ChemSequenceCount; seq++) { for (int model = 0; model < chemFile.ChemSequences[seq].ChemModelCount; model++) { Org.OpenScience.CDK.Interfaces.IChemModel chemModel = chemFile.ChemSequences[seq].ChemModels[model]; for (int atomC = 0; atomC < chemModel.SetOfMolecules.AtomContainerCount; atomC++) { for (int bondIdx = 0; bondIdx < chemModel.SetOfMolecules.AtomContainers[atomC].Bonds.Length; bondIdx++) { Org.OpenScience.CDK.Interfaces.IBond bond = chemModel.SetOfMolecules.AtomContainers[atomC].Bonds[bondIdx]; Org.OpenScience.CDK.Interfaces.IAtom[] cdkAtoms = bond.getAtoms(); // locate translated atoms Atom atom1, atom2; atomsList.TryGetValue(cdkAtoms[0], out atom1); atomsList.TryGetValue(cdkAtoms[1], out atom2); bondAtoms(atom1, atom2, (int)bond.Order); } } } } } catch (Exception e) { throw new ApplicationException("Problem translating bonds", e); } atomsList.Clear(); // translate structures of PDBPolymer only for (int seq = 0; seq < chemFile.ChemSequenceCount; seq++) { for (int model = 0; model < chemFile.ChemSequences[seq].ChemModelCount; model++) { Org.OpenScience.CDK.Interfaces.IChemModel chemModel = chemFile.ChemSequences[seq].ChemModels[model]; foreach (Org.OpenScience.CDK.Interfaces.IMolecule molecule in chemModel.SetOfMolecules.Molecules) { if (molecule is PDBPolymer) { PDBPolymer pdbPolymer = (PDBPolymer)molecule; if (pdbPolymer.Structures != null && pdbPolymer.Structures.Count > 0) { structuresDefined = true; foreach (PDBStructure pdbStruct in pdbPolymer.Structures) { structuresDefined = true; mmset.defineStructure(pdbStruct.StructureType, pdbStruct.StartChainID, pdbStruct.StartSequenceNumber, pdbStruct.StartInsertionCode, pdbStruct.EndChainID, pdbStruct.EndSequenceNumber, pdbStruct.EndInsertionCode); } } } } } } autoBond(null, null); // build groups FinalizeGroupBuild(); BuildPolymers(); Freeze(); finalizeBuild(); // create ribbon shapes try { setShapeSize(JmolConstants.SHAPE_RIBBONS, -1, new BitArray(0)); setShapeSize(JmolConstants.SHAPE_CARTOON, -1, new BitArray(0)); } catch (Exception) { } }
//////////////////////////////////////////////////////////////// public AminoMonomer(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex, sbyte[] offsets) : base(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, offsets) { }
public void initializeBuild(int atomCountEstimate) { currentModel = null; currentChainID = '\uFFFF'; currentChain = null; currentGroupInsertionCode = '\uFFFF'; if (atomCountEstimate <= 0) atomCountEstimate = ATOM_GROWTH_INCREMENT; atoms = new Atom[atomCountEstimate]; bonds = new Bond[2 * atomCountEstimate]; htAtomMap.Clear(); initializeGroupBuild(); }
public Group(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex) { this.chain = chain; this.seqcode = seqcode; if (group3 == null) group3 = ""; this.groupID = getGroupID(group3); this.firstAtomIndex = firstAtomIndex; this.lastAtomIndex = lastAtomIndex; }
//////////////////////////////////////////////////////////////// public AlphaMonomer(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex, sbyte[] offsets) : base(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, offsets) { }
public static Monomer validateAndAllocate(Chain chain, string group3, int seqcode, int firstIndex, int lastIndex, int[] specialAtomIndexes, Atom[] atoms) { if (firstIndex != lastIndex || specialAtomIndexes[JmolConstants.ATOMID_ALPHA_CARBON] != firstIndex) return null; return new AlphaMonomer(chain, group3, seqcode, firstIndex, lastIndex, alphaOffsets); }