Package: libgoby-java / 3.3.1+dfsg2-11

using_commons-cli.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
Description: using classes of commons-cli instead of unpackaged ones
Author: Pierre Gruet <pgt@debian.org>
Forwarded: not-needed
Last-Update: 2021-07-31

--- a/goby-distribution/src/main/java/org/campagnelab/goby/algorithmic/algorithm/dmr/EstimatedDistribution.java
+++ b/goby-distribution/src/main/java/org/campagnelab/goby/algorithmic/algorithm/dmr/EstimatedDistribution.java
@@ -19,7 +19,7 @@
 package org.campagnelab.goby.algorithmic.algorithm.dmr;
 
 import org.campagnelab.goby.algorithmic.algorithm.FenwickTree;
-import edu.mssm.crover.cli.CLI;
+import org.apache.commons.cli.*;
 import it.unimi.dsi.fastutil.ints.IntArrayList;
 import it.unimi.dsi.fastutil.io.BinIO;
 import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@@ -240,68 +240,113 @@
     }
 
     public static void main(final String[] args) throws IOException {
-        boolean printDensity = CLI.isKeywordGiven(args, "--print-density");
-        boolean printObservations = CLI.isKeywordGiven(args, "--print-observations");
-        String filename = CLI.getOption(args, "-f", null);
-        String outputFilename = CLI.getOption(args, "-o", "out.tsv");
-        PrintWriter outWriter = new PrintWriter(new FileWriter(outputFilename));
-        if (printDensity) {
-            EstimatedDistribution estimated = null;
-
-            try {
-                estimated = load(filename);
-                String statName = estimated.getStatAdaptor().statName();
-                System.out.println("Statistic=" + statName);
-                System.out.println("binning strategy=" + estimated.getBinningStrategy().getName());
-                int index = 0;
-                outWriter.println("midPointSumTotal\tsumTotal range\t" + statName + "\tcount-at-" + statName);
-                final BinningStrategy binningStrategy = estimated.getBinningStrategy();
-                for (final FenwickTree tree : estimated.densitities) {
-                    if (tree != null) {
-                        int low = binningStrategy.getLowerBound(index);
-                        int high = binningStrategy.getUpperBound(index);
-
-                        int midPointSumTotal = binningStrategy.getMidpoint(index);
-                        System.out.printf("low=%d high=%d midPoint=%d %n", low, high, midPointSumTotal);
-                        final long maxCumulative = tree.getCumulativeCount(tree.size() - 2);
-                        for (int scaledStatistic = 0; scaledStatistic < tree.size() - 1; scaledStatistic++) {
-                            final long cumulativeCountAt = tree.getCumulativeCount(scaledStatistic);
-                            final long cumulativeCountAfter = tree.getCumulativeCount(scaledStatistic + 1);
-
-                            outWriter.printf("%d\t[%d-%d]\t%g\t%d%n", midPointSumTotal, binningStrategy.getLowerBound(index),
-                                    binningStrategy.getUpperBound(index), estimated.unscale(scaledStatistic), cumulativeCountAfter - cumulativeCountAt);
-                            if (cumulativeCountAfter == maxCumulative) {
-                                break;
+        Options options = new Options();
+
+        Option pDensity = new Option("printDensity", "print-density", false, "print density");
+        pDensity.setRequired(false);
+        options.addOption(pDensity);
+
+        Option pObservations = new Option("printObservations", "print-observations", false, "print observations");
+        pObservations.setRequired(false);
+        options.addOption(pObservations);
+
+        Option fname = new Option("filename", "filename", true, "filename");
+        fname.setRequired(false);
+        options.addOption(fname);
+
+        Option o = new Option("o", "o", true, "output filename");
+        o.setRequired(false);
+        options.addOption(o);
+
+        CommandLineParser parser = new DefaultParser();
+        CommandLine cmd;
+        String filename;
+        String outputFilename;
+        boolean printDensity;
+        boolean printObservations;
+
+        try {
+            cmd = parser.parse(options, args);
+            printDensity = cmd.hasOption("printDensity");
+
+            printObservations = cmd.hasOption("printObservations");
+
+            if (cmd.hasOption("f")) {
+                filename = cmd.getOptionValue("f");
+            }
+            else {
+                filename = null;
+            }
+
+            if (cmd.hasOption("o")) {
+                outputFilename = cmd.getOptionValue("o");
+            }
+            else {
+                outputFilename = new String("out.tsv");
+            }
+
+            PrintWriter outWriter = new PrintWriter(new FileWriter(outputFilename));
+            if (printDensity) {
+                EstimatedDistribution estimated = null;
+
+                try {
+                    estimated = load(filename);
+                    String statName = estimated.getStatAdaptor().statName();
+                    System.out.println("Statistic=" + statName);
+                    System.out.println("binning strategy=" + estimated.getBinningStrategy().getName());
+                    int index = 0;
+                    outWriter.println("midPointSumTotal\tsumTotal range\t" + statName + "\tcount-at-" + statName);
+                    final BinningStrategy binningStrategy = estimated.getBinningStrategy();
+                    for (final FenwickTree tree : estimated.densitities) {
+                        if (tree != null) {
+                            int low = binningStrategy.getLowerBound(index);
+                            int high = binningStrategy.getUpperBound(index);
+
+                            int midPointSumTotal = binningStrategy.getMidpoint(index);
+                            System.out.printf("low=%d high=%d midPoint=%d %n", low, high, midPointSumTotal);
+                            final long maxCumulative = tree.getCumulativeCount(tree.size() - 2);
+                            for (int scaledStatistic = 0; scaledStatistic < tree.size() - 1; scaledStatistic++) {
+                                final long cumulativeCountAt = tree.getCumulativeCount(scaledStatistic);
+                                final long cumulativeCountAfter = tree.getCumulativeCount(scaledStatistic + 1);
+
+                                outWriter.printf("%d\t[%d-%d]\t%g\t%d%n", midPointSumTotal, binningStrategy.getLowerBound(index),
+                                        binningStrategy.getUpperBound(index), estimated.unscale(scaledStatistic), cumulativeCountAfter - cumulativeCountAt);
+                                if (cumulativeCountAfter == maxCumulative) {
+                                    break;
+                                }
                             }
                         }
-                    }
-                    index++;
+                        index++;
 
+                    }
+                    outWriter.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    System.exit(1);
                 }
-                outWriter.close();
-            } catch (Exception e) {
-                e.printStackTrace();
-                System.exit(1);
-            }
 
-        }
-        if (printObservations) {
+            }
+            if (printObservations) {
 
-            EstimatedDistribution estimated = null;
+                EstimatedDistribution estimated = null;
 
-            try {
-                estimated = load(filename);
-                String statName = estimated.getStatAdaptor().statName();
-                outWriter.println("tscaled-" + statName + "\t" + statName + "\tcovariates\n");
-                for (final Observation observation : estimated.getObservations()) {
-                    outWriter.printf("%d\t%d\t%g\t%s%n", observation.scaledStatistic,
-                            estimated.unscale(observation.scaledStatistic), IntArrayList.wrap(observation.covariates));
+                try {
+                    estimated = load(filename);
+                    String statName = estimated.getStatAdaptor().statName();
+                    outWriter.println("tscaled-" + statName + "\t" + statName + "\tcovariates\n");
+                    for (final Observation observation : estimated.getObservations()) {
+                        outWriter.printf("%d\t%d\t%g\t%s%n", observation.scaledStatistic,
+                                estimated.unscale(observation.scaledStatistic), IntArrayList.wrap(observation.covariates));
+                    }
+                    outWriter.close();
+                } catch (ClassNotFoundException e) {
+                    e.printStackTrace();
+                    System.exit(1);
                 }
-                outWriter.close();
-            } catch (ClassNotFoundException e) {
-                e.printStackTrace();
-                System.exit(1);
             }
+        } catch (ParseException e) {
+            System.out.println(e.getMessage());
+            System.exit(1);
         }
     }
 
--- a/goby-distribution/src/main/java/org/campagnelab/goby/cli/FoldChangeForExonPairs.java
+++ b/goby-distribution/src/main/java/org/campagnelab/goby/cli/FoldChangeForExonPairs.java
@@ -19,7 +19,7 @@
 package org.campagnelab.goby.cli;
 
 import edu.cornell.med.icb.io.TSVReader;
-import edu.mssm.crover.cli.CLI;
+import org.apache.commons.cli.*;
 
 import java.io.FileReader;
 import java.io.FileNotFoundException;
@@ -46,38 +46,109 @@
     }
 
     private void process(String[] args) throws FileNotFoundException {
-        String inputFilenames = CLI.getOption(args, "--data", "expression-data.tsv,expression-data2.tsv");
-        String pairsFilename = CLI.getOption(args, "--pairs", "pairs.tsv");
-        String log2AverageId = CLI.getOption(args, "--group", "average log2_RPKM group UHR(BUQ)");
-        String outputFilename = CLI.getOption(args, "--output", "/data/gc-weights/exons/out.tsv");
-        String averageCountId = CLI.getOption(args, "--threshold-id", "average count group Brain");
-        int thresholdValue = CLI.getIntOption(args, "--threshold-value", 20);
-
-        //  String groupB= CLI.getOption(args,"-2","average RPKM group UHR(BUQ)");
-        int log2AverageColumnIndex = -1;
-        Object2DoubleMap<MutableString> exonExpressionData;
-
-
-        ObjectArrayList<Pair> pairs = loadPairs(pairsFilename);
-        PrintWriter output = new PrintWriter(outputFilename);
-        output.printf("experiment\texonId1\texonId2\tlog2RpkmExon1-log2RpkmExon2%n");
-        for (String inputFilename : inputFilenames.split("[,]")) {
-
-            System.out.println("Processing " + inputFilename);
-            exonExpressionData = loadData(inputFilename, log2AverageId, averageCountId, thresholdValue);
-            System.out.println("Size: " + exonExpressionData.size());
-            System.out.println("Writing data..");
-            for (Pair pair : pairs) {
-                //calculate log2 RPKM exonId1 - exonId2:
-                if (exonExpressionData.containsKey(pair.exonId1) && exonExpressionData.containsKey(pair.exonId2)) {
-                    double log2FoldChangeExons = exonExpressionData.get(pair.exonId1) - exonExpressionData.get(pair.exonId2);
-                    output.printf("%s\t%s\t%s\t%g%n", FilenameUtils.getBaseName(inputFilename),
-                            pair.exonId1, pair.exonId2, log2FoldChangeExons);
-                }
+        Options options = new Options();
+
+        Option oData = new Option("data", "data", true, "data");
+        oData.setRequired(false);
+        options.addOption(oData);
+
+        Option oPairs = new Option("pairs", "pairs", true, "pairs");
+        oPairs.setRequired(false);
+        options.addOption(oPairs);
+
+        Option oGroup = new Option("group", "group", true, "group");
+        oGroup.setRequired(false);
+        options.addOption(oGroup);
+
+        Option oOutput = new Option("output", "output", true, "output");
+        oOutput.setRequired(false);
+        options.addOption(oOutput);
+
+        Option oThresId = new Option("thresholdId", "threshold-id", true, "threshold id");
+        oThresId.setRequired(false);
+        options.addOption(oThresId);
+
+        Option oThresVal = new Option("thresholdVal", "threshold-value", true, "threshold value");
+        oThresVal.setRequired(false);
+        options.addOption(oThresVal);
+
+        CommandLineParser parser = new DefaultParser();
+        CommandLine cmd;
+        String inputFilenames;
+        String pairsFilename;
+        String log2AverageId;
+        String outputFilename;
+        String averageCountId;
+        int thresholdValue;
+
+        try {
+            cmd = parser.parse(options, args);
 
+            if (cmd.hasOption("data")) {
+                inputFilenames = cmd.getOptionValue("data");
+            }
+            else {
+                inputFilenames = new String("expression-data.tsv,expression-data2.tsv");
+            }
+            if (cmd.hasOption("pairs")) {
+                pairsFilename = cmd.getOptionValue("pairs");
+            }
+            else {
+                pairsFilename = new String("pairs.tsv");
+            }
+            if (cmd.hasOption("group")) {
+                log2AverageId = cmd.getOptionValue("group");
+            }
+            else {
+                log2AverageId = new String("average log2_RPKM group UHR(BUQ)");
+            }
+            if (cmd.hasOption("output")) {
+                outputFilename = cmd.getOptionValue("output");
+            }
+            else {
+                outputFilename = new String("/data/gc-weights/exons/out.tsv");
+            }
+            if (cmd.hasOption("thresholdId")) {
+                averageCountId = cmd.getOptionValue("thresholdId");
+            }
+            else {
+                averageCountId = new String("average count group Brain");
+            }
+            if (cmd.hasOption("thresholdVal")) {
+                thresholdValue = Integer.parseInt(cmd.getOptionValue("thresholdVal"));
+            }
+            else {
+                thresholdValue = 20;
             }
-        }
 
+            //  String groupB= CLI.getOption(args,"-2","average RPKM group UHR(BUQ)");
+            int log2AverageColumnIndex = -1;
+            Object2DoubleMap<MutableString> exonExpressionData;
+
+
+            ObjectArrayList<Pair> pairs = loadPairs(pairsFilename);
+            PrintWriter output = new PrintWriter(outputFilename);
+            output.printf("experiment\texonId1\texonId2\tlog2RpkmExon1-log2RpkmExon2%n");
+            for (String inputFilename : inputFilenames.split("[,]")) {
+
+                System.out.println("Processing " + inputFilename);
+                exonExpressionData = loadData(inputFilename, log2AverageId, averageCountId, thresholdValue);
+                System.out.println("Size: " + exonExpressionData.size());
+                System.out.println("Writing data..");
+                for (Pair pair : pairs) {
+                    //calculate log2 RPKM exonId1 - exonId2:
+                    if (exonExpressionData.containsKey(pair.exonId1) && exonExpressionData.containsKey(pair.exonId2)) {
+                        double log2FoldChangeExons = exonExpressionData.get(pair.exonId1) - exonExpressionData.get(pair.exonId2);
+                        output.printf("%s\t%s\t%s\t%g%n", FilenameUtils.getBaseName(inputFilename),
+                                pair.exonId1, pair.exonId2, log2FoldChangeExons);
+                    }
+
+                }
+            }
+        } catch (ParseException e) {
+            System.out.println(e.getMessage());
+            System.exit(1);
+        }
     }
 
     private ObjectArrayList<Pair> loadPairs(String pairsFilename) throws FileNotFoundException {
--- a/goby-distribution/src/main/java/org/campagnelab/goby/cli/PlantIndels.java
+++ b/goby-distribution/src/main/java/org/campagnelab/goby/cli/PlantIndels.java
@@ -19,7 +19,7 @@
 package org.campagnelab.goby.cli;
 
 import org.campagnelab.goby.parsers.FastaParser;
-import edu.mssm.crover.cli.CLI;
+import org.apache.commons.cli.*;
 import it.unimi.dsi.lang.MutableString;
 
 import java.io.*;
@@ -40,26 +40,128 @@
     private int numIndels;
 
     public static void main(final String args[]) throws IOException {
-        final String fastaReference = CLI.getOption(args, "-r", null);
-        final String outputFilename = CLI.getOption(args, "-o", "out.fq");
-        final String regionIndelTruth = CLI.getOption(args, "-t", "indel-truth.tsv");
-        // reference sequence to use
-        final String refChoice = CLI.getOption(args, "-c", "22");
-        int from = CLI.getIntOption(args, "-s", 0);
-        int to = CLI.getIntOption(args, "-e", 0);
 
-        if (to < from) {
-            System.err.println("argument to -e must be larger than argument to -s");
-            System.exit(1);
-        }
-        final int indelLength = CLI.getIntOption(args, "-l", 3);
+        Options options = new Options();
+
+        Option oR = new Option("r", "r", true, "r");
+        oR.setRequired(false);
+        options.addOption(oR);
+
+        Option oO = new Option("o", "o", true, "o");
+        oO.setRequired(false);
+        options.addOption(oO);
+
+        Option oT = new Option("t", "t", true, "t");
+        oT.setRequired(false);
+        options.addOption(oT);
+
+        Option oC = new Option("c", "c", true, "c");
+        oC.setRequired(false);
+        options.addOption(oC);
+
+        Option oS = new Option("s", "s", true, "s");
+        oS.setRequired(false);
+        options.addOption(oS);
+
+        Option oE = new Option("e", "e", true, "e");
+        oE.setRequired(false);
+        options.addOption(oE);
+
+        Option oL = new Option("l", "l", true, "l");
+        oL.setRequired(false);
+        options.addOption(oL);
+
+        Option oM = new Option("m", "m", true, "m");
+        oM.setRequired(false);
+        options.addOption(oM);
+
+        Option oRd = new Option("readDeletion", "read-deletion", false, "readDeletion");
+        oRd.setRequired(false);
+        options.addOption(oRd);
+
+        Option oN = new Option("n", "n", true, "n");
+        oN.setRequired(false);
+        options.addOption(oN);
+
+        CommandLineParser parser = new DefaultParser();
+        CommandLine cmd;
+        final String fastaReference;
+        final String outputFilename;
+        final String regionIndelTruth;
+        // reference sequence to use
+        final String refChoice;
+        int from;
+        int to;
+        final int indelLength;
         PlantIndels processor = new PlantIndels();
-        processor.outputFilename = outputFilename;
-        processor.insert = !CLI.isKeywordGiven(args, "--read-deletion");
-        processor.numIndels=CLI.getIntOption(args,"-n",5);
-        processor.process(refChoice, fastaReference, from, to, indelLength, regionIndelTruth);
 
+        try {
+            cmd = parser.parse(options, args);
 
+            if (cmd.hasOption("r")) {
+                fastaReference = cmd.getOptionValue("r");
+            }
+            else {
+                fastaReference = null;
+            }
+            if (cmd.hasOption("o")) {
+                outputFilename = cmd.getOptionValue("o");
+            }
+            else {
+                outputFilename = new String("out.fq");
+            }
+            if (cmd.hasOption("t")) {
+                regionIndelTruth = cmd.getOptionValue("t");
+            }
+            else {
+                regionIndelTruth = new String("indel-truth.tsv");
+            }
+            if (cmd.hasOption("c")) {
+                refChoice = cmd.getOptionValue("c");
+            }
+            else {
+                refChoice = new String("22");
+            }
+            if (cmd.hasOption("s")) {
+                from = Integer.parseInt(cmd.getOptionValue("s"));
+            }
+            else {
+                from = 0;
+            }
+            if (cmd.hasOption("e")) {
+                to = Integer.parseInt(cmd.getOptionValue("e"));
+            }
+            else {
+                to = 0;
+            }
+
+            if (to < from) {
+                System.err.println("argument to -e must be larger than argument to -s");
+                System.exit(1);
+            }
+
+            if (cmd.hasOption("l")) {
+                indelLength = Integer.parseInt(cmd.getOptionValue("l"));
+            }
+            else {
+                indelLength = 3;
+            }
+
+            processor.outputFilename = outputFilename;
+            processor.insert = !cmd.hasOption("readDeletion");
+
+            if (cmd.hasOption("n")) {
+                processor.numIndels = Integer.parseInt(cmd.getOptionValue("n"));
+            }
+            else {
+                processor.numIndels = 5;
+            }
+
+            processor.process(refChoice, fastaReference, from, to, indelLength, regionIndelTruth);
+        } catch (ParseException e) {
+            System.out.println(e.getMessage());
+            System.exit(1);
+        }
     }
 
     public void process(String refChoice, String fastaReference, int from, int to, int indelLength, String regionIndelTruth) throws IOException {
--- a/goby-distribution/src/main/java/org/campagnelab/goby/cli/SimulateBisulfiteReads.java
+++ b/goby-distribution/src/main/java/org/campagnelab/goby/cli/SimulateBisulfiteReads.java
@@ -20,7 +20,7 @@
 
 import org.campagnelab.goby.reads.QualityEncoding;
 import org.campagnelab.goby.parsers.FastaParser;
-import edu.mssm.crover.cli.CLI;
+import org.apache.commons.cli.*;
 import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
 import it.unimi.dsi.fastutil.doubles.DoubleIterator;
 import it.unimi.dsi.fastutil.doubles.DoubleList;
@@ -72,32 +72,152 @@
 
     public static void main(String[] args) throws IOException {
 
-        String fastaReference = CLI.getOption(args, "-r", null);
-        String outputFilename = CLI.getOption(args, "-o", "out.fq");
-        String regionTrueRates = CLI.getOption(args, "-t", "true-methylation.tsv");
+        Options options = new Options();
+
+        Option oR = new Option("r", "r", true, "r");
+        oR.setRequired(false);
+        options.addOption(oR);
+
+        Option oO = new Option("o", "o", true, "o");
+        oO.setRequired(false);
+        options.addOption(oO);
+
+        Option oT = new Option("t", "t", true, "t");
+        oT.setRequired(false);
+        options.addOption(oT);
+
+        Option oC = new Option("c", "c", true, "c");
+        oC.setRequired(false);
+        options.addOption(oC);
+
+        Option oS = new Option("s", "s", true, "s");
+        oS.setRequired(false);
+        options.addOption(oS);
+
+        Option oE = new Option("e", "e", true, "e");
+        oE.setRequired(false);
+        options.addOption(oE);
+
+        Option oL = new Option("l", "l", true, "l");
+        oL.setRequired(false);
+        options.addOption(oL);
+
+        Option oM = new Option("m", "m", true, "m");
+        oM.setRequired(false);
+        options.addOption(oM);
+
+        Option oBs = new Option("bisulfite", "bisulfite", false, "bisulfite");
+        oBs.setRequired(false);
+        options.addOption(oBs);
+
+        Option oStrand = new Option("strand", "strand", true, "strand");
+        oStrand.setRequired(false);
+        options.addOption(oStrand);
+
+        Option oN = new Option("n", "n", true, "n");
+        oN.setRequired(false);
+        options.addOption(oN);
+
+        CommandLineParser parser = new DefaultParser();
+        CommandLine cmd;
+        String fastaReference;
+        String outputFilename;
+        String regionTrueRates;
         // reference sequence to use
-        String refChoice = CLI.getOption(args, "-c", "22");
-        int from = CLI.getIntOption(args, "-s", 0);
-        int to = CLI.getIntOption(args, "-e", 0);
-        if (to < from) {
-            System.err.println("argument to -e must be larger than argument to -s");
-            System.exit(1);
-        }
-        int readLength = CLI.getIntOption(args, "-l", 50);
-        String methylationRateFilename = CLI.getOption(args, "-m", "methylation-rates.tsv");
+        String refChoice;
+        int from;
+        int to;
+        int readLength;
+        String methylationRateFilename;
+        String strandChoice;
         SimulateBisulfiteReads processor = new SimulateBisulfiteReads();
-        final boolean bisulfite = CLI.isKeywordGiven(args, "--bisulfite");
-        String strandChoice = CLI.getOption(args, "--strand", "both");
+        final boolean bisulfite;
 
-        processor.configure(bisulfite, strandChoice);
-        processor.bisulfiteTreatment = bisulfite;
-        processor.readLength = readLength;
-        processor.outputFilename = outputFilename;
-        processor.regionTrueRates = regionTrueRates;
-        processor.numRepeats = CLI.getIntOption(args, "-n", 10000);
-
-        processor.process(refChoice, fastaReference, from, to, methylationRateFilename);
+        try {
+            cmd = parser.parse(options, args);
 
+            if (cmd.hasOption("r")) {
+                fastaReference = cmd.getOptionValue("r");
+            }
+            else {
+                fastaReference = null;
+            }
+            if (cmd.hasOption("o")) {
+                outputFilename = cmd.getOptionValue("o");
+            }
+            else {
+                outputFilename = new String("out.fq");
+            }
+            if (cmd.hasOption("t")) {
+                regionTrueRates = cmd.getOptionValue("t");
+            }
+            else {
+                regionTrueRates = new String("true-methylation.tsv");
+            }
+            if (cmd.hasOption("c")) {
+                refChoice = cmd.getOptionValue("c");
+            }
+            else {
+                refChoice = new String("22");
+            }
+            if (cmd.hasOption("s")) {
+                from = Integer.parseInt(cmd.getOptionValue("s"));
+            }
+            else {
+                from = 0;
+            }
+            if (cmd.hasOption("e")) {
+                to = Integer.parseInt(cmd.getOptionValue("e"));
+            }
+            else {
+                to = 0;
+            }
+
+            if (to < from) {
+                System.err.println("argument to -e must be larger than argument to -s");
+                System.exit(1);
+            }
+
+            if (cmd.hasOption("l")) {
+                readLength = Integer.parseInt(cmd.getOptionValue("l"));
+            }
+            else {
+                readLength = 50;
+            }
+            if (cmd.hasOption("m")) {
+                methylationRateFilename = cmd.getOptionValue("c");
+            }
+            else {
+                methylationRateFilename = new String("methylation-rates.tsv");
+            }
+
+            bisulfite = cmd.hasOption("biSulfite");
+
+            if (cmd.hasOption("strand")) {
+                strandChoice = cmd.getOptionValue("strang");
+            }
+            else {
+                strandChoice = new String("both");
+            }
+
+            processor.configure(bisulfite, strandChoice);
+            processor.bisulfiteTreatment = bisulfite;
+            processor.readLength = readLength;
+            processor.outputFilename = outputFilename;
+            processor.regionTrueRates = regionTrueRates;
+
+            if (cmd.hasOption("n")) {
+                processor.numRepeats = Integer.parseInt(cmd.getOptionValue("n"));
+            }
+            else {
+                processor.numRepeats = 10000;
+            }
+
+            processor.process(refChoice, fastaReference, from, to, methylationRateFilename);
+        } catch (ParseException e) {
+            System.out.println(e.getMessage());
+            System.exit(1);
+        }
     }
 
     public void configure(boolean bisulfite, String strandChoice) {
--- a/goby-distribution/src/main/java/org/campagnelab/goby/methylation/MethylSimilarityScan.java
+++ b/goby-distribution/src/main/java/org/campagnelab/goby/methylation/MethylSimilarityScan.java
@@ -20,7 +20,7 @@
 
 import org.campagnelab.goby.cli.DoInParallel;
 import edu.cornell.med.icb.io.TSVReader;
-import edu.mssm.crover.cli.CLI;
+import org.apache.commons.cli.*;
 import it.unimi.dsi.fastutil.floats.FloatArrayList;
 import it.unimi.dsi.fastutil.ints.*;
 import it.unimi.dsi.fastutil.io.BinIO;
@@ -63,40 +63,92 @@
     }
 
     private void process(String[] args) throws IOException {
-        String inputFilename = CLI.getOption(args, "-i", "/data/lister/mc_h1.tsv");
-        this.windowWidths = CLI.getOption(args, "-w", "10");
-        this.maxBestHits = CLI.getIntOption(args, "-h", 100);
-        String outputFilename = CLI.getOption(args, "-o", "out.tsv");
-        final MethylationData data = load(inputFilename);
-        File outputFile = new File(outputFilename);
-        boolean outputFileExists = outputFile.exists();
-// append:
-        PrintWriter output = new PrintWriter(new FileWriter(outputFilename, true));
 
+        Options options = new Options();
 
-        if (!outputFileExists) {
-            output.write("windowSize\tlocation\tchromosome\tforward strand start\tforward strand end\treverse strand start\treverse strand end\teffective window size\tstatistic\n");
-        }
-        for (String windowWidthString : windowWidths.split("[,]")) {
-            final int windowWidth = Integer.parseInt(windowWidthString);
-            System.out.println("Processing window size=" + windowWidth);
-            final HitBoundedPriorityQueue hits = new HitBoundedPriorityQueue(maxBestHits);
-            DoInParallel scan = new DoInParallel() {
-                @Override
-                public void action(DoInParallel forDataAccess, String chromosome, int loopIndex) {
-                    compareStrands(hits, data, windowWidth, new MutableString(chromosome));
-                }
-            };
+        Option oI = new Option("i", "i", true, "i");
+        oI.setRequired(false);
+        options.addOption(oI);
+
+        Option oW = new Option("w", "w", true, "w");
+        oW.setRequired(false);
+        options.addOption(oW);
+
+        Option oH = new Option("h", "h", true, "h");
+        oH.setRequired(false);
+        options.addOption(oH);
+
+        Option oO = new Option("o", "o", true, "o");
+        oO.setRequired(false);
+        options.addOption(oO);
+
+        CommandLineParser parser = new DefaultParser();
+        CommandLine cmd;
+        String inputFilename;
+        String outputFilename;
+
+        try {
+            cmd = parser.parse(options, args);
+
+            if (cmd.hasOption("i")) {
+                inputFilename = cmd.getOptionValue("i");
+            }
+            else {
+                inputFilename = new String("/data/lister/mc_h1.tsv");
+            }
+            if (cmd.hasOption("w")) {
+                this.windowWidths = cmd.getOptionValue("w");
+            }
+            else {
+                this.windowWidths = new String("10");
+            }
+            if (cmd.hasOption("h")) {
+                this.maxBestHits = Integer.parseInt(cmd.getOptionValue("h"));
+            }
+            else {
+                this.maxBestHits = 100;
+            }
+            if (cmd.hasOption("o")) {
+                outputFilename = cmd.getOptionValue("o");
+            }
+            else {
+                outputFilename = new String("out.tsv");
+            }
 
-            try {
-                scan.execute(true, data.getChromosomeStrings());
-            } catch (Exception e) {
-                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            final MethylationData data = load(inputFilename);
+            File outputFile = new File(outputFilename);
+            boolean outputFileExists = outputFile.exists();
+            // append:
+            PrintWriter output = new PrintWriter(new FileWriter(outputFilename, true));
+
+
+            if (!outputFileExists) {
+                output.write("windowSize\tlocation\tchromosome\tforward strand start\tforward strand end\treverse strand start\treverse strand end\teffective window size\tstatistic\n");
             }
+            for (String windowWidthString : windowWidths.split("[,]")) {
+                final int windowWidth = Integer.parseInt(windowWidthString);
+                System.out.println("Processing window size=" + windowWidth);
+                final HitBoundedPriorityQueue hits = new HitBoundedPriorityQueue(maxBestHits);
+                DoInParallel scan = new DoInParallel() {
+                    @Override
+                    public void action(DoInParallel forDataAccess, String chromosome, int loopIndex) {
+                        compareStrands(hits, data, windowWidth, new MutableString(chromosome));
+                    }
+                };
+
+                try {
+                    scan.execute(true, data.getChromosomeStrings());
+                } catch (Exception e) {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
 
-            printResults(hits, windowWidth, data, output);
+                printResults(hits, windowWidth, data, output);
+            }
+            output.close();
+        } catch (ParseException e) {
+            System.out.println(e.getMessage());
+            System.exit(1);
         }
-        output.close();
     }
 
 
--- a/goby-distribution/src/main/java/org/campagnelab/goby/modes/PercentMismatchesQualityFilter.java
+++ b/goby-distribution/src/main/java/org/campagnelab/goby/modes/PercentMismatchesQualityFilter.java
@@ -20,7 +20,7 @@
 
 package org.campagnelab.goby.modes;
 
-import edu.mssm.crover.cli.CLI;
+import org.apache.commons.cli.*;
 import org.apache.commons.lang.StringUtils;
 import org.campagnelab.goby.alignments.Alignments;
 import org.campagnelab.goby.alignments.filters.AlignmentQualityFilter;
@@ -61,9 +61,30 @@
     }
 
     public void setParameters(final String parameters) {
-        final String[] args = StringUtils.defaultString(parameters).split("[',=]");
-        qualityThresholdPercent = CLI.getDoubleOption(args, "threshold", 0.05d);
-        System.err.println("Setting quality threshold to " + qualityThresholdPercent);
+        final String parametersWithHyphens = StringUtils.replace(parameters, "threshold", "-threshold");
+        final String[] args = StringUtils.defaultString(parametersWithHyphens).split("[',=]");
+        Options options = new Options();
+
+        Option threshold = new Option("threshold", "threshold", true, "threshold");
+        threshold.setRequired(false);
+        options.addOption(threshold);
+        CommandLineParser parser = new DefaultParser();
+        CommandLine cmd;
+
+        try {
+            cmd = parser.parse(options, args);
+
+            if (cmd.hasOption("threshold")) {
+                qualityThresholdPercent = Double.parseDouble(cmd.getOptionValue("threshold"));
+            }
+            else {
+                qualityThresholdPercent = 0.05d;
+            }
+            System.err.println("Setting quality threshold to " + qualityThresholdPercent);
+        } catch (ParseException e) {
+            System.out.println(e.getMessage());
+            System.exit(1);
+        }
     }
 
     public void printUsage(final PrintStream out) {