package impl.protein_analysers;
import Sight.Agents.*;
import Sight.Agents.Redirectors.*;
import Sight.Structures.*;
import Sight.dds.*;
import java.io.*;
import Sight.Agents.util.*;
public class InterPro extends Sight.Agents.Prototypes.tableBasedAgent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Sequence;
public String Emaddr="q@q.q";
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("connect:url", "http://srs.ebi.ac.uk/srs6bin/cgi-bin/subiprscan"); map.add("connect:action", "POST"); map.add("connect:master", "http://www.ebi.ac.uk/interpro/scan.html"); map.add("qstr", "goaway"); map.add("sequence", request.Sequence); map.add("runtype", "interactive"); map.add("sndmail", "0"); map.add("emaddr", request.Emaddr); return map; };
public static Request getDefaultRequest() {
return Public.getRequest(); }
private Request getRequest() { return new Request(); };
public String getFormURL() {
return "http://srs.ebi.ac.uk/srs6bin/cgi-bin/subiprscan"; }
public String getMasterURL() {
return "http://www.ebi.ac.uk/interpro/scan.html"; }
public dStructure getRequestDds() {
return new Sight.dds.Records(false,
new dField[] {
new dField("Sequence","CharSequence",null,""),
new dField("Emaddr","CharSequence",null,"q@q.q") }
);
}
public static class Record extends Sight.Record implements Serializable {
public CharSequence Hit;
public CharSequence Url;
};
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 ""+" <a href=\""+r.Url+"\"> "+r.Hit+"</a>" ;
case 1: return ""+" <a href=\""+r.Url+"\"> "+r.Hit+"</a>" ;
default: return ""+" :" +" <a href=\""+r.Url+"\"> "+r.Hit+"</a> ";
}
};
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("Hit",null,null,""),
new dField("Url","URL","Hit url ","") }
);
}
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.Hit=noHtml(fields[0]);
r.Url=getURL(fields[0]);
return r;
};
public Sight.Result resultFromString(String html) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(html);
return r;
};
public InterPro() { ignoreFirstLine=false;
ignoreLastLine =false;
table_position ="3.2.1";
setDescription("Integrated search in PROSITE, Pfam, PRINTS and other family and domain databases");
preScan = new preScan();
addRedirector(new RedirWaitLonger());
};
public static InterPro Public = new InterPro();
public static Agent getAvailableAgent() { return Public; };
public static void main(String[] args) {
Sight.Agents.util.Pind.showConsoles();
try {
Request request = getDefaultRequest();
request. Sequence="MPSSGRALLDSPLDSGSLTSLDSSVFCSEGEGEPLALGDCFTVNVGGSRFVLSQQALSCFPHTRLGKLAVVVASYRRPGALAAVPSPLELCDDANPVDNEYFFDRSSQAFRYVLHYYRTGRLHVMEQLCALSFLQEIQYWGIDELSIDSCCRDRYFRRKELSETLDFKKDTEDQESQHESEQDFSQGPCPTVRQKLWNILEKPGSSTAARIFGVISIIFVVVSIINMALMSAELSWLDLQLLEILEYVCISWFTGEFVLRFLCVRDRCRFLRKVPNIIDLLAILPFYITLLVESLSGSQTTQELENVGRIVQVLRLLRALRMLKLGRHSTGLRSLGMTITQCYEEVGLLLLFLSVGISIFSTVEYFAEQSIPDTTFTSVPCAWWWATTSMTTVGYGDIRPDTTTGKIVAFMCILSGILVLALPIAIINDRFSACYFTLKLKEAAVRQREALKKLTKNIATDSYISVNLRDVYARSIMEMLRLKGRERASTRSSGGDDFWF";
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();
};
};
static class RedirWaitLonger extends Sight.Agents.Redirectors.RedirectionSystem implements RedirectionProvider, Cloneable
{
public Redirection getRedirection(String text)
{
Redirection R = super.getRedirection(text);
if (R!=null)
{
if (R.waitFor<55) R.waitFor = 55;
R.explain="Wait longer (55s). "+R.explain;
};
return R;
};
public RedirectionProvider getCopy()
{
return this;
}
}
}