public void WriteProteinFragment(ref AtomParser.AtomCategory _atomCat, int _fragStart, int _fragEnd, int _chainIndex, string _chainID, string _fileWithPath) { // this is complicated because the indices refer to alpha-carbon-only, while this function writes // whole thing AtomParser.ChainAtoms theChainAtoms = new ChainAtoms(); AtomParser.ChainAtoms onlyCAChainAtoms = new ChainAtoms(); theChainAtoms = _atomCat.ChainAtomList[_chainIndex]; onlyCAChainAtoms = _atomCat.CalphaAtomList()[_chainIndex]; string firstCAauthSeqID = onlyCAChainAtoms.CartnAtoms[_fragStart].authSeqId; string lastCAauthSeqID = onlyCAChainAtoms.CartnAtoms[_fragEnd].authSeqId; StreamWriter protWriter = new StreamWriter(_fileWithPath, false); int atomCounter = new int(); atomCounter = 1; bool writingInFragment = new bool(); bool hitLastCA = new bool(); writingInFragment = false; hitLastCA = false; for (int atomIndex = 0; atomIndex < theChainAtoms.CartnAtoms.Length; atomIndex++) { if (theChainAtoms.CartnAtoms[atomIndex].authSeqId == firstCAauthSeqID) { writingInFragment = true; } if (writingInFragment) { if (!hitLastCA) { if (theChainAtoms.CartnAtoms[atomIndex].authSeqId == lastCAauthSeqID) { hitLastCA = true; } } else { if (theChainAtoms.CartnAtoms[atomIndex].authSeqId != lastCAauthSeqID) // hit the residue after the last residue in fragment { break; } } protWriter.WriteLine(WriteSingleLine(theChainAtoms.CartnAtoms[atomIndex], atomCounter, _chainID)); } } protWriter.Close(); return; }
public void WriteWholeProtein(ref AtomParser.AtomCategory _atomCat, string _fileWithPath) { StreamWriter protWriter = new StreamWriter(_fileWithPath, false); foreach (AtomParser.ChainAtoms thisChainAtoms in _atomCat.ChainAtomList) { for (int atomIndex = 0; atomIndex < thisChainAtoms.CartnAtoms.Length; atomIndex++) { protWriter.WriteLine(WriteSingleLine(thisChainAtoms.CartnAtoms[atomIndex], (atomIndex + 1), thisChainAtoms.AsymChain)); } } protWriter.Close(); return; }
public void WriteCAOnlyFragment(ref AtomParser.AtomCategory _atomCat, int _fragStart, int _fragEnd, int _chainIndex, string _chainID, string _fileWithPath) { AtomParser.ChainAtoms theChainAtoms = new ChainAtoms(); theChainAtoms = (_atomCat.CalphaAtomList())[_chainIndex]; StreamWriter protWriter = new StreamWriter(_fileWithPath, false); int atomCounter = new int(); atomCounter = 1; for (int atomIndex = _fragStart; atomIndex < _fragEnd; atomIndex++) { protWriter.WriteLine(WriteSingleLine(theChainAtoms.CartnAtoms[atomIndex], atomCounter, _chainID)); } protWriter.Close(); return; }
public Chain(ref AtomParser.AtomCategory _myAtomCat, int chainNum, string pdbName, bool mono_status, string dssp_dir) { this.ChainName = _myAtomCat.ChainAtomList[chainNum].AuthAsymChain; this.ChainNum = chainNum; this.ResidueCount = 0; this.PdbName = pdbName.ToUpper(); int mySeqID = -1; this.MonovsPoly = mono_status; int startRes = -15; //Changed from 0 on 11-15-17: This causes horrible problems for PDBs that start at neg values of res nums if (this.PdbName.Contains("7AHL") || this.PdbName.Contains("3W9T")) { startRes = 100; //These lines also explain why these can fail to build loops in Rosetta. } //if (this.PdbName.Contains("3O44")) startRes = 200; if (this.PdbName.Contains("3O44")) { startRes = 130; } for (int atomCtr = 0; atomCtr < _myAtomCat.ChainAtomList[chainNum].cartnAtoms.Count; atomCtr++)//_myAtomCat.ChainAtomList[chainNum].cartnAtoms.Count includes ALL atoms in chain { if (Convert.ToInt32(_myAtomCat.ChainAtomList[chainNum].CartnAtoms[atomCtr].authSeqId) < startRes) { continue; } if (Convert.ToInt32(_myAtomCat.ChainAtomList[chainNum].CartnAtoms[atomCtr].authSeqId) > 350 && this.PdbName.Contains("3O44")) { break; } if (mySeqID == Convert.ToInt32(_myAtomCat.ChainAtomList[chainNum].CartnAtoms[atomCtr].seqId)) { continue; //if the residue has already been added, keep going } else { mySeqID = Convert.ToInt32(_myAtomCat.ChainAtomList[chainNum].CartnAtoms[atomCtr].seqId);//the first new atom in residue is "atomCtr" Res myRes = new Res(ref _myAtomCat, chainNum, ResidueCount, atomCtr); this.ResidueCount++; this.Residues.Add(myRes); //Console.Write(".");//loading screen :) } } //Console.WriteLine(this.ResidueCount); //set residue Direction for (int residueCtr = 0; residueCtr < ResidueCount - 1; residueCtr++) { Vector3D myDirection = new Vector3D(); if (Residues[residueCtr].BackboneCoords.Count == 4 && Residues[residueCtr + 1].BackboneCoords.Count == 4) { myDirection = Residues[residueCtr].BackboneCoords["CA"] - Residues[residueCtr + 1].BackboneCoords["CA"]; Residues[residueCtr].Direction = myDirection; } else { } //Console.WriteLine("cannot calc direction for res {0}", Residues[residueCtr].SeqID); } //Set rel b-factors - added 6/2/17 for loops double largest_bfac = 0; foreach (Res Res1 in Residues) { if (Res1.BFacCA > largest_bfac) { largest_bfac = Res1.BFacCA; } } foreach (Res Res1 in Residues) { Res1.RelBFac = Res1.BFacCA / largest_bfac; } Dictionary <int, string> DSSP_values = new Dictionary <int, string>(); DSSP_values = getDSSP(this.PdbName, dssp_dir, this.ChainName); foreach (Res Res1 in Residues) { try { Res1.DSSP = DSSP_values[Res1.SeqID]; } catch (KeyNotFoundException) { Res1.DSSP = "*"; } } //set residue PhiPsiOmega for (int residueCtr = 0; residueCtr < ResidueCount; residueCtr++) { ////set e1 for each O //Vector3D e1 = new Vector3D(); //e1 = Residues[residueCtr].BackboneCoords["C"] - Residues[residueCtr].BackboneCoords["CA"]; //e1.Normalize(); //for (int atomCtr2 = 0; atomCtr2 < Residues[residueCtr].Atoms.Count; atomCtr2++) //{ // if (Residues[residueCtr].Atoms[atomCtr2].AtomName == "O") Residues[residueCtr].Atoms[atomCtr2].e1 = e1; //} if (residueCtr != 0) { if (Residues[residueCtr - 1].BackboneCoords.Count == 4 && Residues[residueCtr].BackboneCoords.Count == 4) { Residues[residueCtr].Omega = SharedFunctions.CalculateTorsion(Residues[residueCtr - 1].BackboneCoords["CA"], Residues[residueCtr - 1].BackboneCoords["C"], Residues[residueCtr].BackboneCoords["N"], Residues[residueCtr].BackboneCoords["CA"]); Residues[residueCtr].Phi = SharedFunctions.CalculateTorsion(Residues[residueCtr - 1].BackboneCoords["C"], Residues[residueCtr].BackboneCoords["N"], Residues[residueCtr].BackboneCoords["CA"], Residues[residueCtr].BackboneCoords["C"]); } for (int atomCtr = 0; atomCtr < Residues[residueCtr].Atoms.Count; atomCtr++) { if (Residues[residueCtr].Atoms[atomCtr].AtomName == "N" && Residues[residueCtr].ThreeLetCode != "PRO" && Residues[residueCtr - 1].BackboneCoords.Count == 4) {// get H coords for NH - exact opposite direction as the previous res' C-O vector Vector3D COvec = new Vector3D(); COvec = Residues[residueCtr - 1].BackboneCoords["C"] - Residues[residueCtr - 1].BackboneCoords["O"]; COvec.Normalize(); COvec = COvec * .9; COvec += Residues[residueCtr].Atoms[atomCtr].Coords; Residues[residueCtr].Atoms[atomCtr].Hydrogen = COvec; } //get e2 vector for carbonyl try { Vector3D e2 = new Vector3D(); e2 = Residues[residueCtr - 1].BackboneCoords["C"] - Residues[residueCtr].BackboneCoords["N"]; e2.Normalize(); for (int atomCtr2 = 0; atomCtr2 < Residues[residueCtr - 1].Atoms.Count; atomCtr2++) { if (Residues[residueCtr - 1].Atoms[atomCtr2].AtomName == "O") { Residues[residueCtr - 1].Atoms[atomCtr2].e2 = e2; } } } catch (KeyNotFoundException) { continue; } } } if (residueCtr != ResidueCount - 1) { if (Residues[residueCtr + 1].BackboneCoords.Count == 4 && Residues[residueCtr].BackboneCoords.Count == 4) { Residues[residueCtr].Psi = SharedFunctions.CalculateTorsion(Residues[residueCtr].BackboneCoords["N"], Residues[residueCtr].BackboneCoords["CA"], Residues[residueCtr].BackboneCoords["C"], Residues[residueCtr + 1].BackboneCoords["N"]); } } //ben's code moved from peptide analytics //order: // [0] CA (index-1) // [1] C' (index-1) // [2] N // [3] CA // [4] C' // [5] N (index+1) //phiPsiAndOmega[2] = CalculateTorsion(atom0, atom1, atom2, atom3); // phiPsiAndOmega[0] = CalculateTorsion(atom1, atom2, atom3, atom4); // phiPsiAndOmega[1] = CalculateTorsion(atom2, atom3, atom4, atom5); } // set SecondaryStructure for (int residueCtr = 1; residueCtr < ResidueCount - 1; residueCtr++) { string bigPValue = "P"; string littlePValue = "p"; string geoSeq = ""; double phiValue = Residues[residueCtr].Phi; double psiValue = Residues[residueCtr].Psi; double omgValue = Residues[residueCtr].Omega; // possible values of geo hash: // trans values: lowercase // phi < 0: // alpha-R (A): -100 <= psi <= 50 // if not: beta (B) if phi < -100, polyproII (P) if phi >= -100 // phi > 0: // alpha-L (L): -50 <= psi <= 100 : L // beta(B): phi > 150 and not alpha-L : G (gamma) otherwise bool transPeptide = new bool(); transPeptide = true; if (Math.Abs(omgValue) < 90) { transPeptide = false; } if (phiValue < 0) { if (psiValue >= -100 && psiValue <= 50) { // alphaR or D if (phiValue < -100) { // D if (transPeptide) { geoSeq += "D"; } else { geoSeq += "d"; } } else { if (transPeptide) { geoSeq += "A"; } else { geoSeq += "a"; } } } else // beta or polyproII { if (MonovsPoly == false && phiValue < -90) //Changed from -100 on 12/1/15; needs to be -90 for multi-chain barrels { if (transPeptide) { geoSeq += "B"; } else { geoSeq += "b"; } } else if (MonovsPoly == true && phiValue < -100) //Changed from -100 on 12/1/15; needs to be -100 for single-chain barrels { if (transPeptide) { geoSeq += "B"; } else { geoSeq += "b"; } } else // polyproII { if (transPeptide) { geoSeq += bigPValue; } // switch to B to merge else { geoSeq += littlePValue; } // switch to b to merge } } } else // phi >= 0 { if (psiValue >= -50 && psiValue <= 100) { // alpha-L if (transPeptide) { geoSeq += "L"; } else { geoSeq += "l"; } } else { if (phiValue > 150) { //extension of beta if (transPeptide) { geoSeq += "B"; } else { geoSeq += "b"; } } else // gamma conformation { if (transPeptide) { geoSeq += "G"; } else { geoSeq += "g"; } } } } Residues[residueCtr].SSType = geoSeq; } //makeHBondList(); }