--- /dev/null
+package jalview.ext.jmol;
+
+import jalview.datamodel.SequenceI;
+import jalview.io.AppletFormatAdapter;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
+import MCview.PDBfile;
+
+/**
+ * This is not a unit test, rather it is a bulk End-to-End scan for sequences
+ * consistency for PDB files parsed with JmolParser vs. Jalview's PDBfile
+ * parser. The directory of PDB files to test must be provided in the launch
+ * args.
+ *
+ * @author tcnofoegbu
+ *
+ */
+public class JmolVsJalviewPDBParserEndToEndTest
+{
+
+ public static void main(String[] args)
+ {
+ if (args == null || args[0] == null)
+ {
+ System.err
+ .println("You must provide a PDB directory in the launch argument");
+ return;
+ }
+
+ // args[0] must provide the directory of PDB files to run the test with
+ String testDir = args[0];
+ System.out.println("PDB directory : " + testDir);
+ File pdbDir = new File(testDir);
+ String testFiles[] = pdbDir.list();
+ testFileParser(testDir, testFiles);
+ }
+
+ public static void testFileParser(String testDir, String[] testFiles)
+ {
+ Set<String> failedFiles = new HashSet<String>();
+ int totalSeqScanned = 0, totalFail = 0;
+ for (String pdbStr : testFiles)
+ {
+ String testFile = testDir + "/" + pdbStr;
+ PDBfile mctest = null;
+ JmolParser jtest = null;
+ try
+ {
+ mctest = new PDBfile(false, false, false, testFile,
+ AppletFormatAdapter.FILE);
+ jtest = new JmolParser(false, false, false, testFile,
+ jalview.io.AppletFormatAdapter.FILE);
+ } catch (IOException e)
+ {
+ System.err.println("Exception thrown while parsing : " + pdbStr);
+ }
+ Vector<SequenceI> seqs = jtest.getSeqs();
+ Vector<SequenceI> mcseqs = mctest.getSeqs();
+
+ for (SequenceI sq : seqs)
+ {
+ try
+ {
+ String testSeq = mcseqs.remove(0).getSequenceAsString();
+ if (!sq.getSequenceAsString().equals(testSeq))
+ {
+ ++totalFail;
+ System.err.println("Test Failed for " + pdbStr + ". Diff:");
+ System.err.println(sq.getSequenceAsString());
+ System.err.println(testSeq);
+ failedFiles.add(pdbStr);
+ }
+ ++totalSeqScanned;
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ int count = 0;
+
+ System.out.println("\n\nTotal sequence Scanned : " + totalSeqScanned);
+ System.out.println("Total sequence passed : "
+ + (totalSeqScanned - totalFail));
+ System.out.println("Total sequence failed : " + totalFail);
+ System.out
+ .println("Success rate: "
+ + ((totalSeqScanned - totalFail) * 100)
+ / totalSeqScanned + "%");
+ System.out.println("\nList of " + failedFiles.size()
+ + " file(s) with sequence diffs:");
+ for (String problemFile : failedFiles)
+ {
+ System.out.println(++count + ". " + problemFile);
+ }
+ }
+}