public static decimal CalculateProteinInterfaceAverageResidueSequenceIndex(ClusteringResultProteinInterfaceListContainer.Chain.ProteinInterface proteinInterface) { if (ParameterValidation.IsProteinInterfaceNullOrEmpty(proteinInterface)) { throw new ArgumentOutOfRangeException(nameof(proteinInterface)); } decimal sumTotal = 0.0m; int sumAtoms = 0; foreach (ATOM_Record atom in proteinInterface.AtomList) { int residueSequenceIndex; if (int.TryParse(atom.resSeq.FieldValue, out residueSequenceIndex)) { sumTotal += residueSequenceIndex; sumAtoms++; } } decimal average = -1m; if (sumAtoms > 0) { average = sumTotal / sumAtoms; } return(average); }