private bool CheckIfAllNeededAtomsExists(MolData molDic) { List <Residue> rList = molDic.mol.Chains[0].Residues; for (int i = 0; i < rList.Count; i++) { int counter = 0; for (int j = 0; j < rList[i].Atoms.Count; j++) { switch (rList[i].Atoms[j].AtomName) { case "CA": case "N": case "C": counter++; break; } } if (counter < 3) { return(false); } } return(true); }
protected void MakeProfiles(string strName, MolData molDic, StreamWriter wr, int k) { if (molDic != null) { PDBFiles pdb = new PDBFiles(); pdb.AddPDB(strName, PDBMODE.ONLY_CA); DebugClass.WriteMessage("Make Started"); //int []contact=pdbs.molDic[strName].CreateFullContactMap(8.5f); //molDic.CreateFullContactMap(9.5f,contact[k]);//correct List <string> cc = new List <string>(pdb.molDic.Keys); pdb.molDic[cc[0]].indexMol = molDic.indexMol; GenerateContactMap(pdb.molDic[cc[0]], k); //pdb.molDic[cc[0]].CreateFullContactMap(8.5f, contact[k]); //molDic.CreateFullContactMap(8.5f,contact[k]); //pdbs.molDic[strName].CreateContactMap(9.5f, "CB"); for (int i = 0; i < contact[k].Length; i++) { if (contact[k][i] == 1) { contOne[i]++; } } int j = 0; for (int i = 0; i < contact[k].Length - 1; i++) { if (contact[k][i] == 1) { contactToString[k][j++] = '1'; } else { contactToString[k][j++] = '0'; } contactToString[k][j++] = ' '; } if (contact[k][contact[k].Length - 1] == 1) { contactToString[k][j] = '1'; } else { contactToString[k][j] = '0'; } string all = new string(contactToString[k], 0, j); wr.WriteLine(">" + cc[0]); //for (int i = 0; i < contact[k].Length-1; i++) // wr.Write(contact[k][i]+" "); //wr.Write(contact[k][contact.Length-1]); //all = all.Trim(); wr.WriteLine(all.Trim()); //wr.WriteLine(); //molDic.CleanMolData(); DebugClass.WriteMessage("Make finished"); } }
public bool CalcAllDihedrals(MolData molDic) { Dictionary <string, Point3D> pfAtoms = new Dictionary <string, Point3D>() { { "CA", null }, { "C", null }, { "N", null }, { "PrevC", null }, { "NextN", null } }; short result = 360; residuePsi[0] = result; if (!CheckIfAllNeededAtomsExists(molDic)) { return(false); } for (int i = 0; i < molDic.mol.Residues.Count; i++) { foreach (var item in molDic.mol.Residues[i].Atoms) { if (pfAtoms.ContainsKey(item.AtomName)) { pfAtoms[item.AtomName] = item.Position; } } if (i > 0) { residuePhi[i] = (short)Math.Round(CalculateDihedralAngles(pfAtoms["PrevC"], pfAtoms["N"], pfAtoms["CA"], pfAtoms["C"])); } else { residuePhi[i] = 360; } if (i < molDic.mol.Residues.Count - 1) { foreach (var item in molDic.mol.Residues[i + 1].Atoms) { if (item.AtomName == "N") { pfAtoms["NextN"] = item.Position; break; } } residuePsi[i] = (short)Math.Round(CalculateDihedralAngles(pfAtoms["N"], pfAtoms["CA"], pfAtoms["C"], pfAtoms["NextN"])); } else { residuePsi[i] = 360; } pfAtoms["PrevC"] = pfAtoms["C"]; } return(true); }
private void doAutoCenter(bool withZCenter, int k, double[] sizes, double[] centerPoint, List <double[]> file) { if (k == 0) { return; } for (int i = 0; i < k; i++) { double[] centerCoord = Methods.CenterStructure(centerPoint, file); if (Math.Abs(centerCoord[0]) < 0.5 && Math.Abs(centerCoord[1]) < 0.5 && Math.Abs(centerCoord[2]) < 0.5) { break; } int breakmark = 0; if (!withZCenter) { centerCoord[2] = 0.0; } MolData.ShiftAllDouble(3, sizes, centerCoord, centerPoint, file); double[] diam = Methods.GetDiameter(file); for (int j = 0; j <= 2; j++) { if (Math.Abs(diam[j] - sizes[j]) <= 2) { var shifts = new double[3]; shifts[j] = -Methods.CenterAxis_Type2(false, j, sizes[j], centerPoint[j], file); if (j == 2 && !withZCenter) { shifts[j] = 0.0; } MolData.ShiftAllDouble(3, sizes, shifts, centerPoint, file); } else { if (centerCoord[j] < 0.5) { breakmark++; } } } if ((breakmark == 2 && !withZCenter) || (breakmark == 3 && withZCenter)) { break; } } }
private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { object[] objects = (object[])e.Argument; bool hasWalls = (bool)objects[0]; string fileName = (string)objects[1] + "/" + (string)objects[2] + ".lammpstrj"; string format = (string)objects[3]; double[] shifts = (double[])objects[4]; bool toTrim = (bool)objects[5]; double percentage = (double)objects[6] / 100.0; string[] files = (string[])objects[7]; for (int i = 0; i < files.Length; i++) { double[] sizes = new double[3]; List <double[]> data; if (format == "xyzr") { data = FileWorker.LoadXyzrLines(files[i]); sizes[0] = Math.Abs(data[data.Count - 1][0] - data[data.Count - 8][0]); sizes[1] = Math.Abs(data[data.Count - 1][1] - data[data.Count - 8][1]); sizes[2] = Math.Abs(data[data.Count - 1][2]); } else { int snapnum = 0; data = FileWorker.LoadLammpstrjLines(files[i], out snapnum, out sizes); } double[] centerPoint = MolData.GetCenterPoint(sizes, data); var system = MolData.ShiftAll(hasWalls, 0, false, 3, sizes, shifts, centerPoint, data); if (toTrim) { system = MolData.ReduceSystem(system, percentage); } FileWorker.SaveLammpstrj(true, fileName, i + 1, sizes, 3, system); int filesCount = (int)((double)files.Length / 100.0); if (filesCount == 0) { filesCount++; } if (i % filesCount == 0) { if (((BackgroundWorker)sender).CancellationPending) { e.Cancel = true; break; } ((BackgroundWorker)sender).ReportProgress((int)(100.0 * (double)i / (double)files.Length)); } } }
public CswNbtWebServiceMols.MolDataReturn saveMolPropText(MolData MolImgData) { CswNbtWebServiceMols.MolDataReturn Ret = new CswNbtWebServiceMols.MolDataReturn(); var SvcDriver = new CswWebSvcDriver <CswNbtWebServiceMols.MolDataReturn, MolData>( CswWebSvcResourceInitializer: new CswWebSvcResourceInitializerNbt(_Context, null), ReturnObj: Ret, WebSvcMethodPtr: CswNbtWebServiceMols.SaveMolPropFile, ParamObj: MolImgData ); SvcDriver.run(); return(Ret); }
public CswNbtWebServiceMols.MolDataReturn ClearMolFingerprint(MolData Request) { CswNbtWebServiceMols.MolDataReturn Ret = new CswNbtWebServiceMols.MolDataReturn(); var SvcDriver = new CswWebSvcDriver <CswNbtWebServiceMols.MolDataReturn, MolData>( CswWebSvcResourceInitializer: new CswWebSvcResourceInitializerNbt(_Context, null), ReturnObj: Ret, WebSvcMethodPtr: CswNbtWebServiceMols.ClearMolFingerprint, ParamObj: Request ); SvcDriver.run(); return(Ret); }
protected override void MakeProfiles(string strName, MolData molDic, StreamWriter wr) { Dictionary <int, List <int> > contacts = new Dictionary <int, List <int> >(); if (molDic != null) { KeyValuePair <char [], string> x = GenerateStates(molDic); string ss = new string(x.Key); if (x.Value.Length > 0) { wr.WriteLine(">" + strName); wr.WriteLine(contactProfile + x.Value); wr.WriteLine(ssProfile + ss); wr.WriteLine(SEQprofile + molDic.mol.Chains[0].chainSequence); } molDic.CleanMolData(); } }
public static float[,] GetFullStructure(MolData mol) { float[,] structure = new float [mol.indexMol.Length, 3]; for (int i = 0; i < mol.indexMol.Length; i++) { if (mol.indexMol[i] != -1 && mol.mol.Residues[mol.indexMol[i]].ResidueName != 'X') { //Take only first Atom (should be CA) Atom atom = mol.mol.Residues[mol.indexMol[i]].Atoms[0]; structure[i, 0] = atom.Position.X; structure[i, 1] = atom.Position.Y; structure[i, 2] = atom.Position.Z; } else { structure[i, 0] = float.MaxValue; structure[i, 1] = float.MaxValue; structure[i, 2] = float.MaxValue; } } return(structure); }
private void bgWorkerCenter_DoWork(object sender, DoWorkEventArgs e) { object[] objects = (object[])e.Argument; string format = (string)objects[0]; int centerType = (int)objects[1]; string[] files = (string[])objects[2]; bool withZCenter = true; if (centerType == 2) { withZCenter = false; } double[] sizes = new double[3]; double[] centerPoint = new double[3]; for (int k = 0, len = files.Length; k < len; k++) { if (!bgWorkerCenter.CancellationPending) { int snapnum = 0; var file = new List <double[]>(); readTableFile(format, files[k], out snapnum, out file, out sizes); if (k == 0) { centerPoint = MolData.GetCenterPoint(sizes, file); } doAutoCenter(withZCenter, 5, sizes, centerPoint, file); var strct = MolData.ShiftAll(false, 0, false, 3, sizes, new double[] { 0, 0, 0 }, centerPoint, file); if (format == "xyzr") { FileWorker.Save_XYZ(files[k], true, sizes, strct); } else { FileWorker.SaveLammpstrj(false, files[k], snapnum, sizes, 3, strct); } int filesCount = (int)((double)files.Length / 100.0); if (filesCount == 0) { filesCount++; } if (k % filesCount == 0) { ((BackgroundWorker)sender).ReportProgress((int)(100.0 * (double)k / (double)files.Length)); } } else { e.Cancel = true; break; } } }
protected override void MakeProfiles(string strName, MolData molDic, StreamWriter wr) { int tNumb = dirSettings.numberOfCores; if (molDic != null) { foreach (var chain in molDic.mol.Chains) { for (int i = 0; i < profile.Length; i++) { profile[i] = 0; } res = chain.Residues; if (dirSettings.mode == INPUTMODE.PROTEIN) { if (res.Count <= 10) { continue; } } if (dirSettings.mode == INPUTMODE.RNA) { if (res.Count <= 5) { continue; } } for (int i = 0; i < res.Count; i++) { for (int j = 0; j < fragBagLibrary.Count; j++) { distData[j] = float.MaxValue; index[j] = j; } for (int n = 0; n < tNumb; n++) { int[] pp = new int[4]; pp[0] = (int)(n * fragBagLibrary.Count / Convert.ToDouble(tNumb, System.Globalization.CultureInfo.InvariantCulture)); pp[1] = (int)((n + 1) * fragBagLibrary.Count / Convert.ToDouble(tNumb, System.Globalization.CultureInfo.InvariantCulture)); pp[2] = i; pp[3] = n; resetEvents[n].Reset(); ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadLibrary), (object)pp); } for (int n = 0; n < tNumb; n++) { resetEvents[n].WaitOne(); } Array.Sort(distData, index); //Console.WriteLine(distData[0] + " " + distData[1]); if (distData[0] != float.MaxValue)// && distData[0]<1) { if (profile[index[0]] > Byte.MaxValue) { profile[index[0]] = Byte.MaxValue; } else { profile[index[0]]++; } } } if (profile.Length > 0) { if (chainId.Count > 0) { wr.WriteLine(">" + strName + "|" + chainId[chain.ChainIdentifier]); } else { wr.WriteLine(">" + strName); } wr.Write(fragBagProfile); foreach (var item in profile) { byte value = 0; if (item < 255) { value = Convert.ToByte(item); } else { value = 244; } wr.Write(value + " "); } wr.WriteLine(); count++; for (int i = 0; i < profile.Length; i++) { if (profile[i] == 0) { zeroCount[i]++; } } } } } }
protected override void GenerateContactMap(MolData mol, int k) { mol.CreateFullContactMap(15.5f, contact[k], "P"); }
public static void SaveMolPropFile(ICswResources CswResources, MolDataReturn Return, MolData ImgData) { CswNbtResources NBTResources = (CswNbtResources)CswResources; string Href; CswNbtSdBlobData SdBlobData = new CswNbtSdBlobData(NBTResources); string FormattedMolString; string errorMsg; SdBlobData.saveMol(ImgData.molString, ImgData.propId, out Href, out FormattedMolString, out errorMsg); ImgData.molString = FormattedMolString; ImgData.href = Href; ImgData.errorMsg = errorMsg; Return.Data = ImgData; }
public MolDataReturn() { Data = new MolData(); }
public static void ClearMolFingerprint(ICswResources CswResources, MolDataReturn Return, MolData Request) { //TODO: remove me CswNbtResources NbtResources = (CswNbtResources)CswResources; CswPrimaryKey pk = new CswPrimaryKey(); pk.FromString(Request.nodeId); }
protected KeyValuePair <char[], string> GenerateStates(MolData molDic) { Dictionary <int, List <int> > contacts = new Dictionary <int, List <int> >(); char[] statesTab = Enumerable.Repeat <char>('N', molDic.mol.Residues.Count).ToArray(); double[] dist2; molDic.CreateCAContactMap(8.5f, false); //pdbs.molDic[strName].CreateContactMap(9.5f, "CB"); foreach (var contItem in molDic.contactMap.Keys) { if (!contacts.ContainsKey(contItem)) { contacts.Add(contItem, new List <int>()); } foreach (var itemList in molDic.contactMap[contItem]) { contacts[contItem].Add((int)itemList); if (!contacts.ContainsKey((int)itemList)) { contacts.Add((int)itemList, new List <int>()); contacts[(int)itemList].Add(contItem); } else if (!contacts[(int)itemList].Contains(contItem)) { contacts[(int)itemList].Add(contItem); } } } int num; string profile = ""; int len = molDic.mol.Chains[0].chainSequence.Length; for (int i = 0; i < len; i++) { if (contacts.ContainsKey(i)) { num = contacts[i].Count; if (num > 9) { num = 9; } } else { num = 0; } profile += num; if (i < len - 1) { profile += " "; } } dist2 = new double[molDic.mol.Residues.Count - 2]; for (int i = 0; i < molDic.mol.Residues.Count - 2; i++) { Atom aux1 = molDic.mol.Residues[i].Atoms[0]; Atom aux2 = molDic.mol.Residues[i + 2].Atoms[0]; double sum = (aux1.Position.X - aux2.Position.X) * (aux1.Position.X - aux2.Position.X); sum += (aux1.Position.Y - aux2.Position.Y) * (aux1.Position.Y - aux2.Position.Y); sum += (aux1.Position.Z - aux2.Position.Z) * (aux1.Position.Z - aux2.Position.Z); sum = Math.Sqrt(sum); dist2[i] = sum; } for (int i = 0; i < molDic.mol.Residues.Count - 4; i++) { Atom aux1 = molDic.mol.Residues[i].Atoms[0]; Atom aux2 = molDic.mol.Residues[i + 4].Atoms[0]; double sum = (aux1.Position.X - aux2.Position.X) * (aux1.Position.X - aux2.Position.X); sum += (aux1.Position.Y - aux2.Position.Y) * (aux1.Position.Y - aux2.Position.Y); sum += (aux1.Position.Z - aux2.Position.Z) * (aux1.Position.Z - aux2.Position.Z); sum = Math.Sqrt(sum); if (dist2[i] > 4 && dist2[i] < 8) { if (dist2[i] < 6) { if (sum > 4 && sum < 14) { if (sum < 7) { statesTab[i] = 'H'; } else if (sum < 9) { statesTab[i] = 'J'; } else if (sum < 11) { statesTab[i] = 'K'; } else if (sum < 13) { statesTab[i] = 'L'; } } else { statesTab[i] = 'U';//unphysical } } else if (sum > 4 && sum < 14) { if (sum < 7) { statesTab[i] = 'E'; } else if (sum < 9) { statesTab[i] = 'R'; } else if (sum < 11) { statesTab[i] = 'T'; } else if (sum < 13) { statesTab[i] = 'Y'; } } } else { statesTab[i] = 'U';//unphysical } } return(new KeyValuePair <char[], string>(statesTab, profile)); }
public static void getMolImg(ICswResources CswResources, MolDataReturn Return, MolData ImgData) { string molData = ImgData.molString; string nodeId = ImgData.nodeId; string base64String = ""; CswNbtResources NbtResources = (CswNbtResources)CswResources; if (String.IsNullOrEmpty(molData) && false == String.IsNullOrEmpty(nodeId)) //if we only have a nodeid, get the mol text from the mol property if there is one { CswPrimaryKey pk = CswConvert.ToPrimaryKey(nodeId); CswNbtNode node = NbtResources.Nodes[pk]; CswNbtMetaDataNodeTypeProp molNTP = node.getNodeType().getMolProperty(); if (null != molNTP) { molData = node.Properties[molNTP].AsMol.getMol(); } } if (false == String.IsNullOrEmpty(molData)) { //If the Direct Structure Search module is enabled, use the AcclDirect methods to generate an image. Otherwise, use the legacy code. byte[] bytes = (NbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.DirectStructureSearch) ? NbtResources.AcclDirect.GetImage(molData) : CswStructureSearch.GetImage(molData)); base64String = Convert.ToBase64String(bytes); } ImgData.molImgAsBase64String = base64String; ImgData.molString = molData; Return.Data = ImgData; }
/* public static posMOL PrepareData(MolData mol1, MolData mol2, bool atomList = false) * { * posMOL globPosMol = new posMOL(); * * globPosMol.posmol1 = new float[mol1.mol.Residues.Count, 3]; * globPosMol.posmol2 = new float[mol2.mol.Residues.Count, 3]; * * for (int i = 0; i < mol1.mol.Residues.Count; i++) * { * globPosMol.posmol1[i, 0] = mol1.mol.Residues[i].Atoms[0].Position.X; * globPosMol.posmol1[i, 1] = mol1.mol.Residues[i].Atoms[0].Position.Y; * globPosMol.posmol1[i, 2] = mol1.mol.Residues[i].Atoms[0].Position.Z; * } * for (int i = 0; i < mol2.mol.Residues.Count; i++) * { * globPosMol.posmol2[i, 0] = mol2.mol.Residues[i].Atoms[0].Position.X; * globPosMol.posmol2[i, 1] = mol2.mol.Residues[i].Atoms[0].Position.Y; * globPosMol.posmol2[i, 2] = mol2.mol.Residues[i].Atoms[0].Position.Z; * } * * float[] center = new float[3]; * * CenterMol(globPosMol.posmol1, center); * CenterMol(globPosMol.posmol2, center); * * return globPosMol; * * }*/ public static posMOL PrepareData(MolData mol1, MolData mol2, bool atomList = false) { int count = 0; posMOL globPosMol = new posMOL(); Dictionary <string, int> atomNameMol1 = null; for (int i = 0; i < mol1.mol.Residues.Count; i++) { if (mol1.mol.Residues[i].Atoms.Count > count) { count = mol1.mol.Residues[i].Atoms.Count; } } atomNameMol1 = new Dictionary <string, int>(count); count = 0; for (int i = 0; i < mol1.indexMol.Length; i++) { if (mol1.indexMol[i] != -1 && mol2.indexMol[i] != -1)// && mol1.mol.Residues[mol1.indexMol[i]].ResidueName != 'X' && mol2.mol.Residues[mol2.indexMol[i]].ResidueName != 'X') { atomNameMol1.Clear(); List <Atom> atoms = mol1.mol.Residues[mol1.indexMol[i]].Atoms; for (int j = 0; j < atoms.Count; j++) { atomNameMol1.Add(atoms[j].AtomName, j); } foreach (var item in mol2.mol.Residues[mol2.indexMol[i]].Atoms) { if (atomNameMol1.ContainsKey(item.AtomName)) { count++; } } } } // index1 = mol1.indexMol; //index2 = mol2.indexMol; if (globPosMol.posmol1 == null || count != globPosMol.posmol1.GetLength(0)) { globPosMol.posmol1 = new float[count, 3]; globPosMol.posmol2 = new float[count, 3]; } if (atomList) { globPosMol.atoms = new List <string> [mol1.indexMol.Length]; for (int i = 0; i < mol1.indexMol.Length; i++) { globPosMol.atoms[i] = new List <string>(); } } count = 0; for (int i = 0; i < mol1.indexMol.Length; i++) { if (mol1.indexMol[i] != -1 && mol2.indexMol[i] != -1)// && mol1.mol.Residues[mol1.indexMol[i]].ResidueName != 'X' && mol2.mol.Residues[mol2.indexMol[i]].ResidueName != 'X') { atomNameMol1.Clear(); List <Atom> atoms = mol1.mol.Residues[mol1.indexMol[i]].Atoms; for (int j = 0; j < atoms.Count; j++) { atomNameMol1.Add(atoms[j].AtomName, j); } foreach (var item in mol2.mol.Residues[mol2.indexMol[i]].Atoms) { if (atomNameMol1.ContainsKey(item.AtomName)) { Atom aux = mol1.mol.Residues[mol1.indexMol[i]].Atoms[atomNameMol1[item.AtomName]]; globPosMol.posmol1[count, 0] = aux.Position.X; globPosMol.posmol1[count, 1] = aux.Position.Y; globPosMol.posmol1[count, 2] = aux.Position.Z; globPosMol.posmol2[count, 0] = item.Position.X; globPosMol.posmol2[count, 1] = item.Position.Y; globPosMol.posmol2[count, 2] = item.Position.Z; if (atomList) { globPosMol.atoms[i].Add(item.AtomName); } count++; } } } } float[] center = new float[3]; CenterMol(globPosMol.posmol1, center); CenterMol(globPosMol.posmol2, center); return(globPosMol); }
protected virtual void GenerateContactMap(MolData mol, int k) { mol.CreateFullContactMap(8.5f, contact[k], "CA"); }
protected virtual void MakeProfiles(string strName, MolData molDic, StreamWriter wr) { Dictionary <int, List <int> > contacts = new Dictionary <int, List <int> >(); if (molDic != null) { residuePsi = new short[molDic.mol.Residues.Count]; residuePhi = new short[molDic.mol.Residues.Count]; if (!CalcAllDihedrals(molDic)) { return; } molDic.CreateSideChainContactMap(8.5f, false); //pdbs.molDic[strName].CreateContactMap(9.5f, "CB"); foreach (var contItem in molDic.contactMap.Keys) { if (!contacts.ContainsKey(contItem)) { contacts.Add(contItem, new List <int>()); } foreach (var itemList in molDic.contactMap[contItem]) { contacts[contItem].Add((int)itemList); if (!contacts.ContainsKey((int)itemList)) { contacts.Add((int)itemList, new List <int>()); contacts[(int)itemList].Add(contItem); } else if (!contacts[(int)itemList].Contains(contItem)) { contacts[(int)itemList].Add(contItem); } } } int num; string profile = ""; int len = molDic.mol.Chains[0].chainSequence.Length; for (int i = 0; i < len; i++) { if (contacts.ContainsKey(i)) { num = contacts[i].Count; if (num > 9) { num = 9; } } else { num = 0; } profile += num; if (i < len - 1) { profile += " "; } } string psiProfile = ""; string phiProfile = ""; string ss = ""; List <string> meso = new List <string>(); List <string> mesoDF = new List <string>(); for (int i = 0; i < molDic.mol.Residues.Count; i++) { string key; psiProfile += residuePsi[i]; phiProfile += residuePhi[i]; key = BuildKey(residuePhi[i], residuePsi[i]); meso.Add(key); if (i < molDic.mol.Residues.Count - 1) { ss += " "; psiProfile += " "; phiProfile += " "; } } char[] ssStates = new char[meso.Count]; for (int i = 0; i < meso.Count; i++) { ssStates[i] = 'C'; } for (int i = 0; i < meso.Count; i++) { if (meso[i] == null) { continue; } if (mesoStates.ContainsKey(meso[i])) { //mesoDF.Add(mesoStates[meso[i]]); if (PII.ContainsKey(mesoStates[meso[i]])) { ssStates[i] = 'P'; } if (i < meso.Count - 1) { if (meso[i + 1] != null && mesoStates.ContainsKey(meso[i + 1])) { string combStates = mesoStates[meso[i]] + mesoStates[meso[i + 1]]; if (turns.ContainsKey(combStates)) { ssStates[i] = ssStates[i + 1] = 'T'; } } } } } for (int i = 0; i < meso.Count; i++) { int counter = 0; if (meso[i] == null) { continue; } if (mesoStates.ContainsKey(meso[i])) { if (helix.ContainsKey(mesoStates[meso[i]]) && i < meso.Count - 5) { for (int k = 0; k < 5; k++) { if (meso[i + k] != null && mesoStates.ContainsKey(meso[i + k]) && helix.ContainsKey(mesoStates[meso[i + k]])) { counter++; } else { break; } } if (counter == 5) { for (int k = 0; k < 5; k++) { ssStates[i + k] = 'H'; } } } counter = 0; if (i < meso.Count - 3) { for (int k = 0; k < 3; k++) { if (meso[i + k] != null && mesoStates.ContainsKey(meso[i + k]) && strand.ContainsKey(mesoStates[meso[i + k]])) { counter++; } else { break; } } if (counter == 3) { for (int k = 0; k < 3; k++) { if (ssStates[i + k] == 'C' || ssStates[i + k] == 'P') { ssStates[i + k] = 'E'; } } } } } } ss = new string(ssStates); if (profile.Length > 0) { wr.WriteLine(">" + strName); wr.WriteLine(contactProfile + profile); //wr.WriteLine(PsiProfile+psiProfile); //wr.WriteLine(PhiProfile+phiProfile); wr.WriteLine(ssProfile + ss); wr.WriteLine(SEQprofile + molDic.mol.Chains[0].chainSequence); } molDic.CleanMolData(); } }