~ubuntu-branches/ubuntu/precise/ncbi-tools6/precise

« back to all changes in this revision

Viewing changes to demo/bl2seq.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-03-27 12:00:15 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050327120015-embhesp32nj73p9r
Tags: 6.1.20041020-3
* Fix FTBFS under GCC 4.0 caused by inconsistent use of "static" on
  functions.  (Closes: #295110.)
* Add a watch file, now that we can.  (Upstream's layout needs version=3.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
static char const rcsid[] = "$Id: bl2seq.c,v 6.66 2004/10/04 14:05:06 madden Exp $";
 
2
 
1
3
/**************************************************************************
2
4
*                                                                         *
3
5
*                             COPYRIGHT NOTICE                            *
25
27
***************************************************************************
26
28
*
27
29
* $Log: bl2seq.c,v $
 
30
* Revision 6.66  2004/10/04 14:05:06  madden
 
31
* Use Blast_PrintOutputFooter rather than BLAST_PrintSummaryReturns
 
32
*
 
33
* Revision 6.65  2004/09/13 15:15:54  madden
 
34
* Changes for BlastSeqLoc and BlastMaskLoc
 
35
*
 
36
* Revision 6.64  2004/08/16 14:26:47  madden
 
37
* Fix bad frees for blastx filtering locations
 
38
*
 
39
* Revision 6.63  2004/08/09 13:08:15  madden
 
40
* Bl2seq now can run queries with new blast engine
 
41
*
 
42
* Revision 6.62  2004/08/03 14:02:02  madden
 
43
* Introduce enum to make myargs more readable
 
44
*
 
45
* Revision 6.61  2004/06/30 16:03:48  kans
 
46
* include <blfmtutl.h>
 
47
*
 
48
* Revision 6.60  2004/02/26 16:25:06  camacho
 
49
* Fix uninitialized variable errors that caused core dumps on empty input files
 
50
*
 
51
* Revision 6.59  2003/06/26 18:56:05  coulouri
 
52
* remove unnecessary variables
 
53
*
 
54
* Revision 6.58  2003/05/30 17:31:09  coulouri
 
55
* add rcsid
 
56
*
 
57
* Revision 6.57  2003/05/13 16:02:42  coulouri
 
58
* make ErrPostEx(SEV_FATAL, ...) exit with nonzero status
 
59
*
 
60
* Revision 6.56  2003/05/06 18:57:46  dondosha
 
61
* Do not set cutoff_s for megablast, it is not needed
 
62
*
 
63
* Revision 6.55  2003/04/22 19:38:00  dondosha
 
64
* Fix for ungapped search with tabular output
 
65
*
 
66
* Revision 6.54  2003/01/16 19:46:28  kans
 
67
* include accid1.h to fix Mac compiler error on missing symbols
 
68
*
 
69
* Revision 6.53  2003/01/10 20:55:36  dondosha
 
70
* Enable the Entrez client option without a special definition
 
71
*
 
72
* Revision 6.52  2003/01/07 15:47:11  dondosha
 
73
* Hide the -A argument if NCBI_ENTREZ_CLIENT is not defined
 
74
*
 
75
* Revision 6.51  2002/09/18 18:21:04  camacho
 
76
* Fixed memory leak when using the -U option
 
77
*
 
78
* Revision 6.50  2002/09/13 18:53:26  dondosha
 
79
* Corrected the way query and subject deflines are shown in all types of output
 
80
*
 
81
* Revision 6.49  2002/08/09 19:41:25  camacho
 
82
* 1) Added blast version number to command-line options
 
83
* 2) Added explanations for some default parameters
 
84
*
 
85
* Revision 6.48  2002/06/26 21:44:57  dondosha
 
86
* Set default gap penalties before checking command line options
 
87
*
 
88
* Revision 6.47  2002/06/24 18:24:05  dondosha
 
89
* Multiple memory freeing bug fixed
 
90
*
 
91
* Revision 6.46  2002/05/09 15:37:52  dondosha
 
92
* Call BLASTOptionNewEx instead of BLASTOptionNew, so megablast defaults are set in a central place
 
93
*
 
94
* Revision 6.45  2002/05/02 22:18:25  dondosha
 
95
* Copy bioseq if getting it from ID1, removing non-residue characters from sequence
 
96
*
 
97
* Revision 6.44  2002/05/01 16:43:53  dondosha
 
98
* Call BLASTOptionSetGapParams instead of setting options->matrix
 
99
*
 
100
* Revision 6.43  2002/04/29 19:55:26  madden
 
101
* Use ARG_FLOAT for db length
 
102
*
 
103
* Revision 6.42  2002/03/19 23:29:38  dondosha
 
104
* Do not increment options->wordsize by 4 for megablast any more
 
105
*
 
106
* Revision 6.41  2002/03/14 16:11:41  camacho
 
107
* Extended BlastTwoSequences to allow comparison between sequence and PSSM
 
108
*
28
109
* Revision 6.40  2001/07/19 22:05:47  dondosha
29
110
* Made db_length option a string, to convert to Int8 value
30
111
*
152
233
#include <txalign.h>
153
234
#include <sqnutils.h>
154
235
#include <mblast.h>
 
236
#include <accid1.h>
 
237
#include <blfmtutl.h>
 
238
 
 
239
#include <algo/blast/api/twoseq_api.h>
 
240
#include <algo/blast/api/blast_format.h>
 
241
#include <algo/blast/api/blast_seq.h>
 
242
#include <algo/blast/core/blast_filter.h>
 
243
 
155
244
 
156
245
/* Used by the callback function. */
157
246
FILE *global_fp=NULL;
158
247
 
 
248
#define LOCAL_BUFLEN 255
159
249
static BioseqPtr
160
 
BioseqFromAccession(CharPtr accver, Int2 id_num, Boolean is_na)
 
250
BioseqFromAccession(CharPtr accver, Int2 id_num, Boolean is_na, 
 
251
                    Boolean believe_defline)
161
252
{
162
 
   CharPtr accession, new_defline, accver_var, version_str;
 
253
   CharPtr accession, new_defline, version_str;
163
254
   Int4 version=0, gi, number, title_length, id_length;
164
255
   SeqIdPtr sip = NULL;
165
256
   TextSeqIdPtr tsip;
166
257
   PDBSeqIdPtr  psip;
167
 
   BioseqPtr bsp = NULL;
 
258
   BioseqPtr bsp = NULL, bsp_tmp = NULL;
168
259
   ObjectIdPtr  oid;
169
260
   SeqPortPtr spp;
170
261
   Int2 retval, buf_length=512;
171
262
   Uint1 buf[512];
172
 
   Char tmp[255];
 
263
   Char tmp[LOCAL_BUFLEN];
173
264
 
174
 
#ifdef NCBI_ENTREZ_CLIENT
175
265
   if (!ID1BioseqFetchEnable ("bl2seq", TRUE))
176
 
      ErrPostEx(SEV_FATAL, 0, 0, 
 
266
      ErrPostEx(SEV_FATAL, 1, 0, 
177
267
                "Entrez access interface currently unavailable\n");
178
 
   accver_var = StringSave(accver);
179
268
   if (!IS_DIGIT(*accver)) {
180
269
      accession = StringTokMT(accver, ".", &version_str);
181
270
      if (version_str)
243
332
 
244
333
   if (gi > 0) {
245
334
      ValNodeAddInt(&sip, SEQID_GI, gi);
246
 
      if ((bsp = BioseqLockById(sip)) == NULL) {
 
335
      if ((bsp_tmp = BioseqLockById(sip)) == NULL) {
247
336
         ErrPostEx(SEV_WARNING, 0, 0, "Gi %ld not found", gi);
248
337
         return NULL;
249
338
      }
250
339
   } 
251
340
   
252
 
   if (ISA_na(bsp->mol) != is_na) {
253
 
      BioseqUnlock(bsp);
 
341
   if (ISA_na(bsp_tmp->mol) != is_na) {
 
342
      BioseqUnlock(bsp_tmp);
254
343
      if (is_na)
255
 
         ErrPostEx(SEV_FATAL, 0, 0, 
 
344
         ErrPostEx(SEV_FATAL, 1, 0, 
256
345
                   "%s is a protein sequence, program requires nucleotide", 
257
346
                   accver);
258
347
      else
259
 
         ErrPostEx(SEV_FATAL, 0, 0, 
 
348
         ErrPostEx(SEV_FATAL, 1, 0, 
260
349
                   "%s is a nucleotide sequence, program requires protein", 
261
350
                   accver);
262
351
      return NULL;
263
352
   }
264
 
 
 
353
   
 
354
   bsp = BioseqNew();
 
355
   bsp->length = bsp_tmp->length;
 
356
   bsp->mol = bsp_tmp->mol;
 
357
   bsp->repr = Seq_repr_raw;
 
358
   bsp->seq_data = BSNew(bsp->length);
 
359
                   
265
360
   if (ISA_na(bsp->mol)) {
266
 
      spp = SeqPortNew(bsp, 0, -1, Seq_strand_plus, 
 
361
      spp = SeqPortNew(bsp_tmp, 0, -1, Seq_strand_plus, 
267
362
                       Seq_code_iupacna);
268
363
      bsp->seq_data_type = Seq_code_iupacna;
269
364
   } else {
270
 
      spp = SeqPortNew(bsp, 0, -1, Seq_strand_unknown, 
 
365
      spp = SeqPortNew(bsp_tmp, 0, -1, Seq_strand_unknown, 
271
366
                       Seq_code_ncbieaa);
272
367
      bsp->seq_data_type = Seq_code_ncbieaa;
273
368
   }
280
375
   
281
376
   while (number < bsp->length) {
282
377
      retval = SeqPortRead(spp, buf, buf_length);
283
 
      if (retval <= 0)
 
378
      if (retval < 0)
 
379
         continue;
 
380
      if (retval == 0)
284
381
         break;
285
382
      BSWrite(bsp->seq_data, buf, retval);
286
383
      number += retval;
287
384
   }
288
385
   
289
386
   SeqPortFree(spp);
 
387
   if (believe_defline) {
 
388
      new_defline = StringSave(BioseqGetTitle(bsp_tmp));
 
389
   } else {
 
390
      title_length = StringLen(BioseqGetTitle(bsp_tmp));
 
391
      SeqIdWrite(bsp_tmp->id, tmp, PRINTID_FASTA_LONG, LOCAL_BUFLEN);
 
392
      id_length = StringLen(tmp);
 
393
      title_length += id_length;
 
394
      title_length +=3;
 
395
      new_defline = (CharPtr) MemNew(title_length*sizeof(Char));
 
396
      StringCpy(new_defline, tmp);
 
397
      *(new_defline+id_length) = ' ';
 
398
      StringCpy(new_defline+id_length+1, BioseqGetTitle(bsp_tmp));
 
399
      *(new_defline+title_length-1) = NULLB;
 
400
   }
 
401
 
 
402
   bsp->descr = ValNodeAddStr(NULL, Seq_descr_title, new_defline);
 
403
   bsp->id = ValNodeNew(NULL);
 
404
   oid = ObjectIdNew();
 
405
   oid->str = (char*) Malloc(LOCAL_BUFLEN+1);
 
406
   if (believe_defline) {
 
407
      SeqIdWrite(bsp_tmp->id, oid->str, PRINTID_FASTA_LONG, LOCAL_BUFLEN);
 
408
   } else {
 
409
      sprintf(oid->str, "%d", id_num);
 
410
   }
 
411
   bsp->id->choice = SEQID_LOCAL;
 
412
   bsp->id->data.ptrvalue = (Pointer) oid;
 
413
   SeqMgrDeleteFromBioseqIndex(bsp_tmp);
 
414
   BioseqUnlock(bsp_tmp);
290
415
   BioseqPack(bsp);
291
416
   ID1BioseqFetchDisable();
292
 
#endif   
293
417
   return bsp;
294
418
}
295
419
                
296
420
#define NUMARG (sizeof(myargs)/sizeof(myargs[0]))
297
421
 
 
422
typedef enum {
 
423
   ARG_QUERY = 0,
 
424
   ARG_SUBJECT,
 
425
   ARG_PROGRAM,
 
426
   ARG_GAPPED,
 
427
   ARG_OUT,
 
428
   ARG_DBSIZE,
 
429
   ARG_ASNOUT,
 
430
   ARG_GAPOPEN,
 
431
   ARG_GAPEXT,
 
432
   ARG_XDROP,
 
433
   ARG_WORDSIZE,
 
434
   ARG_MATRIX,
 
435
   ARG_MISMATCH,
 
436
   ARG_MATCH,
 
437
   ARG_FILTER,
 
438
   ARG_EVALUE,
 
439
   ARG_STRAND,
 
440
   ARG_HTML,
 
441
   ARG_USEMEGABLAST,
 
442
   ARG_SEARCHSP,
 
443
   ARG_INTRON,
 
444
   ARG_LOC1,
 
445
   ARG_LOC2,
 
446
   ARG_FORMAT,
 
447
   ARG_LCASE,
 
448
   ARG_ACCN,
 
449
   ARG_FORCE_OLD
 
450
} BlastArguments;
 
451
 
298
452
static Args myargs [] = {
299
453
  { "First sequence",            
300
 
        NULL, NULL, NULL, FALSE, 'i', ARG_FILE_IN, 0.0, 0, NULL}, /* 0 */
 
454
        NULL, NULL, NULL, FALSE, 'i', ARG_FILE_IN, 0.0, 0, NULL}, /* ARG_QUERY */
301
455
  { "Second sequence",
302
 
        NULL, NULL, NULL, FALSE, 'j', ARG_FILE_IN, 0.0, 0, NULL}, /* 1 */
 
456
        NULL, NULL, NULL, FALSE, 'j', ARG_FILE_IN, 0.0, 0, NULL}, /* ARG_SUBJECT */
303
457
  { "Program name: blastp, blastn, blastx, tblastn, tblastx. For blastx 1st sequence should be nucleotide, tblastn 2nd sequence nucleotide",
304
 
        NULL, NULL, NULL, FALSE, 'p', ARG_STRING, 0.0, 0, NULL},/* 2 */
 
458
        NULL, NULL, NULL, FALSE, 'p', ARG_STRING, 0.0, 0, NULL}, /* ARG_PROGRAM */
305
459
  { "Gapped",
306
 
        "T", NULL, NULL, FALSE, 'g', ARG_BOOLEAN, 0.0, 0, NULL},/* 3 */
 
460
        "T", NULL, NULL, FALSE, 'g', ARG_BOOLEAN, 0.0, 0, NULL}, /* ARG_GAPPED */
307
461
  { "alignment output file",
308
 
        "stdout", NULL, NULL, FALSE, 'o', ARG_FILE_OUT, 0.0, 0, NULL},/* 4 */
 
462
        "stdout", NULL, NULL, FALSE, 'o', ARG_FILE_OUT, 0.0, 0, NULL}, /* ARG_OUT */
309
463
  { "theor. db size (zero is real size)", 
310
 
        "0", NULL, NULL, FALSE, 'd', ARG_STRING, 0.0, 0, NULL},/* 5 */
 
464
        "0", NULL, NULL, FALSE, 'd', ARG_FLOAT, 0.0, 0, NULL}, /* ARG_DBSIZE */
311
465
  { "SeqAnnot output file",
312
 
        NULL, NULL, NULL, TRUE, 'a', ARG_FILE_OUT, 0.0, 0, NULL},/* 6 */
313
 
  { "Cost to open a gap (zero invokes default behavior)",
314
 
        "0", NULL, NULL, FALSE, 'G', ARG_INT, 0.0, 0, NULL},/* 7 */
315
 
  { "Cost to extend a gap (zero invokes default behavior)",
316
 
        "0", NULL, NULL, FALSE, 'E', ARG_INT, 0.0, 0, NULL},/* 8 */
317
 
  { "X dropoff value for gapped alignment (in bits) (zero invokes default behavior)",
318
 
        "0", NULL, NULL, FALSE, 'X', ARG_INT, 0.0, 0, NULL},/* 9 */
319
 
  { "Wordsize (zero invokes default behavior)",
320
 
        "0", NULL, NULL, FALSE, 'W', ARG_INT, 0.0, 0, NULL},/* 10 */
 
466
        NULL, NULL, NULL, TRUE, 'a', ARG_FILE_OUT, 0.0, 0, NULL}, /* ARG_ASNOUT */
 
467
  { "Cost to open a gap (-1 invokes default behavior; non-default values can result in unreliable statistics)",
 
468
        "-1", NULL, NULL, FALSE, 'G', ARG_INT, 0.0, 0, NULL}, /* ARG_GAPOPEN */
 
469
  { "Cost to extend a gap (-1 invokes default behavior; non-default values can result in unreliable statistics)",
 
470
        "-1", NULL, NULL, FALSE, 'E', ARG_INT, 0.0, 0, NULL}, /* ARG_GAPEXT */
 
471
  { "X dropoff value for gapped alignment (in bits) (zero invokes default "
 
472
    "behavior)\n      blastn 30, megablast 20, tblastx 0, all others 15",
 
473
        "0", NULL, NULL, FALSE, 'X', ARG_INT, 0.0, 0, NULL}, /* ARG_XDROP */
 
474
  { "Word size, default if zero (blastn 11, megablast 28, "
 
475
        "all others 3)",
 
476
        "0", NULL, NULL, FALSE, 'W', ARG_INT, 0.0, 0, NULL}, /* ARG_WORDSIZE */
321
477
  { "Matrix",
322
 
        "BLOSUM62", NULL, NULL, FALSE, 'M', ARG_STRING, 0.0, 0, NULL},/* 11 */
 
478
        "BLOSUM62", NULL, NULL, FALSE, 'M', ARG_STRING, 0.0, 0, NULL}, /* ARG_MATRIX */
323
479
  { "Penalty for a nucleotide mismatch (blastn only)",
324
 
        "-3", NULL, NULL, FALSE, 'q', ARG_INT, 0.0, 0, NULL},/* 12 */
 
480
        "-3", NULL, NULL, FALSE, 'q', ARG_INT, 0.0, 0, NULL}, /* ARG_MISMATCH */
325
481
  { "Reward for a nucleotide match (blastn only)",
326
 
        "1", NULL, NULL, FALSE, 'r', ARG_INT, 0.0, 0, NULL},/* 13 */
 
482
        "1", NULL, NULL, FALSE, 'r', ARG_INT, 0.0, 0, NULL}, /* ARG_MATCH */
327
483
  { "Filter query sequence (DUST with blastn, SEG with others)",
328
 
        "T", NULL, NULL, FALSE, 'F', ARG_STRING, 0.0, 0, NULL},/* 14 */
 
484
        "T", NULL, NULL, FALSE, 'F', ARG_STRING, 0.0, 0, NULL}, /* ARG_FILTER */
329
485
  { "Expectation value (E)",
330
 
        "10.0", NULL, NULL, FALSE, 'e', ARG_FLOAT, 0.0, 0, NULL},/* 15 */
 
486
        "10.0", NULL, NULL, FALSE, 'e', ARG_FLOAT, 0.0, 0, NULL}, /* ARG_EVALUE */
331
487
  { "Query strands to search against database (blastn only).  3 is both, 1 is top, 2 is bottom",
332
 
        "3", NULL, NULL, FALSE, 'S', ARG_INT, 0.0, 0, NULL},/* 16 */
 
488
        "3", NULL, NULL, FALSE, 'S', ARG_INT, 0.0, 0, NULL}, /* ARG_STRAND */
333
489
  { "Produce HTML output",
334
 
        "F", NULL, NULL, FALSE, 'T', ARG_BOOLEAN, 0.0, 0, NULL},/* 17 */
 
490
        "F", NULL, NULL, FALSE, 'T', ARG_BOOLEAN, 0.0, 0, NULL}, /* ARG_HTML */
335
491
  { "Use Mega Blast for search",
336
 
        "F", NULL, NULL, TRUE, 'm', ARG_BOOLEAN, 0.0, 0, NULL},/* 18 */
 
492
        "F", NULL, NULL, TRUE, 'm', ARG_BOOLEAN, 0.0, 0, NULL}, /* ARG_USEMEGABLAST */
337
493
  { "Effective length of the search space (use zero for the real size)",
338
 
        "0", NULL, NULL, FALSE, 'Y', ARG_FLOAT, 0.0, 0, NULL}, /* 19 */
339
 
  { "Input sequences in the form of accession.version",
340
 
        "F", NULL, NULL, FALSE, 'A', ARG_BOOLEAN, 0.0, 0, NULL}, /* 20 */
 
494
        "0", NULL, NULL, FALSE, 'Y', ARG_FLOAT, 0.0, 0, NULL}, /* ARG_SEARCHSP */
341
495
  { "Length of the largest intron allowed in tblastn for linking HSPs",
342
 
        "0", NULL, NULL, FALSE, 't', ARG_INT, 0.0, 0, NULL},/* 21 */
 
496
        "0", NULL, NULL, FALSE, 't', ARG_INT, 0.0, 0, NULL}, /* ARG_INTRON */
343
497
  { "Location on first sequence",
344
 
        NULL, NULL, NULL, TRUE, 'I', ARG_STRING, 0.0, 0, NULL},/* 22 */
 
498
        NULL, NULL, NULL, TRUE, 'I', ARG_STRING, 0.0, 0, NULL}, /* ARG_LOC1 */
345
499
  { "Location on second sequence",
346
 
        NULL, NULL, NULL, TRUE, 'J', ARG_STRING, 0.0, 0, NULL},/* 23 */
347
 
  { "Output format: 0 - traditional, 1 - tabulated", 
348
 
        "0", NULL, NULL, FALSE, 'D', ARG_INT, 0.0, 0, NULL}, /* 24 */
 
500
        NULL, NULL, NULL, TRUE, 'J', ARG_STRING, 0.0, 0, NULL}, /* ARG_LOC2 */
 
501
  { "Output format: 0 - traditional, 1 - tabular", 
 
502
        "0", NULL, NULL, FALSE, 'D', ARG_INT, 0.0, 0, NULL}, /* ARG_FORMAT */
349
503
  { "Use lower case filtering for the query sequence",
350
 
        "F", NULL, NULL, TRUE, 'U', ARG_BOOLEAN, 0.0, 0, NULL}/* 25 */
 
504
        "F", NULL, NULL, TRUE, 'U', ARG_BOOLEAN, 0.0, 0, NULL}, /* ARG_LCASE */
 
505
  { "Input sequences in the form of accession.version",
 
506
        "F", NULL, NULL, FALSE, 'A', ARG_BOOLEAN, 0.0, 0, NULL}, /* ARG_ACCN */
 
507
  {"Force use of old engine",
 
508
        "T", NULL, NULL, TRUE, 'V', ARG_BOOLEAN, 0.0, 0, NULL}  /* ARG_FORCE_OLD */
351
509
};
352
510
 
353
 
Int2 Main (void)
 
511
/**
 
512
 * Fetches sequences filling in either just the Bioseq's (if fetch from Entrez) or
 
513
 * both the BioseqPtr's and the SeqEntryPtr's (if read from FASTA).  The lcase_mask 
 
514
 * is also filled in with letters in query that were lower-case if myargs[ARG_LCASE].intvalue
 
515
 * is non-zero.
 
516
 *
 
517
 * @param seq1_is_na the query sequence is DNA if true [in]
 
518
 * @param seq2_is_na the subject sequence is DNA if true [in]
 
519
 * @param query_bsp pointer to query BioseqPtr, to be filled in [out]
 
520
 * @param subject_bsp pointer to subject BioseqPtr, to be filled in [out]
 
521
 * @param sep pointer to query SeqEntryPtr, to be filled in [out]
 
522
 * @param sep1 pointer to subject SeqEntryPtr, to be filled in [out]
 
523
 * @param lcase_mask pointer to lower-case masking data to be filled in [out]
 
524
 * @return TRUE on success, FALSE on failure.
 
525
*/
 
526
 
 
527
static Int4
 
528
BL2SEQ_GetSequences(Boolean seq1_is_na, Boolean seq2_is_na, BioseqPtr *query_bsp, BioseqPtr *subject_bsp, 
 
529
    SeqEntryPtr *sep, SeqEntryPtr *sep1, SeqLocPtr *lcase_mask, Boolean believe_query)
 
530
{
 
531
        Boolean entrez_lookup = (Boolean) myargs[ARG_ACCN].intvalue;
 
532
        char *query_accver = NULL, *subject_accver = NULL;  /* Used if entrez_lookup. */
 
533
        char *blast_inputfile = NULL, *blast_inputfile1 = NULL;  /* Used if FASTA read. */
 
534
        
 
535
        if (entrez_lookup) {
 
536
           query_accver = myargs [ARG_QUERY].strvalue;
 
537
           subject_accver = myargs [ARG_SUBJECT].strvalue;
 
538
        } else {
 
539
           blast_inputfile = myargs [ARG_QUERY].strvalue;
 
540
           blast_inputfile1 = myargs [ARG_SUBJECT].strvalue;
 
541
        }
 
542
 
 
543
        if (entrez_lookup) {
 
544
           *query_bsp = BioseqFromAccession(query_accver, 1, seq1_is_na, TRUE);
 
545
        } else {
 
546
           FILE *infp;
 
547
           if ((infp = FileOpen(blast_inputfile, "r")) == NULL)
 
548
           {
 
549
                ErrPostEx(SEV_FATAL, 1, 0, "blast: Unable to open input file %s\n", blast_inputfile);
 
550
                return FALSE;
 
551
           }
 
552
           if (myargs[ARG_LCASE].intvalue)
 
553
              *sep = FastaToSeqEntryForDb(infp, seq1_is_na, NULL, 
 
554
                                         believe_query, NULL, NULL, 
 
555
                                         lcase_mask);
 
556
           else
 
557
              *sep = FastaToSeqEntryEx(infp, seq1_is_na, NULL, believe_query);
 
558
 
 
559
           FileClose(infp);
 
560
 
 
561
           if (*sep != NULL) {
 
562
              *query_bsp = NULL;
 
563
              if (seq1_is_na)
 
564
                 SeqEntryExplore(*sep, query_bsp, FindNuc);
 
565
              else
 
566
                 SeqEntryExplore(*sep, query_bsp, FindProt);
 
567
 
 
568
           }
 
569
        }
 
570
        if (*query_bsp == NULL) {
 
571
           ErrPostEx(SEV_FATAL, 1, 0, "Unable to obtain bioseq\n");
 
572
           return FALSE;
 
573
        }
 
574
 
 
575
        if (entrez_lookup) {
 
576
           *subject_bsp = 
 
577
              BioseqFromAccession(subject_accver, 2, seq2_is_na, FALSE);
 
578
        } else {
 
579
           FILE *infp1;
 
580
           if ((infp1 = FileOpen(blast_inputfile1, "r")) == NULL)
 
581
           {
 
582
                ErrPostEx(SEV_FATAL, 1, 0, "blast: Unable to open input file %s\n", blast_inputfile1);
 
583
                return FALSE;
 
584
           }
 
585
           *sep1 = FastaToSeqEntryEx(infp1, seq2_is_na, NULL, FALSE);
 
586
 
 
587
           FileClose(infp1);
 
588
 
 
589
           if (*sep1 != NULL) {
 
590
              *subject_bsp = NULL;
 
591
              if (seq2_is_na)
 
592
                 SeqEntryExplore(*sep1, subject_bsp, FindNuc);
 
593
              else
 
594
                 SeqEntryExplore(*sep1, subject_bsp, FindProt);
 
595
              
 
596
           }
 
597
        }
 
598
        
 
599
        if (*subject_bsp == NULL) {
 
600
           ErrPostEx(SEV_FATAL, 1, 0, "Unable to obtain bioseq\n");
 
601
           return FALSE;
 
602
        }
 
603
 
 
604
        return TRUE;
 
605
}
 
606
 
 
607
/**
 
608
 * Creates SeqLoc's from the given BioseqPtr's.  if myargs for ARG_LOC1 or ARG_LOC2 are non-NULL, 
 
609
 * these are used in the creation of the SeqLoc's.
 
610
 *
 
611
 * @param bsp1 the query BioseqPtr [in]
 
612
 * @param bsp2 the subject BioseqPtr [in]
 
613
 * @param slp1 the query SeqLocPtr to be filled in [out]
 
614
 * @param slp2 the subject SeqLocPtr to be filled in [out]
 
615
 * @param strand_option specifies strand of slp1 [in]
 
616
 * @return TRUE on success, FALSE on failure.
 
617
*/
 
618
 
 
619
static Boolean
 
620
BL2SEQ_MakeSeqLoc(const BioseqPtr bsp1, const BioseqPtr bsp2, SeqLocPtr *slp1, SeqLocPtr *slp2, Uint1 strand_option)
 
621
{
 
622
       const char* k_delimiters = " ,;";
 
623
       CharPtr location;
 
624
       Int4 from, to;
 
625
 
 
626
       *slp1 = NULL;
 
627
       *slp2 = NULL;
 
628
 
 
629
       location = myargs[ARG_LOC1].strvalue;
 
630
       if (location) {
 
631
           from = atoi(StringTokMT(location, k_delimiters, &location)) - 1;
 
632
           to = atoi(location) - 1;
 
633
 
 
634
            from = MAX(from, 0);
 
635
            if (to < 0) 
 
636
                 to = bsp1->length - 1;
 
637
            to = MIN(to, bsp1->length - 1);
 
638
            if (from >= bsp1->length) {
 
639
                 ErrPostEx(SEV_FATAL, 1, 0, 
 
640
                           "Location outside of the first sequence range\n");
 
641
                 return FALSE;
 
642
            }
 
643
            *slp1 = SeqLocIntNew(from, to, strand_option,
 
644
                                 SeqIdFindBestAccession(bsp1->id));
 
645
        } else if (strand_option != Seq_strand_both) {
 
646
            *slp1 = SeqLocIntNew(0, bsp1->length-1, strand_option,
 
647
                                 SeqIdFindBestAccession(bsp1->id));
 
648
        } else
 
649
              ValNodeAddPointer(slp1, SEQLOC_WHOLE, SeqIdDup(SeqIdFindBestAccession(bsp1->id)));
 
650
 
 
651
        location = myargs[ARG_LOC2].strvalue;
 
652
        if (location) {
 
653
            from = atoi(StringTokMT(location, k_delimiters, &location)) - 1;
 
654
            to = atoi(location) - 1;
 
655
 
 
656
            from = MAX(from, 0);
 
657
            if (to < 0) 
 
658
                to = bsp2->length - 1;
 
659
            to = MIN(to, bsp2->length - 1);
 
660
            if (from >= bsp2->length) {
 
661
               ErrPostEx(SEV_FATAL, 1, 0, 
 
662
                           "Location outside of the second sequence range\n");
 
663
               return FALSE;
 
664
            }
 
665
            *slp2 = SeqLocIntNew(from, to, Seq_strand_plus, SeqIdFindBestAccession(bsp2->id));
 
666
         } else
 
667
            ValNodeAddPointer(slp2, SEQLOC_WHOLE, SeqIdDup(SeqIdFindBestAccession(bsp2->id)));
 
668
 
 
669
       return TRUE;
 
670
}
 
671
 
 
672
/**
 
673
 * Initializes and sets the summary options based upon the command-line args.
 
674
 *
 
675
 * @param ret_options object to be initialized and filled in [out]
 
676
 * @param program_number specifies blastn/blastp/blastx etc. [in]
 
677
 * @return TRUE on success, FALSE on failure.
 
678
 */
 
679
static Boolean
 
680
Bl2SEQ_SummaryOptionsSet(BLAST_SummaryOptions* *ret_options, EBlastProgramType program_number)
 
681
{
 
682
        BLAST_SummaryOptions* options;
 
683
 
 
684
        if (BLAST_SummaryOptionsInit(&options) != 0)
 
685
        {
 
686
                ErrPostEx(SEV_FATAL, 1, 0, "SummaryOptionsInit failed.");
 
687
                return FALSE;
 
688
        }
 
689
 
 
690
        options->hint = eNone;
 
691
 
 
692
        switch (program_number) {
 
693
            case eBlastTypeBlastn:
 
694
               options->program = eBlastn;
 
695
               break;
 
696
            case eBlastTypeBlastp:
 
697
               options->program = eBlastp;
 
698
               break;
 
699
            case eBlastTypeBlastx:
 
700
               options->program = eBlastx;
 
701
               break;
 
702
            case eBlastTypeTblastn:
 
703
               options->program = eTblastn;
 
704
               break;
 
705
            case eBlastTypeTblastx:
 
706
               options->program = eTblastx;
 
707
               break;
 
708
            default:  
 
709
               ErrPostEx(SEV_FATAL, 1, 0, "Program_number (%ld) not valid in Bl2SEQ_SummaryOptionsSet", (long) program_number);
 
710
               BLAST_SummaryOptionsFree(options);
 
711
               return FALSE;
 
712
        }
 
713
 
 
714
        options->cutoff_evalue = (Nlm_FloatHi) myargs [ARG_EVALUE].floatvalue;
 
715
 
 
716
        if (options->program == eBlastn)
 
717
        {
 
718
            options->nucleotide_mismatch = myargs[ARG_MISMATCH].intvalue;
 
719
            options->nucleotide_match = myargs[ARG_MATCH].intvalue;
 
720
            if (myargs[ARG_USEMEGABLAST].intvalue > 0)
 
721
                options->use_megablast = TRUE;
 
722
        }
 
723
 
 
724
        if (myargs[ARG_GAPOPEN].intvalue != -1)
 
725
              options->gap_open = myargs[ARG_GAPOPEN].intvalue;
 
726
 
 
727
        if (myargs[ARG_GAPEXT].intvalue != -1)
 
728
               options->gap_extend = myargs[ARG_GAPEXT].intvalue;
 
729
 
 
730
        options->strand = myargs[ARG_STRAND].intvalue;
 
731
 
 
732
        if (myargs[ARG_WORDSIZE].intvalue != 0)
 
733
               options->word_size = myargs[ARG_WORDSIZE].intvalue;
 
734
 
 
735
        if (myargs[ARG_MATRIX].strvalue)
 
736
               options->matrix = StringSave(myargs[ARG_MATRIX].strvalue);
 
737
 
 
738
        if (myargs[ARG_FILTER].strvalue)
 
739
               options->filter_string = StringSave(myargs[ARG_FILTER].strvalue);
 
740
 
 
741
        if (myargs[ARG_XDROP].intvalue != 0)
 
742
        {
 
743
               options->gap_x_dropoff = myargs[ARG_XDROP].intvalue;
 
744
        }
 
745
 
 
746
        *ret_options = options;
 
747
 
 
748
        return TRUE;
 
749
}
 
750
 
 
751
Int2 Main_new(void)
 
752
 
 
753
{
 
754
        BioseqPtr query_bsp=NULL, subject_bsp=NULL;
 
755
        BioseqPtr bsp1=NULL, bsp2=NULL;
 
756
        BioseqPtr fake_bsp=NULL, fake_subject_bsp=NULL;
 
757
        BlastFormattingOptions* format_options;
 
758
        BlastMaskLoc* blast_mask_head = NULL;
 
759
        BLAST_SummaryOptions* options=NULL;
 
760
        Blast_SummaryReturn* extra_returns=NULL;
 
761
        Boolean believe_query= FALSE;
 
762
        Boolean seq1_is_na, seq2_is_na;  /* seq1/2 is DNA if TRUE. */
 
763
        Boolean seqannot_output;   /* SeqAlign will be output. */
 
764
        Boolean entrez_lookup;     /* QUery/subject fetched from Entrez. */
 
765
        Boolean mask_at_hash=FALSE;  /* masking only on lookup table if TRUE. */
 
766
        DbtagPtr        dbtagptr;
 
767
        EBlastProgramType program_number;
 
768
        Int2 status; /* return value */
 
769
        Int4 align_view=0; /* Used for formatting */
 
770
        SeqAlignPtr seqalign=NULL;
 
771
        SeqEntryPtr sep=NULL, sep1=NULL;
 
772
        SeqLocPtr slp1, slp2;   /* Used for actual search. */
 
773
        SeqLocPtr filter_loc=NULL;  /* Location of regions filtered (returned by engine) */
 
774
        SeqLocPtr filter_loc_head=NULL;  /* Location of regions filtered (returned by engine) */
 
775
        SeqLocPtr lcase_mask=NULL;    /* For lower-case masking info from query FASTA. */
 
776
        Uint1 strand_option = 0; /* FIXME */
 
777
        
 
778
        strand_option = (Uint1) myargs[ARG_STRAND].intvalue;
 
779
 
 
780
        entrez_lookup = (Boolean) myargs[ARG_ACCN].intvalue;
 
781
        seqannot_output = (myargs[ARG_ASNOUT].strvalue != NULL);
 
782
        believe_query = (seqannot_output || entrez_lookup); 
 
783
        if (myargs[ARG_FORMAT].intvalue != 0)
 
784
           align_view = 9;  /* Means tabular output. */
 
785
 
 
786
        BlastProgram2Number(myargs[ARG_PROGRAM].strvalue, &program_number);
 
787
 
 
788
        seq1_is_na = (program_number == eBlastTypeBlastn ||
 
789
                  program_number == eBlastTypeBlastx ||
 
790
                  program_number == eBlastTypeRpsTblastn ||
 
791
                  program_number == eBlastTypeTblastx);
 
792
 
 
793
        seq2_is_na = (program_number == eBlastTypeBlastn ||
 
794
               program_number == eBlastTypeTblastn ||
 
795
               program_number == eBlastTypeTblastx);
 
796
 
 
797
        if (BL2SEQ_GetSequences(seq1_is_na, seq2_is_na, &query_bsp, &subject_bsp, &sep, &sep1,
 
798
               &lcase_mask, believe_query) == FALSE)
 
799
        {
 
800
                ErrPostEx(SEV_FATAL, 1, 0, "blast: Unable to get sequences");
 
801
                return (1);
 
802
        }
 
803
 
 
804
        if (!believe_query)
 
805
           fake_bsp = BlastMakeFakeBioseq(query_bsp, NULL);
 
806
 
 
807
        fake_subject_bsp = BioseqNew();
 
808
        fake_subject_bsp->descr = subject_bsp->descr;
 
809
        fake_subject_bsp->repr = subject_bsp->repr;
 
810
        fake_subject_bsp->mol = subject_bsp->mol;
 
811
        fake_subject_bsp->length = subject_bsp->length;
 
812
        fake_subject_bsp->seq_data = subject_bsp->seq_data;
 
813
        fake_subject_bsp->seq_data_type = subject_bsp->seq_data_type;
 
814
        dbtagptr = DbtagNew();
 
815
        dbtagptr->db = StringSave("BL_ORD_ID");
 
816
        dbtagptr->tag = ObjectIdNew();
 
817
        dbtagptr->tag->str = StringSave(BioseqGetTitle(subject_bsp));
 
818
        ValNodeAddPointer(&fake_subject_bsp->id, SEQID_GENERAL, dbtagptr);
 
819
 
 
820
        if (believe_query)
 
821
           bsp1 = query_bsp;
 
822
        else 
 
823
           bsp1 = fake_bsp;
 
824
 
 
825
        bsp2 = fake_subject_bsp;
 
826
 
 
827
        if (BL2SEQ_MakeSeqLoc(bsp1, bsp2, &slp1, &slp2, strand_option) == FALSE)
 
828
                return 1;
 
829
 
 
830
        if (Bl2SEQ_SummaryOptionsSet(&options, program_number) == FALSE)
 
831
                return 1;
 
832
 
 
833
        status = BLAST_TwoSeqLocSets(options, slp1, slp2, lcase_mask, &seqalign, &filter_loc_head, &mask_at_hash, &extra_returns);
 
834
        if (status != 0)
 
835
        {
 
836
                ErrPostEx(SEV_FATAL, 1, 0, "BLAST_TwoSeqLocSets failed");
 
837
                return status;
 
838
        }
 
839
 
 
840
        if (myargs[ARG_ASNOUT].strvalue) {
 
841
            AsnIoPtr asnout =
 
842
               AsnIoOpen(myargs[ARG_ASNOUT].strvalue, (char*)"w");
 
843
            GenericSeqAlignSetAsnWrite(seqalign, asnout);
 
844
            asnout = AsnIoClose(asnout);
 
845
        }
 
846
 
 
847
        if ((status = BlastFormattingOptionsNew(program_number, myargs[ARG_OUT].strvalue, 0, 1,
 
848
                       align_view, &format_options)) != 0)
 
849
           return status;
 
850
 
 
851
        if (myargs[ARG_HTML].intvalue) {
 
852
           format_options->html = TRUE;
 
853
           format_options->align_options += TXALIGN_HTML;
 
854
           format_options->print_options += TXALIGN_HTML;
 
855
        }
 
856
 
 
857
        if (!mask_at_hash)
 
858
        {
 
859
            Int4 total=0;
 
860
            Int4 i=0;
 
861
            filter_loc = filter_loc_head;
 
862
            while (filter_loc)
 
863
            {
 
864
               total++;
 
865
               filter_loc = filter_loc->next;
 
866
            }
 
867
            filter_loc = filter_loc_head;
 
868
            blast_mask_head = BlastMaskLocNew(total);
 
869
            while (filter_loc)
 
870
            {
 
871
               blast_mask_head->seqloc_array[i] = BlastSeqLocFromSeqLoc(filter_loc->data.ptrvalue);
 
872
               filter_loc = filter_loc->next;
 
873
               i++;
 
874
            }
 
875
        }
 
876
        else
 
877
             blast_mask_head = NULL;
 
878
 
 
879
        /* Format the results */
 
880
        status = BLAST_FormatResults(seqalign, NULL, myargs[ARG_PROGRAM].strvalue, 1, slp1,
 
881
               blast_mask_head, format_options, FALSE, NULL, NULL);
 
882
        
 
883
        status = Blast_PrintOutputFooter(program_number, format_options, NULL, extra_returns);
 
884
 
 
885
 
 
886
        blast_mask_head = BlastMaskLocFree(blast_mask_head);
 
887
        format_options = BlastFormattingOptionsFree(format_options);
 
888
        extra_returns = Blast_SummaryReturnFree(extra_returns);
 
889
 
 
890
        if (entrez_lookup) {
 
891
           BioseqFree(query_bsp);
 
892
           BioseqFree(subject_bsp);
 
893
        } else {
 
894
           SeqEntryFree(sep);
 
895
           SeqEntryFree(sep1);
 
896
        }
 
897
 
 
898
        options = BLAST_SummaryOptionsFree(options);
 
899
        seqalign = SeqAlignFree(seqalign);
 
900
        slp1 = SeqLocSetFree(slp1);
 
901
        slp2 = SeqLocSetFree(slp2);
 
902
        filter_loc = filter_loc_head;
 
903
        while (filter_loc)
 
904
        {
 
905
            SeqLocSetFree((SeqLocPtr) filter_loc->data.ptrvalue);
 
906
            filter_loc->data.ptrvalue;
 
907
            filter_loc = filter_loc->next;
 
908
        }
 
909
        ValNodeFree(filter_loc_head);
 
910
 
 
911
        fake_bsp = BlastDeleteFakeBioseq(fake_bsp);
 
912
 
 
913
        return 0;
 
914
 
 
915
}
 
916
 
 
917
Int2 Main_old (void)
354
918
 
355
919
{
356
920
        
357
921
        AsnIoPtr aip;
358
 
        BioseqPtr fake_bsp, fake_subject_bsp, query_bsp, subject_bsp;
 
922
        BioseqPtr fake_bsp = NULL, fake_subject_bsp = NULL, query_bsp = NULL, 
 
923
                  subject_bsp = NULL;
359
924
        BioseqPtr bsp1, bsp2;
360
925
        BLAST_KarlinBlkPtr ka_params=NULL, ka_params_gap=NULL;
361
 
        BLAST_OptionsBlkPtr options;
 
926
        BLAST_OptionsBlkPtr options=NULL;
362
927
        Boolean seq1_is_na, seq2_is_na;
363
 
        CharPtr ret_buffer=NULL, params_buffer=NULL;
 
928
        CharPtr params_buffer=NULL;
364
929
        DbtagPtr        dbtagptr;
365
930
        Uint1 align_type;
366
931
        Uint4 align_options;
367
932
        SeqAlignPtr  seqalign;
368
933
        SeqAnnotPtr seqannot;
369
934
        SeqEntryPtr sep = NULL, sep1 = NULL;
370
 
        TxDfDbInfoPtr dbinfo=NULL, dbinfo_head;
371
 
        CharPtr blast_inputfile, blast_inputfile1, program_name, blast_outputfile;
372
 
        FILE *infp, *infp1, *outfp;
 
935
        CharPtr program_name, blast_outputfile;
 
936
        FILE *outfp;
373
937
        ValNodePtr  mask_loc, mask_loc_start, vnp, other_returns=NULL, error_returns=NULL;
374
938
        BLAST_MatrixPtr matrix;
375
939
        Int4Ptr PNTR txmatrix;
376
940
        int (LIBCALLBACK *handle_results)PROTO((VoidPtr search)) = NULL;
377
941
        Boolean entrez_lookup = FALSE;
378
 
        CharPtr query_accver = NULL, subject_accver = NULL;
379
 
        const char *dummystr;
380
 
 
381
 
        if (! GetArgs ("bl2seq", NUMARG, myargs))
382
 
        {
383
 
                return (1);
384
 
        }
385
 
 
386
 
        UseLocalAsnloadDataAndErrMsg ();
387
 
 
388
 
        if (! SeqEntryLoad())
389
 
                return 1;
390
 
 
391
 
        ErrSetMessageLevel(SEV_WARNING);
392
 
        entrez_lookup = (Boolean) myargs[20].intvalue;
393
 
#ifndef NCBI_ENTREZ_CLIENT
394
 
        if (entrez_lookup) {
395
 
           ErrPostEx(SEV_WARNING, 0, 0, "Entrez client interface unavailable, -A option cannot be used");
396
 
           return 1;
397
 
        }
398
 
#endif
399
 
        if (entrez_lookup) {
400
 
           query_accver = myargs [0].strvalue;
401
 
           subject_accver = myargs [1].strvalue;
402
 
        } else {
403
 
           blast_inputfile = myargs [0].strvalue;
404
 
           blast_inputfile1 = myargs [1].strvalue;
405
 
        }
406
 
        blast_outputfile = myargs [4].strvalue;
407
 
 
408
 
        program_name = StringSave(myargs[2].strvalue);
 
942
        Boolean html, seqannot_output, believe_query;
 
943
        Uint1 tabular_output;
 
944
        Boolean gapped_calculation;
 
945
 
 
946
        entrez_lookup = (Boolean) myargs[ARG_ACCN].intvalue;
 
947
        html = (Boolean) myargs[ARG_HTML].intvalue;
 
948
        seqannot_output = (myargs[ARG_ASNOUT].strvalue != NULL);
 
949
 
 
950
        blast_outputfile = myargs [ARG_OUT].strvalue;
 
951
 
 
952
        program_name = StringSave(myargs[ARG_PROGRAM].strvalue);
409
953
        if (StringCmp(program_name, "blastn") && 
410
954
            StringCmp(program_name, "blastp") && 
411
955
            StringCmp(program_name, "blastx") && 
412
956
            StringCmp(program_name, "tblastn") && 
413
957
            StringCmp(program_name, "tblastx")) {
414
 
                ErrPostEx(SEV_FATAL, 0, 0, "Program name must be blastn, blastp, blastx, tblastn or tblastx\n");
 
958
                ErrPostEx(SEV_FATAL, 1, 0, "Program name must be blastn, blastp, blastx, tblastn or tblastx\n");
415
959
                return (1);
416
960
        }
417
961
           
418
 
 
419
962
        align_type = BlastGetTypes(program_name, &seq1_is_na, &seq2_is_na);
420
963
 
421
 
        if (!entrez_lookup && (infp = FileOpen(blast_inputfile, "r")) == NULL)
422
 
        {
423
 
                ErrPostEx(SEV_FATAL, 0, 0, "blast: Unable to open input file %s\n", blast_inputfile);
424
 
                return (1);
425
 
        }
426
 
 
427
 
        if (!entrez_lookup && (infp1 = FileOpen(blast_inputfile1, "r")) == NULL)
428
 
        {
429
 
                ErrPostEx(SEV_FATAL, 0, 0, "blast: Unable to open input file %s\n", blast_inputfile1);
430
 
                return (1);
431
 
        }
432
 
 
433
964
        if ((outfp = FileOpen(blast_outputfile, "w")) == NULL)
434
965
        {
435
 
                ErrPostEx(SEV_FATAL, 0, 0, "blast: Unable to open output file %s\n", blast_outputfile);
 
966
                ErrPostEx(SEV_FATAL, 1, 0, "blast: Unable to open output file %s\n", blast_outputfile);
436
967
                return (1);
437
968
        }
438
969
 
439
970
        global_fp = outfp;
440
 
        options = BLASTOptionNew(program_name, (Boolean) myargs[3].intvalue);
441
 
        options->is_megablast_search = (Boolean) myargs[18].intvalue;
442
 
 
443
 
        if (entrez_lookup) {
444
 
           query_bsp = BioseqFromAccession(query_accver, 1, seq1_is_na);
445
 
        } else {
446
 
           if (myargs[25].intvalue)
447
 
              sep = FastaToSeqEntryForDb(infp, seq1_is_na, NULL, FALSE, 
448
 
                                         NULL, NULL, 
449
 
                                         &options->query_lcase_mask);
450
 
           else
451
 
              sep = FastaToSeqEntry(infp, seq1_is_na);
452
 
 
453
 
           if (sep != NULL) {
454
 
              query_bsp = NULL;
455
 
              if (seq1_is_na)
456
 
                 SeqEntryExplore(sep, &query_bsp, FindNuc);
457
 
              else
458
 
                 SeqEntryExplore(sep, &query_bsp, FindProt);
459
 
 
460
 
           }
461
 
        }
462
 
        if (query_bsp == NULL) {
463
 
           ErrPostEx(SEV_FATAL, 0, 0, "Unable to obtain bioseq\n");
464
 
           return 2;
465
 
        }
466
 
 
467
 
        if (myargs[24].intvalue == 0)
 
971
        gapped_calculation = (Boolean) myargs[ARG_GAPPED].intvalue;
 
972
        believe_query = (seqannot_output || entrez_lookup); 
 
973
 
 
974
        options = BLASTOptionNewEx(program_name, gapped_calculation,
 
975
                                   (Boolean) myargs[ARG_USEMEGABLAST].intvalue);
 
976
 
 
977
        if (BL2SEQ_GetSequences(seq1_is_na, seq2_is_na, &query_bsp, &subject_bsp, &sep, &sep1, 
 
978
               &(options->query_lcase_mask), believe_query) == FALSE)
 
979
        {
 
980
                ErrPostEx(SEV_FATAL, 1, 0, "blast: Unable to get sequences");
 
981
                return (1);
 
982
        }
 
983
 
 
984
        if (!believe_query)
468
985
           fake_bsp = BlastMakeFakeBioseq(query_bsp, NULL);
469
 
        if (entrez_lookup) {
470
 
           subject_bsp = BioseqFromAccession(subject_accver, 2, seq2_is_na);
471
 
        } else {
472
 
           if (myargs[6].strvalue != NULL || myargs[17].intvalue != 0
473
 
               || myargs[24].intvalue != 0)
474
 
              sep1 = FastaToSeqEntry(infp1, seq2_is_na);
475
 
           else
476
 
              sep1 = FastaToSeqEntryEx(infp1, seq2_is_na, NULL, FALSE);
477
 
        
478
 
           if (sep1 != NULL) {
479
 
              subject_bsp = NULL;
480
 
              if (seq2_is_na)
481
 
                 SeqEntryExplore(sep1, &subject_bsp, FindNuc);
482
 
              else
483
 
                 SeqEntryExplore(sep1, &subject_bsp, FindProt);
484
 
              
485
 
           }
486
 
        }
487
 
        
488
 
        if (subject_bsp == NULL) {
489
 
           ErrPostEx(SEV_FATAL, 0, 0, "Unable to obtain bioseq\n");
490
 
           return 2;
491
 
        }
492
 
 
493
 
        if (myargs[6].strvalue == NULL && myargs[17].intvalue == 0 &&
494
 
            myargs[24].intvalue == 0) {
495
 
           if (!entrez_lookup) {
496
 
              fake_subject_bsp = BioseqNew();
497
 
              fake_subject_bsp->descr = subject_bsp->descr;
498
 
              fake_subject_bsp->repr = subject_bsp->repr;
499
 
              fake_subject_bsp->mol = subject_bsp->mol;
500
 
              fake_subject_bsp->length = subject_bsp->length;
501
 
              fake_subject_bsp->seq_data = subject_bsp->seq_data;
502
 
              fake_subject_bsp->seq_data_type = subject_bsp->seq_data_type;
503
 
              dbtagptr = DbtagNew();
504
 
              dbtagptr->db = StringSave("BL_ORD_ID");
505
 
              dbtagptr->tag = ObjectIdNew();
506
 
              dbtagptr->tag->id = 0;
507
 
              ValNodeAddPointer(&fake_subject_bsp->id, SEQID_GENERAL, dbtagptr);
508
 
           } else {
509
 
              Char tmp[256];
510
 
              SeqIdWrite(subject_bsp->id, tmp, PRINTID_FASTA_LONG, 255);
511
 
              fake_subject_bsp = BlastMakeFakeBioseq(subject_bsp, tmp);
512
 
           }
513
 
        }
514
 
        if (options->is_megablast_search) {
515
 
           options->gap_open = options->gap_extend = 0;
516
 
           options->wordsize = 28;
517
 
           options->block_width = 0;
518
 
        }
519
 
 
520
 
        if (myargs[19].floatvalue)
521
 
                options->searchsp_eff = (Nlm_FloatHi) myargs[19].floatvalue;
522
 
 
523
 
 
524
 
        options->filter_string = StringSave(myargs[14].strvalue);
525
 
        options->expect_value  = (Nlm_FloatHi) myargs [15].floatvalue;
 
986
 
 
987
        fake_subject_bsp = BioseqNew();
 
988
        fake_subject_bsp->descr = subject_bsp->descr;
 
989
        fake_subject_bsp->repr = subject_bsp->repr;
 
990
        fake_subject_bsp->mol = subject_bsp->mol;
 
991
        fake_subject_bsp->length = subject_bsp->length;
 
992
        fake_subject_bsp->seq_data = subject_bsp->seq_data;
 
993
        fake_subject_bsp->seq_data_type = subject_bsp->seq_data_type;
 
994
        dbtagptr = DbtagNew();
 
995
        dbtagptr->db = StringSave("BL_ORD_ID");
 
996
        dbtagptr->tag = ObjectIdNew();
 
997
        dbtagptr->tag->str = StringSave(BioseqGetTitle(subject_bsp));
 
998
        ValNodeAddPointer(&fake_subject_bsp->id, SEQID_GENERAL, dbtagptr);
 
999
 
 
1000
        tabular_output = (Uint1) myargs[ARG_FORMAT].intvalue; 
 
1001
 
 
1002
 
 
1003
        if (myargs[ARG_SEARCHSP].floatvalue)
 
1004
           options->searchsp_eff = (Nlm_FloatHi) myargs[ARG_SEARCHSP].floatvalue;
 
1005
 
 
1006
 
 
1007
        options->filter_string = StringSave(myargs[ARG_FILTER].strvalue);
 
1008
        options->expect_value  = (Nlm_FloatHi) myargs [ARG_EVALUE].floatvalue;
526
1009
 
527
1010
        if (StringICmp("blastn", program_name) == 0)
528
1011
        {
529
 
                options->penalty = myargs[12].intvalue;
530
 
                options->reward = myargs[13].intvalue;
 
1012
                options->penalty = myargs[ARG_MISMATCH].intvalue;
 
1013
                options->reward = myargs[ARG_MATCH].intvalue;
531
1014
        }
532
1015
 
533
 
        options->db_length = StringToInt8(myargs[5].strvalue, &dummystr);
 
1016
        options->db_length = (Int8) myargs[ARG_DBSIZE].floatvalue;
534
1017
 
535
1018
        options->discontinuous = FALSE;
536
1019
 
537
 
        if (myargs[7].intvalue != 0)
538
 
              options->gap_open = myargs[7].intvalue;
539
 
        if (myargs[8].intvalue != 0)
540
 
               options->gap_extend = myargs[8].intvalue;
541
 
        if (myargs[9].intvalue != 0)
 
1020
        if (myargs[ARG_XDROP].intvalue != 0)
542
1021
        {
543
 
               options->gap_x_dropoff = myargs[9].intvalue;
 
1022
               options->gap_x_dropoff = myargs[ARG_XDROP].intvalue;
544
1023
        }
545
 
        if (myargs[10].intvalue != 0)
546
 
               options->wordsize = (Int2) myargs[10].intvalue;
 
1024
        if (myargs[ARG_WORDSIZE].intvalue != 0)
 
1025
               options->wordsize = (Int2) myargs[ARG_WORDSIZE].intvalue;
547
1026
 
548
1027
        if (options->is_megablast_search) {
549
 
           options->cutoff_s2 = options->wordsize;
550
 
           options->wordsize += 4;
551
 
           options->cutoff_s = options->wordsize;
 
1028
           options->cutoff_s2 = options->wordsize*options->reward;
552
1029
        }
553
 
        MemFree(options->matrix);
554
 
        options->matrix = myargs[11].strvalue;
555
 
 
556
 
        options->strand_option = myargs[16].intvalue;
557
 
 
558
 
        /* Input longest intron length is in nucleotide scale; in the lower level
559
 
           code it will be used in protein scale */
560
 
        if (myargs[21].intvalue > 0) 
561
 
           options->longest_intron = MAX(myargs[21].intvalue, MAX_INTRON_LENGTH);
562
 
        if (myargs[24].intvalue == 1) {
563
 
           options->output = (VoidPtr) outfp;
564
 
           if (options->is_megablast_search)
565
 
              handle_results = MegaBlastPrintAlignInfo;
566
 
           else
567
 
              handle_results = BlastPrintAlignInfo;
568
 
        } else 
569
 
           handle_results = NULL;
570
 
 
571
 
        if (myargs[6].strvalue || myargs[17].intvalue || 
572
 
            handle_results) {
 
1030
        options->matrix = MemFree(options->matrix);
 
1031
        BLASTOptionSetGapParams(options, myargs[ARG_MATRIX].strvalue, 0, 0); 
 
1032
 
 
1033
        if (myargs[ARG_GAPOPEN].intvalue != -1)
 
1034
              options->gap_open = myargs[ARG_GAPOPEN].intvalue;
 
1035
        if (myargs[ARG_GAPEXT].intvalue != -1)
 
1036
               options->gap_extend = myargs[ARG_GAPEXT].intvalue;
 
1037
 
 
1038
        options->strand_option = myargs[ARG_STRAND].intvalue;
 
1039
 
 
1040
        /* Input longest intron length is in nucleotide scale; in the lower 
 
1041
           level code it will be used in protein scale */
 
1042
        if (myargs[ARG_INTRON].intvalue > 0) 
 
1043
           options->longest_intron = 
 
1044
              MAX(myargs[ARG_INTRON].intvalue, MAX_INTRON_LENGTH);
 
1045
 
 
1046
        if (believe_query) {
573
1047
           bsp1 = query_bsp;
574
 
           bsp2 = subject_bsp;
575
1048
        } else {
576
1049
           bsp1 = fake_bsp;
577
 
           bsp2 = fake_subject_bsp;
578
1050
        }
579
1051
 
580
 
        if (!myargs[22].strvalue && !myargs[23].strvalue) {
581
 
              seqalign = BlastTwoSequencesWithCallback(bsp1, bsp2, program_name, options, &other_returns, &error_returns, handle_results);
 
1052
        bsp2 = fake_subject_bsp;
 
1053
 
 
1054
        if (!myargs[ARG_LOC1].strvalue && !myargs[ARG_LOC2].strvalue) {
 
1055
           seqalign = BlastTwoSequencesWithCallback(bsp1, bsp2, program_name, 
 
1056
              options, &other_returns, &error_returns, handle_results);
582
1057
        } else {
583
 
           /* Location(s) are provided */
584
 
           CharPtr delimiters = " ,;";
585
 
           CharPtr location;
586
 
           Int4 from, to;
587
 
           SeqLocPtr slp1 = NULL, slp2 = NULL;
588
 
           location = myargs[22].strvalue;
589
 
           if (location) {
590
 
              from = atoi(StringTokMT(location, delimiters, &location)) - 1;
591
 
              to = atoi(location) - 1;
592
 
 
593
 
              from = MAX(from, 0);
594
 
              if (to < 0) 
595
 
                 to = bsp1->length - 1;
596
 
              to = MIN(to, bsp1->length - 1);
597
 
              if (from >= bsp1->length) {
598
 
                 ErrPostEx(SEV_FATAL, 0, 0, 
599
 
                           "Location outside of the first sequence range\n");
600
 
                 return 3;
601
 
              }
602
 
              slp1 = SeqLocIntNew(from, to, options->strand_option,
603
 
                                  SeqIdFindBestAccession(bsp1->id));
604
 
           } else
605
 
              ValNodeAddPointer(&slp1, SEQLOC_WHOLE, SeqIdDup(SeqIdFindBestAccession(bsp1->id)));
606
 
 
607
 
           location = myargs[23].strvalue;
608
 
           if (location) {
609
 
              from = atoi(StringTokMT(location, delimiters, &location)) - 1;
610
 
              to = atoi(location) - 1;
611
 
 
612
 
              from = MAX(from, 0);
613
 
              if (to < 0) 
614
 
                 to = bsp2->length - 1;
615
 
              to = MIN(to, bsp2->length - 1);
616
 
              if (from >= bsp2->length) {
617
 
                 ErrPostEx(SEV_FATAL, 0, 0, 
618
 
                           "Location outside of the second sequence range\n");
619
 
                 return 3;
620
 
              }
621
 
              slp2 = SeqLocIntNew(from, to, Seq_strand_plus, SeqIdFindBestAccession(bsp2->id));
622
 
           } else
623
 
              ValNodeAddPointer(&slp2, SEQLOC_WHOLE, SeqIdDup(SeqIdFindBestAccession(bsp2->id)));
624
 
           
625
 
           seqalign = BlastTwoSequencesByLocWithCallback(slp1, slp2, program_name, options, &other_returns, &error_returns, handle_results);
 
1058
            SeqLocPtr slp1=NULL, slp2=NULL;
 
1059
            if (BL2SEQ_MakeSeqLoc(bsp1, bsp2, &slp1, &slp2, options->strand_option) == FALSE)
 
1060
                return 1;
 
1061
           seqalign = BlastTwoSequencesByLocWithCallback(slp1, slp2, program_name, options, &other_returns, &error_returns, handle_results, NULL);
626
1062
           SeqLocFree(slp1);
627
1063
           SeqLocFree(slp2);
628
1064
        }
634
1070
           }
635
1071
           ValNodeFree(error_returns);
636
1072
        }
637
 
        
638
 
        if (!handle_results) {
639
 
           dbinfo = NULL;
640
 
           ka_params = NULL;
641
 
           ka_params_gap = NULL;
642
 
           params_buffer = NULL;
643
 
           mask_loc = NULL;
644
 
           matrix = NULL;
645
 
           txmatrix = NULL;
646
 
           for (vnp=other_returns; vnp; vnp = vnp->next) {
647
 
              switch (vnp->choice) {
648
 
              case TXDBINFO:
649
 
                 dbinfo = vnp->data.ptrvalue;
650
 
                 break;
651
 
              case TXKABLK_NOGAP:
652
 
                 ka_params = vnp->data.ptrvalue;
653
 
                 break;
654
 
              case TXKABLK_GAP:
655
 
                 ka_params_gap = vnp->data.ptrvalue;
656
 
                 break;
657
 
              case TXPARAMETERS:
658
 
                 params_buffer = vnp->data.ptrvalue;
659
 
                 break;
660
 
              case TXMATRIX:
661
 
                 matrix = vnp->data.ptrvalue;
662
 
                 if (matrix)
663
 
                    txmatrix = BlastMatrixToTxMatrix(matrix);
664
 
                 break;
665
 
              case SEQLOC_MASKING_NOTSET:
666
 
              case SEQLOC_MASKING_PLUS1:
667
 
              case SEQLOC_MASKING_PLUS2:
668
 
              case SEQLOC_MASKING_PLUS3:
669
 
              case SEQLOC_MASKING_MINUS1:
670
 
              case SEQLOC_MASKING_MINUS2:
671
 
              case SEQLOC_MASKING_MINUS3:
672
 
                 ValNodeAddPointer(&mask_loc, vnp->choice, vnp->data.ptrvalue);
673
 
                 break;
674
 
              default:
675
 
                 break;
676
 
              }
677
 
           }    
678
 
 
 
1073
       
 
1074
        ka_params = NULL;
 
1075
        ka_params_gap = NULL;
 
1076
        params_buffer = NULL;
 
1077
        mask_loc = NULL;
 
1078
        matrix = NULL;
 
1079
        txmatrix = NULL;
 
1080
        for (vnp=other_returns; vnp; vnp = vnp->next) {
 
1081
           switch (vnp->choice) {
 
1082
           case TXKABLK_NOGAP:
 
1083
              ka_params = vnp->data.ptrvalue;
 
1084
              break;
 
1085
           case TXKABLK_GAP:
 
1086
              ka_params_gap = vnp->data.ptrvalue;
 
1087
              break;
 
1088
           case TXPARAMETERS:
 
1089
              params_buffer = vnp->data.ptrvalue;
 
1090
              break;
 
1091
           case TXMATRIX:
 
1092
              matrix = vnp->data.ptrvalue;
 
1093
              if (matrix && !tabular_output)
 
1094
                 txmatrix = BlastMatrixToTxMatrix(matrix);
 
1095
              break;
 
1096
           case SEQLOC_MASKING_NOTSET:
 
1097
           case SEQLOC_MASKING_PLUS1:
 
1098
           case SEQLOC_MASKING_PLUS2:
 
1099
           case SEQLOC_MASKING_PLUS3:
 
1100
           case SEQLOC_MASKING_MINUS1:
 
1101
           case SEQLOC_MASKING_MINUS2:
 
1102
           case SEQLOC_MASKING_MINUS3:
 
1103
              ValNodeAddPointer(&mask_loc, vnp->choice, vnp->data.ptrvalue);
 
1104
              break;
 
1105
           default:
 
1106
              break;
 
1107
           }
 
1108
        }       
 
1109
        if (!tabular_output || seqannot_output) {
679
1110
           align_options = 0;
680
1111
           align_options += TXALIGN_MATRIX_VAL;
681
1112
           align_options += TXALIGN_SHOW_QS;
685
1116
              align_options += TXALIGN_BLASTX_SPECIAL;
686
1117
           }
687
1118
           
688
 
           if (myargs[17].intvalue)
 
1119
           if (html)
689
1120
              align_options += TXALIGN_HTML;
690
 
           
691
 
           if (entrez_lookup)
692
 
              AcknowledgeBlastQuery(query_bsp, 70, outfp, TRUE, myargs[17].intvalue);
693
 
           else
694
 
              AcknowledgeBlastQuery(query_bsp, 70, outfp, FALSE, myargs[17].intvalue);
695
 
           
 
1121
 
696
1122
           seqannot = SeqAnnotNew();
697
1123
           seqannot->type = 2;
698
1124
           AddAlignInfoToSeqAnnot(seqannot, align_type);
699
1125
           seqannot->data = seqalign;
700
 
           ShowTextAlignFromAnnot(seqannot, 60, outfp, NULL, NULL, align_options, txmatrix, mask_loc, FormatScoreFunc);
701
 
           
702
1126
           aip = NULL;
703
 
           if (myargs[6].strvalue)
704
 
              aip = AsnIoOpen (myargs[6].strvalue,"w");
 
1127
           if (seqannot_output)
 
1128
              aip = AsnIoOpen (myargs[ARG_ASNOUT].strvalue,"w");
705
1129
           
706
1130
           if (aip && seqannot) {
707
1131
              SeqAnnotAsnWrite((SeqAnnotPtr) seqannot, aip, NULL);
708
1132
              AsnIoReset(aip);
709
1133
              aip = AsnIoClose(aip);
710
1134
           }
 
1135
        }
 
1136
        if (!tabular_output) {    
 
1137
           AcknowledgeBlastQuery(query_bsp, 70, outfp, believe_query, html);
 
1138
           ShowTextAlignFromAnnot(seqannot, 60, outfp, NULL, NULL, align_options, txmatrix, mask_loc, FormatScoreFunc);
 
1139
           
711
1140
           seqannot = SeqAnnotFree(seqannot);
712
 
           
713
 
           matrix = BLAST_MatrixDestruct(matrix);
714
1141
           if (txmatrix)
715
1142
              txmatrix = TxMatrixDestruct(txmatrix);
716
1143
           init_buff_ex(85);
717
 
           dbinfo_head = dbinfo;
718
 
           while (dbinfo) {
719
 
              PrintDbReport(dbinfo, 70, outfp);
720
 
              dbinfo = dbinfo->next;
721
 
           }
722
 
           dbinfo_head = TxDfDbInfoDestruct(dbinfo_head);
723
 
           
 
1144
        
724
1145
           if (ka_params) {
725
1146
              PrintKAParameters(ka_params->Lambda, ka_params->K, ka_params->H, 70, outfp, FALSE);
726
 
              MemFree(ka_params);
727
1147
           }
728
 
           
 
1148
        
729
1149
           if (ka_params_gap) {
730
1150
              PrintKAParameters(ka_params_gap->Lambda, ka_params_gap->K, ka_params_gap->H, 70, outfp, TRUE);
731
 
              MemFree(ka_params_gap);
732
1151
           }
733
 
           
 
1152
        
734
1153
           PrintTildeSepLines(params_buffer, 70, outfp);
735
 
           MemFree(params_buffer);
736
1154
           free_buff();
737
 
           mask_loc_start = mask_loc;
738
 
           while (mask_loc) {
739
 
              SeqLocSetFree(mask_loc->data.ptrvalue);
740
 
              mask_loc = mask_loc->next;
741
 
           }
742
 
           ValNodeFree(mask_loc_start);
743
 
           
744
 
           fake_bsp = BlastDeleteFakeBioseq(fake_bsp);
745
 
        } else { 
746
 
           /* Just destruct all other_returns parts */
747
 
           for (vnp=other_returns; vnp; vnp = vnp->next) {
748
 
              switch (vnp->choice) {
749
 
              case TXDBINFO:
750
 
                 TxDfDbInfoDestruct(vnp->data.ptrvalue);
751
 
                 break;
752
 
              case TXKABLK_NOGAP:
753
 
              case TXKABLK_GAP:
754
 
              case TXPARAMETERS:
755
 
                 MemFree(vnp->data.ptrvalue);
756
 
                 break;
757
 
              case TXMATRIX:
758
 
                 BLAST_MatrixDestruct(vnp->data.ptrvalue);
759
 
                 break;
760
 
              case SEQLOC_MASKING_NOTSET:
761
 
              case SEQLOC_MASKING_PLUS1:
762
 
              case SEQLOC_MASKING_PLUS2:
763
 
              case SEQLOC_MASKING_PLUS3:
764
 
              case SEQLOC_MASKING_MINUS1:
765
 
              case SEQLOC_MASKING_MINUS2:
766
 
              case SEQLOC_MASKING_MINUS3:
767
 
                 SeqLocSetFree(vnp->data.ptrvalue);
768
 
                 break;
769
 
              default:
770
 
                 break;
771
 
              }
772
 
           }
773
 
        }
 
1155
        } else {
 
1156
           PrintTabularOutputHeader(NULL, query_bsp, NULL, 
 
1157
              program_name, 0, believe_query, outfp);
 
1158
 
 
1159
           BlastPrintTabulatedResults(seqalign, query_bsp, NULL, 
 
1160
              1, program_name, !gapped_calculation,
 
1161
              believe_query, 0, 0, outfp, FALSE);
 
1162
           SeqAlignSetFree(seqalign);
 
1163
        }
 
1164
 
 
1165
        matrix = BLAST_MatrixDestruct(matrix);
 
1166
        MemFree(ka_params);
 
1167
        MemFree(ka_params_gap);
 
1168
        MemFree(params_buffer);
 
1169
    
 
1170
        mask_loc_start = mask_loc;
 
1171
        while (mask_loc) {
 
1172
           SeqLocSetFree(mask_loc->data.ptrvalue);
 
1173
           mask_loc = mask_loc->next;
 
1174
        }
 
1175
        ValNodeFree(mask_loc_start);
 
1176
        
 
1177
        fake_bsp = BlastDeleteFakeBioseq(fake_bsp);
 
1178
 
774
1179
        other_returns = ValNodeFree(other_returns);
 
1180
    options->query_lcase_mask = SeqLocSetFree(options->query_lcase_mask);
775
1181
        options = BLASTOptionDelete(options);
776
1182
        MemFree(program_name);
777
1183
        FileClose(outfp);
778
1184
 
779
1185
        if (entrez_lookup) {
780
 
           BioseqUnlock(query_bsp);
781
 
           BioseqUnlock(subject_bsp);
 
1186
           BioseqFree(query_bsp);
 
1187
           BioseqFree(subject_bsp);
782
1188
        } else {
783
1189
           SeqEntryFree(sep);
784
1190
           SeqEntryFree(sep1);
785
1191
        }
786
1192
        return 0;
787
1193
}
 
1194
 
 
1195
 
 
1196
Int2 Main (void)
 
1197
 
 
1198
{
 
1199
    Char buf[256] = { '\0' };  /* Used below for name and version. */
 
1200
    Int2 status = 0;    /* return value of function. */
 
1201
 
 
1202
    StringCpy(buf, "bl2seq ");
 
1203
    StringNCat(buf, BlastGetVersionNumber(), sizeof(buf)-StringLen(buf)-1);
 
1204
    if (! GetArgs (buf, NUMARG, myargs)) {
 
1205
        return (1);
 
1206
    }
 
1207
 
 
1208
    UseLocalAsnloadDataAndErrMsg ();
 
1209
 
 
1210
    if (! SeqEntryLoad())
 
1211
                return 1;
 
1212
 
 
1213
    ErrSetMessageLevel(SEV_WARNING);
 
1214
 
 
1215
    if (myargs[ARG_FORCE_OLD].intvalue != 0)
 
1216
        status = Main_old();
 
1217
    else
 
1218
        status = Main_new();
 
1219
 
 
1220
    return status;
 
1221
}
788
1222
        
789
1223