package impl.sequence_readers;
import Sight.Agents.*;
import Sight.Agents.Redirectors.*;
import Sight.Structures.*;
import Sight.dds.*;
import java.io.*;
import org.w3c.dom.*;
public class xmlReaderNCBI extends Sight.Agents.Prototypes.xml_based_agent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Id="NM_000068";
public Sight.Agents.Request submit() { return Sight.Agents.Request.submit(Public, this, getKey()); };
public Sight.Agents.Request submit(String key)
{ return Sight.Agents.Request.submit(Public, this, key); };
};
protected AMap getFormParameters(Object req) {
Request request = (Request) req;
AMap map = new AMap();
map.add("url:identifier", request.Id); map.add("connect:master", "http://www.ncbi.nlm.nih.gov/entrez/"); map.add("connect:action", "get"); map.add("url:prefix", "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?view=xml&txt=on&val="); map.add("url:suffix", ""); return map; };
public static Request getDefaultRequest() {
return Public.getRequest(); }
private Request getRequest() { return new Request(); };
public dStructure getRequestDds() {
return new Sight.dds.Records(false,
new dField[] {
new dField("Id","CharSequence",null,"NM_000068") }
);
}
public static class Record extends Sight.Record implements Serializable {
public CharSequence Bioseq_set_class;
public CharSequence Bioseq_set_class_value;
public CharSequence Org_ref_taxname;
public CharSequence RNA_sequence;
public CharSequence Protein_sequence;
};
public static class Result extends Sight.Result implements Serializable {
public Record[] a;
public CharSequence getReportForRecord(Object ro, int level)
{ Record r = (Record) ro;
switch (level) {
case 0: return ""+r.Bioseq_set_class+" "+r.Bioseq_set_class_value+" "+r.Org_ref_taxname;
case 1: return ""+r.Bioseq_set_class+" "+r.Bioseq_set_class_value+" "+r.Org_ref_taxname+" RNA:"+r.RNA_sequence.length()+"bp Protein:"+r.Protein_sequence.length()+" aa";
default: return ""+" : "+r.Bioseq_set_class+" "+" : "+r.Bioseq_set_class_value+" "+" : "+r.Org_ref_taxname+" "+" : <textarea>"+r.RNA_sequence+"</textarea> "+" : <textarea>"+r.Protein_sequence+"</textarea> ";
}
};
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("Bioseq_set_class","CharSequence",null,""),
new dField("Bioseq_set_class_value","CharSequence",null,""),
new dField("Org_ref_taxname","CharSequence",null,""),
new dField("RNA_sequence","CharSequence",null,""),
new dField("Protein_sequence","CharSequence",null,"") }
);
}
public Sight.Record createRecord(Node xml)
{
Record r = new Record();
r. Bioseq_set_class = getXMLField("Bioseq-set_class", xml);
r. Bioseq_set_class_value = getXMLField("Bioseq-set_class&value", xml);
r. Org_ref_taxname = getXMLField("Org-ref_taxname", xml);
r. RNA_sequence = getXMLField("IUPACna", xml);
r. Protein_sequence = getXMLField("NCBIeaa", xml);
return r;
};
public static void main(String[] args) {
try {
Request request = getDefaultRequest();
Sight.Agents.Request submission = request.submit();
Result response = (Result) submission.getResult();
try {
String html = xmlReaderNCBI .getAvailableAgent().getReport(response, 2);
System.out.println("Report: "+html);
}
catch (java.lang.UnsupportedOperationException ui)
{ System.out.println(ui.getMessage()); };
} catch (Exception exc)
{ if (exc!=null) System.out.println(exc.getMessage());
exc.printStackTrace();
};
}
public xmlReaderNCBI() {
setDescription("Reads the sequence decription in XML. This reader gets more information about the sequence, but downloads much larger files.");
setFormURL("http://www.ncbi.nlm.nih.gov/entrez/");
setMasterURL("http://www.ncbi.nlm.nih.gov/entrez/");
preScan = new preScan();
cn_maxConnectionLength = 80000000; }
public static xmlReaderNCBI Public = new xmlReaderNCBI();
public static Agent getAvailableAgent() { return Public; };
public Class getRecordClass() { return Record.class; };
public Sight.Result resultFromDocument(Document node) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(node);
return r;
};
public String getXSLT() {
return getXMLFromSelf("Sight:xml-xsl-insert-1");
};
}