public static ATOM_Record FindAtomInsidePdbFileChain(ProteinChainListContainer pdbFileChains, int chainIndex, int residueSequenceIndex) { if (ParameterValidation.IsProteinChainListContainerNullOrEmpty(pdbFileChains)) { return(null); } if (ParameterValidation.IsChainIndexInvalid(chainIndex)) { throw new ArgumentOutOfRangeException(nameof(chainIndex)); } if (ParameterValidation.IsResidueSequenceIndexInvalid(residueSequenceIndex, true)) { throw new ArgumentOutOfRangeException(nameof(residueSequenceIndex)); } for (int memberIndex = 0; memberIndex < pdbFileChains.ChainList[chainIndex].AtomList.Count; memberIndex++) { ATOM_Record atom = pdbFileChains.ChainList[chainIndex].AtomList[memberIndex]; if (ProteinDataBankFileOperations.NullableTryParseInt32(atom.resSeq.FieldValue) == residueSequenceIndex) { return(atom); } } return(null); }
public static ATOM_Record FindAtomInsideSingularInteractionsChain(ProteinChainListContainer singularAaToAaInteractions, int chainIndex, int residueSequenceIndex) { if (ParameterValidation.IsProteinChainListContainerNullOrEmpty(singularAaToAaInteractions)) { return(null); } if (ParameterValidation.IsChainIndexInvalid(chainIndex)) { throw new ArgumentOutOfRangeException(nameof(chainIndex)); } if (ParameterValidation.IsResidueSequenceIndexInvalid(residueSequenceIndex, true)) { throw new ArgumentOutOfRangeException(nameof(residueSequenceIndex)); } // Loop through atoms in specified chain to find atom with given residue sequence index for (int atomIndex = 0; atomIndex < singularAaToAaInteractions.ChainList[chainIndex].AtomList.Count; atomIndex++) { ATOM_Record atom = singularAaToAaInteractions.ChainList[chainIndex].AtomList[atomIndex]; if (ProteinDataBankFileOperations.NullableTryParseInt32(atom.resSeq.FieldValue) == residueSequenceIndex) { return(atom); } } return(null); }
public static bool IsAtomNullOrEmpty(ATOM_Record atom) { if (atom == null || string.IsNullOrWhiteSpace(atom.resName.FieldValue)) { return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="AtomPair" /> class. /// </summary> /// <param name="atom1">The first atom.</param> /// <param name="atom2">The second atom.</param> /// <param name="distance"> /// The distance between atom1 and atom2 (presumed already calculated as it is expensive to /// calculate 3d distance). /// </param> public AtomPair(ATOM_Record atom1, ATOM_Record atom2, decimal distance = 0) { //PdbIdAtom1 = null; Atom1 = atom1; //PdbIdAtom2 = null; Atom2 = atom2; Distance = distance; }
public static Point1D AtomResidueSequencePoint1D(ATOM_Record atom) { if (ParameterValidation.IsAtomNullOrEmpty(atom)) { throw new ArgumentOutOfRangeException(nameof(atom)); } return(new Point1D(atom.resSeq.FieldValue)); }
public static Point3D AtomPoint3D(ATOM_Record atom) { if (ParameterValidation.IsAtomNullOrEmpty(atom)) { throw new ArgumentOutOfRangeException(nameof(atom)); } return(new Point3D(atom.x.FieldValue, atom.y.FieldValue, atom.z.FieldValue)); }
public AtomPair(string pdbIdAtom1, ATOM_Record atom1, string pdbIdAtom2, ATOM_Record atom2, decimal distance = 0) { Atom1 = atom1; Atom2 = atom2; Distance = distance; Atom1FullProteinInterfaceId.ProteinId = pdbIdAtom1; Atom2FullProteinInterfaceId.ProteinId = pdbIdAtom2; }
/// <summary> /// This method returns the total number of interactions an atom has with non-proteinInterfaces in oppoproteinInterface chains. The method /// requires the object returned by the FindInteractionsBetweenProteinInterfaces method. /// </summary> /// <param name="interactionBetweenProteinInterfacesContainer"></param> /// <param name="sourceChainIndex"></param> /// <param name="atomToFind"></param> /// <returns></returns> public static int CountAtomInteractionsOutsideProteinInterface( InteractionBetweenProteinInterfacesListContainer interactionBetweenProteinInterfacesContainer, int sourceChainIndex, ATOM_Record atomToFind ) { int totalInteractionsOutsideProteinInterfaces = interactionBetweenProteinInterfacesContainer.InteractionBetweenNonProteinInterfacesList.Count( a => (a.Atom1.FullProteinInterfaceId.ChainId == sourceChainIndex && a.Atom1.Atom == atomToFind) || (a.Atom2.FullProteinInterfaceId.ChainId == sourceChainIndex && a.Atom2.Atom == atomToFind)); return(totalInteractionsOutsideProteinInterfaces); }
/// <summary> /// Get the lowest (minimum) and highest (maximum) residue sequence index (as found in the pdb file) in an interaction /// proteinInterface. /// </summary> /// <param name="proteinInterface"></param> /// <param name="singularAaToAaInteractions"></param> /// <param name="chainIndex"></param> /// <returns></returns> public static MinMax MinMaxResidueSequenceIndex(ClusteringFullResultListContainer.Chain.Stage.Cluster proteinInterface, ProteinChainListContainer singularAaToAaInteractions, int chainIndex) { if (ParameterValidation.IsClusterNullOrEmpty(proteinInterface)) { throw new ArgumentNullException(nameof(proteinInterface)); } if (ParameterValidation.IsProteinChainListContainerNullOrEmpty(singularAaToAaInteractions)) { throw new ArgumentNullException(nameof(singularAaToAaInteractions)); } if (ParameterValidation.IsChainIndexInvalid(chainIndex)) { throw new ArgumentOutOfRangeException(nameof(chainIndex)); } int proteinInterfaceMin = 0; int proteinInterfaceMax = 0; for (int memberIndex = 0; memberIndex < proteinInterface.AtomIndexList.Count; memberIndex++) { int member = proteinInterface.AtomIndexList[memberIndex]; ATOM_Record atom = singularAaToAaInteractions.ChainList[chainIndex].AtomList[member]; var residueSequenceIndex = ProteinDataBankFileOperations.NullableTryParseInt32(atom.resSeq.FieldValue); if (residueSequenceIndex == null) { continue; } if (memberIndex == 0 || residueSequenceIndex < proteinInterfaceMin) { proteinInterfaceMin = residueSequenceIndex.Value; } if (memberIndex == 0 || residueSequenceIndex > proteinInterfaceMax) { proteinInterfaceMax = residueSequenceIndex.Value; } } return(new MinMax(proteinInterfaceMin, proteinInterfaceMax)); }
public static int AtomIndexPositionInProteinInterface( ProteinChainListContainer singularAaToAaInteractions, ClusteringFullResultListContainer proteinInterfacesClusteringResult, int[] detectedBestStages, int chainIndex, int proteinInterfaceIndex, ATOM_Record atomPositionToFind) { List <ClusteringFullResultListContainer.Chain.Stage.Cluster> proteinInterfaceList = proteinInterfacesClusteringResult.ChainList[chainIndex].StageList[detectedBestStages[chainIndex]].ClusterList; List <ClusteringFullResultListContainer.Chain.Stage.Cluster> nonEmptyProteinInterfaceList = proteinInterfaceList.Where(a => a != null && a.AtomIndexList != null && a.AtomIndexList.Count > 0).ToList(); if (proteinInterfaceIndex > nonEmptyProteinInterfaceList.Count - 1) { throw new ArgumentOutOfRangeException(nameof(proteinInterfaceIndex), proteinInterfaceIndex, "proteinInterfaceIndex was greater than the number of proteinInterfaces found."); } ClusteringFullResultListContainer.Chain.Stage.Cluster proteinInterface = nonEmptyProteinInterfaceList[proteinInterfaceIndex]; if (proteinInterface.AtomIndexList.Count == 0) { return(-1); } MinMax minMaxResidueSequenceIndex = MinMaxResidueSequenceIndex(proteinInterface, singularAaToAaInteractions, chainIndex); int proteinInterfaceLength = CalculateProteinInterfaceLength(minMaxResidueSequenceIndex.Min, minMaxResidueSequenceIndex.Max); var residueSequenceToFind = ProteinDataBankFileOperations.NullableTryParseInt32(atomPositionToFind.resSeq.FieldValue); if (residueSequenceToFind == null) { return(-1); } int index = residueSequenceToFind.Value - minMaxResidueSequenceIndex.Min; // zero based return(index); }
public InteractionAtom(ATOM_Record atom, FullProteinInterfaceId fullProteinInterfaceId) { Atom = atom; FullProteinInterfaceId = fullProteinInterfaceId; }
public InteractionAtom(ATOM_Record atom) { Atom = atom; }
/// <summary> /// This method loads 1 pdb file and returns the atoms contained in the different chains. /// </summary> /// <param name="pdbFilename"></param> /// <param name="chainIdWhiteList"></param> /// <param name="minimumChains"></param> /// <param name="maximumChains"></param> /// <returns></returns> public static ProteinChainListContainer PdbAtomicChains(string pdbFilename, string[] chainIdWhiteList, int minimumChains = 2, int maximumChains = 2, bool onlyCarbonAlphas = false) { ////////Console.WriteLine(pdbFilename); // Check file exists. if (!File.Exists(pdbFilename)) { //return null; throw new FileNotFoundException("File not found", pdbFilename); } // Check min chains not more than max chains. if (minimumChains > maximumChains) { throw new ArgumentOutOfRangeException(nameof(minimumChains)); } // Load pdb/protein file, excluding all records but ATOM, HETATM and TER. var proteinDataBankFile = new ProteinDataBankFile(pdbFilename, new[] { ATOM_Record.ATOM_Field.FieldName, HETATM_Record.HETATM_Field.FieldName, TER_Record.TER_Field.FieldName, MODEL_Record.MODEL_Field.FieldName, ENDMDL_Record.ENDMDL_Field.FieldName }); // Make new array for atom chain. //List<ATOM_Record>[] proteinFileChains = new List<ATOM_Record>[maximumChains]; var pdbFileChains = new ProteinChainListContainer(); //var fileError = false; //var chainCount = 0; // Loop through all the previously loaded protein file records to make lists of atoms in each chain. // Also make a list of residue numbers (which will be sorted later just in case it is out of order). var atomRecordListDictionary = new Dictionary <string, List <ProteinDataBankFileRecord> >(); var hetAtomRecordListDictionary = new Dictionary <string, List <ProteinDataBankFileRecord> >(); int terCount = 0; for (int proteinDataBankFileRecordIndex = 0; proteinDataBankFileRecordIndex < proteinDataBankFile.Count; proteinDataBankFileRecordIndex++) { ProteinDataBankFileRecord currentRecord = proteinDataBankFile.NextRecord(); if (currentRecord == null) { continue; } if (currentRecord.GetType() == typeof(ATOM_Record)) { var atom = (ATOM_Record)currentRecord; if (onlyCarbonAlphas && atom.name.FieldValue.Trim().ToUpperInvariant() != StaticValues.CarbonAlpha) { continue; } string chainIdKey = atom.chainID.FieldValue.Trim().ToUpperInvariant(); if (chainIdWhiteList != null && !chainIdWhiteList.Contains(chainIdKey)) { continue; } if (!atomRecordListDictionary.ContainsKey(chainIdKey)) { atomRecordListDictionary.Add(chainIdKey, new List <ProteinDataBankFileRecord>()); } if (ParameterValidation.IsAminoAcidCodeValid(atom.resName.FieldValue)) { atomRecordListDictionary[chainIdKey].Add(atom); } } else if (currentRecord.GetType() == typeof(HETATM_Record)) { var hetatm = (HETATM_Record)currentRecord; if (onlyCarbonAlphas && hetatm.name.FieldValue.Trim().ToUpperInvariant() != StaticValues.CarbonAlpha) { continue; } string chainIdKey = hetatm.chainID.FieldValue.Trim().ToUpperInvariant(); if (chainIdWhiteList != null && !chainIdWhiteList.Contains(chainIdKey)) { continue; } if (!hetAtomRecordListDictionary.ContainsKey(chainIdKey)) { hetAtomRecordListDictionary.Add(chainIdKey, new List <ProteinDataBankFileRecord>()); } //if (!ParameterValidation.IsAminoAcidCodeValid(hetatm.resName.FieldValue)) //{ // ////////Console.WriteLine(hetatm.columnFormatLine); // hetatm.resName.FieldValue = UnspecifiedOrUnknownAminoAcid.Code3L; // hetatm.columnFormatLine = hetatm.columnFormatLine.Remove(ProteinDataBankFile.HETATM_Record.resName_Field.FirstColumn - 1, (ProteinDataBankFile.HETATM_Record.resName_Field.LastColumn - ProteinDataBankFile.HETATM_Record.resName_Field.FirstColumn) + 1); // hetatm.columnFormatLine = hetatm.columnFormatLine.Insert(ProteinDataBankFile.HETATM_Record.resName_Field.FirstColumn - 1, UnspecifiedOrUnknownAminoAcid.Code3L); // ////////Console.WriteLine(hetatm.columnFormatLine); //} if (ParameterValidation.IsAminoAcidCodeValid(hetatm.resName.FieldValue)) { hetAtomRecordListDictionary[chainIdKey].Add(hetatm); } } else if (currentRecord.GetType() == typeof(TER_Record)) { var ter = (TER_Record)currentRecord; string chainIdKey = ter.chainID.FieldValue.Trim().ToUpperInvariant(); if (chainIdWhiteList != null && !chainIdWhiteList.Contains(chainIdKey)) { continue; } terCount++; if (terCount >= maximumChains) { break; //return null; } } else if (currentRecord.GetType() == typeof(ENDMDL_Record)) { break; } } // file has been parsed so clear used file data from memory as soon as possible proteinDataBankFile.UnloadFile(); int totalChains = atomRecordListDictionary.Count > hetAtomRecordListDictionary.Count ? atomRecordListDictionary.Count : hetAtomRecordListDictionary.Count; for (int chainIndex = 0; chainIndex < totalChains; chainIndex++) { pdbFileChains.ChainList.Add(new ProteinAtomListContainer()); } atomRecordListDictionary = atomRecordListDictionary.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value); int chainIndex2 = -1; foreach (var atomRecordListKvp in atomRecordListDictionary) { chainIndex2++; string chainName = atomRecordListKvp.Key; List <ProteinDataBankFileRecord> chainRecords = atomRecordListKvp.Value; if (chainRecords == null || chainRecords.Count == 0) { continue; } chainRecords = chainRecords.OrderBy(a => NullableTryParseInt32(((ATOM_Record)a).serial.FieldValue)).ToList(); pdbFileChains.ChainList[chainIndex2].AtomList = chainRecords.Select(a => (ATOM_Record)a).ToList(); } hetAtomRecordListDictionary = hetAtomRecordListDictionary.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value); int chainIndex3 = -1; foreach (var hetAtomRecordListKvp in hetAtomRecordListDictionary) { chainIndex3++; string chainName = hetAtomRecordListKvp.Key; List <ProteinDataBankFileRecord> chainRecords = hetAtomRecordListKvp.Value; if (chainRecords == null || chainRecords.Count == 0) { continue; } chainRecords = chainRecords.OrderBy(a => NullableTryParseInt32(((HETATM_Record)a).serial.FieldValue)).ToList(); foreach (ProteinDataBankFileRecord proteinDataBankFileRecord in chainRecords) { var chainRecord = (HETATM_Record)proteinDataBankFileRecord; string residueSequenceToFind = chainRecord.resSeq.FieldValue; string atomChainId = chainRecord.chainID.FieldValue.Trim().ToUpperInvariant(); if (!atomRecordListDictionary.ContainsKey(atomChainId) || atomRecordListDictionary[atomChainId].Count(a => ((ATOM_Record)a).resSeq.FieldValue == residueSequenceToFind) == 0) { ATOM_Record atom = ConvertHetatmRecordToAtomRecord(chainRecord); pdbFileChains.ChainList[chainIndex3].AtomList.Add(atom); } } } int nonEmptyChainCount = pdbFileChains.ChainList.Count(a => a != null && a.AtomList != null && a.AtomList.Count > 0); if (nonEmptyChainCount >= minimumChains && nonEmptyChainCount <= maximumChains) { return(pdbFileChains); } ////////Console.WriteLine("Too many chains (" + nonEmptyChainCount + "): " + pdbFilename); return(null); }
/// <summary> /// This method finds interactions between detected proteinInterfaces. It is specific to dimers with exactly two chains. [Chain A /// ProteinInterface Index, Chain B ProteinInterface Index] /// </summary> /// <param name="cancellationToken"></param> /// <param name="pdbFilename"></param> /// <param name="pdbFileChains"></param> /// <param name="chainInteractingAtomLists"></param> /// <param name="fullClusteringResult"></param> /// <param name="proteinInterfacesClusteringResult"></param> /// <param name="detectedFinalStageIndexes"></param> /// <param name="pdbIdChainIdList"></param> /// <returns></returns> public static InteractionBetweenProteinInterfacesListContainer FindInteractionsBetweenAnyProteinInterfaces( CancellationToken cancellationToken, decimal maxAtomInterationDistance, string pdbFilename, Dictionary<string, List<string>> pdbIdChainIdList, ProteinChainListContainer pdbFileChains, ProteinChainListContainer chainInteractingAtomLists, ClusteringFullResultListContainer fullClusteringResult, ClusteringFullResultListContainer proteinInterfacesClusteringResult, int[] detectedFinalStageIndexes) { if (string.IsNullOrWhiteSpace(pdbFilename)) { throw new ArgumentOutOfRangeException(nameof(pdbFilename)); } if (!File.Exists(pdbFilename)) { throw new FileNotFoundException("File not found", pdbFilename); } if (ParameterValidation.IsProteinChainListContainerNullOrEmpty(chainInteractingAtomLists)) { throw new ArgumentOutOfRangeException(nameof(chainInteractingAtomLists)); } if (ParameterValidation.IsClusteringFullResultListContainerNullOrEmpty(fullClusteringResult)) { throw new ArgumentOutOfRangeException(nameof(fullClusteringResult)); } if (ParameterValidation.IsClusteringFullResultListContainerNullOrEmpty(proteinInterfacesClusteringResult)) { throw new ArgumentOutOfRangeException(nameof(proteinInterfacesClusteringResult)); } if (ParameterValidation.IsIntArrayNullOrEmpty(detectedFinalStageIndexes)) { throw new ArgumentOutOfRangeException(nameof(detectedFinalStageIndexes)); } string proteinId = ProteinDataBankFileOperations.PdbIdFromPdbFilename(pdbFilename); var interactionBetweenProteinInterfacesListContainer = new InteractionBetweenProteinInterfacesListContainer(); List<AtomPair> interactionList; if (pdbFileChains != null && pdbFileChains.ChainList != null && pdbFileChains.ChainList.Count > 0) { interactionList = SearchInteractions.FindInteractions(cancellationToken, maxAtomInterationDistance, proteinId, pdbIdChainIdList, pdbFileChains); //, false, -1, pdbFileChains); } else { interactionList = SearchInteractions.FindInteractions(cancellationToken, maxAtomInterationDistance, pdbFilename, pdbIdChainIdList); } var interactionInsideProteinInterfaceArray = new bool[interactionList.Count]; ////////Console.WriteLine(""); ////////Console.WriteLine(""); ////////Console.WriteLine("------------------ START ------------------"); //int c = 0; for (int chainIndexA = 0; chainIndexA < proteinInterfacesClusteringResult.ChainList.Count; chainIndexA++) { for (int chainIndexB = 0; chainIndexB < proteinInterfacesClusteringResult.ChainList.Count; chainIndexB++) { if (chainIndexA == chainIndexB || chainIndexB < chainIndexA) { continue; } List<ClusteringFullResultListContainer.Chain.Stage.Cluster> proteinInterfaceListA = proteinInterfacesClusteringResult.ChainList[chainIndexA].StageList[detectedFinalStageIndexes[chainIndexA]].ClusterList; List<ClusteringFullResultListContainer.Chain.Stage.Cluster> proteinInterfaceListB = proteinInterfacesClusteringResult.ChainList[chainIndexB].StageList[detectedFinalStageIndexes[chainIndexB]].ClusterList; int realProteinInterfaceIndexA = -1; for (int proteinInterfaceIndexA = 0; proteinInterfaceIndexA < proteinInterfaceListA.Count; proteinInterfaceIndexA++) { int realProteinInterfaceIndexB = -1; List<int> proteinInterfaceMemberIndexListA = proteinInterfaceListA[proteinInterfaceIndexA].AtomIndexList; List<ATOM_Record> proteinInterfaceAtomListA = proteinInterfaceMemberIndexListA.Select(proteinInterfaceMemberIndexA => chainInteractingAtomLists.ChainList[chainIndexA].AtomList[proteinInterfaceMemberIndexA]).ToList(); proteinInterfaceAtomListA = proteinInterfaceAtomListA.OrderBy(a => ProteinDataBankFileOperations.NullableTryParseInt32(a.resSeq.FieldValue)).ToList(); if (proteinInterfaceAtomListA.Count > 0) { realProteinInterfaceIndexA++; } else { continue; } for (int proteinInterfaceIndexB = 0; proteinInterfaceIndexB < proteinInterfaceListB.Count; proteinInterfaceIndexB++) { List<int> proteinInterfaceMemberIndexListB = proteinInterfaceListB[proteinInterfaceIndexB].AtomIndexList; List<ATOM_Record> proteinInterfaceAtomListB = proteinInterfaceMemberIndexListB.Select(proteinInterfaceMemberIndexB => chainInteractingAtomLists.ChainList[chainIndexB].AtomList[proteinInterfaceMemberIndexB]).ToList(); proteinInterfaceAtomListB = proteinInterfaceAtomListB.OrderBy(b => ProteinDataBankFileOperations.NullableTryParseInt32(b.resSeq.FieldValue)).ToList(); if (proteinInterfaceAtomListB.Count > 0) { realProteinInterfaceIndexB++; } else { continue; } for (int proteinInterfaceAtomListIndexA = 0; proteinInterfaceAtomListIndexA < proteinInterfaceAtomListA.Count; proteinInterfaceAtomListIndexA++) { ATOM_Record atomA = proteinInterfaceAtomListA[proteinInterfaceAtomListIndexA]; for (int proteinInterfaceAtomListIndexB = 0; proteinInterfaceAtomListIndexB < proteinInterfaceAtomListB.Count; proteinInterfaceAtomListIndexB++) { ATOM_Record atomB = proteinInterfaceAtomListB[proteinInterfaceAtomListIndexB]; //c++; ////////Console.WriteLine(c.ToString().PadLeft(5) + // " Chain " + chainIndexA + " (" + proteinInterfaceListA.Count(a => a.AtomIndexList.Count > 0) + " proteinInterfaces) ProteinInterface " + realProteinInterfaceIndexA + " (" + proteinInterfaceAtomListA.Count + " atoms) <--->" + // " Chain " + chainIndexB + " (" + proteinInterfaceListB.Count(a => a.AtomIndexList.Count > 0) + " proteinInterfaces) ProteinInterface " + realProteinInterfaceIndexB + " (" + proteinInterfaceAtomListB.Count + " atoms) --->" + // " chainID " + atomA.chainID.FieldValue + " resName " + atomA.resName.FieldValue + " resSeq " + atomA.resSeq.FieldValue + " <--->" + // " chainID " + atomB.chainID.FieldValue + " resName " + atomB.resName.FieldValue + " resSeq " + atomB.resSeq.FieldValue); for (int interactionIndex = 0; interactionIndex < interactionList.Count; interactionIndex++) { AtomPair interaction = interactionList[interactionIndex]; if ((interaction.Atom1 == atomA && interaction.Atom2 == atomB) || (interaction.Atom1 == atomB && interaction.Atom2 == atomA)) { interactionInsideProteinInterfaceArray[interactionIndex] = true; var interactionBetweenProteinInterfaces = new InteractionBetweenProteinInterfaces(); interactionBetweenProteinInterfacesListContainer.InteractionBetweenProteinInterfacesList.Add(interactionBetweenProteinInterfaces); interactionBetweenProteinInterfaces.Atom1.Atom = atomA; interactionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinId = proteinId; interactionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ChainId = chainIndexA; interactionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinInterfaceId = realProteinInterfaceIndexA; interactionBetweenProteinInterfaces.Atom2.Atom = atomB; interactionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinId = proteinId; interactionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ChainId = chainIndexB; interactionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinInterfaceId = realProteinInterfaceIndexB; } } } } } } } } for (int interactionIndex = 0; interactionIndex < interactionInsideProteinInterfaceArray.Length; interactionIndex++) { bool interactionInsideProteinInterface = interactionInsideProteinInterfaceArray[interactionIndex]; if (!interactionInsideProteinInterface) { var interactionBetweenNonProteinInterfaces = new InteractionBetweenProteinInterfaces(); interactionBetweenProteinInterfacesListContainer.InteractionBetweenNonProteinInterfacesList.Add(interactionBetweenNonProteinInterfaces); interactionBetweenNonProteinInterfaces.Atom1.Atom = interactionList[interactionIndex].Atom1; interactionBetweenNonProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinId = proteinId; interactionBetweenNonProteinInterfaces.Atom1.FullProteinInterfaceId.ChainId = interactionList[interactionIndex].Atom1FullProteinInterfaceId.ChainId; interactionBetweenNonProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinInterfaceId = -1; interactionBetweenNonProteinInterfaces.Atom2.Atom = interactionList[interactionIndex].Atom2; interactionBetweenNonProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinId = proteinId; interactionBetweenNonProteinInterfaces.Atom2.FullProteinInterfaceId.ChainId = interactionList[interactionIndex].Atom2FullProteinInterfaceId.ChainId; interactionBetweenNonProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinInterfaceId = -1; } } ////////Console.WriteLine("------------------ END ------------------"); // ensure sorted order interactionBetweenProteinInterfacesListContainer.InteractionBetweenProteinInterfacesList = interactionBetweenProteinInterfacesListContainer.InteractionBetweenProteinInterfacesList .OrderBy(a => a.Atom1.FullProteinInterfaceId.ChainId) .ThenBy(a => a.Atom1.FullProteinInterfaceId.ProteinInterfaceId) .ThenBy(a => ProteinDataBankFileOperations.NullableTryParseInt32(a.Atom1.Atom.resSeq.FieldValue)) .ThenBy(a => a.Atom2.FullProteinInterfaceId.ChainId) .ThenBy(a => a.Atom2.FullProteinInterfaceId.ProteinInterfaceId) .ThenBy(a => ProteinDataBankFileOperations.NullableTryParseInt32(a.Atom2.Atom.resSeq.FieldValue)) .ToList(); interactionBetweenProteinInterfacesListContainer.InteractionBetweenNonProteinInterfacesList = interactionBetweenProteinInterfacesListContainer.InteractionBetweenNonProteinInterfacesList .OrderBy(a => a.Atom1.FullProteinInterfaceId.ChainId) .ThenBy(a => a.Atom1.FullProteinInterfaceId.ProteinInterfaceId) .ThenBy(a => ProteinDataBankFileOperations.NullableTryParseInt32(a.Atom1.Atom.resSeq.FieldValue)) .ThenBy(a => a.Atom2.FullProteinInterfaceId.ChainId) .ThenBy(a => a.Atom2.FullProteinInterfaceId.ProteinInterfaceId) .ThenBy(a => ProteinDataBankFileOperations.NullableTryParseInt32(a.Atom2.Atom.resSeq.FieldValue)) .ToList(); // remove duplicates (as the list is sorted, duplicates will always be together in the list) for (int index = interactionBetweenProteinInterfacesListContainer.InteractionBetweenProteinInterfacesList.Count - 1; index > 0; index--) { InteractionBetweenProteinInterfaces lastInteractionBetweenProteinInterfaces = interactionBetweenProteinInterfacesListContainer.InteractionBetweenProteinInterfacesList[index - 1]; InteractionBetweenProteinInterfaces thisInteractionBetweenProteinInterfaces = interactionBetweenProteinInterfacesListContainer.InteractionBetweenProteinInterfacesList[index]; if (lastInteractionBetweenProteinInterfaces == null || thisInteractionBetweenProteinInterfaces == null) { continue; } if (thisInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinId == lastInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinId && thisInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ChainId == lastInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ChainId && thisInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinInterfaceId == lastInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinInterfaceId && thisInteractionBetweenProteinInterfaces.Atom1.Atom == lastInteractionBetweenProteinInterfaces.Atom1.Atom && thisInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinId == lastInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinId && thisInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ChainId == lastInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ChainId && thisInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinInterfaceId == lastInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinInterfaceId && thisInteractionBetweenProteinInterfaces.Atom2.Atom == lastInteractionBetweenProteinInterfaces.Atom2.Atom) { interactionBetweenProteinInterfacesListContainer.InteractionBetweenProteinInterfacesList.RemoveAt(index - 1); //////Console.WriteLine("removed duplicate"); } } for (int index = interactionBetweenProteinInterfacesListContainer.InteractionBetweenNonProteinInterfacesList.Count - 1; index > 0; index--) { InteractionBetweenProteinInterfaces lastInteractionBetweenProteinInterfaces = interactionBetweenProteinInterfacesListContainer.InteractionBetweenNonProteinInterfacesList[index - 1]; InteractionBetweenProteinInterfaces thisInteractionBetweenProteinInterfaces = interactionBetweenProteinInterfacesListContainer.InteractionBetweenNonProteinInterfacesList[index]; if (lastInteractionBetweenProteinInterfaces == null || thisInteractionBetweenProteinInterfaces == null) { continue; } if (thisInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinId == lastInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinId && thisInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ChainId == lastInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ChainId && thisInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinInterfaceId == lastInteractionBetweenProteinInterfaces.Atom1.FullProteinInterfaceId.ProteinInterfaceId && thisInteractionBetweenProteinInterfaces.Atom1.Atom == lastInteractionBetweenProteinInterfaces.Atom1.Atom && thisInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinId == lastInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinId && thisInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ChainId == lastInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ChainId && thisInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinInterfaceId == lastInteractionBetweenProteinInterfaces.Atom2.FullProteinInterfaceId.ProteinInterfaceId && thisInteractionBetweenProteinInterfaces.Atom2.Atom == lastInteractionBetweenProteinInterfaces.Atom2.Atom) { interactionBetweenProteinInterfacesListContainer.InteractionBetweenNonProteinInterfacesList.RemoveAt(index - 1); //////Console.WriteLine("removed duplicate"); } } return interactionBetweenProteinInterfacesListContainer; }
/// <summary> /// Load proteinInterface data from the PDB file based on a list of already detected proteinInterfaces. /// The detected proteinInterfaces may be missing data such as other atoms or residues which are also in the proteinInterface but were not /// directly interacting. /// The positions and lengths of the proteinInterfaces are also calculated. /// </summary> /// <param name="pdbFilename"></param> /// <param name="pdbFileChains"></param> /// <param name="singularAaToAaInteractions"></param> /// <param name="proteinInterfacesClusteringResult"></param> /// <param name="detectedBestStages"></param> /// <param name="interactionBetweenProteinInterfacesContainer"></param> /// <returns></returns> public static List <ProteinInterfaceSequenceAndPositionData> AnalyseProteinInterfacesSequenceAndPositionData( string pdbFilename, Dictionary <string, List <string> > pdbIdChainIdList, ProteinChainListContainer pdbFileChains, ProteinChainListContainer singularAaToAaInteractions, ClusteringFullResultListContainer proteinInterfacesClusteringResult, int[] detectedBestStages, InteractionBetweenProteinInterfacesListContainer interactionBetweenProteinInterfacesContainer) { if (string.IsNullOrWhiteSpace(pdbFilename)) { throw new ArgumentOutOfRangeException(nameof(pdbFilename)); } if (!File.Exists(pdbFilename)) { throw new FileNotFoundException("File not found", pdbFilename); } if (ParameterValidation.IsProteinChainListContainerNullOrEmpty(singularAaToAaInteractions)) { throw new ArgumentOutOfRangeException(nameof(singularAaToAaInteractions)); } if (ParameterValidation.IsClusteringFullResultListContainerNullOrEmpty(proteinInterfacesClusteringResult)) { throw new ArgumentOutOfRangeException(nameof(proteinInterfacesClusteringResult)); } if (ParameterValidation.IsIntArrayNullOrEmpty(detectedBestStages)) { throw new ArgumentOutOfRangeException(nameof(detectedBestStages)); } // ProteinInterfaces are clusters with non-proteinInterfaces removed. var result = new List <ProteinInterfaceSequenceAndPositionData>(); string proteinId = ProteinDataBankFileOperations.PdbIdFromPdbFilename(pdbFilename); int totalChains = proteinInterfacesClusteringResult.ChainList.Count; for (int chainIndex = 0; chainIndex < totalChains; chainIndex++) { int stageIndex = detectedBestStages[chainIndex]; string chainIdLetter = SpreadsheetFileHandler.AlphabetLetterRollOver(chainIndex); List <ClusteringFullResultListContainer.Chain.Stage.Cluster> proteinInterfaceList = proteinInterfacesClusteringResult.ChainList[chainIndex].StageList[stageIndex].ClusterList; List <ClusteringFullResultListContainer.Chain.Stage.Cluster> nonEmptyProteinInterfaceList = proteinInterfaceList.Where(a => a != null && a.AtomIndexList != null && a.AtomIndexList.Count > 0).ToList(); // loop through each proteinInterface for (int proteinInterfaceIndex = 0; proteinInterfaceIndex < nonEmptyProteinInterfaceList.Count; proteinInterfaceIndex++) { ClusteringFullResultListContainer.Chain.Stage.Cluster proteinInterface = nonEmptyProteinInterfaceList[proteinInterfaceIndex]; // Find min and max residue sequence index value in the proteinInterface MinMax proteinInterfaceResidueSequenceIndexes = MinMaxResidueSequenceIndex(proteinInterface, singularAaToAaInteractions, chainIndex); int proteinInterfaceLength = CalculateProteinInterfaceLength(proteinInterfaceResidueSequenceIndexes.Min, proteinInterfaceResidueSequenceIndexes.Max); string proteinInterfaceIdLetter = SpreadsheetFileHandler.AlphabetLetterRollOver(proteinInterfaceIndex); var proteinInterfacePositionData = new ProteinInterfaceSequenceAndPositionData { FullProteinInterfaceId = new FullProteinInterfaceId(proteinId, chainIndex, proteinInterfaceIndex, proteinInterfaceResidueSequenceIndexes.Min, proteinInterfaceResidueSequenceIndexes.Max), ChainIdLetter = chainIdLetter, ProteinInterfaceIdLetter = proteinInterfaceIdLetter, StartPosition = proteinInterfaceResidueSequenceIndexes.Min, EndPosition = proteinInterfaceResidueSequenceIndexes.Max, ProteinInterfaceLength = CalculateProteinInterfaceLength(proteinInterfaceResidueSequenceIndexes.Min, proteinInterfaceResidueSequenceIndexes.Max) }; proteinInterfacePositionData.AminoAcidSequenceAllResidueSequenceIndexes = new ProteinInterfaceAminoAcidMetaData[proteinInterfacePositionData.ProteinInterfaceLength]; proteinInterfacePositionData.AminoAcidSequenceAll1L = ""; proteinInterfacePositionData.AminoAcidSequenceInteractionsAll1L = ""; proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly1L = ""; proteinInterfacePositionData.AminoAcidSequenceInteractionsNone1L = ""; proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly1L = ""; proteinInterfacePositionData.AminoAcidSequenceAll3L = ""; proteinInterfacePositionData.AminoAcidSequenceInteractionsAll3L = ""; proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly3L = ""; proteinInterfacePositionData.AminoAcidSequenceInteractionsNone3L = ""; proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly3L = ""; //int foundAtomCount = 0; const string placeholder1L = "_"; const string placeholder3L = "___"; for (int residueSequenceIndex = proteinInterfaceResidueSequenceIndexes.Min; residueSequenceIndex <= proteinInterfaceResidueSequenceIndexes.Max; residueSequenceIndex++) { /* questions * 1. does this reside interact with another reside which is also part of a proteinInterface? * 2. if not, does this reside interact at all? */ var proteinInterfaceAminoAcidMetaData = new ProteinInterfaceAminoAcidMetaData(); proteinInterfacePositionData.AminoAcidSequenceAllResidueSequenceIndexes[proteinInterfacePositionData.AminoAcidSequenceAll1L.Length] = proteinInterfaceAminoAcidMetaData; ATOM_Record foundAtomInsidePdbFile = AtomSearchMethods.FindAtomInsidePdbFileChain(pdbFileChains, chainIndex, residueSequenceIndex); if (foundAtomInsidePdbFile == null) { // Non-CA atom is loaded here in case of missing CA atom to find the AA code for the resSeq index var chainIdList = pdbIdChainIdList != null ? (pdbIdChainIdList.ContainsKey(proteinId) ? pdbIdChainIdList[proteinId].ToArray() : null) : null; ProteinChainListContainer pdbFileChains2 = ProteinDataBankFileOperations.PdbAtomicChains(pdbFilename, chainIdList, -1, -1, false); foundAtomInsidePdbFile = AtomSearchMethods.FindAtomInsidePdbFileChain(pdbFileChains2, chainIndex, residueSequenceIndex); } proteinInterfaceAminoAcidMetaData.PdbResidueSequenceIndex = residueSequenceIndex; proteinInterfaceAminoAcidMetaData.ArrayMemberIndex = pdbFileChains.ChainList[chainIndex].AtomList.IndexOf(foundAtomInsidePdbFile); proteinInterfaceAminoAcidMetaData.OppoproteinInterfaceInteractions = new bool[proteinInterfaceLength]; if (foundAtomInsidePdbFile != null) { proteinInterfacePositionData.AminoAcidSequenceAll1L += AminoAcidConversions.AminoAcidNameToCode1L(foundAtomInsidePdbFile.resName.FieldValue); proteinInterfacePositionData.AminoAcidSequenceAll3L += foundAtomInsidePdbFile.resName.FieldValue.PadRight(3, '_'); } else { proteinInterfacePositionData.AminoAcidSequenceAll1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsAll1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsNone1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceAll3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsAll3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsNone3L += placeholder3L; proteinInterfaceAminoAcidMetaData.ProteinInterfaceInteractionType = ProteinInterfaceInteractionType.NoInteractionFound; proteinInterfaceAminoAcidMetaData.NonProteinInterfaceInteractionResidueNames1L += placeholder1L; proteinInterfaceAminoAcidMetaData.NonProteinInterfaceInteractionResidueNames3L += placeholder3L; continue; } List <ATOM_Record> foundAtomInteractingWithAnotherProteinInterface = AtomSearchMethods.FindAtomInteractingWithOtherProteinInterfaces(foundAtomInsidePdbFile, interactionBetweenProteinInterfacesContainer, FindAtomInteractingWithAnotherProteinInterfaceOptions.FindAtomsInteractingWithOtherProteinInterfaces); List <ATOM_Record> foundAtomInteractingWithNonProteinInterface = AtomSearchMethods.FindAtomInteractingWithOtherProteinInterfaces(foundAtomInsidePdbFile, interactionBetweenProteinInterfacesContainer, FindAtomInteractingWithAnotherProteinInterfaceOptions.FindAtomsInteractingWithNonProteinInterfaces); proteinInterfaceAminoAcidMetaData.OppoproteinInterfaceInteractions = AminoAcidInteractionVector(singularAaToAaInteractions, proteinInterfacesClusteringResult, detectedBestStages, interactionBetweenProteinInterfacesContainer, chainIndex, proteinInterfaceIndex, residueSequenceIndex); proteinInterfaceAminoAcidMetaData.ResidueName1L = AminoAcidConversions.AminoAcidNameToCode1L(foundAtomInsidePdbFile.resName.FieldValue); proteinInterfaceAminoAcidMetaData.ResidueName3L = foundAtomInsidePdbFile.resName.FieldValue.PadRight(3, '_'); if (foundAtomInteractingWithAnotherProteinInterface != null) { foreach (ATOM_Record atom in foundAtomInteractingWithAnotherProteinInterface) { proteinInterfaceAminoAcidMetaData.ProteinInterfaceInteractionResidueNames1L += AminoAcidConversions.AminoAcidNameToCode1L(atom.resName.FieldValue); proteinInterfaceAminoAcidMetaData.ProteinInterfaceInteractionResidueNames3L += atom.resName.FieldValue.PadRight(3, '_'); } } if (foundAtomInteractingWithNonProteinInterface != null) { foreach (ATOM_Record atom in foundAtomInteractingWithNonProteinInterface) { proteinInterfaceAminoAcidMetaData.NonProteinInterfaceInteractionResidueNames1L += AminoAcidConversions.AminoAcidNameToCode1L(atom.resName.FieldValue); proteinInterfaceAminoAcidMetaData.NonProteinInterfaceInteractionResidueNames3L += atom.resName.FieldValue.PadRight(3, '_'); } } if (foundAtomInteractingWithAnotherProteinInterface != null && foundAtomInteractingWithAnotherProteinInterface.Count > 0) { proteinInterfacePositionData.AminoAcidSequenceInteractionsAll1L += AminoAcidConversions.AminoAcidNameToCode1L(foundAtomInsidePdbFile.resName.FieldValue); proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly1L += AminoAcidConversions.AminoAcidNameToCode1L(foundAtomInsidePdbFile.resName.FieldValue); proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsNone1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsAll3L += foundAtomInsidePdbFile.resName.FieldValue.PadRight(3, '_'); proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly3L += foundAtomInsidePdbFile.resName.FieldValue.PadRight(3, '_'); proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsNone3L += placeholder3L; proteinInterfaceAminoAcidMetaData.ProteinInterfaceInteractionType = ProteinInterfaceInteractionType.InteractionWithAnotherProteinInterface; if (foundAtomInteractingWithNonProteinInterface != null && foundAtomInteractingWithNonProteinInterface.Count > 0) { proteinInterfaceAminoAcidMetaData.ProteinInterfaceInteractionType |= ProteinInterfaceInteractionType.InteractionWithNonProteinInterface; } } else if (foundAtomInteractingWithNonProteinInterface != null && foundAtomInteractingWithNonProteinInterface.Count > 0) { proteinInterfacePositionData.AminoAcidSequenceInteractionsAll1L += AminoAcidConversions.AminoAcidNameToCode1L(foundAtomInsidePdbFile.resName.FieldValue); proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly1L += AminoAcidConversions.AminoAcidNameToCode1L(foundAtomInsidePdbFile.resName.FieldValue); proteinInterfacePositionData.AminoAcidSequenceInteractionsNone1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsAll3L += foundAtomInsidePdbFile.resName.FieldValue.PadRight(3, '_'); proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly3L += foundAtomInsidePdbFile.resName.FieldValue.PadRight(3, '_'); proteinInterfacePositionData.AminoAcidSequenceInteractionsNone3L += placeholder3L; proteinInterfaceAminoAcidMetaData.ProteinInterfaceInteractionType = ProteinInterfaceInteractionType.InteractionWithNonProteinInterface; } else { proteinInterfacePositionData.AminoAcidSequenceInteractionsAll1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly1L += placeholder1L; proteinInterfacePositionData.AminoAcidSequenceInteractionsNone1L += AminoAcidConversions.AminoAcidNameToCode1L(foundAtomInsidePdbFile.resName.FieldValue); proteinInterfacePositionData.AminoAcidSequenceInteractionsAll3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsInsideProteinInterfacesOnly3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsOutsideProteinInterfacesOnly3L += placeholder3L; proteinInterfacePositionData.AminoAcidSequenceInteractionsNone3L += foundAtomInsidePdbFile.resName.FieldValue.PadRight(3, '_'); proteinInterfaceAminoAcidMetaData.ProteinInterfaceInteractionType = ProteinInterfaceInteractionType.NoInteractionFound; } } result.Add(proteinInterfacePositionData); } } return(result); }
public static List <ATOM_Record> FindAtomInteractingWithOtherProteinInterfaces(ATOM_Record atom, InteractionBetweenProteinInterfacesListContainer interactionBetweenProteinInterfacesContainer, FindAtomInteractingWithAnotherProteinInterfaceOptions findAtomInteractingWithAnotherProteinInterfaceOptions) { if (ParameterValidation.IsAtomNullOrEmpty(atom)) { throw new ArgumentNullException(nameof(atom)); } if (ParameterValidation.IsInteractionBetweenProteinInterfacesListContainerNullOrEmpty(interactionBetweenProteinInterfacesContainer)) { ////////Console.WriteLine("empty"); return(null); } List <InteractionBetweenProteinInterfaces> searchList = null; if (findAtomInteractingWithAnotherProteinInterfaceOptions == FindAtomInteractingWithAnotherProteinInterfaceOptions.FindAtomsInteractingWithOtherProteinInterfaces) { searchList = interactionBetweenProteinInterfacesContainer.InteractionBetweenProteinInterfacesList; } else if (findAtomInteractingWithAnotherProteinInterfaceOptions == FindAtomInteractingWithAnotherProteinInterfaceOptions.FindAtomsInteractingWithNonProteinInterfaces) { searchList = interactionBetweenProteinInterfacesContainer.InteractionBetweenNonProteinInterfacesList; } else { throw new NotImplementedException(); } if (searchList == null) { ////////Console.WriteLine("returning null"); return(null); } var result = new List <ATOM_Record>(); foreach (InteractionBetweenProteinInterfaces interaction in searchList) { if (interaction.Atom1.Atom == atom && interaction.Atom2.Atom != atom) { //return interaction.Atom1.Atom; result.Add(interaction.Atom2.Atom); } if (interaction.Atom1.Atom != atom && interaction.Atom2.Atom == atom) { //return interaction.Atom2.Atom; result.Add(interaction.Atom1.Atom); } } //if (result.Count == 0) //{ // //////Console.WriteLine("returning empty list"); //} return(result); }
/// <summary> /// Returns a PDB record class instance of the appropriate type for the given line of PDB file. /// </summary> /// <param name="columnFormatLine"></param> /// <returns></returns> public ProteinDataBankFileRecord ProteinDataBaseFileLineRecord(string columnFormatLine) { ProteinDataBankFileRecord result = null; string recordType = ProteinDataBankFileLineRecordType(columnFormatLine); if ((TargetRecordTypes != null) && (TargetRecordTypes.Length > 0) && (!TargetRecordTypes.Contains(recordType))) { return(result); } switch (recordType) { case "HEADER": result = new HEADER_Record(columnFormatLine); break; case "OBSLTE": result = new OBSLTE_Record(columnFormatLine); break; case "TITLE": result = new TITLE_Record(columnFormatLine); break; case "SPLIT": result = new SPLIT_Record(columnFormatLine); break; case "CAVEAT": result = new CAVEAT_Record(columnFormatLine); break; case "COMPND": result = new COMPND_Record(columnFormatLine); break; case "SOURCE": result = new SOURCE_Record(columnFormatLine); break; case "KEYWDS": result = new KEYWDS_Record(columnFormatLine); break; case "EXPDTA": result = new EXPDTA_Record(columnFormatLine); break; case "NUMMDL": result = new NUMMDL_Record(columnFormatLine); break; case "MDLTYP": result = new MDLTYP_Record(columnFormatLine); break; case "AUTHOR": result = new AUTHOR_Record(columnFormatLine); break; case "REVDAT": result = new REVDAT_Record(columnFormatLine); break; case "SPRSDE": result = new SPRSDE_Record(columnFormatLine); break; case "JRNL": result = new JRNL_DOI_Record(columnFormatLine); if (((JRNL_DOI_Record)result).DOI.FieldValue == JRNL_DOI_Record.DOI_Field.FieldName) { break; } result = new JRNL_PMID_Record(columnFormatLine); if (((JRNL_PMID_Record)result).PMID.FieldValue == JRNL_PMID_Record.PMID_Field.FieldName) { break; } result = new JRNL_PUBL_Record(columnFormatLine); if (((JRNL_PUBL_Record)result).PUBL.FieldValue == JRNL_PUBL_Record.PUBL_Field.FieldName) { break; } result = new JRNL_REFN_ISSN_or_ESSN_Record(columnFormatLine); if (((JRNL_REFN_ISSN_or_ESSN_Record)result).REFN.FieldValue == JRNL_REFN_ISSN_or_ESSN_Record.REFN_Field.FieldName && (((JRNL_REFN_ISSN_or_ESSN_Record)result).ISSN_or_ESSN.FieldValue.ToUpperInvariant() == "ISSN" || ((JRNL_REFN_ISSN_or_ESSN_Record)result).ISSN_or_ESSN.FieldValue.ToUpperInvariant() == "ESSN")) { break; } result = new JRNL_REF_V_Record(columnFormatLine); if (((JRNL_REF_V_Record)result).REF.FieldValue == JRNL_REF_V_Record.REF_Field.FieldName && ((JRNL_REF_V_Record)result).V_.FieldValue == JRNL_REF_V_Record.V_Field.FieldName) { break; } result = new JRNL_REFN_Record(columnFormatLine); if (((JRNL_REFN_Record)result).REFN.FieldValue == JRNL_REFN_Record.REFN_Field.FieldName) { break; } result = new JRNL_REF_TOBEPUBLISHED_Record(columnFormatLine); if (((JRNL_REF_TOBEPUBLISHED_Record)result).REF.FieldValue == JRNL_REF_TOBEPUBLISHED_Record.REF_Field.FieldName) { break; } result = new JRNL_Record(columnFormatLine); break; case "REMARK": result = new REMARK_1_AUTH_Record(columnFormatLine); if (((REMARK_1_AUTH_Record)result)._1.FieldValue == REMARK_1_AUTH_Record._1_Field.FieldName && ((REMARK_1_AUTH_Record)result).AUTH.FieldValue == REMARK_1_AUTH_Record.AUTH_Field.FieldName) { break; } result = new REMARK_1_PUBL_Record(columnFormatLine); if (((REMARK_1_PUBL_Record)result)._1.FieldValue == REMARK_1_PUBL_Record._1_Field.FieldName && ((REMARK_1_PUBL_Record)result).PUBL.FieldValue == REMARK_1_PUBL_Record.PUBL_Field.FieldName) { break; } result = new REMARK_1_REF_V_Record(columnFormatLine); if (((REMARK_1_REF_V_Record)result)._1.FieldValue == REMARK_1_REF_V_Record._1_Field.FieldName && ((REMARK_1_REF_V_Record)result).REF.FieldValue == REMARK_1_REF_V_Record.REF_Field.FieldName && ((REMARK_1_REF_V_Record)result).V_.FieldValue == REMARK_1_REF_V_Record.V_Field.FieldName) { break; } result = new REMARK_1_REFERENCE_Record(columnFormatLine); if (((REMARK_1_REFERENCE_Record)result)._1.FieldValue == REMARK_1_REFERENCE_Record._1_Field.FieldName && ((REMARK_1_REFERENCE_Record)result).REFERENCE.FieldValue == REMARK_1_REFERENCE_Record.REFERENCE_Field.FieldName) { break; } result = new REMARK_1_REFN_ISSN_or_ESSN_Record(columnFormatLine); if (((REMARK_1_REFN_ISSN_or_ESSN_Record)result)._1.FieldValue == REMARK_1_REFN_ISSN_or_ESSN_Record._1_Field.FieldName && ((REMARK_1_REFN_ISSN_or_ESSN_Record)result).REFN.FieldValue == REMARK_1_REFN_ISSN_or_ESSN_Record.REFN_Field.FieldName && (((REMARK_1_REFN_ISSN_or_ESSN_Record)result).ISSN_or_ESSN.FieldValue == "ISSN" || ((REMARK_1_REFN_ISSN_or_ESSN_Record)result).ISSN_or_ESSN.FieldValue == "ESSN")) { break; } result = new REMARK_1_REFN_Record(columnFormatLine); if (((REMARK_1_REFN_Record)result)._1.FieldValue == REMARK_1_REFN_Record._1_Field.FieldName && ((REMARK_1_REFN_Record)result).REFN.FieldValue == REMARK_1_REFN_Record.REFN_Field.FieldName) { break; } result = new REMARK_1_TITL_Record(columnFormatLine); if (((REMARK_1_TITL_Record)result)._1.FieldValue == REMARK_1_TITL_Record._1_Field.FieldName && ((REMARK_1_TITL_Record)result).TITL.FieldValue == REMARK_1_TITL_Record.TITL_Field.FieldName) { break; } result = new REMARK_2_RESOLUTION_ANGSTROMS_Record(columnFormatLine); if (((REMARK_2_RESOLUTION_ANGSTROMS_Record)result)._2.FieldValue == REMARK_2_RESOLUTION_ANGSTROMS_Record._2_Field.FieldName && ((REMARK_2_RESOLUTION_ANGSTROMS_Record)result).RESOLUTION_.FieldValue == REMARK_2_RESOLUTION_ANGSTROMS_Record.RESOLUTION_Field.FieldName && ((REMARK_2_RESOLUTION_ANGSTROMS_Record)result).ANGSTROMS_.FieldValue == REMARK_2_RESOLUTION_ANGSTROMS_Record.ANGSTROMS_Field.FieldName) { break; } result = new REMARK_2_RESOLUTION_NOTAPPLICABLE_Record(columnFormatLine); if (((REMARK_2_RESOLUTION_NOTAPPLICABLE_Record)result)._2.FieldValue == REMARK_2_RESOLUTION_NOTAPPLICABLE_Record._2_Field.FieldName && ((REMARK_2_RESOLUTION_NOTAPPLICABLE_Record)result).RESOLUTION_NOT_APPLICABLE_.FieldValue == REMARK_2_RESOLUTION_NOTAPPLICABLE_Record.RESOLUTION_NOT_APPLICABLE_Field.FieldName) { break; } result = new REMARK_1_REF_TOBEPUBLISHED_Record(columnFormatLine); if (((REMARK_1_REF_TOBEPUBLISHED_Record)result)._1.FieldValue == REMARK_1_REF_TOBEPUBLISHED_Record._1_Field.FieldName && ((REMARK_1_REF_TOBEPUBLISHED_Record)result).REF.FieldValue == REMARK_1_REF_TOBEPUBLISHED_Record.REF_Field.FieldName && ((REMARK_1_REF_TOBEPUBLISHED_Record)result).TO_BE_PUBLISHED.FieldValue == REMARK_1_REF_TOBEPUBLISHED_Record.TO_BE_PUBLISHED_Field.FieldName) { break; } result = new REMARK_Record(columnFormatLine); break; case "DBREF": result = new DBREF_Record(columnFormatLine); break; case "DBREF1": result = new DBREF1_Record(columnFormatLine); break; case "DBREF2": result = new DBREF2_Record(columnFormatLine); break; case "SEQADV": result = new SEQADV_Record(columnFormatLine); break; case "SEQRES": result = new SEQRES_Record(columnFormatLine); break; case "MODRES": result = new MODRES_Record(columnFormatLine); break; case "HET": result = new HET_Record(columnFormatLine); break; case "HETNAM": result = new HETNAM_Record(columnFormatLine); break; case "HETSYN": result = new HETSYN_Record(columnFormatLine); break; case "FORMUL": result = new FORMUL_Record(columnFormatLine); break; case "HELIX": result = new HELIX_Record(columnFormatLine); break; case "SHEET": result = new SHEET_Record(columnFormatLine); break; case "SSBOND": result = new SSBOND_CYS_CYS_Record(columnFormatLine); break; case "LINK": result = new LINK_Record(columnFormatLine); break; case "CISPEP": result = new CISPEP_Record(columnFormatLine); break; case "SITE": result = new SITE_Record(columnFormatLine); break; case "CRYST1": result = new CRYST1_Record(columnFormatLine); break; case "ORIGX1": result = new ORIGX1_Record(columnFormatLine); break; case "ORIGX2": result = new ORIGX2_Record(columnFormatLine); break; case "ORIGX3": result = new ORIGX3_Record(columnFormatLine); break; case "SCALE1": result = new SCALE1_Record(columnFormatLine); break; case "SCALE2": result = new SCALE2_Record(columnFormatLine); break; case "SCALE3": result = new SCALE3_Record(columnFormatLine); break; case "MTRIX1": result = new MTRIX1_Record(columnFormatLine); break; case "MTRIX2": result = new MTRIX2_Record(columnFormatLine); break; case "MTRIX3": result = new MTRIX3_Record(columnFormatLine); break; case "MODEL": result = new MODEL_Record(columnFormatLine); break; case "ATOM": result = new ATOM_Record(columnFormatLine); break; case "ANISOU": result = new ANISOU_Record(columnFormatLine); break; case "TER": result = new TER_Record(columnFormatLine); break; case "HETATM": result = new HETATM_Record(columnFormatLine); break; case "ENDMDL": result = new ENDMDL_Record(columnFormatLine); break; case "CONECT": result = new CONECT_Record(columnFormatLine); break; case "MASTER": result = new MASTER_0_Record(columnFormatLine); break; case "END": result = new END_Record(columnFormatLine); break; } return(result); }
public static ATOM_Record ConvertHetatmRecordToAtomRecord(HETATM_Record hetatm) { var atom = new ATOM_Record("ATOM " + hetatm.ColumnFormatLine.Substring(6)); return(atom); }