package impl.dna_analysers;
import Sight.*;
import Sight.Agents.*;
import Sight.Structures.*;
import Sight.dds.*;
import java.io.*;
import Sight.Agents.util.*;
public class E_PCR extends Sight.Agents.Prototypes.tableBasedAgent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Ntseq;
public String Sts_set="non_warn";
public String W="7";
public String M="10";
public String N="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:master", "http://www.ncbi.nlm.nih.gov/genome/sts/epcr.cgi"); map.add("connect:url", "http://www.ncbi.nlm.nih.gov/genome/sts/epcr.cgi"); map.add("connect:action", "Post"); map.add("NTSEQ", request.Ntseq); map.add("STS_SET", request.Sts_set); map.add("W", request.W); map.add("M", request.M); map.add("N", request.N); return map; };
public static Request getDefaultRequest() {
return Public.getRequest(); }
private Request getRequest() { return new Request(); };
public String getFormURL() {
return "http://www.ncbi.nlm.nih.gov/genome/sts/epcr.cgi"; }
public String getMasterURL() {
return "http://www.ncbi.nlm.nih.gov/genome/sts/epcr.cgi"; }
public dStructure getRequestDds() {
return new Sight.dds.Records(false,
new dField[] {
new dField("Ntseq","CharSequence","DNA/RNA sequence or NCBI accession number",""),
new dField("Sts_set","CharSequence","Return repetetive markers or not","non_warn",new String[] {"unists","non_warn"},new String[] {"all markers","non-repetitive markers default"}),
new dField("W","CharSequence","Required match area","7",new String[] {"3","4","5","6","7","8"},new String[] {"3","4","5","6","7 default","8"}),
new dField("M","CharSequence","An e-PCR product size to be within M bases margin of the previously reported PCR product size. ","10",new String[] {"0","10","50","100","500","1000","5000"},new String[] {"0","10 default","50","100","500","1000","5000"}),
new dField("N","CharSequence","Allowed mismatches, but not in the word size area.","1",new String[] {"0","1","2","3"},new String[] {"0","1 default","2","3"}) }
);
}
public static class Record extends Sight.Record implements Serializable {
public s_feature region;
public CharSequence marker;
public CharSequence marker_url;
public CharSequence chromosome;
public CharSequence organism;
};
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.marker_url+"\">"+r.marker+"</a>" +r.chromosome+" ";
case 1: return ""+r.region+" "+" <a href=\""+r.marker_url+"\">"+r.marker+"</a>" +r.chromosome+" ";
default: return ""+" region:" +r.region+" "+" :" +" <a href=\""+r.marker_url+"\">"+r.marker+"</a> "+" :" +r.chromosome+" "+" organism:" +r.organism+" ";
}
};
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("region",null,"region",""),
new dField("marker",null,null,""),
new dField("marker url","URL","marker url ",""),
new dField("chromosome",null,null,""),
new dField("organism",null,"organism","") }
);
}
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.region=new s_feature(fields[0]);
r.marker=noHtml(fields[1]);
r.marker_url=getURL(fields[1]);
r.chromosome=fields[2];
r.organism=fields[3];
return r;
};
public Sight.Result resultFromString(String html) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(html);
return r;
};
public E_PCR() { ignoreFirstLine=true;
ignoreLastLine =false;
table_position ="2.3";
setDescription("NCBI electronic PCR");
};
public static E_PCR Public = new E_PCR();
public static Agent getAvailableAgent() { return Public; };
public static void main(String[] args) {
Sight.Agents.util.Pind.showConsoles();
try {
Request request = getDefaultRequest();
request. Ntseq="AC018608";
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();
};
}
;
}