package impl.sequence_readers;
import Sight.Agents.*;
import Sight.Agents.Redirectors.*;
import Sight.Structures.*;
import Sight.dds.*;
import Sight.tools.xSignature.*;
import java.io.*;
import Sight.Agents.util.*;
public class fastaReaderEnsembl extends Sight.Agents.Prototypes.signatureBasedAgent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Id="ENSP00000296184";
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.ensembl.org/Homo_sapiens/"); map.add("connect:action", "get"); map.add("url:prefix", "http://www.ensembl.org/Homo_sapiens/protview?peptide="); map.add("url:suffix", ""); return map; };
public static Request getDefaultRequest() {
return Public.getRequest(); }
private Request getRequest() { return new Request(); };
public String getFormURL() {
return ""; }
public String getMasterURL() {
return "http://www.ensembl.org/Homo_sapiens/"; }
public dStructure getRequestDds() {
return new Sight.dds.Records(false,
new dField[] {
new dField("Id","CharSequence",null,"ENSP00000296184") }
);
}
public static class Record extends Sight.Record implements Serializable {
public CharSequence Id;
public CharSequence Sequence;
public CharSequence Length;
public CharSequence Mw;
public CharSequence Pi;
};
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.Id+" "+r.Length+" ";
case 1: return ""+r.Id+" "+r.Length+" "+r.Mw+" "+r.Pi+" ";
default: return r.Id+"<br><textarea rows=\"3\" cols=\"80\">"+
r.Sequence+"</textarea>";
}
};
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("Id","CharSequence",null,""),
new dField("Sequence","CharSequence",null,""),
new dField("Length","CharSequence",null,""),
new dField("Mw","CharSequence",null,""),
new dField("Pi","CharSequence",null,"") }
);
}
public Sight.Record createRecord(String[] row) throws Exception
{ return fillRecord(row); };
public Class getRecordClass() { return Record.class; };
Record fillRecord(String[] fields) throws Exception {
Record r = new Record();
r.Id=fields[0];
r.Sequence=getPlainSequence(noHtml(fields[1]));
r.Length=fields[2];
r.Mw=fields[3];
r.Pi=fields[4];
return r;
};
public Sight.Result resultFromString(String html) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(html);
return r;
};
public fastaReaderEnsembl() { signatures = new multiSignatures();
signatures.errorCases = new String[] { "Ensembl Services Unavailable" };
signatures.far_start="<TD><B>Peptide sequence</B></TD>";
signatures.top=null;
signatures.bottom=" <FORM";
signatures.signatures =
new Signature[] {
new Signature("\n\t<TR>\n\t <TD valign=\"top\"><BR><tt><small>>","<br />"),
new Signature("<br />","</small></tt><br /></TD>\n\t <td valign=\"top\">\n\t\t<BR><B>Residues:</B>"),
new Signature("</small></tt><br /></TD>\n\t <td valign=\"top\">\n\t\t<BR><B>Residues:</B>","<BR><B>MW:</B> "),
new Signature("<BR><B>MW:</B> ","<BR>\n<B>Avg. Res. Wt.:</B>"),
new Signature("<BR>\n<B>pI:</B> ","<BR>\n")
};
setDescription("Read sequences using Ensembl identifier");
preScan = new preScan();
};
public static fastaReaderEnsembl Public = new fastaReaderEnsembl();
public static Agent getAvailableAgent() { return Public; };
public static void main(String[] args) {
Sight.Agents.util.Pind.showConsoles();
try {
Request request = getDefaultRequest();
Sight.Agents.Request submission = request.submit();
Result response = (Result) submission.getResult();
System.out.println(response.getReport(2));
} catch (Exception exc)
{ if (exc!=null) System.out.println(exc.getMessage());
exc.printStackTrace();
};
}
;
}