示例#1
0
void axtToPsl(char *inName, char *tSizeFile, char *qSizeFile, char *outName)
/* axtToPsl - Convert axt to psl format. */
{
struct hash *tSizeHash = readSizes(tSizeFile);
struct hash *qSizeHash = readSizes(qSizeFile);
struct lineFile *lf = lineFileOpen(inName, TRUE);
char strand[2];
FILE *f = mustOpen(outName, "w");
struct psl* psl;
struct axt *axt;
strand[1] = '\0';

while ((axt = axtRead(lf)) != NULL)
    {
    int qSize = findSize(qSizeHash, axt->qName);
    int qStart =  axt->qStart;
    int qEnd = axt->qEnd;
    if (axt->qStrand == '-')
        reverseIntRange(&qStart, &qEnd, qSize);
    strand[0] = axt->qStrand;
    psl = pslFromAlign(axt->qName, qSize, qStart, qEnd, axt->qSym, 
                       axt->tName, findSize(tSizeHash, axt->tName),
                       axt->tStart, axt->tEnd, axt->tSym, strand,
                       PSL_IS_SOFTMASK);
    if (psl != NULL)
	{
	pslTabOut(psl, f);
	pslFree(&psl);
	}
    axtFree(&axt);
    }
lineFileClose(&lf);
carefulClose(&f);
}
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);
    }
}
示例#3
0
void fastaToPsl(char *inName, char *outName)
/* fastaToPsl - Convert axt to psl format. */
{
struct lineFile *inLF;
FILE *outFh;
boolean read;
struct psl* pslAlign;

DNA *qSeq;
int qSize;
int qSeqLen;
char *qHeader;

DNA *tSeq;
int tSize;
int tSeqLen;
char *tHeader;

int queryCounter;

inLF  = lineFileOpen(inName, TRUE);
outFh = mustOpen(outName, "w");

/* read the target sequence */
read = faMixedSpeedReadNext(inLF, &qSeq, &qSize, &qHeader);
if (!read)
    errAbort("Could not read target FASTA entry.");
qSeq    = cloneString(qSeq);
qSeqLen = countNonDash(qSeq, qSize);
qHeader = cloneString(qHeader);
verbose(2, "Query sequence header: %s\n", qHeader);
verbose(3, "Query sequence alignment length: %d\n", qSize);
verbose(3, "Query sequence length: %d\n", qSeqLen);
verbose(4, "Query sequence: %s\n", qSeq);

/* read the rest of the sequences */
queryCounter = 1;
pslWriteHead(outFh);
while (faMixedSpeedReadNext(inLF, &tSeq, &tSize, &tHeader))
    {
    tSeqLen = countNonDash(tSeq, tSize);

    verbose(2, "Target sequence (%d) header: %s\n", queryCounter, tHeader);
    verbose(3, "Target sequence (%d) length: %d\n", queryCounter, tSeqLen);
    verbose(4, "Target sequence (%d): %s\n", queryCounter, tSeq);

    pslAlign = pslFromAlign(qHeader, qSeqLen, 0, qSeqLen, qSeq,
                            tHeader, tSeqLen, 0, tSeqLen, tSeq,
                            "+", 0);
    pslTabOut(pslAlign, outFh);

    ++queryCounter;
    }

lineFileClose(&inLF);
}