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 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; }