public override void AddInternalProfiles() { profileNode node = new profileNode(); node.profName = ProfileName; node.internalName = ProfileName; InternalProfilesManager.AddNodeToList(node, typeof(UserDefinedProfile).FullName); }
public bool CheckAccessibility(profileNode profile, INPUTMODE type) { Type t = Type.GetType(internalList[profile]); InternalProfileBase c = Activator.CreateInstance(t) as InternalProfileBase; if (c.destination.Contains(type)) { return(true); } return(false); }
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 static void AddNodeToList(profileNode node, string type) { profileNode nn = GetNode(node.internalName); if (nn == null) { if (!internalList.ContainsKey(node)) { internalList.Add(node, type); SaveProfiles(); } } }
public override void AddInternalProfiles() { profileNode node = new profileNode(); node.profName = profileName; node.internalName = profileName; node.AddStateItem("0", "0"); node.AddStateItem("1", "1"); node.AddStateItem("2", "2"); node.AddStateItem("3", "3"); InternalProfilesManager.AddNodeToList(node, typeof(ContactMapProfileRNA).FullName); }
public override void AddInternalProfiles() { profileNode node = new profileNode(); node.profName = profileName; node.internalName = profileName; for (int i = 0; i < 255; i++) { node.AddStateItem(i.ToString(), i.ToString(), true); } InternalProfilesManager.AddNodeToList(node, typeof(FragBagProfile).FullName); }
public void RunProfile(string name, string listFile) { 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.RunThreads(listFile); progressInfo = null; progress++; } }
public InternalProfileForm(profileNode node,filterOPT filter,bool flag=true) { InitializeComponent(); if(filter==filterOPT.SIMILARITY) { button4.Visible = false; button3.Visible = true; } else { button4.Visible = true; button3.Visible = false; } if (node == null) return; if(node.internalName==UserDefinedProfile.ProfileName) dataGridView1.Columns["Column1"].ReadOnly = false; else dataGridView1.Columns["Column1"].ReadOnly = flag; localNode.profProgram = node.profProgram; localNode.internalName = node.internalName; textBox1.Text = node.profName; if (node.GetNumberofStates()> 0) { dataGridView1.Rows.Add(node.GetNumberofStates()); int i = 0; foreach (var item in node.states) { dataGridView1.Rows[i].Cells[0].Value = item.Key; dataGridView1.Rows[i++].Cells[1].Value = item.Value; } foreach (var item in node.profWeights.Keys) { foreach (var item2 in node.profWeights[item].Keys) { dataGridView2.Rows.Add(1); int index = dataGridView2.Rows.Count - 2; dataGridView2.Rows[index].Cells[0].Value = item; dataGridView2.Rows[index].Cells[1].Value = item2; dataGridView2.Rows[index].Cells[2].Value = node.profWeights[item][item2].ToString(); } } } }
public Dictionary <string, protInfo> GetProfile(profileNode node, string listFile) { profileNode n = GetNode(node.internalName); if (n != null) { Type t = Type.GetType(internalList[n]); InternalProfileBase c = Activator.CreateInstance(t) as InternalProfileBase; progressInfo = c; Dictionary <string, protInfo> res = c.GetProfile(node, listFile, null); progressInfo = null; progress++; return(res); } return(null); }
public virtual List <byte> CreateNewProfile(profileNode node, string [] profile) { List <byte> newProfile = new List <byte>(profile.Length); for (int i = 0; i < profile.Length; i++) { string state = profile[i]; if (node.ContainsState(state)) { newProfile.Add(node.GetCodedState(node.states[state])); } else { ErrorBase.AddErrors("Unknow state " + state + " in " + node.profName + " profile!"); } } return(newProfile); }
public override void AddInternalProfiles() { profileNode node = new profileNode(); node.profName = "Contact"; node.internalName = "Contact"; for (int i = 0; i < 10; i++) { node.AddStateItem(i.ToString(), i.ToString()); } //manager.AddNodeToList(node, "P"); node.AddStateItem("T", "T"); node.AddStateItem("C", "C"); node.AddStateItem("P", "P"); node.AddStateItem("H", "H"); node.AddStateItem("E", "E"); InternalProfilesManager.AddNodeToList(node, typeof(ContactProfile).FullName); }
public ProfileDefinitionForm(profileNode profile) { InitializeComponent(); this.profile = profile; textBox1.Text = profile.profName; textBox2.Text = profile.profProgram; textBox3.Text = profile.OutFileName; if (profile.progParameters == null) profile.progParameters = "input_file"; textBox4.Text = profile.progParameters; checkBox1.Checked = profile.removeOutFile; foreach (var item in profile.profWeights.Keys) { foreach (var item2 in profile.profWeights[item].Keys) { dataGridView1.Rows.Add(); dataGridView1.Rows[dataGridView1.Rows.Count-2].Cells[0].Value = item; dataGridView1.Rows[dataGridView1.Rows.Count-2].Cells[1].Value = item2; dataGridView1.Rows[dataGridView1.Rows.Count-2].Cells[2].Value = profile.profWeights[item][item2].ToString(); } } }
public ProfileDefinitionForm(profileNode profile) { InitializeComponent(); this.profile = profile; textBox1.Text = profile.profName; textBox2.Text = profile.profProgram; textBox3.Text = profile.OutFileName; if (profile.progParameters == null) { profile.progParameters = "input_file"; } textBox4.Text = profile.progParameters; checkBox1.Checked = profile.removeOutFile; foreach (var item in profile.profWeights.Keys) { foreach (var item2 in profile.profWeights[item].Keys) { dataGridView1.Rows.Add(); dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells[0].Value = item; dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells[1].Value = item2; dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells[2].Value = profile.profWeights[item][item2].ToString(); } } }
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 void AddInternalProfiles() { profileNode node = new profileNode(); node.profName = "RNA_SS"; node.internalName = "RNA_SS"; foreach (var item in SSList) { node.AddStateItem(item, item); } InternalProfilesManager.AddNodeToList(node, typeof(RNASSProfile).FullName); node = new profileNode(); node.profName = "RNA_LW"; node.internalName = "RNA_LW"; foreach (var item in LWList) { node.AddStateItem(item, item); } InternalProfilesManager.AddNodeToList(node, typeof(RNASSProfile).FullName); }
public override void AddInternalProfiles() { profileNode node = new profileNode(); node.profName = "SS"; node.internalName = "SS"; foreach (var item in SSList) { node.AddStateItem(item, item); } InternalProfilesManager.AddNodeToList(node, typeof(DsspInternalProfile).FullName); node = new profileNode(); node.profName = "SA"; node.internalName = "SA"; for (int i = 0; i < 10; i++) { node.AddStateItem(i.ToString(), i.ToString()); } InternalProfilesManager.AddNodeToList(node, typeof(DsspInternalProfile).FullName); }
public override void AddInternalProfiles() { profileNode node = new profileNode(); node.profName = "Contact"; node.internalName = "Contact"; for (int i = 0; i < 10; i++) node.AddStateItem(i.ToString(), i.ToString()); //manager.AddNodeToList(node, "P"); node.AddStateItem("T", "T"); node.AddStateItem("C", "C"); node.AddStateItem("P", "P"); node.AddStateItem("H", "H"); node.AddStateItem("E", "E"); InternalProfilesManager.AddNodeToList(node, typeof(ContactProfile).FullName); }
public static ProfileTree AnalyseProfileFile(string fileName, SIMDIST similarityFlag, string internalName = null) { ProfileTree t = new ProfileTree(); StreamReader wr; if (fileName == null || !File.Exists(fileName)) { throw new Exception("File:" + fileName + " not exists"); } wr = new StreamReader(fileName); string line = wr.ReadLine(); Dictionary <string, Dictionary <string, int> > dic = new Dictionary <string, Dictionary <string, int> >(); while (line != null) { if (line.Contains(">")) { line = wr.ReadLine(); while (line != null && line[0] != '>') { if (line.Contains("profile") && !line.Contains("SEQ")) { string[] tmp = line.Split(new string[] { " profile " }, StringSplitOptions.None); if (!dic.ContainsKey(tmp[0])) { dic.Add(tmp[0], new Dictionary <string, int>()); } string[] aux; if (tmp[1].Contains(" ")) { aux = tmp[1].Split(' '); } else { aux = new string[tmp[1].Length]; for (int i = 0; i < tmp[1].Length; i++) { aux[i] = tmp[1][i].ToString(); } } foreach (var item in aux) { if (item != "-" && item != "") { if (!dic[tmp[0]].ContainsKey(item)) { dic[tmp[0]].Add(item, 0); } } } } line = wr.ReadLine(); } } else { line = wr.ReadLine(); } } wr.Close(); if (dic.Keys.Count == 0) { throw new Exception("File " + fileName + " is not valid Profile file!"); } foreach (var item in dic) { profileNode node = new profileNode(); node.active = true; if (internalName != null) { node.internalName = internalName; } else { node.internalName = "User defined profile"; } node.profName = item.Key; foreach (var itemK in item.Value) { node.AddStateItem(itemK.Key, itemK.Key); } node.profWeights = GenerateWeights(new List <string>(item.Value.Keys), similarityFlag); t.AdddNode("/", node); } // t.pr return(t); }
public ProfileDefinitionForm() { InitializeComponent(); profile = new profileNode(); }
abstract public Dictionary <string, protInfo> GetProfile(profileNode node, string listFile, DCDFile dcd);
abstract public Dictionary<string, protInfo> GetProfile(profileNode node, string listFile,DCDFile dcd);
public Dictionary<string, protInfo> GetProfile(profileNode node,string listFile) { profileNode n=GetNode(node.internalName); if (n != null) { Type t = Type.GetType(internalList[n]); InternalProfileBase c = Activator.CreateInstance(t) as InternalProfileBase; progressInfo = c; Dictionary<string, protInfo> res = c.GetProfile(node, listFile, null); progressInfo = null; progress++; return res; } return null; }
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 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 static ProfileTree AnalyseProfileFile(string fileName, SIMDIST similarityFlag) { ProfileTree t = new ProfileTree(); StreamReader wr; if (fileName == null || !File.Exists(fileName)) throw new Exception("File:" + fileName + " not exists"); wr = new StreamReader(fileName); string line = wr.ReadLine(); Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>(); while (line != null) { if (line.Contains(">")) { line = wr.ReadLine(); while (line != null && line[0] != '>') { if (line.Contains("profile") && !line.Contains("SEQ")) { string[] tmp = line.Split(new string[] { " profile " }, StringSplitOptions.None); if (!dic.ContainsKey(tmp[0])) dic.Add(tmp[0], new Dictionary<string, int>()); string[] aux; if (tmp[1].Contains(" ")) aux = tmp[1].Split(' '); else { aux = new string[tmp[1].Length]; for (int i = 0; i < tmp[1].Length; i++) aux[i] = tmp[1][i].ToString(); } foreach (var item in aux) if (item != "-" && item!="") if (!dic[tmp[0]].ContainsKey(item)) dic[tmp[0]].Add(item, 0); } line = wr.ReadLine(); } } else line = wr.ReadLine(); } wr.Close(); if (dic.Keys.Count == 0) throw new Exception("File " + fileName + " is not valid Profile file!"); foreach (var item in dic) { profileNode node = new profileNode(); node.active = true; node.internalName = "User defined profile"; node.profName = item.Key; foreach (var itemK in item.Value) node.AddStateItem(itemK.Key, itemK.Key); node.profWeights = GenerateWeights(new List<string>(item.Value.Keys), similarityFlag); t.AdddNode("/", node); } // t.pr return t; }
public bool CheckAccessibility(profileNode profile,INPUTMODE type) { Type t = Type.GetType(internalList[profile]); InternalProfileBase c = Activator.CreateInstance(t) as InternalProfileBase; if (c.destination.Contains(type)) return true; return false; }
public static void AddNodeToList(profileNode node,string type) { profileNode nn = GetNode(node.internalName); if (nn==null) { if (!internalList.ContainsKey(node)) { internalList.Add(node, type); SaveProfiles(); } } }
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 virtual List<byte> CreateNewProfile(profileNode node,string [] profile) { List <byte>newProfile = new List<byte>(profile.Length); for (int i = 0; i < profile.Length; i++) { string state = profile[i]; if (node.ContainsState(state)) newProfile.Add(node.GetCodedState(node.states[state])); else ErrorBase.AddErrors("Unknow state " + state + " in " + node.profName + " profile!"); } return newProfile; }
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 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; }
private void EditProfile(string Path, bool edit, profileType type) { ProfileDefinitionForm profDef = null; InternalProfileForm internalDef = null; profileNode node = null; profileNode newNode = null; DialogResult res = DialogResult.Cancel; if (edit) { node = treeProfiles.FindNode(Path); if (node.internalName != null) { internalDef = new InternalProfileForm(node, filter); res = internalDef.ShowDialog(); if (res == DialogResult.OK) { newNode = internalDef.localNode; toolSave.Enabled = true; toolStripButton6.Enabled = true; } } else { profDef = new ProfileDefinitionForm(node); res = profDef.ShowDialog(); if (res == DialogResult.OK) { newNode = profDef.profile; toolSave.Enabled = true; toolStripButton6.Enabled = true; } } } else { if (Path == null) { Path = "Profiles"; } if (type == profileType.EXTERNAL) { profDef = new ProfileDefinitionForm(); res = profDef.ShowDialog(); if (res == DialogResult.OK) { node = profDef.profile; node.internalName = null; toolSave.Enabled = true; toolStripButton6.Enabled = true; } } else { Settings set = new Settings(); set.Load(); InternalProfilesManager manager = new InternalProfilesManager(); List <profileNode> validProfiles = new List <profileNode>(); foreach (var item in InternalProfilesManager.internalList.Keys) { if (manager.CheckAccessibility(item, set.mode)) { validProfiles.Add(item); } } ListInternal intr = new ListInternal(validProfiles); res = intr.ShowDialog(); if (res == DialogResult.OK) { InternalProfileForm intForm; profileNode localNode = InternalProfilesManager.GetNode(intr.selectedProfile); if (localNode.profName.Contains("Load")) { intForm = new InternalProfileForm(localNode, filter, false); } else { intForm = new InternalProfileForm(localNode, filter); } res = intForm.ShowDialog(); if (res == DialogResult.OK) { node = intForm.localNode; node.profProgram = intr.selectedProfile; newNode = node; toolSave.Enabled = true; toolStripButton6.Enabled = true; } } } } if (res == DialogResult.OK) { if (node != null && File.Exists(node.OutFileName)) { File.Delete(node.OutFileName); } //profChanged = true; if (!edit) { //profChanged = true; Regex exp = new Regex("^/"); TreeNode nodeT;//= new TreeNode(profDef.profile.profName); string nPath = ""; if (Path != null) { nPath = exp.Replace(Path, ""); } if (profilesView.SelectedNode == null) { nodeT = profilesView.Nodes[0].Nodes.Add(node.profName); profilesView.Nodes[0].Expand(); } else { nodeT = profilesView.SelectedNode.Nodes.Add(node.profName); profilesView.SelectedNode.Expand(); } nodeT.Tag = newNode; Regex exp2 = new Regex("^Profiles"); Path = exp2.Replace(Path, ""); treeProfiles.AdddNode(Path, node); } else { profilesView.SelectedNode.Text = node.profName; treeProfiles.RemoveNode(Path); Regex exp2 = new Regex("^Profiles"); Path = exp2.Replace(Path, ""); treeProfiles.AdddNode(ParentPath(Path), newNode); node.CopyNode(newNode); ShowTree(); } } }
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); }
public override void AddInternalProfiles() { profileNode node = new profileNode(); node.profName = "Contact CA"; node.internalName = "Contact CA"; for (int i = 0; i < 10; i++) node.AddStateItem(i.ToString(), i.ToString()); InternalProfilesManager.AddNodeToList(node, typeof(CAProfiles).FullName); node = new profileNode(); node.profName = "SS CA"; node.internalName = "SS CA"; node.AddStateItem("H", "H"); node.AddStateItem("J", "J"); node.AddStateItem("K", "K"); node.AddStateItem("L", "L"); node.AddStateItem("E", "E"); node.AddStateItem("R", "R"); node.AddStateItem("T", "T"); node.AddStateItem("Y", "Y"); node.AddStateItem("U", "U"); node.AddStateItem("N", "N"); InternalProfilesManager.AddNodeToList(node, typeof(CAProfiles).FullName); }