ensure we never check in autogenerated documentation or build artefacts
[jabaws.git] / runner / compbio / pipeline / _jpred / BlastBlastComparator.java
1 /* Copyright (c) 2011 Peter Troshin\r
2  *  \r
3  *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
4  * \r
5  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
6  *  Apache License version 2 as published by the Apache Software Foundation\r
7  * \r
8  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
9  *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
10  *  License for more details.\r
11  * \r
12  *  A copy of the license is in apache_license.txt. It is also available here:\r
13  * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
14  * \r
15  * Any republication or derived work distributed in source code form\r
16  * must include this copyright and license notice.\r
17  */\r
18 package compbio.pipeline._jpred;\r
19 \r
20 import java.io.FileNotFoundException;\r
21 import java.util.HashSet;\r
22 import java.util.Set;\r
23 \r
24 import javax.xml.stream.XMLStreamException;\r
25 \r
26 \r
27 public class BlastBlastComparator {\r
28 \r
29     /**\r
30      * args[0] is assumed to be the name of a Blast output file\r
31      * \r
32      * @throws XMLStreamException\r
33      * @throws FileNotFoundException\r
34      */\r
35     public static void main(String[] args) throws FileNotFoundException,\r
36             XMLStreamException {\r
37         BlastParser res1 = new BlastParser(args[0]);\r
38         BlastParser res2 = new BlastParser(args[1]);\r
39         assert res1.iters.size() == res2.iters.size();\r
40 \r
41         for (Integer iterNum : res1.iters.keySet()) {\r
42             Set<Hit> list = res1.iters.get(iterNum);\r
43             Set<Hit> otherList = res2.iters.get(iterNum);\r
44             System.out.print("Iter " + iterNum + " arg0: " + list.size());\r
45             System.out.println(" arg1: " + otherList.size());\r
46             BlastParser.printNames(getDiff(list, otherList));\r
47             // System.out.println("Diffs: " + getDiff(list, otherList));\r
48             // System.out.println("Diffs: " + getDiff(otherList, list));\r
49 \r
50         }\r
51 \r
52     }\r
53 \r
54     static Set<Hit> getDiff(Set<Hit> list, Set<Hit> otherList) {\r
55         Set diff = new HashSet<Hit>();\r
56         for (Hit pseq : list) {\r
57             if (otherList.contains(pseq)) {\r
58                 continue;\r
59             }\r
60             diff.add(pseq);\r
61         }\r
62         return diff;\r
63     }\r
64 \r
65 }\r