private void Abstract_Load(object sender, EventArgs e) { this.Text = name; if (id == null) { abstractBox.Text = "There were no abstracts found"; return; } string datapage = EutilsURLBuilder.getFile("pubmed", id, "text", "abstract"); System.Net.WebRequest request = WebRequest.Create(datapage); WebResponse response; try { response = request.GetResponse(); } catch { abstractBox.Text = "There were errors accessing the abstract page."; return; } Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string abr = reader.ReadToEnd(); abstractBox.Text = abr.Replace("\n", "\r\n"); reader.Close(); response.Close(); }
private void Get_Page(string id) { // get page from ID string datapage = EutilsURLBuilder.getFile("nucleotide", id, "gb", "xml"); Console.WriteLine(datapage); WebRequest request = WebRequest.Create(datapage); WebResponse response; try { response = request.GetResponse(); } catch { Console.WriteLine("There was an error accessing the web utilities."); return; } Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string responseFromServer = reader.ReadToEnd(); Console.WriteLine(responseFromServer); reader.Close(); response.Close(); // get name & location & put in vector prevSEQ = curSEQ; curSEQ = new Sequence(new XmlTextReader(new StringReader(responseFromServer))); listitems.Clear(); foreach (Sequence.feature feat in curSEQ.featurelist) { listitems.Add(feat.name); } featureListBox.DataSource = listitems; SetTitles(); graphstart = 1; viewer.On(); isSeqView = true; Refresh(); }
private void get_page_Click(object sender, EventArgs e) { viewer.Off(); isSeqView = false; Control[] boxArray = { Accession, Organism, Feature_key, dropDown, All_fields }; WebRequest id_request = WebRequest.Create(EutilsURLBuilder.makeQueryURL(boxArray, "nucleotide", 30)); WebResponse id_response = null; try { id_response = id_request.GetResponse(); } catch { Console.WriteLine("There was an error accessing the web utilities."); return; } Stream id_dataStream = id_response.GetResponseStream(); StreamReader id_reader = new StreamReader(id_dataStream); string id_responseFromServer = id_reader.ReadToEnd(); id_reader.Close(); id_response.Close(); Match id_matches = Regex.Match(id_responseFromServer, "<Id>(\\d+)</Id>"); XmlTextReader id_read = new XmlTextReader(new StringReader(id_responseFromServer)); string thisName = ""; List <string> ids = new List <string>(); while (id_read.Read()) { if (id_read.NodeType == XmlNodeType.Element) { thisName = id_read.Name; } else if (id_read.NodeType == XmlNodeType.Text && thisName == "Id") { ids.Add(id_read.Value); } else if (id_read.NodeType == XmlNodeType.Text && thisName == "ERROR") { Console.WriteLine("There was an error accessing the web utilities."); } } WebRequest sum_request = WebRequest.Create(EutilsURLBuilder.getSummary("nucleotide", ids)); WebResponse sum_response = null; try { sum_response = sum_request.GetResponse(); } catch { Console.WriteLine("There was an error accessing the web utilities."); return; } Stream sum_dataStream = sum_response.GetResponseStream(); StreamReader sum_reader = new StreamReader(sum_dataStream); string sum_responseFromServer = sum_reader.ReadToEnd(); sum_reader.Close(); sum_response.Close(); view_list.SetFound(new XmlTextReader(new StringReader(sum_responseFromServer))); view_list.On(); }