View Single Post
Old 05-10-2012, 05:51 PM   #13
Richard Finney
Senior Member
 
Location: bethesda

Join Date: Feb 2009
Posts: 701
Default

[ EDIT 6/21/2013 ... see later posts for full, improved more robust version ]
If you want the "orphan" reads [ i.e. read not properly paired], modify bampe2fqs.c as instructed below ...

This will dump "orphan" reads to the file "orphans.fq" in addtion to the pairs in 1.fq and 2.fq

1) Uncomment dump_orphans() call.

2) Add this code to bampe2fqs.c after line with "static Tree tree;"

Remember AVL tree "library" is at http://piumarta.com/software/tree/ as include files and point to your libz and libbam libraries when compiling.

=============== insert after Tree declaration ==============
int orphcnt = 0; // count of orphans reads

void orphan_node_printer(Node *self, void *stream)
{
fprintf(stream,"@%s\n%s\n+\n%s\n",self->name, self->seq,self->qual);
orphcnt++;
}
void dump_orphans()
{
FILE *fpo; // orphan fastqs
fpo = fopen("orphan.fq","w");
TREE_FORWARD_APPLY(&tree, _Node, linkage, orphan_node_printer, fpo);
fclose(fpo);
fprintf(stderr,"DONE, %d orphans flushed\n",orphcnt);
}

Last edited by Richard Finney; 06-21-2013 at 10:47 AM.
Richard Finney is offline   Reply With Quote