Changes from JWS3 is merged
[jabaws.git] / runner / compbio / pipeline / _jpred / BlastHmmerComparator.java
diff --git a/runner/compbio/pipeline/_jpred/BlastHmmerComparator.java b/runner/compbio/pipeline/_jpred/BlastHmmerComparator.java
new file mode 100644 (file)
index 0000000..21dec65
--- /dev/null
@@ -0,0 +1,60 @@
+/* Copyright (c) 2009 Peter Troshin\r
+ *  \r
+ *  Jalview Web Services @version: 2.0     \r
+ * \r
+ *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
+ *  Apache License version 2 as published by the Apache Software Foundation\r
+ * \r
+ *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
+ *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
+ *  License for more details.\r
+ * \r
+ *  A copy of the license is in apache_license.txt. It is also available here:\r
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
+ * \r
+ * Any republication or derived work distributed in source code form\r
+ * must include this copyright and license notice.\r
+ */\r
+package compbio.pipeline._jpred;\r
+\r
+import java.io.IOException;\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import javax.xml.stream.XMLStreamException;\r
+\r
+public class BlastHmmerComparator {\r
+\r
+    /**\r
+     * args[0] is assumed to be the name of a Blast output file\r
+     * \r
+     * @throws XMLStreamException\r
+     * @throws IOException\r
+     */\r
+    public static void main(String[] args) throws XMLStreamException,\r
+           IOException {\r
+       BlastParser res1 = new BlastParser(args[0]);\r
+       JackHmmerHitParser res2 = new JackHmmerHitParser(args[1]);\r
+       Set<Hit> list = res1.iters.get(3);\r
+       Set<Hit> otherList = res2.hits;\r
+       System.out.print("Iter " + 3 + " arg0: " + list.size());\r
+       System.out.println(" arg1: " + otherList.size());\r
+       BlastParser.printNames(getDiff(list, otherList));\r
+       BlastParser.printNames(getDiff(otherList, list));\r
+       // System.out.println("Diffs: " + getDiff(list, otherList));\r
+       // System.out.println("Diffs: " + getDiff(otherList, list));\r
+\r
+    }\r
+\r
+    static Set<Hit> getDiff(Set<Hit> list, Set<Hit> otherList) {\r
+       Set diff = new HashSet<Hit>();\r
+       for (Hit pseq : list) {\r
+           if (otherList.contains(pseq)) {\r
+               continue;\r
+           }\r
+           diff.add(pseq);\r
+       }\r
+       return diff;\r
+    }\r
+\r
+}\r