~ubuntu-branches/ubuntu/oneiric/ncbi-tools6/oneiric

« back to all changes in this revision

Viewing changes to sequin/sequin1.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2008-07-14 19:43:15 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080714194315-ed44u9ek7txva2rz
Tags: 6.1.20080302-3
tools/readdb.c: enable madvise()-based code on all glibc (hence all
Debian) systems, not just Linux.  (Closes: #490437.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
*
30
30
* Version Creation Date:   1/22/95
31
31
*
32
 
* $Revision: 6.565 $
 
32
* $Revision: 6.653 $
33
33
*
34
34
* File Description: 
35
35
*
91
91
#include <sqnutils.h>
92
92
#include <tax3api.h>
93
93
#include <validerr.h>
 
94
#include <algo/blast/api/blast_api.h>
 
95
#include <findrepl.h>
94
96
 
95
97
/* USE_SMARTNET */
96
98
#ifdef USE_SMARTNET
118
120
#include <medarch.h>
119
121
#include <medutil.h>
120
122
 
 
123
#include <mla2api.h>
 
124
 
 
125
 
121
126
#ifdef USE_SPELL
122
127
#include <spellapi.h>
123
128
#endif
126
131
#include <Gestalt.h>
127
132
#endif
128
133
 
129
 
#define SEQ_APP_VER "6.42"
 
134
#define SEQ_APP_VER "8.03"
130
135
 
131
136
#ifndef CODECENTER
132
137
static char* sequin_version_binary = "Sequin Indexer Services Version " SEQ_APP_VER " " __DATE__ " " __TIME__;
138
143
CharPtr SEQUIN_SERVICES = NULL;
139
144
CharPtr SEQUIN_VERSION = NULL;
140
145
 
141
 
extern EnumFieldAssoc  orgmod_subtype_alist [];
142
 
extern EnumFieldAssoc  subsource_subtype_alist [];
143
146
extern EnumFieldAssoc  biosource_genome_simple_alist [];
144
147
 
145
148
Boolean  useDesktop = FALSE;
146
149
Boolean  useEntrez = FALSE;
147
150
Boolean  useSeqFetch = FALSE;
 
151
Boolean  useIdLookup = FALSE;
148
152
Boolean  useLocal = FALSE;
149
153
Boolean  useBlast = FALSE;
150
154
Boolean  useMedarch = FALSE;
 
155
Boolean  newMedarch = FALSE;
151
156
Boolean  useTaxon = FALSE;
152
157
Boolean  allowDownload = FALSE;
153
158
Boolean  extraServices = FALSE;
295
300
static Int2     subtoolTimerCount = 0;
296
301
static Boolean  subtoolRecordDirty = FALSE;
297
302
 
 
303
static Boolean  testLatLonSubregion = FALSE;
 
304
static Boolean  strictLatLonCountry = FALSE;
 
305
 
298
306
 
299
307
#ifdef USE_SMARTNET
300
308
static Int4 SMWriteBioseqObj(VoidPtr bio_data, SMUserDataPtr sm_usr_data, 
301
309
                             VoidPtr data);
302
310
static Int4 SMReadBioseqObj(VoidPtr data, CharPtr buffer, 
303
 
                            Int4 length, Int4 fd);
 
311
                            Int4 length, void* fd);
304
312
#define SMART_KEY 1313
305
313
#define DUMB_KEY 1314
306
314
#endif
385
393
  }
386
394
}
387
395
 
 
396
static void TaxonValidate (SeqEntryPtr sep, ValidStructPtr vsp);
 
397
 
 
398
 
388
399
static Boolean OkayToWriteTheEntity (Uint2 entityID, ForM f)
389
400
 
390
401
{
400
411
  if (entityID < 1) return FALSE;
401
412
  sep = GetTopSeqEntryForEntityID (entityID);
402
413
  if (sep == NULL) return FALSE;
 
414
 
 
415
  if (!FixSpecialCharacters (entityID)) return FALSE;
 
416
 
403
417
  if (GetSequinAppParam ("PREFERENCES", "ASKBEFOREVALIDATE", NULL, str, sizeof (str))) {
404
418
    if (StringICmp (str, "TRUE") == 0) {
405
419
      if (! (subtoolMode ||smartnetMode || backupMode) ) {
418
432
    }
419
433
    if (indexerVersion) {
420
434
      vsp->alwaysRequireIsoJTA = TRUE;
 
435
      if (smartnetMode) {
 
436
        vsp->farFetchCDSproducts = TRUE;
 
437
        vsp->farFetchMRNAproducts = TRUE;
 
438
      }
421
439
    }
422
440
    oldErrSev = ErrSetMessageLevel (SEV_MAX);
423
441
    vsp->validateAlignments = TRUE;
424
442
    vsp->alignFindRemoteBsp = TRUE;
425
443
    vsp->doSeqHistAssembly = FALSE;
 
444
    if (smartnetMode) {
 
445
      vsp->doSeqHistAssembly = TRUE;
 
446
      vsp->farIDsInAlignments = TRUE;
 
447
      if (useEntrez) {
 
448
        /*
 
449
        LookupFarSeqIDs (sep, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE);
 
450
        vsp->inferenceAccnCheck = TRUE;
 
451
        */
 
452
      }
 
453
      vsp->testLatLonSubregion = testLatLonSubregion;
 
454
      vsp->strictLatLonCountry = strictLatLonCountry;
 
455
    }
426
456
    for (j = 0; j < 6; j++) {
427
457
      vsp->errors [j] = 0;
428
458
    }
429
459
    ValidateSeqEntry (sep, vsp);
 
460
    if (indexerVersion && useEntrez) {
 
461
      TaxonValidate (sep, vsp);
 
462
    }
430
463
    ErrSetMessageLevel (oldErrSev);
431
464
    ErrClear ();
432
465
    ErrShow ();
976
1009
  Char         path [PATH_MAX];
977
1010
  CharPtr      ptr;
978
1011
  SeqEntryPtr  sep;
 
1012
  Char         suffix [32];
 
1013
  Char         tmp [32];
979
1014
  Boolean      update;
980
1015
 
981
1016
  if (bfp != NULL) {
995
1030
        if (ptr != NULL) {
996
1031
          *ptr = '\0';
997
1032
        }
998
 
        if (StringLen (dfault) < sizeof (dfault) - 5) {
999
 
          StringCat (dfault, ".sqn");
 
1033
        suffix [0] = '\0';
 
1034
        if (GetSequinAppParam ("PREFERENCES", "SUFFIX", ".sqn", tmp, sizeof (tmp))) {
 
1035
          if (tmp [0] == '.') {
 
1036
            StringNCpy_0 (suffix, tmp, sizeof (suffix));
 
1037
          } else {
 
1038
            StringCpy (suffix, ".");
 
1039
            StringNCpy_0 (suffix + 1, tmp, sizeof (suffix) - 1);
 
1040
          }
 
1041
        }
 
1042
        if (StringLen (dfault) < sizeof (dfault) - StringLen (suffix)) {
 
1043
          StringCat (dfault, suffix);
1000
1044
        }
1001
1045
        if (! (GetOutputFileName (path, sizeof (path), dfault))) return FALSE;
1002
1046
      }
1252
1296
        
1253
1297
        omudp = ObjMgrGetUserData(bfp->input_entityID, 0, 0, SMART_KEY);
1254
1298
        if (omudp == NULL) return;
 
1299
 
 
1300
        /* for now set dirty flag to force validation in OkayToWriteTheEntity */
 
1301
        ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
 
1302
 
1255
1303
        omdp = ObjMgrGetData (bfp->input_entityID);
1256
1304
 
1257
1305
        sm_usr_data = (SMUserDataPtr) omudp->userdata.ptrvalue;
1320
1368
                }
1321
1369
                PropagateFromGenBankBioseqSet (sep, FALSE);
1322
1370
            }
1323
 
            /*   SeqEntryPubsAsn3 (sep);   */
1324
1371
            CdCheck (sep, NULL);
1325
1372
 
1326
1373
            omudp = ObjMgrGetUserData(bfp->input_entityID, 0, 0, DUMB_KEY);
1429
1476
        }
1430
1477
        PropagateFromGenBankBioseqSet (sep, FALSE);
1431
1478
      }
1432
 
      /*
1433
 
      SeqEntryPubsAsn3 (sep);
1434
 
      */
1435
1479
      CdCheck (sep, NULL);
1436
1480
    }
1437
1481
    /*SetChecklistValue (checklistForm, 7);*/
1500
1544
{
1501
1545
  Boolean         allRawOrSeg = TRUE;
1502
1546
  BaseFormPtr     bfp;
 
1547
  Char            buf [32];
1503
1548
  Int2            errors;
1504
1549
  Int2            j;
1505
1550
  ErrHookProc     oldErrHook;
1506
1551
  ErrSev          oldErrSev;
1507
1552
  SeqEntryPtr     sep;
1508
1553
  CharPtr         str;
 
1554
  Int2            verbosity;
1509
1555
  ValidStructPtr  vsp;
1510
1556
 
1511
1557
  bfp = (BaseFormPtr) GetObjectExtra (f);
1543
1589
      vsp->errors [j] = 0;
1544
1590
    }
1545
1591
    ValidateSeqEntry (sep, vsp);
 
1592
    if (indexerVersion && useEntrez) {
 
1593
      TaxonValidate (sep, vsp);
 
1594
    }
1546
1595
    ErrSetMessageLevel (oldErrSev);
1547
1596
    ErrClear ();
1548
1597
    ErrShow ();
1560
1609
        vsp = ValidStructNew ();
1561
1610
        if (vsp != NULL) {
1562
1611
          /*SetChecklistValue (checklistForm, 6);*/
 
1612
 
 
1613
          verbosity = 2;
 
1614
          if (GetSequinAppParam ("SETTINGS", "VALIDATEVERBOSITY", NULL, buf, sizeof (buf))) {
 
1615
            if (! StrToInt (buf, &verbosity)) {
 
1616
              verbosity = 2;
 
1617
            }
 
1618
          }
 
1619
 
1563
1620
          CreateValidateWindowEx (ValidNotify, "Sequin Validation Errors",
1564
 
                                  programFont, SEV_INFO, TRUE, bfp, ProcessDoneButton, TRUE);
 
1621
                                  programFont, SEV_INFO, verbosity, bfp, ProcessDoneButton, TRUE);
1565
1622
          ClearValidateWindow ();
1566
1623
          SeqEntryExplore (sep, (Pointer) (&allRawOrSeg), CheckForCookedBioseqs);
1567
1624
          if (allRawOrSeg) {
1578
1635
          for (j = 0; j < 6; j++) {
1579
1636
            vsp->errors [j] = 0;
1580
1637
          }
 
1638
          vsp->errfunc = ValidErrCallback;
1581
1639
          ValidateSeqEntry (sep, vsp);
 
1640
          if (indexerVersion && useEntrez) {
 
1641
            TaxonValidate (sep, vsp);
 
1642
          }
1582
1643
          ErrSetMessageLevel (oldErrSev);
1583
1644
          ErrSetHandler (oldErrHook);
1584
1645
          ErrClear ();
1658
1719
extern Boolean SequinEntrezInit (CharPtr appl_id, Boolean no_warnings, BoolPtr is_network)
1659
1720
 
1660
1721
{
 
1722
  /*
1661
1723
  MonitorPtr  mon;
1662
1724
  Boolean     rsult;
1663
1725
 
1668
1730
  MonitorFree (mon);
1669
1731
  Update ();
1670
1732
  return rsult;
 
1733
  */
 
1734
  return FALSE;
1671
1735
}
1672
1736
 
1673
1737
/*
1797
1861
 
1798
1862
NLM_EXTERN void CDECL  ValidErr VPROTO((ValidStructPtr vsp, int severity, int code1, int code2, const char *fmt, ...));
1799
1863
 
 
1864
static void ReportBadSpecificHostValues (SeqEntryPtr sep, ValidStructPtr vsp)
 
1865
{
 
1866
  ValNodePtr  bad_biop_list, vnp;
 
1867
  ObjValNodePtr ovp;
 
1868
  BioSourcePtr  biop;
 
1869
  OrgModPtr     mod;
 
1870
 
 
1871
  bad_biop_list = Taxon3CheckSpecificHostInSeqEntry (sep, TRUE, FALSE);
 
1872
 
 
1873
  for (vnp = bad_biop_list; vnp != NULL; vnp = vnp->next)
 
1874
  {
 
1875
    vsp->sfp = NULL;
 
1876
    vsp->descr = NULL;
 
1877
    vsp->bsp = NULL;
 
1878
    vsp->bssp = NULL;
 
1879
    biop = NULL;
 
1880
    mod = NULL;
 
1881
 
 
1882
    if (vnp->choice == OBJ_SEQFEAT)
 
1883
    {
 
1884
      vsp->sfp = (SeqFeatPtr) vnp->data.ptrvalue;
 
1885
      vsp->gcp->entityID = vsp->sfp->idx.entityID;
 
1886
      vsp->gcp->itemID = vsp->sfp->idx.itemID;
 
1887
      vsp->gcp->thistype = OBJ_SEQFEAT;
 
1888
      if (vsp->sfp->idx.parenttype == OBJ_BIOSEQ)
 
1889
      {
 
1890
        vsp->bsp = vsp->sfp->idx.parentptr;        
 
1891
      }
 
1892
      else if (vsp->sfp->idx.parenttype == OBJ_BIOSEQSET)
 
1893
      {
 
1894
        vsp->bssp = vsp->sfp->idx.parentptr;        
 
1895
      }
 
1896
      biop = (BioSourcePtr) vsp->sfp->data.value.ptrvalue;
 
1897
    } 
 
1898
    else if (vnp->choice == OBJ_SEQDESC)
 
1899
    {
 
1900
      vsp->descr = (SeqDescrPtr) vnp->data.ptrvalue;
 
1901
      if (vsp->descr != NULL && vsp->descr->extended != 0) 
 
1902
      {
 
1903
        ovp = (ObjValNodePtr) vsp->descr;
 
1904
        vsp->gcp->entityID = ovp->idx.entityID;
 
1905
        vsp->gcp->itemID = ovp->idx.itemID;
 
1906
        vsp->gcp->thistype = OBJ_SEQDESC;
 
1907
 
 
1908
        if (ovp->idx.parenttype == OBJ_BIOSEQ)
 
1909
        {
 
1910
          vsp->bsp = ovp->idx.parentptr;        
 
1911
        }
 
1912
        else if (ovp->idx.parenttype == OBJ_BIOSEQSET)
 
1913
        {
 
1914
          vsp->bssp = ovp->idx.parentptr;        
 
1915
        }
 
1916
      }
 
1917
      biop = vsp->descr->data.ptrvalue;
 
1918
    }
 
1919
    
 
1920
    if (biop != NULL && biop->org != NULL && biop->org->orgname != NULL)
 
1921
    {
 
1922
      mod = biop->org->orgname->mod;
 
1923
      while (mod != NULL && mod->subtype != ORGMOD_nat_host)
 
1924
      {
 
1925
        mod = mod->next;
 
1926
      }
 
1927
      if (mod != NULL)
 
1928
      {      
 
1929
        ValidErr (vsp, SEV_WARNING, ERR_SEQ_DESCR_BadSpecificHost, "Invalid value for specific host: %s", mod->subname);
 
1930
      }
 
1931
    }
 
1932
  }
 
1933
  bad_biop_list = ValNodeFree (bad_biop_list);
 
1934
}
 
1935
 
 
1936
static Boolean log_tax_asn = FALSE;
 
1937
static Boolean log_tax_set = FALSE;
 
1938
 
1800
1939
static void TaxonValidate (SeqEntryPtr sep, ValidStructPtr vsp)
1801
1940
 
1802
1941
{
1807
1946
  Boolean           force_tax_consult;
1808
1947
  ValNodePtr        last = NULL;
1809
1948
  OrgRefPtr         orp;
 
1949
  ErrSev            sev;
1810
1950
  TaxLst            srclist;
1811
1951
  CharPtr           str;
1812
1952
  T3ErrorPtr        t3ep;
1846
1986
    last = vnp2;
1847
1987
  }
1848
1988
 
 
1989
#ifdef OS_UNIX
 
1990
  if (! log_tax_set) {
 
1991
    str = (CharPtr) getenv ("LOG_TAX_ASN");
 
1992
    if (StringDoesHaveText (str)) {
 
1993
      if (StringICmp (str, "TRUE") == 0) {
 
1994
        log_tax_asn = TRUE;
 
1995
      }
 
1996
    }
 
1997
    log_tax_set = TRUE;
 
1998
  }
 
1999
#endif
 
2000
 
 
2001
  sev = ErrSetMessageLevel (SEV_WARNING);
 
2002
  if (log_tax_asn) {
 
2003
    LaunchAsnTextViewer ((Pointer) t3rq, (AsnWriteFunc) Taxon3RequestAsnWrite, "tax3 request");
 
2004
  }
1849
2005
  t3ry = Tax3SynchronousQuery (t3rq);
 
2006
  ErrSetMessageLevel (sev);
1850
2007
  Taxon3RequestFree (t3rq);
1851
2008
  if (t3ry == NULL) return;
 
2009
  if (log_tax_asn) {
 
2010
    LaunchAsnTextViewer ((Pointer) t3ry, (AsnWriteFunc) Taxon3ReplyAsnWrite, "tax3 result");
 
2011
  }
1852
2012
 
1853
2013
  for (trp = t3ry->reply, vnp = srclist.head;
1854
2014
       trp != NULL && vnp != NULL;
1886
2046
 
1887
2047
    is_species_level = FALSE;
1888
2048
    has_nucleomorphs = FALSE;
 
2049
    is_nucleomorph = FALSE;
 
2050
 
1889
2051
    for (tfp = tdp->status; tfp != NULL; tfp = tfp->next) {
1890
2052
 
1891
2053
      /*
1944
2106
 
1945
2107
  Taxon3ReplyFree (t3ry);
1946
2108
  ValNodeFreeData (srclist.head);
 
2109
 
 
2110
  /* also validate specific-host values */
 
2111
 
 
2112
  ReportBadSpecificHostValues (sep, vsp);
1947
2113
}
1948
2114
 
1949
 
static void ValSeqEntryFormEx (ForM f, Boolean doAligns, Int2 limit)
 
2115
static void ValSeqEntryFormEx (ForM f, Boolean doAligns, Int2 limit, Boolean inferenceAccnCheck)
1950
2116
 
1951
2117
{
1952
2118
  Boolean         allRawOrSeg = TRUE;
1953
2119
  BaseFormPtr     bfp;
 
2120
  Char            buf [32];
1954
2121
  Int2            errors;
1955
2122
  Int2            j;
1956
2123
  ErrHookProc     oldErrHook;
1957
2124
  ErrSev          oldErrSev;
1958
2125
  SeqEntryPtr     sep;
1959
2126
  Char            str [32];
 
2127
  Int2            verbosity;
1960
2128
  ValidStructPtr  vsp;
1961
2129
 
1962
2130
  bfp = (BaseFormPtr) GetObjectExtra (f);
1973
2141
        WatchCursor ();
1974
2142
        Update ();
1975
2143
        /*SetChecklistValue (checklistForm, 6);*/
 
2144
 
 
2145
       verbosity = 1;
 
2146
       if (GetSequinAppParam ("SETTINGS", "VALIDATEVERBOSITY", NULL, buf, sizeof (buf))) {
 
2147
          if (! StrToInt (buf, &verbosity)) {
 
2148
            verbosity = 1;
 
2149
          }
 
2150
        }
 
2151
 
1976
2152
        CreateValidateWindowEx (ValidNotify, "Sequin Validation Errors",
1977
 
                                programFont, SEV_INFO, TRUE, bfp, ValSeqEntryForm, TRUE);
 
2153
                                programFont, SEV_INFO, verbosity, bfp, ValSeqEntryForm, TRUE);
1978
2154
        ClearValidateWindow ();
1979
2155
        SeqEntryExplore (sep, (Pointer) (&allRawOrSeg), CheckForCookedBioseqs);
1980
2156
        if (allRawOrSeg) {
2000
2176
            }
2001
2177
          }
2002
2178
        }
2003
 
        if (useEntrez) {
 
2179
        if (useEntrez && inferenceAccnCheck) {
2004
2180
          LookupFarSeqIDs (sep, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE);
 
2181
          vsp->inferenceAccnCheck = TRUE;
2005
2182
        }
 
2183
        vsp->testLatLonSubregion = testLatLonSubregion;
 
2184
        vsp->strictLatLonCountry = strictLatLonCountry;
2006
2185
        oldErrHook = ErrSetHandler (ValidErrHook);
2007
2186
        oldErrSev = ErrSetMessageLevel (SEV_NONE);
2008
2187
        for (j = 0; j < 6; j++) {
2009
2188
          vsp->errors [j] = 0;
2010
2189
        }
 
2190
        vsp->errfunc = ValidErrCallback;
2011
2191
        ValidateSeqEntry (sep, vsp);
2012
 
        if (indexerVersion) {
 
2192
        if (indexerVersion && useEntrez) {
2013
2193
          TaxonValidate (sep, vsp);
2014
2194
        }
2015
2195
        ErrSetMessageLevel (oldErrSev);
2036
2216
  }
2037
2217
}
2038
2218
 
 
2219
static void CountInfAccnVer (SeqFeatPtr sfp, Pointer userdata)
 
2220
 
 
2221
{
 
2222
  Int4Ptr    countP;
 
2223
  GBQualPtr  gbq;
 
2224
 
 
2225
  if (sfp == NULL || userdata == NULL) return;
 
2226
  countP = (Int4Ptr) userdata;
 
2227
 
 
2228
  for (gbq = sfp->qual; gbq != NULL; gbq = gbq->next) {
 
2229
    if (StringICmp (gbq->qual, "inference") == 0) {
 
2230
      (*countP)++;
 
2231
    }
 
2232
  }
 
2233
}
 
2234
 
 
2235
static Boolean SmallInferenceAccnVer (ForM f)
 
2236
 
 
2237
{
 
2238
  BaseFormPtr  bfp;
 
2239
  Int4         count = 0;
 
2240
  SeqEntryPtr  sep;
 
2241
 
 
2242
  bfp = (BaseFormPtr) GetObjectExtra (f);
 
2243
  if (bfp == NULL) return FALSE;
 
2244
 
 
2245
  sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
 
2246
  if (sep == NULL) return FALSE;
 
2247
 
 
2248
  VisitFeaturesInSep (sep, (Pointer) &count, CountInfAccnVer);
 
2249
 
 
2250
  if (count < 100) return TRUE;
 
2251
 
 
2252
  if (indexerVersion) {
 
2253
    Message (MSG_POST, "Validation skipping %ld inference accession.version tests",
 
2254
             (long) count);
 
2255
  }
 
2256
 
 
2257
  return FALSE;
 
2258
}
 
2259
 
2039
2260
extern void ValSeqEntryForm (ForM f)
2040
2261
 
2041
2262
{
2042
 
  ValSeqEntryFormEx (f, TRUE, VALIDATE_ALL);
 
2263
  Boolean  inferenceAccnCheck;
 
2264
 
 
2265
  inferenceAccnCheck = SmallInferenceAccnVer (f);
 
2266
  ValSeqEntryFormEx (f, TRUE, VALIDATE_ALL, inferenceAccnCheck);
2043
2267
}
2044
2268
 
2045
2269
static void ValSeqEntryProc (IteM i)
2046
2270
 
2047
2271
{
2048
2272
  BaseFormPtr  bfp;
 
2273
  Boolean      inferenceAccnCheck;
2049
2274
 
2050
2275
#ifdef WIN_MAC
2051
2276
  bfp = (BaseFormPtr) currentFormDataPtr;
2053
2278
  bfp = (BaseFormPtr) GetObjectExtra (i);
2054
2279
#endif
2055
2280
  if (bfp != NULL) {
2056
 
    ValSeqEntryForm (bfp->form);
 
2281
    inferenceAccnCheck = SmallInferenceAccnVer (bfp->form);
 
2282
    ValSeqEntryFormEx (bfp->form, TRUE, VALIDATE_ALL, inferenceAccnCheck);
2057
2283
  }
2058
2284
}
2059
2285
 
2068
2294
  bfp = (BaseFormPtr) GetObjectExtra (i);
2069
2295
#endif
2070
2296
  if (bfp != NULL) {
2071
 
    ValSeqEntryFormEx (bfp->form, FALSE, VALIDATE_ALL);
 
2297
    ValSeqEntryFormEx (bfp->form, FALSE, VALIDATE_ALL, FALSE);
 
2298
  }
 
2299
}
 
2300
 
 
2301
static void ValSeqEntryProcInfAccn (IteM i)
 
2302
 
 
2303
{
 
2304
  BaseFormPtr  bfp;
 
2305
 
 
2306
#ifdef WIN_MAC
 
2307
  bfp = (BaseFormPtr) currentFormDataPtr;
 
2308
#else
 
2309
  bfp = (BaseFormPtr) GetObjectExtra (i);
 
2310
#endif
 
2311
  if (bfp != NULL) {
 
2312
    ValSeqEntryFormEx (bfp->form, FALSE, VALIDATE_ALL, TRUE);
2072
2313
  }
2073
2314
}
2074
2315
 
2083
2324
  bfp = (BaseFormPtr) GetObjectExtra (i);
2084
2325
#endif
2085
2326
  if (bfp != NULL) {
2086
 
    ValSeqEntryFormEx (bfp->form, FALSE, limit);
 
2327
    ValSeqEntryFormEx (bfp->form, FALSE, limit, FALSE);
2087
2328
  }
2088
2329
}
2089
2330
 
2135
2376
{
2136
2377
  Boolean         allRawOrSeg = TRUE;
2137
2378
  BaseFormPtr     bfp;
 
2379
  Char            buf [32];
2138
2380
  Int2            errors;
2139
2381
  Int2            j;
2140
2382
  MonitorPtr      mon;
2141
2383
  ErrHookProc     oldErrHook;
2142
2384
  ErrSev          oldErrSev;
2143
2385
  SeqEntryPtr     sep;
 
2386
  Int2            verbosity;
2144
2387
  ValidStructPtr  vsp;
2145
2388
 
2146
2389
  bfp = (BaseFormPtr) GetObjectExtra (f);
2170
2413
        vsp->spellcallback = SpellCallBack;
2171
2414
        vsp->onlyspell = TRUE;
2172
2415
        vsp->justwarnonspell = TRUE;
 
2416
 
 
2417
       verbosity = 1;
 
2418
       if (GetSequinAppParam ("SETTINGS", "VALIDATEVERBOSITY", NULL, buf, sizeof (buf))) {
 
2419
          if (! StrToInt (buf, &verbosity)) {
 
2420
            verbosity = 1;
 
2421
          }
 
2422
        }
 
2423
 
2173
2424
        CreateValidateWindowEx (ValidNotify, "Sequin Spell Check Errors",
2174
 
                                programFont, SEV_INFO, TRUE, bfp, SpellCheckTheForm, TRUE);
 
2425
                                programFont, SEV_INFO, verbosity, bfp, SpellCheckTheForm, TRUE);
2175
2426
        ClearValidateWindow ();
2176
2427
        SeqEntryExplore (sep, (Pointer) (&allRawOrSeg), CheckForCookedBioseqs);
2177
2428
        if (allRawOrSeg) {
2185
2436
        for (j = 0; j < 6; j++) {
2186
2437
          vsp->errors [j] = 0;
2187
2438
        }
 
2439
        vsp->errfunc = ValidErrCallback;
2188
2440
        ValidateSeqEntry (sep, vsp);
2189
2441
        ErrSetMessageLevel (oldErrSev);
2190
2442
        ErrSetHandler (oldErrHook);
2518
2770
  *notaxid = TRUE;
2519
2771
}
2520
2772
 
2521
 
static Boolean HandleOneNewAsnProc (BaseFormPtr bfp, Boolean removeold, Boolean askForSubmit,
 
2773
static Boolean HandleOneNewAsnProcEx (BaseFormPtr bfp, Boolean removeold, Boolean askForSubmit,
2522
2774
                                    CharPtr path, Pointer dataptr, Uint2 datatype, Uint2 entityID,
2523
 
                                    Uint2Ptr updateEntityIDPtr)
 
2775
                                    Uint2Ptr updateEntityIDPtr, ValNodePtr PNTR err_list)
2524
2776
 
2525
2777
{
2526
2778
  BioseqPtr     bsp;
2651
2903
        entityID = bfp->input_entityID;
2652
2904
      }
2653
2905
      SeqEntrySetScope (NULL);
2654
 
      entityID = SmartAttachSeqAnnotToSeqEntry (entityID, (SeqAnnotPtr) dataptr);
 
2906
      entityID = SmartAttachSeqAnnotToSeqEntry (entityID, (SeqAnnotPtr) dataptr, err_list);
2655
2907
      ArrowCursor ();
2656
2908
      if (entityID != 0) {
2657
2909
        /* code to inhibit multiple updates when attaching multiple feature tables to the same entity */
2680
2932
  return FALSE;
2681
2933
}
2682
2934
 
 
2935
static Boolean HandleOneNewAsnProc (BaseFormPtr bfp, Boolean removeold, Boolean askForSubmit,
 
2936
                                    CharPtr path, Pointer dataptr, Uint2 datatype, Uint2 entityID,
 
2937
                                    Uint2Ptr updateEntityIDPtr)
 
2938
{
 
2939
  return HandleOneNewAsnProcEx (bfp, removeold, askForSubmit, path, dataptr, datatype, entityID,
 
2940
                                updateEntityIDPtr, NULL);
 
2941
}
 
2942
 
2683
2943
typedef struct multbioseqform {
2684
2944
  FORM_MESSAGE_BLOCK
2685
2945
 
2983
3243
  SeqEntryPtr    sephead = NULL;
2984
3244
  ValNodePtr     simples;
2985
3245
  Uint2          updateEntityID;
2986
 
  ValNodePtr     vnp;
 
3246
  ValNodePtr     vnp, err_list, vnp_err;
 
3247
  LogInfoPtr     lip;
2987
3248
 
2988
3249
  if (filename == NULL) return FALSE;
2989
3250
  fp = FileOpen (filename, "r");
3002
3263
    projects = ValNodeExtractList (&head, OBJ_PROJECT);
3003
3264
    simples = ValNodeExtractList (&head, OBJ_FASTA);
3004
3265
    updateEntityID = 0;
 
3266
    lip = OpenLog ("Errors");
3005
3267
    for (vnp = head; vnp != NULL; vnp = vnp->next) {
3006
3268
      datatype = vnp->choice;
3007
3269
      dataptr = vnp->data.ptrvalue;
3008
3270
      entityID = ObjMgrRegister (datatype, dataptr);
3009
 
      each = HandleOneNewAsnProc (bfp, removeold, askForSubmit, path, dataptr, datatype, entityID, &updateEntityID);
 
3271
      
 
3272
      err_list = NULL;
 
3273
      each = HandleOneNewAsnProcEx (bfp, removeold, askForSubmit, path, dataptr, datatype, entityID, &updateEntityID, &err_list);
 
3274
      if (err_list != NULL) {
 
3275
        for (vnp_err = err_list; vnp_err != NULL; vnp_err = vnp_err->next) {
 
3276
          fprintf (lip->fp, "%s\n", vnp_err->data.ptrvalue);
 
3277
          lip->data_in_log = TRUE;
 
3278
        }
 
3279
        err_list = ValNodeFreeData (err_list);
 
3280
        if (datatype == OBJ_SEQANNOT) {
 
3281
          ExportSeqAnnotFeatureTable (lip->fp, dataptr);
 
3282
        }
 
3283
      }
3010
3284
      removeold = FALSE;
3011
3285
      rsult = (Boolean) (rsult || each);
3012
3286
      if (backupMode) {
3016
3290
          omudp->messagefunc = BackupModeMsgFunc;
3017
3291
        }
3018
3292
        subtoolRecordDirty = TRUE;
3019
 
      }
 
3293
      }      
3020
3294
    }
 
3295
    CloseLog (lip);
 
3296
    lip = FreeLog (lip);
3021
3297
    ValNodeFree (head);
3022
3298
    if (updateEntityID != 0) {
3023
3299
      ObjMgrSetDirtyFlag (updateEntityID, TRUE);
3292
3568
 
3293
3569
   if (bsp == NULL)
3294
3570
      return;
 
3571
   if (bsp->seq_data_type == Seq_code_gap) return;
3295
3572
   len = bsp->length-1;
3296
3573
   compact = 2;
3297
3574
   spp = SeqPortNew(bsp, 0, len, 0, Seq_code_ncbistdaa);
3332
3609
      BSPutByte(bs, res1);
3333
3610
   }
3334
3611
   MemFree(bsp->seq_data);
3335
 
   bsp->seq_data = bs;
 
3612
   bsp->seq_data = (SeqDataPtr) bs;
3336
3613
   if (compact == 4)
3337
3614
      bsp->seq_data_type = Seq_code_ncbi2na;
3338
3615
   else
3471
3748
static void PrintExtraErrorInstructions (FILE *fp, CharPtr message)
3472
3749
{
3473
3750
  CharPtr explanation, end;
3474
 
  Char    tmp;
 
3751
  Char    tmp = '\0';
3475
3752
  if (fp == NULL || message == NULL) return;
3476
3753
 
3477
3754
  if (StringStr (message, "bad characters") == NULL
3641
3918
typedef struct alphabetformdata {
3642
3919
  FEATURE_FORM_BLOCK
3643
3920
 
3644
 
  TexT  missing;
3645
 
  TexT  beginning_gap;
3646
 
  TexT  middle_gap;
3647
 
  TexT  end_gap;
3648
 
  TexT  match;
3649
 
  PopuP sequence_type;
 
3921
  DialoG aln_settings;
3650
3922
  Handle obj;
3651
3923
  Char  path [PATH_MAX];
3652
3924
  FILE  *fp;
3686
3958
extern SeqEntryPtr 
3687
3959
SeqEntryFromAlignmentFile 
3688
3960
(FILE *fp,
3689
 
 CharPtr missing,
3690
 
 CharPtr match,
3691
 
 CharPtr beginning_gap,
3692
 
 CharPtr middle_gap,
3693
 
 CharPtr end_gap,
3694
 
 const CharPtr alphabet,
 
3961
 TSequenceInfoPtr sequence_info,
3695
3962
 Uint1   moltype,
3696
3963
 CharPtr no_org_err_msg)
3697
3964
{
3698
 
  TSequenceInfoPtr  sequence_info;
3699
3965
  TErrorInfoPtr     error_list;
3700
3966
  ReadBufferData    rbd;
3701
3967
  TAlignmentFilePtr afp;
3702
3968
  SeqEntryPtr       sep = NULL;
3703
3969
  MsgAnswer         ans;
3704
3970
 
3705
 
  if (fp == NULL) return NULL;
3706
 
 
3707
 
  sequence_info = SequenceInfoNew ();
3708
 
  if (sequence_info == NULL) return NULL;
3709
 
 
3710
 
  MemFree (sequence_info->missing);
3711
 
  sequence_info->missing = StringSave (missing);
3712
 
  MemFree (sequence_info->beginning_gap);
3713
 
  sequence_info->beginning_gap = StringSave (beginning_gap);
3714
 
  MemFree (sequence_info->middle_gap);
3715
 
  sequence_info->middle_gap = StringSave (middle_gap);
3716
 
  MemFree (sequence_info->end_gap);
3717
 
  sequence_info->end_gap = StringSave (end_gap);
3718
 
  MemFree (sequence_info->match);
3719
 
  sequence_info->match = StringSave (match);
3720
 
  sequence_info->alphabet = alphabet;
 
3971
  if (fp == NULL || sequence_info == NULL) return NULL;
3721
3972
 
3722
3973
  error_list = NULL;
3723
3974
  rbd.fp = fp;
3745
3996
      }
3746
3997
    }
3747
3998
  }
3748
 
  SequenceInfoFree (sequence_info);
3749
3999
 
3750
4000
  AlignmentFileFree (afp);
3751
4001
  return sep;
3756
4006
  AlphabetFormPtr  abc;
3757
4007
  TAlignmentFilePtr afp;
3758
4008
  TErrorInfoPtr     error_list;
3759
 
  Char             missing [15];
3760
 
  Char             beginning_gap [15];
3761
 
  Char             middle_gap [15];
3762
 
  Char             end_gap [15];
3763
 
  Char             match [15];
3764
4009
  TSequenceInfoPtr  sequence_info;
3765
4010
  SeqEntryPtr      sep;
3766
4011
  Uint1            moltype;
3771
4016
  Hide (abc->form);
3772
4017
  Update ();
3773
4018
 
3774
 
  sequence_info = SequenceInfoNew ();
 
4019
  sequence_info = (TSequenceInfoPtr) DialogToPointer (abc->aln_settings);
3775
4020
  if (sequence_info == NULL) return;
3776
4021
 
3777
 
 
3778
4022
  WatchCursor ();
3779
4023
  Update ();
3780
4024
 
3781
 
  GetTitle (abc->missing, missing, sizeof (missing) -1);
3782
 
  GetTitle (abc->beginning_gap, beginning_gap, sizeof (beginning_gap) - 1);
3783
 
  GetTitle (abc->middle_gap, middle_gap, sizeof (middle_gap) - 1);
3784
 
  GetTitle (abc->end_gap, end_gap, sizeof (end_gap) - 1);
3785
 
  GetTitle (abc->match, match, sizeof (match) - 1);
3786
 
  if (GetValue (abc->sequence_type) == 1) {
3787
 
    sequence_info->alphabet = nucleotide_alphabet;
 
4025
  if (StringCmp (sequence_info->alphabet, protein_alphabet) == 0) {
 
4026
    moltype = Seq_mol_aa;
 
4027
  } else {
3788
4028
    moltype = Seq_mol_na;
3789
 
  } else {
3790
 
    sequence_info->alphabet = protein_alphabet;
3791
 
    moltype = Seq_mol_aa;
3792
4029
  }
3793
4030
 
3794
 
  MemFree (sequence_info->missing);
3795
 
  sequence_info->missing = StringSave (missing);
3796
 
  MemFree (sequence_info->beginning_gap);
3797
 
  sequence_info->beginning_gap = StringSave (beginning_gap);
3798
 
  MemFree (sequence_info->middle_gap);
3799
 
  sequence_info->middle_gap = StringSave (middle_gap);
3800
 
  MemFree (sequence_info->end_gap);
3801
 
  sequence_info->end_gap = StringSave (end_gap);
3802
 
  MemFree (sequence_info->match);
3803
 
  sequence_info->match = StringSave (match);
3804
 
 
3805
4031
  error_list = NULL;
3806
4032
  rbd.fp = abc->fp;
3807
4033
  rbd.current_data = NULL;
3826
4052
  Remove (abc->form);
3827
4053
}
3828
4054
 
 
4055
 
3829
4056
/* Need cleanup for Alphabet Dialog to close File Pointer */
3830
4057
static void CleanupAlphabetDialog (GraphiC g, VoidPtr data)
3831
4058
{
3843
4070
{
3844
4071
  BaseFormPtr        bfp;
3845
4072
  ButtoN             b;
3846
 
  GrouP              c, h, g;
 
4073
  GrouP              c, h;
3847
4074
  AlphabetFormPtr    afp;
3848
4075
  WindoW             w;
3849
4076
 
3874
4101
 
3875
4102
  h = HiddenGroup (w, -1, 0, NULL);
3876
4103
  SetGroupSpacing (h, 10, 10);
 
4104
 
 
4105
  afp->aln_settings = AlnSettingsDlg (h, TRUE);  
 
4106
 
 
4107
  c = HiddenGroup (h, 4, 0, NULL);
 
4108
  b = DefaultButton (c, "Accept", DoReadAlignment);
 
4109
  SetObjectExtra (b, afp, NULL);
 
4110
  PushButton (c, "Cancel", StdCancelButtonProc);
 
4111
 
 
4112
  AlignObjects (ALIGN_CENTER, (HANDLE) afp->aln_settings, (HANDLE) c, NULL);
 
4113
  RealizeWindow (w);
 
4114
  Show (w);
 
4115
  Update ();
 
4116
}
 
4117
 
 
4118
extern void ReadAlignment (IteM i)
 
4119
{
 
4120
  BuildGetAlphabetDialog (i);
 
4121
 
 
4122
}
 
4123
 
 
4124
 
 
4125
typedef struct alnsettingsdlg {
 
4126
  DIALOG_MESSAGE_BLOCK
 
4127
  TexT missing;
 
4128
  TexT match;
 
4129
  TexT beginning_gap;
 
4130
  TexT middle_gap;
 
4131
  TexT end_gap;
 
4132
 
 
4133
  PopuP sequence_type;
 
4134
} AlnSettingsDlgData, PNTR AlnSettingsDlgPtr;
 
4135
 
 
4136
static CharPtr aln_settings_help = "\
 
4137
Beginning Gap: When some of the sequences in an \
 
4138
alignment are shorter or longer than others, beginning \
 
4139
gap characters are added to the beginning of the sequence \
 
4140
to maintain the correct spacing.  These will not appear \
 
4141
in your sequence file.\n\
 
4142
Middle Gap: These characters are used to maintain the spacing \
 
4143
inside an alignment.  These are not nucleotides and will \
 
4144
not appear as part of your sequence file.\n\
 
4145
End Gap: When some of the sequences in an alignment are shorter \
 
4146
or longer than others, end gap characters are added to the end \
 
4147
of the sequence to maintain the correct spacing.  These will \
 
4148
not appear in your sequence file.\n\
 
4149
Ambiguous/Unknown: These characters are used to represent \
 
4150
indeterminate/ambiguous nucleotides.  These will appear in your \
 
4151
sequence file as 'n'.\n\
 
4152
Match: These characters are used to indicate positions where \
 
4153
sequences are identical to the first sequence.  These will be \
 
4154
replaced by the actual characters from the first sequence.";
 
4155
 
 
4156
const char *nucleotide_alphabet = "ABCDGHKMRSTUVWYabcdghkmrstuvwy";
 
4157
const char *protein_alphabet = "ABCDEFGHIKLMPQRSTUVWXYZabcdefghiklmpqrstuvwxyz";
 
4158
 
 
4159
extern TSequenceInfoPtr GetDefaultSequenceInfo (void)
 
4160
{
 
4161
  TSequenceInfoPtr sequence_info = SequenceInfoNew();
 
4162
 
 
4163
  sequence_info->missing = MemFree (sequence_info->missing);
 
4164
  sequence_info->missing = StringSave ("?Nn");
 
4165
 
 
4166
  sequence_info->beginning_gap = MemFree (sequence_info->beginning_gap);
 
4167
  sequence_info->beginning_gap = StringSave ("-.Nn?");
 
4168
 
 
4169
  sequence_info->middle_gap = MemFree (sequence_info->middle_gap);
 
4170
  sequence_info->middle_gap = StringSave ("-.");
 
4171
 
 
4172
  sequence_info->end_gap = MemFree (sequence_info->end_gap);
 
4173
  sequence_info->end_gap = StringSave ("-.Nn?");
 
4174
 
 
4175
  sequence_info->match = MemFree (sequence_info->match);
 
4176
  sequence_info->match = StringSave (":");
 
4177
 
 
4178
  sequence_info->alphabet = nucleotide_alphabet;
 
4179
 
 
4180
  return sequence_info;
 
4181
}
 
4182
 
 
4183
static Pointer AlnSettingsDlgToData (DialoG d)
 
4184
{
 
4185
  AlnSettingsDlgPtr dlg;
 
4186
  TSequenceInfoPtr  sequence_info;
 
4187
 
 
4188
  dlg = (AlnSettingsDlgPtr) GetObjectExtra (d);
 
4189
  if (dlg == NULL) return NULL;
 
4190
 
 
4191
  sequence_info = SequenceInfoNew ();
 
4192
  if (sequence_info == NULL) return NULL;
 
4193
 
 
4194
  sequence_info->missing = MemFree (sequence_info->missing);
 
4195
  sequence_info->missing = SaveStringFromText (dlg->missing);
 
4196
 
 
4197
  sequence_info->beginning_gap = MemFree (sequence_info->beginning_gap);
 
4198
  sequence_info->beginning_gap = SaveStringFromText (dlg->beginning_gap);
 
4199
 
 
4200
  sequence_info->middle_gap = MemFree (sequence_info->middle_gap);
 
4201
  sequence_info->middle_gap = SaveStringFromText (dlg->middle_gap);
 
4202
 
 
4203
  sequence_info->end_gap = MemFree (sequence_info->end_gap);
 
4204
  sequence_info->end_gap = SaveStringFromText (dlg->end_gap);
 
4205
 
 
4206
  sequence_info->match = MemFree (sequence_info->match);
 
4207
  sequence_info->match = SaveStringFromText (dlg->match);
 
4208
 
 
4209
  if (dlg->sequence_type != NULL) 
 
4210
  {
 
4211
    if (GetValue (dlg->sequence_type) == 1) {
 
4212
      sequence_info->alphabet = nucleotide_alphabet;
 
4213
    } else {
 
4214
      sequence_info->alphabet = protein_alphabet;
 
4215
    }
 
4216
  }
 
4217
  else
 
4218
  {
 
4219
    sequence_info->alphabet = nucleotide_alphabet;
 
4220
  }
 
4221
 
 
4222
  return sequence_info;
 
4223
}
 
4224
 
 
4225
 
 
4226
static void DataToAlnSettingsDlg (DialoG d, Pointer data)
 
4227
{
 
4228
  AlnSettingsDlgPtr dlg;
 
4229
  TSequenceInfoPtr  sequence_info;
 
4230
 
 
4231
  dlg = (AlnSettingsDlgPtr) GetObjectExtra (d);
 
4232
  if (dlg == NULL) return;
 
4233
 
 
4234
  sequence_info = (TSequenceInfoPtr) data;
 
4235
 
 
4236
  if (sequence_info == NULL)
 
4237
  {
 
4238
    SetTitle (dlg->missing, "?Nn");
 
4239
    SetTitle (dlg->beginning_gap, "-.Nn?");
 
4240
    SetTitle (dlg->middle_gap, "-.");
 
4241
    SetTitle (dlg->end_gap, "-.Nn?");
 
4242
    SetTitle (dlg->match, ":");
 
4243
    if (dlg->sequence_type != NULL)
 
4244
    {
 
4245
      SetValue (dlg->sequence_type, 1);
 
4246
    }
 
4247
  }
 
4248
  else
 
4249
  {
 
4250
    SetTitle (dlg->missing, sequence_info->missing);
 
4251
    SetTitle (dlg->beginning_gap, sequence_info->beginning_gap);
 
4252
    SetTitle (dlg->middle_gap, sequence_info->middle_gap);
 
4253
    SetTitle (dlg->end_gap, sequence_info->end_gap);
 
4254
    SetTitle (dlg->match, sequence_info->match);
 
4255
 
 
4256
    if (dlg->sequence_type != NULL) 
 
4257
    {
 
4258
      if (StringCmp (sequence_info->alphabet, protein_alphabet) == 0) 
 
4259
      {
 
4260
        SetValue (dlg->sequence_type, 2);
 
4261
      }
 
4262
      else
 
4263
      {
 
4264
        SetValue (dlg->sequence_type, 1);
 
4265
      }
 
4266
    }
 
4267
  }
 
4268
}
 
4269
 
 
4270
 
 
4271
static ValNodePtr TestAlnSettingsDlg (DialoG d)
 
4272
{
 
4273
  ValNodePtr        err_list = NULL;
 
4274
  TSequenceInfoPtr  sequence_info;
 
4275
  CharPtr           cp;
 
4276
  CharPtr           fmt = "Character %c cannot appear in both %s and %s.";
 
4277
  CharPtr           err_str;
 
4278
  CharPtr           missing_name = "Ambiguous/Unknown";
 
4279
  CharPtr           middle_gap_name = "Middle Gap";
 
4280
  CharPtr           match_name = "Match";
 
4281
 
 
4282
  sequence_info = DialogToPointer (d);
 
4283
  if (sequence_info == NULL) return NULL;
 
4284
 
 
4285
  /* missing and match cannot appear in middle gap list */
 
4286
  cp = sequence_info->missing;
 
4287
  while (cp != NULL && *cp != 0)
 
4288
  {
 
4289
    if (StringChr (sequence_info->middle_gap, *cp)) 
 
4290
    {
 
4291
      err_str = (CharPtr) MemNew (sizeof (Char) * (StringLen (fmt) 
 
4292
                                                   + StringLen (missing_name)
 
4293
                                                   + StringLen (middle_gap_name)));
 
4294
      sprintf (err_str, fmt, *cp, missing_name, middle_gap_name);
 
4295
      ValNodeAddPointer (&err_list, 0, err_str);
 
4296
    }
 
4297
    cp++;
 
4298
  }
 
4299
 
 
4300
  cp = sequence_info->match;
 
4301
  while (cp != NULL && *cp != 0)
 
4302
  {
 
4303
    if (StringChr (sequence_info->middle_gap, *cp)) 
 
4304
    {
 
4305
      err_str = (CharPtr) MemNew (sizeof (Char) * (StringLen (fmt) 
 
4306
                                                   + StringLen (match_name)
 
4307
                                                   + StringLen (middle_gap_name)));
 
4308
      sprintf (err_str, fmt, *cp, match_name, middle_gap_name);
 
4309
      ValNodeAddPointer (&err_list, 0, err_str);
 
4310
    }
 
4311
    cp++;
 
4312
  }
 
4313
 
 
4314
  /* missing and match cannot share characters */
 
4315
  cp = sequence_info->missing;
 
4316
  while (cp != NULL && *cp != 0)
 
4317
  {
 
4318
    if (StringChr (sequence_info->match, *cp)) 
 
4319
    {
 
4320
      err_str = (CharPtr) MemNew (sizeof (Char) * (StringLen (fmt) 
 
4321
                                                   + StringLen (missing_name)
 
4322
                                                   + StringLen (match_name)));
 
4323
      sprintf (err_str, fmt, *cp, missing_name, match_name);
 
4324
      ValNodeAddPointer (&err_list, 0, err_str);
 
4325
    }
 
4326
    cp++;
 
4327
  }
 
4328
 
 
4329
  return err_list;
 
4330
}
 
4331
 
 
4332
 
 
4333
extern DialoG AlnSettingsDlg (GrouP h, Boolean allow_sequence_type)
 
4334
{
 
4335
  AlnSettingsDlgPtr dlg;
 
4336
  GrouP             p, g, p_msg;
3877
4337
  
3878
 
  g = HiddenGroup (h, 2, 4, NULL);
 
4338
  dlg = (AlnSettingsDlgPtr) MemNew (sizeof (AlnSettingsDlgData));
 
4339
  p = HiddenGroup (h, -1, 0, NULL);
 
4340
  SetObjectExtra (p, dlg, StdCleanupExtraProc);
 
4341
  SetGroupSpacing (p, 10, 10);
 
4342
 
 
4343
  dlg->dialog = (DialoG) p;
 
4344
  dlg->todialog = DataToAlnSettingsDlg;
 
4345
  dlg->fromdialog = AlnSettingsDlgToData;
 
4346
  dlg->testdialog = TestAlnSettingsDlg;
 
4347
 
 
4348
  g = HiddenGroup (p, 2, 0, NULL);
3879
4349
  StaticPrompt (g, "Ambiguous/Unknown", 0, dialogTextHeight, programFont, 'c');
3880
 
  afp->missing = DialogText (g, "?Nn", 5, NULL);
 
4350
  dlg->missing = DialogText (g, "?Nn", 5, NULL);
3881
4351
  StaticPrompt (g, "Match", 0, dialogTextHeight, programFont, 'c');
3882
 
  afp->match = DialogText (g, ".", 5, NULL);
 
4352
  dlg->match = DialogText (g, ".", 5, NULL);
3883
4353
  StaticPrompt (g, "Beginning Gap", 0, dialogTextHeight, programFont, 'c');
3884
 
  afp->beginning_gap = DialogText (g, "-.?nN", 5, NULL);
 
4354
  dlg->beginning_gap = DialogText (g, "-.?nN", 5, NULL);
3885
4355
  StaticPrompt (g, "Middle Gap", 0, dialogTextHeight, programFont, 'c');
3886
 
  afp->middle_gap = DialogText (g, "-", 5, NULL);
 
4356
  dlg->middle_gap = DialogText (g, "-", 5, NULL);
3887
4357
  StaticPrompt (g, "End Gap", 0, dialogTextHeight, programFont, 'c');
3888
 
  afp->end_gap = DialogText (g, "-.?nN", 5, NULL);
3889
 
  StaticPrompt (g, "Sequence Type", 0, dialogTextHeight, programFont, 'c');
3890
 
  afp->sequence_type = PopupList (g, TRUE, NULL);
3891
 
  PopupItem (afp->sequence_type, "Nucleotide");
3892
 
  PopupItem (afp->sequence_type, "Protein");
3893
 
  SetValue (afp->sequence_type, 1);
3894
 
 
3895
 
  c = HiddenGroup (h, 4, 0, NULL);
3896
 
  b = DefaultButton (c, "Accept", DoReadAlignment);
3897
 
  SetObjectExtra (b, afp, NULL);
3898
 
  PushButton (c, "Cancel", StdCancelButtonProc);
3899
 
 
3900
 
  AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
3901
 
  RealizeWindow (w);
3902
 
  Show (w);
3903
 
  Update ();
3904
 
}
3905
 
 
3906
 
extern void ReadAlignment (IteM i)
3907
 
{
3908
 
  BuildGetAlphabetDialog (i);
3909
 
 
 
4358
  dlg->end_gap = DialogText (g, "-.?nN", 5, NULL);
 
4359
  if (allow_sequence_type) {
 
4360
    StaticPrompt (g, "Sequence Type", 0, dialogTextHeight, programFont, 'c');
 
4361
    dlg->sequence_type = PopupList (g, TRUE, NULL);
 
4362
    PopupItem (dlg->sequence_type, "Nucleotide");
 
4363
    PopupItem (dlg->sequence_type, "Protein");
 
4364
    SetValue (dlg->sequence_type, 1);
 
4365
  }
 
4366
  
 
4367
  p_msg = MultiLinePrompt (p, aln_settings_help, 750, systemFont);
 
4368
 
 
4369
  AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) p_msg, NULL);
 
4370
  
 
4371
  return (DialoG) p;
3910
4372
}
3911
4373
 
3912
4374
 
4137
4599
  IteM           editseq;
4138
4600
  IteM           editsub;
4139
4601
  MenU           editupd;
4140
 
  MenU           editupd_idx;
 
4602
  MenU           editupd_idx = NULL;
4141
4603
  MenU           editext;
4142
4604
  MenU           editadd;
4143
4605
  Int2           mssgadd;
4144
4606
  Int2           mssgseq;
4145
4607
  Int2           mssgsub;
4146
4608
  Int2           mssgupd;
4147
 
  Int2           mssgupd_idx;
 
4609
  Int2           mssgupd_idx = 0;
4148
4610
  Int2           mssgext;
4149
4611
  ObjMgrDataPtr  omdp;
4150
4612
  SeqEntryPtr    sep;
4247
4709
                   (HANDLE) saveAsItem,
4248
4710
                   (HANDLE) copyItem,
4249
4711
                   (HANDLE) deleteItem,
4250
 
                   (HANDLE) displayfontItem,
4251
4712
                   (HANDLE) findItem,
4252
4713
                   (HANDLE) findFFItem,
4253
4714
                   (HANDLE) findGeneItem,
4281
4742
  Enable (parseFileItem);
4282
4743
  Enable (spellItem);
4283
4744
  Enable (addSecondaryItem);
 
4745
  Enable (displayfontItem);
4284
4746
  Disable (importItem);
4285
4747
  EnableFeaturesPerTarget ((BaseFormPtr) currentFormDataPtr);
4286
4748
  EnableAnalysisItems ((BaseFormPtr) currentFormDataPtr, FALSE);
4287
4749
  EnableEditSeqAlignAndSubItems ((BaseFormPtr) currentFormDataPtr);
4288
4750
}
4289
4751
 
 
4752
/*
4290
4753
static void TermSelectionActivateProc (WindoW w)
4291
4754
 
4292
4755
{
4340
4803
  Enable (saveUidItem);
4341
4804
  EnableAnalysisItems ((BaseFormPtr) currentFormDataPtr, TRUE);
4342
4805
}
 
4806
*/
4343
4807
 
4344
4808
static void SeqEditFormActivated (WindoW w)
4345
4809
 
4528
4992
                   (HANDLE) duplicateViewItem,
4529
4993
                   (HANDLE) importItem,
4530
4994
                   (HANDLE) exportItem,
4531
 
                   (HANDLE) displayfontItem,
4532
4995
                   (HANDLE) findItem,
4533
4996
                   (HANDLE) findFFItem,
4534
4997
                   (HANDLE) findGeneItem,
4571
5034
  Disable (legendItem);
4572
5035
  Disable (duplicateItem);
4573
5036
  Disable (addSecondaryItem);
 
5037
  Disable (displayfontItem);
4574
5038
  Disable (printItem);
4575
5039
  Disable (restoreItem);
4576
5040
  Disable (specialMenu);
4627
5091
static Boolean debug_fix_pub_equiv = FALSE;
4628
5092
static Boolean debug_fix_pub_set = FALSE;
4629
5093
 
 
5094
static Boolean log_mla_asn = FALSE;
 
5095
static Boolean log_mla_set = FALSE;
 
5096
 
 
5097
static ValNodePtr LookupAnArticleFuncNew (ValNodePtr oldpep, BoolPtr success)
 
5098
 
 
5099
{
 
5100
  CitArtPtr      cap = NULL;
 
5101
  ArticleIdPtr   ids;
 
5102
  MlaBackPtr     mbp;
 
5103
  MlaRequestPtr  mrp;
 
5104
  Int4           pmid = 0;
 
5105
  ValNodePtr     pub = NULL;
 
5106
  ValNodePtr     vnp;
 
5107
#ifdef OS_UNIX
 
5108
  CharPtr        str;
 
5109
#endif
 
5110
 
 
5111
  if (success != NULL) {
 
5112
    *success = FALSE;
 
5113
  }
 
5114
  if (oldpep == NULL) return NULL;
 
5115
 
 
5116
#ifdef OS_UNIX
 
5117
  if (! log_mla_set) {
 
5118
    str = (CharPtr) getenv ("LOG_MLA_ASN");
 
5119
    if (StringDoesHaveText (str)) {
 
5120
      if (StringICmp (str, "TRUE") == 0) {
 
5121
        log_mla_asn = TRUE;
 
5122
      }
 
5123
    }
 
5124
    log_mla_set = TRUE;
 
5125
  }
 
5126
#endif
 
5127
 
 
5128
  for (vnp = oldpep; vnp != NULL; vnp = vnp->next) {
 
5129
    if (vnp->choice == PUB_Article) {
 
5130
      cap = (CitArtPtr) vnp->data.ptrvalue;
 
5131
    } else if (vnp->choice == PUB_PMid) {
 
5132
      pmid = (Int4) vnp->data.intvalue;
 
5133
    }
 
5134
  }
 
5135
 
 
5136
  if (cap != NULL) {
 
5137
    mrp = Mla2CreateCitArtMatchRequest (cap);
 
5138
    if (mrp != NULL) {
 
5139
      if (log_mla_asn) {
 
5140
        LaunchAsnTextViewer ((Pointer) mrp, (AsnWriteFunc) MlaRequestAsnWrite, "citart match request");
 
5141
      }
 
5142
      mbp = Mla2SynchronousQuery (mrp);
 
5143
      mrp = MlaRequestFree (mrp);
 
5144
      if (mbp != NULL) {
 
5145
        if (log_mla_asn) {
 
5146
          LaunchAsnTextViewer ((Pointer) mbp, (AsnWriteFunc) MlaBackAsnWrite, "citart match result");
 
5147
        }
 
5148
        pmid = Mla2ExtractCitMatchReply (mbp);
 
5149
        mbp = MlaBackFree (mbp);
 
5150
      }
 
5151
    }
 
5152
  }
 
5153
 
 
5154
  if (pmid > 0) {
 
5155
    mrp = Mla2CreatePubFetchRequest (pmid);
 
5156
    if (mrp != NULL) {
 
5157
      if (log_mla_asn) {
 
5158
        LaunchAsnTextViewer ((Pointer) mrp, (AsnWriteFunc) MlaRequestAsnWrite, "get pub request");
 
5159
      }
 
5160
      mbp = Mla2SynchronousQuery (mrp);
 
5161
      mrp = MlaRequestFree (mrp);
 
5162
      if (mbp != NULL) {
 
5163
        if (log_mla_asn) {
 
5164
          LaunchAsnTextViewer ((Pointer) mbp, (AsnWriteFunc) MlaBackAsnWrite, "get pub result");
 
5165
        }
 
5166
        cap = Mla2ExtractPubFetchReply (mbp);
 
5167
        if (cap != NULL) {
 
5168
          if (log_mla_asn) {
 
5169
            LaunchAsnTextViewer ((Pointer) cap, (AsnWriteFunc) CitArtAsnWrite, "before");
 
5170
          }
 
5171
          ChangeCitArtMLAuthorsToSTD (cap);
 
5172
          if (log_mla_asn) {
 
5173
            LaunchAsnTextViewer ((Pointer) cap, (AsnWriteFunc) CitArtAsnWrite, "after");
 
5174
          }
 
5175
          for (ids = cap->ids; ids != NULL; ids = ids->next) {
 
5176
            if (ids->choice != ARTICLEID_PUBMED) continue;
 
5177
            if (ids->data.intvalue != pmid) {
 
5178
              Message (MSG_POSTERR, "CitArt ID %ld does not match PMID %ld",
 
5179
                       (long) ids->data.intvalue, (long) pmid);
 
5180
            }
 
5181
          }
 
5182
          pub = ValNodeAddPointer (NULL, PUB_Article, (Pointer) cap);
 
5183
          ValNodeAddInt (&pub, PUB_PMid, pmid);
 
5184
          if (success != NULL) {
 
5185
            *success = TRUE;
 
5186
          }
 
5187
        }
 
5188
        mbp = MlaBackFree (mbp);
 
5189
      }
 
5190
    }
 
5191
  }
 
5192
 
 
5193
  return pub;
 
5194
}
 
5195
 
4630
5196
static ValNodePtr LookupAnArticleFunc (ValNodePtr oldpep, BoolPtr success)
4631
5197
 
4632
5198
{
4735
5301
  return pub;
4736
5302
}
4737
5303
 
4738
 
static Boolean LookupJournalFunc (CharPtr title, size_t maxsize, Int1Ptr jtaType)
4739
 
 
4740
 
{
 
5304
static Boolean LookupJournalFuncNew (CharPtr title, size_t maxsize, Int1Ptr jtaType, ValNodePtr PNTR all_titlesP)
 
5305
 
 
5306
{
 
5307
  ValNodePtr       first = NULL;
 
5308
  ValNodePtr       last = NULL;
 
5309
  MlaBackPtr       mbp;
 
5310
  MlaRequestPtr    mrp;
 
5311
  CharPtr          str;
 
5312
  TitleMsgListPtr  tlp;
 
5313
  TitleMsgPtr      tmp;
 
5314
  ValNodePtr       ttl;
 
5315
  ValNodePtr       vnp;
 
5316
 
 
5317
  if (all_titlesP != NULL) {
 
5318
    *all_titlesP = NULL;
 
5319
  }
 
5320
  if (jtaType != NULL) {
 
5321
    *jtaType = 0;
 
5322
  }
 
5323
  if (StringHasNoText (title)) return FALSE;
 
5324
 
 
5325
#ifdef OS_UNIX
 
5326
  if (! log_mla_set) {
 
5327
    str = (CharPtr) getenv ("LOG_MLA_ASN");
 
5328
    if (StringDoesHaveText (str)) {
 
5329
      if (StringICmp (str, "TRUE") == 0) {
 
5330
        log_mla_asn = TRUE;
 
5331
      }
 
5332
    }
 
5333
    log_mla_set = TRUE;
 
5334
  }
 
5335
#endif
 
5336
 
 
5337
  WatchCursor ();
 
5338
  Update ();
 
5339
 
 
5340
  mrp = Mla2CreateJournalTitleRequest (title);
 
5341
  if (mrp != NULL) {
 
5342
  if (log_mla_asn) {
 
5343
    LaunchAsnTextViewer ((Pointer) mrp, (AsnWriteFunc) MlaRequestAsnWrite, "lookup journal request");
 
5344
  }
 
5345
    mbp = Mla2SynchronousQuery (mrp);
 
5346
    mrp = MlaRequestFree (mrp);
 
5347
    if (mbp != NULL) {
 
5348
      if (log_mla_asn) {
 
5349
        LaunchAsnTextViewer ((Pointer) mbp, (AsnWriteFunc) MlaBackAsnWrite, "lookup journal result");
 
5350
      }
 
5351
      tlp = Mla2ExtractJournalTitleReply (mbp);
 
5352
      if (tlp != NULL) {
 
5353
        for (tmp = tlp->titles; tmp != NULL; tmp = tmp->next) {
 
5354
          for (ttl = tmp->title; ttl != NULL; ttl = ttl->next) {
 
5355
            if (ttl->choice != Cit_title_iso_jta) continue;
 
5356
            str = (CharPtr) ttl->data.ptrvalue;
 
5357
            if (StringHasNoText (str)) continue;
 
5358
            vnp = ValNodeCopyStr (&last, ttl->choice, str);
 
5359
            if (first == NULL) {
 
5360
              first = vnp;
 
5361
            }
 
5362
            last = vnp;
 
5363
          }
 
5364
        }
 
5365
        if (all_titlesP != NULL) {
 
5366
          *all_titlesP = first;
 
5367
        }
 
5368
        if (first != NULL) {
 
5369
          str = (CharPtr) first->data.ptrvalue;
 
5370
          StringNCpy_0 (title, str, maxsize);
 
5371
          if (jtaType != NULL) {
 
5372
            *jtaType = (Int1) first->choice;
 
5373
          }
 
5374
        }
 
5375
        tlp = TitleMsgListFree (tlp);
 
5376
      }
 
5377
      mbp = MlaBackFree (mbp);
 
5378
    }
 
5379
  }
 
5380
 
 
5381
  ArrowCursor ();
 
5382
  Update ();
 
5383
 
 
5384
  return TRUE;
 
5385
}
 
5386
 
 
5387
static Boolean LookupJournalFunc (CharPtr title, size_t maxsize, Int1Ptr jtaType, ValNodePtr PNTR all_titlesP)
 
5388
 
 
5389
{
 
5390
  ValNodePtr  first = NULL;
 
5391
  Int4        i;
 
5392
  ValNodePtr  last = NULL;
4741
5393
  MonitorPtr  mon;
4742
5394
  Int4        num;
4743
5395
  Char        str [256];
4744
 
  CharPtr     titles [1];
4745
 
  Int1        types [1];
 
5396
  CharPtr     titles [20];
 
5397
  Int1        types [20];
 
5398
  ValNodePtr  vnp;
4746
5399
 
4747
5400
  WatchCursor ();
4748
5401
  mon = MonitorStrNewEx ("Lookup Journal", 40, FALSE);
4754
5407
      MonitorStrValue (mon, "Performing Lookup");
4755
5408
      Update ();
4756
5409
      num = MedArchGetTitles (titles, types, str, (Int1) Cit_title_jta,
4757
 
                              Cit_title_iso_jta, 1);
 
5410
                              Cit_title_iso_jta, 20);
 
5411
      if (num > 0 && all_titlesP != NULL) {
 
5412
        for (i = 0; i < num; i++) {
 
5413
          vnp = ValNodeCopyStr (&last, types [i], titles [i]);
 
5414
          if (first == NULL) {
 
5415
            first = vnp;
 
5416
          }
 
5417
          last = vnp;
 
5418
        }
 
5419
        *all_titlesP = first;
 
5420
      }
4758
5421
      if (num > 0 && types [0] == Cit_title_iso_jta) {
4759
5422
        StringNCpy_0 (title, titles [0], maxsize);
4760
5423
        if (jtaType != NULL) {
4761
5424
          *jtaType = types [0];
4762
5425
        }
4763
 
        MemFree (titles [0]);
 
5426
        for (i = 0; i < num; i++) {
 
5427
          MemFree (titles [i]);
 
5428
        }
4764
5429
      } else {
 
5430
        /*
4765
5431
        Message (MSG_OK, "Unable to match journal");
 
5432
        */
4766
5433
      }
4767
5434
    }
4768
5435
    MonitorStrValue (mon, "Closing MedArch");
4803
5470
 
4804
5471
{
4805
5472
  Boolean        dirty;
4806
 
  Uint2          j;
4807
 
  Uint2          num;
 
5473
  Uint4          j;
 
5474
  Uint4          num;
4808
5475
  ObjMgrPtr      omp;
4809
5476
  ObjMgrDataPtr  PNTR omdpp;
4810
5477
  ObjMgrDataPtr  tmp;
4888
5555
  Uint2              entityID;
4889
5556
  Boolean            freeEditors = FALSE;
4890
5557
  Int4               num_dirty;
4891
 
  Int2               j;
4892
 
  Int2               num;
 
5558
  Uint4              j;
 
5559
  Uint4              num;
4893
5560
  Boolean            numview;
4894
5561
  ObjMgrPtr          omp;
4895
5562
  ObjMgrDataPtr      PNTR omdpp;
5038
5705
static void EditSubmitBlock (BaseFormPtr bfp)
5039
5706
 
5040
5707
{
5041
 
  Boolean        handled;
 
5708
  Int2           handled;
5042
5709
  ObjMgrDataPtr  omdp;
5043
5710
 
5044
5711
  if (bfp != NULL && bfp->input_entityID != 0) {
5129
5796
  }
5130
5797
}
5131
5798
 
5132
 
extern SeqEntryPtr RestoreFromFile (CharPtr path);
5133
 
extern SeqEntryPtr RestoreFromFile (CharPtr path)
5134
 
 
5135
 
{
5136
 
  BioseqPtr     bsp;
5137
 
  BioseqSetPtr  bssp;
5138
 
  Pointer       dataptr;
5139
 
  Uint2         datatype;
5140
 
  Uint2         entityID;
5141
 
  SeqEntryPtr   rsult;
5142
 
  SeqEntryPtr   sep;
5143
 
 
5144
 
  rsult = NULL;
5145
 
  if (path != NULL && path [0] != '\0') {
5146
 
    dataptr = ObjMgrGenericAsnTextFileRead (path, &datatype, &entityID);
5147
 
    if (dataptr != NULL && entityID > 0) {
5148
 
      if (datatype == OBJ_SEQSUB || datatype == OBJ_SEQENTRY ||
5149
 
          datatype == OBJ_BIOSEQ || datatype == OBJ_BIOSEQSET) {
5150
 
        WatchCursor ();
5151
 
        sep = GetTopSeqEntryForEntityID (entityID);
5152
 
        if (sep == NULL) {
5153
 
          sep = SeqEntryNew ();
5154
 
          if (sep != NULL) {
5155
 
            if (datatype == OBJ_BIOSEQ) {
5156
 
              bsp = (BioseqPtr) dataptr;
5157
 
              sep->choice = 1;
5158
 
              sep->data.ptrvalue = bsp;
5159
 
              SeqMgrSeqEntry (SM_BIOSEQ, (Pointer) bsp, sep);
5160
 
            } else if (datatype == OBJ_BIOSEQSET) {
5161
 
              bssp = (BioseqSetPtr) dataptr;
5162
 
              sep->choice = 2;
5163
 
              sep->data.ptrvalue = bssp;
5164
 
              SeqMgrSeqEntry (SM_BIOSEQSET, (Pointer) bssp, sep);
5165
 
            } else {
5166
 
              sep = SeqEntryFree (sep);
5167
 
            }
5168
 
          }
5169
 
          sep = GetTopSeqEntryForEntityID (entityID);
5170
 
        }
5171
 
        if (sep != NULL) {
5172
 
          rsult = SeqEntryNew ();
5173
 
          if (rsult != NULL) {
5174
 
            rsult->choice = sep->choice;
5175
 
            rsult->data.ptrvalue = sep->data.ptrvalue;
5176
 
            sep->data.ptrvalue = NULL;
5177
 
            if (datatype == OBJ_SEQSUB) {
5178
 
              SeqSubmitFree ((SeqSubmitPtr) dataptr);
5179
 
            } else {
5180
 
              SeqEntryFree (sep);
5181
 
            }
5182
 
            /*Message (MSG_OK, "Call new object manager free function");*/
5183
 
          }
5184
 
        }
5185
 
        ArrowCursor ();
5186
 
      }
5187
 
      /*
5188
 
      ObjMgrDelete (entityID);
5189
 
      */
5190
 
    }
5191
 
  }
5192
 
  return rsult;
5193
 
}
5194
5799
 
5195
5800
static void RestoreSeqEntryProc (IteM i)
5196
5801
 
5197
5802
{
5198
 
  SeqEntryPtr  currsep;
5199
5803
  BaseFormPtr  bfp;
5200
 
  SeqEntryPtr  oldsep;
5201
5804
  Char         path [PATH_MAX];
 
5805
  Uint2        new_entityID;
5202
5806
 
5203
5807
#ifdef WIN_MAC
5204
5808
  bfp = currentFormDataPtr;
5207
5811
#endif
5208
5812
  if (bfp != NULL && bfp->input_itemtype == OBJ_BIOSEQ) {
5209
5813
    if (GetInputFileName (path, sizeof (path), "", "TEXT")) {
5210
 
      SeqEntrySetScope (NULL);
5211
 
      oldsep = RestoreFromFile (path);
5212
 
      currsep = GetTopSeqEntryForEntityID (bfp->input_entityID);
5213
 
      ReplaceSeqEntryWithSeqEntry (currsep, oldsep, TRUE);
5214
 
      SeqEntrySetScope (NULL);
5215
 
      bfp->input_entityID = ObjMgrGetEntityIDForChoice (currsep);
5216
 
      ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
5217
 
      ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
 
5814
      new_entityID = RestoreEntityIDFromFile (path, bfp->input_entityID);
 
5815
      if (new_entityID != 0) {
 
5816
        bfp->input_entityID = new_entityID;
 
5817
        ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
 
5818
        ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
 
5819
      }
5218
5820
    }
5219
5821
  }
5220
5822
}
5423
6025
  DialoG             prefs;
5424
6026
} PrefsForm, PNTR PrefsFormPtr;
5425
6027
 
 
6028
/*
5426
6029
static void AcceptPrefsProc (ButtoN b)
5427
6030
 
5428
6031
{
5460
6063
  EntrezPrefsFree (epp);
5461
6064
  Remove (pfp->form);
5462
6065
}
 
6066
*/
5463
6067
 
5464
6068
static void DefaultMessageProc (ForM f, Int2 mssg)
5465
6069
 
5477
6081
static void PreferencesProc (IteM i)
5478
6082
 
5479
6083
{
 
6084
  /*
5480
6085
  ButtoN          b;
5481
6086
  GrouP           c;
5482
6087
  EntrezPrefsPtr  epp;
5487
6092
  pfp = (PrefsFormPtr) MemNew (sizeof (PrefsForm));
5488
6093
  if (pfp == NULL) return;
5489
6094
  if (! EntrezIsInited ()) {
5490
 
    /* EntrezBioseqFetchEnable ("Sequin", TRUE); */
 
6095
    EntrezBioseqFetchEnable ("Sequin", TRUE);
5491
6096
    SequinEntrezInit ("Sequin", FALSE, NULL);
5492
6097
  }
5493
6098
  w = FixedWindow (-50, -33, -10, -10, "Preferences", StdCloseWindowProc);
5521
6126
  EntrezPrefsFree (epp);
5522
6127
  Show (w);
5523
6128
  Select (w);
 
6129
  */
5524
6130
}
5525
6131
 
5526
6132
void NetConfigureProc (IteM i)
5583
6189
 
5584
6190
{
5585
6191
  EnumFieldAssocPtr  ap;
 
6192
  Nlm_QualNameAssocPtr qp;
5586
6193
  BaseFormPtr        bfp;
5587
6194
  Uint1              biomol;
5588
6195
  BioSourcePtr       biop = NULL;
5710
6317
            biop = (BioSourcePtr) vnp->data.ptrvalue;
5711
6318
          }
5712
6319
          if (biop != NULL && title != NULL) {
5713
 
            for (ap = orgmod_subtype_alist; ap->name != NULL; ap++) {
5714
 
              MakeSearchStringFromAlist (str, ap->name);
5715
 
              AddToOrgMod (biop, title, str, (Int2) ap->value);
 
6320
            for (qp = current_orgmod_subtype_alist; qp->name != NULL; qp++) {
 
6321
              MakeSearchStringFromAlist (str, qp->name);
 
6322
              AddToOrgMod (biop, title, str, qp->value);
5716
6323
              ExciseString (title, str, "]");
5717
6324
            }
5718
 
            for (ap = subsource_subtype_alist; ap->name != NULL; ap++) {
5719
 
              MakeSearchStringFromAlist (str, ap->name);
5720
 
              AddToSubSource (biop, title, str, (Int2) ap->value);
 
6325
            for (qp = current_subsource_subtype_alist; qp->name != NULL; qp++) {
 
6326
              MakeSearchStringFromAlist (str, qp->name);
 
6327
              AddToSubSource (biop, title, str, qp->value);
5721
6328
              ExciseString (title, str, "]");
5722
6329
            }
5723
6330
            AddToOrgMod (biop, title, "[note=", 255);
6149
6756
      SetObjectExtra (i, bfp, NULL);
6150
6757
      i = CommandItem (sub, "Validate no Alignments/ A", ValSeqEntryProcNoAln);
6151
6758
      SetObjectExtra (i, bfp, NULL);
 
6759
      i = CommandItem (sub, "Validate check Inference", ValSeqEntryProcInfAccn);
 
6760
      SetObjectExtra (i, bfp, NULL);
6152
6761
      SeparatorItem (sub);
6153
6762
      i = CommandItem (sub, "Validate Inst", ValSeqEntryProcInst);
6154
6763
      SetObjectExtra (i, bfp, NULL);
6209
6818
    i = CommandItem (m, "Select Target...", DoChangeTarget);
6210
6819
    SetObjectExtra (i, bfp, NULL);
6211
6820
 
 
6821
    /*
6212
6822
    if (! indexerVersion) {
6213
6823
      m = PulldownMenu (w, "Options");
6214
6824
      sub = SubMenu (m, "Font Selection");
6215
6825
      i = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
6216
6826
      SetObjectExtra (i, bfp, NULL);
6217
 
      /*
6218
6827
      SeparatorItem (m);
6219
6828
      CreateLegendItem (m, bfp);
6220
 
      */
6221
6829
    }
 
6830
    */
6222
6831
 
6223
6832
/*#ifdef EXTRA_SERVICES*/
6224
6833
    if (extraServices) {
6228
6837
/*#endif*/
6229
6838
 
6230
6839
    m = PulldownMenu (w, "Misc");
 
6840
    /*
6231
6841
    CommandItem (m, "Style Manager...", StyleManagerProc);
6232
6842
    SeparatorItem (m);
 
6843
    */
6233
6844
    CommandItem (m, "Net Configure...", NetConfigureProc);
6234
6845
    if (useEntrez) {
6235
6846
      /*
6286
6897
    }
6287
6898
  }
6288
6899
}
6289
 
 
6290
 
static void TermListFormMenus (WindoW w)
6291
 
 
6292
 
{
6293
 
  BaseFormPtr  bfp;
6294
 
  MenU         m;
6295
 
  MenU         sub;
6296
 
 
6297
 
  bfp = (BaseFormPtr) GetObjectExtra (w);
6298
 
  if (bfp != NULL) {
6299
 
    m = PulldownMenu (w, "File");
6300
 
    AddAboutAndHelpMenuItems (m);
6301
 
    FormCommandItem (m, "Close", bfp, VIB_MSG_CLOSE);
6302
 
    SeparatorItem (m);
6303
 
    if (loadSaveUidListOK) {
6304
 
      FormCommandItem (m, "Import Uid List...", bfp, VIB_MSG_IMPORT);
6305
 
      FormCommandItem (m, "Export Uid List...", bfp, VIB_MSG_EXPORT);
6306
 
      SeparatorItem (m);
6307
 
    }
6308
 
    FormCommandItem (m, "Quit/Q", bfp, VIB_MSG_QUIT);
6309
 
 
6310
 
    m = PulldownMenu (w, "Edit");
6311
 
    FormCommandItem (m, CUT_MENU_ITEM, bfp, VIB_MSG_CUT);
6312
 
    FormCommandItem (m, COPY_MENU_ITEM, bfp, VIB_MSG_COPY);
6313
 
    FormCommandItem (m, PASTE_MENU_ITEM, bfp, VIB_MSG_PASTE);
6314
 
    FormCommandItem (m, CLEAR_MENU_ITEM, bfp, VIB_MSG_DELETE);
6315
 
 
6316
 
    m = PulldownMenu (w, "Options");
6317
 
    CommandItem (m, "Preferences...", PreferencesProc);
6318
 
    SeparatorItem (m);
6319
 
    sub = SubMenu (m, "Query Style");
6320
 
    CreateQueryTypeChoice (sub, bfp);
6321
 
    CreateClearUnusedItem (m, bfp);
6322
 
 
6323
 
    m = PulldownMenu (w, "Misc");
6324
 
    CommandItem (m, "Style Manager...", StyleManagerProc);
6325
 
/*
6326
 
#ifndef WIN16
6327
 
    if (BiostrucAvail ()) {
6328
 
      SeparatorItem (m);
6329
 
      CommandItem (m, "Cn3D Window...", Cn3DWinShowProc);
6330
 
    }
6331
 
#endif
6332
 
*/
6333
 
    SeparatorItem (m);
6334
 
    VSMAddToMenu (m, VSM_DESKTOP);
6335
 
  }
6336
 
}
6337
 
 
6338
 
static void DocSumFormMenus (WindoW w)
6339
 
 
6340
 
{
6341
 
  BaseFormPtr  bfp;
6342
 
  ChoicE       c;
6343
 
  IteM         i;
6344
 
  MenU         m;
6345
 
  MenU         sub;
6346
 
 
6347
 
  bfp = (BaseFormPtr) GetObjectExtra (w);
6348
 
  if (bfp != NULL) {
6349
 
    m = PulldownMenu (w, "File");
6350
 
    FormCommandItem (m, "Close", bfp, VIB_MSG_CLOSE);
6351
 
    SeparatorItem (m);
6352
 
    FormCommandItem (m, "Import FASTA or Uid List...", bfp, VIB_MSG_IMPORT);
6353
 
    FormCommandItem (m, "Export...", bfp, VIB_MSG_EXPORT);
6354
 
    SeparatorItem (m);
6355
 
    /*
6356
 
    FormCommandItem (m, "Save", bfp, VIB_MSG_SAVE);
6357
 
    FormCommandItem (m, "Save As...", bfp, VIB_MSG_SAVE_AS);
6358
 
    SeparatorItem (m);
6359
 
    */
6360
 
    FormCommandItem (m, "Print...", bfp, VIB_MSG_PRINT);
6361
 
 
6362
 
    m = PulldownMenu (w, "Edit");
6363
 
    FormCommandItem (m, COPY_MENU_ITEM, bfp, VIB_MSG_COPY);
6364
 
 
6365
 
    m = PulldownMenu (w, "Options");
6366
 
    CommandItem (m, "Preferences...", PreferencesProc);
6367
 
    SeparatorItem (m);
6368
 
    sub = SubMenu (m, "Font Selection");
6369
 
    i = CommandItem (sub, "DocSum Font...", DocSumFontChangeProc);
6370
 
    SetObjectExtra (i, bfp, NULL);
6371
 
    /*
6372
 
    i = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
6373
 
    SetObjectExtra (i, bfp, NULL);
6374
 
    */
6375
 
    SeparatorItem (m);
6376
 
    sub = SubMenu (m, "Neighbor Policy");
6377
 
    c = CreateNeighborDelayChoice (sub, bfp);
6378
 
    SetValue (c, 2); /* UseDelayedNeighbor */
6379
 
    SeparatorItem (m);
6380
 
    LoadDocsumOptionsMenu (m);
6381
 
    seqviewprocs.alignWithChecked = entrezglobals.alignWithChecked;
6382
 
    seqviewprocs.alignDefault = entrezglobals.alignDefault;
6383
 
 
6384
 
    CreateAnalysisMenu (w, bfp, FALSE, TRUE);
6385
 
  }
6386
 
}
6387
6900
#endif
6388
6901
 
6389
6902
static void GetRidCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
6429
6942
  SeqEntryExplore (sep, NULL, GetRidCallback);
6430
6943
}
6431
6944
 
6432
 
typedef struct findgenedata {
6433
 
  GeneRefPtr  grp;
6434
 
  SeqFeatPtr  sfp;
6435
 
  SeqLocPtr   slp;
6436
 
  Int4        min;
6437
 
} FindGeneData, PNTR FindGenePtr;
6438
 
 
6439
 
typedef struct tripletdata {
6440
 
    ObjMgrPtr  omp;
6441
 
        Uint2      entityID;
6442
 
        Uint4      itemID;
6443
 
        Uint2      itemtype;
6444
 
        Pointer    lookfor;
6445
 
    Char       label [81];
6446
 
} TripletData, PNTR TripletDataPtr;
6447
 
 
6448
 
static Boolean FindOverlappingGeneFunc (GatherContextPtr gcp)
6449
 
 
6450
 
{
6451
 
  Int4         diff;
6452
 
  FindGenePtr  fgp;
6453
 
  GeneRefPtr   grp;
6454
 
  SeqFeatPtr   sfp;
6455
 
 
6456
 
  if (gcp == NULL) return TRUE;
6457
 
 
6458
 
  fgp = (FindGenePtr) gcp->userdata;
6459
 
  if (fgp == NULL) return TRUE;
6460
 
  if (gcp->thistype == OBJ_SEQFEAT) {
6461
 
    sfp = (SeqFeatPtr) gcp->thisitem;
6462
 
    if (sfp != NULL && sfp->data.choice == SEQFEAT_GENE) {
6463
 
      grp = (GeneRefPtr) sfp->data.value.ptrvalue;
6464
 
      if (grp != NULL) {
6465
 
        diff = SeqLocAinB (fgp->slp, sfp->location);
6466
 
        if (diff >= 0) {
6467
 
          if (diff < fgp->min) {
6468
 
            fgp->min = diff;
6469
 
            fgp->grp = grp;
6470
 
            fgp->sfp = sfp;
6471
 
          }
6472
 
        }
6473
 
      }
6474
 
    }
6475
 
  }
6476
 
  return TRUE;
6477
 
}
6478
 
 
6479
 
static Boolean FindTripletItem (GatherContextPtr gcp)
6480
 
 
6481
 
{
6482
 
  ObjMgrTypePtr   omtp;
6483
 
  TripletDataPtr  tdp;
6484
 
 
6485
 
  tdp = (TripletDataPtr) gcp->userdata;
6486
 
  if (tdp != NULL && gcp->thisitem == tdp->lookfor) {
6487
 
    tdp->entityID = gcp->entityID;
6488
 
    tdp->itemID = gcp->itemID;
6489
 
    tdp->itemtype = gcp->thistype;
6490
 
    omtp = ObjMgrTypeFind (tdp->omp, gcp->thistype, NULL, NULL);
6491
 
    if (omtp != NULL) {
6492
 
      if (omtp->labelfunc != NULL) {
6493
 
        (*(omtp->labelfunc)) (gcp->thisitem, tdp->label, 80, OM_LABEL_CONTENT);
6494
 
      }
6495
 
    }
6496
 
  }
6497
 
  return TRUE;
6498
 
}
6499
 
 
6500
 
static CharPtr deleteCdsMsg =
6501
 
"In addition to deleting the CDS feature, you should probably\n\
6502
 
delete the protein product, which is a separate data element in\n\
6503
 
the record.  You will be asked about this in a subsequent message.\n\
6504
 
Do you wish to continue deleting the CDS?";
6505
 
 
6506
6945
static CharPtr deleteProtMsg =
6507
6946
"The protein product of a CDS (shown in the /translation qualifier)\n\
6508
6947
is actually a separate data element in the record.  Unless explicitly\n\
6509
 
deleted, it will remain hidden in the record after you delete the CDS.\n\
6510
 
Do you wish to delete the protein product";
 
6948
deleted, it will remain hidden in the record after you delete the CDS.";
6511
6949
 
6512
6950
static CharPtr deleteGeneMsg =
6513
6951
"The /gene qualifier is generated from an overlapping gene feature.\n\
6514
 
If you delete a CDS you may also want to delete this separate gene.\n\
6515
 
Do you wish to delete the overlapping gene";
6516
 
 
6517
 
static CharPtr deleteMrnaMsg =
6518
 
"In addition to deleting the mRNA feature, you should probably\n\
6519
 
delete the cDNA and protein products, which are separate data\n\
6520
 
 elements in the record.  Do you wish to continue deleting the mRNA?";
 
6952
If you delete a CDS you may also want to delete this separate gene.";
6521
6953
 
6522
6954
static CharPtr deleteCdnaMsg =
6523
6955
"The cDNA product of an mRNA is actually a separate data element\n\
6524
6956
in the record.  Unless explicitly deleted, it will remain hidden\n\
6525
 
in the record after you delete the mRNA.  Do you wish to delete\n\
6526
 
the cDNA product";
 
6957
in the record after you delete the mRNA.";
 
6958
 
 
6959
typedef struct deletecdsoptions {
 
6960
  Boolean delete_feature;
 
6961
  Boolean delete_gene;
 
6962
  Boolean delete_cdna;
 
6963
  Boolean delete_protein;
 
6964
} DeleteCDSOptionsData, PNTR DeleteCDSOptionsPtr;
 
6965
 
 
6966
static void GetDeleteCDSOptions (DeleteCDSOptionsPtr dcop)
 
6967
{
 
6968
  WindoW w;
 
6969
  GrouP  h, g, c;
 
6970
  ButtoN b;
 
6971
  ModalAcceptCancelData acd;
 
6972
  ButtoN delete_gene = NULL;
 
6973
  ButtoN delete_cdna = NULL;
 
6974
  ButtoN delete_protein = NULL;
 
6975
  
 
6976
  if (dcop == NULL) return;
 
6977
  if (!dcop->delete_gene
 
6978
      && !dcop->delete_cdna
 
6979
      && !dcop->delete_protein) {
 
6980
    return;
 
6981
  }
 
6982
  
 
6983
  acd.accepted = FALSE;
 
6984
  acd.cancelled = FALSE;
 
6985
  
 
6986
  w = ModalWindow(-20, -13, -10, -10, NULL);
 
6987
  h = HiddenGroup (w, -1, 0, NULL);
 
6988
  SetGroupSpacing (h, 10, 10);
 
6989
 
 
6990
  g = HiddenGroup (h, 2, 0, NULL);
 
6991
  SetGroupSpacing (g, 10, 10);
 
6992
  if (dcop->delete_gene) {
 
6993
    delete_gene = CheckBox (g, "Delete overlapping gene", NULL);
 
6994
    MultiLinePrompt (g, deleteGeneMsg, 30 * stdCharWidth, systemFont);
 
6995
  }
 
6996
  
 
6997
  if (dcop->delete_cdna) {
 
6998
    delete_cdna = CheckBox (g, "Delete cDNA", NULL);
 
6999
    SetStatus (delete_cdna, TRUE);
 
7000
    MultiLinePrompt (g, deleteCdnaMsg, 30 * stdCharWidth, systemFont);
 
7001
  }
 
7002
 
 
7003
  if (dcop->delete_protein) {
 
7004
    delete_protein = CheckBox (g, "Delete protein product", NULL);
 
7005
    SetStatus (delete_protein, TRUE);
 
7006
    MultiLinePrompt (g, deleteProtMsg, 30 * stdCharWidth, systemFont);
 
7007
  }
 
7008
 
 
7009
  c = HiddenGroup (h, 3, 0, NULL);
 
7010
  SetGroupSpacing (c, 10, 10);
 
7011
  b = PushButton (c, "Accept", ModalAcceptButton);
 
7012
  SetObjectExtra (b, &acd, NULL);
 
7013
  b = PushButton (c, "Cancel", ModalCancelButton);
 
7014
  SetObjectExtra (b, &acd, NULL);
 
7015
  AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
 
7016
  
 
7017
  Show(w); 
 
7018
  Select (w);
 
7019
  while (!acd.accepted && ! acd.cancelled)
 
7020
  {
 
7021
    ProcessExternalEvent ();
 
7022
    Update ();
 
7023
  }
 
7024
  ProcessAnEvent ();
 
7025
  Remove (w);
 
7026
  if (acd.accepted)
 
7027
  {
 
7028
    dcop->delete_feature = TRUE;
 
7029
    dcop->delete_gene = delete_gene == NULL ? FALSE : GetStatus (delete_gene);
 
7030
    dcop->delete_cdna = delete_cdna == NULL ? FALSE : GetStatus (delete_cdna);
 
7031
    dcop->delete_protein = delete_protein == NULL ? FALSE : GetStatus (delete_protein);
 
7032
  }
 
7033
  else
 
7034
  {
 
7035
    dcop->delete_feature = FALSE;
 
7036
    dcop->delete_gene = FALSE;
 
7037
    dcop->delete_cdna = FALSE;
 
7038
    dcop->delete_protein = FALSE;
 
7039
  }
 
7040
}
6527
7041
 
6528
7042
static Boolean DeleteSelectedFeatureOrDescriptor (GatherContextPtr gcp)
6529
7043
 
6530
7044
{
6531
 
  MsgAnswer       ans;
6532
7045
  BioseqPtr       bsp;
6533
7046
  BioseqPtr       cdna;
6534
 
  FindGeneData    fgd;
6535
7047
  Uint2           entityID;
6536
7048
  SeqFeatPtr      gene;
6537
 
  GatherScope     gs;
6538
7049
  Uint4           itemID;
6539
7050
  Uint2           itemtype;
6540
 
  SeqFeatPtr      mrna;
6541
7051
  BioseqSetPtr    nps;
6542
 
  ObjMgrPtr       omp;
6543
 
  OMProcControl   ompc;
6544
7052
  BioseqSetPtr    parent;
6545
 
  SeqEntryPtr     scope;
6546
7053
  SeqFeatPtr      sfp;
6547
7054
  SeqIdPtr        sip;
6548
 
  TripletData     td;
6549
 
  SeqFeatXrefPtr  xref;
 
7055
  DeleteCDSOptionsData dcod;
 
7056
  SeqMgrFeatContext    fcontext;
 
7057
  ObjValNodePtr        ovn;
 
7058
  SeqDescrPtr          sdp;
6550
7059
#ifdef USE_SMARTNET
6551
 
  SeqDescrPtr     sdp;
6552
7060
  UserObjectPtr   uop;
6553
7061
#endif
6554
7062
 
 
7063
  if (gcp->thistype != OBJ_SEQDESC && gcp->thistype != OBJ_SEQFEAT) {
 
7064
    /* This function should only handle descriptors and features */
 
7065
    return FALSE;
 
7066
  } else if (gcp->thisitem == NULL) {
 
7067
    return TRUE;
 
7068
  }
6555
7069
 
6556
7070
#ifdef USE_SMARTNET
6557
7071
  /* This code will prevent from deletion SMART User Object */
6569
7083
  }
6570
7084
#endif
6571
7085
 
6572
 
  sfp = NULL;
 
7086
  /* delete the descriptor */
 
7087
  if (gcp->thistype == OBJ_SEQDESC) {
 
7088
    sdp = (SeqDescrPtr) gcp->thisitem;
 
7089
    if (sdp != NULL && sdp->extended != 0) {
 
7090
      ovn = (ObjValNodePtr) sdp;
 
7091
      ovn->idx.deleteme = TRUE;
 
7092
      return TRUE;
 
7093
    } else {
 
7094
      return FALSE;
 
7095
    }
 
7096
  }
 
7097
 
 
7098
  /* because it wasn't a descriptor, this must be a feature */
 
7099
  sfp = (SeqFeatPtr) gcp->thisitem;
6573
7100
  bsp = NULL;
6574
7101
  gene = NULL;
6575
 
  mrna = NULL;
6576
7102
  cdna = NULL;
6577
7103
  nps = NULL;
6578
7104
  entityID = gcp->entityID;
6579
7105
  itemID = gcp->itemID;
6580
7106
  itemtype = gcp->thistype;
6581
 
  omp = ObjMgrGet ();
6582
 
  scope = GetBestTopParentForItemID (entityID, itemID, itemtype);
6583
 
  if (gcp->thistype == OBJ_SEQFEAT) {
6584
 
    sfp = (SeqFeatPtr) gcp->thisitem;
6585
 
    if (sfp != NULL && sfp->idx.subtype == FEATDEF_mRNA && sfp->product != NULL) {
6586
 
      mrna = sfp;
6587
 
      sip = SeqLocId (mrna->product);
6588
 
      if (sip != NULL) {
6589
 
        cdna = BioseqFind (sip);
6590
 
        if (cdna != NULL) {
6591
 
          if (cdna->idx.parenttype == OBJ_BIOSEQSET) {
6592
 
            parent = (BioseqSetPtr) cdna->idx.parentptr;
6593
 
            while (parent != NULL) {
6594
 
              if (parent->_class == BioseqseqSet_class_nuc_prot) {
6595
 
                nps = parent;
6596
 
              }
6597
 
              if (parent->idx.parenttype == OBJ_BIOSEQSET) {
6598
 
                parent = (BioseqSetPtr) parent->idx.parentptr;
6599
 
              } else {
6600
 
                parent = NULL;
6601
 
              }
 
7107
 
 
7108
  /* When deleting some features, there are other objects that the user may wish to
 
7109
   * remove at the same time.
 
7110
   * When removing a coding region, the user may wish to also do the following:
 
7111
   *   1) Remove the overlapping gene
 
7112
   *   2) Remove the product protein
 
7113
   * When removing an mRNA, the user may wish to also do the following:
 
7114
   *   1) Remove the cDNA product
 
7115
   *   2) Remove the nucprotset parent
 
7116
   */
 
7117
  if (sfp->idx.subtype == FEATDEF_mRNA && sfp->product != NULL) {
 
7118
    sip = SeqLocId (sfp->product);
 
7119
    if (sip != NULL) {
 
7120
      cdna = BioseqFind (sip);
 
7121
      if (cdna != NULL) {
 
7122
        if (cdna->idx.parenttype == OBJ_BIOSEQSET) {
 
7123
          parent = (BioseqSetPtr) cdna->idx.parentptr;
 
7124
          while (parent != NULL) {
 
7125
            if (parent->_class == BioseqseqSet_class_nuc_prot) {
 
7126
              nps = parent;
 
7127
            }
 
7128
            if (parent->idx.parenttype == OBJ_BIOSEQSET) {
 
7129
              parent = (BioseqSetPtr) parent->idx.parentptr;
 
7130
            } else {
 
7131
              parent = NULL;
6602
7132
            }
6603
7133
          }
6604
7134
        }
6605
7135
      }
6606
7136
    }
6607
 
    if (sfp != NULL && sfp->data.choice != SEQFEAT_CDREGION) {
6608
 
      sfp = NULL;
6609
 
    }
6610
 
  }
6611
 
  if (sfp != NULL) {
 
7137
  } else if (sfp->idx.subtype == FEATDEF_CDS) {
6612
7138
    if (sfp->product != NULL) {
6613
7139
      sip = SeqLocId (sfp->product);
6614
7140
      if (sip != NULL) {
6615
7141
        bsp = BioseqFind (sip);
6616
7142
      }
6617
7143
    }
6618
 
    xref = sfp->xref;
6619
 
    while (xref != NULL && xref->data.choice != SEQFEAT_GENE) {
6620
 
      xref = xref->next;
6621
 
    }
6622
 
    if (xref == NULL) {
6623
 
      MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
6624
 
      gs.seglevels = 1;
6625
 
      gs.get_feats_location = TRUE;
6626
 
      MemSet ((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
6627
 
      gs.ignore[OBJ_BIOSEQ] = FALSE;
6628
 
      gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
6629
 
      gs.ignore[OBJ_SEQFEAT] = FALSE;
6630
 
      gs.ignore[OBJ_SEQANNOT] = FALSE;
6631
 
      gs.scope = scope;
6632
 
      fgd.min = INT4_MAX;
6633
 
      fgd.grp = NULL;
6634
 
      fgd.sfp = NULL;
6635
 
      fgd.slp = sfp->location;
6636
 
      GatherEntity (entityID, (Pointer) &fgd, FindOverlappingGeneFunc, &gs);
6637
 
      if (fgd.sfp != NULL) {
6638
 
        gene = fgd.sfp;
6639
 
      }
 
7144
    if (SeqMgrGetGeneXref(sfp) == NULL) {
 
7145
      gene = SeqMgrGetOverlappingGene (sfp->location, &fcontext);
6640
7146
    }
6641
7147
  }
 
7148
 
 
7149
  MemSet (&dcod, 0, sizeof (dcod));
6642
7150
  if (sfp != NULL) {
6643
 
    ans = Message (MSG_OKC, "%s", deleteCdsMsg);
6644
 
    if (ans == ANS_CANCEL) {
6645
 
      return TRUE;
6646
 
    }
6647
 
  }
6648
 
  if (nps != NULL || cdna != NULL) {
6649
 
    ans = Message (MSG_OKC, "%s", deleteMrnaMsg);
6650
 
    if (ans == ANS_CANCEL) {
6651
 
      return TRUE;
6652
 
    }
6653
 
  }
6654
 
  MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
6655
 
  ompc.do_not_reload_from_cache = TRUE;
6656
 
  ompc.input_entityID = entityID;
6657
 
  ompc.input_itemID = itemID;
6658
 
  ompc.input_itemtype = itemtype;
6659
 
  if (! DetachDataForProc (&ompc, FALSE)) {
6660
 
    Message (MSG_ERROR, "DetachDataForProc failed");
6661
 
  }
6662
 
  if (nps != NULL || cdna != NULL) {
6663
 
    ans = Message (MSG_YN, "%s", deleteCdnaMsg, td.label);
6664
 
    if (ans == ANS_YES) {
6665
 
      if (nps != NULL) {
6666
 
        nps->idx.deleteme = TRUE;
6667
 
      } else if (cdna != NULL) {
6668
 
        cdna->idx.deleteme = TRUE;
6669
 
      }
6670
 
    }
 
7151
    dcod.delete_feature = TRUE;
 
7152
  }
 
7153
  if (nps != NULL || cdna != NULL) {
 
7154
    dcod.delete_cdna = TRUE;
6671
7155
  }
6672
7156
  if (bsp != NULL) {
6673
 
    td.omp = omp;
6674
 
    td.entityID = 0;
6675
 
    td.itemID = 0;
6676
 
    td.itemtype = 0;
6677
 
    td.lookfor = (Pointer) bsp;
6678
 
    td.label [0] = '\0';
6679
 
    MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
6680
 
    gs.seglevels = 1;
6681
 
    gs.get_feats_location = TRUE;
6682
 
    MemSet ((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
6683
 
    gs.ignore[OBJ_BIOSEQ] = FALSE;
6684
 
    gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
6685
 
    gs.ignore[OBJ_SEQFEAT] = FALSE;
6686
 
    gs.ignore[OBJ_SEQANNOT] = FALSE;
6687
 
    gs.scope = scope;
6688
 
    GatherEntity (entityID, (Pointer) (&td), FindTripletItem, &gs);
6689
 
    if (td.entityID > 0 && td.itemID > 0 && td.itemtype > 0) {
6690
 
      ans = Message (MSG_YN, "%s (%s)?", deleteProtMsg, td.label);
6691
 
      if (ans == ANS_YES) {
6692
 
        MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
6693
 
        ompc.do_not_reload_from_cache = TRUE;
6694
 
        ompc.input_entityID = td.entityID;
6695
 
        ompc.input_itemID = td.itemID;
6696
 
        ompc.input_itemtype = td.itemtype;
6697
 
        if (! DetachDataForProc (&ompc, FALSE)) {
6698
 
          Message (MSG_ERROR, "DetachDataForProc failed");
6699
 
        }
6700
 
      }
6701
 
    }
 
7157
    dcod.delete_protein = TRUE;
6702
7158
  }
 
7159
 
6703
7160
  if (gene != NULL) {
6704
 
    td.omp = omp;
6705
 
    td.entityID = 0;
6706
 
    td.itemID = 0;
6707
 
    td.itemtype = 0;
6708
 
    td.lookfor = (Pointer) gene;
6709
 
    td.label [0] = '\0';
6710
 
    MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
6711
 
    gs.seglevels = 1;
6712
 
    gs.get_feats_location = TRUE;
6713
 
    MemSet ((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
6714
 
    gs.ignore[OBJ_BIOSEQ] = FALSE;
6715
 
    gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
6716
 
    gs.ignore[OBJ_SEQFEAT] = FALSE;
6717
 
    gs.ignore[OBJ_SEQANNOT] = FALSE;
6718
 
    gs.scope = scope;
6719
 
    GatherEntity (entityID, (Pointer) (&td), FindTripletItem, &gs);
6720
 
    if (td.entityID > 0 && td.itemID > 0 && td.itemtype > 0) {
6721
 
      ans = Message (MSG_YN, "%s (%s)?", deleteGeneMsg, td.label);
6722
 
      if (ans == ANS_YES) {
6723
 
        MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
6724
 
        ompc.do_not_reload_from_cache = TRUE;
6725
 
        ompc.input_entityID = td.entityID;
6726
 
        ompc.input_itemID = td.itemID;
6727
 
        ompc.input_itemtype = td.itemtype;
6728
 
        if (! DetachDataForProc (&ompc, FALSE)) {
6729
 
          Message (MSG_ERROR, "DetachDataForProc failed");
6730
 
        }
6731
 
      }
 
7161
    dcod.delete_gene = TRUE;
 
7162
  }
 
7163
 
 
7164
  GetDeleteCDSOptions (&dcod);
 
7165
  if (!dcod.delete_feature) {
 
7166
    return TRUE;
 
7167
  }
 
7168
 
 
7169
 
 
7170
  /* delete the feature */
 
7171
  sfp->idx.deleteme = TRUE;
 
7172
 
 
7173
  /* delete cdna product */
 
7174
  if (dcod.delete_cdna) {
 
7175
    if (nps != NULL) {
 
7176
      nps->idx.deleteme = TRUE;
 
7177
    } else if (cdna != NULL) {
 
7178
      cdna->idx.deleteme = TRUE;
6732
7179
    }
6733
7180
  }
 
7181
 
 
7182
  /* delete protein product */
 
7183
  if (bsp != NULL && dcod.delete_protein) {
 
7184
    bsp->idx.deleteme = TRUE;
 
7185
  }
 
7186
 
 
7187
  /* delete overlapping gene */
 
7188
  if (gene != NULL && dcod.delete_gene) {
 
7189
    gene->idx.deleteme = TRUE;
 
7190
  }
 
7191
 
 
7192
  /* Note - delete marked objects is called by the calling function */
 
7193
 
6734
7194
  return TRUE;
6735
7195
}
6736
7196
 
6990
7450
  if (bfp != NULL) {
6991
7451
    switch (mssg) {
6992
7452
      case VIB_MSG_SAVE :
6993
 
        SaveSeqSubmitProc (bfp, FALSE);
 
7453
        if (FixSpecialCharacters (bfp->input_entityID))
 
7454
        {
 
7455
          SaveSeqSubmitProc (bfp, FALSE);
 
7456
        }
6994
7457
        break;
6995
7458
      case VIB_MSG_SAVE_AS :
6996
 
        SaveSeqSubmitProc (bfp, TRUE);
 
7459
        if (FixSpecialCharacters (bfp->input_entityID))
 
7460
        {
 
7461
          SaveSeqSubmitProc (bfp, TRUE);
 
7462
        }
6997
7463
        break;
6998
7464
      case VIB_MSG_CLOSE :
6999
7465
        CloseProc (bfp);
7213
7679
/* from salfiles.c */
7214
7680
static Int4 AccessionToGi (CharPtr string, CharPtr program)
7215
7681
{
 
7682
   /*
7216
7683
   CharPtr str;
7217
7684
   LinkSetPtr lsp;
7218
7685
   Int4 gi;
7232
7699
   LinkSetFree (lsp);
7233
7700
   EntrezFini ();
7234
7701
   return gi;
 
7702
   */
 
7703
   return 0;
7235
7704
}
7236
7705
 
7237
7706
static SeqEntryPtr LIBCALLBACK SeqEdDownload (CharPtr program, CharPtr accession,
7239
7708
 
7240
7709
{
7241
7710
  BioseqPtr    bsp;
 
7711
  SeqEntryPtr  sep = NULL;
 
7712
  SeqId        sid;
 
7713
  /*
7242
7714
  LinkSetPtr   lsp;
7243
 
  SeqEntryPtr  sep = NULL;
7244
7715
  Int2         seqtype;
7245
 
  SeqId        sid;
7246
7716
  Char         str [64];
 
7717
  */
7247
7718
 
7248
7719
  if (is_new != NULL) {
7249
7720
     *is_new = TRUE;
7267
7738
    return sep;
7268
7739
  }
7269
7740
/********************/
 
7741
  /*
7270
7742
  EntrezInit (program, TRUE, NULL);
7271
7743
  if (uid==0 && ! StringHasNoText (accession)) {
7272
7744
    if (is_na) {
7298
7770
  }
7299
7771
  EntrezFini ();
7300
7772
  return sep;
 
7773
  */
 
7774
  return NULL;
7301
7775
}
7302
7776
 
7303
7777
static void SequinStdEditorFormMessage (ForM f, Int2 mssg)
7338
7812
  SendHelpScrollMessage (helpForm, heading, section);
7339
7813
}
7340
7814
 
 
7815
/*
7341
7816
static void MakeTermListForm (void)
7342
7817
 
7343
7818
{
7344
7819
  if (! EntrezIsInited ()) {
7345
 
    /* EntrezBioseqFetchEnable ("Sequin", TRUE); */
 
7820
    EntrezBioseqFetchEnable ("Sequin", TRUE);
7346
7821
    SequinEntrezInit ("Sequin", FALSE, NULL);
7347
7822
  }
7348
7823
  if (termListForm != NULL) return;
7355
7830
 
7356
7831
{
7357
7832
  if (! EntrezIsInited ()) {
7358
 
    /* EntrezBioseqFetchEnable ("Sequin", TRUE); */
 
7833
    EntrezBioseqFetchEnable ("Sequin", TRUE);
7359
7834
    SequinEntrezInit ("Sequin", FALSE, NULL);
7360
7835
  }
7361
7836
  if (docSumForm != NULL) return;
7362
7837
  docSumForm = CreateDocSumForm (-10, -90, "Document",
7363
7838
                                 DocumentSummaryActivateProc,
7364
7839
                                 DocumentSummaryFormMessage);
7365
 
  /* if (indexerVersion) { */
7366
 
  UseDelayedNeighbor (docSumForm, TRUE);
7367
 
  /* } */
 
7840
  if (indexerVersion) {
 
7841
    UseDelayedNeighbor (docSumForm, TRUE);
 
7842
  }
7368
7843
}
 
7844
*/
7369
7845
 
7370
7846
void EntrezQueryProc (IteM i)
7371
7847
 
7372
7848
{
 
7849
  /*
7373
7850
  MakeTermListForm ();
7374
7851
  MakeDocSumForm ();
7375
7852
  Show (termListForm);
7376
7853
  Select (termListForm);
7377
7854
  Update ();
 
7855
  */
7378
7856
}
7379
7857
 
7380
7858
#if defined(OS_MAC) || defined(OS_UNIX_DARWIN)
7407
7885
*  to have the application track multiple term list and docsum windows.
7408
7886
*/
7409
7887
 
 
7888
/*
7410
7889
static void DoRetrieveDocuments (ForM f, Int2 num, Int2 parents, Int4Ptr uids, Int2 db)
7411
7890
 
7412
7891
{
7462
7941
{
7463
7942
  if (useEntrez) {
7464
7943
    if (! EntrezIsInited ()) {
7465
 
      /* EntrezBioseqFetchEnable ("Sequin", TRUE); */
 
7944
      EntrezBioseqFetchEnable ("Sequin", TRUE);
7466
7945
      SequinEntrezInit ("Sequin", FALSE, NULL);
7467
7946
    }
7468
7947
    return MakeViewerLinkControls (prnt, bfp, doctype, uid, FALSE);
7475
7954
{
7476
7955
  if (useEntrez) {
7477
7956
    if (! EntrezIsInited ()) {
7478
 
      /* EntrezBioseqFetchEnable ("Sequin", TRUE); */
 
7957
      EntrezBioseqFetchEnable ("Sequin", TRUE);
7479
7958
      SequinEntrezInit ("Sequin", FALSE, NULL);
7480
7959
    }
7481
7960
    return MakeViewerLinkControls (prnt, bfp, doctype, uid, TRUE);
7482
7961
  }
7483
7962
  return NULL;
7484
7963
}
 
7964
*/
7485
7965
 
7486
7966
typedef struct aligngroup {
7487
7967
  DIALOG_MESSAGE_BLOCK
7513
7993
  if (bfp == NULL) return;
7514
7994
  egp = (EntrezGlobalsPtr) GetAppProperty ("EntrezGlobals");
7515
7995
  if (egp == NULL || egp->retrieveDocsProc == NULL) return;
 
7996
  /*
7516
7997
  if (! EntrezIsInited ()) {
7517
7998
    SequinEntrezInit ("Sequin", FALSE, NULL);
7518
7999
  }
 
8000
  */
7519
8001
  uids = NULL;
7520
8002
  sep = NULL;
7521
8003
  if (GetStatus (agp->onlyFromThis)) {
7842
8324
    medviewprocs.useScrollText = FALSE;
7843
8325
  }
7844
8326
  medviewprocs.handleMessages = SequinMedlineFormMessage;
 
8327
  /*
7845
8328
  medviewprocs.makeControls = DoMakeMedViewerLinkControls;
 
8329
  */
7846
8330
  SetAppProperty ("MedlineDisplayForm", &medviewprocs);
7847
8331
 
7848
8332
  MemSet ((Pointer) (&seqviewprocs), 0, sizeof (SeqViewProcs));
7885
8369
  seqviewprocs.handleMessages = SequinSeqViewFormMessage;
7886
8370
  /*
7887
8371
  seqviewprocs.makeControls = DoMakeSeqViewerLinkControls;
7888
 
  */
7889
8372
  seqviewprocs.updateControls = UpdateViewerLinkTarget;
 
8373
  */
7890
8374
  seqviewprocs.makeAlignBtn = DoMakeViewerAlignBtn;
7891
8375
  seqviewprocs.updateCounts = DoUpdateFetchCounts;
7892
8376
  seqviewprocs.filepath = NULL;
7911
8395
    seqedprocs.download = SeqEdDownload;
7912
8396
  }
7913
8397
 
7914
 
  seqedprocs.col1r=seqedprocs.col1g=seqedprocs.col1b=0;
7915
 
  seqedprocs.col2r=seqedprocs.col2g=seqedprocs.col2b=0;
7916
 
  seqedprocs.col3r=seqedprocs.col3g=seqedprocs.col3b=0;
7917
 
  seqedprocs.col4r=seqedprocs.col4g=seqedprocs.col4b=0;
7918
 
  seqedprocs.col5r=seqedprocs.col5g=seqedprocs.col5b=0;
7919
 
  seqedprocs.col6r=seqedprocs.col6g=seqedprocs.col6b=0;
7920
 
  seqedprocs.col7r=seqedprocs.col7g=seqedprocs.col7b=0;
7921
 
 
7922
8398
  SetAppProperty ("SeqEditDisplayForm", &seqedprocs);
7923
8399
 
7924
8400
  MemSet ((Pointer) (&stdedprocs), 0, sizeof (StdEditorProcs));
7951
8427
  SetAppProperty ("HelpMessageProc", (Pointer) ProcessHelpMessage);
7952
8428
 
7953
8429
  MemSet ((Pointer) (&pubedprocs), 0, sizeof (PubdescEditProcs));
7954
 
  if (useMedarch) {
 
8430
  if (newMedarch) {
 
8431
    pubedprocs.lookupArticle = LookupAnArticleFuncNew;
 
8432
    pubedprocs.lookupJournal = LookupJournalFuncNew;
 
8433
  } else if (useMedarch) {
7955
8434
    pubedprocs.lookupArticle = LookupAnArticleFunc;
7956
8435
    pubedprocs.lookupJournal = LookupJournalFunc;
7957
8436
  }
8095
8574
    AsnSetXMLmodulePrefix (StringSave (str));
8096
8575
  }
8097
8576
 
8098
 
  if (GetSequinAppParam ("PREFERENCES", "COL1R", NULL, str, sizeof (str)))
8099
 
{
8100
 
    if (StrToInt (str, &val) && val > 0) {
8101
 
      val = MIN (val, 255);
8102
 
      seqedprocs.col1r = val;
8103
 
    }
8104
 
  }
8105
 
  if (GetSequinAppParam ("PREFERENCES", "COL1G", NULL, str, sizeof (str)))
8106
 
{
8107
 
    if (StrToInt (str, &val) && val > 0) {
8108
 
      val = MIN (val, 255);
8109
 
      seqedprocs.col1g = val;
8110
 
    }
8111
 
  }
8112
 
  if (GetSequinAppParam ("PREFERENCES", "COL1B", NULL, str, sizeof (str)))
8113
 
{
8114
 
    if (StrToInt (str, &val) && val > 0) {
8115
 
      val = MIN (val, 255);
8116
 
      seqedprocs.col1b = val;
8117
 
    }
8118
 
  }
8119
 
  if (GetSequinAppParam ("PREFERENCES", "COL2R", NULL, str, sizeof (str)))
8120
 
{
8121
 
    if (StrToInt (str, &val) && val > 0) {
8122
 
      val = MIN (val, 255);
8123
 
      seqedprocs.col2r = val;
8124
 
    }
8125
 
  }
8126
 
  if (GetSequinAppParam ("PREFERENCES", "COL2G", NULL, str, sizeof (str)))
8127
 
{
8128
 
    if (StrToInt (str, &val) && val > 0) {
8129
 
      val = MIN (val, 255);
8130
 
      seqedprocs.col2g = val;
8131
 
    }
8132
 
  }
8133
 
  if (GetSequinAppParam ("PREFERENCES", "COL2B", NULL, str, sizeof (str)))
8134
 
{
8135
 
    if (StrToInt (str, &val) && val > 0) {
8136
 
      val = MIN (val, 255);
8137
 
      seqedprocs.col2b = val;
8138
 
    }
8139
 
  }
8140
 
  if (GetSequinAppParam ("PREFERENCES", "COL3R", NULL, str, sizeof (str)))
8141
 
{
8142
 
    if (StrToInt (str, &val) && val > 0) {
8143
 
      val = MIN (val, 255);
8144
 
      seqedprocs.col3r = val;
8145
 
    }
8146
 
  }
8147
 
  if (GetSequinAppParam ("PREFERENCES", "COL3G", NULL, str, sizeof (str)))
8148
 
{
8149
 
    if (StrToInt (str, &val) && val > 0) {
8150
 
      val = MIN (val, 255);
8151
 
      seqedprocs.col3g = val;
8152
 
    }
8153
 
  }
8154
 
  if (GetSequinAppParam ("PREFERENCES", "COL3B", NULL, str, sizeof (str)))
8155
 
{
8156
 
    if (StrToInt (str, &val) && val > 0) {
8157
 
      val = MIN (val, 255);
8158
 
      seqedprocs.col3b = val;
8159
 
    }
8160
 
  }
8161
 
  if (GetSequinAppParam ("PREFERENCES", "COL4R", NULL, str, sizeof (str)))
8162
 
{
8163
 
    if (StrToInt (str, &val) && val > 0) {
8164
 
      val = MIN (val, 255);
8165
 
      seqedprocs.col4r = val;
8166
 
    }
8167
 
  }
8168
 
  if (GetSequinAppParam ("PREFERENCES", "COL4G", NULL, str, sizeof (str)))
8169
 
{
8170
 
    if (StrToInt (str, &val) && val > 0) {
8171
 
      val = MIN (val, 255);
8172
 
      seqedprocs.col4g = val;
8173
 
    }
8174
 
  }
8175
 
  if (GetSequinAppParam ("PREFERENCES", "COL4B", NULL, str, sizeof (str)))
8176
 
{
8177
 
    if (StrToInt (str, &val) && val > 0) {
8178
 
      val = MIN (val, 255);
8179
 
      seqedprocs.col4b = val;
8180
 
    }
8181
 
  }
8182
 
  if (GetSequinAppParam ("PREFERENCES", "COL5R", NULL, str, sizeof (str)))
8183
 
{
8184
 
    if (StrToInt (str, &val) && val > 0) {
8185
 
      val = MIN (val, 255);
8186
 
      seqedprocs.col5r = val;
8187
 
    }
8188
 
  }
8189
 
  if (GetSequinAppParam ("PREFERENCES", "COL5G", NULL, str, sizeof (str)))
8190
 
{
8191
 
    if (StrToInt (str, &val) && val > 0) {
8192
 
      val = MIN (val, 255);
8193
 
      seqedprocs.col5g = val;
8194
 
    }
8195
 
  }
8196
 
  if (GetSequinAppParam ("PREFERENCES", "COL5B", NULL, str, sizeof (str)))
8197
 
{
8198
 
    if (StrToInt (str, &val) && val > 0) {
8199
 
      val = MIN (val, 255);
8200
 
      seqedprocs.col5b = val;
8201
 
    }
8202
 
  }
8203
 
  if (GetSequinAppParam ("PREFERENCES", "COL6R", NULL, str, sizeof (str)))
8204
 
{
8205
 
    if (StrToInt (str, &val) && val > 0) {
8206
 
      val = MIN (val, 255);
8207
 
      seqedprocs.col6r = val;
8208
 
    }
8209
 
  }
8210
 
  if (GetSequinAppParam ("PREFERENCES", "COL6G", NULL, str, sizeof (str)))
8211
 
{
8212
 
    if (StrToInt (str, &val) && val > 0) {
8213
 
      val = MIN (val, 255);
8214
 
      seqedprocs.col6g = val;
8215
 
    }
8216
 
  }
8217
 
  if (GetSequinAppParam ("PREFERENCES", "COL6B", NULL, str, sizeof (str)))
8218
 
{
8219
 
    if (StrToInt (str, &val) && val > 0) {
8220
 
      val = MIN (val, 255);
8221
 
      seqedprocs.col6b = val;
8222
 
    }
8223
 
  }
8224
 
 
8225
 
  if (GetSequinAppParam ("PREFERENCES", "COL7R", NULL, str, sizeof (str)))
8226
 
{
8227
 
    if (StrToInt (str, &val) && val > 0) {
8228
 
      val = MIN (val, 255);
8229
 
      seqedprocs.col7r = val;
8230
 
    }
8231
 
  }
8232
 
  if (GetSequinAppParam ("PREFERENCES", "COL7G", NULL, str, sizeof (str)))
8233
 
{
8234
 
    if (StrToInt (str, &val) && val > 0) {
8235
 
      val = MIN (val, 255);
8236
 
      seqedprocs.col7g = val;
8237
 
    }
8238
 
  }
8239
 
  if (GetSequinAppParam ("PREFERENCES", "COL7B", NULL, str, sizeof (str)))
8240
 
{
8241
 
    if (StrToInt (str, &val) && val > 0) {
8242
 
      val = MIN (val, 255);
8243
 
      seqedprocs.col7b = val;
8244
 
    }
8245
 
  }
8246
 
 
8247
8577
  validateExons = TRUE;
8248
8578
  if (GetSequinAppParam ("PREFERENCES", "VALIDATEEXONS", NULL, str, sizeof (str))) {
8249
8579
    if (StringICmp (str, "FALSE") == 0) {
8267
8597
    SetAppProperty ("ValidateCDSmRNAoneToOne", (void *) 1024);
8268
8598
  }
8269
8599
 
 
8600
  testLatLonSubregion = FALSE;
 
8601
  if (GetSequinAppParam ("PREFERENCES", "VALIDATELATLONSUBREGION", NULL, str, sizeof (str))) {
 
8602
    if (StringICmp (str, "TRUE") == 0) {
 
8603
      testLatLonSubregion = TRUE;
 
8604
    }
 
8605
  }
 
8606
 
 
8607
  strictLatLonCountry = FALSE;
 
8608
  if (GetSequinAppParam ("PREFERENCES", "VALIDATELATLONSTRICT", NULL, str, sizeof (str))) {
 
8609
    if (StringICmp (str, "TRUE") == 0) {
 
8610
      strictLatLonCountry = TRUE;
 
8611
    }
 
8612
  }
 
8613
 
8270
8614
  /*
8271
8615
  if (GetSequinAppParam ("SETTINGS", "NUCFIELD", NULL, str, sizeof (str))) {
8272
8616
    if (StrToInt (str, &val) && val >= 0) {
8326
8670
  }
8327
8671
 
8328
8672
  MemSet ((Pointer) (&entrezglobals), 0, sizeof (EntrezGlobals));
 
8673
  /*
8329
8674
  entrezglobals.retrieveDocsProc = DoRetrieveDocuments;
8330
8675
  entrezglobals.retrieveProjectProc = DoRetrieveProject;
8331
8676
  entrezglobals.retrieveSimpleProc = DoRetrieveSimple;
8336
8681
  entrezglobals.createDocSumMenus = DocSumFormMenus;
8337
8682
#endif
8338
8683
  SetAppProperty ("EntrezGlobals", &entrezglobals);
 
8684
  */
8339
8685
 
8340
8686
  entrezglobals.showAsn = TRUE;
8341
8687
 
8605
8951
  BioseqPtr                  bsp;
8606
8952
  Char                       buf [41];
8607
8953
  FILE                       *fp;
8608
 
  Int4                       j, num;
 
8954
  Uint4                      j, num;
8609
8955
  ObjMgrDataPtr              omdp;
8610
8956
  ObjMgrDataPtr PNTR         omdpp;
8611
8957
  ObjMgrPtr                  omp;
8668
9014
  Int2  mssgfeatprop;
8669
9015
  Int2  mssgseq;
8670
9016
  Int2  mssgsub;
8671
 
  Int2  mssgupd, mssgupd_idx;
 
9017
  Int2  mssgupd, mssgupd_idx = 0;
8672
9018
  Int2  mssgext;
 
9019
  /*
8673
9020
  MenU  sub;
 
9021
  */
8674
9022
 
8675
9023
  m = AppleMenu (NULL);
8676
9024
  AddAboutAndHelpMenuItems (m);
8807
9155
    validateMenu = SubMenu (m, "Validate");
8808
9156
    CommandItem (validateMenu, "Validate Record/ V", ValSeqEntryProc);
8809
9157
    CommandItem (validateMenu, "Validate no Alignments", ValSeqEntryProcNoAln);
 
9158
    CommandItem (validateMenu, "Validate check Inference", ValSeqEntryProcInfAccn);
8810
9159
    SeparatorItem (validateMenu);
8811
9160
    CommandItem (validateMenu, "Validate Inst", ValSeqEntryProcInst);
8812
9161
    CommandItem (validateMenu, "Validate Hist", ValSeqEntryProcHist);
8854
9203
    preferencesItem = CommandItem (m, "Preferences...", PreferencesProc);
8855
9204
    SeparatorItem (m);
8856
9205
  }
 
9206
  /*
8857
9207
  sub = SubMenu (m, "Font Selection");
8858
9208
  if (useEntrez) {
8859
9209
    docsumfontItem = CommandItem (sub, "DocSum Font...", DocSumFontChangeProc);
8860
9210
  }
8861
9211
  displayfontItem = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
8862
 
  /*
8863
9212
  SeparatorItem (m);
8864
9213
  legendItem = CreateLegendItem (m, NULL);
8865
 
  */
8866
9214
  SeparatorItem (m);
8867
9215
  sub = SubMenu (m, "Query Style");
8868
9216
  queryChoice = CreateQueryTypeChoice (sub, NULL);
8874
9222
  LoadDocsumOptionsMenu (m);
8875
9223
  seqviewprocs.alignWithChecked = entrezglobals.alignWithChecked;
8876
9224
  seqviewprocs.alignDefault = entrezglobals.alignDefault;
 
9225
  */
8877
9226
  if (indexerVersion) {
 
9227
    /*
8878
9228
    SeparatorItem (m);
 
9229
    */
8879
9230
    oldAsnItem = StatusItem (m, "Use Old ASN.1", ToggleOldAsnProc);
8880
9231
    SetStatus (oldAsnItem, leaveAsOldAsn);
8881
9232
  }
8888
9239
/*#endif*/
8889
9240
 
8890
9241
  m = PulldownMenu (NULL, "Misc");
 
9242
  /*
8891
9243
  CommandItem (m, "Style Manager...", StyleManagerProc);
8892
9244
  SeparatorItem (m);
 
9245
  */
8893
9246
  CommandItem (m, "Net Configure...", NetConfigureProc);
8894
9247
  if (useEntrez) {
8895
9248
    /*
9530
9883
  useDesktop = FALSE;
9531
9884
  useEntrez = FALSE;
9532
9885
  useLocal = FALSE;
 
9886
  useIdLookup = FALSE;
9533
9887
  useBlast = FALSE;
9534
9888
  useMedarch = FALSE;
 
9889
  newMedarch = FALSE;
9535
9890
  useTaxon = FALSE;
9536
9891
  allowDownload = FALSE;
9537
9892
  extraServices = FALSE;
9539
9894
 
9540
9895
  genomeCenter = NULL;
9541
9896
 
 
9897
#ifdef INTERNAL_NCBI_SEQUIN
 
9898
  indexerVersion = TRUE;
 
9899
  extraServices = TRUE;
 
9900
  useDesktop = TRUE;
 
9901
  useEntrez = TRUE;
 
9902
  useLocal = TRUE;
 
9903
  useIdLookup = TRUE;
 
9904
  useBlast = TRUE;
 
9905
  useMedarch = TRUE;
 
9906
  newMedarch = TRUE;
 
9907
  useTaxon = TRUE;
 
9908
  allowDownload = TRUE;
 
9909
#endif
 
9910
  if (GetSequinAppParam ("SETTINGS", "INDEXERVERSION", NULL, str, sizeof (str))) {
 
9911
    if (StringICmp (str, "TRUE") == 0) {
 
9912
      indexerVersion = TRUE;
 
9913
      extraServices = TRUE;
 
9914
      useDesktop = TRUE;
 
9915
      useEntrez = TRUE;
 
9916
      useLocal = TRUE;
 
9917
      useIdLookup = TRUE;
 
9918
      useBlast = TRUE;
 
9919
      useMedarch = TRUE;
 
9920
      newMedarch = TRUE;
 
9921
      useTaxon = TRUE;
 
9922
      allowDownload = TRUE;
 
9923
    }
 
9924
  }
 
9925
 
 
9926
#ifdef PUBLIC_NETWORK_SEQUIN
 
9927
  useDesktop = TRUE;
 
9928
  useEntrez = TRUE;
 
9929
  useLocal = TRUE;
 
9930
  useIdLookup = TRUE;
 
9931
  useBlast = TRUE;
 
9932
  useMedarch = TRUE;
 
9933
  newMedarch = TRUE;
 
9934
  useTaxon = TRUE;
 
9935
  allowDownload = TRUE;
 
9936
#endif
 
9937
  if (GetSequinAppParam ("SETTINGS", "PUBLICNETWORKSEQUIN", NULL, str, sizeof (str))) {
 
9938
    if (StringICmp (str, "TRUE") == 0) {
 
9939
      useDesktop = TRUE;
 
9940
      useEntrez = TRUE;
 
9941
      useLocal = TRUE;
 
9942
      useIdLookup = TRUE;
 
9943
      useBlast = TRUE;
 
9944
      useMedarch = TRUE;
 
9945
      newMedarch = TRUE;
 
9946
      useTaxon = TRUE;
 
9947
      allowDownload = TRUE;
 
9948
    }
 
9949
  }
 
9950
 
9542
9951
#ifdef USE_DESKTOP
9543
9952
  useDesktop = TRUE;
9544
9953
#endif
9568
9977
 
9569
9978
#ifdef USE_MEDARCH
9570
9979
  useMedarch = TRUE;
 
9980
  newMedarch = TRUE;
9571
9981
#endif
9572
9982
  if (GetSequinAppParam ("SETTINGS", "USEMEDARCH", NULL, str, sizeof (str))) {
9573
9983
    if (StringICmp (str, "TRUE") == 0) {
9574
9984
      useMedarch = TRUE;
 
9985
      newMedarch = TRUE;
 
9986
    }
 
9987
  }
 
9988
  if (GetSequinAppParam ("SETTINGS", "NEWMEDARCH", NULL, str, sizeof (str))) {
 
9989
    if (StringICmp (str, "FALSE") == 0) {
 
9990
      newMedarch = FALSE;
9575
9991
    }
9576
9992
  }
9577
9993
 
9603
10019
    }
9604
10020
  }
9605
10021
 
9606
 
#ifdef INTERNAL_NCBI_SEQUIN
9607
 
  indexerVersion = TRUE;
9608
 
  extraServices = TRUE;
9609
 
  useDesktop = TRUE;
9610
 
  useEntrez = TRUE;
9611
 
  useLocal = TRUE;
9612
 
  useBlast = TRUE;
9613
 
  useMedarch = TRUE;
9614
 
  useTaxon = TRUE;
9615
 
  allowDownload = TRUE;
9616
 
#endif
9617
 
  if (GetSequinAppParam ("SETTINGS", "INDEXERVERSION", NULL, str, sizeof (str))) {
9618
 
    if (StringICmp (str, "TRUE") == 0) {
9619
 
      indexerVersion = TRUE;
9620
 
      extraServices = TRUE;
9621
 
      useDesktop = TRUE;
9622
 
      useEntrez = TRUE;
9623
 
      useLocal = TRUE;
9624
 
      useBlast = TRUE;
9625
 
      useMedarch = TRUE;
9626
 
      useTaxon = TRUE;
9627
 
      allowDownload = TRUE;
9628
 
    }
9629
 
  }
9630
 
 
9631
 
#ifdef PUBLIC_NETWORK_SEQUIN
9632
 
  useDesktop = TRUE;
9633
 
  useEntrez = TRUE;
9634
 
  useLocal = TRUE;
9635
 
  useBlast = TRUE;
9636
 
  useMedarch = TRUE;
9637
 
  useTaxon = TRUE;
9638
 
  allowDownload = TRUE;
9639
 
#endif
9640
 
  if (GetSequinAppParam ("SETTINGS", "PUBLICNETWORKSEQUIN", NULL, str, sizeof (str))) {
9641
 
    if (StringICmp (str, "TRUE") == 0) {
9642
 
      useDesktop = TRUE;
9643
 
      useEntrez = TRUE;
9644
 
      useLocal = TRUE;
9645
 
      useBlast = TRUE;
9646
 
      useMedarch = TRUE;
9647
 
      useTaxon = TRUE;
9648
 
      allowDownload = TRUE;
9649
 
    }
9650
 
  }
9651
 
 
9652
10022
  if (GetSequinAppParam ("SETTINGS", "SUPPRESSENTREZ", NULL, str, sizeof (str))) {
9653
10023
    if (StringICmp (str, "TRUE") == 0) {
9654
10024
      allowDownload = FALSE;
9655
10025
      useEntrez = FALSE;
 
10026
      useMedarch = FALSE;
 
10027
      useTaxon = FALSE;
 
10028
    }
 
10029
  }
 
10030
 
 
10031
  useSeqFetch = useEntrez;
 
10032
 
 
10033
  if (GetSequinAppParam ("SETTINGS", "SUPPRESSSEQFETCH", NULL, str, sizeof (str))) {
 
10034
    if (StringICmp (str, "TRUE") == 0) {
 
10035
      useSeqFetch = FALSE;
 
10036
    }
 
10037
  }
 
10038
 
 
10039
  if (GetSequinAppParam ("SETTINGS", "SUPPRESSIDLOOKUP", NULL, str, sizeof (str))) {
 
10040
    if (StringICmp (str, "TRUE") == 0) {
 
10041
      useIdLookup = FALSE;
9656
10042
    }
9657
10043
  }
9658
10044
 
9667
10053
    }
9668
10054
  }
9669
10055
 
 
10056
  if (GetSequinAppParam ("SETTINGS", "SUPPRESSLOCAL", NULL, str, sizeof (str))) {
 
10057
    if (StringICmp (str, "TRUE") == 0) {
 
10058
      useLocal = FALSE;
 
10059
    }
 
10060
  }
 
10061
 
9670
10062
  if (GetSequinAppParam ("SETTINGS", "GENOMETAG", NULL, str, sizeof (str))) {
9671
10063
    TrimSpacesAroundString (str);
9672
10064
    if (! StringHasNoText (str)) {
9735
10127
  ExitMuskStyles ();
9736
10128
  FreeOrganismTable ();
9737
10129
  FreeGeneticCodes ();
 
10130
  GeneticCodeSingletonFini ();
9738
10131
  FreePrintOptions ();
9739
10132
 
9740
10133
/*#ifdef USE_LOCAL*/
9746
10139
/*#ifdef USE_ENTREZ*/
9747
10140
  if (useEntrez) {
9748
10141
    /* EntrezBioseqFetchDisable (); */
 
10142
    /*
9749
10143
    if (EntrezIsInited ()) {
9750
10144
      EntrezFini ();
9751
10145
    }
 
10146
    */
9752
10147
    /* ID1BioseqFetchDisable (); */
9753
10148
    PubSeqFetchDisable ();
9754
10149
  }
9851
10246
#endif
9852
10247
#ifdef OS_MSWIN
9853
10248
  sprintf (cmmd, "%s %s -o %s", dirsubfetchcmd, accn, path);
9854
 
  system (cmmd);
 
10249
  RunSilent (cmmd);
9855
10250
#endif
9856
10251
 
9857
10252
  fp = FileOpen (path, "r");
9908
10303
#endif
9909
10304
#ifdef OS_MSWIN
9910
10305
  sprintf (cmmd, "%s %s -o %s", dirsubfetchcmd, tsip->accession, path);
9911
 
  system (cmmd);
 
10306
  RunSilent (cmmd);
9912
10307
#endif
9913
10308
 
9914
10309
  fp = FileOpen (path, "r");
9976
10371
#endif
9977
10372
#ifdef OS_MSWIN
9978
10373
  sprintf (cmmd, "%s %s -o %s", smartfetchcmd, accn, path);
9979
 
  system (cmmd);
 
10374
  RunSilent (cmmd);
9980
10375
#endif
9981
10376
 
9982
10377
  fp = FileOpen (path, "r");
10006
10401
  SeqEntryPtr       sep = NULL;
10007
10402
  SeqIdPtr          sip;
10008
10403
  TextSeqIdPtr      tsip;
 
10404
  OMUserDataPtr     omudp;
10009
10405
 
10010
10406
  ompcp = (OMProcControlPtr) data;
10011
10407
  if (ompcp == NULL) return OM_MSG_RET_ERROR;
10033
10429
#endif
10034
10430
#ifdef OS_MSWIN
10035
10431
  sprintf (cmmd, "%s %s -o %s", smartfetchcmd, tsip->accession, path);
10036
 
  system (cmmd);
 
10432
  RunSilent (cmmd);
10037
10433
#endif
10038
10434
 
10039
10435
  fp = FileOpen (path, "r");
10052
10448
  bsp = BioseqFindInSeqEntry (sip, sep);
10053
10449
  ompcp->output_data = (Pointer) bsp;
10054
10450
  ompcp->output_entityID = ObjMgrGetEntityIDForChoice (sep);
 
10451
 
 
10452
  omudp = ObjMgrAddUserData(ompcp->output_entityID, ompp->procid, OMPROC_FETCH, 0);
 
10453
  
 
10454
 
10055
10455
  return OM_MSG_RET_DONE;
10056
10456
}
10057
10457
 
10064
10464
  return TRUE;
10065
10465
}
10066
10466
 
 
10467
static CharPtr hupfetchproc = "HUPBioseqFetch";
 
10468
 
 
10469
static CharPtr hupfetchcmd = NULL;
 
10470
 
 
10471
extern Pointer ReadFromHUP (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID);
 
10472
extern Pointer ReadFromHUP (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID)
 
10473
 
 
10474
{
 
10475
  Char     cmmd [256];
 
10476
  Pointer  dataptr;
 
10477
  FILE*    fp;
 
10478
  Char     path [PATH_MAX];
 
10479
 
 
10480
  if (datatype != NULL) {
 
10481
    *datatype = 0;
 
10482
  }
 
10483
  if (entityID != NULL) {
 
10484
    *entityID = 0;
 
10485
  }
 
10486
  if (! dirsubMode) return NULL;
 
10487
  if (StringHasNoText (accn)) return NULL;
 
10488
 
 
10489
  if (hupfetchcmd == NULL) {
 
10490
    if (GetAppParam ("SEQUIN", "HUP", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
 
10491
        hupfetchcmd = StringSaveNoNull (cmmd);
 
10492
    }
 
10493
  }
 
10494
  if (hupfetchcmd == NULL) return NULL;
 
10495
 
 
10496
  TmpNam (path);
 
10497
 
 
10498
#ifdef OS_UNIX
 
10499
  sprintf (cmmd, "csh %s %s > %s", hupfetchcmd, accn, path);
 
10500
  system (cmmd);
 
10501
#endif
 
10502
#ifdef OS_MSWIN
 
10503
  sprintf (cmmd, "%s %s -o %s", hupfetchcmd, accn, path);
 
10504
  RunSilent (cmmd);
 
10505
#endif
 
10506
 
 
10507
  fp = FileOpen (path, "r");
 
10508
  if (fp == NULL) {
 
10509
    FileRemove (path);
 
10510
    return NULL;
 
10511
  }
 
10512
  dataptr = ReadAsnFastaOrFlatFile (fp, datatype, entityID, FALSE, FALSE, TRUE, FALSE);
 
10513
  FileClose (fp);
 
10514
  FileRemove (path);
 
10515
  return dataptr;
 
10516
}
 
10517
 
 
10518
 
 
10519
static Int2 LIBCALLBACK HUPBioseqFetchFunc (Pointer data)
 
10520
 
 
10521
{
 
10522
  BioseqPtr         bsp;
 
10523
  Char              cmmd [256];
 
10524
  Pointer           dataptr;
 
10525
  Uint2             datatype;
 
10526
  Uint2             entityID;
 
10527
  FILE*             fp;
 
10528
  OMProcControlPtr  ompcp;
 
10529
  ObjMgrProcPtr     ompp;
 
10530
  Char              path [PATH_MAX];
 
10531
  SeqEntryPtr       sep = NULL;
 
10532
  SeqIdPtr          sip;
 
10533
  TextSeqIdPtr      tsip;
 
10534
  OMUserDataPtr     omudp;
 
10535
 
 
10536
  ompcp = (OMProcControlPtr) data;
 
10537
  if (ompcp == NULL) return OM_MSG_RET_ERROR;
 
10538
  ompp = ompcp->proc;
 
10539
  if (ompp == NULL) return OM_MSG_RET_ERROR;
 
10540
  sip = (SeqIdPtr) ompcp->input_data;
 
10541
  if (sip == NULL) return OM_MSG_RET_ERROR;
 
10542
 
 
10543
  if (sip->choice != SEQID_GENBANK) return OM_MSG_RET_ERROR;
 
10544
  tsip = (TextSeqIdPtr) sip->data.ptrvalue;
 
10545
  if (tsip == NULL || StringHasNoText (tsip->accession)) return OM_MSG_RET_ERROR;
 
10546
 
 
10547
  if (hupfetchcmd == NULL) {
 
10548
    if (GetAppParam ("SEQUIN", "HUP", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
 
10549
        hupfetchcmd = StringSaveNoNull (cmmd);
 
10550
    }
 
10551
  }
 
10552
  if (hupfetchcmd == NULL) return OM_MSG_RET_ERROR;
 
10553
 
 
10554
  TmpNam (path);
 
10555
 
 
10556
#ifdef OS_UNIX
 
10557
  sprintf (cmmd, "csh %s %s > %s", hupfetchcmd, tsip->accession, path);
 
10558
  system (cmmd);
 
10559
#endif
 
10560
#ifdef OS_MSWIN
 
10561
  sprintf (cmmd, "%s %s -o %s", hupfetchcmd, tsip->accession, path);
 
10562
  RunSilent (cmmd);
 
10563
#endif
 
10564
 
 
10565
  fp = FileOpen (path, "r");
 
10566
  if (fp == NULL) {
 
10567
    FileRemove (path);
 
10568
    return OM_MSG_RET_ERROR;
 
10569
  }
 
10570
  dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, &entityID, FALSE, FALSE, TRUE, FALSE);
 
10571
  FileClose (fp);
 
10572
  FileRemove (path);
 
10573
 
 
10574
  if (dataptr == NULL) return OM_MSG_RET_OK;
 
10575
 
 
10576
  sep = GetTopSeqEntryForEntityID (entityID);
 
10577
  if (sep == NULL) return OM_MSG_RET_ERROR;
 
10578
  bsp = BioseqFindInSeqEntry (sip, sep);
 
10579
  ompcp->output_data = (Pointer) bsp;
 
10580
  ompcp->output_entityID = ObjMgrGetEntityIDForChoice (sep);
 
10581
 
 
10582
  omudp = ObjMgrAddUserData(ompcp->output_entityID, ompp->procid, OMPROC_FETCH, 0);
 
10583
  
 
10584
 
 
10585
  return OM_MSG_RET_DONE;
 
10586
}
 
10587
 
 
10588
static Boolean HUPFetchEnable (void)
 
10589
 
 
10590
{
 
10591
  ObjMgrProcLoad (OMPROC_FETCH, hupfetchproc, hupfetchproc,
 
10592
                  OBJ_SEQID, 0, OBJ_BIOSEQ, 0, NULL,
 
10593
                  HUPBioseqFetchFunc, PROC_PRIORITY_DEFAULT);
 
10594
  return TRUE;
 
10595
}
 
10596
 
10067
10597
static CharPtr tpasmartfetchproc = "TPASmartBioseqFetch";
10068
10598
 
10069
10599
static CharPtr tpasmartfetchcmd = NULL;
10101
10631
#endif
10102
10632
#ifdef OS_MSWIN
10103
10633
  sprintf (cmmd, "%s %s -o %s", tpasmartfetchcmd, accn, path);
10104
 
  system (cmmd);
 
10634
  RunSilent (cmmd);
10105
10635
#endif
10106
10636
 
10107
10637
  fp = FileOpen (path, "r");
10158
10688
#endif
10159
10689
#ifdef OS_MSWIN
10160
10690
  sprintf (cmmd, "%s %s -o %s", tpasmartfetchcmd, tsip->accession, path);
10161
 
  system (cmmd);
 
10691
  RunSilent (cmmd);
10162
10692
#endif
10163
10693
 
10164
10694
  fp = FileOpen (path, "r");
10243
10773
 
10244
10774
extern ForM smartBioseqViewForm;
10245
10775
 
10246
 
static Int4 SMReadBioseqObj(VoidPtr data, CharPtr buffer, Int4 length, Int4 fd)
 
10776
 
 
10777
static void CountBioSources (BioSourcePtr biop, Pointer userdata)
 
10778
{
 
10779
  Int4Ptr count;
 
10780
 
 
10781
  if (biop == NULL || userdata == NULL) return;
 
10782
  count = (Int4Ptr) userdata;
 
10783
  (*count)++;
 
10784
}
 
10785
 
 
10786
static Int4 SMReadBioseqObj(VoidPtr data, CharPtr buffer, Int4 length, void* fd)
10247
10787
{
10248
10788
    AsnIoMemPtr    aimp;
10249
10789
    BaseFormPtr    bfp;
10262
10802
    Pointer        parentptr = NULL;
10263
10803
    SMUserDataPtr  sm_user_data;
10264
10804
    Int4           bio_type;
 
10805
    Int4           num_srcs = 0;
 
10806
    Boolean        do_taxlookup = TRUE;
10265
10807
 
10266
10808
    if(buffer == NULL || length < sizeof(SMMsgHeader))
10267
10809
        return -1; 
10362
10904
    }
10363
10905
    
10364
10906
    sm_user_data = MemNew(sizeof(SMUserData));
10365
 
    sm_user_data->fd = fd;
 
10907
    sm_user_data->fd = (void*) fd;
10366
10908
    sm_user_data->header = header;
10367
10909
 
10368
10910
    if(bio_data == NULL) {
10392
10934
        subtoolEntityID = entityID;
10393
10935
 
10394
10936
        sep = GetTopSeqEntryForEntityID (entityID);
10395
 
        MySeqEntryToAsn3 (sep, TRUE, FALSE, TRUE);
 
10937
        VisitBioSourcesInSep (sep, &num_srcs, CountBioSources);
 
10938
        if (num_srcs > 10000) {
 
10939
          if (ANS_CANCEL == Message (MSG_OKC, "Record contains %d BioSources.  Do Taxlookup now?", num_srcs)) {
 
10940
            do_taxlookup = FALSE;
 
10941
          }
 
10942
        }
 
10943
        MySeqEntryToAsn3 (sep, TRUE, FALSE, do_taxlookup);
10396
10944
 
10397
10945
        /* now instantiating protein titles */
10398
10946
        InstantiateProteinTitles (entityID, NULL);
10582
11130
  return FALSE;
10583
11131
}
10584
11132
 
 
11133
#include <ent2api.h>
 
11134
extern REG CORE_GetREG(void);
 
11135
 
 
11136
static void SetNetIdent (void)
 
11137
 
 
11138
{
 
11139
  static const char kRevision [] = "$Revision: " SEQ_APP_VER;
 
11140
  unsigned int major = 0, minor = 0;
 
11141
  char progname [80];
 
11142
  char buf [128];
 
11143
  CharPtr s, bf, pn;
 
11144
  int n;
 
11145
  int res;
 
11146
  size_t len;
 
11147
 
 
11148
  pn = (CharPtr) progname;
 
11149
  bf = (CharPtr) buf;
 
11150
  StringCpy (pn, "Sequin");
 
11151
  s = StringChr (kRevision, ':');
 
11152
  if (s != 0) {
 
11153
    res = sscanf (s + 1, "%u.%u%n", &major, &minor, &n);
 
11154
    if (res >= 2 && n > 0) {
 
11155
      len = StringLen (pn);
 
11156
      sprintf (pn + len, "-%u.%u", major, minor);
 
11157
      REG_Set (CORE_GetREG (), DEF_CONN_REG_SECTION,
 
11158
               REG_CONN_ARGS, pn, eREG_Transient);
 
11159
      pn [len] = '/';
 
11160
    }
 
11161
  }
 
11162
  EntrezSetProgramName (pn);
 
11163
  sprintf (bf, "User-Agent: %s\r\n", pn);
 
11164
  REG_Set (CORE_GetREG (), DEF_CONN_REG_SECTION,
 
11165
           REG_CONN_HTTP_USER_HEADER, bf, eREG_Transient);
 
11166
}
 
11167
 
10585
11168
extern CharPtr objPrtMemStr;
10586
11169
 
10587
11170
Int2 Main (void)
10624
11207
  ErrClearOptFlags (EO_SHOW_USERSTR);
10625
11208
  ProcessUpdatesFirst (FALSE);
10626
11209
 
 
11210
  SetNetIdent ();
 
11211
 
10627
11212
  UseLocalAsnloadDataAndErrMsg ();
10628
11213
  ErrPathReset ();
10629
11214
 
10689
11274
  subtoolEntityID = 0;
10690
11275
  leaveAsOldAsn = FALSE;
10691
11276
 
10692
 
  useSeqFetch = useEntrez;
10693
 
 
10694
11277
#if defined(OS_UNIX) || defined(WIN_MOTIF)
10695
11278
  {{
10696
11279
    Nlm_Int4         argc = GetArgc();
10741
11324
          backupMode = TRUE;
10742
11325
        } else if (StringCmp (argv[i], "-noseqfetch") == 0) {
10743
11326
          useSeqFetch = FALSE;
 
11327
        } else if (StringCmp (argv[i], "-nolocalfetch") == 0) {
 
11328
          useLocal = FALSE;
 
11329
        } else if (StringCmp (argv[i], "-noseqidlookup") == 0) {
 
11330
          useIdLookup = FALSE;
10744
11331
        }
10745
11332
#ifdef USE_SMARTNET
10746
11333
        else if (StringCmp (argv[i], "-ds") == 0) {
10778
11365
          nohelpMode = TRUE;
10779
11366
        else if (StringCmp (argv[i], "-noseqfetch") == 0)
10780
11367
          useSeqFetch = FALSE;
 
11368
        else if (StringCmp (argv[i], "-nolocalfetch") == 0)
 
11369
          useLocal = FALSE;
 
11370
        else if (StringCmp (argv[i], "-noseqidlookup") == 0)
 
11371
          useIdLookup = FALSE;
10781
11372
#ifdef USE_SMARTNET
10782
11373
        else if (StringNCmp (argv[i], "-z", 2) == 0) {
10783
11374
          smartnetMode = TRUE;
10874
11465
 
10875
11466
  SetupGeneticCodes ();
10876
11467
 
 
11468
  GeneticCodeSingletonInit ();
 
11469
 
10877
11470
  if (! SetupPrintOptions ()) {
10878
11471
    ArrowCursor ();
10879
11472
    Message (MSG_FATAL, "StdPrintOptionsNew failed");
10902
11495
  VSeqMgrInit (FALSE);
10903
11496
  WatchCursor ();
10904
11497
 
10905
 
#ifdef USE_SMARTNET
10906
 
  if (dirsubMode) {
10907
 
    DirSubFetchEnable ();
10908
 
    SmartFetchEnable ();
10909
 
    TPASmartFetchEnable ();
10910
 
  }
10911
 
#endif
 
11498
  /* register fetch functions */
10912
11499
 
10913
 
/*#ifdef USE_ENTREZ*/
10914
11500
  if (useEntrez) {
10915
11501
    /* EntrezBioseqFetchEnable ("Sequin", FALSE); */
10916
11502
    if (useSeqFetch) {
10917
11503
      /* ID1BioseqFetchEnable ("Sequin", FALSE); */
10918
11504
      PubSeqFetchEnable ();
10919
11505
      PubMedFetchEnable ();
10920
 
    } else {
 
11506
    } else if (useIdLookup) {
10921
11507
      PubSeqFetchEnableEx (FALSE, TRUE, TRUE, TRUE, TRUE);
10922
11508
      PubMedFetchEnable ();
10923
11509
    }
10924
11510
  }
10925
 
/*#endif*/
10926
 
 
10927
 
/*#ifdef USE_LOCAL*/
 
11511
 
 
11512
#ifdef USE_SMARTNET
 
11513
  if (dirsubMode) {
 
11514
    if (useSeqFetch) {
 
11515
      /* DirSubFetchEnable (); */
 
11516
      TPASmartFetchEnable ();
 
11517
      SmartFetchEnable ();
 
11518
      HUPFetchEnable ();
 
11519
    }
 
11520
  }
 
11521
#endif
 
11522
 
10928
11523
  if (useLocal) {
10929
11524
    LocalSeqFetchInit (FALSE);
10930
11525
  }
10931
 
/*#endif*/
 
11526
 
 
11527
/*
 
11528
#ifdef USE_SMARTNET
 
11529
  if (dirsubMode) {
 
11530
    if (only_use_smart) {
 
11531
      SmartFetchEnable ();
 
11532
    } else {
 
11533
      DirSubFetchEnable ();
 
11534
      SmartFetchEnable ();
 
11535
      TPASmartFetchEnable ();
 
11536
    }
 
11537
  }
 
11538
#endif
 
11539
 
 
11540
  if (! only_use_smart) {
 
11541
    if (useEntrez) {
 
11542
      if (useSeqFetch) {
 
11543
        PubSeqFetchEnable ();
 
11544
        PubMedFetchEnable ();
 
11545
      } else {
 
11546
        PubSeqFetchEnableEx (FALSE, TRUE, TRUE, TRUE, TRUE);
 
11547
        PubMedFetchEnable ();
 
11548
      }
 
11549
    }
 
11550
 
 
11551
    if (useLocal) {
 
11552
      LocalSeqFetchInit (FALSE);
 
11553
    }
 
11554
  }
 
11555
*/
10932
11556
 
10933
11557
#ifdef WIN_MAC
10934
11558
  SetDeactivate (NULL, MacDeactProc);
11212
11836
  if (subtoolMode || stdinMode || binseqentryMode) {
11213
11837
  } else if (workbenchMode) {
11214
11838
  } else if (entrezMode) {
 
11839
    /*
11215
11840
    MakeTermListForm ();
11216
11841
    if (termListForm != NULL) {
11217
11842
      Show (termListForm);
11229
11854
      CleanupSequin ();
11230
11855
      return 0;
11231
11856
    }
 
11857
    */
 
11858
    Message (MSG_FATAL, "This mode is obsolete");
 
11859
    CleanupSequin ();
 
11860
    return 0;
11232
11861
  } else if (startupForm != NULL) {
11233
11862
    Show (startupForm);
11234
11863
    Select (startupForm);
11283
11912
  Remove (initSubmitForm);
11284
11913
  Remove (formatForm);
11285
11914
  Remove (helpForm);
 
11915
 
 
11916
  FreeSqnTempFiles ();
 
11917
 
11286
11918
  ArrowCursor ();
11287
11919
  Update ();
11288
11920
 
11359
11991
  return TRUE;
11360
11992
}
11361
11993
 
 
11994
 
 
11995
extern void MakeBadSpecificHostValueTable (IteM i)
 
11996
{
 
11997
  BaseFormPtr  bfp;
 
11998
  SeqEntryPtr  sep;
 
11999
  ValNodePtr   bad_biop_list;
 
12000
  LogInfoPtr   lip;
 
12001
 
 
12002
#ifdef WIN_MAC
 
12003
  bfp = currentFormDataPtr;
 
12004
#else
 
12005
  bfp = GetObjectExtra (i);
 
12006
#endif
 
12007
  if (bfp == NULL) return;
 
12008
  sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
 
12009
  if (sep == NULL) return;
 
12010
 
 
12011
  bad_biop_list = Taxon3CheckSpecificHostInSeqEntry (sep, TRUE, FALSE);
 
12012
 
 
12013
  if (bad_biop_list == NULL)
 
12014
  {
 
12015
    Message (MSG_OK, "No bad specific-host values found!");
 
12016
    return;
 
12017
  }
 
12018
  lip = OpenLog ("Bad Specific-Host Values");
 
12019
 
 
12020
  lip->data_in_log = WriteBadSpecificHostTable (bad_biop_list, lip->fp);
 
12021
 
 
12022
  bad_biop_list = ValNodeFree (bad_biop_list);
 
12023
  CloseLog (lip);
 
12024
  lip = FreeLog (lip);
 
12025
}
 
12026
 
 
12027
 
 
12028
typedef struct updatefeaturesform {
 
12029
  FORM_MESSAGE_BLOCK
 
12030
  DialoG new_features;
 
12031
  ValNodePtr feat_list;
 
12032
  SeqAnnotPtr sap;
 
12033
} UpdateFeaturesFormData, PNTR UpdateFeaturesFormPtr;
 
12034
 
 
12035
 
 
12036
static void CleanupUpdateFeaturesForm (GraphiC g, VoidPtr data)
 
12037
{
 
12038
    UpdateFeaturesFormPtr f;
 
12039
 
 
12040
    f = (UpdateFeaturesFormPtr) data;
 
12041
    if (f != NULL) {
 
12042
      f->feat_list = FreeClickableList (f->feat_list);
 
12043
      f->sap = SeqAnnotFree (f->sap);
 
12044
    }
 
12045
    StdCleanupFormProc (g, data);
 
12046
}
 
12047
 
 
12048
 
 
12049
 
 
12050
static CharPtr GetNewItemDescription (SeqFeatPtr sfp)
 
12051
{
 
12052
  CharPtr location, label, row_text;
 
12053
  Char buf[129];
 
12054
  
 
12055
  location = SeqLocPrintUseBestID (sfp->location);
 
12056
  label = (CharPtr) FeatDefTypeLabel(sfp);
 
12057
 
 
12058
  FeatDefLabel (sfp, buf, sizeof (buf) - 1, OM_LABEL_CONTENT);
 
12059
 
 
12060
  row_text = (CharPtr) MemNew (sizeof (Char) * 
 
12061
                              (StringLen (label) 
 
12062
                              + StringLen (buf) 
 
12063
                              + StringLen (location) 
 
12064
                              + 6));
 
12065
  sprintf (row_text, "%s:%s:%s\n", label, buf, location);
 
12066
  location = MemFree (location);
 
12067
  return row_text;
 
12068
}
 
12069
 
 
12070
 
 
12071
static ClickableItemPtr PutFeaturesInOldItem (ValNodePtr item_list)
 
12072
{
 
12073
  ClickableItemPtr cip_olditems, cip;
 
12074
  ValNodePtr       vnp;
 
12075
 
 
12076
  cip_olditems = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
 
12077
  if (item_list == NULL) {
 
12078
    cip_olditems->description = StringSave ("No old features found");
 
12079
    cip_olditems->chosen = FALSE;
 
12080
  } else {
 
12081
    for (vnp = item_list; vnp != NULL; vnp = vnp->next) {
 
12082
      cip = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
 
12083
      cip->description = GetNewItemDescription (vnp->data.ptrvalue);
 
12084
      cip->chosen = TRUE;
 
12085
      ValNodeAddPointer (&(cip->item_list), OBJ_SEQFEAT, vnp->data.ptrvalue);
 
12086
      ValNodeAddPointer (&(cip_olditems->subcategories), 0, cip);
 
12087
    }
 
12088
    cip_olditems->description = StringSave ("Old Features (check to delete)");
 
12089
    cip_olditems->chosen = TRUE;
 
12090
  }
 
12091
  return cip_olditems;
 
12092
}
 
12093
 
 
12094
 
 
12095
static void MarkChosenFeatures (ValNodePtr item_list, Boolean delete_marked)
 
12096
{
 
12097
  ClickableItemPtr cip;
 
12098
  ValNodePtr vnp;
 
12099
  SeqFeatPtr sfp;
 
12100
 
 
12101
  while (item_list != NULL) {
 
12102
    cip = (ClickableItemPtr) item_list->data.ptrvalue;
 
12103
    if (cip != NULL) {
 
12104
      for (vnp = cip->item_list; vnp != NULL; vnp = vnp->next) {
 
12105
        if (vnp->choice == OBJ_SEQFEAT) {
 
12106
          sfp = (SeqFeatPtr) vnp->data.ptrvalue;
 
12107
          if ((cip->chosen && delete_marked) || (!cip->chosen && !delete_marked)) {
 
12108
            sfp->idx.deleteme = TRUE;
 
12109
          }
 
12110
        }
 
12111
      }
 
12112
    }
 
12113
    item_list = item_list->next;
 
12114
  }
 
12115
}
 
12116
 
 
12117
 
 
12118
static void MarkChosenFeaturesForBioseqs (ValNodePtr feat_list)
 
12119
{
 
12120
  ClickableItemPtr cip, cip_new, cip_old;
 
12121
 
 
12122
  if (feat_list == NULL) return;
 
12123
  cip = (ClickableItemPtr) feat_list->data.ptrvalue;
 
12124
  if (cip->item_list != NULL && cip->item_list->choice == OBJ_BIOSEQ) {
 
12125
    if (cip->subcategories != NULL) {
 
12126
      cip_new = (ClickableItemPtr) cip->subcategories->data.ptrvalue;
 
12127
      MarkChosenFeatures (cip_new->subcategories, FALSE);
 
12128
      if (cip->subcategories->next != NULL) {
 
12129
        cip_old = (ClickableItemPtr) cip->subcategories->next->data.ptrvalue;
 
12130
        MarkChosenFeatures (cip_old->subcategories, TRUE);
 
12131
      }
 
12132
    }
 
12133
    MarkChosenFeaturesForBioseqs (feat_list->next);
 
12134
  } else if (feat_list->next != NULL && feat_list->next->next == NULL && cip->item_list == NULL) {
 
12135
    cip_new = (ClickableItemPtr) feat_list->data.ptrvalue;
 
12136
    cip_old = (ClickableItemPtr) feat_list->next->data.ptrvalue;
 
12137
    MarkChosenFeatures (cip_new->subcategories, FALSE);
 
12138
    MarkChosenFeatures (cip_old->subcategories, TRUE);
 
12139
  }
 
12140
}
 
12141
 
 
12142
 
 
12143
static void DoUpdateFeatures (ButtoN b)
 
12144
{
 
12145
  UpdateFeaturesFormPtr f;
 
12146
 
 
12147
  f = (UpdateFeaturesFormPtr) GetObjectExtra (b);
 
12148
  if (f == NULL) return;
 
12149
 
 
12150
  MarkChosenFeaturesForBioseqs (f->feat_list);
 
12151
  
 
12152
  SmartAttachSeqAnnotToSeqEntry (f->input_entityID, f->sap, NULL);
 
12153
  f->sap = NULL;
 
12154
 
 
12155
  DeleteMarkedObjects (f->input_entityID, 0, NULL);
 
12156
  ObjMgrSetDirtyFlag (f->input_entityID, TRUE);
 
12157
  ObjMgrSendMsg (OM_MSG_UPDATE, f->input_entityID, 0, 0);
 
12158
 
 
12159
  Remove (f->form);
 
12160
}
 
12161
 
 
12162
 
 
12163
extern void UpdateFeatures (IteM i)
 
12164
{
 
12165
  BaseFormPtr  bfp;
 
12166
  SeqEntryPtr  sep;
 
12167
  Pointer        dataptr;
 
12168
  Uint2          datatype;
 
12169
  FILE           *fp;
 
12170
  Char           path [PATH_MAX];
 
12171
  SeqAnnotPtr    sap;
 
12172
  SeqFeatPtr     sfp;
 
12173
  ValNodePtr     new_feat_list = NULL, no_bsp_list = NULL, old_item_list;
 
12174
  Int4           leftmost = -1, rightmost = -1, new_left, new_right, tmp;
 
12175
  BioseqPtr      bsp, last_bsp = NULL;
 
12176
  ClickableItemPtr cip = NULL, cip_newitems = NULL, cip_olditems, cip_newfeat;
 
12177
  SeqLocPtr        slp;
 
12178
  WindoW           w;
 
12179
  GrouP            h, g, c;
 
12180
  ButtoN           b;
 
12181
  UpdateFeaturesFormPtr f;
 
12182
  Char             id [42];
 
12183
 
 
12184
#ifdef WIN_MAC
 
12185
  bfp = currentFormDataPtr;
 
12186
#else
 
12187
  bfp = GetObjectExtra (i);
 
12188
#endif
 
12189
  if (bfp == NULL) return;
 
12190
  sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
 
12191
  if (sep == NULL) return;
 
12192
 
 
12193
  path [0] = '\0';
 
12194
  if (!GetInputFileName (path, sizeof (path), "", "TEXT")) {
 
12195
    return;
 
12196
  }
 
12197
 
 
12198
  fp = FileOpen (path, "r");
 
12199
  if (fp == NULL) {
 
12200
    Message (MSG_ERROR, "Unable to open file!");
 
12201
    return;
 
12202
  }
 
12203
  dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE, FALSE,
 
12204
                                    TRUE, TRUE);
 
12205
  FileClose (fp);
 
12206
  if (dataptr == NULL || datatype != OBJ_SEQANNOT) {
 
12207
    Message (MSG_ERROR, "File does not contain feature table!");
 
12208
    return;
 
12209
  }
 
12210
 
 
12211
  sap = (SeqAnnotPtr) dataptr;
 
12212
  if (sap->type != 1) {
 
12213
    Message (MSG_ERROR, "File does not contain feature table!");
 
12214
    sap = SeqAnnotFree (sap);
 
12215
    return;
 
12216
  }
 
12217
 
 
12218
  // list features for each bioseq
 
12219
  for (sfp = sap->data; sfp != NULL; sfp = sfp->next) {
 
12220
    bsp = BioseqFindFromSeqLoc (sfp->location);
 
12221
    if (bsp == NULL) {    
 
12222
      ValNodeAddPointer (&no_bsp_list, OBJ_SEQFEAT, sfp);
 
12223
    } else {
 
12224
      if (bsp != last_bsp) {   
 
12225
        if (last_bsp != NULL) {
 
12226
          slp = SeqLocIntNew (leftmost, rightmost, Seq_strand_plus, SeqIdDup (SeqIdFindWorst (bsp->id)));
 
12227
          old_item_list = ListFeaturesOverlappingLocation (last_bsp, slp, 0, 0);
 
12228
          slp = SeqLocFree (slp);
 
12229
          cip_olditems = PutFeaturesInOldItem (old_item_list);
 
12230
          old_item_list = ValNodeFree (old_item_list);
 
12231
          ValNodeAddPointer (&(cip->subcategories), 0, cip_olditems);
 
12232
        }   
 
12233
        cip = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
 
12234
        ValNodeAddPointer (&(cip->item_list), OBJ_BIOSEQ, bsp);
 
12235
 
 
12236
        SeqIdWrite (SeqIdFindBest (bsp->id, SEQID_GENBANK), id, PRINTID_FASTA_LONG, sizeof (id) - 1);
 
12237
        cip->description = StringSave (id);
 
12238
        cip_newitems = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
 
12239
        cip_newitems->description = StringSave ("New Features (check to import)");
 
12240
        cip_newitems->chosen = TRUE;
 
12241
        ValNodeAddPointer (&(cip->subcategories), 0, cip_newitems);
 
12242
        last_bsp = bsp;
 
12243
        ValNodeAddPointer (&new_feat_list, 0, cip);
 
12244
        leftmost = -1;
 
12245
        rightmost = -1;
 
12246
      }
 
12247
      cip_newfeat = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
 
12248
      cip_newfeat->description = GetNewItemDescription (sfp);      
 
12249
      cip_newfeat->chosen = TRUE;
 
12250
      ValNodeAddPointer (&(cip_newfeat->item_list), OBJ_SEQFEAT, sfp);
 
12251
      ValNodeAddPointer (&(cip_newitems->subcategories), 0, cip_newfeat);
 
12252
      new_left = SeqLocStart (sfp->location);
 
12253
      new_right = SeqLocStop (sfp->location);
 
12254
      if (new_left > new_right) {
 
12255
        tmp = new_left;
 
12256
        new_left = new_right;
 
12257
        new_right = tmp;
 
12258
      }
 
12259
      if (leftmost == -1 || new_left < leftmost) {
 
12260
        leftmost = new_left;
 
12261
      }
 
12262
      if (rightmost == -1 || new_right > rightmost) {
 
12263
        rightmost = new_right;
 
12264
      }
 
12265
    }
 
12266
  }
 
12267
  if (last_bsp != NULL) {
 
12268
    slp = SeqLocIntNew (leftmost, rightmost, Seq_strand_plus, SeqIdDup (SeqIdFindWorst (bsp->id)));
 
12269
    old_item_list = ListFeaturesOverlappingLocation (last_bsp, slp, 0, 0);
 
12270
    slp = SeqLocFree (slp);
 
12271
    cip_olditems = PutFeaturesInOldItem (old_item_list);
 
12272
    old_item_list = ValNodeFree (old_item_list);
 
12273
    ValNodeAddPointer (&(cip->subcategories), 0, cip_olditems);
 
12274
  }
 
12275
 
 
12276
  if (no_bsp_list != NULL) {
 
12277
    Message (MSG_ERROR, "%d features in table are not found on a Bioseq in this record!", ValNodeLen (no_bsp_list));
 
12278
    no_bsp_list = ValNodeFree (no_bsp_list);
 
12279
  }
 
12280
 
 
12281
  if (new_feat_list == NULL) {
 
12282
    Message (MSG_ERROR, "No features found!");
 
12283
    sap = SeqAnnotFree (sap);
 
12284
    return;
 
12285
  }
 
12286
  if (new_feat_list->next == NULL) {
 
12287
    no_bsp_list = new_feat_list;
 
12288
    cip = (ClickableItemPtr) new_feat_list->data.ptrvalue;
 
12289
    new_feat_list = cip->subcategories;
 
12290
    cip->subcategories = NULL;
 
12291
    no_bsp_list = FreeClickableList (no_bsp_list);
 
12292
  }  
 
12293
   
 
12294
 
 
12295
  /* Now create dialog to allow user to select new features to import and existing features to delete */
 
12296
  f = (UpdateFeaturesFormPtr) MemNew (sizeof (UpdateFeaturesFormData));
 
12297
  w = FixedWindow (-50, -33, -10, -10, "Update Features", StdCloseWindowProc);
 
12298
  SetObjectExtra (w, f, CleanupUpdateFeaturesForm);
 
12299
  f->form = (ForM) w;
 
12300
  f->input_entityID = bfp->input_entityID;
 
12301
  f->feat_list = new_feat_list;
 
12302
  f->sap = sap;
 
12303
  h = HiddenGroup (w, -1, 0, NULL);
 
12304
  SetGroupSpacing (h, 10, 10);
 
12305
  g = HiddenGroup (h, 2, 0, NULL);
 
12306
  f->new_features = CreateClickableListDialog (g, "New Features (check to import)", "label1", NULL, NULL, NULL, GetDiscrepancyItemText);
 
12307
  PointerToDialog (f->new_features, new_feat_list);
 
12308
/*  f->old_features = CreateClickableListDialog (g, "Old Features", "label1",
 
12309
                                               ScrollToDiscrepancyItem, EditDiscrepancyItem, bfp,
 
12310
                                               GetDiscrepancyItemText); */
 
12311
  c = HiddenGroup (h, 4, 0, NULL);
 
12312
  b = PushButton (c, "Accept", DoUpdateFeatures);
 
12313
  SetObjectExtra (b, f, NULL);
 
12314
  PushButton (c, "Cancel", StdCancelButtonProc);
 
12315
  
 
12316
  AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
 
12317
  Show (w);
 
12318
  Select (w);
 
12319
 
 
12320
 
 
12321
}
 
12322