2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
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.
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.
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
23 // Contact: phylosoft @ gmail . com
24 // WWW: www.phylosoft.org
26 package org.forester.application;
29 import java.io.IOException;
30 import java.util.ArrayList;
31 import java.util.List;
33 import org.forester.go.PfamToGoMapping;
34 import org.forester.go.PfamToGoParser;
35 import org.forester.go.etc.MetaOntologizer;
36 import org.forester.util.CommandLineArguments;
37 import org.forester.util.ForesterUtil;
39 public class meta_ontologizer {
41 final static private String HELP_OPTION_1 = "help";
42 final static private String HELP_OPTION_2 = "h";
43 final static private String P_OPTION = "p";
44 final static private String PRG_NAME = "meta_ontologizer";
45 final static private String PRG_VERSION = "1.10";
46 final static private String PRG_DATE = "2009.04.29";
47 final static private String E_MAIL = "czmasek@burnham.org";
48 final static private String WWW = "www.phylosoft.org/forester/";
49 private static final String RESULT_FILE_PREFIX = "table";
51 public static void main( final String args[] ) {
52 ForesterUtil.printProgramInformation( PRG_NAME, PRG_VERSION, PRG_DATE, E_MAIL, WWW );
53 CommandLineArguments cla = null;
55 cla = new CommandLineArguments( args );
57 catch ( final Exception e ) {
58 ForesterUtil.fatalError( PRG_NAME, e.getMessage() );
60 if ( cla.isOptionSet( HELP_OPTION_1 ) || cla.isOptionSet( HELP_OPTION_2 ) || ( args.length == 0 ) ) {
64 if ( args.length < 4 ) {
66 System.out.println( "[" + PRG_NAME + "] incorrect number of arguments" );
71 final List<String> allowed_options = new ArrayList<String>();
72 allowed_options.add( P_OPTION );
73 final List<String> mandatory_options = new ArrayList<String>();
74 mandatory_options.add( P_OPTION );
75 if ( ( cla.getNumberOfNames() != 5 ) && ( cla.getNumberOfNames() != 6 ) ) {
77 System.out.println( "[" + PRG_NAME + "] incorrect number of arguments" );
82 final String missing = cla.validateMandatoryOptionsAsString( mandatory_options );
83 if ( missing.length() > 0 ) {
84 ForesterUtil.fatalError( PRG_NAME, "missing option(s): " + missing );
86 final String dissallowed_options = cla.validateAllowedOptionsAsString( allowed_options );
87 if ( dissallowed_options.length() > 0 ) {
88 ForesterUtil.fatalError( PRG_NAME, "unknown option(s): " + dissallowed_options );
90 final File obo_file = cla.getFile( 0 );
91 final File pfam2go_file = cla.getFile( 1 );
92 final File ontologizer_outdir = cla.getFile( 2 );
93 File domain_gain_loss_file = null;
94 String outfile_base = null;
95 String comment = null;
96 if ( cla.getNumberOfNames() == 6 ) {
97 domain_gain_loss_file = cla.getFile( 3 );
98 outfile_base = cla.getName( 4 );
99 comment = cla.getName( 5 );
102 outfile_base = cla.getName( 3 );
103 comment = cla.getName( 4 );
105 double p_adjusted_upper_limit = -1;
107 p_adjusted_upper_limit = cla.getOptionValueAsDouble( P_OPTION );
109 catch ( final IOException e ) {
110 ForesterUtil.fatalError( PRG_NAME, e.getMessage() );
113 final PfamToGoParser parser = new PfamToGoParser( pfam2go_file );
114 final List<PfamToGoMapping> pfam_to_go_mappings = parser.parse();
115 ForesterUtil.programMessage( PRG_NAME, "parsed " + pfam_to_go_mappings.size() + " Pfam to GO mappings" );
116 MetaOntologizer.reformat( ontologizer_outdir,
118 domain_gain_loss_file,
121 p_adjusted_upper_limit,
123 pfam_to_go_mappings );
125 catch ( final IOException e ) {
126 ForesterUtil.fatalError( PRG_NAME, e.getMessage() );
129 ForesterUtil.programMessage( PRG_NAME, "OK" );
130 System.out.println();
133 private static void printHelp() {
134 System.out.println( "Usage:" );
135 System.out.println();
138 + " -p=<adj P value limit> <obo file> <pfam to go file> <ontologizer outdir> [domain gain loss file] <base for meta ontologizer outfile> <comment>" );
139 System.out.println();