#include "dnautil.h"#include "hash.h"Include dependency graph for nib.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Data Structures | |
| struct | nibInfo |
Defines | |
| #define | NIB_MASK_MIXED 0x01 |
| #define | NIB_MASK_MAP 0x02 |
| #define | NIB_BASE_NAME 0x04 |
Functions | |
| void | nibOpenVerify (char *fileName, FILE **retFile, int *retSize) |
| dnaSeq * | nibLoadPart (char *fileName, int start, int size) |
| dnaSeq * | nibLoadPartMasked (int options, char *fileName, int start, int size) |
| dnaSeq * | nibLdPart (char *fileName, FILE *f, int seqSize, int start, int size) |
| dnaSeq * | nibLdPartMasked (int options, char *fileName, FILE *f, int seqSize, int start, int size) |
| dnaSeq * | nibLoadAll (char *fileName) |
| dnaSeq * | nibLoadAllMasked (int options, char *fileName) |
| void | nibWrite (struct dnaSeq *seq, char *fileName) |
| void | nibWriteMasked (int options, struct dnaSeq *seq, char *fileName) |
| boolean | nibIsFile (char *fileName) |
| boolean | nibIsRange (char *fileName) |
| void | nibParseName (unsigned options, char *fileSpec, char *filePath, char *name, unsigned *start, unsigned *end) |
| nibStream * | nibStreamOpen (char *fileName) |
| void | nibStreamClose (struct nibStream **pNs) |
| void | nibStreamOne (struct nibStream *ns, DNA base) |
| void | nibStreamMany (struct nibStream *ns, DNA *dna, int size) |
| nibInfo * | nibInfoNew (char *path) |
| void | nibInfoFree (struct nibInfo **pNib) |
| nibInfo * | nibInfoFromCache (struct hash *hash, char *nibDir, char *nibName) |
| int | nibGetSize (char *nibFile) |
| #define NIB_BASE_NAME 0x04 |
| #define NIB_MASK_MAP 0x02 |
| #define NIB_MASK_MIXED 0x01 |
Options for controlling masking
Definition at line 20 of file nib.h.
Referenced by dnaLoadSingle(), gfClientSeqList(), nibInput(), nibOutput(), nibTwoCacheSeqPartExt(), nibTwoLoadOne(), readMaskedNib(), and searchOneIndex().
| int nibGetSize | ( | char * | nibFile | ) |
Definition at line 507 of file nib.c.
References carefulClose(), nibOpenVerify(), and nibInfo::size.
00509 { 00510 FILE* fh; 00511 int size; 00512 00513 nibOpenVerify(nibFile, &fh, &size); 00514 carefulClose(&fh); 00515 return size; 00516 }
Here is the call graph for this function:

| void nibInfoFree | ( | struct nibInfo ** | pNib | ) |
Definition at line 480 of file nib.c.
References carefulClose(), nibInfo::f, nibInfo::fileName, freeMem(), and freez().
Referenced by gfFileCacheFreeEl(), and nibTwoCacheFree().
00482 { 00483 struct nibInfo *nib = *pNib; 00484 if (nib != NULL) 00485 { 00486 carefulClose(&nib->f); 00487 freeMem(nib->fileName); 00488 freez(pNib); 00489 } 00490 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 492 of file nib.c.
References hashAdd(), hashFindVal(), nibInfoNew(), PATH_LEN, and safef().
Referenced by nibTwoCacheSeq(), and nibTwoCacheSeqPartExt().
00494 { 00495 struct nibInfo *nib; 00496 char path[PATH_LEN]; 00497 safef(path, sizeof(path), "%s/%s.nib", nibDir, nibName); 00498 nib = hashFindVal(hash, path); 00499 if (nib == NULL) 00500 { 00501 nib = nibInfoNew(path); 00502 hashAdd(hash, path, nib); 00503 } 00504 return nib; 00505 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct nibInfo* nibInfoNew | ( | char * | path | ) | [read] |
Definition at line 470 of file nib.c.
References AllocVar, cloneString(), nibInfo::f, nibInfo::fileName, nibOpenVerify(), and nibInfo::size.
Referenced by gfiExpandAndLoadCached(), and nibInfoFromCache().
00472 { 00473 struct nibInfo *nib; 00474 AllocVar(nib); 00475 nib->fileName = cloneString(path); 00476 nibOpenVerify(path, &nib->f, &nib->size); 00477 return nib; 00478 }
Here is the call graph for this function:

Here is the caller graph for this function:

| boolean nibIsFile | ( | char * | fileName | ) |
Definition at line 444 of file nib.c.
References endsWith(), and findNibSubrange().
Referenced by dnaLoadSingle(), gfClientFileArray(), gfClientSeqList(), gfFileCacheFreeEl(), gfiExpandAndLoadCached(), gfiGetSeqName(), gfIndexNibsAndTwoBits(), gfIndexTransNibsAndTwoBits(), gfMakeOoc(), readSeqFrag(), and searchOneIndex().
00446 { 00447 boolean isANib; 00448 char *subrange = findNibSubrange(fileName); 00449 if (subrange != NULL) 00450 *subrange = '\0'; 00451 isANib = endsWith(fileName, ".nib") || endsWith(fileName, ".NIB"); 00452 if (subrange != NULL) 00453 *subrange = ':'; 00454 return isANib; 00455 }
Here is the call graph for this function:

Here is the caller graph for this function:

| boolean nibIsRange | ( | char * | fileName | ) |
Definition at line 457 of file nib.c.
References endsWith(), FALSE, and findNibSubrange().
00459 { 00460 boolean isANib; 00461 char *subrange = findNibSubrange(fileName);; 00462 if (subrange == NULL) 00463 return FALSE; 00464 *subrange = '\0'; 00465 isANib = endsWith(fileName, ".nib") || endsWith(fileName, ".NIB"); 00466 *subrange = ':'; 00467 return isANib; 00468 }
Here is the call graph for this function:

| struct dnaSeq* nibLdPart | ( | char * | fileName, | |
| FILE * | f, | |||
| int | seqSize, | |||
| int | start, | |||
| int | size | |||
| ) | [read] |
Definition at line 301 of file nib.c.
References nibLdPartMasked().
Referenced by gfAddTilesInNib(), gfCountTilesInNib(), gfiExpandAndLoadCached(), and nibTwoCacheSeq().
00303 { 00304 return nibLdPartMasked(0, fileName, f, seqSize, start, size); 00305 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct dnaSeq* nibLdPartMasked | ( | int | options, | |
| char * | fileName, | |||
| FILE * | f, | |||
| int | seqSize, | |||
| int | start, | |||
| int | size | |||
| ) | [read] |
Definition at line 292 of file nib.c.
References nibInput(), and safef().
Referenced by nibLdPart(), nibLoadPartMasked(), and nibTwoCacheSeqPartExt().
00295 { 00296 char nameBuf[512]; 00297 safef(nameBuf, sizeof(nameBuf), "%s:%d-%d", fileName, start, start+size); 00298 return nibInput(options, fileName, nameBuf, f, seqSize, start, size); 00299 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct dnaSeq* nibLoadAll | ( | char * | fileName | ) | [read] |
Definition at line 352 of file nib.c.
References nibLoadAllMasked().
Referenced by gfMakeOoc(), and readMaskedNib().
00354 { 00355 return nibLoadAllMasked(0, fileName); 00356 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct dnaSeq* nibLoadAllMasked | ( | int | options, | |
| char * | fileName | |||
| ) | [read] |
Definition at line 325 of file nib.c.
References name, nibInput(), nibOpenVerify(), nibParseName(), and PATH_LEN.
Referenced by dnaLoadSingle(), gfClientSeqList(), nibLoadAll(), nibTwoLoadOne(), readMaskedNib(), and searchOneIndex().
00328 : 00329 * /path/file.nib:seqid:start-end 00330 * or\n" 00331 * /path/file.nib:start-end 00332 * With the first form, seqid becomes the id of the subrange, with the second 00333 * form, a sequence id of file:start-end will be used. 00334 */ 00335 { 00336 struct dnaSeq *seq; 00337 FILE *f; 00338 int seqSize; 00339 char filePath[PATH_LEN]; 00340 char name[PATH_LEN]; 00341 unsigned start, end; 00342 00343 nibParseName(options, fileName, filePath, name, &start, &end); 00344 nibOpenVerify(filePath, &f, &seqSize); 00345 if (end == 0) 00346 end = seqSize; 00347 seq = nibInput(options, fileName, name, f, seqSize, start, end-start); 00348 fclose(f); 00349 return seq; 00350 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct dnaSeq* nibLoadPart | ( | char * | fileName, | |
| int | start, | |||
| int | size | |||
| ) | [read] |
Definition at line 319 of file nib.c.
References nibLoadPartMasked().
Referenced by readSeqFrag().
00321 { 00322 return nibLoadPartMasked(0, fileName, start, size); 00323 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct dnaSeq* nibLoadPartMasked | ( | int | options, | |
| char * | fileName, | |||
| int | start, | |||
| int | size | |||
| ) | [read] |
Definition at line 307 of file nib.c.
References nibLdPartMasked(), and nibOpenVerify().
Referenced by nibLoadPart().
00309 { 00310 struct dnaSeq *seq; 00311 FILE *f; 00312 int seqSize; 00313 nibOpenVerify(fileName, &f, &seqSize); 00314 seq = nibLdPartMasked(options, fileName, f, seqSize, start, size); 00315 fclose(f); 00316 return seq; 00317 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void nibOpenVerify | ( | char * | fileName, | |
| FILE ** | retFile, | |||
| int * | retSize | |||
| ) |
Definition at line 84 of file nib.c.
References bits32, byteSwap32(), dnaUtilOpen(), errAbort(), errno, mustReadOne, nibSig, and safef().
Referenced by dnaLoadSingle(), gfAddTilesInNib(), gfCountTilesInNib(), nibGetSize(), nibInfoNew(), nibLoadAllMasked(), and nibLoadPartMasked().
00086 { 00087 bits32 size; 00088 bits32 sig; 00089 FILE *f = fopen(fileName, "rb"); 00090 char buffer[512]; 00091 char buffer2[512]; 00092 char buffer3[512]; 00093 00094 if (f == NULL) 00095 { 00096 /* see if nib is down a few directories ala faSplit -outDirDepth */ 00097 char *ptr = NULL; 00098 char *dir, *file; 00099 struct stat statBuf; 00100 00101 /* divide fileName into file and directory components */ 00102 safef(buffer, sizeof(buffer), "%s", fileName); 00103 if ((ptr = strrchr(buffer, '/')) != NULL) 00104 { 00105 *ptr++ = 0; 00106 dir = buffer; 00107 file = ptr; 00108 } 00109 else 00110 { 00111 dir = ""; 00112 file = buffer; 00113 } 00114 00115 buffer3[0] = 0; 00116 /* start at the end of the fileName (minus .nib) */ 00117 for(ptr = &file[strlen(file) - 5]; ; ) 00118 { 00119 strcpy(buffer2, buffer3); 00120 if (isdigit(*ptr)) 00121 { 00122 /* if we have a digit in the fileName, see if there is a directory with this name */ 00123 safef(buffer3, sizeof(buffer3), "%c/%s",*ptr,buffer2); 00124 ptr--; 00125 } 00126 else 00127 /* we've run out of digits in the fileName, just add 0's */ 00128 safef(buffer3, sizeof(buffer3), "0/%s",buffer2); 00129 00130 /* check to see if this directory exists */ 00131 safef(buffer2, sizeof(buffer2), "%s/%s", dir, buffer3); 00132 if (stat(buffer2, &statBuf) < 0) 00133 break; 00134 00135 /* directory exists, see if our file is down there */ 00136 safef(buffer2, sizeof(buffer2), "%s/%s/%s", dir, buffer3, file); 00137 if ((f = fopen(buffer2, "rb")) != NULL) 00138 break; 00139 } 00140 if (f == NULL) 00141 errAbort("Can't open %s to read: %s", fileName, strerror(errno)); 00142 } 00143 dnaUtilOpen(); 00144 mustReadOne(f, sig); 00145 mustReadOne(f, size); 00146 if (sig != nibSig) 00147 { 00148 sig = byteSwap32(sig); 00149 size = byteSwap32(size); 00150 if (sig != nibSig) 00151 errAbort("%s is not a good .nib file.", fileName); 00152 } 00153 *retSize = size; 00154 *retFile = f; 00155 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void nibParseName | ( | unsigned | options, | |
| char * | fileSpec, | |||
| char * | filePath, | |||
| char * | name, | |||
| unsigned * | start, | |||
| unsigned * | end | |||
| ) |
Definition at line 48 of file nib.c.
References findNibSubrange(), NIB_BASE_NAME, parseSubrange(), and splitPath().
Referenced by dnaLoadSingle(), and nibLoadAllMasked().
00054 { 00055 char *subrange = findNibSubrange(fileSpec); 00056 if (subrange != NULL) 00057 { 00058 *subrange = '\0'; 00059 parseSubrange(subrange, name, start, end); 00060 strcpy(filePath, fileSpec); 00061 *subrange = ':'; 00062 if (strlen(name) == 0) 00063 { 00064 /* no name in spec, generate one */ 00065 if (options & NIB_BASE_NAME) 00066 splitPath(filePath, NULL, name, NULL); 00067 else 00068 strcpy(name, filePath); 00069 sprintf(name+strlen(name), ":%u-%u", *start, *end); 00070 } 00071 } 00072 else 00073 { 00074 *start = 0; 00075 *end = 0; 00076 strcpy(filePath, fileSpec); 00077 if (options & NIB_BASE_NAME) 00078 splitPath(fileSpec, NULL, name, NULL); 00079 else 00080 strcpy(name, fileSpec); 00081 } 00082 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void nibStreamClose | ( | struct nibStream ** | pNs | ) |
Definition at line 401 of file nib.c.
References bits32, nibStream::byte, nibStream::f, nibStream::fileName, freeMem(), freez(), nibSig, SEEK_SET, nibStream::size, and writeOne.
00403 { 00404 struct nibStream *ns = *pNs; 00405 FILE *f; 00406 bits32 sig = nibSig; 00407 if (ns == NULL) 00408 return; 00409 f = ns->f; 00410 if (ns->size&1) 00411 writeOne(f, ns->byte); 00412 fseek(f, 0L, SEEK_SET); 00413 writeOne(f, sig); 00414 writeOne(f, ns->size); 00415 fclose(f); 00416 freeMem(ns->fileName); 00417 freez(pNs); 00418 }
Here is the call graph for this function:

Definition at line 436 of file nib.c.
References nibStreamOne().
00438 { 00439 int i; 00440 for (i=0; i<size; ++i) 00441 nibStreamOne(ns, *dna++); 00442 }
Here is the call graph for this function:

Definition at line 420 of file nib.c.
References nibStream::byte, nibStream::f, ntVal5, nibStream::size, UBYTE, and writeOne.
Referenced by nibStreamMany().
00422 { 00423 UBYTE ub = ntVal5[(int)base]; 00424 00425 if ((++ns->size&1) == 0) 00426 { 00427 ub += ns->byte; 00428 writeOne(ns->f, ub); 00429 } 00430 else 00431 { 00432 ns->byte = (ub<<4); 00433 } 00434 }
Here is the caller graph for this function:

| struct nibStream* nibStreamOpen | ( | char * | fileName | ) | [read] |
Definition at line 383 of file nib.c.
References AllocVar, cloneString(), dnaUtilOpen(), nibStream::f, nibStream::fileName, mustOpen(), nibStream::size, and writeOne.
00385 { 00386 struct nibStream *ns; 00387 FILE *f; 00388 00389 dnaUtilOpen(); 00390 AllocVar(ns); 00391 ns->f = f = mustOpen(fileName, "wb"); 00392 ns->fileName = cloneString(fileName); 00393 00394 /* Write header - initially zero. Will fix it up when we close. */ 00395 writeOne(f, ns->size); 00396 writeOne(f, ns->size); 00397 00398 return ns; 00399 }
Here is the call graph for this function:

| void nibWrite | ( | struct dnaSeq * | seq, | |
| char * | fileName | |||
| ) |
Definition at line 365 of file nib.c.
References nibWriteMasked().
00367 { 00368 nibWriteMasked(0, seq, fileName); 00369 }
Here is the call graph for this function:

| void nibWriteMasked | ( | int | options, | |
| struct dnaSeq * | seq, | |||
| char * | fileName | |||
| ) |
Definition at line 358 of file nib.c.
References nibOutput().
Referenced by nibWrite().
Here is the call graph for this function:

Here is the caller graph for this function:

1.5.2