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

Go to the source code of this file.
Functions | |
| void | readNcbidb_open (char *filename) |
| unsigned char * | readNcbidb_getSequence (uint4 sequenceNumber, uint4 *length) |
| unsigned char * | readNcbidb_getDescription (uint4 sequenceNumber, uint4 *length) |
Variables | |
| int | readNcbidb_version |
| int | readNcbidb_alphabetType |
| uint4 | readNcbidb_numberOfSequences |
| uint4 | readNcbidb_longestSequenceLength |
| uint8 | readNcbidb_numberOfLetters |
| unsigned char* readNcbidb_getDescription | ( | uint4 | sequenceNumber, | |
| uint4 * | length | |||
| ) |
Definition at line 219 of file readNcbidb.c.
References global_malloc(), readNcbidb_descriptionOffsets, readNcbidb_numberOfSequences, readNcbidb_phrFile, readNcbidb_phrFilename, readNcbidb_readASN1sequenceLength(), and uint4.
Referenced by main().
00220 { 00221 unsigned char* description, *newDescription, *descriptionStart; 00222 uint4 offset, startPos; 00223 00224 if (sequenceNumber >= readNcbidb_numberOfSequences) 00225 return NULL; 00226 00227 *length = readNcbidb_descriptionOffsets[sequenceNumber + 1] 00228 - readNcbidb_descriptionOffsets[sequenceNumber] - 1; 00229 offset = readNcbidb_descriptionOffsets[sequenceNumber]; 00230 00231 // printf("offset=%d length=%d\n", offset, *length); fflush(stdout); 00232 00233 description = (char*)global_malloc((*length) + 1); 00234 if (fseek(readNcbidb_phrFile, offset, SEEK_SET) == -1 || 00235 fread(description, sizeof(char), *length, readNcbidb_phrFile) < *length) 00236 { 00237 fprintf(stderr, "%s\n", strerror(errno)); 00238 fprintf(stderr, "Error reading description from %s\n", readNcbidb_phrFilename); 00239 exit(-1); 00240 } 00241 description[*length] = '\0'; 00242 00243 // Read sequence length in ASN.1 format 00244 descriptionStart = description + 7; 00245 descriptionStart = readNcbidb_readASN1sequenceLength(descriptionStart, length); 00246 00247 // Copy description to new buffer 00248 newDescription = global_malloc((*length) + 1); 00249 memcpy(newDescription, descriptionStart, (*length) + 1); 00250 free(description); 00251 00252 return newDescription; 00253 }
Here is the call graph for this function:

Here is the caller graph for this function:

| unsigned char* readNcbidb_getSequence | ( | uint4 | sequenceNumber, | |
| uint4 * | length | |||
| ) |
Definition at line 150 of file readNcbidb.c.
References global_malloc(), readNcbidb_convertCode(), readNcbidb_numberOfSequences, readNcbidb_psqFile, readNcbidb_psqFilename, readNcbidb_sequenceOffsets, and uint4.
Referenced by main().
00151 { 00152 char* sequence; 00153 uint4 offset, position = 0; 00154 00155 if (sequenceNumber >= readNcbidb_numberOfSequences) 00156 return NULL; 00157 00158 *length = readNcbidb_sequenceOffsets[sequenceNumber + 1] 00159 - readNcbidb_sequenceOffsets[sequenceNumber] - 1; 00160 offset = readNcbidb_sequenceOffsets[sequenceNumber]; 00161 00162 sequence = (char*)global_malloc(*length); 00163 if (fseek(readNcbidb_psqFile, offset, SEEK_SET) == -1 || 00164 fread(sequence, sizeof(char), *length, readNcbidb_psqFile) < *length) 00165 { 00166 fprintf(stderr, "%s\n", strerror(errno)); 00167 fprintf(stderr, "Error reading sequence from %s\n", readNcbidb_psqFilename); 00168 exit(-1); 00169 } 00170 00171 while (position < *length) 00172 { 00173 sequence[position] = readNcbidb_convertCode(sequence[position]); 00174 position++; 00175 } 00176 00177 return sequence; 00178 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void readNcbidb_open | ( | char * | filename | ) |
Definition at line 48 of file readNcbidb.c.
References global_malloc(), readNcbidb_alphabetType, readNcbidb_descriptionOffsets, readNcbidb_longestSequenceLength, readNcbidb_numberOfLetters, readNcbidb_numberOfSequences, readNcbidb_phrFile, readNcbidb_phrFilename, readNcbidb_pinFile, readNcbidb_pinFilename, readNcbidb_psqFile, readNcbidb_psqFilename, readNcbidb_read64Int(), readNcbidb_readInt(), readNcbidb_sequenceOffsets, readNcbidb_version, and uint4.
Referenced by main().
00049 { 00050 int titleLength, createdLength; 00051 char* title, *created; 00052 uint4 sequenceNumber = 0, headerOffset; 00053 00054 // Open PIN file 00055 readNcbidb_pinFilename = global_malloc(strlen(filename) + 5); 00056 sprintf(readNcbidb_pinFilename, "%s.pin", filename); 00057 if ((readNcbidb_pinFile = fopen(readNcbidb_pinFilename, "r")) == NULL) 00058 { 00059 fprintf(stderr, "Error opening file %s for reading\n", readNcbidb_pinFilename); 00060 exit(-1); 00061 } 00062 00063 // Read header information 00064 readNcbidb_version = readNcbidb_readInt(readNcbidb_pinFile, readNcbidb_pinFilename); 00065 readNcbidb_alphabetType = !(readNcbidb_readInt(readNcbidb_pinFile, readNcbidb_pinFilename)); 00066 00067 // Read title 00068 titleLength = readNcbidb_readInt(readNcbidb_pinFile, readNcbidb_pinFilename); 00069 title = global_malloc(titleLength + 1); 00070 if (fread(title, sizeof(char), titleLength, readNcbidb_pinFile) < titleLength) 00071 { 00072 fprintf(stderr, "Error reading from file %s\n", readNcbidb_pinFilename); 00073 exit(-1); 00074 } 00075 title[titleLength] = '\0'; 00076 // printf("Title = \"%s\"\n", title); 00077 00078 // Read creation time 00079 createdLength = readNcbidb_readInt(readNcbidb_pinFile, readNcbidb_pinFilename); 00080 created = global_malloc(createdLength + 1); 00081 if (fread(created, sizeof(char), createdLength, readNcbidb_pinFile) < createdLength) 00082 { 00083 fprintf(stderr, "Error reading from file %s\n", readNcbidb_pinFilename); 00084 exit(-1); 00085 } 00086 created[createdLength] = '\0'; 00087 // printf("Created = \"%s\"\n", created); 00088 00089 // Read more header info 00090 readNcbidb_numberOfSequences = readNcbidb_readInt(readNcbidb_pinFile, readNcbidb_pinFilename); 00091 readNcbidb_numberOfLetters = readNcbidb_read64Int(readNcbidb_pinFile, readNcbidb_pinFilename); 00092 readNcbidb_longestSequenceLength = readNcbidb_readInt(readNcbidb_pinFile, readNcbidb_pinFilename); 00093 00094 // printf("%d,%llu,%d\n", readNcbidb_numberOfSequences, readNcbidb_numberOfLetters, readNcbidb_longestSequenceLength); 00095 00096 // Read description offsets 00097 readNcbidb_descriptionOffsets = global_malloc(sizeof(uint4) * (readNcbidb_numberOfSequences + 1)); 00098 sequenceNumber = 0; 00099 while (sequenceNumber <= readNcbidb_numberOfSequences) 00100 { 00101 readNcbidb_descriptionOffsets[sequenceNumber] 00102 = readNcbidb_readInt(readNcbidb_pinFile, readNcbidb_pinFilename); 00103 sequenceNumber++; 00104 } 00105 00106 // Read sequence offsets 00107 readNcbidb_sequenceOffsets = global_malloc(sizeof(uint4) * (readNcbidb_numberOfSequences + 1)); 00108 sequenceNumber = 0; 00109 while (sequenceNumber <= readNcbidb_numberOfSequences) 00110 { 00111 readNcbidb_sequenceOffsets[sequenceNumber] 00112 = readNcbidb_readInt(readNcbidb_pinFile, readNcbidb_pinFilename); 00113 00114 // printf("[%d]", readNcbidb_sequenceOffsets[sequenceNumber]); 00115 sequenceNumber++; 00116 } 00117 00118 fclose(readNcbidb_pinFile); 00119 00120 // Open PHR and PSQ files for reading 00121 readNcbidb_phrFilename = global_malloc(strlen(filename) + 5); 00122 sprintf(readNcbidb_phrFilename, "%s.phr", filename); 00123 if ((readNcbidb_phrFile = fopen(readNcbidb_phrFilename, "r")) == NULL) 00124 { 00125 fprintf(stderr, "Error opening file %s for reading\n", readNcbidb_phrFilename); 00126 exit(-1); 00127 } 00128 readNcbidb_psqFilename = global_malloc(strlen(filename) + 5); 00129 sprintf(readNcbidb_psqFilename, "%s.psq", filename); 00130 if ((readNcbidb_psqFile = fopen(readNcbidb_psqFilename, "r")) == NULL) 00131 { 00132 fprintf(stderr, "Error opening file %s for reading\n", readNcbidb_psqFilename); 00133 exit(-1); 00134 } 00135 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4 of file readNcbidb.c.
Referenced by main(), readNcbidb_getDescription(), readNcbidb_getSequence(), and readNcbidb_open().
1.5.2