I am working with Taverna to build a workflow. Taverna has a beanshell where I can program in java. I am having some problems in writing a script. I want to extract information from a string, separated by newline. For this i am using regex.
The String is given:
P48534
EXP value is: e-10
Q0543
EXP value is: 4e-07
My script look like this in Beanshell:
Expand|Select|Wrap|Line Numbers
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- Pattern pGI = Pattern.compile("(^.*?$)");
- Pattern pEvaLue = Pattern.compile("is: (.*)$");
- Matcher mGI;
- Matcher mEvalue;
- StringBuffer temp = new StringBuffer();
- String [] line = BlastReport.split("\n");
- int arraysize = line.length;
- for (int i=0; i<(arraysize-1); i+=2){
- String sGI = line[i];
- String sEvalue = line[i+1];
- mGI = pGI.matcher(sGI);
- mEvalue = pEvalue.matcher(sEvalue);
- String gi="";
- if (mGI.find()){
- gi =mGI.group(1);
- }
- if (mEvalue.find()){
- String eval = mEvalue.group(1);
- if(eval.startsWith("e")){
- eval= "1".concat(eval);
- }
- Double d = new Double (eval);
- double Evalue = d.doubleValue();
- if (Evalue<=0.02){
- temp.append(gi + "\n");
- }
- }
- }
- String result = temp.toString().trim();
The error message is: "Attempt to resolve method: matcher() on undefined variable or class name: pEvalue: at Line: 16: pEvalue .matcher(sEvalue)"
Can someone tell me why is giving me this error and how can i fix it.
Thank you in advance,
Mokita