Difference between revisions of "Automated Evaluation of Homoloy Models"

From Bioinformatikpedia
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  +
The call of TMS is wrong which slighty changes the values or did you do that on purpose? (Benny)
  +
  +
You call<br>
  +
<code>TMS <NATIVE> <MODEL></code>
  +
  +
but the help states <br>
  +
<code>TMS <MODEL> <NATIVE></code>
  +
  +
 
=Source code for Eval.java=
 
=Source code for Eval.java=
<code>
 
<nowiki>
 
import java.io.BufferedReader;
 
import java.io.BufferedWriter;
 
import java.io.File;
 
import java.io.FileNotFoundException;
 
import java.io.FileReader;
 
import java.io.FileWriter;
 
import java.io.IOException;
 
import java.io.InputStreamReader;
 
import java.util.ArrayList;
 
   
  +
<code>
public class Eval
 
  +
import java.io.BufferedReader;<br>
{
 
  +
import java.io.BufferedWriter;<br>
public static String USAGE = "java -jar Eval.jar <modelContainer> <modelDir> <refContainer> <refDir>" +
 
  +
import java.io.File;<br>
"\n\t <modelContainer> contains in each line one id of the used models (the filename before the .pdb)" +
 
  +
import java.io.FileNotFoundException;<br>
"\n\t <modelDir> the directory where the model-files lie" +
 
  +
import java.io.FileReader;<br>
"\n\t <refContainer> contains in each line one id of the used reference structures (the filename before the .pdb)" +
 
  +
import java.io.FileWriter;<br>
"\n\t <refDir> the directory where the model-files lie";
 
  +
import java.io.IOException;<br>
 
  +
import java.io.InputStreamReader;<br>
public static void main(String[] args)
 
  +
import java.util.ArrayList;<br>
{
 
  +
<br>
if(args.length != 4)
 
  +
public class Eval <br>
{
 
  +
{<br>
System.out.println(Eval.USAGE);
 
  +
public static String USAGE = "java -jar Eval.jar <modelContainer> <modelDir> <refContainer> <refDir>" +<br>
System.exit(1);
 
  +
"\n\t <modelContainer> contains in each line one id of the used models (the filename before the .pdb)" +<br>
}
 
  +
"\n\t <modelDir> the directory where the model-files lie" +<br>
 
  +
"\n\t <refContainer> contains in each line one id of the used reference structures (the filename before the .pdb)" +<br>
File modelContainer = new File(args[0]);
 
  +
"\n\t <refDir> the directory where the model-files lie";<br>
File modelDir = new File(args[1]);
 
  +
<br>
File refContainer = new File(args[2]);
 
  +
public static void main(String[] args)<br>
File refDir = new File(args[3]);
 
  +
{<br>
 
  +
if(args.length != 4)<br>
ArrayList <String> modelIds = Eval.readContainer(modelContainer);
 
  +
{<br>
ArrayList <String> refIds = Eval.readContainer(refContainer);
 
  +
System.out.println(Eval.USAGE);<br>
 
  +
System.exit(1);<br>
for(String modelId : modelIds)
 
{
+
}<br>
  +
<br>
File model = Eval.getPDB(modelDir, modelId);
 
  +
File modelContainer = new File(args[0]);<br>
for(String refId : refIds)
 
  +
File modelDir = new File(args[1]);<br>
{
 
  +
File refContainer = new File(args[2]);<br>
System.out.println(modelId+" vs. " +refId);
 
File reference = Eval.getPDB(refDir, refId);
+
File refDir = new File(args[3]);<br>
  +
<br>
System.out.println("RMSD: "+Eval.calcRMSD(reference, model));
 
  +
ArrayList <String> modelIds = Eval.readContainer(modelContainer);<br>
System.out.println("TM: "+Eval.calcTM(reference, model));
 
  +
ArrayList <String> refIds = Eval.readContainer(refContainer);<br>
System.out.println("ALL RMSD: "+Eval.calcFeRMSD(reference, model));
 
}
+
<br>
  +
for(String modelId : modelIds)<br>
}
 
  +
{<br>
}
 
  +
File model = Eval.getPDB(modelDir, modelId);<br>
 
  +
for(String refId : refIds)<br>
public static String calcRMSD(File reference, File model)
 
  +
{<br>
{
 
  +
System.out.println(modelId+" vs. " +refId);<br>
String res = "";
 
  +
File reference = Eval.getPDB(refDir, refId);<br>
 
  +
System.out.println("RMSD: "+Eval.calcRMSD(reference, model));<br>
try
 
  +
System.out.println("TM: "+Eval.calcTM(reference, model));<br>
{
 
  +
System.out.println("ALL RMSD: "+Eval.calcFeRMSD(reference, model));<br>
Process p = Runtime.getRuntime().exec("sap "+reference.getAbsolutePath()+" "+model.getAbsolutePath());
 
  +
System.out.println();<br>
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
 
  +
}<br>
String line;
 
  +
}<br>
while((line = in.readLine()) != null)
 
  +
}<br>
{
 
  +
<br>
if(line.startsWith("Un-weighted RMSd ="))
 
  +
public static String calcRMSD(File reference, File model)<br>
{
 
  +
{<br>
int off = line.indexOf("over all matched atoms");
 
if(off != -1)
+
String res = "";<br>
{
+
<br>
  +
try <br>
res = line.substring(18, off);
 
  +
{<br>
res.replaceAll(" ", "");
 
  +
Process p = Runtime.getRuntime().exec("sap "+reference.getAbsolutePath()+" "+model.getAbsolutePath());<br>
}
 
  +
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));<br>
}
 
  +
String line;<br>
}
 
  +
while((line = in.readLine()) != null)<br>
}
 
  +
{<br>
catch (IOException e)
 
  +
if(line.startsWith("Un-weighted RMSd ="))<br>
{
 
  +
{<br>
e.printStackTrace();
 
  +
int off = line.indexOf("over all matched atoms"); <br>
}
 
  +
if(off != -1)<br>
 
  +
{<br>
return res;
 
  +
res = line.substring(18, off);<br>
}
 
  +
res.replaceAll(" ", "");<br>
 
  +
}<br>
public static String calcAllRMSD(File reference, File model)
 
  +
}<br>
{
 
  +
}<br>
String res = "";
 
+
} <br>
  +
catch (IOException e) <br>
try
 
{
+
{<br>
  +
e.printStackTrace();<br>
Process p = Runtime.getRuntime().exec("rms.pl -out all "+reference.getAbsolutePath()+" "+model.getAbsolutePath());
 
  +
}<br>
p.waitFor();
 
+
<br>
  +
return res;<br>
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
 
  +
}<br>
 
  +
<br>
String line;
 
  +
public static String calcTM(File reference, File model)<br>
while((line = in.readLine()) != null)
 
  +
{<br>
{
 
res = line.replaceAll(" all", "");
+
String res = "";<br>
  +
<br>
res = res.replaceAll(" ", "");
 
  +
try <br>
}
 
+
{<br>
  +
Process p = Runtime.getRuntime().exec("TMS "+reference.getAbsolutePath()+" "+model.getAbsolutePath());<br>
in.close();
 
}
+
<br>
  +
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));<br>
catch (IOException e)
 
  +
String line;<br>
{
 
  +
while((line = in.readLine()) != null)<br>
e.printStackTrace();
 
}
+
{<br>
  +
res = line.substring(5);<br>
catch (InterruptedException e)
 
{
+
}<br>
  +
} <br>
e.printStackTrace();
 
  +
catch (IOException e) <br>
}
 
+
{<br>
  +
e.printStackTrace();<br>
return res;
 
  +
}<br>
}
 
  +
<br>
 
  +
return res;<br>
public static String calcTM(File reference, File model)
 
  +
}<br>
{
 
  +
<br>
String res = "";
 
  +
public static String calcFeRMSD(File reference, File model)<br>
 
  +
{<br>
try
 
  +
String res = "";<br>
{
 
  +
<br>
Process p = Runtime.getRuntime().exec("TMS "+reference.getAbsolutePath()+" "+model.getAbsolutePath());
 
  +
try <br>
 
  +
{<br>
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
 
  +
File script = Eval.writePythonScript(reference, model);<br>
String line;
 
  +
<br>
while((line = in.readLine()) != null)
 
  +
Process p = Runtime.getRuntime().exec("pymol "+script.getAbsolutePath());<br>
{
 
res = line.substring(5);
+
p.waitFor();<br>
}
+
<br>
  +
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));<br>
}
 
  +
String line;<br>
catch (IOException e)
 
{
+
<br>
  +
while((line = in.readLine()) != null)<br>
e.printStackTrace();
 
}
+
{<br>
  +
if(line.startsWith(" Executive: RMS ="))<br>
 
  +
{<br>
return res;
 
  +
res = line.substring(line.indexOf("=")+1, line.indexOf("("));<br>
}
 
  +
res = res.replaceAll(" ", "");<br>
 
  +
}<br>
public static String calcFeRMSD(File reference, File model)
 
  +
}<br>
{
 
  +
}<br>
String res = "";
 
  +
catch (IOException e) <br>
 
try
+
{<br>
  +
e.printStackTrace();<br>
{
 
  +
} <br>
File reftemp = File.createTempFile("reftemp", ".pdb");
 
  +
catch (InterruptedException e) <br>
reftemp.deleteOnExit();
 
  +
{<br>
File modtemp = File.createTempFile("modtemp", ".pdb");
 
modtemp.deleteOnExit();
+
e.printStackTrace();<br>
+
}<br>
  +
<br>
File script = Eval.writePythonScript(reference, model, reftemp, modtemp);
 
  +
return res;<br>
 
  +
}<br>
Process p = Runtime.getRuntime().exec("pymol "+script.getAbsolutePath());
 
  +
<br>
p.waitFor();
 
  +
public static File writePythonScript(File reference, File model)<br>
 
  +
{<br>
res = Eval.calcAllRMSD(reftemp, modtemp);
 
  +
File script = null;<br>
}
 
  +
try <br>
catch (IOException e)
 
{
+
{<br>
  +
script = File.createTempFile("fesel", ".pml");<br>
e.printStackTrace();
 
  +
script.deleteOnExit();<br>
}
 
  +
<br>
catch (InterruptedException e)
 
  +
BufferedWriter out = new BufferedWriter(new FileWriter(script));<br>
{
 
  +
<br>
e.printStackTrace();
 
  +
out.write("load "+reference.getAbsolutePath()+", reference\n");<br>
}
 
  +
out.write("load "+model.getAbsolutePath()+", mod\n");<br>
 
  +
out.write("select fe, name fe\n");<br>
return res;
 
  +
out.write("align mod, reference\n");<br>
}
 
  +
out.write("select ref_near_7, (fe around 7) and reference\n");<br>
 
  +
out.write("select ref_near_7, byres ref_near_7\n");<br>
public static File writePythonScript(File reference, File model, File reftemp, File modtemp)
 
  +
out.write("select mod_near_7, (fe around 7) and mod\n");<br>
{
 
  +
out.write("select mod_near_7, byres mod_near_7\n");<br>
File script = null;
 
  +
out.write("align mod_near_7, ref_near_7\n");<br>
try
 
  +
out.write("quit\n");<br>
{
 
  +
<br>
script = File.createTempFile("fesel", ".pml");
 
script.deleteOnExit();
+
out.close();<br>
+
<br>
  +
} <br>
BufferedWriter out = new BufferedWriter(new FileWriter(script));
 
  +
catch (IOException e) <br>
 
  +
{<br>
out.write("load "+reference.getAbsolutePath()+", reference\n");
 
  +
e.printStackTrace();<br>
out.write("load "+model.getAbsolutePath()+", mod\n");
 
  +
}<br>
out.write("select fe, name fe\n");
 
  +
<br>
out.write("align mod, reference\n");
 
  +
return script;<br>
out.write("select near_7, fe around 7\n");
 
  +
}<br>
out.write("select ref_near_7, (fe around 7) and reference\n");
 
  +
<br>
out.write("save "+reftemp.getAbsolutePath()+", ref_near_7\n");
 
  +
public static File getPDB(File dir, String name)<br>
out.write("select mod_near_7, (fe around 7) and mod\n");
 
  +
{<br>
out.write("save "+modtemp.getAbsolutePath()+", mod_near_7\n");
 
  +
return new File(dir, name+".pdb");<br>
out.write("quit\n");
 
  +
}<br>
 
  +
<br>
out.close();
 
  +
public static ArrayList<String> readContainer(File f)<br>
 
  +
{<br>
}
 
  +
ArrayList <String> ids = new ArrayList<String>();<br>
catch (IOException e)
 
{
+
<br>
  +
try <br>
e.printStackTrace();
 
}
+
{<br>
  +
BufferedReader in = new BufferedReader(new FileReader(f));<br>
 
  +
String line;<br>
return script;
 
  +
<br>
}
 
  +
while((line = in.readLine()) != null)<br>
 
  +
{<br>
public static File getPDB(File dir, String name)
 
  +
ids.add(line);<br>
{
 
  +
}<br>
return new File(dir, name+".pdb");
 
  +
<br>
}
 
  +
in.close();<br>
 
  +
} <br>
public static ArrayList<String> readContainer(File f)
 
  +
catch (FileNotFoundException e) <br>
{
 
  +
{<br>
ArrayList <String> ids = new ArrayList<String>();
 
  +
e.printStackTrace();<br>
 
try
+
} <br>
  +
catch (IOException e) <br>
{
 
  +
{<br>
BufferedReader in = new BufferedReader(new FileReader(f));
 
  +
e.printStackTrace();<br>
String line;
 
+
}<br>
  +
<br>
while((line = in.readLine()) != null)
 
  +
return ids;<br>
{
 
  +
}<br>
ids.add(line);
 
}
 
 
in.close();
 
}
 
catch (FileNotFoundException e)
 
{
 
e.printStackTrace();
 
}
 
catch (IOException e)
 
{
 
e.printStackTrace();
 
}
 
 
return ids;
 
}
 
 
}
 
}
</nowiki>
 
 
</code>
 
</code>

Latest revision as of 19:47, 14 June 2011

The call of TMS is wrong which slighty changes the values or did you do that on purpose? (Benny)

You call
TMS <NATIVE> <MODEL>

but the help states
TMS <MODEL> <NATIVE>


Source code for Eval.java

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Eval
{
public static String USAGE = "java -jar Eval.jar <modelContainer> <modelDir> <refContainer> <refDir>" +
"\n\t <modelContainer> contains in each line one id of the used models (the filename before the .pdb)" +
"\n\t <modelDir> the directory where the model-files lie" +
"\n\t <refContainer> contains in each line one id of the used reference structures (the filename before the .pdb)" +
"\n\t <refDir> the directory where the model-files lie";

public static void main(String[] args)
{
if(args.length != 4)
{
System.out.println(Eval.USAGE);
System.exit(1);
}

File modelContainer = new File(args[0]);
File modelDir = new File(args[1]);
File refContainer = new File(args[2]);
File refDir = new File(args[3]);

ArrayList <String> modelIds = Eval.readContainer(modelContainer);
ArrayList <String> refIds = Eval.readContainer(refContainer);

for(String modelId : modelIds)
{
File model = Eval.getPDB(modelDir, modelId);
for(String refId : refIds)
{
System.out.println(modelId+" vs. " +refId);
File reference = Eval.getPDB(refDir, refId);
System.out.println("RMSD: "+Eval.calcRMSD(reference, model));
System.out.println("TM: "+Eval.calcTM(reference, model));
System.out.println("ALL RMSD: "+Eval.calcFeRMSD(reference, model));
System.out.println();
}
}
}

public static String calcRMSD(File reference, File model)
{
String res = "";

try
{
Process p = Runtime.getRuntime().exec("sap "+reference.getAbsolutePath()+" "+model.getAbsolutePath());
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line = in.readLine()) != null)
{
if(line.startsWith("Un-weighted RMSd ="))
{
int off = line.indexOf("over all matched atoms");
if(off != -1)
{
res = line.substring(18, off);
res.replaceAll(" ", "");
}
}
}
}
catch (IOException e)
{
e.printStackTrace();
}

return res;
}

public static String calcTM(File reference, File model)
{
String res = "";

try
{
Process p = Runtime.getRuntime().exec("TMS "+reference.getAbsolutePath()+" "+model.getAbsolutePath());

BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line = in.readLine()) != null)
{
res = line.substring(5);
}
}
catch (IOException e)
{
e.printStackTrace();
}

return res;
}

public static String calcFeRMSD(File reference, File model)
{
String res = "";

try
{
File script = Eval.writePythonScript(reference, model);

Process p = Runtime.getRuntime().exec("pymol "+script.getAbsolutePath());
p.waitFor();

BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;

while((line = in.readLine()) != null)
{
if(line.startsWith(" Executive: RMS ="))
{
res = line.substring(line.indexOf("=")+1, line.indexOf("("));
res = res.replaceAll(" ", "");
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
catch (InterruptedException e)
{
e.printStackTrace();
}

return res;
}

public static File writePythonScript(File reference, File model)
{
File script = null;
try
{
script = File.createTempFile("fesel", ".pml");
script.deleteOnExit();

BufferedWriter out = new BufferedWriter(new FileWriter(script));

out.write("load "+reference.getAbsolutePath()+", reference\n");
out.write("load "+model.getAbsolutePath()+", mod\n");
out.write("select fe, name fe\n");
out.write("align mod, reference\n");
out.write("select ref_near_7, (fe around 7) and reference\n");
out.write("select ref_near_7, byres ref_near_7\n");
out.write("select mod_near_7, (fe around 7) and mod\n");
out.write("select mod_near_7, byres mod_near_7\n");
out.write("align mod_near_7, ref_near_7\n");
out.write("quit\n");

out.close();

}
catch (IOException e)
{
e.printStackTrace();
}

return script;
}

public static File getPDB(File dir, String name)
{
return new File(dir, name+".pdb");
}

public static ArrayList<String> readContainer(File f)
{
ArrayList <String> ids = new ArrayList<String>();

try
{
BufferedReader in = new BufferedReader(new FileReader(f));
String line;

while((line = in.readLine()) != null)
{
ids.add(line);
}

in.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}

return ids;
}
}