Skip to content

Commit

Permalink
print_bed is back
Browse files Browse the repository at this point in the history
  • Loading branch information
fafa13 committed Jan 16, 2019
1 parent 4193cf4 commit 9ffb3c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
3 changes: 0 additions & 3 deletions command/free_gtf_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ int free_gtf_data(GTF_DATA *gtf_data) {
free(row->field);

for (j = 0; j < row->attributes.nb; j++) {
//if (row->attributes.attr[j]->key != NULL) free(row->attributes.attr[j]->key);
//if (row->attributes.attr[j]->value != NULL) free(row->attributes.attr[j]->value);
//free(row->attributes.attr[j]);
if ((row->attributes.attr + j)->key != NULL) free((row->attributes.attr + j)->key);
if ((row->attributes.attr + j)->value != NULL) free((row->attributes.attr + j)->value);
}
Expand Down
30 changes: 30 additions & 0 deletions command/print_bed.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* write_bed.c
*
* Created on: December 7, 2018
* Author: puthier (based on Fafa code...)
* Objective: print a gtf obj in bed format
*/

#include "libgtftk.h"

extern void print_row_bed(FILE *output, GTF_ROW *r, char delim, int add_chr, char *keys, char *sep, char *more_info);

__attribute__ ((visibility ("default")))
void *print_bed(GTF_DATA *gtf_data, char *output, int add_chr, char *keys, char *sep, char *more_info) {
int i;
FILE *out = stdout;

if (gtf_data != NULL) {
if (*output != '-') out = fopen(output, "w");
if (out == NULL) out = stdout;
for (i = 0; i < gtf_data->size; i++){
print_row_bed(out, gtf_data->data[i], '\t', add_chr, keys, sep, more_info);
}
if (out != stdout) {
fflush(out);
fclose(out);
}
}
return 0;
}

0 comments on commit 9ffb3c9

Please sign in to comment.