Esempio n. 1
0
void pslRecalcMatch(char *inName, char *targetName, char *queryName, 
	char *outName)
/* pslRecalcMatch - Recalculate match,mismatch,repMatch columns in psl file.  
 * This can be useful if the psl went through pslMap, or if you've added 
 * lower-case repeat masking after the fact. */
{
struct nibTwoCache *tCache = nibTwoCacheNew(targetName);
struct dnaSeq *qSeqList = dnaLoadAll(queryName);
struct hash *qHash = dnaSeqHash(qSeqList);
struct psl *psl;
struct lineFile *lf = pslFileOpen(inName);
FILE *f = mustOpen(outName, "w");

while ((psl = pslNext(lf)) != NULL)
    {
    int tSize;
    struct dnaSeq *tSeqPart = nibTwoCacheSeqPart(tCache,
    	psl->tName, psl->tStart, psl->tEnd - psl->tStart, &tSize);
    struct dnaSeq *qSeq = hashMustFindVal(qHash, getQName(psl->qName));
    recalcMatches(psl, tSeqPart, psl->tStart, qSeq);
    pslTabOut(psl, f);
    dnaSeqFree(&tSeqPart);
    }
carefulClose(&f);
lineFileClose(&lf);
}
Esempio n. 2
0
bool UserDefinedXQType::isSuperTypeOf(
    const TypeManager* tm,
    const XQType* subType,
    const QueryLoc& loc) const
{
  if (isUnion() && isGenAtomicAny() && subType->isAtomicAny())
  {
    std::vector<xqtref_t>::const_iterator ite = m_unionItemTypes.begin();
    std::vector<xqtref_t>::const_iterator end = m_unionItemTypes.end();
    for (; ite != end; ++ite)
    {
      if (TypeOps::is_subtype(tm, *subType, *(*ite), loc))
        return true;
    }

    return false;
  }

  if (subType->type_kind() != XQType::USER_DEFINED_KIND)
    return false;

  const UserDefinedXQType* subtype = static_cast<const UserDefinedXQType*>(subType);

  do
  {
    if (getUDTKind() == subtype->getUDTKind() &&
        getQName()->equals(subtype->getQName()))
    {
      return true;
    }

    subType = subtype->getBaseType().getp();

    if (subType->type_kind() != XQType::USER_DEFINED_KIND)
      return false;

    subtype = static_cast<const UserDefinedXQType*>(subType);

  }
  while (subtype != NULL);

  return false;
}
Esempio n. 3
0
static void processHspRec(struct ncbiBlastBlastOutput *outputRec, struct ncbiBlastIteration *iterRec, struct ncbiBlastHit *hitRec,
                          struct ncbiBlastHsp *hspRec, unsigned flags, FILE *pslFh, FILE *scoreFh)
/* process one HSP record, converting to a PSL */
{
int queryLen = (iterRec->ncbiBlastIterationQueryLen != NULL) 
    ? iterRec->ncbiBlastIterationQueryLen->text
    : outputRec->ncbiBlastBlastOutputQueryLen->text;
struct coords qUcsc = blastToUcsc(hspRec->ncbiBlastHspQueryFrom->text, hspRec->ncbiBlastHspQueryTo->text, queryLen,
                                  ((hspRec->ncbiBlastHspQueryFrame == NULL) ? 0 : hspRec->ncbiBlastHspQueryFrame->text));
struct coords tUcsc = blastToUcsc(hspRec->ncbiBlastHspHitFrom->text, hspRec->ncbiBlastHspHitTo->text, hitRec->ncbiBlastHitLen->text,
                                  ((hspRec->ncbiBlastHspHitFrame == NULL) ? 0 : hspRec->ncbiBlastHspHitFrame->text));
struct psl *psl = pslBuildFromHsp(getQName(outputRec, iterRec), qUcsc.size, qUcsc.start, qUcsc.end, qUcsc.strand, hspRec->ncbiBlastHspQseq->text,
                                  getTName(hitRec),  tUcsc.size, tUcsc.start, tUcsc.end, tUcsc.strand, hspRec->ncbiBlastHspHseq->text,
                                  flags);
if  ((psl->blockCount > 0) && ((hspRec->ncbiBlastHspEvalue->text <= eVal) || (eVal == -1)))
    {
    outputPsl(psl, pslFh);
    if (scoreFh != NULL)
        outputScore(psl, outputRec, iterRec, hitRec, hspRec, scoreFh);
    }
pslFree(&psl);
}
Esempio n. 4
0
bool match_expr::matches(const match_expr* other) const
{
  if (theTestKind != other->theTestKind)
    return false;

  switch (theTestKind)
  {
  case match_name_test:
  {
    if (getWildKind() != other->getWildKind())
      return false;

    if (getWildName() != other->getWildName())
      return false;

    if (getWildKind() == match_no_wild || getWildKind() == match_name_wild)
    {
      return getQName()->equals(other->getQName());
    }

    return true;
  }
  case match_anykind_test:
  case match_text_test:
  case match_comment_test:
  {
    return true;
  }
  case match_pi_test:
  {
    if (theQName == NULL && other->theQName == NULL)
      return true;

    if (theQName == NULL || other->theQName == NULL)
      return false;

    return theQName->equals(other->theQName);
  }
  case match_doc_test:
  {
    if (theDocTestKind != other->theDocTestKind)
      return false;

    if (theDocTestKind == match_xs_elem_test)
      goto schema_test;

    // else fall through
  }
  case match_elem_test:
  case match_attr_test:
  {
    if (theQName == NULL || other->theQName == NULL)
    {
      if (theQName != NULL || other->theQName != NULL)
        return false;
    }
    else if (!theQName->equals(other->theQName))
    {
      return false;
    }

    if (theTypeName == NULL || other->theTypeName == NULL)
    {
      if (theTypeName != NULL || other->theTypeName != NULL)
        return false;
    }
    else if (!theTypeName->equals(other->theTypeName))
    {
      return false;
    }

    if (theNilledAllowed != other->theNilledAllowed)
      return false;

    return true;
  }
  case match_xs_elem_test:
  case match_xs_attr_test:
  {
schema_test:
    return (theQName->equals(other->theQName) &&
            theTypeName->equals(other->theTypeName));
  }
  default:
  {
    ZORBA_ASSERT(false);
  }
  }

  return false;
}