Skip to content

Commit

Permalink
Merge pull request #77 from SooLee/isoc99
Browse files Browse the repository at this point in the history
Isoc99
  • Loading branch information
clarabakker authored Feb 2, 2024
2 parents ea19c74 + bfe81d1 commit 94d0107
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 80 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.7
0.3.8
2 changes: 1 addition & 1 deletion src/pairix.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef __TABIDX_H
#define __TABIDX_H

#define PACKAGE_VERSION "0.3.7"
#define PACKAGE_VERSION "0.3.8"

#include <stdint.h>
#include "kstring.h"
Expand Down
86 changes: 43 additions & 43 deletions src/pairs_merger.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,6 @@

#define FILENAMEMAX 2000

int main(int argc, char *argv[])
{
int num_fn = argc -1;
int i;
//BGZF *bzfp;
//int f_dst;

if(argc==1){
fprintf(stderr, "\n");
fprintf(stderr, "Program: pairs_merger\n");
fprintf(stderr, "Version: %s\n\n", PACKAGE_VERSION);
//fprintf(stderr, "Usage: pairs_merger <in1.pairs.gz> <in2.pairs.gz> <in3.pairs.gz> ... > out.pairs.gz\n\n");
fprintf(stderr, "Usage: pairs_merger <in1.pairs.gz> <in2.pairs.gz> <in3.pairs.gz> ... | bgzip -c > out.pairs.gz\n\n");
return(1);
}

char *fn_list[num_fn];
for(i=0;i<num_fn;i++) {
fn_list[i]=malloc(FILENAMEMAX*sizeof(char));
strcpy(fn_list[i],argv[i+1]);
}

// write to stdout bgzip
//f_dst = fileno(stdout);
//bzfp = bgzf_dopen(f_dst, "w");

// actually write merged pairs to bzfp stdout
//int res = pairs_merger(fn_list, num_fn, bzfp);
int res = pairs_merger(fn_list, num_fn, NULL);

// close bgzf stream
//if (bgzf_close(bzfp) < 0) fail(bzfp);
//if (bgzf_close(bzfp) < 0){ fprintf(stderr,"Error: %d\n",bzfp->errcode); return(1); }


for(i=0;i<num_fn;i++) {
free(fn_list[i]);
}
return(res);
}

int pairs_merger(char **fn, int n, BGZF *bzfp) // pass bgfp if the result should be bgzipped. or pass NULL.
{
pairix_t *tbs[n];
Expand Down Expand Up @@ -91,6 +50,47 @@ int pairs_merger(char **fn, int n, BGZF *bzfp) // pass bgfp if the result shoul
for(i=0;i<n;i++) ti_close(tbs[i]);
for(i=0;i<n_uniq_seq;i++) free(uniq_seq_list[i]);
free(uniq_seq_list);
return(NULL);
} else { fprintf(stderr,"Null unique seq list\n"); return(NULL); }
return(0);
} else { fprintf(stderr,"Null unique seq list\n"); return(0); }
}

int main(int argc, char *argv[])
{
int num_fn = argc -1;
int i;
//BGZF *bzfp;
//int f_dst;

if(argc==1){
fprintf(stderr, "\n");
fprintf(stderr, "Program: pairs_merger\n");
fprintf(stderr, "Version: %s\n\n", PACKAGE_VERSION);
//fprintf(stderr, "Usage: pairs_merger <in1.pairs.gz> <in2.pairs.gz> <in3.pairs.gz> ... > out.pairs.gz\n\n");
fprintf(stderr, "Usage: pairs_merger <in1.pairs.gz> <in2.pairs.gz> <in3.pairs.gz> ... | bgzip -c > out.pairs.gz\n\n");
return(1);
}

char *fn_list[num_fn];
for(i=0;i<num_fn;i++) {
fn_list[i]=malloc(FILENAMEMAX*sizeof(char));
strcpy(fn_list[i],argv[i+1]);
}

// write to stdout bgzip
//f_dst = fileno(stdout);
//bzfp = bgzf_dopen(f_dst, "w");

// actually write merged pairs to bzfp stdout
//int res = pairs_merger(fn_list, num_fn, bzfp);
int res = pairs_merger(fn_list, num_fn, NULL);

// close bgzf stream
//if (bgzf_close(bzfp) < 0) fail(bzfp);
//if (bgzf_close(bzfp) < 0){ fprintf(stderr,"Error: %d\n",bzfp->errcode); return(1); }


for(i=0;i<num_fn;i++) {
free(fn_list[i]);
}
return(res);
}
71 changes: 36 additions & 35 deletions src/streamer_1d.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,6 @@

#define FILENAMEMAX 2000

int main(int argc, char *argv[])
{
//BGZF *bzfp;
//int f_dst;

if(argc==1){
fprintf(stderr, "\n");
fprintf(stderr, "Program: streamer_1d\n");
fprintf(stderr, "Version: %s\n\n", PACKAGE_VERSION);
fprintf(stderr, "Resorter (convert a file sorted by chr1-chr2-pos1-pos2 to a stream sorted by chr1-pos1)\n\n");
fprintf(stderr, "Usage: streamer_1d in.2d.pairs.gz > out.1d.pairs\n");
fprintf(stderr, "Usage: streamer_1d in.2d.pairs.gz | bgzip -c > out.1d.pairs.gz\n\n");
return(1);
}

char *fn;
fn=malloc(FILENAMEMAX*sizeof(char));
strcpy(fn,argv[1]);

// write to stdout bgzip (This is slower, so don't use it)
//f_dst = fileno(stdout);
//bzfp = bgzf_dopen(f_dst, "w");

// actually write merged pairs to bzfp stdout
//int res = stream_1d(fn, bzfp);
int res = stream_1d(fn);

// close bgzf stream
//if (bgzf_close(bzfp) < 0) fail(bzfp);
//if (bgzf_close(bzfp) < 0){ fprintf(stderr,"Error: %d\n",bzfp->errcode); return(1); }

free(fn);
return(res);
}


// Uc->Up converter - convert a single 2D-sorted file into a 1D-sorted stream.
int stream_1d(char *fn)
Expand Down Expand Up @@ -91,3 +56,39 @@ int stream_1d(char *fn)

return (0);
}

int main(int argc, char *argv[])
{
//BGZF *bzfp;
//int f_dst;

if(argc==1){
fprintf(stderr, "\n");
fprintf(stderr, "Program: streamer_1d\n");
fprintf(stderr, "Version: %s\n\n", PACKAGE_VERSION);
fprintf(stderr, "Resorter (convert a file sorted by chr1-chr2-pos1-pos2 to a stream sorted by chr1-pos1)\n\n");
fprintf(stderr, "Usage: streamer_1d in.2d.pairs.gz > out.1d.pairs\n");
fprintf(stderr, "Usage: streamer_1d in.2d.pairs.gz | bgzip -c > out.1d.pairs.gz\n\n");
return(1);
}

char *fn;
fn=malloc(FILENAMEMAX*sizeof(char));
strcpy(fn,argv[1]);

// write to stdout bgzip (This is slower, so don't use it)
//f_dst = fileno(stdout);
//bzfp = bgzf_dopen(f_dst, "w");

// actually write merged pairs to bzfp stdout
//int res = stream_1d(fn, bzfp);
int res = stream_1d(fn);

// close bgzf stream
//if (bgzf_close(bzfp) < 0) fail(bzfp);
//if (bgzf_close(bzfp) < 0){ fprintf(stderr,"Error: %d\n",bzfp->errcode); return(1); }

free(fn);
return(res);
}

0 comments on commit 94d0107

Please sign in to comment.