NCBI C Toolkit Cross Reference

C/demo/asnbarval.c


  1 /*   asnbarval.c
  2 * ===========================================================================
  3 *
  4 *                            PUBLIC DOMAIN NOTICE
  5 *            National Center for Biotechnology Information (NCBI)
  6 *
  7 *  This software/database is a "United States Government Work" under the
  8 *  terms of the United States Copyright Act.  It was written as part of
  9 *  the author's official duties as a United States Government employee and
 10 *  thus cannot be copyrighted.  This software/database is freely available
 11 *  to the public for use. The National Library of Medicine and the U.S.
 12 *  Government do not place any restriction on its use or reproduction.
 13 *  We would, however, appreciate having the NCBI and the author cited in
 14 *  any work or product based on this material
 15 *
 16 *  Although all reasonable efforts have been taken to ensure the accuracy
 17 *  and reliability of the software and data, the NLM and the U.S.
 18 *  Government do not and cannot warrant the performance or results that
 19 *  may be obtained by using this software or data. The NLM and the U.S.
 20 *  Government disclaim all warranties, express or implied, including
 21 *  warranties of performance, merchantability or fitness for any particular
 22 *  purpose.
 23 *
 24 * ===========================================================================
 25 *
 26 * File Name:  asnbarval.c
 27 *
 28 * Author:  Jonathan Kans, adapted from asnval.c by Colleen Bollin
 29 *
 30 * Version Creation Date:   1/23/07
 31 *
 32 * $Revision: 1.6 $
 33 *
 34 * File Description:
 35 *
 36 * Modifications:  
 37 * --------------------------------------------------------------------------
 38 * Date     Name        Description of modification
 39 * -------  ----------  -----------------------------------------------------
 40 *
 41 *
 42 * ==========================================================================
 43 */
 44 
 45 #include <ncbi.h>
 46 #include <objall.h>
 47 #include <objsset.h>
 48 #include <objsub.h>
 49 #include <objfdef.h>
 50 #include <seqport.h>
 51 #include <sequtil.h>
 52 #include <sqnutils.h>
 53 #include <subutil.h>
 54 #include <gather.h>
 55 #include <explore.h>
 56 #include <lsqfetch.h>
 57 #include <valid.h>
 58 #include <pmfapi.h>
 59 #ifdef INTERNAL_NCBI_ASNBARVAL
 60 #include <accpubseq.h>
 61 #include <tax3api.h>
 62 #endif
 63 
 64 #define ASNBARVAL_APP_VER "1.2"
 65 
 66 CharPtr ASNBARVAL_APPLICATION = ASNBARVAL_APP_VER;
 67 
 68 typedef struct brflags {
 69   Boolean  farFetchCDSproducts;
 70   Boolean  batch;
 71   Boolean  binary;
 72   Boolean  compressed;
 73   Boolean  useThreads;
 74   Boolean  usePUBSEQ;
 75   Int2     type;
 76   Int4     maxcount;
 77   CharPtr  outpath;
 78   CharPtr  output_suffix;
 79   CharPtr  output_dir;
 80   FILE     *outfp;
 81   Int4     numrecords;
 82   ValNodePtr            sep_list;
 83   ValNodePtr            bsplist;
 84   BarcodeTestConfigData bcd;
 85 } BRFlagData, PNTR BRFlagPtr;
 86 
 87 #ifdef INTERNAL_NCBI_ASNBARVAL
 88 const PerformDiscrepancyTest taxlookup = CheckTaxNamesAgainstTaxDatabase;
 89 #else
 90 const PerformDiscrepancyTest taxlookup = NULL;
 91 #endif
 92 
 93 #ifdef INTERNAL_NCBI_ASNBARVAL
 94 static CharPtr dirsubfetchproc = "DirSubBioseqFetch";
 95 
 96 static CharPtr dirsubfetchcmd = NULL;
 97 
 98 extern Pointer ReadFromDirSub (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID);
 99 extern Pointer ReadFromDirSub (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID)
100 
101 {
102   Char     cmmd [256];
103   Pointer  dataptr;
104   FILE*    fp;
105   Char     path [PATH_MAX];
106 
107   if (datatype != NULL) {
108     *datatype = 0;
109   }
110   if (entityID != NULL) {
111     *entityID = 0;
112   }
113   if (StringHasNoText (accn)) return NULL;
114 
115   if (dirsubfetchcmd == NULL) {
116     if (GetAppParam ("SEQUIN", "DIRSUB", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
117         dirsubfetchcmd = StringSaveNoNull (cmmd);
118     }
119   }
120   if (dirsubfetchcmd == NULL) return NULL;
121 
122   TmpNam (path);
123 
124 #ifdef OS_UNIX
125   sprintf (cmmd, "csh %s %s > %s", dirsubfetchcmd, accn, path);
126   system (cmmd);
127 #endif
128 #ifdef OS_MSWIN
129   sprintf (cmmd, "%s %s -o %s", dirsubfetchcmd, accn, path);
130   system (cmmd);
131 #endif
132 
133   fp = FileOpen (path, "r");
134   if (fp == NULL) {
135     FileRemove (path);
136     return NULL;
137   }
138   dataptr = ReadAsnFastaOrFlatFile (fp, datatype, entityID, FALSE, FALSE, TRUE, FALSE);
139   FileClose (fp);
140   FileRemove (path);
141   return dataptr;
142 }
143 
144 
145 static Int2 LIBCALLBACK DirSubBioseqFetchFunc (Pointer data)
146 
147 {
148   BioseqPtr         bsp;
149   Char              cmmd [256];
150   Pointer           dataptr;
151   Uint2             datatype;
152   Uint2             entityID;
153   FILE*             fp;
154   OMProcControlPtr  ompcp;
155   ObjMgrProcPtr     ompp;
156   Char              path [PATH_MAX];
157   SeqEntryPtr       sep = NULL;
158   SeqIdPtr          sip;
159   TextSeqIdPtr      tsip;
160 
161   ompcp = (OMProcControlPtr) data;
162   if (ompcp == NULL) return OM_MSG_RET_ERROR;
163   ompp = ompcp->proc;
164   if (ompp == NULL) return OM_MSG_RET_ERROR;
165   sip = (SeqIdPtr) ompcp->input_data;
166   if (sip == NULL) return OM_MSG_RET_ERROR;
167 
168   if (sip->choice != SEQID_GENBANK) return OM_MSG_RET_ERROR;
169   tsip = (TextSeqIdPtr) sip->data.ptrvalue;
170   if (tsip == NULL || StringHasNoText (tsip->accession)) return OM_MSG_RET_ERROR;
171 
172   if (dirsubfetchcmd == NULL) {
173     if (GetAppParam ("SEQUIN", "DIRSUB", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
174         dirsubfetchcmd = StringSaveNoNull (cmmd);
175     }
176   }
177   if (dirsubfetchcmd == NULL) return OM_MSG_RET_ERROR;
178 
179   TmpNam (path);
180 
181 #ifdef OS_UNIX
182   sprintf (cmmd, "csh %s %s > %s", dirsubfetchcmd, tsip->accession, path);
183   system (cmmd);
184 #endif
185 #ifdef OS_MSWIN
186   sprintf (cmmd, "%s %s -o %s", dirsubfetchcmd, tsip->accession, path);
187   system (cmmd);
188 #endif
189 
190   fp = FileOpen (path, "r");
191   if (fp == NULL) {
192     FileRemove (path);
193     return OM_MSG_RET_ERROR;
194   }
195   dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, &entityID, FALSE, FALSE, TRUE, FALSE);
196   FileClose (fp);
197   FileRemove (path);
198 
199   if (dataptr == NULL) return OM_MSG_RET_OK;
200 
201   sep = GetTopSeqEntryForEntityID (entityID);
202   if (sep == NULL) return OM_MSG_RET_ERROR;
203   bsp = BioseqFindInSeqEntry (sip, sep);
204   ompcp->output_data = (Pointer) bsp;
205   ompcp->output_entityID = ObjMgrGetEntityIDForChoice (sep);
206   return OM_MSG_RET_DONE;
207 }
208 
209 static Boolean DirSubFetchEnable (void)
210 
211 {
212   ObjMgrProcLoad (OMPROC_FETCH, dirsubfetchproc, dirsubfetchproc,
213                   OBJ_SEQID, 0, OBJ_BIOSEQ, 0, NULL,
214                   DirSubBioseqFetchFunc, PROC_PRIORITY_DEFAULT);
215   return TRUE;
216 }
217 
218 static CharPtr smartfetchproc = "SmartBioseqFetch";
219 
220 static CharPtr smartfetchcmd = NULL;
221 
222 extern Pointer ReadFromSmart (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID);
223 extern Pointer ReadFromSmart (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID)
224 
225 {
226   Char     cmmd [256];
227   Pointer  dataptr;
228   FILE*    fp;
229   Char     path [PATH_MAX];
230 
231   if (datatype != NULL) {
232     *datatype = 0;
233   }
234   if (entityID != NULL) {
235     *entityID = 0;
236   }
237   if (StringHasNoText (accn)) return NULL;
238 
239   if (smartfetchcmd == NULL) {
240     if (GetAppParam ("SEQUIN", "SMART", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
241         smartfetchcmd = StringSaveNoNull (cmmd);
242     }
243   }
244   if (smartfetchcmd == NULL) return NULL;
245 
246   TmpNam (path);
247 
248 #ifdef OS_UNIX
249   sprintf (cmmd, "csh %s %s > %s", smartfetchcmd, accn, path);
250   system (cmmd);
251 #endif
252 #ifdef OS_MSWIN
253   sprintf (cmmd, "%s %s -o %s", smartfetchcmd, accn, path);
254   system (cmmd);
255 #endif
256 
257   fp = FileOpen (path, "r");
258   if (fp == NULL) {
259     FileRemove (path);
260     return NULL;
261   }
262   dataptr = ReadAsnFastaOrFlatFile (fp, datatype, entityID, FALSE, FALSE, TRUE, FALSE);
263   FileClose (fp);
264   FileRemove (path);
265   return dataptr;
266 }
267 
268 
269 static Int2 LIBCALLBACK SmartBioseqFetchFunc (Pointer data)
270 
271 {
272   BioseqPtr         bsp;
273   Char              cmmd [256];
274   Pointer           dataptr;
275   Uint2             datatype;
276   Uint2             entityID;
277   FILE*             fp;
278   OMProcControlPtr  ompcp;
279   ObjMgrProcPtr     ompp;
280   Char              path [PATH_MAX];
281   SeqEntryPtr       sep = NULL;
282   SeqIdPtr          sip;
283   TextSeqIdPtr      tsip;
284 
285   ompcp = (OMProcControlPtr) data;
286   if (ompcp == NULL) return OM_MSG_RET_ERROR;
287   ompp = ompcp->proc;
288   if (ompp == NULL) return OM_MSG_RET_ERROR;
289   sip = (SeqIdPtr) ompcp->input_data;
290   if (sip == NULL) return OM_MSG_RET_ERROR;
291 
292   if (sip->choice != SEQID_GENBANK) return OM_MSG_RET_ERROR;
293   tsip = (TextSeqIdPtr) sip->data.ptrvalue;
294   if (tsip == NULL || StringHasNoText (tsip->accession)) return OM_MSG_RET_ERROR;
295 
296   if (smartfetchcmd == NULL) {
297     if (GetAppParam ("SEQUIN", "SMART", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
298         smartfetchcmd = StringSaveNoNull (cmmd);
299     }
300   }
301   if (smartfetchcmd == NULL) return OM_MSG_RET_ERROR;
302 
303   TmpNam (path);
304 
305 #ifdef OS_UNIX
306   sprintf (cmmd, "csh %s %s > %s", smartfetchcmd, tsip->accession, path);
307   system (cmmd);
308 #endif
309 #ifdef OS_MSWIN
310   sprintf (cmmd, "%s %s -o %s", smartfetchcmd, tsip->accession, path);
311   system (cmmd);
312 #endif
313 
314   fp = FileOpen (path, "r");
315   if (fp == NULL) {
316     FileRemove (path);
317     return OM_MSG_RET_ERROR;
318   }
319   dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, &entityID, FALSE, FALSE, TRUE, FALSE);
320   FileClose (fp);
321   FileRemove (path);
322 
323   if (dataptr == NULL) return OM_MSG_RET_OK;
324 
325   sep = GetTopSeqEntryForEntityID (entityID);
326   if (sep == NULL) return OM_MSG_RET_ERROR;
327   bsp = BioseqFindInSeqEntry (sip, sep);
328   ompcp->output_data = (Pointer) bsp;
329   ompcp->output_entityID = ObjMgrGetEntityIDForChoice (sep);
330   return OM_MSG_RET_DONE;
331 }
332 
333 static Boolean SmartFetchEnable (void)
334 
335 {
336   ObjMgrProcLoad (OMPROC_FETCH, smartfetchproc, smartfetchproc,
337                   OBJ_SEQID, 0, OBJ_BIOSEQ, 0, NULL,
338                   SmartBioseqFetchFunc, PROC_PRIORITY_DEFAULT);
339   return TRUE;
340 }
341 
342 static CharPtr tpasmartfetchproc = "TPASmartBioseqFetch";
343 
344 static CharPtr tpasmartfetchcmd = NULL;
345 
346 extern Pointer ReadFromTPASmart (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID);
347 extern Pointer ReadFromTPASmart (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID)
348 
349 {
350   Char     cmmd [256];
351   Pointer  dataptr;
352   FILE*    fp;
353   Char     path [PATH_MAX];
354 
355   if (datatype != NULL) {
356     *datatype = 0;
357   }
358   if (entityID != NULL) {
359     *entityID = 0;
360   }
361   if (StringHasNoText (accn)) return NULL;
362 
363   if (tpasmartfetchcmd == NULL) {
364     if (GetAppParam ("SEQUIN", "TPASMART", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
365         tpasmartfetchcmd = StringSaveNoNull (cmmd);
366     }
367   }
368   if (tpasmartfetchcmd == NULL) return NULL;
369 
370   TmpNam (path);
371 
372 #ifdef OS_UNIX
373   sprintf (cmmd, "csh %s %s > %s", tpasmartfetchcmd, accn, path);
374   system (cmmd);
375 #endif
376 #ifdef OS_MSWIN
377   sprintf (cmmd, "%s %s -o %s", tpasmartfetchcmd, accn, path);
378   system (cmmd);
379 #endif
380 
381   fp = FileOpen (path, "r");
382   if (fp == NULL) {
383     FileRemove (path);
384     return NULL;
385   }
386   dataptr = ReadAsnFastaOrFlatFile (fp, datatype, entityID, FALSE, FALSE, TRUE, FALSE);
387   FileClose (fp);
388   FileRemove (path);
389   return dataptr;
390 }
391 
392 
393 static Int2 LIBCALLBACK TPASmartBioseqFetchFunc (Pointer data)
394 
395 {
396   BioseqPtr         bsp;
397   Char              cmmd [256];
398   Pointer           dataptr;
399   Uint2             datatype;
400   Uint2             entityID;
401   FILE*             fp;
402   OMProcControlPtr  ompcp;
403   ObjMgrProcPtr     ompp;
404   Char              path [PATH_MAX];
405   SeqEntryPtr       sep = NULL;
406   SeqIdPtr          sip;
407   TextSeqIdPtr      tsip;
408 
409   ompcp = (OMProcControlPtr) data;
410   if (ompcp == NULL) return OM_MSG_RET_ERROR;
411   ompp = ompcp->proc;
412   if (ompp == NULL) return OM_MSG_RET_ERROR;
413   sip = (SeqIdPtr) ompcp->input_data;
414   if (sip == NULL) return OM_MSG_RET_ERROR;
415 
416   if (sip->choice != SEQID_TPG) return OM_MSG_RET_ERROR;
417   tsip = (TextSeqIdPtr) sip->data.ptrvalue;
418   if (tsip == NULL || StringHasNoText (tsip->accession)) return OM_MSG_RET_ERROR;
419 
420   if (tpasmartfetchcmd == NULL) {
421     if (GetAppParam ("SEQUIN", "TPASMART", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
422         tpasmartfetchcmd = StringSaveNoNull (cmmd);
423     }
424   }
425   if (tpasmartfetchcmd == NULL) return OM_MSG_RET_ERROR;
426 
427   TmpNam (path);
428 
429 #ifdef OS_UNIX
430   sprintf (cmmd, "csh %s %s > %s", tpasmartfetchcmd, tsip->accession, path);
431   system (cmmd);
432 #endif
433 #ifdef OS_MSWIN
434   sprintf (cmmd, "%s %s -o %s", tpasmartfetchcmd, tsip->accession, path);
435   system (cmmd);
436 #endif
437 
438   fp = FileOpen (path, "r");
439   if (fp == NULL) {
440     FileRemove (path);
441     return OM_MSG_RET_ERROR;
442   }
443   dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, &entityID, FALSE, FALSE, TRUE, FALSE);
444   FileClose (fp);
445   FileRemove (path);
446 
447   if (dataptr == NULL) return OM_MSG_RET_OK;
448 
449   sep = GetTopSeqEntryForEntityID (entityID);
450   if (sep == NULL) return OM_MSG_RET_ERROR;
451   bsp = BioseqFindInSeqEntry (sip, sep);
452   ompcp->output_data = (Pointer) bsp;
453   ompcp->output_entityID = ObjMgrGetEntityIDForChoice (sep);
454   return OM_MSG_RET_DONE;
455 }
456 
457 static Boolean TPASmartFetchEnable (void)
458 
459 {
460   ObjMgrProcLoad (OMPROC_FETCH, tpasmartfetchproc, tpasmartfetchproc,
461                   OBJ_SEQID, 0, OBJ_BIOSEQ, 0, NULL,
462                   TPASmartBioseqFetchFunc, PROC_PRIORITY_DEFAULT);
463   return TRUE;
464 }
465 #endif
466 
467 static ValNodePtr DoLockFarComponents (
468   SeqEntryPtr sep,
469   BRFlagPtr drfp
470 )
471 
472 {
473   ValNodePtr  rsult;
474 
475 #ifdef INTERNAL_NCBI_ASNBARVAL
476   if (drfp->useThreads) {
477     Message (MSG_POST, "Threads will not be used in this executable");
478     drfp->useThreads = FALSE;;
479   }
480 #endif
481 
482   if (NlmThreadsAvailable () && drfp->useThreads) {
483     rsult = AdvcLockFarComponents (sep, TRUE, drfp->farFetchCDSproducts, drfp->farFetchCDSproducts, NULL, TRUE);
484   } else if (drfp->useThreads) {
485     Message (MSG_POST, "Threads not available in this executable");
486     rsult = AdvcLockFarComponents (sep, TRUE, drfp->farFetchCDSproducts, drfp->farFetchCDSproducts, NULL, FALSE);
487   } else {
488     rsult = AdvcLockFarComponents (sep, TRUE, drfp->farFetchCDSproducts, drfp->farFetchCDSproducts, NULL, FALSE);
489   }
490 
491   return rsult;
492 }
493 
494 static void ProcessSeqEntryList (BRFlagPtr drfp, CharPtr filename)
495 {
496   ValNodePtr  pass_fail_list, vnp;
497   ObjMgrPtr   omp;
498   SeqEntryPtr sep;
499   FILE        *ofp = NULL;
500   Boolean     need_ofp_close = FALSE;
501   Char        path [PATH_MAX];
502   CharPtr     ptr;
503 
504   if (drfp == NULL || drfp->sep_list == NULL) return;
505 
506   if (drfp->outfp == NULL) {
507     if (StringDoesHaveText (drfp->output_dir)) {
508       if (StringLen (drfp->output_dir) > PATH_MAX) {
509         Message (MSG_ERROR, "Unable to generate output file - path name is too long");
510         return;
511       }
512       StringCpy (path, drfp->output_dir);
513 #ifdef OS_WINNT
514       ptr = StringRChr (filename, '\\');
515       if (path[StringLen(path) - 1] != '\\') {
516         StringCat (path, "\\");
517       }
518 #else
519       ptr = StringRChr (filename, '/');
520       if (path[StringLen(path) - 1] != '/') {
521         StringCat (path, "/");
522       }
523 #endif;
524       if (ptr == NULL) {
525         StringNCat (path, filename, PATH_MAX - StringLen(path) - 1);
526       } else {
527         StringNCat (path, ptr + 1, PATH_MAX - StringLen(path) - 1);
528       }
529     } else {
530       StringNCpy_0 (path, filename, sizeof (path));
531     }
532     ptr = StringRChr (path, '.');
533     if (ptr != NULL) {
534       *ptr = '\0';
535     }
536     if (StringDoesHaveText (drfp->output_suffix)) {
537       StringNCat (path, drfp->output_suffix, PATH_MAX - StringLen(path) - 1);
538       path[PATH_MAX - 1] = 0;
539     } else {
540       StringCat (path, ".dr");
541     }
542     if (drfp->outfp == NULL) {
543       ofp = FileOpen (path, "w");
544       need_ofp_close = TRUE;
545     } else {
546       ofp = drfp->outfp;
547     }
548   } else {
549     ofp = drfp->outfp;
550   }
551 
552   for (vnp = drfp->sep_list; vnp != NULL; vnp = vnp->next) {
553     sep = (SeqEntryPtr) vnp->data.ptrvalue;
554     pass_fail_list = GetBarcodePassFail (sep, &(drfp->bcd));
555     WriteBarcodeTestCompliance (ofp, pass_fail_list);
556   }
557   pass_fail_list = BarcodeTestResultsListFree (pass_fail_list);
558   for (vnp = drfp->sep_list; vnp != NULL; vnp = vnp->next) {
559     sep = vnp->data.ptrvalue;
560     SeqEntryFree (sep);
561     omp = ObjMgrGet ();
562     ObjMgrReapOne (omp);
563   }
564   SeqMgrClearBioseqIndex ();
565   ObjMgrFreeCache (0);
566   FreeSeqIdGiCache ();
567   SeqEntrySetScope (NULL);
568   drfp->sep_list = ValNodeFree (drfp->sep_list);
569   
570   drfp->bsplist = UnlockFarComponents (drfp->bsplist);
571 
572   if (ofp != NULL && need_ofp_close) {
573     FileClose (ofp);
574   }
575 }
576 
577 
578 static void ProcessSingleRecord (
579   CharPtr filename,
580   BRFlagPtr drfp
581 )
582 
583 {
584   AsnIoPtr       aip;
585   BioseqPtr      bsp;
586   ValNodePtr     bsplist_next = NULL;
587   BioseqSetPtr   bssp;
588   Pointer        dataptr = NULL;
589   Uint2          datatype, entityID = 0;
590   FILE           *fp;
591   SeqEntryPtr    sep;
592 
593   if (StringHasNoText (filename)) return;
594   if (drfp == NULL) return;
595 
596   if (drfp->type == 1) {
597     fp = FileOpen (filename, "r");
598     if (fp == NULL) {
599       Message (MSG_POSTERR, "Failed to open '%s'", filename);
600       return;
601     }
602 
603     dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE, FALSE, FALSE, FALSE);
604 
605     FileClose (fp);
606 
607     entityID = ObjMgrRegister (datatype, dataptr);
608 
609   } else if (drfp->type >= 2 && drfp->type <= 5) {
610     aip = AsnIoOpen (filename, drfp->binary? "rb" : "r");
611     if (aip == NULL) {
612       Message (MSG_POSTERR, "AsnIoOpen failed for input file '%s'", filename);
613       return;
614     }
615 
616     SeqMgrHoldIndexing (TRUE);
617     switch (drfp->type) {
618       case 2 :
619         dataptr = (Pointer) SeqEntryAsnRead (aip, NULL);
620         datatype = OBJ_SEQENTRY;
621         break;
622       case 3 :
623         dataptr = (Pointer) BioseqAsnRead (aip, NULL);
624         datatype = OBJ_BIOSEQ;
625         break;
626       case 4 :
627         dataptr = (Pointer) BioseqSetAsnRead (aip, NULL);
628         datatype = OBJ_BIOSEQSET;
629         break;
630       case 5 :
631         dataptr = (Pointer) SeqSubmitAsnRead (aip, NULL);
632         datatype = OBJ_SEQSUB;
633         break;
634       default :
635         break;
636     }
637     SeqMgrHoldIndexing (FALSE);
638 
639     AsnIoClose (aip);
640 
641     entityID = ObjMgrRegister (datatype, dataptr);
642 
643   } else {
644     Message (MSG_POSTERR, "Input format type '%d' unrecognized", (int) drfp->type);
645     return;
646   }
647 
648   if (entityID < 1 || dataptr == NULL) {
649     Message (MSG_POSTERR, "Data read failed for input file '%s'", filename);
650     return;
651   }
652 
653   if (SeqMgrFeaturesAreIndexed(entityID) == 0) {
654     SeqMgrIndexFeatures (entityID, NULL);
655   }
656 
657   if (datatype == OBJ_SEQSUB || datatype == OBJ_SEQENTRY ||
658         datatype == OBJ_BIOSEQ || datatype == OBJ_BIOSEQSET) {
659 
660     sep = GetTopSeqEntryForEntityID (entityID);
661 
662     if (sep == NULL) {
663       sep = SeqEntryNew ();
664       if (sep != NULL) {
665         if (datatype == OBJ_BIOSEQ) {
666           bsp = (BioseqPtr) dataptr;
667           sep->choice = 1;
668           sep->data.ptrvalue = bsp;
669           SeqMgrSeqEntry (SM_BIOSEQ, (Pointer) bsp, sep);
670         } else if (datatype == OBJ_BIOSEQSET) {
671           bssp = (BioseqSetPtr) dataptr;
672           sep->choice = 2;
673           sep->data.ptrvalue = bssp;
674           SeqMgrSeqEntry (SM_BIOSEQSET, (Pointer) bssp, sep);
675         } else {
676           sep = SeqEntryFree (sep);
677         }
678       }
679       sep = GetTopSeqEntryForEntityID (entityID);
680     }
681 
682     if (sep != NULL) {
683       ValNodeAddPointer (&(drfp->sep_list), 0, sep);
684 
685     }
686   } else {
687     Message (MSG_POSTERR, "Datatype %d not recognized", (int) datatype);
688   }
689 
690   SeqEntrySetScope (NULL);
691 }
692 
693 static void ProcessMultipleRecord (
694   CharPtr filename,
695   BRFlagPtr drfp
696 )
697 
698 {
699   AsnIoPtr        aip;
700   AsnModulePtr    amp;
701   AsnTypePtr      atp, atp_bss, atp_desc, atp_sbp, atp_se, atp_ssp;
702   Int2            maxcount = 0;
703   CitSubPtr       csp = NULL;
704   FILE            *fp, *ofp = NULL;
705   Int4            numrecords = 0;
706   SeqEntryPtr     sep;
707   ObjValNode      ovn;
708   Pubdesc         pd;
709   SubmitBlockPtr  sbp = NULL;
710   SeqDescrPtr     subcit = NULL;
711   ValNode         vn;
712 #ifdef OS_UNIX
713   Char            cmmd [256];
714   Boolean         detailed_report = FALSE;
715   CharPtr         gzcatprog;
716   Boolean         memory_usage = FALSE;
717   int             ret;
718   Boolean         usedPopen = FALSE;
719 #endif
720 
721   if (StringHasNoText (filename)) return;
722   if (drfp == NULL) return;
723 
724 #ifndef OS_UNIX
725   if (drfp->compressed) {
726     Message (MSG_POSTERR, "Can only decompress on-the-fly on UNIX machines");
727     return;
728   }
729 #endif
730 
731   amp = AsnAllModPtr ();
732   if (amp == NULL) {
733     Message (MSG_POSTERR, "Unable to load AsnAllModPtr");
734     return;
735   }
736 
737   atp_ssp = AsnFind ("Seq-submit");
738   if (atp_ssp == NULL) {
739     Message (MSG_POSTERR, "Unable to find ASN.1 type Seq-submit");
740     return;
741   }
742 
743   atp_sbp = AsnFind ("Seq-submit.sub");
744   if (atp_sbp == NULL) {
745     Message (MSG_POSTERR, "Unable to find ASN.1 type Seq-submit.sub");
746     return;
747   }
748 
749   atp_bss = AsnFind ("Bioseq-set");
750   if (atp_bss == NULL) {
751     Message (MSG_POSTERR, "Unable to find ASN.1 type Bioseq-set");
752     return;
753   }
754 
755   atp_desc = AsnFind ("Bioseq-set.descr");
756   if (atp_desc == NULL) {
757     Message (MSG_POSTERR, "Unable to find ASN.1 type Bioseq-set.descr");
758     return;
759   }
760 
761   atp_se = AsnFind ("Bioseq-set.seq-set.E");
762   if (atp_se == NULL) {
763     Message (MSG_POSTERR, "Unable to find ASN.1 type Bioseq-set.seq-set.E");
764     return;
765   }
766 
767 #ifdef OS_UNIX
768   if (getenv ("ASNVAL_LOG_OBJMGR_REPORT") != NULL) {
769     detailed_report = TRUE;
770   }
771   if (getenv ("ASNVAL_LOG_MEMORY_REPORT") != NULL) {
772     memory_usage = TRUE;
773   }
774 
775   if (drfp->compressed) {
776     gzcatprog = getenv ("NCBI_UNCOMPRESS_BINARY");
777     if (gzcatprog != NULL) {
778       sprintf (cmmd, "%s %s", gzcatprog, filename);
779     } else {
780       ret = system ("gzcat -h >/dev/null 2>&1");
781       if (ret == 0) {
782         sprintf (cmmd, "gzcat %s", filename);
783       } else if (ret == -1) {
784         Message (MSG_POSTERR, "Unable to fork or exec gzcat in ScanBioseqSetRelease");
785         return;
786       } else {
787         ret = system ("zcat -h >/dev/null 2>&1");
788         if (ret == 0) {
789           sprintf (cmmd, "zcat %s", filename);
790         } else if (ret == -1) {
791           Message (MSG_POSTERR, "Unable to fork or exec zcat in ScanBioseqSetRelease");
792           return;
793         } else {
794           Message (MSG_POSTERR, "Unable to find zcat or gzcat in ScanBioseqSetRelease - please edit your PATH environment variable");
795           return;
796         }
797       }
798     }
799     fp = popen (cmmd, /* drfp->binary? "rb" : */ "r");
800     usedPopen = TRUE;
801   } else {
802     fp = FileOpen (filename, drfp->binary? "rb" : "r");
803   }
804 #else
805   fp = FileOpen (filename, drfp->binary? "rb" : "r");
806 #endif
807   if (fp == NULL) {
808     Message (MSG_POSTERR, "FileOpen failed for input file '%s'", filename);
809     return;
810   }
811 
812   aip = AsnIoNew (drfp->binary? ASNIO_BIN_IN : ASNIO_TEXT_IN, fp, NULL, NULL, NULL);
813   if (aip == NULL) {
814     Message (MSG_ERROR, "AsnIoNew failed for input file '%s'", filename);
815     return;
816   }
817 
818   if (drfp->type == 4) {
819     atp = atp_bss;
820   } else if (drfp->type == 5) {
821     atp = atp_ssp;
822   } else {
823     Message (MSG_ERROR, "Batch processing type not set properly");
824     return;
825   }
826 
827   while ((atp = AsnReadId (aip, amp, atp)) != NULL && maxcount < drfp->maxcount) {
828     if (atp == atp_se) {
829 
830       SeqMgrHoldIndexing (TRUE);
831       sep = SeqEntryAsnRead (aip, atp);
832       SeqMgrHoldIndexing (FALSE);
833 
834       ValNodeAddPointer (&(drfp->sep_list), 0, sep);
835 
836       numrecords++;
837       maxcount++;
838     } else if (atp == atp_sbp) {
839       sbp = SubmitBlockAsnRead (aip, atp);
840       if (sbp != NULL) {
841         csp = sbp->cit;
842         if (csp != NULL) {
843           MemSet ((Pointer) &ovn, 0, sizeof (ObjValNode));
844           MemSet ((Pointer) &pd, 0, sizeof (Pubdesc));
845           MemSet ((Pointer) &vn, 0, sizeof (ValNode));
846           vn.choice = PUB_Sub;
847           vn.data.ptrvalue = (Pointer) csp;
848           vn.next = NULL;
849           pd.pub = &vn;
850           ovn.vn.choice = Seq_descr_pub;
851           ovn.vn.data.ptrvalue = (Pointer) &pd;
852           ovn.vn.next = NULL;
853           ovn.vn.extended = 1;
854           subcit = (SeqDescrPtr) &ovn;
855         }
856       }
857     } else {
858       AsnReadVal (aip, atp, NULL);
859     }
860   }
861 
862 
863 
864   AsnIoFree (aip, FALSE);
865 
866 #ifdef OS_UNIX
867   if (usedPopen) {
868     pclose (fp);
869   } else {
870     FileClose (fp);
871   }
872 #else
873   FileClose (fp);
874 #endif
875 
876 }
877 
878 static void ProcessOneRecord (
879   CharPtr filename,
880   Pointer userdata
881 )
882 
883 {
884   BRFlagPtr  drfp;
885 
886   drfp = (BRFlagPtr) userdata;
887   if (drfp == NULL) return;
888 
889   if (drfp->batch) {
890     ProcessMultipleRecord (filename, drfp);
891   } else {
892     ProcessSingleRecord (filename, drfp);
893   }
894   if (drfp->outfp == NULL) {
895     ProcessSeqEntryList (drfp, filename);
896   }
897 }
898 
899 /* Args structure contains command-line arguments */
900 
901 typedef enum {
902   p_argInputPath = 0,
903   i_argInputFile,
904   o_argOutputFile,
905   x_argSuffix,
906   u_argRecurse,
907   e_argEnableTests,
908   d_argDisableTests,
909   n_argMaxPercentN,
910   l_argMinLength,
911   s_argOutputSuffix,
912   q_argOutputDir,
913   Z_argRemoteCDS,
914   a_argType,
915   b_argBinary,
916   c_argCompressed,
917   r_argRemote,
918   k_argLocalFetch,
919   I_argAsnIdx,
920   T_argThreads,
921   C_argMaxCount
922 } BRFlagNum;
923 
924 Args myargs [] = {
925   {"Path to ASN.1 Files", NULL, NULL, NULL,
926     TRUE, 'p', ARG_STRING, 0.0, 0, NULL},
927   {"Single Input File", "stdin", NULL, NULL,
928     TRUE, 'i', ARG_FILE_IN, 0.0, 0, NULL},
929   {"Single Output File", NULL, NULL, NULL,
930     TRUE, 'o', ARG_FILE_OUT, 0.0, 0, NULL},
931   {"File Selection Substring", ".sqn", NULL, NULL,
932     TRUE, 'x', ARG_STRING, 0.0, 0, NULL},
933   {"Recurse", "F", NULL, NULL,
934     TRUE, 'u', ARG_BOOLEAN, 0.0, 0, NULL},
935   {"Enable Tests (comma-delimited list of test names)\n", "", NULL, NULL,
936     TRUE, 'e', ARG_STRING, 0.0, 0, NULL},
937   {"Disable Tests (comma-delimited list of test names)\n", "", NULL, NULL,
938     TRUE, 'd', ARG_STRING, 0.0, 0, NULL},
939   {"Maximum Allowable Precentage of Ns\n", "1", NULL, NULL,
940     TRUE, 'n', ARG_INT, 0.0, 0, NULL},
941   {"Minimum Allowable Bioseq Length\n", "500", NULL, NULL,
942     TRUE, 'l', ARG_INT, 0.0, 0, NULL},
943   {"Output File Suffix", ".dr", NULL, NULL,
944     TRUE, 's', ARG_STRING, 0.0, 0, NULL},
945   {"Output Directory", NULL, NULL, NULL,
946     TRUE, 'q', ARG_STRING, 0.0, 0, NULL},
947   {"Remote CDS Product Fetch", "F", NULL, NULL,
948     TRUE, 'Z', ARG_BOOLEAN, 0.0, 0, NULL},
949   {"ASN.1 Type (a Any, e Seq-entry, b Bioseq, s Bioseq-set, m Seq-submit, t Batch Bioseq-set, u Batch Seq-submit)", "a", NULL, NULL,
950     TRUE, 'a', ARG_STRING, 0.0, 0, NULL},
951   {"Batch File is Binary", "F", NULL, NULL,
952     TRUE, 'b', ARG_BOOLEAN, 0.0, 0, NULL},
953   {"Batch File is Compressed", "F", NULL, NULL,
954     TRUE, 'c', ARG_BOOLEAN, 0.0, 0, NULL},
955   {"Remote Fetching from ID", "F", NULL, NULL,
956     TRUE, 'r', ARG_BOOLEAN, 0.0, 0, NULL},
957   {"Local Fetching", "F", NULL, NULL,
958     TRUE, 'k', ARG_BOOLEAN, 0.0, 0, NULL},
959   {"Path to Indexed Binary ASN.1 Data", NULL, NULL, NULL,
960     TRUE, 'I', ARG_STRING, 0.0, 0, NULL},
961   {"Use Threads", "F", NULL, NULL,
962     TRUE, 'T', ARG_BOOLEAN, 0.0, 0, NULL},
963   {"Max Count", "0", NULL, NULL,
964     TRUE, 'C', ARG_INT, 0.0, 0, NULL},
965 };
966 
967 
968 static CharPtr SetTestsFromString (CharPtr list, Boolean enable, BarcodeTestConfigPtr dcp)
969 {
970   CharPtr         ptr, tmp, name_start, err_msg;
971   Int4            test_type;
972   CharPtr         err_fmt = "%s is an unrecognized test name";
973   
974   if (dcp == NULL) return StringSave ("Unable to configure");
975 
976   if (!StringDoesHaveText (list)) {
977       return StringSave ("No tests specified!");
978   }
979 
980   tmp = StringSave (list);
981   name_start = tmp;
982   while (name_start != NULL && StringDoesHaveText (name_start)) {
983     ptr = StringChr (name_start, ',');
984     if (ptr != NULL) {
985       *ptr = 0;
986     }
987     TrimSpacesAroundString (name_start);
988     test_type = GetBarcodeTestNumFromBarcodeTestName (name_start);
989     if (test_type == eBarcodeTest_LAST) {
990       err_msg = (CharPtr) MemNew (StringLen (err_fmt) + StringLen (name_start));
991       sprintf (err_msg, err_fmt, name_start);
992       tmp = MemFree (tmp);
993       return err_msg;
994     }
995     dcp->conf_list[test_type] = enable;
996     if (ptr == NULL) {
997       name_start = NULL;
998     } else {
999       name_start = ptr + 1;
1000     }
1001   }
1002   tmp = MemFree (tmp);
1003   return NULL;  
1004 }
1005 
1006 static CharPtr GetTestNameList (CharPtr intro)
1007 {
1008   Int4 i, len;
1009   CharPtr text;
1010 
1011   len = StringLen (intro) + 1;
1012 
1013   for (i = 0; i < eBarcodeTest_LAST; i++)
1014   {
1015     len += StringLen (GetBarcodeTestName (i)) + 2;
1016   }
1017 
1018   text = (CharPtr) MemNew (sizeof (Char) * len);
1019   StringCat (text, intro);
1020   for (i = 0; i < eBarcodeTest_LAST; i++) {
1021     StringCat (text, "\t");
1022     StringCat (text, GetBarcodeTestName (i));
1023     StringCat (text, "\n");
1024   }
1025   return text;
1026 }
1027 
1028 Int2 Main (void)
1029 
1030 {
1031   Char         app [64];
1032   CharPtr      asnidx, directory, infile, outfile, str, suffix, output_dir;
1033   CharPtr      enabled_list, disabled_list, err_msg;
1034   Boolean      batch, binary, compressed, dorecurse,
1035                indexed, local, remote, usethreads;
1036   Int2         type = 0, k;
1037   Int4         max_n;
1038   BRFlagData   dfd;
1039 
1040   /* standard setup */
1041 
1042   ErrSetFatalLevel (SEV_MAX);
1043   ErrSetMessageLevel (SEV_MAX);
1044   ErrClearOptFlags (EO_SHOW_USERSTR);
1045   ErrSetLogfile ("stderr", ELOG_APPEND);
1046   ErrSetOpts (ERR_IGNORE, ERR_LOG_ON);
1047 
1048   UseLocalAsnloadDataAndErrMsg ();
1049   ErrPathReset ();
1050 
1051   if (! AllObjLoad ()) {
1052     Message (MSG_FATAL, "AllObjLoad failed");
1053     return 1;
1054   }
1055   if (! SubmitAsnLoad ()) {
1056     Message (MSG_FATAL, "SubmitAsnLoad failed");
1057     return 1;
1058   }
1059   if (! FeatDefSetLoad ()) {
1060     Message (MSG_FATAL, "FeatDefSetLoad failed");
1061     return 1;
1062   }
1063   if (! SeqCodeSetLoad ()) {
1064     Message (MSG_FATAL, "SeqCodeSetLoad failed");
1065     return 1;
1066   }
1067   if (! GeneticCodeTableLoad ()) {
1068     Message (MSG_FATAL, "GeneticCodeTableLoad failed");
1069     return 1;
1070   }
1071 
1072   /* set up help descriptions for enable and disable */
1073   myargs[e_argEnableTests].prompt = GetTestNameList("Enable Tests (comma-delimited list of test names)\n");
1074   myargs[d_argDisableTests].prompt = GetTestNameList("Disable Tests (comma-delimited list of test names)\n");
1075 
1076   /* process command line arguments */
1077 
1078   sprintf (app, "asnbarval %s", ASNBARVAL_APPLICATION);
1079   if (! GetArgs (app, sizeof (myargs) / sizeof (Args), myargs)) {
1080     return 0;
1081   }
1082 
1083   /* additional setup modifications */
1084   MemSet (&dfd, 0, sizeof (BRFlagData));
1085 
1086   directory = (CharPtr) myargs [p_argInputPath].strvalue;
1087   suffix = (CharPtr) myargs [x_argSuffix].strvalue;
1088   dfd.output_suffix = (CharPtr) myargs [s_argOutputSuffix].strvalue;
1089   infile = (CharPtr) myargs [i_argInputFile].strvalue;
1090   outfile = (CharPtr) myargs [o_argOutputFile].strvalue;
1091   output_dir = (CharPtr) myargs [q_argOutputDir].strvalue;
1092   if (StringDoesHaveText (outfile) && StringDoesHaveText (output_dir)) {
1093     Message (MSG_FATAL, "-o and -q are incompatible: specify the output file name with the full path.");
1094     return 1;
1095   }
1096   if (StringDoesHaveText (output_dir)) {
1097     dfd.output_dir = output_dir;
1098     if (! CreateDir (output_dir)) {
1099       Message (MSG_FATAL, "Unable to create output directory %s", output_dir);
1100     }
1101   }
1102 
1103   dorecurse = (Boolean) myargs [u_argRecurse].intvalue;
1104   remote = (Boolean ) myargs [r_argRemote].intvalue;
1105   local = (Boolean) myargs [k_argLocalFetch].intvalue;
1106 
1107   asnidx = (CharPtr) myargs [I_argAsnIdx].strvalue;
1108   indexed = (Boolean) StringDoesHaveText (asnidx);
1109   usethreads = (Boolean) myargs [T_argThreads].intvalue;
1110   dfd.farFetchCDSproducts = (Boolean) myargs [Z_argRemoteCDS].intvalue;
1111 
1112   /* maximum Percent Ns */
1113   max_n = myargs [n_argMaxPercentN].intvalue;
1114   dfd.bcd.min_n_percent = (FloatLo)(max_n);
1115 
1116   /* minimum length */
1117   dfd.bcd.min_length = myargs[l_argMinLength].intvalue;
1118 
1119   /* require keyword to be present */
1120   dfd.bcd.require_keyword = TRUE;
1121 
1122   /* set up Barcode Report Configuration */
1123   enabled_list = (CharPtr) myargs [e_argEnableTests].strvalue;
1124   disabled_list = (CharPtr) myargs [d_argDisableTests].strvalue;
1125 
1126   err_msg = NULL;
1127   if (StringDoesHaveText (enabled_list) && StringDoesHaveText (disabled_list)) {
1128     err_msg = StringSave ("Cannot specify both -e and -d.  Choose -e to enable only a few tests and disable the rest, choose -d to disable only a few tests and enable the rest.");
1129   } else if (StringDoesHaveText (disabled_list)) {
1130     for (k = 0; k < eBarcodeTest_LAST; k++) {
1131       dfd.bcd.conf_list[k] = TRUE;
1132     }
1133 
1134     /* now disable tests from string */
1135     err_msg = SetTestsFromString (disabled_list, FALSE, &(dfd.bcd));
1136   } else if (StringDoesHaveText (enabled_list)) {
1137     for (k = 0; k < eBarcodeTest_LAST; k++) {
1138       dfd.bcd.conf_list[k] = FALSE;
1139     }
1140     /* now enable tests from string */
1141     err_msg = SetTestsFromString (enabled_list, TRUE, &(dfd.bcd));
1142   } else {
1143     /* enable all tests by default */
1144     for (k = 0; k < eBarcodeTest_LAST; k++) {
1145       dfd.bcd.conf_list[k] = TRUE;
1146     }
1147   }
1148   if (err_msg != NULL) {
1149     Message (MSG_FATAL, err_msg);
1150     err_msg = MemFree (err_msg);
1151     return 1;
1152   }
1153 
1154   dfd.maxcount = (Int4) myargs [C_argMaxCount].intvalue;
1155   if (dfd.maxcount < 1) {
1156     dfd.maxcount = INT4_MAX;
1157   }
1158 
1159   batch = FALSE;
1160   binary = (Boolean) myargs [b_argBinary].intvalue;
1161   compressed = (Boolean) myargs [c_argCompressed].intvalue;
1162 
1163   str = myargs [a_argType].strvalue;
1164   if (StringICmp (str, "a") == 0) {
1165     type = 1;
1166   } else if (StringICmp (str, "e") == 0) {
1167     type = 2;
1168   } else if (StringICmp (str, "b") == 0) {
1169     type = 3;
1170   } else if (StringICmp (str, "s") == 0) {
1171     type = 4;
1172   } else if (StringICmp (str, "m") == 0) {
1173     type = 5;
1174   } else if (StringICmp (str, "t") == 0) {
1175     type = 4;
1176     batch = TRUE;
1177   } else if (StringICmp (str, "u") == 0) {
1178     type = 5;
1179     batch = TRUE;
1180   } else {
1181     type = 1;
1182   }
1183 
1184   if ((binary || compressed) && (! batch)) {
1185     if (type == 1) {
1186       Message (MSG_FATAL, "-b or -c cannot be used without -t or -a");
1187       return 1;
1188     }
1189   }
1190 
1191   if (StringHasNoText (directory) && StringHasNoText (infile)) {
1192     Message (MSG_FATAL, "Input path or input file must be specified");
1193     return 1;
1194   }
1195 
1196   /* populate parameter structure */
1197 
1198   dfd.batch = batch;
1199   dfd.binary = binary;
1200   dfd.compressed = compressed;
1201   dfd.useThreads = usethreads;
1202   dfd.type = type;
1203   dfd.numrecords = 0;
1204 
1205   if (! StringHasNoText (outfile)) {
1206     dfd.outpath = outfile;
1207     dfd.outfp = FileOpen (outfile, "w");
1208     if (dfd.outfp == NULL) {
1209       Message (MSG_FATAL, "Unable to open single output file");
1210       return 1;
1211     }
1212   }
1213 
1214   /* register fetch functions */
1215 
1216   if (remote) {
1217 #ifdef INTERNAL_NCBI_ASNBARVAL
1218 
1219     if (! PUBSEQBioseqFetchEnable ("asnval", FALSE)) {
1220       Message (MSG_POSTERR, "PUBSEQBioseqFetchEnable failed");
1221       return 1;
1222     }
1223     dfd.usePUBSEQ = TRUE;
1224     dfd.useThreads = FALSE;
1225 #else
1226     PubSeqFetchEnable ();
1227 #endif
1228   }
1229 
1230   if (local) {
1231     LocalSeqFetchInit (FALSE);
1232   }
1233 
1234   if (indexed) {
1235     AsnIndexedLibFetchEnable (asnidx, TRUE);
1236   }
1237 
1238   /* recurse through all files within source directory or subdirectories */
1239 
1240   if (StringDoesHaveText (directory)) {
1241 
1242     DirExplore (directory, NULL, suffix, dorecurse, ProcessOneRecord, (Pointer) &dfd);
1243     if (dfd.outfp != NULL) {
1244       ProcessSeqEntryList (&dfd, NULL);
1245     }
1246 
1247   } else if (StringDoesHaveText (infile)) {
1248 
1249     ProcessOneRecord (infile, (Pointer) &dfd);
1250     if (dfd.outfp != NULL) {
1251       ProcessSeqEntryList (&dfd, NULL);
1252     }
1253   }
1254 
1255   if (dfd.outfp != NULL) {
1256     FileClose (dfd.outfp);
1257   }
1258 
1259   /* close fetch functions */
1260 
1261   if (indexed) {
1262     AsnIndexedLibFetchDisable ();
1263   }
1264 
1265   if (local) {
1266     LocalSeqFetchDisable ();
1267   }
1268 
1269   if (remote) {
1270 #ifdef INTERNAL_NCBI_ASNBARVAL
1271     PUBSEQBioseqFetchDisable ();
1272 #else
1273     PubSeqFetchDisable ();
1274 #endif
1275     SeqMgrSetPreCache (NULL);
1276     SeqMgrSetSeqIdSetFunc (NULL);
1277   }
1278 
1279   TransTableFreeAll ();
1280 
1281   ECNumberFSAFreeAll ();
1282 
1283   return 0;
1284 }
1285 
1286 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.