lib/dnaseq.c File Reference

#include "common.h"
#include "dnaseq.h"
#include "bits.h"
#include "hash.h"
#include "obscure.h"

Include dependency graph for dnaseq.c:

Go to the source code of this file.

Functions

dnaSeqnewDnaSeq (DNA *dna, int size, char *name)
dnaSeqcloneDnaSeq (struct dnaSeq *orig)
void freeDnaSeq (struct dnaSeq **pSeq)
void freeDnaSeqList (struct dnaSeq **pSeqList)
boolean seqIsLower (bioSeq *seq)
boolean seqIsDna (bioSeq *seq)
aaSeqtranslateSeqN (struct dnaSeq *inSeq, unsigned offset, unsigned inSize, boolean stop)
aaSeqtranslateSeq (struct dnaSeq *inSeq, unsigned offset, boolean stop)
bioSeqwhichSeqIn (bioSeq **seqs, int seqCount, char *letters)
BitsmaskFromUpperCaseSeq (bioSeq *seq)
hashdnaSeqHash (struct dnaSeq *seqList)

Variables

static char const rcsid [] = "$Id: dnaseq.c,v 1.19 2005/11/10 03:40:34 kent Exp $"


Function Documentation

struct dnaSeq* cloneDnaSeq ( struct dnaSeq orig  )  [read]

Definition at line 29 of file dnaseq.c.

References bitClone(), cloneString(), CloneVar, dnaSeq::dna, dnaSeq::mask, dnaSeq::name, needHugeMem(), and dnaSeq::size.

00031 {
00032 struct dnaSeq *seq = CloneVar(orig);
00033 seq->name = cloneString(seq->name);
00034 seq->dna = needHugeMem(seq->size+1);
00035 memcpy(seq->dna, orig->dna, seq->size+1);
00036 seq->mask = NULL;
00037 if (orig->mask != NULL)
00038     {
00039     seq->mask = bitClone(orig->mask, seq->size);
00040     }
00041 return seq;
00042 }

Here is the call graph for this function:

struct hash* dnaSeqHash ( struct dnaSeq seqList  )  [read]

Definition at line 163 of file dnaseq.c.

References digitsBaseTwo(), hashAddUnique(), hashNew, dnaSeq::name, dnaSeq::next, hash::size, and slCount().

00165 {
00166 int size = slCount(seqList)+1;
00167 int sizeLog2 = digitsBaseTwo(size);
00168 struct hash *hash = hashNew(sizeLog2);
00169 struct dnaSeq *seq;
00170 for (seq = seqList; seq != NULL; seq = seq->next)
00171     hashAddUnique(hash, seq->name, seq);
00172 return hash;
00173 }

Here is the call graph for this function:

void freeDnaSeq ( struct dnaSeq **  pSeq  ) 

Definition at line 44 of file dnaseq.c.

References bitFree(), dnaSeq::dna, freeMem(), freez(), dnaSeq::mask, and dnaSeq::name.

Referenced by freeDnaSeqList(), gfAddTilesInNib(), gfAlignStrand(), gfCountTilesInNib(), gfCountTilesInTwoBit(), gfIndexTransNibsAndTwoBits(), searchOneIndex(), and trans3Free().

00046 {
00047 struct dnaSeq *seq = *pSeq;
00048 if (seq == NULL)
00049     return;
00050 freeMem(seq->name);
00051 freeMem(seq->dna);
00052 bitFree(&seq->mask);
00053 freez(pSeq);
00054 }

Here is the call graph for this function:

Here is the caller graph for this function:

void freeDnaSeqList ( struct dnaSeq **  pSeqList  ) 

Definition at line 56 of file dnaseq.c.

References freeDnaSeq(), and dnaSeq::next.

Referenced by blat(), gfAlignTrans(), gfAlignTransTrans(), and gfMakeOoc().

00058 {
00059 struct dnaSeq *seq, *next;
00060 
00061 for (seq = *pSeqList; seq != NULL; seq = next)
00062     {
00063     next = seq->next;
00064     freeDnaSeq(&seq);
00065     }
00066 *pSeqList = NULL;
00067 }

Here is the call graph for this function:

Here is the caller graph for this function:

Bits* maskFromUpperCaseSeq ( bioSeq seq  ) 

Definition at line 148 of file dnaseq.c.

References bitAlloc(), bitSetOne(), dnaSeq::dna, and dnaSeq::size.

Referenced by blat(), gfLargeIndexSeq(), gfSmallIndexSeq(), and maskQuerySeq().

00151 {
00152 int size = seq->size, i;
00153 char *poly = seq->dna;
00154 Bits *b = bitAlloc(size);
00155 for (i=0; i<size; ++i)
00156     {
00157     if (isupper(poly[i]))
00158         bitSetOne(b, i);
00159     }
00160 return b;
00161 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct dnaSeq* newDnaSeq ( DNA dna,
int  size,
char *  name 
) [read]

Definition at line 15 of file dnaseq.c.

References cloneString(), and needMem().

Referenced by faReadMixedNext(), and gffReadDnaSeq().

00017 {
00018 struct dnaSeq *seq;
00019 
00020 seq = needMem(sizeof(*seq));
00021 if (name != NULL)
00022     seq->name = cloneString(name);
00023 seq->dna = dna;
00024 seq->size = size;
00025 seq->mask = NULL;
00026 return seq;
00027 }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean seqIsDna ( bioSeq seq  ) 

Definition at line 80 of file dnaseq.c.

References dnaSeq::dna, isDna(), and dnaSeq::size.

Referenced by doBlat().

00082 {
00083 return isDna(seq->dna, seq->size);
00084 }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean seqIsLower ( bioSeq seq  ) 

Definition at line 69 of file dnaseq.c.

References dnaSeq::dna, FALSE, dnaSeq::size, and TRUE.

00071 {
00072 int size = seq->size, i;
00073 char *poly = seq->dna;
00074 for (i=0; i<size; ++i)
00075     if (!islower(poly[i]))
00076         return FALSE;
00077 return TRUE;
00078 }

aaSeq* translateSeq ( struct dnaSeq inSeq,
unsigned  offset,
boolean  stop 
)

Definition at line 124 of file dnaseq.c.

References translateSeqN().

Referenced by trans3New().

00128 {
00129 return translateSeqN(inSeq, offset, 0, stop);
00130 }

Here is the call graph for this function:

Here is the caller graph for this function:

aaSeq* translateSeqN ( struct dnaSeq inSeq,
unsigned  offset,
unsigned  inSize,
boolean  stop 
)

Definition at line 87 of file dnaseq.c.

References AllocVar, cloneString(), dnaSeq::dna, lookupCodon(), dnaSeq::name, needLargeMem(), and dnaSeq::size.

Referenced by translateSeq().

00090 {
00091 aaSeq *seq;
00092 DNA *dna = inSeq->dna;
00093 AA *pep, aa;
00094 int i, lastCodon;
00095 int actualSize = 0;
00096 
00097 assert(offset <= inSeq->size);
00098 if ((inSize == 0) || (inSize > (inSeq->size - offset)))
00099     inSize = inSeq->size - offset;
00100 lastCodon = offset + inSize - 3;
00101 
00102 AllocVar(seq);
00103 seq->dna = pep = needLargeMem(inSize/3+1);
00104 for (i=offset; i <= lastCodon; i += 3)
00105     {
00106     aa = lookupCodon(dna+i);
00107     if (aa == 0)
00108         {
00109         if (stop)
00110             break;
00111         else
00112             aa = 'Z';
00113         }
00114     *pep++ = aa;
00115     ++actualSize;
00116     }
00117 *pep = 0;
00118 assert(actualSize <= inSize/3+1);
00119 seq->size = actualSize;
00120 seq->name = cloneString(inSeq->name);
00121 return seq;
00122 }

Here is the call graph for this function:

Here is the caller graph for this function:

bioSeq* whichSeqIn ( bioSeq **  seqs,
int  seqCount,
char *  letters 
)

Definition at line 132 of file dnaseq.c.

References dnaSeq::dna, internalErr, and dnaSeq::size.

00134 {
00135 aaSeq *seq;
00136 int i;
00137 
00138 for (i=0; i<seqCount; ++i)
00139     {
00140     seq = seqs[i];
00141     if (seq->dna <= letters && letters < seq->dna + seq->size)
00142         return seq;
00143     }
00144 internalErr();
00145 return NULL;
00146 }


Variable Documentation

char const rcsid[] = "$Id: dnaseq.c,v 1.19 2005/11/10 03:40:34 kent Exp $" [static]

Definition at line 12 of file dnaseq.c.


Generated on Tue Dec 25 19:45:29 2007 for blat by  doxygen 1.5.2