package impl.Blast;
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 Ebi_fasta extends Sight.Agents.Prototypes.signatureBasedAgent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Dbtype="Protein";
public String Database="spens-p";
public String Email="";
public String Program="fasta3";
public String Gapopen="-12";
public String Gapext="-2";
public String Scores="50";
public String Alignments="50";
public String Ktup="2";
public String Hist="no";
public String Strand="none";
public String Matrix="BL50";
public String Expupperlim="10.0";
public String Explowlim="default";
public String Seqrange="START-END";
public String Dbrange="START-END";
public String Stype="PROTEIN"; public String Sequence;
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.ebi.ac.uk/cgi-bin/fasta/genomes.pl"); map.add("connect:action", "POST"); map.add("connect:master", "http://www.ebi.ac.uk/fasta33/genomes.html"); map.add("dbtype", request.Dbtype); map.add("database", request.Database); map.add("email", request.Email); map.add("title", ""); map.add("srchtype", "interactive"); map.add("program", request.Program); map.add("gapopen", request.Gapopen); map.add("gapext", request.Gapext); map.add("scores", request.Scores); map.add("alignments", request.Alignments); map.add("ktup", request.Ktup); map.add("hist", request.Hist); map.add("strand", request.Strand); map.add("matrix", request.Matrix); map.add("expupperlim", request.Expupperlim); map.add("explowlim", request.Explowlim); map.add("seqrange", request.Seqrange); map.add("dbrange", request.Dbrange); map.add("moltype", "default"); map.add("stype", request.Stype); map.add("sequence", request.Sequence); map.add("jobid", ""); 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("Dbtype","CharSequence",null,"Protein",new String[] {"Protein","DNA"},new String[] {"Proteomes default","Genomes"}),
new dField("Database","CharSequence","Organism","spens-p",new String[] {"3702-p","6239-p","7227-p","6035-p","55529-p","9606-p","spens-p","10090-p","10090.SPEns-p","4932-p","4896-p","181661-p","180835-p","103690-p","63363-p","86665-p","1423-p","139-p","29459-p","118099-p","197-p","155892-p","83560-p","115711-p","115713-p","138677-p","813-p","1488-p","1502-p","196627-p","1299-p","83333-p","155864-p","83334-p","76856-p","727-p","85962-p","85963-p","1360-p","1642-p","1639-p","1769-p","83332-p","83331-p","2097-p","2104-p","2107-p","65699-p","491-p","747-p","287-p","305-p","381-p","382-p","781-p","782-p","601-p","602-p","158878-p","158879-p","196620-p","171101-p","170187-p","1314-p","186103-p","1902-p","1148-p","119072-p","2336-p","160-p","134821-p","666-p","92829-p","340-p","2371-p","632-p","56636-p","2234-p","64091-p","145262-p","2190-p","2320-p","2214-p","192952-p","13773-p","29292-p","2261-p","53953-p","2287-p","111955-p","2303-p","50339-p"},new String[] {"Arabidopsis thaliana","Caenorhabditis elegans","Drosophila melanogaster","Encephalitozoon cuniculi","Guillardia theta","Homo sapiens","Homo Sapiens (SpTr+Ensembl)","Mus musculus (Mouse)","Mus musculus (SpTr+Ensembl)","Saccharomyces cerevisiae","Schizosaccharomyces pombe","Agrobacterium tumefaciens (strain C58 / ATCC 33970 (Cereon))","Agrobacterium tumefaciens (strain C58 / ATCC 33970 (Washington University))","Anabaena sp. (strain PCC 7120)","Aquifex aeolicus","Bacillus halodurans","Bacillus subtilis","Borrelia burgdorferi","Brucella melitensis","Buchnera aphidicola (subsp. Acyrthosiphon pisum)","Campylobacter jejuni","Caulobacter crescentus","Chlamydia muridarum","Chlamydia pneumoniae strain AR39","Chlamydia pneumoniae strain CWL029","Chlamydia pneumoniae strain J138","Chlamydia trachomatis","Clostridium acetobutylicum","Clostridium perfringens","Corynebacterium glutamicum ATCC 13032","Deinococcus radiodurans","Escherichia coli K-12","Escherichia coli O157:H7 strain EDL933","Escherichia coli O157:H7 substrain RIMD 0509952","Fusobacterium nucleatum (subsp. nucleatum)","Haemophilus influenzae","Helicobacter pylori strain 26695","Helicobacter pylori strain J99","Lactococcus lactis (subsp. lactis)","Listeria innocua","Listeria monocytogenes","Mycobacterium leprae","Mycobacterium tuberculosis","Mycobacterium tuberculosis CDC1551","Mycoplasma genitalium","Mycoplasma pneumoniae","Mycoplasma pulmonis","Neisseria meningitidis (serogroup A)","Neisseria meningitidis (serogroup B)","Pasteurella multocida","Pseudomonas aeruginosa","Ralstonia solanacearum (Pseudomonas solanacearum)","Rhizobium loti","Rhizobium meliloti (Sinorhizobium meliloti)","Rickettsia conorii","Rickettsia prowazekii","Salmonella typhi","Salmonella typhimurium LT2","Staphylococcus aureus (strain Mu50 / ATCC 700699)","Staphylococcus aureus (strain N315)","Staphylococcus aureus MW2","Streptococcus pneumoniae R6","Streptococcus pneumoniae TIGR4","Streptococcus pyogenes","Streptococcus pyogenes (serotype M18)","Streptomyces coelicolor","Synechocystis sp. (strain PCC 6803)","Thermoanaerobacter tengcongensis","Thermotoga maritima","Treponema pallidum","Ureaplasma parvum","Vibrio cholerae","Xanthomonas axonopodis (pv. citri)","Xanthomonas campestris (pv. campestris)","Xylella fastidiosa","Yersinia pestis","Aeropyrum pernix","Archaeoglobus fulgidus","Halobacterium sp. (strain NRC-1)","Methanobacterium thermoautotrophicum","Methanococcus jannaschii","Methanopyrus kandleri","Methanosarcina acetivorans","Methanosarcina mazei Goe1","Pyrobaculum aerophilum","Pyrococcus abyssi","Pyrococcus furiosus","Pyrococcus horikoshii","Sulfolobus solfataricus","Sulfolobus tokodaii","Thermoplasma acidophilum","Thermoplasma volcanium"}),
new dField("Email","CharSequence",null,""),
new dField("Program","CharSequence",null,"fasta3",new String[] {"fasta3","fastx3","fasty3","fastf3","fasts3"},new String[] {"fasta3 default","fastx3","fasty3","fastf3","fasts3"}),
new dField("Gapopen","CharSequence",null,"-12",new String[] {"-12","-18","-16","-14","-10","-8","-6","-4","-2","0"},new String[] {"-12 default","-18","-16","-14","-10","-8","-6","-4","-2","0"}),
new dField("Gapext","CharSequence",null,"-2",new String[] {"-2","0","-4","-6","-8"},new String[] {"-2 default","0","-4","-6","-8"}),
new dField("Scores","CharSequence",null,"50",new String[] {"10","20","30","40","50","60","70","80","90","100"},new String[] {"10","20","30","40","50 default","60","70","80","90","100"}),
new dField("Alignments","CharSequence",null,"50",new String[] {"10","20","30","40","50","60","70","80","90","100"},new String[] {"10","20","30","40","50 default","60","70","80","90","100"}),
new dField("Ktup","CharSequence",null,"2",new String[] {"2","1"},new String[] {"2 default","1"}),
new dField("Hist","CharSequence",null,"no",new String[] {"no","yes"},new String[] {"no default","yes"}),
new dField("Strand","CharSequence",null,"none",new String[] {"none","none"},new String[] {"none default","none"}),
new dField("Matrix","CharSequence",null,"BL50",new String[] {"BL50","BL62","BL80","P120","P250","M10","M20","M40"},new String[] {"BLOSUM50 default","BLOSUM62","BLOSUM80","PAM120","PAM250","MDM10","MDM20","MDM40"}),
new dField("Expupperlim","CharSequence",null,"10.0",new String[] {"1e-600","1e-300","1e-100","1e-50","1e-10","1e-5","0.001","0.1","1.0","2.0","5.0","10.0","20.0","50"},new String[] {"1e-600","1e-300","1e-100","1e-50","1e-10","1e-5","0.001","0.1","1.0","2.0","5.0","10.0 default","20.0","50"}),
new dField("Explowlim","CharSequence",null,"default",new String[] {"default","1e-600","1e-300","1e-100","1e-50","1e-10","1e-5","0.001","0.1","1.0","2.0","5.0","10.0","20.0","50"},new String[] {"default default","1e-600","1e-300","1e-100","1e-50","1e-10","1e-5","0.001","0.1","1.0","2.0","5.0","10.0","20.0","50"}),
new dField("Seqrange","CharSequence",null,"START-END"),
new dField("Dbrange","CharSequence",null,"START-END"),
new dField("Stype","CharSequence",null,"PROTEIN"),
new dField("Sequence","CharSequence",null,"") }
);
}
public static class Record extends Sight.Record implements Serializable {
public String url;
public CharSequence header;
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 r.header;
default: return "<tr><td>"+r.header+"</td><td><a href=\""+r.url+"\">"+r.E+"</a></td></tr>";
}
};
public String getReport(Object[] x, int verbosityLevel)
{
boolean singleLine = x.length<=1;
StringBuffer b = new StringBuffer();
if (verbosityLevel>=1)
{ b.append(getAgentSignature());
b.append(": ");
};
if (verbosityLevel==0)
{
Sight.util.Generalizer g = new Sight.util.Generalizer();
g.setIgnore("aa");
Record r;
for (int i = 0; i < x.length; i++) {
r = (Record) x[i];
try {
g.add(r.header.toString(), Double.parseDouble(r.E.toString().trim()));
} catch (Exception exc)
{
g.add(r.header.toString(), -1);
};
}
return g.toString();
}
else
{
b.append(Sight.Agents.Variants.sBlaster.defaultTableHeader);
b.append("<tr><td>Header</td><td>E</td></tr>");
for (int i = 0; i < x.length; i++) {
b.append(getReportForRecord(x[i], verbosityLevel));
if ( (i>=5 && verbosityLevel==1) || i>=21)
{
b.append("<tr><td colspan=\"2\">(truncated, "+x.length+" hits in total)<td></tr>");
break;
};
}
b.append("</table>");
};
return b.toString();
};
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("url","String","Link",""),
new dField("header","CharSequence",null,""),
new dField("E","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.url=getURL(fields[0]);
r.header=noHtml(fields[1]);
r.E=fields[2];
return r;
};
public Sight.Result resultFromString(String html) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(html);
return r;
};
public Ebi_fasta() { signatures = new multiSignatures();
signatures.far_start=null;
signatures.top=null;
signatures.bottom=null;
signatures.signatures =
new Signature[] {
new Signature(">>SWALL:<a href=","</a"),
new Signature(">","\n"),
new Signature("E():","Smith")
};
setDescription("Proteomes and Genomes Fasta");
setFormURL("http://www.ebi.ac.uk/cgi-bin/fasta/genomes.pl");
setMasterURL("http://www.ebi.ac.uk/fasta33/genomes.html");
preScan = new preScan();
preScan.zeroCases = new String[] { "!! No library sequences" };
};
public static Ebi_fasta Public = new Ebi_fasta();
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();
};
}
;
}