public static Monomer[] getAlphaMonomers(Group[] groups, int firstGroupIndex) { AlphaMonomer previous = null; int count = 0; for (int i = firstGroupIndex; i < groups.Length; ++i, ++count) { Group group = groups[i]; if (!(group is AlphaMonomer)) { break; } AlphaMonomer current = (AlphaMonomer)group; if (current.polymer != null) { break; } if (!current.isConnectedAfter(previous)) { break; } previous = current; } if (count == 0) { return(null); } Monomer[] monomers = new Monomer[count]; for (int j = 0; j < count; ++j) { monomers[j] = (AlphaMonomer)groups[firstGroupIndex + j]; } return(monomers); }
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; } }