package org.cpic.reporter;

import java.io.File;
import java.io.IOException;
import java.util.Properties;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Reporter {
    
    /**
     * Logging instance
     */
   private Log logger = LogFactory.getLog( Reporter.class );
    
    /**
     * Configuration properties loaded from file
     */
    private Properties props;
    
    /**
     * File in
     */
    private File inFile;
    
    /**
     * File to write final results to
     */
    private File outFile;
    

    
    //parse command line options
    private Reporter( CommandLine cmdline )  throws IOException {
        
        File propsFile = new File( cmdline.getOptionValue( "conf" ) );
        props = readConfFile( propsFile );
        
        String out_location = cmdline.getOptionValue( "outFile" );
        this.outFile = new File( out_location );
        
        String in_file = cmdline.getOptionValue("inFile");
        this.inFile = new File( in_file );
       
                                
    }
    
    /**
     * Read config file into props object
     */
    private Properties readConfFile( File file ) throws IOException {
        Properties props = new Properties();
        props.load( FileUtils.openInputStream( file ) );
        return props;
    }

    public static Options createCommandLineOptions() {
        Options options = new Options();
       
        Option infile = new Option("inFile", true, "required - haplotype result to generate report");
        options.addOption(infile);
        
        Option conf = new Option( "conf", true, "required - configuration file" );
        options.addOption( conf );
        
        
        Option outfile = new Option( "outFile", true, "required - location to write final file" );
        options.addOption( outfile );
       
        return options;
    }

    public static void main(String[] args) throws Exception {
        Options options = createCommandLineOptions();
        CommandLine cmdline = new DefaultParser().parse( options,  args );
        
        if( args.length == 0 ) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp( "CPIC-Reporter", options );
            System.exit( 0 );
        } else if ( !cmdline.hasOption("conf") ||
                    !cmdline.hasOption( "in" ) ||
                    !cmdline.hasOption("out") ) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp( "CPIC-Reporter", options );
            System.out.println( "Error in options in, out, conf" +
                    " are required variables" );
            System.exit( 1 );
        
        } else if ( !cmdline.hasOption("inputBam")){
            System.out.println( "WARNING: No bam file provided" );
        }
        
        //if minimal required parameters are set parse command line
        Reporter report = new Reporter( cmdline );
        //run genotyper workflow
        report.run();
    }
    
    private void run() throws IOException {
  
        
        logger.info( "Complete" );
    }

    
    
    
  

}

@@ -25,87 +25,8 @@
 r;%0A%0A
-import java.io.File;%0Aimport java.io.IOException;%0Aimport java.util.Properties;%0A%0A
 impo
@@ -51,27 +51,17 @@
 ons.cli.
-CommandLine
+*
 ;%0Aimport
@@ -84,182 +84,99 @@
 ons.
-cli.DefaultParser;%0Aimport org.apache.commons.cli.HelpFormatter;%0Aimport org.apache.commons.cli.Option;%0Aimport org.apache.commons.cli.Options;%0Aimport org.apache.commons
+io.FileUtils;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java
 .io.File
 Util
@@ -163,37 +163,32 @@
 ort java.io.File
-Utils
 ;%0Aimport org.apa
@@ -184,84 +184,56 @@
 ort 
-org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory
+java.io.IOException;%0Aimport java.util.Properties
 ;%0A%0Ap
@@ -255,20 +255,16 @@
 orter %7B%0A
-    
 %0A    /**
@@ -310,16 +310,19 @@
 vate Log
+ger
  logger 
@@ -326,16 +326,19 @@
 er = Log
+ger
 Factory.
@@ -343,16 +343,19 @@
 y.getLog
+ger
 ( Report
@@ -366,20 +366,16 @@
 lass );%0A
-    
 %0A    /**
@@ -462,20 +462,16 @@
  props;%0A
-    
 %0A    /**
@@ -519,20 +519,16 @@
 inFile;%0A
-    
 %0A    /**
@@ -604,18 +604,10 @@
 le;%0A
-    %0A%0A    
+%0A%0A
 %0A   
@@ -702,24 +702,16 @@
 ption %7B%0A
-        
 %0A       
@@ -813,32 +813,24 @@
 ropsFile );%0A
-        
 %0A        Str
@@ -930,32 +930,24 @@
 location );%0A
-        
 %0A        Str
@@ -1041,59 +1041,16 @@
  );%0A
-       %0A                                
+%0A
 %0A    %7D%0A
-    
 %0A   
@@ -1401,23 +1401,16 @@
 ions();%0A
-       
 %0A       
@@ -1539,24 +1539,16 @@
 nfile);%0A
-        
 %0A       
@@ -1658,33 +1658,17 @@
 conf );%0A
-        %0A        
+%0A
 %0A       
@@ -1797,23 +1797,16 @@
 file );%0A
-       
 %0A       
@@ -2016,32 +2016,24 @@
 s,  args );%0A
-        
 %0A        if(
@@ -2620,24 +2620,16 @@
 t( 1 );%0A
-        
 %0A       
@@ -2751,24 +2751,16 @@
       %7D%0A
-        
 %0A       
@@ -2932,20 +2932,16 @@
 ;%0A    %7D%0A
-    
 %0A    pri
@@ -2977,27 +2977,17 @@
 ption %7B%0A
-  %0A        
+%0A
 %0A       
@@ -3025,25 +3025,11 @@
  %7D%0A%0A
-    %0A    %0A    %0A  
+%0A%0A%0A
 %0A%0A%7D%0A

Fix logging compile problem.