public GDT_TS(DCDFile dcd, string alignFile, bool flag, string refJuryProfile = null) : base(dcd, alignFile, flag, PDBMODE.ONLY_CA, refJuryProfile) { order = true; maxSimilarity = 100.0; gdt = new GDT(dcd, alignFile, flag, refJuryProfile); }
public Rmsd(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null) : base(dcd, alignFile, flag, refJuryProfile) { DCDReader readDCD = new DCDReader(dcd); dirSettings.Load(); pdbs = new PDBFiles(); readDCD.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile); int counter = 0; bool cont = true; do { MemoryStream mStream = new MemoryStream(); StreamWriter wStream = new StreamWriter(mStream); cont=readDCD.ReadAndSavePDB(wStream); string name = "Model" + counter++; mStream.Position = 0; pdbs.AddPDB(mStream, allAtoms, name); } while(cont); readDCD.FinishDCDReading(); pdbs.FindReferenceSeq(); pdbs.MakeAlignment(alignFile); if(pdbs is ErrorBase) AddErrors(pdbs.errors); opt = new Optimization(); structNames = CheckAvailableStructures(); order = true; }
public Rmsd(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null) : base(dcd, alignFile, flag, refJuryProfile) { DCDReader readDCD = new DCDReader(dcd); dirSettings.Load(); pdbs = new PDBFiles(); readDCD.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile); int counter = 0; bool cont = true; do { MemoryStream mStream = new MemoryStream(); StreamWriter wStream = new StreamWriter(mStream); cont = readDCD.ReadAndSavePDB(wStream); string name = "Model" + counter++; mStream.Position = 0; pdbs.AddPDB(mStream, allAtoms, name); }while(cont); readDCD.FinishDCDReading(); pdbs.FindReferenceSeq(); pdbs.MakeAlignment(alignFile); if (pdbs is ErrorBase) { AddErrors(pdbs.errors); } opt = new Optimization(); structNames = CheckAvailableStructures(); order = true; }
protected Dictionary <string, int> CheckFile(DCDFile dcd) { Dictionary <string, int> dic = new Dictionary <string, int>(); if (File.Exists(GetProfileFileName(dcd))) { using (StreamReader rf = new StreamReader(GetProfileFileName(dcd))) { if (rf == null) { return(null); } string line = rf.ReadLine(); while (line != null) { if (line.Contains('>')) { line = line.Remove(0, 1); dic.Add(line, 1); } line = rf.ReadLine(); } rf.Close(); } } return(dic); }
protected void InitMeasure(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null) { base.InitMeasure(dcd, alignFile, flag, refJuryProfile); DCDReader readDCD = new DCDReader(dcd); pdbs = new PDBFiles(); readDCD.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile); int counter = 0; bool cont = true; do { MemoryStream mStream = new MemoryStream(); StreamWriter wStream = new StreamWriter(mStream); cont = readDCD.ReadAndSavePDB(wStream); string name = "Model" + counter++; mStream.Position = 0; pdbs.AddPDB(mStream, allAtoms, name); }while(cont); readDCD.FinishDCDReading(); pdbs.FindReferenceSeq(); pdbs.MakeAlignment(alignFile); structNames = CheckAvailableStructures(); atomDic = pdbs.MakeAllAtomsDic(); }
public HammingBase(DCDFile dcd, string alignFile, bool flag, string profileName, string refJuryProfile = null) { this.dcd = dcd; this.alignFile = alignFile; this.flag = flag; this.profileName = profileName; this.refJuryProfile = refJuryProfile; }
public Rmsd(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null) { order = true; dirSettings.Load(); this.dcd = dcd; this.alignFile = alignFile; this.flag = flag; this.allAtoms = allAtoms; this.refJuryProfile = refJuryProfile; }
protected string GetProfileFileName(DCDFile dcd) { string[] aux; string bDir = ""; aux = dcd.dcdFile.Split(Path.DirectorySeparatorChar); if (set.profilesDir != null && set.profilesDir.Length > 0) { bDir = set.profilesDir + Path.DirectorySeparatorChar; } return(bDir + aux[aux.Length - 1] + "_" + profileName); }
public static Dictionary <string, protInfo> GetProfile(profileNode node, DCDFile dcd) { profileNode n = GetNode(node.internalName); if (n != null) { Type t = Type.GetType(internalList[n]); InternalProfileBase c = Activator.CreateInstance(t) as InternalProfileBase; return(c.GetProfile(node, null, dcd)); } return(null); }
public virtual void InitMeasure(DCDFile dcd, string alignFile, bool referenceFlag, string juryProfile = null) { this.alignFile = alignFile; if (referenceFlag) { if (juryProfile.Length == 0 || !File.Exists(juryProfile)) { throw new Exception("Profile for reference structure searching has been not defined or does not exist"); } jury = new jury1D(); jury.PrepareJury(dcd, alignFile, juryProfile); } }
public void InitMeasure(DCDFile dcd, string alignFile, bool flag, string profileName, string refJuryProfile = null) { base.InitMeasure(dcd, alignFile, flag, refJuryProfile); if (profileName != null) { currentProfile = profileName; } dirSettings.Load(); al = new Alignment(); al.Prepare(dcd, dirSettings, currentProfile); InitHamming(); }
public void RunProfile(string name, DCDFile dcd) { profileNode node = GetNode(name); if (node != null) { Type t = Type.GetType(internalList[node]); InternalProfileBase c = Activator.CreateInstance(t) as InternalProfileBase; c.CheckIfAvailable(); progressInfo = c; c.Run(dcd); progressInfo = null; progress++; } }
// virtual public void RunThreads(string listFile); abstract public void Run(DCDFile dcd);
abstract public Dictionary <string, protInfo> GetProfile(profileNode node, string listFile, DCDFile dcd);
protected string GetProfileFileName(DCDFile dcd) { string[] aux; string bDir = ""; aux = dcd.dcdFile.Split(Path.DirectorySeparatorChar); if (set.profilesDir != null && set.profilesDir.Length > 0) bDir = set.profilesDir + Path.DirectorySeparatorChar; return bDir+aux[aux.Length - 1] + "_" + profileName; }
public override Dictionary<string, protInfo> GetProfile(profileNode node, string listFile,DCDFile dcd=null) { Dictionary<string, protInfo> dic = null; StreamReader wr; DebugClass.WriteMessage("start reading file" + listFile); string useFile = listFile; List<string> names = GetFileList(listFile); if(names==null) DebugClass.WriteMessage("After GetFileList null"); else DebugClass.WriteMessage("After GetFileList "+names.Count); maxV = names.Count; Dictionary<string, int> dicNames = new Dictionary<string, int>(names.Count); foreach (var item in names) { string[] aux = item.Split(Path.DirectorySeparatorChar); if(!dicNames.ContainsKey(aux[aux.Length-1])) dicNames.Add(aux[aux.Length-1], 0); } DebugClass.WriteMessage("After loop"); string[] dotFlag = names[0].Split('|'); bool flag = false; if (dotFlag.Length == 2) flag = true; DebugClass.WriteMessage("Before profile"); if (dcd == null) { wr = new StreamReader(GetProfileFileName(listFile)); } else wr = new StreamReader(GetProfileFileName(dcd)); DebugClass.WriteMessage("start ddd reading"); protInfo info; string line = wr.ReadLine(); string name=""; string seq=""; List<string> profile; ; List<byte> newProfile = null; string profileName; if (node.ContainsState("H")) profileName = ssProfile; else profileName = contactProfile; //Check number of elements in file int lineLength=0; while (line != null) { if (lineLength < line.Length) lineLength = line.Length; line=wr.ReadLine(); } wr.BaseStream.Position = 0; wr.DiscardBufferedData(); profile = new List<string>(lineLength); dic = new Dictionary<string, protInfo>(names.Count); line=wr.ReadLine(); string remName=""; DebugClass.WriteMessage("Starrrrr"); while (line != null) { if (line[0]=='>') { if (name.Length > 0) { if (dicNames.ContainsKey(name)) { info = new protInfo(); info.sequence = seq; info.profile = newProfile; //string newName = line; //newName = newName.Remove(0, 1); if (!dic.ContainsKey(remName)) dic.Add(remName, info); else ErrorBase.AddErrors("!!In the generated profile file structure " + remName + " exists more then once!!!\nOnly the first profile will be considered!"); currentProgress++; } } name = line.Remove(0, 1); remName = name; if(name.Contains("|") && !flag) { string[] tmp = name.Split('|'); name = tmp[0]; } } if (dicNames.ContainsKey(name)) { if (line.Contains(SEQprofile)) seq = line.Remove(0, SEQprofile.Length); else if (line.Contains(profileName)) { //StringBuilder tmp = new StringBuilder(line); line=line.Remove(0,profileName.Length); //tmp = tmp.Remove(0, profileName.Length); //StringBuilder tmp = new StringBuilder (line.Remove(0, profileName.Length)); string[] aux; if(line.Contains(' ')) aux = line.Split(' '); else { aux = new string[line.Length]; for (int i = 0; i < line.Length; i++) aux[i] = line[i].ToString(); } newProfile = CreateNewProfile(node, aux); } } line = wr.ReadLine(); } if (dicNames.ContainsKey(name)) { info = new protInfo(); info.sequence = seq; info.profile = newProfile; dic.Add(remName, info); } wr.Close(); DebugClass.WriteMessage("Reading finished"); return dic; }
public GDT(DCDFile dcd, string alignFile, bool flag, string refJuryProfile = null) : base(dcd, alignFile, flag, refJuryProfile) { order = true; maxSimilarity = 100.0; }
public override void Run(DCDFile dcd) { DCDReader dcdReader = new DCDReader(null); string modelName=null; int counter = 0; string fileName; StreamWriter wr; PDBFiles pdbs = new PDBFiles(); Dictionary<string,int> modelList=null; fileName = GetProfileFileName(dcd); if (File.Exists(fileName)) { modelList = CheckFile(dcd); wr = File.AppendText(fileName); } else wr = new StreamWriter(fileName); if (wr == null) throw new Exception("Cannot open file: " + fileName); dcdReader.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile); bool cont = true; do { MemoryStream mStream = new MemoryStream(); StreamWriter write = new StreamWriter(mStream); cont = dcdReader.ReadAndSavePDB(write); modelName = "Model" + counter++; if (modelList == null || modelList.ContainsKey(modelName)) continue; mStream.Position = 0; if (this.GetType() == typeof(ContactProfile)) pdbs.AddPDB(mStream, PDBMODE.ALL_ATOMS, modelName); else pdbs.AddPDB(mStream, PDBMODE.ONLY_CA, modelName); if(pdbs.molDic.ContainsKey(modelName)) MakeProfiles(modelName,pdbs.molDic[modelName], wr); } while (cont); dcdReader.FinishDCDReading(); wr.Close(); }
protected Dictionary<string,int> CheckFile(DCDFile dcd) { Dictionary<string, int> dic = new Dictionary<string, int>(); if (File.Exists(GetProfileFileName(dcd))) { using (StreamReader rf = new StreamReader(GetProfileFileName(dcd))) { if (rf == null) return null; string line = rf.ReadLine(); while (line != null) { if (line.Contains('>')) { line = line.Remove(0, 1); dic.Add(line, 1); } line = rf.ReadLine(); } rf.Close(); } } return dic; }
abstract public Dictionary<string, protInfo> GetProfile(profileNode node, string listFile,DCDFile dcd);
public override void Run(DCDFile dcd) { throw new NotImplementedException(); }
public DCDReader(DCDFile dcdFile) { this.dcdFile = dcdFile; }
public override Dictionary <string, protInfo> GetProfile(profileNode node, string fileName, DCDFile dcd) { Dictionary <string, protInfo> dic = new Dictionary <string, protInfo>(); StreamReader wr; DebugClass.WriteMessage("profile" + fileName); wr = new StreamReader(fileName); protInfo info; string line = wr.ReadLine(); string name = ""; string seq = ""; List <string> profile = new List <string>(); List <byte> newProfile = new List <byte>(); while (line != null) { if (line.Contains(">")) { if (name.Length > 0) { info = new protInfo(); info.sequence = null; info.profile = newProfile; if (dic.ContainsKey(name)) { wr.Close(); throw new Exception("The nameof profile must be unique, name: " + name + " already exists in " + fileName); } dic.Add(name, info); } newProfile = new List <byte>(); name = line.Replace(">", ""); line = wr.ReadLine(); } if (line != null && line.Contains(" profile ")) { int index = line.IndexOf(" profile "); if (index == -1) { wr.Close(); throw new Exception("Incorrect file format you have to have 'profile' word!"); } string cLine = line.Remove(0, " profile ".Length + index); cLine = Regex.Replace(cLine, @"\s+", " "); if (line.Length == 0) { continue; } cLine = cLine.Trim(); string[] aux; if (cLine.Contains(' ')) { aux = cLine.Split(' '); } else { char[] charArray = cLine.ToCharArray(); aux = cLine.Select(x => x.ToString()).ToArray(); } profile.Clear(); foreach (var item in aux) { profile.Add(item); } newProfile = new List <byte>(); for (int i = 0; i < profile.Count; i++) { if (node.ContainsState(profile[i].ToString())) { newProfile.Add(node.GetCodedState(node.states[profile[i].ToString()])); } else if (profile[i].ToString() != "-" && profile[i].ToString() != "X") { throw new Exception("Unknow state " + profile[i].ToString() + " in " + node.profName + " profile!"); } else { newProfile.Add(0); } } } line = wr.ReadLine(); } if (newProfile.Count > 0) { info = new protInfo(); info.sequence = seq; info.profile = newProfile; dic.Add(name, info); } DebugClass.WriteMessage("number of profiles " + dic.Keys.Count); wr.Close(); return(dic); }
public static Dictionary<string, protInfo> GetProfile(profileNode node, DCDFile dcd) { profileNode n = GetNode(node.internalName); if (n != null) { Type t = Type.GetType(internalList[n]); InternalProfileBase c = Activator.CreateInstance(t) as InternalProfileBase; return c.GetProfile(node, null,dcd); } return null; }
public CosineDistance(DCDFile dcd, string alignFile, bool flag, string profileName, string refJuryProfile = null) : base(dcd, alignFile, flag, profileName, refJuryProfile) { }
public override void Run(DCDFile dcd) { DCDReader dcdReader = new DCDReader(null); string modelName = null; int counter = 0; string fileName; StreamWriter wr; PDBFiles pdbs = new PDBFiles(); Dictionary <string, int> modelList = null; fileName = GetProfileFileName(dcd); if (File.Exists(fileName)) { modelList = CheckFile(dcd); wr = File.AppendText(fileName); } else { wr = new StreamWriter(fileName); } if (wr == null) { throw new Exception("Cannot open file: " + fileName); } dcdReader.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile); bool cont = true; do { MemoryStream mStream = new MemoryStream(); StreamWriter write = new StreamWriter(mStream); cont = dcdReader.ReadAndSavePDB(write); modelName = "Model" + counter++; if (modelList == null || modelList.ContainsKey(modelName)) { continue; } mStream.Position = 0; if (this.GetType() == typeof(ContactProfile)) { pdbs.AddPDB(mStream, PDBMODE.ALL_ATOMS, modelName); } else { pdbs.AddPDB(mStream, PDBMODE.ONLY_CA, modelName); } if (pdbs.molDic.ContainsKey(modelName)) { MakeProfiles(modelName, pdbs.molDic[modelName], wr); } }while (cont); dcdReader.FinishDCDReading(); wr.Close(); }
public override Dictionary <string, protInfo> GetProfile(profileNode node, string listFile, DCDFile dcd = null) { Dictionary <string, protInfo> res = base.GetProfile(node, listFile, dcd); /* StreamReader r = new StreamReader("sekw"); * string line = r.ReadLine(); * int []index = new int[399]; * int counter = 0; * while (line != null) * { * index[counter] = Convert.ToInt32(line); * line = r.ReadLine(); * counter++; * }*/ int[] index = new int[20] { 0, 74, 57, 375, 343, 174, 33, 371, 227, 330, 9, 327, 141, 160, 256, 216, 138, 385, 51, 268 }; // for proteins // int[] index = new int[29] { 21, 64, 29, 2, 33, 57, 77, 84, 14, 44, 81, 0, 90, 74, 30, 71, 76, 8, 48, 61,86,41,3,7,15,20,23,25,51};//for rna List <string> keys = new List <string>(res.Keys); foreach (var item in keys) { List <byte> newProfile = new List <byte>(); for (int i = 0; i < index.Length; i++) { newProfile.Add(res[item].profile[index[i]]); } protInfo xx = res[item]; xx.profile = newProfile; res[item] = xx; } //res = RearangeColumnOrder(res); // res = RearangeColumnOrder(res, "C:\\Projects\\listIndex"); res = ProfileStat.RearangeStates(res, 0.51); return(res); }
public override Dictionary <string, protInfo> GetProfile(profileNode node, string fileName, DCDFile dcd) { Dictionary <string, protInfo> dic = new Dictionary <string, protInfo>(); StreamReader wr; DebugClass.WriteMessage("profile" + fileName); wr = new StreamReader(fileName); protInfo info; string line = wr.ReadLine(); string name = ""; string seq = ""; List <string> profile = new List <string>(); List <byte> newProfile = new List <byte>(); while (line != null) { if (line.Contains(">")) { if (name.Length > 0) { info = new protInfo(); info.sequence = null; info.profile = newProfile; dic.Add(name, info); } name = line.Replace(">", ""); line = wr.ReadLine(); } if (line.Contains(" profile ")) //if (line.Contains(node.profName+" ")) { string[] aux; aux = line.Split(' '); node.profName = aux[0]; string cLine = line.Remove(0, (node.profName + " profile ").Length); cLine = Regex.Replace(cLine, @"\s+", " "); cLine = cLine.Trim(); if (cLine.Contains(' ')) { aux = cLine.Split(' '); } else { char[] charArray = cLine.ToCharArray(); aux = cLine.Select(x => x.ToString()).ToArray(); } profile.Clear(); foreach (var item in aux) { profile.Add(item); } newProfile = new List <byte>(); for (int i = 0; i < profile.Count; i++) { if (node.ContainsState(profile[i].ToString())) { newProfile.Add(node.GetCodedState(node.states[profile[i].ToString()])); } else if (profile[i].ToString() != "-" && profile[i].ToString() != "X") { throw new Exception("Unknow state " + profile[i].ToString() + " in " + node.profName + " profile!"); } else { newProfile.Add(0); } } } line = wr.ReadLine(); } info = new protInfo(); info.sequence = seq; info.profile = newProfile; dic.Add(name, info); DebugClass.WriteMessage("number of profiles " + dic.Keys.Count); wr.Close(); return(dic); }
public override Dictionary <string, protInfo> GetProfile(profileNode node, string listFile, DCDFile dcd = null) { Dictionary <string, protInfo> dic = null; StreamReader wr; DebugClass.WriteMessage("start reading file" + listFile); string useFile = listFile; List <string> names = GetFileList(listFile); if (names == null) { DebugClass.WriteMessage("After GetFileList null"); } else { DebugClass.WriteMessage("After GetFileList " + names.Count); } maxV = names.Count; Dictionary <string, int> dicNames = new Dictionary <string, int>(names.Count); foreach (var item in names) { string[] aux = item.Split(Path.DirectorySeparatorChar); if (!dicNames.ContainsKey(aux[aux.Length - 1])) { dicNames.Add(aux[aux.Length - 1], 0); } } DebugClass.WriteMessage("After loop"); string[] dotFlag = names[0].Split('|'); bool flag = false; if (dotFlag.Length == 2) { flag = true; } DebugClass.WriteMessage("Before profile"); if (dcd == null) { wr = new StreamReader(GetProfileFileName(listFile)); } else { wr = new StreamReader(GetProfileFileName(dcd)); } DebugClass.WriteMessage("start ddd reading"); protInfo info; string line = wr.ReadLine(); string name = ""; string seq = ""; List <string> profile;; List <byte> newProfile = null; string profileName; if (node.ContainsState("H")) { profileName = ssProfile; } else { profileName = contactProfile; } //Check number of elements in file int lineLength = 0; while (line != null) { if (lineLength < line.Length) { lineLength = line.Length; } line = wr.ReadLine(); } wr.BaseStream.Position = 0; wr.DiscardBufferedData(); profile = new List <string>(lineLength); dic = new Dictionary <string, protInfo>(names.Count); line = wr.ReadLine(); string remName = ""; DebugClass.WriteMessage("Starrrrr"); while (line != null) { if (line[0] == '>') { if (name.Length > 0) { if (dicNames.ContainsKey(name)) { info = new protInfo(); info.sequence = seq; info.profile = newProfile; //string newName = line; //newName = newName.Remove(0, 1); if (!dic.ContainsKey(remName)) { dic.Add(remName, info); } else { ErrorBase.AddErrors("!!In the generated profile file structure " + remName + " exists more then once!!!\nOnly the first profile will be considered!"); } currentProgress++; } } name = line.Remove(0, 1); remName = name; if (name.Contains("|") && !flag) { string[] tmp = name.Split('|'); name = tmp[0]; } } if (dicNames.ContainsKey(name)) { if (line.Contains(SEQprofile)) { seq = line.Remove(0, SEQprofile.Length); } else if (line.Contains(profileName)) { //StringBuilder tmp = new StringBuilder(line); line = line.Remove(0, profileName.Length); //tmp = tmp.Remove(0, profileName.Length); //StringBuilder tmp = new StringBuilder (line.Remove(0, profileName.Length)); string[] aux; if (line.Contains(' ')) { aux = line.Split(' '); } else { aux = new string[line.Length]; for (int i = 0; i < line.Length; i++) { aux[i] = line[i].ToString(); } } newProfile = CreateNewProfile(node, aux); } } line = wr.ReadLine(); } if (dicNames.ContainsKey(name)) { info = new protInfo(); info.sequence = seq; info.profile = newProfile; dic.Add(remName, info); } wr.Close(); DebugClass.WriteMessage("Reading finished"); return(dic); }
public CosineDistance(DCDFile dcd, string alignFile, bool flag, string profileName, string refJuryProfile = null) :base(dcd, alignFile, flag, profileName, refJuryProfile) { }
public MaxSub(DCDFile dcd, string alignFile, bool flag, string refJuryProfile = null) : base(dcd, alignFile, flag, PDBMODE.ONLY_CA, refJuryProfile) { order = true; maxSimilarity = 0.0; }
public override Dictionary<string, protInfo> GetProfile(profileNode node, string fileName, DCDFile dcd) { Dictionary<string, protInfo> dic = new Dictionary<string, protInfo>(); StreamReader wr; DebugClass.WriteMessage("profile" + fileName); wr = new StreamReader(fileName); protInfo info; string line = wr.ReadLine(); string name = ""; string seq = ""; List<string> profile = new List<string>(); List<byte> newProfile = new List<byte>(); while (line != null) { if (line.Contains(">")) { if (name.Length > 0) { info = new protInfo(); info.sequence = null; info.profile = newProfile; dic.Add(name, info); } name = line.Replace(">", ""); line = wr.ReadLine(); } if (line.Contains(node.profName+" ")) { string cLine=line.Remove(0, (node.profName+" profile ").Length); cLine = Regex.Replace(cLine, @"\s+", " "); cLine = cLine.Trim(); string[] aux; if (cLine.Contains(' ')) aux = cLine.Split(' '); else { char[] charArray = cLine.ToCharArray(); aux = cLine.Select(x => x.ToString()).ToArray(); } profile.Clear(); foreach (var item in aux) profile.Add(item); newProfile = new List<byte>(); for (int i = 0; i < profile.Count; i++) if (node.ContainsState(profile[i].ToString())) newProfile.Add(node.GetCodedState(node.states[profile[i].ToString()])); else if(profile[i].ToString()!="-" && profile[i].ToString()!="X") throw new Exception("Unknow state " + profile[i].ToString() + " in "+ node.profName + " profile!"); else newProfile.Add(0); } line = wr.ReadLine(); } info = new protInfo(); info.sequence = seq; info.profile = newProfile; dic.Add(name, info); DebugClass.WriteMessage("number of profiles " + dic.Keys.Count); wr.Close(); return dic; }
public override Dictionary <string, protInfo> GetProfile(profileNode node, string fileName, DCDFile dcd = null) { Dictionary <string, protInfo> dic = new Dictionary <string, protInfo>(); currentProgress = 0; if (!File.Exists(GetProfileFileName(fileName))) { throw new Exception("Profile rnaSS does not exists!"); } string profileName; if (node.ContainsState("+")) { profileName = LWprofile; } else { profileName = SSprofile; } StreamReader wr = new StreamReader(GetProfileFileName(fileName)); List <string> files = GetFileList(fileName); maxV = files.Count; Dictionary <string, int> dicFile = new Dictionary <string, int>(); foreach (var item in files) { string[] aux = item.Split(Path.DirectorySeparatorChar); if (!dicFile.ContainsKey(aux[aux.Length - 1])) { dicFile.Add(aux[aux.Length - 1], 0); } } protInfo info; string line = wr.ReadLine(); string name = ""; string seq = ""; List <string> profile = new List <string>(); List <byte> newProfile = new List <byte>(); while (line != null) { if (line.Contains('>')) { if (name.Length > 0) { info = new protInfo(); info.sequence = seq; info.profile = newProfile; if (dicFile.ContainsKey(name)) { if (!dic.ContainsKey(name)) { dic.Add(name, info); } else { ErrorBase.AddErrors("There are two the same names " + name + " in the profile file " + GetProfileFileName(fileName)); } } currentProgress++; } name = line.Remove(0, 1); } if (line.Contains(SEQprofile)) { seq = line.Remove(0, SEQprofile.Length); } if (line.Contains(profileName)) { string tmp = line.Remove(0, profileName.Length); string[] aux; profile.Clear(); if (tmp.Contains(" ")) { tmp = tmp.TrimEnd(); aux = tmp.Split(' '); foreach (var item in aux) { profile.Add(item); } } else { for (int i = 0; i < tmp.Length; i++) { profile.Add(tmp[i].ToString()); } } newProfile = new List <byte>(); for (int i = 0; i < profile.Count; i++) { if (node.ContainsState(profile[i].ToString())) { newProfile.Add(node.GetCodedState(node.states[profile[i].ToString()])); } else if (profile[i].ToString() != "-" && profile[i].ToString() != "X") { throw new Exception("Unknow state: " + profile[i].ToString() + " in structure " + name + " in profile " + node.profName + " profile!"); } else { newProfile.Add(0); } } } line = wr.ReadLine(); } info = new protInfo(); info.sequence = seq; info.profile = newProfile; if (!dic.ContainsKey(name)) { dic.Add(name, info); } else { ErrorBase.AddErrors("There are two the same names " + name + " in the profile file " + GetProfileFileName(fileName)); } wr.Close(); currentProgress = maxV; return(dic); }