Пример #1
0
			static iterator putFastQ(uint8_t const * D, iterator it)
			{
				uint32_t const flags = getFlags(D);
				uint64_t const namelen = getLReadName(D)-1;
				uint64_t const lseq = getLseq(D);
				char const * rn = getReadName(D);
				char const * rne = rn + namelen;

				*(it++) = '@';
				while ( rn != rne )
					*(it++) = *(rn++);
				
				if ( (flags & LIBMAUS_BAMBAM_FPAIRED) )
				{
					if ( (flags & LIBMAUS_BAMBAM_FREAD1) )
					{
						*(it++) = '/';
						*(it++) = '1';
					}
					else
					{
						*(it++) = '/';
						*(it++) = '2';
					}
				}
				
				*(it++) = '\n';
				
				if ( flags & LIBMAUS_BAMBAM_FREVERSE )
					it = decodeReadRCIt(D,it,lseq);
				else
					it = decodeRead(D,it,lseq);
					
				*(it++) = '\n';				

				*(it++) = '+';
				*(it++) = '\n';

				if ( flags & LIBMAUS_BAMBAM_FREVERSE )
				{
					uint8_t const * const quale = getQual(D);
					uint8_t const * qualc = quale + lseq;
					
					while ( qualc != quale )
						*(it++) = *(--qualc) + 33;
				}
				else
				{
					uint8_t const * qual = getQual(D);
					uint8_t const * const quale = qual + lseq;
					
					while ( qual != quale )
						*(it++) = (*(qual++)) + 33;				
				}
				*(it++) = '\n';
				
				return it;
			}				
Пример #2
0
/*
 * Shuts down all currently displayed traces and displays those which are
 * suitable for solving a problem at the specified position.
 */
void tman_problem_traces(EdStruct *xx, int pos) {
    int *seqList, i, tmp;
    char c;
    struct {
	int seq;
	int score;
    } found[20] = {{0,-1}, {0,-1}, {0,-1}, {0,-1}, {0,-1},
		   {0,-1}, {0,-1}, {0,-1}, {0,-1}, {0,-1},
		   {0,-1}, {0,-1}, {0,-1}, {0,-1}, {0,-1},
		   {0,-1}, {0,-1}, {0,-1}, {0,-1}, {0,-1}};

    tman_shutdown_traces(xx, 2);

    /* Gather the list of traces covering this point */
    tmp = xx->reveal_cutoffs;
    xx->reveal_cutoffs = 0;
    seqList = sequencesInRegion(xx, pos, 1);
    xx->reveal_cutoffs = tmp;

    /*
     * What's the consensus character at this point?
     * Run this at 1% to ensure we always get a good estimate of the
     * correct base, rather than simply getting dashes all the while.
     */
    {
	float tmp = xx->con_cut;

	xx->con_cut = 0.01;
	DBcalcConsensus(xx, pos, 1, &c,  NULL, BOTH_STRANDS);
	xx->con_cut = tmp;
    }

    /*
     * Find suitable readings.
     * We're looking for any traces from this set:
     *     found[0]	1st reading conflicting with the consensus (any)
     *     found[1]	1st +ve reading conflicting with the consensus
     *     found[2]	1st -ve reading conflicting with the consensus
     *     found[3]	1st good +ve sense (any) (use quality & consensus)
     *     found[4]	1st good +ve sense primer (use quality & consensus)
     *     found[5]	1st good +ve sense terminator (use quality & consensus)
     *     found[6]	1st good -ve sense (any) (use quality & consensus)
     *     found[7]	1st good -ve sense primer (use quality & consensus)
     *     found[8]	1st good -ve sense terminator (use quality & consensus)
     *     ...
     *     found[10]	2nd reading conflicting with the consensus (any)
     *     found[11]	2nd +ve reading conflicting with the consensus
     *     found[12]	2nd -ve reading conflicting with the consensus
     *     found[13]	2nd good +ve sense (any) (use quality & consensus)
     *     found[14]	2nd good +ve sense primer (use quality & consensus)
     *     found[15]	2nd good +ve sense terminator (use quality & consensus)
     *     found[16]	2nd good -ve sense (any) (use quality & consensus)
     *     found[17]	2nd good -ve sense primer (use quality & consensus)
     *     found[18]	2nd good -ve sense terminator (use quality & consensus)
     */
    for (i=0; seqList[i]; i++) {
	int seq = seqList[i], p = pos - DB_RelPos(xx, seqList[i]) + 1;
	int score;
	int term = (DB_Flags(xx, seq) & DB_FLAG_TERMINATOR) > 0;

	score = getQual(xx, seq, p);

	if (DB_WSeq(xx, seq)[p-1] == c) {
	    /* An agreeing reading */
	    if (DB_Comp(xx, seq) == UNCOMPLEMENTED) {
		if (score > found[4+term].score) {
		    found[14+term] = found[4+term];
		    found[4+term].score = score;
		    found[4+term].seq = seq;
		} else if (score > found[14+term].score) {
		    found[14+term].score = score;
		    found[14+term].seq = seq;
		}
		if (score > found[3].score) {
		    found[13] = found[3];
		    found[3].score = score;
		    found[3].seq = seq;
		} else if (score > found[13].score) {
		    found[13].score = score;
		    found[13].seq = seq;
		}
	    } else {
		if (score > found[7+term].score) {
		    found[17+term] = found[7+term];
		    found[7+term].score = score;
		    found[7+term].seq = seq;
		} else if (score > found[17+term].score) {
		    found[17+term].score = score;
		    found[17+term].seq = seq;
		}
		if (score > found[6].score) {
		    found[16] = found[6];
		    found[6].score = score;
		    found[6].seq = seq;
		} else if (score > found[16].score) {
		    found[16].score = score;
		    found[16].seq = seq;
		}
	    }
	} else {
	    /* A disagreeing reading */
	    if (score > found[1+term].score) {
		found[11+term] = found[1+term];
		found[1+term].score = score;
		found[1+term].seq = seq;
	    } else if (score > found[11+term].score) {
		found[11+term].score = score;
		found[11+term].seq = seq;
	    }
	    if (score > found[0].score) {
		found[10] = found[0];
		found[0].score = score;
		found[0].seq = seq;
	    } else if (score > found[10].score) {
		found[10].score = score;
		found[10].seq = seq;
	    }
	}
    }

    /* Display the traces */
    i = 0;
    while (auto_traces[i] != -1) {
	if (found[auto_traces[i]].seq) {
	    int tmp = xx->compare_trace;
	    xx->compare_trace = -1;

	    showTrace(xx, found[auto_traces[i]].seq,
		      pos - DB_RelPos(xx, found[auto_traces[i]].seq) + 1,
		      xx->fontWidth * 2, 0, 0);

	    xx->compare_trace = tmp;
	}
	i++;
    }
}
Пример #3
0
   //
   // Factory::expPromo_Assign
   //
   SR::Exp::CRef Factory::expPromo_Assign(SR::Type const *typeL,
      SR::Exp const *e, Core::Origin pos)
   {
      auto exp   = expPromo_LValue(e, pos);
      auto typeR = exp->getType();

      // If assigning to same type, no conversion is needed.
      if(typeL->getTypeQual() == typeR->getTypeQual())
         return exp;

      // bool = pointer
      // bool = arithmetic
      if(typeL->isTypeBoolean() && (typeR->isTypePointer() || typeR->isCTypeArith()))
      {
         return expConvert_Bool(typeL, exp, pos);
      }

      // integer = line-special
      if(typeL->isCTypeInteg() && typeR->isTypePointer() &&
         typeR->getBaseType()->isTypeFunction() &&
         typeR->getBaseType()->getCallType() == IR::CallType::Special)
      {
         return expConvert_ArithPtr(typeL, exp, pos);
      }

      // arithmetic = arithmetic
      if(typeL->isCTypeArith())
      {
         if(!typeR->isCTypeArith())
            Core::Error(pos, "cannot implicitly convert to "
               "arithmetic type from non-arithmetic type");

         return expConvert_Arith(typeL, exp, pos);
      }

      // struct = struct
      if(typeL->isCTypeStruct() || typeL->isCTypeUnion())
      {
         if(typeL->getTypeQual() != typeR->getTypeQual())
            Core::Error(pos, "cannot implicitly convert to "
               "incompatible structure or union type");

         return exp;
      }

      // pointer = pointer
      if(typeL->isTypePointer())
      {
         // Check for exp being a null pointer constant.
         if(typeR->isCTypeInteg() && exp->isZero())
            return expConvert_PtrArith(typeL, exp, pos);

         if(!typeR->isTypePointer())
            Core::Error(pos, "cannot implicitly convert to "
               "pointer type from non-pointer type");

         auto baseL = typeL->getBaseType();
         auto baseR = typeR->getBaseType();

         // Treat __str_ent* as char const __str_ars* for these checks.
         if(baseR->isTypeStrEnt())
         {
            SR::TypeQual qual = {{IR::AddrBase::StrArs, Core::STR_}};
            qual.aCons = true;
            baseR = TypeChar->getTypeQual(qual);
         }

         // Check underlying type compatibility.
         if(!baseL->isTypeVoid() && !baseR->isTypeVoid() &&
            baseL->getTypeArrayQual() != baseR->getTypeArrayQual())
            Core::Error(pos, "cannot implicitly convert to "
               "incompatible pointer type");

         auto qualL = baseL->getQual();
         auto qualR = baseR->getQual();

         // Check address space compatibility.
         if(!Target::IsAddrEnclosed(qualL.space, qualR.space))
            Core::Error(pos, "cannot implicitly convert to "
               "pointer to disjoint address space");

         // Check for discarded qualifiers.
         if((!qualL.aAtom && qualR.aAtom) || (!qualL.aCons && qualR.aCons) ||
            (!qualL.aRest && qualR.aRest) || (!qualL.aVola && qualR.aVola))
            Core::Error(pos, "cannot implicitly discard qualifiers");

         return expConvert_Pointer(typeL, exp, pos);
      }

      Core::Error(pos, "cannot implicitly convert");
   }