package impl.contig_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 listCDS_NCBI_NT extends Sight.Agents.Prototypes.signatureBasedAgent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Id="NT_005513";
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?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,"NT_005513") }
);
}
public static class Record extends Sight.Record implements Serializable {
public CharSequence Gene;
public CharSequence Header;
public CharSequence Id;
};
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.Gene+" "+r.Id+" ";
case 1: return ""+r.Gene+" "+r.Header+" "+r.Id+" ";
default: return ""+" : "+r.Gene+" "+" : "+r.Header+" "+" : "+r.Id+" ";
}
};
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("Gene","CharSequence",null,""),
new dField("Header","CharSequence",null,""),
new dField("Id","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.Gene=fields[0];
r.Header=fields[1];
r.Id=fields[2];
return r;
};
public Sight.Result resultFromString(String html) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(html);
return r;
};
public listCDS_NCBI_NT() { signatures = new multiSignatures();
signatures.far_start=null;
signatures.top=null;
signatures.bottom=null;
signatures.signatures =
new Signature[] {
new Signature("/gene=\"","\""),
new Signature(" /product=\"","\""),
new Signature("/protein_id=\"","\"")
};
setDescription("Get list of coding sequences for the given NCBI contig");
setFormURL("http://www.ncbi.nlm.nih.gov/entrez/");
setMasterURL("http://www.ncbi.nlm.nih.gov/entrez/");
preScan = new preScan();
};
public static listCDS_NCBI_NT Public = new listCDS_NCBI_NT();
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();
};
}
;
}