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

« back to all changes in this revision

Viewing changes to demo/tbl2asn.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:
29
29
*
30
30
* Version Creation Date:   5/5/00
31
31
*
32
 
* $Revision: 6.141 $
 
32
* $Revision: 6.149 $
33
33
*
34
34
* File Description: 
35
35
*
63
63
#include <util/creaders/alnread.h>
64
64
#include <pmfapi.h>
65
65
#include <tax3api.h>
 
66
#ifdef INTERNAL_NCBI_TBL2ASN
 
67
#include <accpubseq.h>
 
68
#endif
66
69
 
67
 
#define TBL2ASN_APP_VER "5.3"
 
70
#define TBL2ASN_APP_VER "5.9"
68
71
 
69
72
CharPtr TBL2ASN_APPLICATION = TBL2ASN_APP_VER;
70
73
 
76
79
  Boolean  gapped;
77
80
  Boolean  phrapace;
78
81
  Boolean  genprodset;
 
82
  Boolean  makelinks;
 
83
  Boolean  implicitgaps;
79
84
  Boolean  forcelocalid;
80
85
  Boolean  gpstonps;
81
86
  Boolean  gnltonote;
2448
2453
  return NULL;
2449
2454
}
2450
2455
 
 
2456
static SeqEntryPtr MakeUnk100GapSep (void)
 
2457
 
 
2458
{
 
2459
  BioseqPtr    bsp;
 
2460
  SeqEntryPtr  sep;
 
2461
 
 
2462
  sep = SeqEntryNew ();
 
2463
  if (sep == NULL) return NULL;
 
2464
  bsp = BioseqNew ();
 
2465
  if (bsp == NULL) return NULL;
 
2466
  bsp->repr = Seq_repr_virtual;
 
2467
  bsp->mol = Seq_mol_na;
 
2468
  bsp->length = 100;
 
2469
  bsp->id = SeqIdParse ("lcl|unk100");
 
2470
  sep->choice = 1;
 
2471
  sep->data.ptrvalue = bsp;
 
2472
  SeqMgrSeqEntry (SM_BIOSEQ, (Pointer) bsp, sep);
 
2473
  return sep;
 
2474
}
 
2475
 
2451
2476
static Uint2 ProcessDeltaSet (
2452
2477
  FILE* fp,
2453
2478
  BioSourcePtr src,
2461
2486
  BioseqPtr      bsp, deltabsp;
2462
2487
  BioseqSetPtr   bssp;
2463
2488
  Uint2          entityID;
2464
 
  SeqEntryPtr    firstsep, lastsep, nextsep, sep, topsep;
 
2489
  SeqEntryPtr    firstsep, lastsep, nextsep, sep, tmp, topsep;
2465
2490
  IntFuzzPtr     ifp;
2466
2491
  Boolean        is_unk100;
2467
2492
  ObjectIdPtr    oip;
2491
2516
    if (firstsep == NULL) {
2492
2517
      firstsep = sep;
2493
2518
    }
 
2519
    if (tbl->implicitgaps && lastsep != NULL) {
 
2520
      tmp = MakeUnk100GapSep ();
 
2521
      if (tmp != NULL) {
 
2522
        ValNodeLink (&lastsep, tmp);
 
2523
        lastsep = tmp;
 
2524
      }
 
2525
    }
2494
2526
    if (lastsep != NULL) {
2495
2527
      ValNodeLink (&lastsep, sep);
2496
2528
    }
4030
4062
  center = (CharPtr) userdata;
4031
4063
  if (StringHasNoText (center)) return;
4032
4064
 
4033
 
  for (sip = bsp->id; sip != NULL; sip = sip->next) {
4034
 
    if (sip->choice != SEQID_LOCAL) continue;
4035
 
    oip = (ObjectIdPtr) sip->data.ptrvalue;
4036
 
    if (oip == NULL) continue;
4037
 
    if (StringDoesHaveText (oip->str)) {
4038
 
      accn = oip->str;
4039
 
    }
4040
 
  }
 
4065
  for (sip = bsp->id; sip != NULL && sip->choice != SEQID_LOCAL; sip = sip->next) continue;
 
4066
  if (sip == NULL) return;
 
4067
  oip = (ObjectIdPtr) sip->data.ptrvalue;
 
4068
  if (oip == NULL) return;
 
4069
  accn = oip->str;
4041
4070
  if (StringHasNoText (accn)) return;
4042
4071
 
4043
4072
  dbt = DbtagNew ();
4048
4077
  dbt->db = StringSave (center);
4049
4078
  dbt->tag = oip;
4050
4079
 
 
4080
  sip->data.ptrvalue = ObjectIdFree ((ObjectIdPtr) sip->data.ptrvalue);
 
4081
  sip->data.ptrvalue = (Pointer) dbt;
 
4082
  sip->choice = SEQID_GENERAL;
 
4083
  /*
4051
4084
  ValNodeAddPointer (&(bsp->id), SEQID_GENERAL, (Pointer) dbt);
 
4085
  */
4052
4086
  SeqMgrReplaceInBioseqIndex (bsp);
4053
4087
}
4054
4088
 
4454
4488
    /*
4455
4489
    SeriousSeqEntryCleanup (sep, NULL, NULL);
4456
4490
    */
 
4491
    if (tbl->makelinks) {
 
4492
      LinkCDSmRNAbyProduct (sep);
 
4493
    }
4457
4494
    if (StringHasNoText (results)) {
4458
4495
      results = directory;
4459
4496
    }
4891
4928
 
4892
4929
/* Args structure contains command-line arguments */
4893
4930
 
4894
 
#define p_argInputPath    0
4895
 
#define r_argOutputPath   1
4896
 
#define i_argInputFile    2
4897
 
#define o_argOutputFile   3
4898
 
#define x_argSuffix       4
4899
 
#define t_argTemplate     5
4900
 
#define s_argFastaSet     6
4901
 
#define w_argWhichClass   7
4902
 
#define d_argDeltaSet     8
4903
 
#define l_argAlignment    9
4904
 
#define z_argGapped      10
4905
 
#define e_argPhrapAce    11
4906
 
#define g_argGenProdSet  12
4907
 
#define a_argAccession   13
4908
 
#define C_argCenter      14
4909
 
#define n_argOrgName     15
4910
 
#define j_argSrcQuals    16
4911
 
#define y_argComment     17
4912
 
#define Y_argCommentFile 18
4913
 
#define c_argFindOrf     19
4914
 
#define m_argAltStart    20
4915
 
#define k_argConflict    21
4916
 
#define v_argValidate    22
4917
 
#define b_argGenBank     23
4918
 
#define q_argFileID      24
4919
 
#define u_argUndoGPS     25
4920
 
#define h_argGnlToNote   26
4921
 
#define B_argBegGap      27
4922
 
#define E_argEndGap      28
4923
 
#define G_argMidGap      29
4924
 
#define X_argMissing     30
4925
 
#define M_argMatch       31
4926
 
#define P_argIsProt      32
4927
 
#define R_argRemote      33
4928
 
#define S_argSmartFeats  34
4929
 
#define Q_argSmartTitle  35
4930
 
#define U_argUnnecXref   36
4931
 
#define L_argLocalID     37
4932
 
#define T_argTaxLookup   38
 
4931
#define p_argInputPath      0
 
4932
#define r_argOutputPath     1
 
4933
#define i_argInputFile      2
 
4934
#define o_argOutputFile     3
 
4935
#define x_argSuffix         4
 
4936
#define t_argTemplate       5
 
4937
#define s_argFastaSet       6
 
4938
#define w_argWhichClass     7
 
4939
#define d_argDeltaSet       8
 
4940
#define l_argAlignment      9
 
4941
#define z_argGapped        10
 
4942
#define e_argPhrapAce      11
 
4943
#define g_argGenProdSet    12
 
4944
#define F_argFeatIdLinks   13
 
4945
#define H_argImplicitGaps  14
 
4946
#define a_argAccession     15
 
4947
#define C_argCenter        16
 
4948
#define n_argOrgName       17
 
4949
#define j_argSrcQuals      18
 
4950
#define y_argComment       19
 
4951
#define Y_argCommentFile   20
 
4952
#define c_argFindOrf       21
 
4953
#define m_argAltStart      22
 
4954
#define k_argConflict      23
 
4955
#define v_argValidate      24
 
4956
#define b_argGenBank       25
 
4957
#define q_argFileID        26
 
4958
#define u_argUndoGPS       27
 
4959
#define h_argGnlToNote     28
 
4960
#define B_argBegGap        29
 
4961
#define E_argEndGap        30
 
4962
#define G_argMidGap        31
 
4963
#define X_argMissing       32
 
4964
#define M_argMatch         33
 
4965
#define P_argIsProt        34
 
4966
#define R_argRemote        35
 
4967
#define S_argSmartFeats    36
 
4968
#define Q_argSmartTitle    37
 
4969
#define U_argUnnecXref     38
 
4970
#define L_argLocalID       39
 
4971
#define T_argTaxLookup     40
4933
4972
 
4934
4973
Args myargs [] = {
4935
4974
  {"Path to files", NULL, NULL, NULL,
4958
4997
    TRUE, 'e', ARG_BOOLEAN, 0.0, 0, NULL},
4959
4998
  {"Genomic Product Set", "F", NULL, NULL,
4960
4999
    TRUE, 'g', ARG_BOOLEAN, 0.0, 0, NULL},
 
5000
  {"Feature ID Links", "F", NULL, NULL,
 
5001
    TRUE, 'F', ARG_BOOLEAN, 0.0, 0, NULL},
 
5002
  {"Implicit Gaps", "F", NULL, NULL,
 
5003
    TRUE, 'H', ARG_BOOLEAN, 0.0, 0, NULL},
4961
5004
  {"Accession", NULL, NULL, NULL,
4962
5005
    TRUE, 'a', ARG_STRING, 0.0, 0, NULL},
4963
5006
  {"Genome center tag", NULL, NULL, NULL,
5092
5135
  outfile = (CharPtr) myargs [o_argOutputFile].strvalue;
5093
5136
  tmplate = (CharPtr) myargs [t_argTemplate].strvalue;
5094
5137
 
 
5138
  if (StringHasNoText(directory) && StringHasNoText(base)) {
 
5139
    Message (MSG_FATAL, "You must supply either an input file (-i) or an input directory (-p).\nUse -p . to specify the current directory.\n\n");
 
5140
    return 1;
 
5141
  }
5095
5142
  remote = (Boolean) myargs [R_argRemote].intvalue;
5096
5143
 
5097
5144
  tbl.fastaset = (Boolean) myargs [s_argFastaSet].intvalue;
5101
5148
  tbl.gapped = (Boolean) myargs [z_argGapped].intvalue;
5102
5149
  tbl.phrapace = (Boolean) myargs [e_argPhrapAce].intvalue;
5103
5150
  tbl.genprodset = (Boolean) myargs [g_argGenProdSet].intvalue;
 
5151
  tbl.makelinks = (Boolean) myargs [F_argFeatIdLinks].intvalue;
 
5152
  tbl.implicitgaps = (Boolean) myargs [H_argImplicitGaps].intvalue;
5104
5153
  tbl.forcelocalid = (Boolean) myargs [L_argLocalID].intvalue;
5105
5154
  tbl.gpstonps = (Boolean) myargs [u_argUndoGPS].intvalue;
5106
5155
  tbl.gnltonote = (Boolean) myargs [h_argGnlToNote].intvalue;
5258
5307
  /* register fetch function */
5259
5308
 
5260
5309
  if (remote) {
 
5310
#ifdef INTERNAL_NCBI_TBL2ASN
 
5311
    if (! PUBSEQBioseqFetchEnable ("tbl2asn", FALSE)) {
 
5312
      Message (MSG_POSTERR, "PUBSEQBioseqFetchEnable failed");
 
5313
      return 1;
 
5314
    }
 
5315
#else
5261
5316
    PubSeqFetchEnable ();
 
5317
#endif
5262
5318
  }
5263
5319
 
5264
5320
  /* process one or more records */
5309
5365
  /* close fetch function */
5310
5366
 
5311
5367
  if (remote) {
 
5368
#ifdef INTERNAL_NCBI_TBL2ASN
 
5369
    PUBSEQBioseqFetchDisable ();
 
5370
#else
5312
5371
    PubSeqFetchDisable ();
 
5372
#endif
5313
5373
  }
5314
5374
 
5315
5375
  return 0;