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