MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / getLineNumber

Function getLineNumber

src/myFunc.cpp:355–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355long getLineNumber(std::string const& fileName, std::string const& refFileName, const std::string& pathToSamtools, const std::string& pathToSambamba, const std::string& SambambaThreads) {
356 string line ;
357 long count = 0;
358 FILE *stream;
359 char buffer[MAX_BUFFER];
360
361 if (fileName.substr(fileName.size()-3,3).compare(".gz")==0) {
362 string command = "gzip -cd "+fileName;
363 stream =
364 #if defined(_WIN32)
365 _popen(command.c_str(), "r");
366 #else
367 popen(command.c_str(), "r");
368 #endif
369 while ( fgets(buffer, MAX_BUFFER, stream) != NULL ) {
370 count++;
371 }
372 #if defined(_WIN32)
373 _pclose(stream);
374 #else
375 pclose(stream);
376 #endif
377 }
378 else if (fileName.substr(fileName.size()-4,4).compare(".bam")==0) {
379 string command = "";
380 if (pathToSambamba != "")
381 {
382 command = pathToSambamba + " view -t " + SambambaThreads + " " +fileName;
383 //myInputFormat="sam"; //will try to use existing samtools
384 cout << "..sambamba should be installed to be able to read BAM files\n";
385 }
386 else
387 {
388 command = pathToSamtools + " view -@ "+ SambambaThreads + " " + fileName;
389 //myInputFormat="sam"; //will try to use existing samtools
390 cout << "..samtools should be installed to be able to read BAM files\n";
391 }
392 stream =
393 #if defined(_WIN32)
394 _popen(command.c_str(), "r");
395 #else
396 popen(command.c_str(), "r");
397 #endif
398
399 while ( fgets(buffer, MAX_BUFFER, stream) != NULL ) {
400 count++;
401 }
402 #if defined(_WIN32)
403 _pclose(stream);
404 #else
405 pclose(stream);
406 #endif
407 }
408 else if (fileName.substr(fileName.size()-5,5).compare(".cram")==0) {
409 string command = "";
410 if (refFileName == "")
411 {
412 cout << "..Reference FASTA file (config.fastaFile) should be given to be able to read CRAM files\n";

Callers 1

readCopyNumberMethod · 0.85

Calls 1

compareMethod · 0.80

Tested by

no test coverage detected