]> git.donarmstrong.com Git - rsem.git/blobdiff - Refs.h
Fixed a bug in perl scripts for printing error messages
[rsem.git] / Refs.h
diff --git a/Refs.h b/Refs.h
index 63b67e16e0d705d8c66d3946085f76b79496724c..008d2755e3aa56862566363523028f330de69c5b 100644 (file)
--- a/Refs.h
+++ b/Refs.h
@@ -20,6 +20,7 @@ class Refs {
   Refs() {
     M = 0;
     seqs.clear();
+    has_polyA = false;
   }
 
   ~Refs() {}
@@ -36,6 +37,8 @@ class Refs {
 
   std::vector<RefSeq>& getRefs() { return seqs; } // may be slow, for copying the whole thing
 
+  bool hasPolyA() { return has_polyA; } // if any of sequence has poly(A) tail added
+
   //lim : >=0 If mismatch > lim , return; -1 find all mismatches
   int countMismatch(const std::string& seq, int pos, const std::string& readseq, int LEN, int lim = -1) {
     int nMis = 0; // number of mismatches
@@ -73,7 +76,7 @@ class Refs {
  private:
   int M; // # of isoforms, id starts from 1
   std::vector<RefSeq> seqs;  // reference sequences, starts from 1; 0 is for noise gene
-
+  bool has_polyA; // if at least one sequence has polyA added, the value is true; otherwise, the value is false
 };
 
 //inpF in fasta format
@@ -87,6 +90,7 @@ void Refs::makeRefs(char *inpF, RefSeqPolicy& policy, PolyARules& rules) {
   seqs.push_back(RefSeq()); // noise isoform
 
   M = 0;
+  has_polyA = false;
 
   fin.open(inpF);
   if (!fin.is_open()) { fprintf(stderr, "Cannot open %s! It may not exist.\n", inpF); exit(-1); }
@@ -97,9 +101,13 @@ void Refs::makeRefs(char *inpF, RefSeqPolicy& policy, PolyARules& rules) {
     while((pt = getline(fin, line)) && line[0] != '>') {
       rawseq += line;
     }
-    assert(rawseq.size() > 0);
+    if (rawseq.size() <= 0) {
+      printf("Warning: Fasta entry %s has an empty sequence! It is omitted!\n", tag.c_str()); 
+      continue;
+    }
     ++M;
     seqs.push_back(RefSeq(tag, policy.convert(rawseq), rules.getLenAt(tag)));
+    has_polyA = has_polyA || seqs[M].getFullLen() < seqs[M].getTotLen();
   }
   fin.close();
 
@@ -118,6 +126,7 @@ void Refs::loadRefs(char *inpF, int option) {
   seqs.push_back(RefSeq());
 
   M = 0;
+  has_polyA = false;
 
   bool success;
   do {
@@ -125,6 +134,7 @@ void Refs::loadRefs(char *inpF, int option) {
     if (success) {
        seqs.push_back(seq);
         ++M;
+       has_polyA = has_polyA || seq.getFullLen() < seq.getTotLen();
     }
   } while (success);