From 102cd7714dbd1c1c13d0f4736ec1b1523b359978 Mon Sep 17 00:00:00 2001 From: Bo Li Date: Wed, 10 Oct 2012 16:46:37 -0500 Subject: [PATCH] use if/elsif to replace switch in rsem-calculate-expression --- BamConverter.h | 2 +- BamWriter.h | 5 +---- rsem-calculate-expression | 12 +++++------- simulation.cpp | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/BamConverter.h b/BamConverter.h index eaf2f66..320824b 100644 --- a/BamConverter.h +++ b/BamConverter.h @@ -87,7 +87,7 @@ void BamConverter::process() { if (isPaired) { assert(samread(in, b2) >= 0 && (b2->core.flag & 0x0001)); assert((b->core.flag & 0x0001) && (b2->core.flag & 0x0001)); - assert((b->core.flag & 0x0040) && (b2->core.flag & 0x0080) || (b->core.flag & 0x0080) && (b2->core.flag & 0x0040)); + assert(((b->core.flag & 0x0040) && (b2->core.flag & 0x0080)) || ((b->core.flag & 0x0080) && (b2->core.flag & 0x0040))); ++cnt; } diff --git a/BamWriter.h b/BamWriter.h index 8c568f3..733eaef 100644 --- a/BamWriter.h +++ b/BamWriter.h @@ -119,7 +119,7 @@ void BamWriter::work(HitWrapper wrapper) { if (verbose && cnt % 1000000 == 0) { std::cout<< cnt<< "alignment lines are loaded!"<< std::endl; } assert((b->core.flag & 0x0001) && (b2->core.flag & 0x0001)); - assert((b->core.flag & 0x0040) && (b2->core.flag & 0x0080) || (b->core.flag & 0x0080) && (b2->core.flag & 0x0040)); + assert(((b->core.flag & 0x0040) && (b2->core.flag & 0x0080)) || ((b->core.flag & 0x0080) && (b2->core.flag & 0x0040))); //unalignable reads, skip bool notgood = (b->core.flag & 0x0004) || (b2->core.flag & 0x0004); @@ -140,9 +140,6 @@ void BamWriter::work(HitWrapper wrapper) { convert(b, hit->getConPrb()); convert(b2, hit->getConPrb()); - - b->core.mpos = b2->core.pos; - b2->core.mpos = b->core.pos; } /* diff --git a/rsem-calculate-expression b/rsem-calculate-expression index 955a7f5..f169755 100755 --- a/rsem-calculate-expression +++ b/rsem-calculate-expression @@ -3,7 +3,6 @@ use Getopt::Long; use Pod::Usage; use File::Basename; -use Switch; use strict; #const @@ -246,12 +245,11 @@ if ($quiet) { $command .= " -q"; } &runCommand($command); $command = $dir."rsem-build-read-index $gap"; -switch($read_type) { - case 0 { $command .= " 0 $quiet $imdName\_alignable.fa"; } - case 1 { $command .= " 1 $quiet $imdName\_alignable.fq"; } - case 2 { $command .= " 0 $quiet $imdName\_alignable_1.fa $imdName\_alignable_2.fa"; } - case 3 { $command .= " 1 $quiet $imdName\_alignable_1.fq $imdName\_alignable_2.fq"; } -} +if ($read_type == 0) { $command .= " 0 $quiet $imdName\_alignable.fa"; } +elsif ($read_type == 1) { $command .= " 1 $quiet $imdName\_alignable.fq"; } +elsif ($read_type == 2) { $command .= " 0 $quiet $imdName\_alignable_1.fa $imdName\_alignable_2.fa"; } +elsif ($read_type == 3) { $command .= " 1 $quiet $imdName\_alignable_1.fq $imdName\_alignable_2.fq"; } +else { print "Impossible! read_type is not in [1,2,3,4]!\n"; exit(-1); } &runCommand($command); my $doesOpen = open(OUTPUT, ">$imdName.mparams"); diff --git a/simulation.cpp b/simulation.cpp index 838a88f..1288c65 100644 --- a/simulation.cpp +++ b/simulation.cpp @@ -133,7 +133,7 @@ void simulate(char* modelF, char* resultsF) { size_t pos2 = line.find_first_of('\t', pos); if (pos2 == string::npos) pos2 = line.length(); tpm = atof(line.substr(pos, pos2 - pos).c_str()); - theta[i] = tpm * eel[i]; + theta[i] = tpm * eel[i]; // during simulation, there is no check for effL < 0. The reason is for that case, eel[i] here = 0 and therefore no chance to sample from it denom += theta[i]; } assert(denom > EPSILON); -- 2.39.2