|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/demo/cspeedtest.c |
source navigation diff markup identifier search freetext search file search |
1 /* cspeedtest.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: cspeedtest.c
27 *
28 * Author: Jonathan Kans
29 *
30 * Version Creation Date: 12/17/07
31 *
32 * $Revision: 1.22 $
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 <objfdef.h>
49 #include <objsub.h>
50 #include <sequtil.h>
51 #include <sqnutils.h>
52 #include <explore.h>
53 #include <toasn3.h>
54 #include <pmfapi.h>
55 #include <tofasta.h>
56 #include <asn2gnbk.h>
57 #include <valid.h>
58 #include <suggslp.h>
59
60 NLM_EXTERN CharPtr NewCreateDefLine (
61 ItemInfoPtr iip,
62 BioseqPtr bsp,
63 Boolean ignoreTitle,
64 Boolean extProtTitle
65 );
66
67 #define CSPEEDTEST_APP_VER "2.0"
68
69 CharPtr CSPEEDTEST_APPLICATION = CSPEEDTEST_APP_VER;
70
71 typedef struct cspeedflags {
72 Boolean batch;
73 Boolean binary;
74 Boolean compressed;
75 Boolean lock;
76 Int2 type;
77 Int4 maxcount;
78 CharPtr io;
79 CharPtr clean;
80 CharPtr skip;
81 CharPtr index;
82 CharPtr seq;
83 CharPtr feat;
84 CharPtr desc;
85 CharPtr verify;
86 BioseqPtr nucbsp;
87 Int2 genCode;
88 AsnModulePtr amp;
89 AsnTypePtr atp_bss;
90 AsnTypePtr atp_bsss;
91 AsnTypePtr atp_se;
92 AsnTypePtr atp_bsc;
93 AsnTypePtr bssp_atp;
94 BioseqSet bss;
95 FILE *ofp;
96 FILE *logfp;
97 } CSpeedFlagData, PNTR CSpeedFlagPtr;
98
99 static void DoVisitFeaturesTest (
100 SeqFeatPtr sfp,
101 Pointer userdata
102 )
103
104 {
105 /* empty visit callback */
106 }
107
108 static void DoVisitCodingRegions (
109 SeqFeatPtr sfp,
110 Pointer userdata
111 )
112
113 {
114 BioseqPtr bsp;
115 CharPtr caret5, caret3;
116 CSpeedFlagPtr cfp;
117 Char id [64];
118 SeqLocPtr loc, slp;
119 Boolean partial5, partial3;
120 SeqIdPtr sip;
121 Int4 start, stop;
122
123 if (sfp == NULL || sfp->data.choice != SEQFEAT_CDREGION) return;
124 cfp = (CSpeedFlagPtr) userdata;
125 if (cfp == NULL || cfp->ofp == NULL) return;
126
127 loc = sfp->location;
128 bsp = BioseqFindFromSeqLoc (loc);
129 if (bsp == NULL) return;
130
131 StringCpy (id, "?");
132 if (sfp->product != NULL) {
133 sip = SeqLocId (sfp->product);
134 if (sip != NULL) {
135 SeqIdWrite (sip, id, PRINTID_FASTA_SHORT, sizeof (id) - 1);
136 }
137 }
138
139 fprintf (cfp->ofp, "%s\n", id);
140 slp = SeqLocFindNext (loc, NULL);
141 while (slp != NULL) {
142 start = GetOffsetInBioseq (slp, bsp, SEQLOC_START) + 1;
143 stop = GetOffsetInBioseq (slp, bsp, SEQLOC_STOP) + 1;
144 caret5 = "";
145 caret3 = "";
146 CheckSeqLocForPartial (slp, &partial5, &partial3);
147 if (partial5) {
148 caret5 = "<";
149 }
150 if (partial3) {
151 caret3 = ">";
152 }
153 fprintf (cfp->ofp, "%s%ld\t%s%ld\n", caret5, (long) start, caret3, (long) stop);
154 slp = SeqLocFindNext (loc, slp);
155 }
156 }
157
158 static void DoSuggestIntervals (
159 BioseqPtr bsp,
160 Pointer userdata
161 )
162
163 {
164 CharPtr caret5, caret3;
165 CSpeedFlagPtr cfp;
166 Char id [64];
167 SeqLocPtr loc, slp;
168 Boolean partial5, partial3;
169 SeqAnnotPtr sap;
170 SeqFeatPtr sfp;
171 SeqIdPtr sip;
172 Int4 start, stop;
173
174 if (bsp == NULL) return;
175 if (! ISA_aa (bsp->mol)) return;
176 cfp = (CSpeedFlagPtr) userdata;
177 if (cfp == NULL || cfp->ofp == NULL || cfp->nucbsp == NULL) return;
178
179 sip = SeqIdFindBest (bsp->id, 0);
180 if (sip == NULL) return;
181 SeqIdWrite (sip, id, PRINTID_FASTA_SHORT, sizeof (id) - 1);
182
183 sap = SuggestCodingRegion (cfp->nucbsp, bsp, cfp->genCode);
184 if (sap == NULL) return;
185 if (sap->type == 1) {
186 sfp = (SeqFeatPtr) sap->data;
187 if (sfp != NULL && sfp->data.choice == SEQFEAT_CDREGION) {
188 loc = sfp->location;
189 if (loc != NULL) {
190 fprintf (cfp->ofp, "%s\n", id);
191 slp = SeqLocFindNext (loc, NULL);
192 while (slp != NULL) {
193 start = GetOffsetInBioseq (slp, cfp->nucbsp, SEQLOC_START) + 1;
194 stop = GetOffsetInBioseq (slp, cfp->nucbsp, SEQLOC_STOP) + 1;
195 caret5 = "";
196 caret3 = "";
197 CheckSeqLocForPartial (slp, &partial5, &partial3);
198 if (partial5) {
199 caret5 = "<";
200 }
201 if (partial3) {
202 caret3 = ">";
203 }
204 fprintf (cfp->ofp, "%s%ld\t%s%ld\n", caret5, (long) start, caret3, (long) stop);
205 slp = SeqLocFindNext (loc, slp);
206 }
207 }
208 }
209 }
210 SeqAnnotFree (sap);
211 }
212
213 static void DoGeneOverlapPrintTest (
214 SeqFeatPtr sfp,
215 Pointer userdata
216 )
217
218 {
219 CSpeedFlagPtr cfp;
220 SeqMgrFeatContext gcontext;
221 SeqFeatPtr gene;
222 CharPtr str1, str2;
223
224 if (sfp == NULL) return;
225 cfp = (CSpeedFlagPtr) userdata;
226 if (cfp == NULL || cfp->ofp == NULL) return;
227
228 if (sfp->data.choice == SEQFEAT_GENE) return;
229 gene = SeqMgrGetOverlappingGene (sfp->location, &gcontext);
230 if (gene == NULL) return;
231
232 str1 = SeqLocPrint (sfp->location);
233 str2 = SeqLocPrint (gene->location);
234 if (str1 != NULL && str2 != NULL) {
235 fprintf (cfp->ofp, "[%s] -> [%s]\n", str1, str2);
236 } else {
237 fprintf (cfp->ofp, "? -> ?\n");
238 }
239 MemFree (str1);
240 MemFree (str2);
241 }
242
243 static void DoGeneOverlapSpeedTest (
244 SeqFeatPtr sfp,
245 Pointer userdata
246 )
247
248 {
249 CSpeedFlagPtr cfp;
250 SeqMgrFeatContext gcontext;
251 SeqFeatPtr gene;
252
253 if (sfp == NULL) return;
254 cfp = (CSpeedFlagPtr) userdata;
255 if (cfp == NULL || cfp->ofp == NULL) return;
256
257 if (sfp->data.choice == SEQFEAT_GENE) return;
258 gene = SeqMgrGetOverlappingGene (sfp->location, &gcontext);
259 if (gene == NULL) return;
260 }
261
262 static void LIBCALLBACK EmptyStreamProc (
263 CharPtr sequence,
264 Pointer userdata
265 )
266
267 {
268 /* empty stream callback */
269 }
270
271 static void DoFastaSeq (
272 BioseqPtr bsp,
273 Pointer userdata
274 )
275
276 {
277 CSpeedFlagPtr cfp;
278
279 if (bsp == NULL) return;
280 cfp = (CSpeedFlagPtr) userdata;
281 if (cfp == NULL) return;
282
283 if (cfp->ofp != NULL) {
284 BioseqFastaStream (bsp, cfp->ofp, STREAM_EXPAND_GAPS, 70, 0, 0, TRUE);
285 } else {
286 SeqPortStream (bsp, STREAM_EXPAND_GAPS, NULL, EmptyStreamProc);
287 }
288 }
289
290 static void DoFastaRaw (
291 BioseqPtr bsp,
292 Pointer userdata
293 )
294
295 {
296 CSpeedFlagPtr cfp;
297
298 if (bsp == NULL) return;
299 cfp = (CSpeedFlagPtr) userdata;
300 if (cfp == NULL) return;
301
302 if (cfp->ofp != NULL) {
303 fprintf (cfp->ofp, ">\n");
304 BioseqFastaStream (bsp, cfp->ofp, STREAM_EXPAND_GAPS, 70, 0, 0, FALSE);
305 } else {
306 SeqPortStream (bsp, STREAM_EXPAND_GAPS, NULL, EmptyStreamProc);
307 }
308 }
309
310 static void DoFastaDefline (
311 BioseqPtr bsp,
312 Pointer userdata
313 )
314
315 {
316 Char buf [4096];
317 CSpeedFlagPtr cfp;
318 Char id [128];
319
320 if (bsp == NULL) return;
321 cfp = (CSpeedFlagPtr) userdata;
322 if (cfp == NULL) return;
323
324 id [0] = '\0';
325 SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
326 buf [0] = '\0';
327 CreateDefLine (NULL, bsp, buf, sizeof (buf) - 1, 0, NULL, NULL);
328
329 if (cfp->ofp != NULL) {
330 fprintf (cfp->ofp, ">%s %s\n", id, buf);
331 }
332 }
333
334 static void DoNewFastaDefline (
335 BioseqPtr bsp,
336 Pointer userdata
337 )
338
339 {
340 BioseqSetPtr bssp;
341 CSpeedFlagPtr cfp;
342 Char id [128];
343 CharPtr title;
344
345 if (bsp == NULL) return;
346 cfp = (CSpeedFlagPtr) userdata;
347 if (cfp == NULL) return;
348
349 if (StringChr (cfp->skip, 's') != NULL) {
350 if (bsp->idx.parenttype == OBJ_BIOSEQSET) {
351 bssp = (BioseqSetPtr) bsp->idx.parentptr;
352 if (bssp != NULL) {
353 if (bssp->_class == BioseqseqSet_class_segset ||
354 bssp->_class == BioseqseqSet_class_parts) return;
355 }
356 }
357 }
358 if (StringChr (cfp->skip, 'v') != NULL) {
359 if (bsp->repr == Seq_repr_virtual) return;
360 }
361
362 id [0] = '\0';
363 SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
364 title = NewCreateDefLine (NULL, bsp, FALSE, FALSE);
365 if (StringHasNoText (title)) {
366 title = StringSave ("?");
367 }
368
369 if (cfp->ofp != NULL) {
370 fprintf (cfp->ofp, ">%s %s\n", id, title);
371 }
372
373 MemFree (title);
374 }
375
376 static void DoFastaComp (
377 BioseqPtr bsp,
378 Pointer userdata,
379 Boolean ignoreExisting
380 )
381
382 {
383 Char buf [4096];
384 CSpeedFlagPtr cfp;
385 Char id [128];
386 CharPtr title;
387
388 if (bsp == NULL) return;
389 cfp = (CSpeedFlagPtr) userdata;
390 if (cfp == NULL) return;
391
392 id [0] = '\0';
393 SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
394 buf [0] = '\0';
395 CreateDefLineExEx (NULL, bsp, buf, sizeof (buf) - 1, 0,
396 NULL, NULL, ignoreExisting, FALSE);
397 title = NewCreateDefLine (NULL, bsp, ignoreExisting, FALSE);
398 if (StringHasNoText (title)) {
399 title = StringSave ("?");
400 }
401
402 if (StringCmp (buf, title) != 0) {
403 if (cfp->ofp != NULL) {
404 fprintf (cfp->ofp, "< %s %s\n", id, buf);
405 fprintf (cfp->ofp, "> %s %s\n", id, title);
406 }
407 printf ("< %s %s\n", id, buf);
408 printf ("> %s %s\n", id, title);
409 fflush (stdout);
410 }
411
412 MemFree (title);
413 }
414
415 static void DoFastaExist (
416 BioseqPtr bsp,
417 Pointer userdata
418 )
419
420 {
421 DoFastaComp (bsp, userdata, FALSE);
422 }
423
424 static void DoFastaRegen (
425 BioseqPtr bsp,
426 Pointer userdata
427 )
428
429 {
430 DoFastaComp (bsp, userdata, TRUE);
431 }
432
433 static void DoFastaFeat (
434 SeqFeatPtr sfp,
435 Pointer userdata
436 )
437
438 {
439 CSpeedFlagPtr cfp;
440 CharPtr str;
441
442 if (sfp == NULL) return;
443 cfp = (CSpeedFlagPtr) userdata;
444 if (cfp == NULL) return;
445
446 if (cfp->ofp != NULL) {
447 str = SeqLocPrint (sfp->location);
448 if (str != NULL) {
449 fprintf (cfp->ofp, "> [%s]\n", str);
450 MemFree (str);
451 }
452 SeqLocFastaStream (sfp->location, cfp->ofp, STREAM_EXPAND_GAPS, 70, 0, 0);
453 } else {
454 SeqPortStreamLoc (sfp->location, STREAM_EXPAND_GAPS, NULL, EmptyStreamProc);
455 }
456 }
457
458 static void DoFastaTrans (
459 SeqFeatPtr sfp,
460 Pointer userdata
461 )
462
463 {
464 ByteStorePtr bs;
465 CSpeedFlagPtr cfp;
466 CharPtr seq, str;
467
468 if (sfp == NULL) return;
469 cfp = (CSpeedFlagPtr) userdata;
470 if (cfp == NULL) return;
471
472 if (sfp->data.choice != SEQFEAT_CDREGION) return;
473 bs = ProteinFromCdRegion (sfp, FALSE);
474 if (bs == NULL) return;
475
476 seq = (CharPtr) BSMerge (bs, NULL);
477 BSFree (bs);
478 if (seq == NULL) return;
479
480 if (cfp->ofp != NULL) {
481 str = SeqLocPrint (sfp->location);
482 if (str != NULL) {
483 fprintf (cfp->ofp, "> (%s)\n", str);
484 MemFree (str);
485 }
486 fprintf (cfp->ofp, "%s\n", seq);
487 }
488
489 MemFree (seq);
490 }
491
492 static CharPtr compatSeverityLabel [] = {
493 "NONE", "NOTE: valid", "WARNING: valid", "ERROR: valid", "REJECT: valid", "FATAL: valid", "MAX", NULL
494 };
495
496 static void LIBCALLBACK ValidCallback (
497 ErrSev severity,
498 int errcode,
499 int subcode,
500 Uint2 entityID,
501 Uint2 itemtype,
502 Uint4 itemID,
503 CharPtr accession,
504 CharPtr featureID,
505 CharPtr message,
506 CharPtr objtype,
507 CharPtr label,
508 CharPtr context,
509 CharPtr location,
510 CharPtr product,
511 Pointer userdata
512 )
513
514 {
515 CharPtr catname, errname;
516 FILE *fp;
517
518 fp = (FILE *) userdata;
519 if (fp == NULL) return;
520
521 if (severity < SEV_NONE || severity > SEV_MAX) {
522 severity = SEV_MAX;
523 }
524
525 catname = GetValidCategoryName (errcode);
526 errname = GetValidErrorName (errcode, subcode);
527
528 if (catname == NULL) {
529 catname = "?";
530 }
531 if (errname == NULL) {
532 errname = "?";
533 }
534
535 if (accession == NULL) {
536 accession = "";
537 }
538 if (message == NULL) {
539 message = "";
540 }
541 if (objtype == NULL) {
542 objtype = "";
543 }
544 if (label == NULL) {
545 label = "";
546 }
547
548 fprintf (fp, "%s [%s.%s] %s %s: %s",
549 compatSeverityLabel [severity],
550 catname, errname, message, objtype, label);
551 if (location != NULL) {
552 fprintf (fp, " %s", location);
553 }
554 if (context != NULL) {
555 fprintf (fp, " %s", context);
556 }
557 if (product != NULL) {
558 fprintf (fp, " -> %s", product);
559 }
560 fprintf (fp, "\n");
561 }
562
563 static void MarkTitles (
564 SeqDescrPtr sdp,
565 Pointer userdata
566 )
567
568 {
569 ObjValNodePtr ovn;
570
571 if (sdp == NULL || sdp->choice != Seq_descr_title) return;
572 if (sdp->extended == 0) return;
573 ovn = (ObjValNodePtr) sdp;
574 ovn->idx.deleteme = TRUE;
575 }
576
577 static void DoProcess (
578 SeqEntryPtr sep,
579 Uint2 entityID,
580 CSpeedFlagPtr cfp
581 )
582
583 {
584 Char id [64];
585 ErrSev oldErrSev;
586 ValidStructPtr vsp;
587
588 if (sep == NULL || cfp == NULL) return;
589
590 if (StringChr (cfp->clean, 't') != NULL) {
591 VisitDescriptorsInSep (sep, NULL, MarkTitles);
592 DeleteMarkedObjects (entityID, 0, NULL);
593 }
594 if (StringChr (cfp->clean, 'a') != NULL) {
595 AssignIDsInEntity (entityID, 0, NULL);
596 }
597 if (StringChr (cfp->clean, 'b') != NULL) {
598 BasicSeqEntryCleanup (sep);
599 }
600 if (StringChr (cfp->clean, 's') != NULL) {
601 SeriousSeqEntryCleanup (sep, NULL, NULL);
602 }
603
604 if (StringChr (cfp->index, 'f') != NULL) {
605 SeqMgrIndexFeatures (entityID, 0);
606 }
607
608 if (StringChr (cfp->seq, 'c') != NULL) {
609 VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaExist);
610 }
611 if (StringChr (cfp->seq, 'C') != NULL) {
612 VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaRegen);
613 }
614 if (StringChr (cfp->seq, 's') != NULL) {
615 VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaSeq);
616 }
617 if (StringChr (cfp->seq, 'S') != NULL) {
618 if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
619 SeqMgrIndexFeatures (entityID, 0);
620 }
621 VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaSeq);
622 }
623 if (StringChr (cfp->seq, 'r') != NULL) {
624 VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaRaw);
625 }
626 if (StringChr (cfp->seq, 'd') != NULL) {
627 VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaDefline);
628 }
629 if (StringChr (cfp->seq, 'D') != NULL) {
630 if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
631 SeqMgrIndexFeatures (entityID, 0);
632 }
633 VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaDefline);
634 }
635 if (StringChr (cfp->seq, 'T') != NULL) {
636 VisitDescriptorsInSep (sep, NULL, MarkTitles);
637 DeleteMarkedObjects (entityID, 0, NULL);
638 SeqMgrIndexFeatures (entityID, 0);
639 VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaDefline);
640 }
641 if (StringChr (cfp->seq, 'x') != NULL) {
642 VisitBioseqsInSep (sep, (Pointer) cfp, DoNewFastaDefline);
643 }
644 if (StringChr (cfp->seq, 'X') != NULL) {
645 VisitDescriptorsInSep (sep, NULL, MarkTitles);
646 DeleteMarkedObjects (entityID, 0, NULL);
647 SeqMgrIndexFeatures (entityID, 0);
648 VisitBioseqsInSep (sep, (Pointer) cfp, DoNewFastaDefline);
649 }
650
651 if (StringChr (cfp->seq, 'f') != NULL) {
652 VisitFeaturesInSep (sep, (Pointer) cfp, DoFastaFeat);
653 }
654 if (StringChr (cfp->seq, 't') != NULL) {
655 VisitFeaturesInSep (sep, (Pointer) cfp, DoFastaTrans);
656 }
657
658 if (StringChr (cfp->feat, 'v') != NULL) {
659 VisitFeaturesInSep (sep, NULL, DoVisitFeaturesTest);
660 }
661 if (StringChr (cfp->feat, 'g') != NULL) {
662 if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
663 SeqMgrIndexFeatures (entityID, 0);
664 }
665 VisitFeaturesInSep (sep, (Pointer) cfp, DoGeneOverlapPrintTest);
666 }
667 if (StringChr (cfp->feat, 'h') != NULL) {
668 if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
669 SeqMgrIndexFeatures (entityID, 0);
670 }
671 VisitFeaturesInSep (sep, (Pointer) cfp, DoGeneOverlapSpeedTest);
672 }
673 if (StringChr (cfp->feat, 'x') != NULL) {
674 }
675 if (StringChr (cfp->feat, 'o') != NULL) {
676 }
677 if (StringChr (cfp->feat, 'd') != NULL) {
678 }
679 if (StringChr (cfp->feat, 't') != NULL) {
680 SeqEntryToGnbk (sep, NULL, FTABLE_FMT, SEQUIN_MODE, NORMAL_STYLE,
681 0, 0, SHOW_PROT_FTABLE, NULL, cfp->ofp);
682 }
683 if (StringChr (cfp->feat, 's') != NULL) {
684 if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
685 SeqMgrIndexFeatures (entityID, 0);
686 }
687 cfp->nucbsp = FindNucBioseq (sep);
688 if (cfp->nucbsp != NULL) {
689 BioseqToGeneticCode (cfp->nucbsp, &(cfp->genCode), NULL, NULL, NULL, 0, NULL);
690 SeqIdWrite (cfp->nucbsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
691 fprintf (cfp->ofp, "%s\n", id);
692 VisitBioseqsInSep (sep, (Pointer) cfp, DoSuggestIntervals);
693 cfp->nucbsp = NULL;
694 cfp->genCode = 0;
695 }
696 }
697 if (StringChr (cfp->feat, 'S') != NULL) {
698 if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
699 SeqMgrIndexFeatures (entityID, 0);
700 }
701 cfp->nucbsp = FindNucBioseq (sep);
702 if (cfp->nucbsp != NULL) {
703 BioseqToGeneticCode (cfp->nucbsp, &(cfp->genCode), NULL, NULL, NULL, 0, NULL);
704 SetBatchSuggestNucleotide (cfp->nucbsp, cfp->genCode);
705 SeqIdWrite (cfp->nucbsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
706 fprintf (cfp->ofp, "%s\n", id);
707 VisitBioseqsInSep (sep, (Pointer) cfp, DoSuggestIntervals);
708 ClearBatchSuggestNucleotide ();
709 cfp->nucbsp = NULL;
710 cfp->genCode = 0;
711 }
712 }
713 if (StringChr (cfp->feat, 'c') != NULL) {
714 VisitFeaturesInSep (sep, (Pointer) cfp, DoVisitCodingRegions);
715 }
716
717 if (StringChr (cfp->desc, 'b') != NULL) {
718 }
719 if (StringChr (cfp->desc, 't') != NULL) {
720 }
721
722 if (StringChr (cfp->verify, 'v') != NULL) {
723 if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
724 SeqMgrIndexFeatures (entityID, 0);
725 }
726 vsp = ValidStructNew ();
727 if (vsp != NULL) {
728 vsp->useSeqMgrIndexes = TRUE;
729 vsp->suppressContext = TRUE;
730 vsp->seqSubmitParent = TRUE;
731 vsp->testLatLonSubregion = TRUE;
732 oldErrSev = ErrSetMessageLevel (SEV_NONE);
733 vsp->errfunc = ValidCallback;
734 vsp->userdata = (Pointer) cfp->ofp;
735 /* vsp->convertGiToAccn = FALSE; */
736 ValidateSeqEntry (sep, vsp);
737 ValidStructFree (vsp);
738 ErrSetMessageLevel (oldErrSev);
739 }
740 }
741 if (StringChr (cfp->verify, 'b') != NULL) {
742 if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
743 SeqMgrIndexFeatures (entityID, 0);
744 }
745 SeqEntryToGnbk (sep, NULL, GENBANK_FMT, SEQUIN_MODE, NORMAL_STYLE,
746 0, 0, 0, NULL, cfp->ofp);
747 }
748
749 if (cfp->ofp != NULL) {
750 fflush (cfp->ofp);
751 }
752 }
753
754 static void ProcessSingleRecord (
755 CharPtr filename,
756 CSpeedFlagPtr cfp
757 )
758
759 {
760 AsnIoPtr aip;
761 BioseqPtr bsp;
762 ValNodePtr bsplist = NULL;
763 BioseqSetPtr bssp;
764 Pointer dataptr = NULL;
765 Uint2 datatype, entityID = 0;
766 FileCache fc;
767 FILE *fp;
768 Int1 iotype;
769 Char line [512];
770 Int4 maxio = 1;
771 SeqEntryPtr sep;
772 time_t starttime, stoptime, worsttime;
773 CharPtr str;
774 Int4 x;
775
776 if (cfp == NULL) return;
777
778 if (StringHasNoText (filename)) return;
779
780 if (StringChr (cfp->io, 'r') != NULL) {
781 maxio = cfp->maxcount;
782 }
783
784 starttime = GetSecs ();
785
786 for (x = 0; x < maxio; x++) {
787 if (entityID != 0) {
788 ObjMgrFreeByEntityID (entityID);
789 entityID = 0;
790 dataptr = NULL;
791 }
792
793 if (cfp->type == 1) {
794
795 fp = FileOpen (filename, "r");
796 if (fp == NULL) {
797 Message (MSG_POSTERR, "Failed to open '%s'", filename);
798 return;
799 }
800
801 dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE, FALSE, FALSE, FALSE);
802
803 FileClose (fp);
804
805 entityID = ObjMgrRegister (datatype, dataptr);
806
807 } else if (cfp->type >= 2 && cfp->type <= 5) {
808
809 aip = AsnIoOpen (filename, cfp->binary? "rb" : "r");
810 if (aip == NULL) {
811 Message (MSG_POSTERR, "AsnIoOpen failed for input file '%s'", filename);
812 return;
813 }
814
815 SeqMgrHoldIndexing (TRUE);
816 switch (cfp->type) {
817 case 2 :
818 dataptr = (Pointer) SeqEntryAsnRead (aip, NULL);
819 datatype = OBJ_SEQENTRY;
820 break;
821 case 3 :
822 dataptr = (Pointer) BioseqAsnRead (aip, NULL);
823 datatype = OBJ_BIOSEQ;
824 break;
825 case 4 :
826 dataptr = (Pointer) BioseqSetAsnRead (aip, NULL);
827 datatype = OBJ_BIOSEQSET;
828 break;
829 case 5 :
830 dataptr = (Pointer) SeqSubmitAsnRead (aip, NULL);
831 datatype = OBJ_SEQSUB;
832 break;
833 default :
834 break;
835 }
836 SeqMgrHoldIndexing (FALSE);
837
838 AsnIoClose (aip);
839
840 entityID = ObjMgrRegister (datatype, dataptr);
841
842 } else if (cfp->type == 6) {
843
844 fp = FileOpen (filename, "r");
845 if (fp == NULL) {
846 Message (MSG_POSTERR, "Failed to open '%s'", filename);
847 return;
848 }
849
850 dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE, FALSE, FALSE, FALSE);
851
852 FileClose (fp);
853
854 entityID = ObjMgrRegister (datatype, dataptr);
855
856 } else if (cfp->type == 7) {
857
858 fp = FileOpen (filename, "r");
859 if (fp == NULL) {
860 Message (MSG_POSTERR, "Failed to open '%s'", filename);
861 return;
862 }
863
864 FileCacheSetup (&fc, fp);
865
866 str = FileCacheReadLine (&fc, line, sizeof (line), NULL);
867 while (str != NULL) {
868 str = FileCacheReadLine (&fc, line, sizeof (line), NULL);
869 }
870
871 FileClose (fp);
872
873 return;
874
875 } else {
876 Message (MSG_POSTERR, "Input format type '%d' unrecognized", (int) cfp->type);
877 return;
878 }
879 }
880
881 if (entityID < 1 || dataptr == NULL) {
882 Message (MSG_POSTERR, "Data read failed for input file '%s'", filename);
883 return;
884 }
885
886 if (datatype == OBJ_SEQSUB || datatype == OBJ_SEQENTRY ||
887 datatype == OBJ_BIOSEQ || datatype == OBJ_BIOSEQSET) {
888
889 stoptime = GetSecs ();
890 worsttime = stoptime - starttime;
891 if (cfp->logfp != NULL) {
892 fprintf (cfp->logfp, "ASN reading time %ld seconds\n", (long) worsttime);
893 fflush (cfp->logfp);
894 }
895
896 sep = GetTopSeqEntryForEntityID (entityID);
897
898 if (sep == NULL) {
899 sep = SeqEntryNew ();
900 if (sep != NULL) {
901 if (datatype == OBJ_BIOSEQ) {
902 bsp = (BioseqPtr) dataptr;
903 sep->choice = 1;
904 sep->data.ptrvalue = bsp;
905 SeqMgrSeqEntry (SM_BIOSEQ, (Pointer) bsp, sep);
906 } else if (datatype == OBJ_BIOSEQSET) {
907 bssp = (BioseqSetPtr) dataptr;
908 sep->choice = 2;
909 sep->data.ptrvalue = bssp;
910 SeqMgrSeqEntry (SM_BIOSEQSET, (Pointer) bssp, sep);
911 } else {
912 sep = SeqEntryFree (sep);
913 }
914 }
915 sep = GetTopSeqEntryForEntityID (entityID);
916 }
917
918 if (sep != NULL) {
919
920 if (cfp->lock) {
921 starttime = GetSecs ();
922
923 bsplist = LockFarComponents (sep);
924
925 stoptime = GetSecs ();
926 worsttime = stoptime - starttime;
927 if (cfp->logfp != NULL) {
928 fprintf (cfp->logfp, "Far component locking time %ld seconds\n", (long) worsttime);
929 fflush (cfp->logfp);
930 }
931 }
932
933 if (StringChr (cfp->io, 'w') != NULL) {
934 starttime = GetSecs ();
935
936 iotype = ASNIO_TEXT_OUT;
937 if (StringChr (cfp->io, 'b') != NULL) {
938 iotype = ASNIO_BIN_OUT;
939 }
940
941 for (x = 0; x < cfp->maxcount; x++) {
942 aip = AsnIoNew (iotype, cfp->ofp, NULL, NULL, NULL);
943 if (aip != NULL) {
944 SeqEntryAsnWrite (sep, aip, NULL);
945 AsnIoFree (aip, FALSE);
946 }
947 }
948
949 stoptime = GetSecs ();
950 worsttime = stoptime - starttime;
951 if (cfp->logfp != NULL) {
952 fprintf (cfp->logfp, "ASN writing time %ld seconds\n", (long) worsttime);
953 fflush (cfp->logfp);
954 }
955 }
956
957 starttime = GetSecs ();
958
959 for (x = 0; x < cfp->maxcount; x++) {
960 DoProcess (sep, entityID, cfp);
961 }
962
963 stoptime = GetSecs ();
964 worsttime = stoptime - starttime;
965 if (cfp->logfp != NULL) {
966 fprintf (cfp->logfp, "Internal processing time %ld seconds\n", (long) worsttime);
967 fflush (cfp->logfp);
968 }
969
970 ObjMgrFreeByEntityID (entityID);
971
972 bsplist = UnlockFarComponents (bsplist);
973 }
974
975 } else {
976
977 Message (MSG_POSTERR, "Datatype %d not recognized", (int) datatype);
978 }
979 }
980
981 static void ProcessMultipleRecord (
982 CharPtr filename,
983 CSpeedFlagPtr cfp
984 )
985
986 {
987 AsnIoPtr aip;
988 AsnTypePtr atp;
989 BioseqPtr bsp;
990 Char buf [41];
991 Uint2 entityID;
992 FILE *fp;
993 SeqEntryPtr fsep;
994 Char longest [41];
995 Int4 numrecords, x;
996 SeqEntryPtr sep;
997 time_t starttime, stoptime, worsttime;
998 #ifdef OS_UNIX
999 Char cmmd [256];
1000 CharPtr gzcatprog;
1001 int ret;
1002 Boolean usedPopen = FALSE;
1003 #endif
1004
1005 if (cfp == NULL) return;
1006
1007 if (StringHasNoText (filename)) return;
1008
1009 #ifndef OS_UNIX
1010 if (cfp->compressed) {
1011 Message (MSG_POSTERR, "Can only decompress on-the-fly on UNIX machines");
1012 return;
1013 }
1014 #endif
1015
1016 #ifdef OS_UNIX
1017 if (cfp->compressed) {
1018 gzcatprog = getenv ("NCBI_UNCOMPRESS_BINARY");
1019 if (gzcatprog != NULL) {
1020 sprintf (cmmd, "%s %s", gzcatprog, filename);
1021 } else {
1022 ret = system ("gzcat -h >/dev/null 2>&1");
1023 if (ret == 0) {
1024 sprintf (cmmd, "gzcat %s", filename);
1025 } else if (ret == -1) {
1026 Message (MSG_POSTERR, "Unable to fork or exec gzcat in ScanBioseqSetRelease");
1027 return;
1028 } else {
1029 ret = system ("zcat -h >/dev/null 2>&1");
1030 if (ret == 0) {
1031 sprintf (cmmd, "zcat %s", filename);
1032 } else if (ret == -1) {
1033 Message (MSG_POSTERR, "Unable to fork or exec zcat in ScanBioseqSetRelease");
1034 return;
1035 } else {
1036 Message (MSG_POSTERR, "Unable to find zcat or gzcat in ScanBioseqSetRelease - please edit your PATH environment variable");
1037 return;
1038 }
1039 }
1040 }
1041 fp = popen (cmmd, /* cfp->binary? "rb" : */ "r");
1042 usedPopen = TRUE;
1043 } else {
1044 fp = FileOpen (filename, cfp->binary? "rb" : "r");
1045 }
1046 #else
1047 fp = FileOpen (filename, cfp->binary? "rb" : "r");
1048 #endif
1049 if (fp == NULL) {
1050 Message (MSG_POSTERR, "FileOpen failed for input file '%s'", filename);
1051 return;
1052 }
1053
1054 aip = AsnIoNew (cfp->binary? ASNIO_BIN_IN : ASNIO_TEXT_IN, fp, NULL, NULL, NULL);
1055 if (aip == NULL) {
1056 Message (MSG_ERROR, "AsnIoNew failed for input file '%s'", filename);
1057 return;
1058 }
1059
1060 if (cfp->logfp != NULL) {
1061 fprintf (cfp->logfp, "%s\n\n", filename);
1062 fflush (cfp->logfp);
1063 }
1064
1065 longest [0] = '\0';
1066 worsttime = 0;
1067 numrecords = 0;
1068
1069 atp = cfp->atp_bss;
1070
1071 while ((atp = AsnReadId (aip, cfp->amp, atp)) != NULL) {
1072 if (atp == cfp->atp_se) {
1073
1074 SeqMgrHoldIndexing (TRUE);
1075 sep = SeqEntryAsnRead (aip, atp);
1076 SeqMgrHoldIndexing (FALSE);
1077
1078 if (sep != NULL) {
1079
1080 entityID = ObjMgrGetEntityIDForChoice (sep);
1081
1082 fsep = FindNthBioseq (sep, 1);
1083 if (fsep != NULL && fsep->choice == 1) {
1084 bsp = (BioseqPtr) fsep->data.ptrvalue;
1085 if (bsp != NULL) {
1086 SeqIdWrite (bsp->id, buf, PRINTID_FASTA_LONG, sizeof (buf));
1087 if (cfp->logfp != NULL) {
1088 fprintf (cfp->logfp, "%s\n", buf);
1089 fflush (cfp->logfp);
1090 }
1091 }
1092 }
1093
1094 starttime = GetSecs ();
1095
1096 for (x = 0; x < cfp->maxcount; x++) {
1097 DoProcess (sep, entityID, cfp);
1098 }
1099 stoptime = GetSecs ();
1100
1101 if (stoptime - starttime > worsttime) {
1102 worsttime = stoptime - starttime;
1103 StringCpy (longest, buf);
1104 }
1105 numrecords++;
1106
1107 ObjMgrFreeByEntityID (entityID);
1108 }
1109
1110 } else {
1111
1112 AsnReadVal (aip, atp, NULL);
1113 }
1114 }
1115
1116 AsnIoFree (aip, FALSE);
1117
1118 #ifdef OS_UNIX
1119 if (usedPopen) {
1120 pclose (fp);
1121 } else {
1122 FileClose (fp);
1123 }
1124 #else
1125 FileClose (fp);
1126 #endif
1127 if (cfp->logfp != NULL && (! StringHasNoText (longest))) {
1128 fprintf (cfp->logfp, "Longest processing time %ld seconds on %s\n",
1129 (long) worsttime, longest);
1130 fprintf (cfp->logfp, "Total number of records %ld\n", (long) numrecords);
1131 fflush (cfp->logfp);
1132 }
1133 }
1134
1135 static void ProcessOneRecord (
1136 CharPtr filename,
1137 Pointer userdata
1138 )
1139
1140 {
1141 CSpeedFlagPtr cfp;
1142
1143 if (StringHasNoText (filename)) return;
1144 cfp = (CSpeedFlagPtr) userdata;
1145 if (cfp == NULL) return;
1146
1147 if (cfp->batch) {
1148 ProcessMultipleRecord (filename, cfp);
1149 } else {
1150 ProcessSingleRecord (filename, cfp);
1151 }
1152 }
1153
1154 /* Args structure contains command-line arguments */
1155
1156 #define p_argInputPath 0
1157 #define i_argInputFile 1
1158 #define o_argOutputFile 2
1159 #define f_argFilter 3
1160 #define x_argSuffix 4
1161 #define a_argType 5
1162 #define b_argBinary 6
1163 #define c_argCompressed 7
1164 #define l_argLockFar 8
1165 #define L_argLogFile 9
1166 #define R_argRemote 10
1167 #define X_argMaxCount 11
1168 #define O_argInOut 12
1169 #define K_argClean 13
1170 #define P_argSkip 14
1171 #define I_argIndex 15
1172 #define S_argSeq 16
1173 #define F_argFeat 17
1174 #define D_argDesc 18
1175 #define V_argVerify 19
1176
1177 Args myargs [] = {
1178 {"Path to Files", NULL, NULL, NULL,
1179 TRUE, 'p', ARG_STRING, 0.0, 0, NULL},
1180 {"Single Input File", "stdin", NULL, NULL,
1181 TRUE, 'i', ARG_FILE_IN, 0.0, 0, NULL},
1182 {"Output File", "stdout", NULL, NULL,
1183 TRUE, 'o', ARG_FILE_OUT, 0.0, 0, NULL},
1184 {"Substring Filter", NULL, NULL, NULL,
1185 TRUE, 'f', ARG_STRING, 0.0, 0, NULL},
1186 {"File Selection Suffix", ".ent", NULL, NULL,
1187 TRUE, 'x', ARG_STRING, 0.0, 0, NULL},
1188 {"ASN.1 Type\n"
1189 " a Any\n"
1190 " e Seq-entry\n"
1191 " b Bioseq\n"
1192 " s Bioseq-set\n"
1193 " m Seq-submit\n"
1194 " t Batch Processing\n"
1195 " f FASTA\n"
1196 " l Read by Lines", "a", NULL, NULL,
1197 TRUE, 'a', ARG_STRING, 0.0, 0, NULL},
1198 {"Bioseq-set is Binary", "F", NULL, NULL,
1199 TRUE, 'b', ARG_BOOLEAN, 0.0, 0, NULL},
1200 {"Bioseq-set is Compressed", "F", NULL, NULL,
1201 TRUE, 'c', ARG_BOOLEAN, 0.0, 0, NULL},
1202 {"Lock Components in Advance", "F", NULL, NULL,
1203 TRUE, 'l', ARG_BOOLEAN, 0.0, 0, NULL},
1204 {"Log File", NULL, NULL, NULL,
1205 TRUE, 'L', ARG_FILE_OUT, 0.0, 0, NULL},
1206 {"Remote Fetching from ID", "F", NULL, NULL,
1207 TRUE, 'R', ARG_BOOLEAN, 0.0, 0, NULL},
1208 {"Max Repeat Count", "1", NULL, NULL,
1209 TRUE, 'X', ARG_INT, 0.0, 0, NULL},
1210 {"Input Output\n"
1211 " r Read ASN.1\n"
1212 " w Write Text ASN.1\n"
1213 " wb Write Binary ASN.1", NULL, NULL, NULL,
1214 TRUE, 'O', ARG_STRING, 0.0, 0, NULL},
1215 {"Cleanup\n"
1216 " t Remove Titles\n"
1217 " a AssignIDsInEntity\n"
1218 " b BasicSeqEntryCleanup\n"
1219 " s SeriousSeqEntryCleanup", NULL, NULL, NULL,
1220 TRUE, 'K', ARG_STRING, 0.0, 0, NULL},
1221 {"Skip\n"
1222 " s Segmented Set Components\n"
1223 " v Virtual Bioseqs", NULL, NULL, NULL,
1224 TRUE, 'P', ARG_STRING, 0.0, 0, NULL},
1225 {"Index\n"
1226 " f Feature Indexing", NULL, NULL, NULL,
1227 TRUE, 'I', ARG_STRING, 0.0, 0, NULL},
1228 {"Sequence\n"
1229 " c Compare FASTA Deflines\n"
1230 " C Compare Regenerated FASTA Deflines\n"
1231 " s FASTA of Sequence\n"
1232 " S Indexed FASTA\n"
1233 " r Raw FASTA no Defline\n"
1234 " d Just FASTA Defline\n"
1235 " D Indexed FASTA Defline\n"
1236 " T Regenerate FASTA Titles\n"
1237 " x New FASTA Titles\n"
1238 " X Regenerate new FASTA Titles\n"
1239 " f FASTA by Feature\n"
1240 " t FASTA of Translation", NULL, NULL, NULL,
1241 TRUE, 'S', ARG_STRING, 0.0, 0, NULL},
1242 {"Feature\n"
1243 " v Visit Features\n"
1244 " g Gene Overlap Print\n"
1245 " h Gene Overlap Speed\n"
1246 " x Gene by Xref\n"
1247 " o Operon by Overlap\n"
1248 " d Feature by ID\n"
1249 " t Feature Table\n"
1250 " s Slow Suggest Intervals\n"
1251 " S Indexed Suggest Intervals\n"
1252 " c Coding Region Intervals", NULL, NULL, NULL,
1253 TRUE, 'F', ARG_STRING, 0.0, 0, NULL},
1254 {"Descriptor\n"
1255 " b BioSource\n"
1256 " t Title", NULL, NULL, NULL,
1257 TRUE, 'D', ARG_STRING, 0.0, 0, NULL},
1258 {"Verification\n"
1259 " v Validate with Normal Stringency\n"
1260 " b Generate GenBank Flatfile\n", NULL, NULL, NULL,
1261 TRUE, 'V', ARG_STRING, 0.0, 0, NULL},
1262 };
1263
1264 Int2 Main (void)
1265
1266 {
1267 Char app [64], type;
1268 CSpeedFlagData cfd;
1269 CharPtr directory, filter, infile, logfile, outfile, str, suffix;
1270 Boolean remote;
1271 time_t runtime, starttime, stoptime;
1272
1273 /* standard setup */
1274
1275 ErrSetFatalLevel (SEV_MAX);
1276 ErrClearOptFlags (EO_SHOW_USERSTR);
1277 UseLocalAsnloadDataAndErrMsg ();
1278 ErrPathReset ();
1279
1280 /* finish resolving internal connections in ASN.1 parse tables */
1281
1282 if (! AllObjLoad ()) {
1283 Message (MSG_FATAL, "AllObjLoad failed");
1284 return 1;
1285 }
1286 if (! SubmitAsnLoad ()) {
1287 Message (MSG_FATAL, "SubmitAsnLoad failed");
1288 return 1;
1289 }
1290 if (! FeatDefSetLoad ()) {
1291 Message (MSG_FATAL, "FeatDefSetLoad failed");
1292 return 1;
1293 }
1294 if (! SeqCodeSetLoad ()) {
1295 Message (MSG_FATAL, "SeqCodeSetLoad failed");
1296 return 1;
1297 }
1298 if (! GeneticCodeTableLoad ()) {
1299 Message (MSG_FATAL, "GeneticCodeTableLoad failed");
1300 return 1;
1301 }
1302
1303 /* process command line arguments */
1304
1305 sprintf (app, "cspeedtest %s", CSPEEDTEST_APPLICATION);
1306 if (! GetArgs (app, sizeof (myargs) / sizeof (Args), myargs)) {
1307 return 0;
1308 }
1309
1310 MemSet ((Pointer) &cfd, 0, sizeof (CSpeedFlagData));
1311
1312 directory = (CharPtr) myargs [p_argInputPath].strvalue;
1313 infile = (CharPtr) myargs [i_argInputFile].strvalue;
1314 outfile = (CharPtr) myargs [o_argOutputFile].strvalue;
1315 filter = (CharPtr) myargs [f_argFilter].strvalue;
1316 suffix = (CharPtr) myargs [x_argSuffix].strvalue;
1317
1318 cfd.batch = FALSE;
1319 cfd.binary = (Boolean) myargs [b_argBinary].intvalue;
1320 cfd.compressed = (Boolean) myargs [c_argCompressed].intvalue;
1321 cfd.lock = (Boolean) myargs [l_argLockFar].intvalue;
1322 cfd.type = 1;
1323
1324 str = myargs [a_argType].strvalue;
1325 TrimSpacesAroundString (str);
1326 if (StringDoesHaveText (str)) {
1327 type = str [0];
1328 } else {
1329 type = 'a';
1330 }
1331
1332 type = TO_LOWER (type);
1333 switch (type) {
1334 case 'a' :
1335 cfd.type = 1;
1336 break;
1337 case 'e' :
1338 cfd.type = 2;
1339 break;
1340 case 'b' :
1341 cfd.type = 3;
1342 break;
1343 case 's' :
1344 cfd.type = 4;
1345 break;
1346 case 'm' :
1347 cfd.type = 5;
1348 break;
1349 case 't' :
1350 cfd.type = 1;
1351 cfd.batch = TRUE;
1352 break;
1353 case 'f' :
1354 cfd.type = 6;
1355 break;
1356 case 'l' :
1357 cfd.type = 7;
1358 break;
1359 default :
1360 cfd.type = 1;
1361 break;
1362 }
1363
1364 remote = (Boolean) myargs [R_argRemote].intvalue;
1365
1366 cfd.maxcount = myargs [X_argMaxCount].intvalue;
1367 if (cfd.maxcount < 1) {
1368 cfd.maxcount = 1;
1369 }
1370
1371 cfd.io = myargs [O_argInOut].strvalue;
1372 cfd.clean = myargs [K_argClean].strvalue;
1373 cfd.skip = myargs [P_argSkip].strvalue;
1374 cfd.index = myargs [I_argIndex].strvalue;
1375 cfd.seq = myargs [S_argSeq].strvalue;
1376 cfd.feat = myargs [F_argFeat].strvalue;
1377 cfd.desc = myargs [D_argDesc].strvalue;
1378 cfd.verify = myargs [V_argVerify].strvalue;
1379
1380 cfd.amp = AsnAllModPtr ();
1381 cfd.atp_bss = AsnFind ("Bioseq-set");
1382 cfd.atp_bsss = AsnFind ("Bioseq-set.seq-set");
1383 cfd.atp_se = AsnFind ("Bioseq-set.seq-set.E");
1384 cfd.atp_bsc = AsnFind ("Bioseq-set.class");
1385 cfd.bssp_atp = AsnLinkType (NULL, cfd.atp_bss);
1386
1387 logfile = (CharPtr) myargs [L_argLogFile].strvalue;
1388 if (StringDoesHaveText (logfile)) {
1389 cfd.logfp = FileOpen (logfile, "w");
1390 }
1391
1392 if (remote) {
1393 PubSeqFetchEnable ();
1394 }
1395
1396 if (StringDoesHaveText (outfile)) {
1397 cfd.ofp = FileOpen (outfile, "w");
1398 }
1399
1400 starttime = GetSecs ();
1401
1402 if (StringDoesHaveText (directory)) {
1403
1404 DirExplore (directory, NULL, suffix, FALSE, ProcessOneRecord, (Pointer) &cfd);
1405
1406 } else if (StringDoesHaveText (infile)) {
1407
1408 ProcessOneRecord (infile, (Pointer) &cfd);
1409 }
1410
1411 if (cfd.ofp != NULL) {
1412 FileClose (cfd.ofp);
1413 }
1414
1415 stoptime = GetSecs ();
1416 runtime = stoptime - starttime;
1417 if (cfd.logfp != NULL) {
1418 fprintf (cfd.logfp, "Finished in %ld seconds\n", (long) runtime);
1419 FileClose (cfd.logfp);
1420 }
1421 printf ("Finished in %ld seconds\n", (long) runtime);
1422
1423 if (remote) {
1424 PubSeqFetchDisable ();
1425 }
1426
1427 return 0;
1428 }
1429
1430 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |