3 // forester -- software libraries and applications
4 // for genomics and evolutionary biology research.
6 // Copyright (C) 2010 Christian M Zmasek
7 // Copyright (C) 2010 Sanford-Burnham Medical Research Institute
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 // Contact: phylosoft @ gmail . com
25 // WWW: www.phylosoft.org/forester
27 package org.forester.application;
29 import java.io.BufferedReader;
31 import java.io.FileNotFoundException;
32 import java.io.FileReader;
33 import java.io.IOException;
34 import java.util.List;
36 import org.forester.go.PfamToGoMapping;
37 import org.forester.go.PfamToGoParser;
39 public class pfamacc2go {
41 final static private String PRG_NAME = "pfamacc2go";
43 public static void main( final String args[] ) {
44 if ( args.length != 2 ) {
48 final PfamToGoParser p = new PfamToGoParser( new File( args[ 0 ] ) );
49 p.setUseAccessors( true );
50 List<PfamToGoMapping> pfam2go = null;
54 catch ( final IOException e ) {
58 BufferedReader br = null;
60 br = new BufferedReader( new FileReader( args[ 1 ] ) );
62 catch ( final FileNotFoundException e ) {
67 int total_pfam_ids = 0;
68 int mapped_pfam_ids = 0;
70 while ( ( line = br.readLine() ) != null ) {
72 if ( ( line.length() > 0 ) && !line.startsWith( "#" ) ) {
73 String[] pfam_ids = null;
74 if ( line.contains( "," ) ) {
75 pfam_ids = line.split( "," );
78 pfam_ids = new String[ 1 ];
81 for( final String pfam_id : pfam_ids ) {
83 boolean mapped = false;
84 for( final PfamToGoMapping pfam_to_go_mapping : pfam2go ) {
85 if ( pfam_to_go_mapping.getKey().getId().equals( pfam_id ) ) {
87 System.out.println( pfam_to_go_mapping.getValue().toString() );
97 catch ( final Exception e ) {
101 System.out.println( "# total pfam ids : " + total_pfam_ids );
102 System.out.println( "# pfam ids mapped: " + mapped_pfam_ids );
105 private static void printHelp() {
106 System.out.println();
107 System.out.println( PRG_NAME
108 + " <pfam2go mapping file> <file with pfam accessors, newline and/or comma separated>" );
109 System.out.println();