package impl.protein_analysers;
import Sight.*;
import Sight.Agents.*;
import Sight.Structures.*;
import Sight.dds.*;
import Sight.tools.xPlain.*;
import java.io.*;
import Sight.Agents.util.*;
public class TmPred extends Sight.Agents.Prototypes.preformattedResponseAgent implements Serializable {
public class Request extends Sight.Request implements java.io.Serializable {
public String Min="17"; public String Max="33"; 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.ch.embnet.org/cgi-bin/TMPRED_form_parser"); map.add("connect:action", "POST"); map.add("connect:master", "http://www.ch.embnet.org/software/TMPRED_form.html"); map.add("outmode", "html"); map.add("min", request.Min); map.add("max", request.Max); map.add("comm", ""); map.add("format", "plain_text"); map.add("seq", request.Sequence); return map; };
public static Request getDefaultRequest() {
return Public.getRequest(); }
private Request getRequest() { return new Request(); };
public String getFormURL() {
return "http://www.ch.embnet.org/cgi-bin/TMPRED_form_parser"; }
public String getMasterURL() {
return "http://www.ch.embnet.org/software/TMPRED_form.html"; }
public dStructure getRequestDds() {
return new Sight.dds.Records(false,
new dField[] {
new dField("Min","CharSequence","Minimal transmembrane segment length","17",new String[] {"14","16","17","18","19","20","21","22","23","24","25","26"},new String[] {"14","16","17 default","18","19","20","21","22","23","24","25","26"}),
new dField("Max","CharSequence","Maximal transmembrane segment length","33",new String[] {"23","25","27","29","31","32","33","34","35","37","39","41"},new String[] {"23","25","27","29","31","32","33 default","34","35","37","39","41"}),
new dField("Sequence","CharSequence","protein sequence","") }
);
}
public static class Record extends Sight.Record implements Serializable {
public s_feature Region;
public CharSequence Score;
public CharSequence Orientation;
public CharSequence Helix;
public CharSequence From;
public CharSequence To;
};
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.Region+" ";
default: return r.Region+" "+" Score: "+r.Score+" "+" Orientation: "+r.Orientation+" ";
}
};
public String getReport(int verbosityLevel)
{ if (verbosityLevel==0) return a.length+" helixes";
return getReport(getRecordArray(), verbosityLevel); };
}
public dStructure getResultDds() {
return new Sight.dds.Records(true,
new dField[] {
new dField("Helix","CharSequence","Helix",""),
new dField("Region","s_feature","Region",""),
new dField("Score","CharSequence","Score",""),
new dField("Orientation","CharSequence","Orientation",""),
new dField("From","CharSequence","From",""),
new dField("To","CharSequence","To",""),
}
);
}
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[1]+".."+fields[2]);
r.Score=fields[4];
r.Orientation=fields[5];
r.From = fields[1];
r.To = fields[2];
return r;
};
public Sight.Result resultFromString(String html) throws Exception {
Result r = new Result();
r.a = (Record[]) createResultArray(html);
for (int i = 0; i < r.a.length; i++) {
r.a[i].Helix = ""+(i+1);
}
return r;
};
public TmPred() { signatures = new multiSignatures();
signatures.far_start=null;
signatures.top="# from to length score orientation";
signatures.zeroCases = new String[] {"probably no transmembrane protein","no possible model found"};
signatures.bottom="\n------>";
signatures.Columns = 6;
setDescription("Prediction of transmembrane regions and protein Orientation (EMBnet-CH)");
};
public static TmPred Public = new TmPred();
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();
};
}
}