28c64d426ec6ee1c53c51d7bfc6dce9e1fcfbfc5
[jabaws.git] / runner / compbio / pipeline / _jpred / BlastHmmerComparator.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.IOException;\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 public class BlastHmmerComparator {\r
27 \r
28     /**\r
29      * args[0] is assumed to be the name of a Blast output file\r
30      * \r
31      * @throws XMLStreamException\r
32      * @throws IOException\r
33      */\r
34     public static void main(String[] args) throws XMLStreamException,\r
35             IOException {\r
36         BlastParser res1 = new BlastParser(args[0]);\r
37         JackHmmerHitParser res2 = new JackHmmerHitParser(args[1]);\r
38         Set<Hit> list = res1.iters.get(3);\r
39         Set<Hit> otherList = res2.hits;\r
40         System.out.print("Iter " + 3 + " arg0: " + list.size());\r
41         System.out.println(" arg1: " + otherList.size());\r
42         BlastParser.printNames(getDiff(list, otherList));\r
43         BlastParser.printNames(getDiff(otherList, list));\r
44         // System.out.println("Diffs: " + getDiff(list, otherList));\r
45         // System.out.println("Diffs: " + getDiff(otherList, list));\r
46 \r
47     }\r
48 \r
49     static Set<Hit> getDiff(Set<Hit> list, Set<Hit> otherList) {\r
50         Set diff = new HashSet<Hit>();\r
51         for (Hit pseq : list) {\r
52             if (otherList.contains(pseq)) {\r
53                 continue;\r
54             }\r
55             diff.add(pseq);\r
56         }\r
57         return diff;\r
58     }\r
59 \r
60 }\r