Automated Evaluation of Homoloy Models

From Bioinformatikpedia
(Redirected from Pah hom autom eval)

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;
}
}