]> git.donarmstrong.com Git - rsem.git/commitdiff
use if/elsif to replace switch in rsem-calculate-expression
authorBo Li <bli@cs.wisc.edu>
Wed, 10 Oct 2012 21:46:37 +0000 (16:46 -0500)
committerBo Li <bli@cs.wisc.edu>
Wed, 10 Oct 2012 21:46:37 +0000 (16:46 -0500)
BamConverter.h
BamWriter.h
rsem-calculate-expression
simulation.cpp

index eaf2f66669d5858a4cd29778d7533a01f5a5690f..320824b5f93a266d3e451dc4ec3a757c4a1dadd4 100644 (file)
@@ -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;
                }
 
index 8c568f348f361fd009c964cd2b9ad021e50fc257..733eaeffacb924b227fa437d5c9e88976c3e6545 100644 (file)
@@ -119,7 +119,7 @@ void BamWriter::work(HitWrapper<PairedEndHit> 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<PairedEndHit> wrapper) {
 
                        convert(b, hit->getConPrb());
                        convert(b2, hit->getConPrb());
-
-                       b->core.mpos = b2->core.pos;
-                       b2->core.mpos = b->core.pos;
                }
 
                /*
index 955a7f5c540ee71ff4b4e94f1238c62524397b5e..f16975545d37dd64e589197b5a2be70d39b596dc 100755 (executable)
@@ -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");
index 838a88fcccae5bf0887c504ac5fef770da8458a7..1288c65178afa360f89f4cff3ee5a2f78b7de5cf 100644 (file)
@@ -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);