Ejemplo n.º 1
0
void faPolyASizes(char *inFile, char *outFile)
/* faPolyASizes - get poly-A tail sizes*/
{
DNA *seq;
int size;
char *name;
struct lineFile *lf = lineFileOpen(inFile, TRUE);
FILE *f = mustOpen(outFile, "w");

while (faSomeSpeedReadNext(lf, &seq, &size, &name, FALSE))
    fprintf(f, "%s\t%d\t%d\t%d\n", name, size,
            maskTailPolyA(seq, size), maskHeadPolyT(seq, size));
}
Ejemplo n.º 2
0
void polyTrimSeq(struct dnaSeq *seq, FILE *fh)
/*  trim a sequence */
{
if (trimPolyA)
    {
    int sz = maskTailPolyA(seq->dna, seq->size);
    seq->size -= sz;
    seq->dna[seq->size] = '\0';
    }
if (trimPolyT)
    {
    int sz = maskHeadPolyT(seq->dna, seq->size);
    seq->size -= sz;
    seq->dna += sz;
    }

faWriteNext(fh, seq->name, seq->dna, seq->size);
}
void trimSeq(struct dnaSeq *seq, struct dnaSeq *trimmed)
/* Copy seq to trimmed (shallow copy) and optionally trim
 * off polyA tail or polyT head. */
{
DNA *dna = seq->dna;
int size = seq->size;
*trimmed = *seq;
if (trimT)
    maskHeadPolyT(dna, size);
if (trimA || trimHardA)
    {
    int trimSize = maskTailPolyA(dna, size);
    if (trimHardA)
	{
	trimmed->size -= trimSize;
	dna[size-trimSize] = 0;
	}
    }
}
void outFaWrite(struct outFa* outFa, struct gbFa* inFa)
/* write a record to the output fasta, open or switch to a new file
 * if needed. */
{
if ((maxFaSize > 0) && (outFa->fa != NULL) && (outFa->fa->off > maxFaSize))
    outFaClose(outFa);
if (outFa->fa == NULL)
    outFaOpen(outFa);
gbFaWriteFromFa(outFa->fa, inFa, NULL);
outFa->numSeqs++;
outFa->numBases += inFa->seqLen;

if (outFa->polyAFh != NULL)
    {
    /* note, this modifies the fasta sequence, but we don't care any more */
    fprintf(outFa->polyAFh, "%s\t%d\t%d\t%d\n", inFa->id, inFa->seqLen,
            maskTailPolyA(inFa->seq, inFa->seqLen),
            maskHeadPolyT(inFa->seq, inFa->seqLen));
    }
}