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 CDD_ncbi extends Sight.Agents.Prototypes.tableBasedAgent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Datalib="oasis_sap"; public String Sequence;
public String Expect="0.01";
public String Smode="0";
public String Nhits="50";
public String Graph="2";
public String Pair="2";
public String Gw="-1";
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://www.ncbi.nlm.nih.gov/Structure/cdd/wrpsb.cgi"); map.add("connect:action", "POST"); map.add("connect:master", "http://www.ncbi.nlm.nih.gov/Structure/cdd/wrpsb.cgi"); map.add("DATALIB", request.Datalib); map.add("SEQUENCE", request.Sequence); map.add("EXPECT", request.Expect); map.add("FILTER", "T"); map.add("SMODE", request.Smode); map.add("NHITS", request.Nhits); map.add("GRAPH", request.Graph); map.add("PAIR", request.Pair); map.add("GW", request.Gw); map.add("RID", ""); 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("Datalib","CharSequence","Data lib","oasis_sap",new String[] {"oasis_smart","oasis_pfam","oasis_sap"},new String[] {"Smart v3.4 - 638 PSSMs","Pfam v7.3 - 3849 PSSMs","All - 4540 PSSMs default"}),
new dField("Sequence","CharSequence","Sequence",""),
new dField("Expect","CharSequence","Expectation value","0.01",new String[] {"0.000001","0.0001","0.01","1","10","100"},new String[] {" 0.000001"," 0.0001"," 0.01 default"," 1"," 10"," 100"}),
new dField("Smode","CharSequence",null,"0",new String[] {"0","1","2"},new String[] {"Multiple hits 1-pass default","Single hit 1-pass","2-pass"}),
new dField("Nhits","CharSequence",null,"50",new String[] {"10","25","50","100","250"},new String[] {" 10 hits"," 25 hits"," 50 hits default"," 100 hits"," 250 hits"}),
new dField("Graph","CharSequence",null,"2",new String[] {"0","1","2"},new String[] {"No Graphic Overview","Condensed Graphic Overview","Extended Graphic Overview default"}),
new dField("Pair","CharSequence",null,"2",new String[] {"0","1","2"},new String[] {"Color Scheme 1","Color Scheme 2","Color Scheme 3 default"}),
new dField("Gw","CharSequence","Residue per pixel","-1",new String[] {"-5","-2","-1","1","2","5","10"},new String[] {"5 pixels per residue","2 pixels per residue","Default Width default","1 residue per pixel","2 residues per pixel","5 residues per pixel","10 residues per pixel"}) }
);
}
public static class Record extends Sight.Record implements Serializable {
public CharSequence id;
public CharSequence id_url;
public CharSequence header;
public CharSequence Bits;
public CharSequence E;
};
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.id_url+"\"> "+r.id+"</a>" +r.header+" "+r.Bits+" "+r.E+" ";
case 1: return ""+" <a href=\""+r.id_url+"\"> "+r.id+"</a>" +r.header+" "+r.Bits+" "+r.E+" ";
default: return ""+" id:" +" <a href=\""+r.id_url+"\"> "+r.id+"</a> "+" :" +r.header+" "+" Score bits:" +r.Bits+" "+" E:" +r.E+" ";
}
};
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("id",null,"id",""),
new dField("id_url","URL","id url ",""),
new dField("header",null,null,""),
new dField("Bits",null,"Score bits",""),
new dField("E",null,"E","") }
);
}
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();
if (fields.length>=5)
{
r.id=noHtml(fields[1]);
r.id_url=getURL(fields[1]);
r.header=noHtml(fields[2]);
r.Bits=noHtml(fields[3]);
r.E=fields[4];
} else
if (fields.length==4)
{
r.id=noHtml(fields[0]);
r.id_url=getURL(fields[0]);
r.header=noHtml(fields[1]);
r.Bits=noHtml(fields[2]);
r.E=fields[3];
} else
throw new Exception("At least 4 columns required.");
return r;
};
public Sight.Result resultFromString(String html) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(html);
return r;
};
public CDD_ncbi() { ignoreFirstLine=true;
ignoreLastLine =false;
table_position ="2.2";
setDescription("NCBI Conserved Domain Search");
setFormURL("http://www.ncbi.nlm.nih.gov/Structure/cdd/wrpsb.cgi");
setMasterURL("http://www.ncbi.nlm.nih.gov/Structure/cdd/wrpsb.cgi");
preScan = new preScan();
preScan.zeroCases = new String[] { "No hits found" };
};
public static CDD_ncbi Public = new CDD_ncbi();
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();
};
}
;
}