Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend splitHaplotype with fastq output option #2147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/haplotyping/splitHaplotype.C
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public:

_minRatio = 1.0;
_minOutputLength = 1000;
_fastqOutput = false;

_ambiguousName = NULL;
_ambiguousWriter = NULL;
Expand Down Expand Up @@ -127,6 +128,7 @@ public:

double _minRatio;
uint32 _minOutputLength;
bool _fastqOutput;

char *_ambiguousName;
compressedFileWriter *_ambiguousWriter;
Expand Down Expand Up @@ -225,12 +227,14 @@ public:

_names = new simpleString [_maxReads];
_bases = new simpleString [_maxReads];
_quals = new simpleString [_maxReads];
_files = new uint32 [_maxReads];
};

~readBatch() {
delete [] _names;
delete [] _bases;
delete [] _quals;
delete [] _files; // Closed elsewhere!
};

Expand All @@ -239,6 +243,7 @@ public:

simpleString *_names; // Name of each sequence.
simpleString *_bases; // Bases in each sequence.
simpleString *_quals; // Quals in each sequence.
uint32 *_files; // File ID where each sequence should be output.
};

Expand Down Expand Up @@ -549,6 +554,8 @@ loadReadBatch(void *G) {
if (seq.length() >= g->_minOutputLength) { // Loaded something. If it's long
s->_names[rr].set(seq.ident()); // enough, save it to our list.
s->_bases[rr].set(seq.bases(), seq.length());
//if (g->_fastqOutput)
s->_quals[rr].set((const char*)seq.quals(), seq.length());
s->_files[rr] = UINT32_MAX;

s->_numReads++;
Expand Down Expand Up @@ -683,8 +690,13 @@ outputReadBatch(void *G, void *S) {
g->_haps[ff]->nBases += s->_bases[ii].length();
}

if (g->_fastqOutput) {
outputFASTQ(F, s->_bases[ii].string(),(const uint8*) s->_quals[ii].string(), s->_bases[ii].length(),
"%s", s->_names[ii].string());
} else {
outputFASTA(F, s->_bases[ii].string(), s->_bases[ii].length(), 0,
"%s", s->_names[ii].string());
}
}

delete s; // We should recycle this, but hard to do.
Expand Down Expand Up @@ -727,6 +739,8 @@ main(int argc, char **argv) {
} else if (strcmp(argv[arg], "-cl") == 0) {
G->_minOutputLength = strtouint32(argv[++arg]);

} else if (strcmp(argv[arg], "-fastq") == 0) {
G->_fastqOutput = true;
} else if (strcmp(argv[arg], "-threads") == 0) {
G->_numThreads = setNumThreads(argv[++arg]);

Expand Down Expand Up @@ -789,6 +803,7 @@ main(int argc, char **argv) {
fprintf(stderr, "PARAMETERS\n");
fprintf(stderr, " -cr ratio minimum ratio between best and second best to classify\n");
fprintf(stderr, " -cl length minimum length of output read\n");
fprintf(stderr, " -fastq print fastq output instead of fasta\n");
fprintf(stderr, "\n");
fprintf(stderr, " -v report how many batches per second are being processed\n");
fprintf(stderr, "\n");
Expand Down