src/main/java/org/ncgr/gwas/CochranArmitage.java
public static void main(String[] args) throws IOException {
        if (args.length!=1) {
            System.out.println("usage: java CochranArmitage <input-filename> <output-filename>");
            System.exit(1);
        }

        long startTime = System.currentTimeMillis();
        String inputFileName = args[0];

        int[] weights = { 0, 1, 2 };
        CochranArmitage ca = new CochranArmitage(weights);    
        
        System.out.println("score\tp-value");
        BufferedReader infile = new BufferedReader(new FileReader(inputFileName));
        int[][] countTable = new int[ca.numRows][ca.numCols];
        String line = null;
        while ((line=infile.readLine())!=null) {
            String[] tokens = line.split("\t");
            int index=0;
            // populate numRowsxnumCols contingency table
            for(int i=0; i<ca.numRows; i++) {
                for(int j=0; j<ca.numCols; j++) {
                    countTable[i][j] = Integer.parseInt(tokens[index++]);
                }
            }
            double pValue = ca.test(countTable);
            System.out.println(String.format("%f\t%f", ca.standardStatistic, pValue));
        }
        long elapsedTime = System.currentTimeMillis() - startTime;
        System.out.println("run time (in milliseconds): " + elapsedTime);
        infile.close();
    }
/**
     * @param args input/output files for testing/debugging a series of 6-entry lines each representing a 2x3 matrix
     * args[0] as input file
     */
@param args input/output files for testing/debugging a series of 6-entry lines each representing a 2x3 matrix
args[0] as input file
@param args input / output files for testing / debugging a series of 6 - entry lines each representing a 2x3 matrix args [ 0 ] as input file
public static void main(String[] args) throws IOException {
        if (args.length!=1) {
            System.out.println("usage: java CochranArmitage <input-filename> <output-filename>");
            System.exit(1);
        }
        long startTime = System.currentTimeMillis();
        String inputFileName = args[0];
        int[] weights = { 0, 1, 2 };
        CochranArmitage ca = new CochranArmitage(weights);    
        System.out.println("score\tp-value");
        BufferedReader infile = new BufferedReader(new FileReader(inputFileName));
        int[][] countTable = new int[ca.numRows][ca.numCols];
        String line = null;
        while ((line=infile.readLine())!=null) {
            String[] tokens = line.split("\t");
            int index=0;
            for(int i=0; i<ca.numRows; i++) {
                for(int j=0; j<ca.numCols; j++) {
                    countTable[i][j] = Integer.parseInt(tokens[index++]);
                }
            }
            double pValue = ca.test(countTable);
            System.out.println(String.format("%f\t%f", ca.standardStatistic, pValue));
        }
        long elapsedTime = System.currentTimeMillis() - startTime;
        System.out.println("run time (in milliseconds): " + elapsedTime);
        infile.close();
    }
public static void main ( String [ ] args ) throws IOException { if ( args . length != 1 ) { System . out . println ( "usage: java CochranArmitage <input-filename> <output-filename>" ) ; System . exit ( 1 ) ; } long startTime = System . currentTimeMillis ( ) ; String inputFileName = args [ 0 ] ; int [ ] weights = { 0 , 1 , 2 } ; CochranArmitage ca = new CochranArmitage ( weights ) ; System . out . println ( "score\tp-value" ) ; BufferedReader infile = new BufferedReader ( new FileReader ( inputFileName ) ) ; int [ ] [ ] countTable = new int [ ca . numRows ] [ ca . numCols ] ; String line = null ; while ( ( line = infile . readLine ( ) ) != null ) { String [ ] tokens = line . split ( "\t" ) ; int index = 0 ; for ( int i = 0 ; i < ca . numRows ; i ++ ) { for ( int j = 0 ; j < ca . numCols ; j ++ ) { countTable [ i ] [ j ] = Integer . parseInt ( tokens [ index ++ ] ) ; } } double pValue = ca . test ( countTable ) ; System . out . println ( String . format ( "%f\t%f" , ca . standardStatistic , pValue ) ) ; } long elapsedTime = System . currentTimeMillis ( ) - startTime ; System . out . println ( "run time (in milliseconds): " + elapsedTime ) ; infile . close ( ) ; }
@param args input/output files for testing/debugging a series of 6-entry lines each representing a 2x3 matrix
 args[0] as input file
@param args input / output files for testing / debugging a series of 6 - entry lines each representing a 2x3 matrix args [ 0 ] as input file
// populate numRowsxnumCols contingency table