static void convertToPsl(struct mafComp *qc, struct mafComp *tc, FILE *pslFh)
/* convert two components to a psl */
{
struct psl* psl;
int qStart = qc->start;
int qEnd = qc->start+qc->size;
int tStart = tc->start;
int tEnd = tc->start+tc->size;
char strand[3];
strand[0] = qc->strand;
strand[1] = tc->strand;
strand[2] = '\0';

    
if (qc->strand == '-')
    reverseIntRange(&qStart, &qEnd, qc->srcSize);
if (tc->strand == '-')
    reverseIntRange(&tStart, &tEnd, tc->srcSize);

psl = pslFromAlign(skipDot(qc->src), qc->srcSize, qStart, qEnd, qc->text,
                   skipDot(tc->src), tc->srcSize, tStart, tEnd, tc->text,
                   strand, 0);
if (psl != NULL)
    {
    /* drop target strand */
    if (psl->strand[1] == '-')
        pslRc(psl);
    psl->strand[1] = '\0';
    pslTabOut(psl, pslFh);
    }
}
Ejemplo n.º 2
0
static void adjustOrientation(unsigned opts, struct psl *inPsl, char *inPslOrigStrand,
                              struct psl* mappedPsl)
/* adjust strand, possibly reverse complementing, based on
 * pslTransMapKeepTrans option and input psls. */
{
if (!(opts&pslTransMapKeepTrans) || ((inPslOrigStrand[1] == '\0') && (mappedPsl->strand[1] == '\0')))
    {
    /* make untranslated */
    if (pslTStrand(mappedPsl) == '-')
        pslRc(mappedPsl);
    mappedPsl->strand[1] = '\0';  /* implied target strand */
    }
}
Ejemplo n.º 3
0
int pslShowAlignment(struct psl *psl, boolean isProt,
	char *qName, bioSeq *qSeq, int qStart, int qEnd,
	char *tName, bioSeq *tSeq, int tStart, int tEnd, FILE *f)
/* Show protein/DNA alignment or translated DNA alignment in HTML format. */
{
/* At this step we just do a little shuffling of the strands for
 * untranslated DNA alignments. */
char origStrand[2];
boolean needsSwap = (psl->strand[0] == '-' && psl->strand[1] == 0);
if (needsSwap)
    {
    memcpy(origStrand, psl->strand, 2);
    pslRc(psl);
    }
pslShowAlignmentStranded(psl, isProt, qName, qSeq, qStart, qEnd,
    tName, tSeq, tStart, tEnd, f);
if (needsSwap)
    {
    pslRc(psl);
    memcpy(psl->strand, origStrand, 2);
    }
return psl->blockCount;
}
Ejemplo n.º 4
0
int pslGenoShowAlignment(struct psl *psl, boolean isProt,
                         char *qName, bioSeq *qSeq, int qStart, int qEnd,
                         char *tName, bioSeq *tSeq, int tStart, int tEnd, int exnStarts[], int exnEnds[], int exnCnt, FILE *f)
/* Show aligned exons between a pre-located gene (a stamper gene)and its homologues (stamp elements)
 * in the genome. The aligned exon sequences are shown in blue as regular blat alignment. * The unaligned exon sequence are shown in red. Intron sequences are shown in black */
{
    /* At this step we just do a little shuffling of the strands for
     * untranslated DNA alignments. */
    char origStrand[2];
    boolean needsSwap = (psl->strand[0] == '-' && psl->strand[1] == 0);
    if (needsSwap)
    {
        memcpy(origStrand, psl->strand, 2);
        pslRc(psl);
    }
    pslShowAlignmentStranded2(psl, isProt, qName, qSeq, qStart, qEnd,
                              tName, tSeq, tStart, tEnd,exnStarts, exnEnds, exnCnt, f);
    if (needsSwap)
    {
        pslRc(psl);
        memcpy(psl->strand, origStrand, 2);
    }
    return psl->blockCount;
}
Ejemplo n.º 5
0
static struct hash* loadPslByQname(char* inPslFile)
/* load PSLs in to hash by qName.  Make sure target strand is positive
 * to make process easier later. */
{
struct hash* pslsByQName = hashNew(0);
struct psl *psls = pslLoadAll(inPslFile);
struct psl *psl;
while ((psl = slPopHead(&psls)) != NULL)
    {
    if (pslTStrand(psl) != '+')
        pslRc(psl);
    struct hashEl *hel = hashStore(pslsByQName, psl->qName);
    struct psl** queryPsls = (struct psl**)&hel->val;
    slAddHead(queryPsls, psl);
    }
return pslsByQName;
}
Ejemplo n.º 6
0
void pslRcFile(char *inPslFile, char *outPslFile)
/* reverse target and query in a psl file */
{
struct lineFile *inLf = pslFileOpen(inPslFile);
FILE *outFh = mustOpen(outPslFile, "w");
struct psl *psl;

while ((psl = pslNext(inLf)) != NULL)
    {
    pslRc(psl);
    pslTabOut(psl, outFh);
    pslFree(&psl);
    }

carefulClose(&outFh);
lineFileClose(&inLf);
}
Ejemplo n.º 7
0
struct psl* pslTransMap(unsigned opts, struct psl *inPsl, struct psl *mapPsl)
/* map a psl via a mapping psl, a single psl is returned, or NULL if it
 * couldn't be mapped. */
{
int mappedPslMax = 8; /* allocated space in output psl */
int iMapBlk = 0;
char inPslOrigStrand[3];
boolean rcInPsl = (pslTStrand(inPsl) != pslQStrand(mapPsl));
boolean cnv1 = (pslIsProtein(inPsl) && !pslIsProtein(mapPsl));
boolean cnv2 = (pslIsProtein(mapPsl) && !pslIsProtein(inPsl));
int iBlock;
struct psl* mappedPsl;

/* sanity check size, but allow names to vary to allow ids to have
 * unique-ifying suffixes. */
if (inPsl->tSize != mapPsl->qSize)
    errAbort("Error: inPsl %s tSize (%d) != mapPsl %s qSize (%d)",
            inPsl->tName, inPsl->tSize, mapPsl->qName, mapPsl->qSize);

/* convert protein PSLs */
if (cnv1)
    pslProtToNA(inPsl);
if (cnv2)
    pslProtToNA(mapPsl);

/* need to ensure common sequence is in same orientation, save strand for later */
safef(inPslOrigStrand, sizeof(inPslOrigStrand), "%s", inPsl->strand);
if (rcInPsl)
    pslRc(inPsl);

mappedPsl = createMappedPsl(inPsl, mapPsl, mappedPslMax);

/* Fill in ungapped blocks.  */
for (iBlock = 0; iBlock < inPsl->blockCount; iBlock++)
    {
    struct block align1Blk = blockFromPslBlock(inPsl, iBlock);
    while (mapBlock(inPsl, mapPsl, &iMapBlk, &align1Blk, mappedPsl,
                    &mappedPslMax))
        continue;
    }

/* finish up psl, or free if no blocks were added */
assert(mappedPsl->blockCount <= mappedPslMax);
if (mappedPsl->blockCount == 0)
    pslFree(&mappedPsl);  /* nothing made it */
else
    {
    setPslBounds(mappedPsl);
    adjustOrientation(opts, inPsl, inPslOrigStrand, mappedPsl);
    }

/* restore input */
if (rcInPsl)
    {
    pslRc(inPsl);
    strcpy(inPsl->strand, inPslOrigStrand);
    }
if (cnv1)
    pslNAToProt(inPsl);
if (cnv2)
    pslNAToProt(mapPsl);

return mappedPsl;
}