~ubuntu-branches/ubuntu/edgy/ncbi-tools6/edgy

« back to all changes in this revision

Viewing changes to api/asn2gnb6.c

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2006-07-19 23:28:07 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060719232807-et3cdmcjgmnyleyx
Tags: 6.1.20060507-3ubuntu1
Re-merge with Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
*
31
31
* Version Creation Date:   10/21/98
32
32
*
33
 
* $Revision: 1.63 $
 
33
* $Revision: 1.73 $
34
34
*
35
35
* File Description:  New GenBank flatfile generator - work in progress
36
36
*
446
446
  "UniProtKB/TrEMBL",
447
447
  "UniSTS",
448
448
  "VBASE2",
 
449
  "VectorBase",
449
450
  "WorfDB",
450
451
  "WormBase",
451
452
  "ZFIN",
458
459
  "ECOCYC",
459
460
  "HPRD",
460
461
  "REBASE",
 
462
  "miRBase",
461
463
  NULL
462
464
};
463
465
 
990
992
  return ptr;
991
993
}
992
994
 
 
995
static Boolean CommentHasSuspiciousHtml (
 
996
  IntAsn2gbJobPtr ajp,
 
997
  CharPtr searchString
 
998
)
 
999
 
 
1000
{
 
1001
  Char        ch;
 
1002
  CharPtr     ptr;
 
1003
  Int2        state;
 
1004
  ValNodePtr  matches;
 
1005
 
 
1006
  if (StringHasNoText (searchString)) return FALSE;
 
1007
 
 
1008
  state = 0;
 
1009
  ptr = searchString;
 
1010
  ch = *ptr;
 
1011
 
 
1012
  while (ch != '\0') {
 
1013
    matches = NULL;
 
1014
    state = TextFsaNext (ajp->bad_html_fsa, state, ch, &matches);
 
1015
    if (matches != NULL) return TRUE;
 
1016
    ptr++;
 
1017
    ch = *ptr;
 
1018
  }
 
1019
 
 
1020
  return FALSE;
 
1021
}
 
1022
 
993
1023
NLM_EXTERN void AddCommentWithURLlinks (
994
1024
  IntAsn2gbJobPtr ajp,
995
1025
  StringItemPtr ffstring,
1002
1032
  Char     ch;
1003
1033
  CharPtr  ptr;
1004
1034
 
 
1035
  if (GetWWW (ajp) && CommentHasSuspiciousHtml (ajp, str)) {
 
1036
    if (prefix != NULL) {
 
1037
      FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
 
1038
    }
 
1039
    AddCommentStringWithTildes (ffstring, str);
 
1040
    if (suffix != NULL) {
 
1041
      FFAddOneString(ffstring, suffix, FALSE, FALSE, TILDE_IGNORE);
 
1042
    }
 
1043
    return;
 
1044
  }
 
1045
 
1005
1046
  while (! StringHasNoText (str)) {
1006
1047
    ptr = StringStr (str, "http://");
1007
1048
    if (ptr == NULL) {
3156
3197
          }
3157
3198
          if (! StringHasNoText (buf)) {
3158
3199
            FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
3159
 
            FF_www_db_xref(ajp, ffstring, dbt->db, buf);
 
3200
            FF_www_db_xref(ajp, ffstring, dbt->db, buf, bsp);
3160
3201
            FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
3161
3202
          }
3162
3203
        }
4048
4089
)
4049
4090
 
4050
4091
{
4051
 
  Char      fmt_buf [32];
 
4092
  Char      fmt_buf [64];
4052
4093
  Char      gapbuf [80];
4053
4094
  Int4      gi;
4054
4095
  Char      gi_buf [16];
4090
4131
      if (gi > 0) {
4091
4132
        sprintf(gi_buf, "%ld", (long) gi);
4092
4133
        sprintf(fmt_buf, "&fmt_mask=%ld", (long) EXPANDED_GAP_DISPLAY);
 
4134
        if (bsp->repr == Seq_repr_delta && (! DeltaLitOnly (bsp))) {
 
4135
          StringCat (fmt_buf, "&view=gbwithparts");
 
4136
        }
4093
4137
        FFAddOneString (ffstring, "    <a href=", FALSE, FALSE, TILDE_IGNORE);
4094
4138
        FFAddOneString (ffstring, link_featc, FALSE, FALSE, TILDE_IGNORE);
4095
4139
        FFAddOneString (ffstring, "val=", FALSE, FALSE, TILDE_IGNORE);
4111
4155
    FixGapAtEnd (buf, ' ');
4112
4156
    ajp->seqGapCurrLen += endgap;
4113
4157
  } else if (endgap > 0) {
 
4158
    /*
4114
4159
    FixGapAtEnd (buf, pad);
 
4160
    */
 
4161
    FixGapAtEnd (buf, ' ');
 
4162
    ajp->seqGapCurrLen += endgap;
4115
4163
  }
4116
4164
 
4117
4165
  FixRemainingGaps (buf, pad);
4119
4167
  return startgapgap;
4120
4168
}
4121
4169
 
 
4170
static void ChangeoTox (CharPtr str)
 
4171
 
 
4172
{
 
4173
  Char  ch;
 
4174
 
 
4175
  if (str == NULL) return;
 
4176
  ch = *str;
 
4177
  while (ch != '\0') {
 
4178
    if (ch == 'O') {
 
4179
      *str = 'X';
 
4180
    } else if (ch == 'o') {
 
4181
      *str = 'x';
 
4182
    }
 
4183
    str++;
 
4184
    ch = *str;
 
4185
  }
 
4186
}
 
4187
 
4122
4188
NLM_EXTERN CharPtr FormatSequenceBlock (
4123
4189
  Asn2gbFormatPtr afp,
4124
4190
  BaseBlockPtr bbp
4181
4247
    } else {
4182
4248
      SeqPortStream (bsp, STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL, (Pointer) &tmp, SaveGBSeqSequence);
4183
4249
    }
 
4250
    if (ISA_aa (bsp->mol) && StringDoesHaveText (str)) {
 
4251
      if (ajp->mode == RELEASE_MODE || ajp->mode == ENTREZ_MODE) {
 
4252
        ChangeoTox (str);
 
4253
      }
 
4254
    }
4184
4255
    gbseq->sequence = StringSave (str);
4185
4256
 
4186
4257
    tmp = gbseq->sequence;
4239
4310
        } else {
4240
4311
          SeqPortStreamInt (bsp, start, extend - 1, Seq_strand_plus, flags, (Pointer) str, NULL);
4241
4312
        }
 
4313
        if (ISA_aa (bsp->mol) && StringDoesHaveText (str)) {
 
4314
          if (ajp->mode == RELEASE_MODE || ajp->mode == ENTREZ_MODE) {
 
4315
            ChangeoTox (str);
 
4316
          }
 
4317
        }
4242
4318
        sbp->bases = str;
4243
4319
      }
4244
4320
    }
4306
4382
  return str;
4307
4383
}
4308
4384
 
 
4385
/*
4309
4386
static CharPtr insd_strd [4] = {
4310
4387
  NULL, "single", "double", "mixed"
4311
4388
};
4317
4394
static CharPtr insd_top [3] = {
4318
4395
  NULL, "linear", "circular"
4319
4396
};
 
4397
*/
4320
4398
 
4321
4399
NLM_EXTERN void AsnPrintNewLine PROTO((AsnIoPtr aip));
4322
4400
 
4326
4404
)
4327
4405
 
4328
4406
{
4329
 
  IntAsn2gbJobPtr    ajp;
4330
 
  Asn2gbSectPtr      asp;
4331
 
  GBFeaturePtr       currf, headf, nextf;
4332
 
  GBReferencePtr     currr, headr, nextr;
4333
 
  GBSeqPtr           gbseq, gbtmp;
4334
 
  IndxPtr            index;
4335
 
  INSDSeq            is;
4336
 
  Int2               moltype, strandedness, topology;
 
4407
  IntAsn2gbJobPtr  ajp;
 
4408
  Asn2gbSectPtr    asp;
 
4409
  GBFeaturePtr     currf, headf, nextf;
 
4410
  GBReferencePtr   currr, headr, nextr;
 
4411
  GBSeqPtr         gbseq, gbtmp;
 
4412
  IndxPtr          index;
 
4413
  INSDSeq          is;
 
4414
  /*
 
4415
  Int2              moltype, strandedness, topology;
 
4416
  */
4337
4417
 
4338
4418
  if (afp == NULL || bbp == NULL) return NULL;
4339
4419
  ajp = afp->ajp;
4405
4485
      is.OBbits__ = gbseq->OBbits__;
4406
4486
      is.locus = gbseq->locus;
4407
4487
      is.length = gbseq->length;
 
4488
      is.strandedness = gbseq->strandedness;
 
4489
      is.moltype = gbseq->moltype;
 
4490
      is.topology = gbseq->topology;
 
4491
      /*
4408
4492
      strandedness = (Int2) gbseq->strandedness;
4409
4493
      if (strandedness < 0 || strandedness > 3) {
4410
4494
        strandedness = 0;
4411
4495
      }
4412
 
      is.strandedness = insd_strd [strandedness];
 
4496
      is.strandedness = StringSave (insd_strd [strandedness]);
4413
4497
      moltype = (Int2) gbseq->moltype;
4414
4498
      if (moltype < 0 || moltype > 9) {
4415
4499
        moltype = 0;
4416
4500
      }
4417
 
      is.moltype = insd_mol [moltype];
 
4501
      is.moltype = StringSave (insd_mol [moltype]);
4418
4502
      topology = (Int2) gbseq->topology;
4419
4503
      if (topology < 0 || topology > 2) {
4420
4504
        topology = 0;
4421
4505
      }
4422
 
      is.topology = insd_top [topology];
 
4506
      is.topology = StringSave (insd_top [topology]);
 
4507
      */
4423
4508
      is.division = gbseq->division;
4424
4509
      is.update_date = gbseq->update_date;
4425
4510
      is.create_date = gbseq->create_date;
4431
4516
      is.accession_version = gbseq->accession_version;
4432
4517
      is.other_seqids = gbseq->other_seqids;
4433
4518
      is.secondary_accessions = gbseq->secondary_accessions;
 
4519
      is.project = gbseq->project;
4434
4520
      is.keywords = gbseq->keywords;
4435
4521
      is.segment = gbseq->segment;
4436
4522
      is.source = gbseq->source;