chasem77 / ea-utils

Automatically exported from code.google.com/p/ea-utils
0 stars 0 forks source link

sam-stats doesn't support -o and -O option #25

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

$ /software/ea-utils/ea-utils-svn/clipper/sam-stats -O test.sam-stats test.bam
/software/ea-utils/ea-utils-svn/clipper/sam-stats: invalid option -- 'O'
Unknown option `-O'.
Usage: sam-stats [options] [file1] [file2...filen]
Version: 1.37.657
...

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

svn version of ea-utils

Here is a patch (options also sorted alphabetically):

$ svn diff
Index: sam-stats.cpp
===================================================================
--- sam-stats.cpp       (revision 662)
+++ sam-stats.cpp       (working copy)
@@ -222,7 +222,7 @@
     int long_index=0;
     const char *prefix;

-    while ( (c = getopt_long(argc, argv, "?BArR:Ddx:MhS:", long_options, 
&long_index)) != -1) {
+    while ( (c = getopt_long(argc, argv, "?ABDdhMoO:R:rS:x:", long_options, 
&long_index)) != -1) {
                 switch (c) {
                 case 'd': ++debug; break;                                       // increment debug level
                 case 'D': ++trackdup; break;

After this patch, this option is accepted, but it doesn't do anything as far as 
I can tell because the prefix variable is never used afterwards:

$ grep prefix sam-stats.cpp 
    const char *prefix;
                case 'O': prefix=optarg; break;
"-O PREFIX      Output prefix enabling extended output (see below)\n"

Here is some bash code to extract the info:

$ echo "                case 'd': ++debug; break;                               
        // increment debug level
                case 'D': ++trackdup; break;
                case 'B': inbam=1; break;
                case 'A': max_chr=1000000; break;                               // max chrom
                case 'R': rnafile=optarg;                                       // pass through
                case 'r': max_chr=1000000; rnamode=1; if (histnum < 60) histnum=60; break;                                                                                         
                case 'O': prefix=optarg; break;
                case 'S': histnum=atoi(optarg); break;
                case 'x': ext=optarg; break;
                case 'M': newonly=1; break;                                                                      
                case 'o': fq_out=1; trackdup=1; break;                     // output suff
                case 'h': usage(stdout); return 0;
                case '?':
"| grep -E -o "'.?'" |cut -f2 -d "'" | cut -f2 -d "'"| sort | tr -d '\n'

?ABdDhMoOrRSx

Similar problems exist in other tools ( I didn't check all of them ):

For example: fastq-join.c:

There is a check for "-dRnbeo:t:v:m:p:r:", but options "-nbe" don't exist.

Also in the help "-t" is not mentioned (as is "-d" which is OK as it is a debug 
option).

        while ( (c = getopt (argc, argv, "-dRnbeo:t:v:m:p:r:")) != -1) {
                switch (c) {
                case '\1':
                        if (!in[0]) 
                                in[0]=optarg;
                        else if (!in[1])                
                                in[1]=optarg;
                        else if (!in[2])                
                                in[2]=optarg;
                        else {
                                usage(stderr); return 1;
                        }
                        ++in_n;
                        break;
                case 'o': if (out_n == 3) {
                                usage(stderr); return 1;
                          }
                          out[out_n++] = optarg; 
                          break;
                case 'r': orep = optarg; break;
                case 't': threads = atoi(optarg); break;
                case 'm': mino = atoi(optarg); break;
                case 'p': pctdiff = atoi(optarg); break;
                case 'R': norevcomp = true; break;
                case 'd': debug = 1; break;
                case 'v':
                        if (strlen(optarg)>1) {
                                fprintf(stderr, "Option -v requires a single character argument");
                                exit(1);
                        }
                        verify = *optarg; break;
                case '?': 
                     if (strchr("otvmpr", optopt))
                       fprintf (stderr, "Option -%c requires an argument.\n", optopt);
                     else if (isprint(optopt))
                       fprintf (stderr, "Unknown option `-%c'.\n", optopt);
                     else
                       fprintf (stderr,
                                "Unknown option character `\\x%x'.\n",
                                optopt);
                     usage(stderr);
                     return 1;
                }
        }

Original issue reported on code.google.com by hulselma...@gmail.com on 9 Oct 2013 at 2:35

GoogleCodeExporter commented 9 years ago

Original comment by earone...@gmail.com on 13 Nov 2013 at 10:13

GoogleCodeExporter commented 9 years ago
I'm not 100% certain the -O output even works.   I think the usage lines might 
have been written before the function.   I'll be happy to add the patch if you 
say... yes: I patched it and it outputs all the files correctly.   

Original comment by earone...@gmail.com on 2 May 2014 at 5:00

GoogleCodeExporter commented 9 years ago
We have get this up on github ... makes more sense.

Original comment by earone...@gmail.com on 2 May 2014 at 5:01