CosteaPaul / qaTools

Some more QA
5 stars 5 forks source link

Cannot get qaTools to compile #1

Closed bastian-wur closed 4 years ago

bastian-wur commented 6 years ago

Hi there,

I wonder what exactly I need to do to get qaTools to compile.

I tried using metaSNV, but when I try to use it, I get: /exports/mm-hpc/bacteriologie/bastian/tools/metaSNV/src/qaTools/qaCompute: error while loading shared libraries: libhts.so.0: cannot open shared object file: No such file or directory

So I tried using it directly: /exports/mm-hpc/bacteriologie/bastian/tools/metaSNV/src/qaTools/qaCompute P16005-02-08-2016_S4_All_qc_5GB-fastq-non_human_mRNA-1-fastq-gz.bam test.txt

Which leads to (end of output)

Basing coverage on 3 reads
Coverage sum 42 ! 
Average coverage over contig_2203 : 0.00
Computing contig_2204 of size 38920... 
Basing coverage on 1 reads
Coverage sum 15 ! 
Average coverage over contig_2204 : 0.00
Computing contig_2205 of size 38901... 
Segmentation fault (core dumped)

therefore I downloaded qaTools directly, to compile it myself (under the assumption that the issue is caused by the 2 dozen of different processor types in our cluster) So I removed the executable, and just typed "make", which gives me

g++ -I/usr/lib/samtools -I/usr/include/htslib -c -Wall removeUnmapped.c
removeUnmapped.c: In function ‘bool is_mapped(const bam1_t*, int, double)’:
removeUnmapped.c:39:22: error: ‘bam1_cigar’ was not declared in this scope
     if ((bam1_cigar(b)[i] & BAM_CIGAR_MASK) == BAM_CMATCH) {
                      ^
removeUnmapped.c: At global scope:
removeUnmapped.c:73:1: error: ‘samfile_t’ does not name a type
 samfile_t * open_alignment_file(std::string path, void* aux = NULL)
 ^
removeUnmapped.c: In function ‘bool isJunction(const bam1_t*)’:
removeUnmapped.c:97:30: error: ‘bam1_cigar’ was not declared in this scope
     int op = bam1_cigar(entry)[k] & BAM_CIGAR_MASK; //operation
                              ^
removeUnmapped.c: In function ‘void print_bam_to_fastq(bam1_t*, FILE*, int)’:
removeUnmapped.c:116:9: warning: statement has no effect [-Wunused-value]
   for (i; (i<core->l_qseq) && (i<cutoff); ++i) {
         ^
removeUnmapped.c:117:14: error: ‘bam_nt16_rev_table’ was not declared in this scope
     seq[i] = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
              ^
removeUnmapped.c:117:53: error: ‘bam1_seq’ was not declared in this scope
     seq[i] = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
                                                     ^
removeUnmapped.c:117:57: error: ‘bam1_seqi’ was not declared in this scope
     seq[i] = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
                                                         ^
removeUnmapped.c:119:26: error: ‘bam1_qual’ was not declared in this scope
     qual[i] = bam1_qual(b)[i]+64;
                          ^
removeUnmapped.c:124:48: error: ‘bam1_qname’ was not declared in this scope
   fprintf(fastq,"@%s\n%s\n+\n%s\n",bam1_qname(b),seq,qual);
                                                ^
removeUnmapped.c: In function ‘int main(int, char**)’:
removeUnmapped.c:132:5: error: ‘samfile_t’ was not declared in this scope
     samfile_t *fp;
     ^
removeUnmapped.c:132:16: error: ‘fp’ was not declared in this scope
     samfile_t *fp;
                ^
removeUnmapped.c:133:16: error: ‘out’ was not declared in this scope
     samfile_t *out;
                ^
removeUnmapped.c:134:16: error: ‘out_rem’ was not declared in this scope
     samfile_t *out_rem = NULL;
                ^
removeUnmapped.c:150:52: error: ‘getopt’ was not declared in this scope
     while ((arg = getopt(argc, argv, "q:i:slk:d:g:")) >= 0) {
                                                    ^
removeUnmapped.c:152:32: error: ‘optarg’ was not declared in this scope
       case 'q': minQual = atoi(optarg); break;
                                ^
removeUnmapped.c:152:38: error: ‘atoi’ was not declared in this scope
       case 'q': minQual = atoi(optarg); break;
                                      ^
removeUnmapped.c:161:37: error: ‘strlen’ was not declared in this scope
  good_file = new char[ strlen(optarg) ];
                                     ^
removeUnmapped.c:162:26: error: ‘strcpy’ was not declared in this scope
  strcpy(good_file, optarg);
                          ^
removeUnmapped.c:171:31: error: ‘strtod’ was not declared in this scope
  identity = strtod(optarg,NULL);
                               ^
removeUnmapped.c:185:14: error: ‘optind’ was not declared in this scope
     if (argc-optind != 2) {
              ^
removeUnmapped.c:191:35: error: ‘optind’ was not declared in this scope
     fp = open_alignment_file(argv[optind]);
                                   ^
removeUnmapped.c:191:42: error: ‘open_alignment_file’ was not declared in this scope
     fp = open_alignment_file(argv[optind]);
                                          ^
removeUnmapped.c:229:24: error: ‘samread’ was not declared in this scope
     while (samread(fp,b) >= 0) {
                        ^
removeUnmapped.c:231:16: error: ‘samwrite’ was not declared in this scope
  samwrite(out,b);
                ^
removeUnmapped.c:237:22: error: ‘samwrite’ was not declared in this scope
    samwrite(out_rem,b);
                      ^
removeUnmapped.c:244:25: error: ‘samread’ was not declared in this scope
     while (samread(fp, b) >= 0) {
                         ^
removeUnmapped.c:249:47: error: ‘abs’ was not declared in this scope
  b->core.isize = abs(b->core.pos - c->core.pos);
                                               ^
removeUnmapped.c:252:99: error: ‘abs’ was not declared in this scope
       if (is_mapped(b, minQual,identity) && is_mapped(c, minQual,identity) && ( (abs(b->core.isize) >= minInsert) || (b->core.tid != c->core.tid) )) {
                                                                                                   ^
removeUnmapped.c:253:30: error: ‘bam1_qname’ was not declared in this scope
  string b_name = bam1_qname(b);
                              ^
removeUnmapped.c:255:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (b_name.find('/') != -1) {
                           ^
removeUnmapped.c:260:16: error: ‘samwrite’ was not declared in this scope
  samwrite(out,b);
                ^
removeUnmapped.c:283:18: error: ‘samwrite’ was not declared in this scope
    samwrite(out,c);
                  ^
removeUnmapped.c:284:66: error: ‘bam1_qname’ was not declared in this scope
    fprintf(stderr,"Writing c: %s\t%s\t%d\t%d\t%d\n", bam1_qname(c),fp->header->target_name[c->core.tid], b->core.qual, b->core.flag&BAM_FUNMAP, c->core.flag&BAM_FUNMAP);
                                                                  ^
removeUnmapped.c:287:66: error: ‘bam1_qname’ was not declared in this scope
    fprintf(stderr,"Writing b: %s\t%s\t%d\t%d\t%d\n", bam1_qname(b), fp->header->target_name[b->core.tid] ,c->core.qual, b->core.flag&BAM_FUNMAP, c->core.flag&BAM_FUNMAP);
                                                                  ^
removeUnmapped.c:288:18: error: ‘samwrite’ was not declared in this scope
    samwrite(out,b);
                  ^
removeUnmapped.c:295:23: error: ‘samwrite’ was not declared in this scope
    samwrite(out_rem, b);
                       ^
removeUnmapped.c:306:14: error: ‘samclose’ was not declared in this scope
   samclose(fp);
              ^
make: *** [removeUnmapped.o] Error 1

And my C++ is really bad, so I do not understand what the error means. (I did however replace the path to htslib (which seems to be causing all the trouble) and to samtools)

Any advice :)?

Bastian

CosteaPaul commented 6 years ago

You need to have htslib and samtools installed. The first error: error while loading shared libraries: libhts.so.0: cannot open shared object file: No such file or directory

just says it can't find hts lib. Check out: http://www.htslib.org/download/

The make errors are related to the paths you figured out. The compiler needs to know where to fetch all these function definitions from. But then, at run-time it also needs to know where to find the library. For example, the "libhts.so"...

bastian-wur commented 6 years ago

Yeah, you're right. Seems I pointed the makefile to the wrong directory for htslib (to the default installation, not to the one in my conda installation), so that is fixed now :). Still cannot get it to compile :/, samtools now the problem. Could you tell me with which version you compiled it? I've tried 0.1.18, 0.1.19, 1.1, 1.2, 1.3.1, 1.4, 1.5 and 1.6 (just because they were all installed), but there are always errors (different though between the 0.x and 1.x versions, but I guess that should be ^^).

EDIT: Not sure what happened, but at some point during the testing a working executable appeared (for qaCompute and removeUnmapped, not for the rest), and metaSVN is now running with it... Seriously confusing, since I have no idea what combo resulted in the executable, and I cannot reproduce it....mmmhhh....