package impl.ext;
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 LocusLink2RNA extends Sight.Agents.Prototypes.signatureBasedAgent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Id="4891";
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); };
};
public static String convert(String li)
{
try {
Request a = getDefaultRequest();
a.Id = li;
Result r = (Result) Public.go(a, li);
if (r==null) return null;
if (r.a.length<1) return null;
String rt = r.a[0].rna_Id.toString();
Public.p(li+" to "+rt);
return rt;
} catch (Exception exc)
{
Sight.io.Output.e(exc);
return null;
}
};
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/LocusLink/LocRpt.cgi?l="); 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,"4891") }
);
}
public static class Record extends Sight.Record implements Serializable {
public CharSequence rna_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.rna_Id+" ";
case 1: return ""+r.rna_Id+" ";
default: return ""+" : "+r.rna_Id+" ";
}
};
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("rna_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.rna_Id=fields[0];
return r;
};
public Sight.Result resultFromString(String html) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(html);
return r;
};
public LocusLink2RNA() { signatures = new multiSignatures();
signatures.far_start="Annotated transcripts/proteins for this locus:";
signatures.top=null;
signatures.bottom=null;
signatures.signatures =
new Signature[] {
new Signature("mRNA:</th>\n <td align=left valign=top ><a href=\"http://www.ncbi.nlm.nih.gov/entrez/viewer.cgi?val=","&db=Nucleotide&dopt=GenBank\"")
};
setDescription("Get rna id from Locus Link id");
setFormURL("http://www.ncbi.nlm.nih.gov/entrez/");
setMasterURL("http://www.ncbi.nlm.nih.gov/entrez/");
preScan = new preScan();
};
public static LocusLink2RNA Public = new LocusLink2RNA();
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();
};
}
;
}