initial commit
[jalview.git] / forester_applications / src / org / forester / applications / set_comparator.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // All rights reserved
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 //
23 // Contact: phylosoft @ gmail . com
24 // WWW: www.phylosoft.org/forester
25 // javac -cp ~/SOFTWARE_DEV/ECLIPSE_WORKSPACE/forester/java/forester.jar
26 // ~/SOFTWARE_DEV/ECLIPSE_WORKSPACE/forester_applications/src/org/forester/applications/set_comparator.java
27 // java -Xmx2048m -cp
28 // /home/czmasek/SOFTWARE_DEV/ECLIPSE_WORKSPACE/forester_applications/src/:/home/czmasek/SOFTWARE_DEV/ECLIPSE_WORKSPACE/forester/java/forester.jar
29 // org.forester.applications.set_comparator
30
31 package org.forester.applications;
32
33 import java.io.File;
34 import java.io.IOException;
35 import java.util.Set;
36
37 import org.forester.util.ForesterUtil;
38
39 public class set_comparator {
40
41     public static void main( final String args[] ) {
42         try {
43             if ( args.length != 2 ) {
44                 System.out.println( "Usage: set_comparator <set A> <set B>" );
45                 System.exit( -1 );
46             }
47             Set<String> set_a = ForesterUtil.file2set( new File( args[ 0 ] ) );
48             final Set<String> set_b = ForesterUtil.file2set( new File( args[ 1 ] ) );
49             System.out.println( "# A SIZE: " + set_a.size() );
50             System.out.println( "# B SIZE: " + set_b.size() );
51             set_a.retainAll( set_b );
52             System.out.println( "# INTERSECTION (" + set_a.size() + "):" );
53             for( final String s : set_a ) {
54                 System.out.println( s );
55             }
56             set_a = ForesterUtil.file2set( new File( args[ 0 ] ) );
57             System.out.println();
58             set_a.removeAll( set_b );
59             System.out.println( "# A ONLY (" + set_a.size() + "):" );
60             for( final String s : set_a ) {
61                 System.out.println( s );
62             }
63             set_a = ForesterUtil.file2set( new File( args[ 0 ] ) );
64             System.out.println();
65             set_b.removeAll( set_a );
66             System.out.println( "# B ONLY (" + set_b.size() + "):" );
67             for( final String s : set_b ) {
68                 System.out.println( s );
69             }
70         }
71         catch ( final IOException e ) {
72             e.printStackTrace();
73             System.exit( -1 );
74         }
75     }
76 }