summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron M. Ucko <ucko@debian.org>2005-03-24 02:38:02 +0000
committerAaron M. Ucko <ucko@debian.org>2005-03-24 02:38:02 +0000
commit9d90590695bd2617a7cffd14904e1264c531ed17 (patch)
tree9d110c3704bc00918a0f86c5e82e7592176aea21
parent20e9c62b7433047567eb3a8bf3647582e12671bd (diff)
Load ncbi (6.1.20040202) into ncbi-tools6/branches/upstream/current.
-rw-r--r--VERSION2
-rw-r--r--access/ent2api.c66
-rw-r--r--access/pmfapi.c8
-rw-r--r--access/qblastapi.c119
-rw-r--r--access/qblastapi.h6
-rw-r--r--access/vecscnapi.c7
-rw-r--r--algo/blast/api/Makefile19
-rw-r--r--algo/blast/api/Makefile.blast_app50
-rw-r--r--algo/blast/api/blast_format.c350
-rw-r--r--algo/blast/api/blast_format.h10
-rw-r--r--algo/blast/api/blast_input.c16
-rw-r--r--algo/blast/api/blast_input.h6
-rw-r--r--algo/blast/api/blast_seq.c36
-rw-r--r--algo/blast/api/blast_seq.h20
-rw-r--r--algo/blast/api/blast_seqalign.c11
-rw-r--r--algo/blast/api/blast_seqalign.h6
-rw-r--r--algo/blast/api/nmakefile35
-rw-r--r--algo/blast/api/seqsrc_readdb.c126
-rw-r--r--algo/blast/api/seqsrc_readdb.h4
-rw-r--r--algo/blast/core/blast_def.h13
-rw-r--r--algo/blast/core/blast_dust.c4
-rw-r--r--algo/blast/core/blast_engine.c174
-rw-r--r--algo/blast/core/blast_engine.h8
-rw-r--r--algo/blast/core/blast_extend.c355
-rw-r--r--algo/blast/core/blast_filter.c28
-rw-r--r--algo/blast/core/blast_filter.h15
-rw-r--r--algo/blast/core/blast_gapalign.c282
-rw-r--r--algo/blast/core/blast_gapalign.h29
-rw-r--r--algo/blast/core/blast_hits.c446
-rw-r--r--algo/blast/core/blast_hits.h43
-rw-r--r--algo/blast/core/blast_lookup.c252
-rw-r--r--algo/blast/core/blast_lookup.h4
-rw-r--r--algo/blast/core/blast_options.c96
-rw-r--r--algo/blast/core/blast_options.h10
-rw-r--r--algo/blast/core/blast_seqsrc.c28
-rw-r--r--algo/blast/core/blast_seqsrc.h40
-rw-r--r--algo/blast/core/blast_setup.c29
-rw-r--r--algo/blast/core/blast_setup.h7
-rw-r--r--algo/blast/core/blast_stat.c395
-rw-r--r--algo/blast/core/blast_stat.h21
-rw-r--r--algo/blast/core/blast_toolkit.h7
-rw-r--r--algo/blast/core/blast_traceback.c167
-rw-r--r--algo/blast/core/blast_traceback.h12
-rw-r--r--algo/blast/core/blast_util.c72
-rw-r--r--algo/blast/core/blast_util.h25
-rw-r--r--algo/blast/core/link_hsps.c6
-rw-r--r--algo/blast/core/lookup_util.c4
-rw-r--r--algo/blast/core/lookup_util.h2
-rw-r--r--algo/blast/core/mb_lookup.c232
-rw-r--r--algo/blast/core/ncbi_math.c7
-rw-r--r--algo/blast/core/ncbi_std.c2
-rw-r--r--algo/blast/core/ncbi_std.h23
-rw-r--r--algo/blast/core/pattern.c16
-rw-r--r--algo/blast/core/pattern.h6
-rw-r--r--algo/blast/core/phi_lookup.c14
-rw-r--r--api/alignval.c21
-rw-r--r--api/alignval.h9
-rw-r--r--api/aliread.c15
-rw-r--r--api/asn2gnb1.c22117
-rw-r--r--api/asn2gnb2.c4778
-rw-r--r--api/asn2gnb3.c4312
-rw-r--r--api/asn2gnb4.c5056
-rw-r--r--api/asn2gnb5.c3618
-rw-r--r--api/asn2gnb6.c3851
-rw-r--r--api/asn2gnbi.h1008
-rw-r--r--api/asn2gnbp.h8
-rw-r--r--api/edutil.c53
-rw-r--r--api/findrepl.c35
-rw-r--r--api/gbparint.c65
-rw-r--r--api/lsqfetch.c202
-rw-r--r--api/lsqfetch.h9
-rw-r--r--api/objmgr.c8
-rw-r--r--api/salpedit.c7
-rw-r--r--api/seqmgr.c47
-rw-r--r--api/seqport.c275
-rw-r--r--api/seqport.h18
-rw-r--r--api/sequtil.c36
-rw-r--r--api/sqnutil1.c125
-rw-r--r--api/sqnutil2.c82
-rw-r--r--api/sqnutils.h8
-rw-r--r--api/tofasta.c113
-rw-r--r--api/tofasta.h15
-rw-r--r--api/txalign.c68
-rw-r--r--api/txalign.h22
-rw-r--r--api/valid.c460
-rw-r--r--api/valid.h15
-rw-r--r--api/valid.msg21
-rw-r--r--api/validerr.h6
-rw-r--r--asnlib/asn.h6
-rw-r--r--asnlib/asndebin.c13
-rw-r--r--asnlib/asnenbin.c9
-rw-r--r--asnlib/asnprint.c15
-rw-r--r--asnlib/asntypes.c34
-rw-r--r--biostruc/cdd/cdd.asn41
-rw-r--r--biostruc/cdd/cdd.h338
-rw-r--r--biostruc/cdd/cddposutil.c38
-rw-r--r--biostruc/cdd/cddserver.c91
-rw-r--r--biostruc/cdd/cddsrv.h9
-rw-r--r--biostruc/cdd/cddutil.c95
-rw-r--r--biostruc/cdd/cddutil.h8
-rw-r--r--biostruc/cdd/objcdd.c1130
-rw-r--r--biostruc/cdd/objcdd.h129
-rw-r--r--biostruc/cdd/wrpsb.h21
-rw-r--r--biostruc/cdd/wrpsbcl3.c845
-rw-r--r--biostruc/cdd/wrpsbtool.c812
-rw-r--r--biostruc/cdd/wrpsbtool.h56
-rw-r--r--biostruc/mmdbapi1.c17
-rw-r--r--biostruc/mmdbapi2.c15
-rw-r--r--biostruc/objmmdb3.h2
-rw-r--r--biostruc/strimprt.h9
-rw-r--r--checkout.date2
-rw-r--r--connect/ncbi_buffer.c19
-rw-r--r--connect/ncbi_connutil.c29
-rw-r--r--connect/ncbi_connutil.h10
-rw-r--r--connect/ncbi_http_connector.c22
-rw-r--r--connect/ncbi_sendmail.c258
-rw-r--r--connect/ncbi_sendmail.h28
-rw-r--r--connect/ncbi_service.c28
-rw-r--r--connect/ncbi_service.h10
-rw-r--r--connect/ncbi_socket.c387
-rw-r--r--connect/ncbi_socket.h49
-rw-r--r--connect/ncbi_util.c14
-rw-r--r--connect/ncbi_util.h11
-rw-r--r--connect/test/test_ncbi_connutil_misc.c10
-rw-r--r--connect/test/test_ncbi_dsock.c260
-rw-r--r--connect/test/test_ncbi_http_connector.c6
-rw-r--r--connect/test/test_ncbi_sendmail.c53
-rw-r--r--corelib/morefile/FullPath.c6
-rw-r--r--corelib/ncbifile.c48
-rw-r--r--corelib/ncbilcl.lnx7
-rw-r--r--corelib/ncbilcl.met6
-rw-r--r--corelib/ncbilcl.msw45
-rw-r--r--corelib/ncbimisc.c15
-rw-r--r--corelib/ncbistr.c15
-rw-r--r--corelib/ncbithr.c29
-rw-r--r--corelib/ncbiwin.h7
-rw-r--r--corelib/tsprintf.c17
-rw-r--r--ctools/asn_connection.c8
-rw-r--r--ctools/asn_connection.h11
-rw-r--r--data/lineages.txt755
-rw-r--r--data/sequin.hlp36
-rw-r--r--data/taxlist.txt487
-rw-r--r--demo/blast_driver.c72
-rw-r--r--demo/blastall.c9
-rw-r--r--demo/copymat.c254
-rw-r--r--demo/debruijn.c113
-rw-r--r--demo/formatdb.c14
-rw-r--r--demo/megablast.c42
-rw-r--r--demo/rtestval.c6
-rw-r--r--demo/tbl2asn.c152
-rw-r--r--desktop/biosrc.c4
-rw-r--r--desktop/cdrgn.c11
-rw-r--r--desktop/dlgutil1.c77
-rw-r--r--desktop/dlgutil2.c17
-rw-r--r--desktop/e2docsum.c19
-rw-r--r--desktop/gbfview.c20
-rw-r--r--desktop/salogif.c48
-rw-r--r--desktop/salogif.h19
-rw-r--r--desktop/smdlg2.c28
-rw-r--r--desktop/smdlg3.c28
-rw-r--r--doc/blast.txt6
-rw-r--r--doc/dispatcher.html14
-rw-r--r--doc/firewall.html13
-rw-r--r--doc/formatdb.txt310
-rwxr-xr-xdoc/fwd_check.sh6
-rw-r--r--doc/images/seqn01.pngbin10031 -> 13063 bytes
-rw-r--r--doc/images/seqn02.pngbin7717 -> 9851 bytes
-rw-r--r--doc/images/seqn03.pngbin7199 -> 9119 bytes
-rw-r--r--doc/images/seqn04.pngbin6829 -> 8606 bytes
-rw-r--r--doc/images/seqn05.pngbin7825 -> 10839 bytes
-rw-r--r--doc/images/seqn06.pngbin9732 -> 12555 bytes
-rw-r--r--doc/images/seqn07.pngbin8135 -> 10265 bytes
-rw-r--r--doc/images/seqn08.pngbin10934 -> 14011 bytes
-rw-r--r--doc/images/seqn09.pngbin10542 -> 13953 bytes
-rw-r--r--doc/images/seqn10.pngbin9407 -> 11534 bytes
-rw-r--r--doc/images/seqn11.pngbin5126 -> 6515 bytes
-rw-r--r--doc/images/seqn12.pngbin5795 -> 7378 bytes
-rw-r--r--doc/images/seqn13.pngbin16823 -> 22177 bytes
-rw-r--r--doc/images/seqn14.pngbin9537 -> 9785 bytes
-rw-r--r--doc/images/seqn15.pngbin14204 -> 14420 bytes
-rw-r--r--doc/images/seqn16.pngbin13491 -> 15841 bytes
-rw-r--r--doc/images/seqn17.pngbin13426 -> 16992 bytes
-rw-r--r--doc/images/seqn18.pngbin10939 -> 13600 bytes
-rw-r--r--doc/images/seqn19.pngbin8801 -> 11534 bytes
-rw-r--r--doc/images/seqn20.pngbin9016 -> 11379 bytes
-rw-r--r--doc/images/seqn21.pngbin18009 -> 20889 bytes
-rw-r--r--doc/images/seqn22.pngbin5157 -> 6913 bytes
-rw-r--r--doc/man/asn2gb.114
-rw-r--r--doc/man/blast.15
-rw-r--r--doc/man/fastacmd.117
-rw-r--r--doc/man/tbl2asn.126
-rw-r--r--doc/sequin.htm48
-rw-r--r--errmsg/valid.msg21
-rw-r--r--link/macmet/ApplicationStationery.mcpbin406277 -> 447659 bytes
-rw-r--r--link/macmet/LibraryStationery.mcpbin394920 -> 436372 bytes
-rwxr-xr-xmake/makeApps.met171
-rwxr-xr-xmake/makeLibs.met155
-rw-r--r--make/makeall.dos4
-rw-r--r--make/makeall.met1
-rw-r--r--make/makeall.unx59
-rwxr-xr-xmake/makeallchives36
-rw-r--r--make/makedemo.met1
-rw-r--r--make/makedemo.unx23
-rwxr-xr-xmake/makedis.csh18
-rw-r--r--make/makenet.unx25
-rw-r--r--make/msvc_prj/blast/blast.dsp293
-rw-r--r--make/msvc_prj/install.sh13
-rw-r--r--make/msvc_prj/internal/all_internal.dsp48
-rw-r--r--make/msvc_prj/internal/smart/smartnet/smartnet.dsp70
-rw-r--r--make/msvc_prj/ncbi.dsw89
-rw-r--r--make/msvc_prj/network/spell/client/ncbispel.dsp78
-rw-r--r--make/msvc_prj/object/ncbiobj.dsp22
-rw-r--r--make/msvc_prj/sequin/ssequin/exe_ssequin.dsp119
-rw-r--r--make/msvc_prj/tools/ncbitool.dsp4
-rw-r--r--make/readme.dos4
-rw-r--r--network/blast3/client/netblap3.c8
-rw-r--r--network/id1arch/idfetch.c18
-rw-r--r--network/id2arch/id2.asn341
-rw-r--r--network/id2arch/id2.c8013
-rw-r--r--network/id2arch/id2.h519
-rw-r--r--network/id2arch/id2gen.h968
-rw-r--r--network/id2arch/id2map.h10
-rw-r--r--network/nsclilib/readme6
-rw-r--r--network/spell/client/objspell.c425
-rw-r--r--network/spell/client/objspell.h57
-rw-r--r--network/spell/client/spell.asn27
-rw-r--r--network/spell/client/spellapi.c453
-rw-r--r--network/spell/client/spellapi.h27
-rw-r--r--network/spell/server/fmspell.c136
-rw-r--r--network/spell/server/spellsrv.c414
-rw-r--r--network/taxon1/taxon2/txcdproc.c6
-rw-r--r--network/vibnet/docsum.c11
-rw-r--r--network/wwwblast/Src/Makefile36
-rw-r--r--network/wwwblast/Src/XML/Makefile2
-rw-r--r--network/wwwblast/Src/psiblast.c9
-rw-r--r--network/wwwblast/Src/wblast2.c15
-rw-r--r--network/wwwblast/Src/wwwblast.c98
-rw-r--r--network/wwwblast/Src/wwwbutl.c48
-rw-r--r--network/wwwblast/readme.html28
-rw-r--r--network/wwwblast/readme.txt43
-rw-r--r--object/objfeat.c10
-rw-r--r--object/objtseq.c8
-rw-r--r--platform/ibm_auto.ncbi.mk4
-rw-r--r--platform/ibm_auto64.ncbi.mk4
-rw-r--r--platform/linux-x86.ncbi.mk51
-rw-r--r--platform/linux.ncbi.mk10
-rw-r--r--platform/netbsd.ncbi.mk6
-rw-r--r--sequin/sequin.h63
-rw-r--r--sequin/sequin1.c198
-rw-r--r--sequin/sequin10.c2940
-rw-r--r--sequin/sequin2.c448
-rw-r--r--sequin/sequin3.c1523
-rw-r--r--sequin/sequin4.c649
-rw-r--r--sequin/sequin5.c642
-rw-r--r--sequin/sequin6.c1213
-rw-r--r--sequin/sequin7.c163
-rw-r--r--sequin/sequin8.c944
-rw-r--r--sequin/sequin9.c842
-rw-r--r--tools/actutils.c40
-rw-r--r--tools/blast.c126
-rw-r--r--tools/blastconcat.c57
-rw-r--r--tools/blastconcatdef.h8
-rw-r--r--tools/blastdef.h30
-rw-r--r--tools/blastkar.c422
-rw-r--r--tools/blastkar.h23
-rw-r--r--tools/blastool.c117
-rw-r--r--tools/blastpri.h10
-rw-r--r--tools/blastutl.c341
-rw-r--r--tools/gapxdrop.c111
-rw-r--r--tools/kappa.c24
-rw-r--r--tools/mbalign.c15
-rw-r--r--tools/mblast.c554
-rw-r--r--tools/mblast.h24
-rw-r--r--tools/ncbisrti.h17
-rw-r--r--tools/newkar.c142
-rw-r--r--tools/readdb.c290
-rw-r--r--tools/salign.c4
-rw-r--r--tools/spidey.c48
-rw-r--r--util/tables/raw_scoremat.c6
-rw-r--r--util/tables/raw_scoremat.h6
-rw-r--r--util/tables/sm_pam250.c98
-rw-r--r--vibrant/image.c9
-rw-r--r--vibrant/ncbidraw.c13
-rw-r--r--vibrant/palette.c11
-rw-r--r--vibrant/vibbutns.c38
-rw-r--r--vibrant/vibdefns.h17
-rw-r--r--vibrant/vibforms.c51
-rw-r--r--vibrant/vibforms.h9
-rw-r--r--vibrant/vibmenus.c198
-rw-r--r--vibrant/vibprocs.h17
-rw-r--r--vibrant/vibtexts.c51
-rw-r--r--vibrant/vibutils.c144
-rw-r--r--vibrant/vibwndws.c259
293 files changed, 54591 insertions, 29496 deletions
diff --git a/VERSION b/VERSION
index ff78c716..17aca6df 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-Wed Oct 29 10:59:56 EST 2003
+Sun Feb 1 10:18:25 EST 2004
diff --git a/access/ent2api.c b/access/ent2api.c
index a036291b..0a0b0e03 100644
--- a/access/ent2api.c
+++ b/access/ent2api.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/29/99
*
-* $Revision: 1.57 $
+* $Revision: 1.60 $
*
* File Description:
*
@@ -145,16 +145,52 @@ NLM_EXTERN CONN EntrezOpenConnection (
Uint2 host_port = e2_host_port;
CharPtr host_path = e2_host_path;
CharPtr host_service = e2_service;
+#ifdef OS_UNIX
+ CharPtr env_machine = NULL;
+ CharPtr env_path = NULL;
+ CharPtr env_port = NULL;
+ CharPtr env_service = NULL;
+ int val = 0;
+#endif
+#ifdef OS_UNIX
+ env_machine = (CharPtr) getenv ("NCBI_ENTREZ2_HOST_MACHINE");
+ if (! StringHasNoText (env_machine)) {
+ host_machine = env_machine;
+ }
+#endif
if (StringHasNoText (host_machine)) {
host_machine = "www.ncbi.nlm.nih.gov";
}
+
+#ifdef OS_UNIX
+ env_port = (CharPtr) getenv ("NCBI_ENTREZ2_HOST_PORT");
+ if (! StringHasNoText (env_port)) {
+ if (sscanf (env_port, "%d", &val) == 1) {
+ host_port = (Uint2) val;
+ }
+ }
+#endif
if (host_port == 0) {
host_port = 80;
}
+
+#ifdef OS_UNIX
+ env_path = (CharPtr) getenv ("NCBI_ENTREZ2_HOST_PATH");
+ if (! StringHasNoText (env_path)) {
+ host_path = env_path;
+ }
+#endif
if (StringHasNoText (host_path)) {
- host_path = "/entrez/utils/entrez2server.fcgi";
+ host_path = "/entrez/eutils/entrez2server.fcgi";
+ }
+
+#ifdef OS_UNIX
+ env_service = (CharPtr) getenv ("NCBI_ENTREZ2_HOST_SERVICE");
+ if (! StringHasNoText (env_service)) {
+ host_service = env_service;
}
+#endif
if (StringHasNoText (host_service)) {
host_service = "Entrez2";
}
@@ -932,6 +968,7 @@ NLM_EXTERN Boolean ValidateEntrez2InfoPtr (
Char ch;
CharPtr db;
Int2 dbcount;
+ CharPtr dbnames [256];
CharPtr dsf;
Int2 dsfcount;
Entrez2DbInfoPtr e2db;
@@ -941,7 +978,9 @@ NLM_EXTERN Boolean ValidateEntrez2InfoPtr (
CharPtr fld;
Int2 fldcount;
Boolean hasLowCase;
+ Int2 i;
CharPtr last;
+ ValNodePtr lastvnp;
size_t len1;
size_t len2;
CharPtr lnk;
@@ -967,6 +1006,19 @@ NLM_EXTERN Boolean ValidateEntrez2InfoPtr (
return FALSE;
}
+ for (i = 0; i < sizeof (dbnames) / sizeof (CharPtr); i++) {
+ dbnames [i] = "?";
+ }
+ i = 0;
+ for (e2db = e2ip->db_info; e2db != NULL; e2db = e2db->next) {
+ i++;
+ if (! StringHasNoText (e2db->db_name)) {
+ dbnames [i] = e2db->db_name;
+ } else if (! StringHasNoText (e2db->db_menu)) {
+ dbnames [i] = e2db->db_menu;
+ }
+ }
+
dbcount = 0;
for (e2db = e2ip->db_info; e2db != NULL; e2db = e2db->next) {
dbcount++;
@@ -1089,7 +1141,7 @@ NLM_EXTERN Boolean ValidateEntrez2InfoPtr (
ValNodeCopyStr (head, 0, buf);
rsult = FALSE;
} else {
- ValNodeCopyStr (&menuhead, 0, e2fip->field_menu);
+ ValNodeCopyStr (&menuhead, (Int2) dbcount, e2fip->field_menu);
if (StringStr (e2fip->field_menu, "Date") != NULL) {
if (! e2fip->is_date) {
sprintf (buf, "Database %s field %s does not have is_date set", db, fld);
@@ -1203,12 +1255,13 @@ NLM_EXTERN Boolean ValidateEntrez2InfoPtr (
menuhead = ValNodeSort (menuhead, SortVnpByStr);
last = NULL;
+ lastvnp = NULL;
for (vnp = menuhead; vnp != NULL; vnp = vnp->next) {
str = (CharPtr) vnp->data.ptrvalue;
if (StringHasNoText (str)) continue;
- if (last != NULL) {
+ if (last != NULL && lastvnp != NULL) {
if (StringICmp (last, str) == 0 && StringCmp (last, str) != 0) {
- sprintf (buf, "Menu names %s and %s differ in capitalization", last, str);
+ sprintf (buf, "Menu names %s [%s] and %s [%s] differ in capitalization", last, dbnames [lastvnp->choice], str, dbnames [vnp->choice]);
ValNodeCopyStr (head, 0, buf);
rsult = FALSE;
} else {
@@ -1224,7 +1277,7 @@ NLM_EXTERN Boolean ValidateEntrez2InfoPtr (
} else if (StringICmp (last, "Rank") == 0 && StringICmp (str, "Ranked standard deviation") == 0) {
} else if (StringICmp (last, "Book") == 0 && StringICmp (str, "Book's Topic") == 0) {
} else {
- sprintf (buf, "Menu names %s and %s may be unintended variants", last, str);
+ sprintf (buf, "Menu names %s [%s] and %s [%s] may be unintended variants", last, dbnames [lastvnp->choice], str, dbnames [vnp->choice]);
ValNodeCopyStr (head, 0, buf);
rsult = FALSE;
}
@@ -1237,6 +1290,7 @@ NLM_EXTERN Boolean ValidateEntrez2InfoPtr (
rsult = FALSE;
}
last = str;
+ lastvnp = vnp;
}
ValNodeFreeData (menuhead);
diff --git a/access/pmfapi.c b/access/pmfapi.c
index 02d0198b..f288d240 100644
--- a/access/pmfapi.c
+++ b/access/pmfapi.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 5/5/00
*
-* $Revision: 1.62 $
+* $Revision: 1.63 $
*
* File Description:
*
@@ -235,6 +235,12 @@ static void ChangeMedlineAuthorsToISO (
alp = cap->authors;
if (alp == NULL || alp->choice != 2) return;
+ /* do not convert if too big for buffers */
+
+ for (tmp = alp->names; tmp != NULL; tmp = tmp->next) {
+ if (StringLen ((CharPtr) tmp->data.ptrvalue) > 70) return;
+ }
+
oldnames = alp->names;
alp->names = NULL;
alp->choice = 1; /* make std names */
diff --git a/access/qblastapi.c b/access/qblastapi.c
index 5cf11516..400a73bd 100644
--- a/access/qblastapi.c
+++ b/access/qblastapi.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 6/28/00
*
-* $Revision: 1.24 $
+* $Revision: 1.28 $
*
* File Description:
*
@@ -37,6 +37,18 @@
* --------------------------------------------------------------------------
*
* $Log: qblastapi.c,v $
+* Revision 1.28 2003/11/14 16:23:08 dondosha
+* If query id not local, append title to id to get defline in BLASTGetQuerySummary
+*
+* Revision 1.27 2003/11/12 21:19:03 kans
+* changed query_number to query_num - fixing typo
+*
+* Revision 1.26 2003/11/12 20:49:20 coulouri
+* Replace code accidentally removed between 1.24 and 1.25 in BlastGetQueryBioseqByRIDEx
+*
+* Revision 1.25 2003/11/03 20:50:53 madden
+* Fix problem with content length, remove call to QblastTestRID, add BLASTGetBOByRIDEx
+*
* Revision 1.24 2003/01/17 20:40:29 madden
* Put QUERY_NUMBER back in URL for fetching Seqannot
*
@@ -755,40 +767,6 @@ static void LIBCALLBACK AsnIoErrorFunc(Int2 type, CharPtr message)
return;
}
-/*
- Tests the RID to see if it's an in-house job
- (i.e., indexer) kept in the LL queue, or a
- normal one.
-
- External jobs start with a 0 after the first dash
- (e.g., 1018299345-016645-15460), internal jobs
- do not.
-
- Return value is TRUE for internal jobs, FALSE for external.
-
-*/
-static Boolean QblastTestRID(CharPtr RID)
-
-{
- Boolean retval=TRUE;
-
- while (*RID != NULLB)
- {
- if (*RID == '-')
- {
- RID++;
- if (*RID == '0')
- retval = FALSE;
- else
- retval = TRUE;
- break;
- }
- RID++;
- }
-
- return retval;
-}
-
/* Function to get SeqAnnot for RID. We suupose, that search already
finished and results are exists on the Qblast repository */
@@ -819,8 +797,10 @@ NLM_EXTERN SeqAnnotPtr BLASTGetSeqAnnotByRIDEx(CharPtr RID,
AsnIoConnPtr aicp;
EIO_Status status;
- sprintf(query_string, "FORMAT_TYPE=ASN.1&CMD=Get&RID=%s&QUERY_NUMBER=%ld&FORMAT_OBJECT=Alignment",
- RID, (long) query_number);
+ sprintf(query_string,
+ "FORMAT_TYPE=ASN.1&CMD=Get&RID=%s&QUERY_NUMBER=%ld&FORMAT_OBJECT=Alignment",
+ RID,
+ (long) query_number);
conn = QUERY_OpenUrlQuery ((host_machine == NULL) ? "www.ncbi.nlm.nih.gov" : host_machine,
(host_port <= 0) ? 80 : host_port,
@@ -829,7 +809,7 @@ NLM_EXTERN SeqAnnotPtr BLASTGetSeqAnnotByRIDEx(CharPtr RID,
240, eMIME_T_Application,
eMIME_WwwForm, eENCOD_Url, 0);
- length = StringLen(query_string)+1;
+ length = StringLen(query_string);
status = CONN_Write (conn, query_string, length , &n_written);
QUERY_SendQuery (conn);
@@ -860,19 +840,15 @@ NLM_EXTERN BioseqPtr BLASTGetQueryBioseqByRIDEx(CharPtr RID, int query_num)
Int4 length;
AsnIoConnPtr aicp;
EIO_Status status;
-
- /* sprintf(query_string, "RID=%s&ALIGNMENT_VIEW=11", RID); */
-
- if (QblastTestRID(RID) == FALSE)
- sprintf(query_string, "CMD=Get&RID=%s&FORMAT_OBJECT=Bioseq&FORMAT_TYPE=ASN.1&QUERY_NUMBER=%d", RID, query_num);
- else
- sprintf(query_string, "CMD=Get&RID=%s&FORMAT_OBJECT=Bioseq&FORMAT_TYPE=ASN.1&QUERY_NUMBER=%d&CLIENT=DirSub", RID, query_num);
-
- /* conn = QUERY_OpenUrlQuery ("www.ncbi.nlm.nih.gov", 80, */
+
+ sprintf(query_string,
+ "FORMAT_TYPE=ASN.1&CMD=Get&RID=%s&QUERY_NUMBER=%ld&FORMAT_OBJECT=Bioseq",
+ RID,
+ (long) query_num);
conn = QUERY_OpenUrlQuery ("www.ncbi.nlm.nih.gov", 80,
"/blast/Blast.cgi", NULL,
- "BLASTGetQueryBioseqByRID()",
+ "BLASTGetQueryBioseqByRIDEx()",
30, eMIME_T_Application,
eMIME_WwwForm, eENCOD_Url, 0);
@@ -896,7 +872,19 @@ NLM_EXTERN Nlm_Boolean BLASTGetQuerySummary(CharPtr RID, Int4 query_number,
BioseqPtr bsp = BLASTGetQueryBioseqByRIDEx(RID, query_number);
if(!bsp)
return FALSE;
- *defline = StringSave(BioseqGetTitle(bsp));
+ if (bsp->id->choice == SEQID_LOCAL) {
+ *defline = StringSave(BioseqGetTitle(bsp));
+ } else {
+#define SEQID_LENGTH 255
+ Int4 id_length;
+ Char tmp[SEQID_LENGTH+1];
+ Int4 title_length = StringLen(BioseqGetTitle(bsp));
+ SeqIdWrite(bsp->id, tmp, PRINTID_FASTA_LONG, SEQID_LENGTH);
+ id_length = StringLen(tmp);
+ title_length += id_length + 3;
+ *defline = (CharPtr) MemNew(title_length*sizeof(Char));
+ sprintf(*defline, "%s %s", tmp, BioseqGetTitle(bsp));
+ }
*query_length = BioseqGetLen(bsp);
BioseqFree(bsp);
return TRUE;
@@ -906,7 +894,13 @@ NLM_EXTERN Nlm_Boolean BLASTGetQuerySummary(CharPtr RID, Int4 query_number,
/* Function to get BlastObject for RID. We suupose, that search already
finished and results are exists on the Qblast repository. Blast Object
ASN.1 will be returned as CharPtr buffer*/
-NLM_EXTERN CharPtr BLASTGetBOByRID(CharPtr RID)
+/*
+ * retrive blast object
+ */
+NLM_EXTERN CharPtr BLASTGetBOByRIDEx(CharPtr RID,
+ Nlm_CharPtr host_machine,
+ Nlm_Uint2 host_port,
+ Nlm_CharPtr host_path)
{
Char query_string[256];
CONN conn;
@@ -916,21 +910,17 @@ NLM_EXTERN CharPtr BLASTGetBOByRID(CharPtr RID)
EIO_Status status;
CharPtr in_buff;
-/*
- sprintf(query_string, "RID=%s&ALIGNMENT_VIEW=13", RID);
-*/
- if (QblastTestRID(RID) == FALSE)
- sprintf(query_string, "CMD=Get&RID=%s&FORMAT_OBJECT=BlastObject&FORMAT_TYPE=ASN.1", RID);
- else
- sprintf(query_string, "CMD=Get&RID=%s&FORMAT_OBJECT=BlastObject&FORMAT_TYPE=ASN.1&CLIENT=DirSub", RID);
-
- conn = QUERY_OpenUrlQuery ("www.ncbi.nlm.nih.gov", 80,
- "/blast/Blast.cgi", NULL,
- "BLASTGetBOByRID()",
+ sprintf(query_string, "CMD=Get&RID=%s&FORMAT_OBJECT=BlastObject&FORMAT_TYPE=ASN.1", RID);
+
+ conn = QUERY_OpenUrlQuery ((host_machine == NULL) ? "www.ncbi.nlm.nih.gov" : host_machine,
+ (host_port <= 0) ? 80 : host_port,
+ (host_path == NULL) ? "/blast/Blast.cgi" : host_path,
+ NULL,
+ "BLASTGetBOByRIDEx()",
30, eMIME_T_Application,
eMIME_WwwForm, eENCOD_Url, 0);
- length = StringLen(query_string) + 1;
+ length = StringLen(query_string);
status = CONN_Write (conn, query_string, length , &n_written);
QUERY_SendQuery (conn);
@@ -960,3 +950,8 @@ NLM_EXTERN CharPtr BLASTGetBOByRID(CharPtr RID)
CONN_Close(conn);
return in_buff;
}
+
+NLM_EXTERN CharPtr BLASTGetBOByRID(CharPtr RID)
+{
+ return BLASTGetBOByRIDEx(RID, NULL, 0, NULL);
+}
diff --git a/access/qblastapi.h b/access/qblastapi.h
index 54f87b72..0904c86c 100644
--- a/access/qblastapi.h
+++ b/access/qblastapi.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 6/28/00
*
-* $Revision: 1.10 $
+* $Revision: 1.11 $
*
* File Description:
*
@@ -37,6 +37,9 @@
* --------------------------------------------------------------------------
*
* $Log: qblastapi.h,v $
+* Revision 1.11 2003/11/03 20:51:04 madden
+* add BLASTGetBOByRIDEx
+*
* Revision 1.10 2003/01/15 22:04:50 madden
* Moved BLASTGetSeqAnnotByRIDEx from internal
*
@@ -212,6 +215,7 @@ NLM_EXTERN Nlm_Boolean BLASTGetQuerySummary(CharPtr RID, Int4 query_number,
ASN.1 will be returned as CharPtr buffer
*/
NLM_EXTERN CharPtr BLASTGetBOByRID(CharPtr RID);
+NLM_EXTERN CharPtr BLASTGetBOByRIDEx(CharPtr RID, Nlm_CharPtr host_machine, Nlm_Uint2 host_port, Nlm_CharPtr host_path);
#ifdef __cplusplus
}
diff --git a/access/vecscnapi.c b/access/vecscnapi.c
index cb7de159..79e2c5a8 100644
--- a/access/vecscnapi.c
+++ b/access/vecscnapi.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 6/13/00
*
-* $Revision: 1.13 $
+* $Revision: 1.15 $
*
* File Description:
*
@@ -467,8 +467,11 @@ NLM_EXTERN Int4 VecScreenCheckQueue (
/* estimated wait time has expired, so queue another check */
- if (curr->secondsToWait < 60) {
+ if (curr->secondsToWait < 300) {
curr->secondsToWait *= 2;
+ if (curr->secondsToWait > 300) {
+ curr->secondsToWait = 300;
+ }
}
curr->postedTime = GetSecs ();
diff --git a/algo/blast/api/Makefile b/algo/blast/api/Makefile
deleted file mode 100644
index fb2efdd7..00000000
--- a/algo/blast/api/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-.PHONY: all install
-
-all:
- cd ../lib && make -f Makefile.blast_lib
- make -f Makefile.blast_app
-
-# Solaris only!
-CXX = purify /netopt/forte6u2/bin/CC
-blast.pure:
- cd ../lib && make -f Makefile.blast_lib
- make APP=$@ CXX="$(CXX)" -f Makefile.blast_app
-
-clean:
- make -f Makefile.blast_app clean
- rm -fr blast.pure
-
-install: blast
- test -d ../bin || mkdir ../bin
- install blast ../bin/
diff --git a/algo/blast/api/Makefile.blast_app b/algo/blast/api/Makefile.blast_app
deleted file mode 100644
index cb26ab53..00000000
--- a/algo/blast/api/Makefile.blast_app
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# Makefile:
-#
-# This file was originally generated by shell script "new_project.sh"
-#
-#
-
-include ../NewBlast.mk
-
-### PATH TO A PRE-BUILT C++ TOOLKIT
-builddir = $(NCBI)/$(VERSION_STABILITY)/$(BUILD_TYPE)/build
-
-
-### DEFAULT COMPILATION FLAGS -- DON'T EDIT OR MOVE THESE 4 LINES !!!
-include $(builddir)/Makefile.mk
-srcdir = .
-BINCOPY = @:
-LOCAL_CPPFLAGS = $(BLAST_CPPFLAGS)
-
-#############################################################################
-### EDIT SETTINGS FOR THE DEFAULT (APPLICATION) TARGET HERE ###
-APP = blast
-SRC = blast_app blast_format blast_input blast_seq blast_seqalign seqsrc_readdb
-# OBJ =
-
-# PRE_LIBS = $(NCBI_C_LIBPATH) .....
-
-LIB = $(SEQ_LIBS) pub medline biblio general dbapi_driver xser xutil \
- xconnect xncbi
-
-# LIB = xser xhtml xcgi xconnect xutil xncbi
-
-## If you need the C toolkit...
-LIBS = $(NCBI_C_LIBPATH) -lncbitool -lncbiobj -lncbi -lblast $(NETWORK_LIBS) $(ORIG_LIBS)
-CPPFLAGS = $(ORIG_CPPFLAGS) -I. -I../include $(NCBI_C_INCLUDE)
-LDFLAGS = $(ORIG_LDFLAGS) $(BLAST_PROFILE) -L../lib
-
-# CFLAGS = $(ORIG_CFLAGS)
-# CXXFLAGS = $(ORIG_CXXFLAGS)
-# LDFLAGS = $(ORIG_LDFLAGS)
-# ###
-#############################################################################
-
-
-### APPLICATION BUILD RULES -- DON'T EDIT OR MOVE THIS LINE !!!
-include $(builddir)/Makefile.app
-MAKEFILE = Makefile.blast_app
-
-
-### PUT YOUR OWN ADDITIONAL TARGETS (MAKE COMMANDS/RULES) HERE
diff --git a/algo/blast/api/blast_format.c b/algo/blast/api/blast_format.c
index 277e3355..24191c3e 100644
--- a/algo/blast/api/blast_format.c
+++ b/algo/blast/api/blast_format.c
@@ -1,4 +1,4 @@
-/* $Id: blast_format.c,v 1.29 2003/10/23 20:15:37 dondosha Exp $
+/* $Id: blast_format.c,v 1.36 2003/12/09 15:31:23 kans Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -34,13 +34,13 @@ Contents: Formatting of BLAST results (SeqAlign)
Detailed Contents:
******************************************************************************
- * $Revision: 1.29 $
+ * $Revision: 1.36 $
* */
-static char const rcsid[] = "$Id: blast_format.c,v 1.29 2003/10/23 20:15:37 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_format.c,v 1.36 2003/12/09 15:31:23 kans Exp $";
-#include "blast_format.h"
-#include "blast_seq.h"
+#include <algo/blast/api/blast_format.h>
+#include <algo/blast/api/blast_seq.h>
#include <algo/blast/core/blast_filter.h>
#include <algo/blast/core/blast_util.h>
#include <sequtil.h>
@@ -83,6 +83,14 @@ BlastPrintReference PROTO((Boolean html, Int4 line_length, FILE *outfp));
extern Boolean LIBCALL
MegaBlastPrintReference PROTO((Boolean html, Int4 line_length, FILE *outfp));
+extern void MBXmlClose(MBXml* mbxp, ValNodePtr other_returns,
+ Boolean ungapped);
+
+extern CharPtr BlastGetReference (Boolean html);
+
+extern CharPtr LIBCALL BlastGetVersionNumber PROTO((void));
+extern CharPtr LIBCALL BlastGetReleaseDate PROTO((void));
+
typedef struct TxDfDbInfo {
struct TxDfDbInfo* next;
Boolean is_protein;
@@ -106,8 +114,31 @@ Int2 BlastFormattingOptionsNew(Uint1 program_number, char* file_out,
calloc(1, sizeof(BlastFormattingOptions))) == NULL)
return -1;
format_options->believe_query = FALSE;
- if ((format_options->outfp = FileOpen(file_out, "w")) == NULL)
- return -1;
+ if (align_view != 7 && align_view < 10) {
+ FILE* outfp;
+ if ((outfp = FileOpen(file_out, "w")) == NULL)
+ return -1;
+ format_options->outfp = (void *) outfp;
+ } else {
+ AsnIoPtr aip;
+ char write_mode[3];
+
+ switch (align_view) {
+ case 7:
+ strcpy(write_mode, "wx"); break;
+ case 10:
+ strcpy(write_mode, "w"); break;
+ case 11:
+ strcpy(write_mode, "wb"); break;
+ default:
+ return -1;
+ }
+
+ if ((aip = AsnIoOpen(file_out, write_mode)) == NULL)
+ return -1;
+ format_options->outfp = (void *) aip;
+ }
+
format_options->number_of_descriptions = num_descriptions;
format_options->number_of_alignments = num_alignments;
@@ -132,14 +163,219 @@ Int2 BlastFormattingOptionsNew(Uint1 program_number, char* file_out,
BlastFormattingOptions*
BlastFormattingOptionsFree(BlastFormattingOptions* format_options)
{
- FileClose(format_options->outfp);
+ if (format_options->align_view != 7 && format_options->align_view < 10)
+ FileClose( (FILE *)format_options->outfp);
+ else
+ AsnIoClose( (AsnIoPtr)format_options->outfp);
+
sfree(format_options);
return NULL;
}
+#define BXML_INCLUDE_QUERY 0x1
+
+static BlastOutputPtr
+CreateBlastOutputHead(CharPtr program, CharPtr database,
+ SeqLocPtr query_loc, Int4 flags)
+{
+ BlastOutputPtr boutp;
+ Char buffer[1024];
+ SeqPortPtr spp;
+ Boolean is_aa = FALSE;
+ Int4 i;
+
+ if((boutp = BlastOutputNew()) == NULL)
+ return FALSE;
+
+ /* For optimization BLOSUM62 may be loaded ones */
+ if (query_loc) {
+ SeqIdPtr sip = SeqLocId(query_loc);
+ BioseqPtr bsp;
+ SeqIdWrite(sip, buffer, PRINTID_FASTA_LONG, sizeof(buffer));
+ boutp->query_ID = StringSave(buffer);
+
+ bsp = BioseqLockById(sip);
+ if(!bsp ||
+ (boutp->query_def = StringSave(BioseqGetTitle(bsp))) == NULL) {
+ boutp->query_def = StringSave("No definition line found");
+ }
+ BioseqUnlock(bsp);
+
+ boutp->query_len = SeqLocLen(query_loc);
+
+ if(flags & BXML_INCLUDE_QUERY) {
+ boutp->query_seq = MemNew(boutp->query_len+1);
+ is_aa = (strcmp(program, "blastp") || strcmp(program, "tblastn"));
+ spp = SeqPortNewByLoc(query_loc,
+ (is_aa) ? Seq_code_ncbieaa : Seq_code_iupacna);
+
+ for (i = 0; i < boutp->query_len; i++) {
+ boutp->query_seq[i] = SeqPortGetResidue(spp);
+ }
+ spp = SeqPortFree(spp);
+ } else {
+ boutp->query_seq = NULL; /* Do we need sequence here??? */
+ }
+ }
+ /* Program name */
+ boutp->program = StringSave(program);
+
+ /* Database name */
+ boutp->db = StringSave(database);
+
+ /* Version text */
+ sprintf(buffer, "%s %s [%s]", program, BlastGetVersionNumber(),
+ BlastGetReleaseDate());
+ boutp->version = StringSave(buffer);
+
+ /* Reference */
+ boutp->reference = BlastGetReference(FALSE);
+
+ /* Filling parameters */
+
+ boutp->param = ParametersNew();
+ /* THE FOLLOWING IS NOT IMPLEMENTED. JUST FILL DEFAULT NUMBERS */
+ boutp->param->expect = 10;
+ boutp->param->gap_open = 0;
+ boutp->param->gap_extend = 0;
+
+ return boutp;
+}
+
+#define MACRO_atp_find(atp,name)\
+ if((atp = AsnTypeFind(amp, #name))==NULL){\
+ ErrPostEx(SEV_ERROR,0,0,\
+ "Could not find type <%s>", #name);\
+ return NULL; \
+ }
+
+static MBXml* MBXmlInit(AsnIoPtr aip, CharPtr program, CharPtr database,
+ SeqLocPtr query_loc, Int4 flags)
+{
+ MBXml* mbxp;
+ AsnModulePtr amp;
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ AsnTypePtr BLASTOUTPUT;
+ AsnTypePtr BLASTOUTPUT_program;
+ AsnTypePtr BLASTOUTPUT_version;
+ AsnTypePtr BLASTOUTPUT_reference;
+ AsnTypePtr BLASTOUTPUT_db;
+ AsnTypePtr BLASTOUTPUT_query_ID;
+ AsnTypePtr BLASTOUTPUT_query_def;
+ AsnTypePtr BLASTOUTPUT_query_len;
+ AsnTypePtr BLASTOUTPUT_query_seq;
+ AsnTypePtr BLASTOUTPUT_param;
+ AsnTypePtr BLASTOUTPUT_iterations;
+ AsnTypePtr BLASTOUTPUT_iterations_E;
+ AsnTypePtr BLASTOUTPUT_mbstat;
+
+ mbxp = (MBXml*) MemNew(sizeof(MBXml));
+
+ mbxp->aip = aip;
+
+ if (! bxmlobjAsnLoad()) {
+ return NULL;
+ }
+
+ amp = AsnAllModPtr();
+
+ MACRO_atp_find(BLASTOUTPUT,BlastOutput);
+ MACRO_atp_find(BLASTOUTPUT_program,BlastOutput.program);
+ MACRO_atp_find(BLASTOUTPUT_version,BlastOutput.version);
+ MACRO_atp_find(BLASTOUTPUT_reference,BlastOutput.reference);
+ MACRO_atp_find(BLASTOUTPUT_db,BlastOutput.db);
+ MACRO_atp_find(BLASTOUTPUT_query_ID,BlastOutput.query-ID);
+ MACRO_atp_find(BLASTOUTPUT_query_def,BlastOutput.query-def);
+ MACRO_atp_find(BLASTOUTPUT_query_len,BlastOutput.query-len);
+ MACRO_atp_find(BLASTOUTPUT_query_seq,BlastOutput.query-seq);
+ MACRO_atp_find(BLASTOUTPUT_param,BlastOutput.param);
+ MACRO_atp_find(BLASTOUTPUT_iterations,BlastOutput.iterations);
+ MACRO_atp_find(BLASTOUTPUT_iterations_E,BlastOutput.iterations.E);
+ MACRO_atp_find(BLASTOUTPUT_mbstat,BlastOutput.mbstat);
+
+ /* Start of iterations structure */
+ mbxp->atp = BLASTOUTPUT_iterations_E;
+
+ /* Head of all BlastOutput structure */
+ mbxp->BlastOutput = BLASTOUTPUT;
+
+ /* Head of iterations strucure */
+ mbxp->BlastOutput_iterations = BLASTOUTPUT_iterations;
+
+ /* Head of the final statistics for Mega BLAST */
+ mbxp->BlastOutput_mbstat = BLASTOUTPUT_mbstat;
+
+ mbxp->boutp = CreateBlastOutputHead(program, database, query_loc, flags);
+
+ atp = AsnLinkType(NULL, BLASTOUTPUT); /* link local tree */
+
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ if (! AsnOpenStruct(mbxp->aip, atp, (Pointer) mbxp->boutp)) {
+ return NULL;
+ }
+
+ if (mbxp->boutp->program != NULL) {
+ av.ptrvalue = mbxp->boutp -> program;
+ retval = AsnWrite(mbxp->aip, BLASTOUTPUT_program, &av);
+ }
+
+ if (mbxp->boutp->version != NULL) {
+ av.ptrvalue = mbxp->boutp->version;
+ retval = AsnWrite(mbxp->aip, BLASTOUTPUT_version, &av);
+ }
+
+ if (mbxp->boutp->reference != NULL) {
+ av.ptrvalue = mbxp->boutp->reference;
+ retval = AsnWrite(mbxp->aip, BLASTOUTPUT_reference, &av);
+ }
+
+ if (mbxp->boutp -> db != NULL) {
+ av.ptrvalue = mbxp->boutp->db;
+ retval = AsnWrite(mbxp->aip, BLASTOUTPUT_db, &av);
+ }
+
+ if (mbxp->boutp -> query_ID != NULL) {
+ av.ptrvalue = mbxp->boutp->query_ID;
+ retval = AsnWrite(mbxp->aip, BLASTOUTPUT_query_ID, &av);
+ }
+
+ if (mbxp->boutp->query_def != NULL) {
+ av.ptrvalue = mbxp->boutp->query_def;
+ retval = AsnWrite(mbxp->aip, BLASTOUTPUT_query_def, &av);
+ }
+
+ av.intvalue = mbxp->boutp->query_len;
+ retval = AsnWrite(mbxp->aip, BLASTOUTPUT_query_len, &av);
+
+ if (mbxp->boutp->query_seq != NULL) {
+ av.ptrvalue = mbxp->boutp->query_seq;
+ retval = AsnWrite(mbxp->aip, BLASTOUTPUT_query_seq, &av);
+ }
+
+ if (mbxp->boutp->param != NULL) {
+ if (!ParametersAsnWrite(mbxp->boutp->param,
+ mbxp->aip, BLASTOUTPUT_param)) {
+ return NULL;
+ }
+ }
+
+ if(!AsnOpenStruct(mbxp->aip, BLASTOUTPUT_iterations, NULL))
+ return NULL;
+
+ AsnIoFlush(mbxp->aip);
+
+ return mbxp;
+}
+
Int2 BLAST_FormatResults(SeqAlignPtr head, char* blast_database,
char* blast_program, Int4 num_queries,
- SeqLocPtr query_slp, BlastMask* blast_mask,
+ SeqLocPtr query_slp, BlastMaskLoc* blast_mask,
BlastFormattingOptions* format_options, Boolean is_ooframe)
{
SeqAlignPtr seqalign = head, sap, next_seqalign;
@@ -154,12 +390,16 @@ Int2 BLAST_FormatResults(SeqAlignPtr head, char* blast_database,
BlastPruneSapStruct* prune;
SeqAnnotPtr seqannot;
MBXml* mbxp = NULL;
- FILE *outfp;
+ FILE *outfp = NULL;
if (!format_options || !format_options->outfp || !query_slp)
return -1;
- outfp = format_options->outfp;
+ if (format_options->align_view != 7 && format_options->align_view < 10)
+ outfp = (FILE *) format_options->outfp;
+ else
+ aip = (AsnIoPtr) format_options->outfp;
+
align_type = BlastGetTypes(blast_program, &query_is_na, &db_is_na);
BlastProgram2Number(blast_program, &program_number);
@@ -169,12 +409,16 @@ Int2 BLAST_FormatResults(SeqAlignPtr head, char* blast_database,
query_index = 0;
slp = query_slp;
mask_loc_head = mask_loc =
- BlastMaskToSeqLoc(program_number, blast_mask, slp);
+ BlastMaskLocToSeqLoc(program_number, blast_mask, slp);
if (!seqalign && format_options->align_view < 7) {
fprintf(outfp, "\n\n ***** No hits found ******\n\n");
}
+ if (format_options->align_view == 7) {
+ mbxp = MBXmlInit(aip, "megablast", blast_database, slp, 0);
+ }
+
while (seqalign) {
/* Find which query the current SeqAlign is for */
query_id = TxGetQueryIdFromSeqAlign(seqalign);
@@ -246,9 +490,8 @@ Int2 BLAST_FormatResults(SeqAlignPtr head, char* blast_database,
outfp, (format_options->align_view == 9));
SeqAlignSetFree(seqalign);
- } else if(format_options->align_view == 7 ||
- format_options->align_view == 10 ||
- format_options->align_view == 11) {
+ } else if(format_options->align_view == 7) {
+ /* XML printout - NOT IMPLEMENTED YET */
IterationPtr iterp;
iterp = BXMLBuildOneQueryIteration(seqalign, NULL, FALSE,
@@ -265,37 +508,37 @@ Int2 BLAST_FormatResults(SeqAlignPtr head, char* blast_database,
if (aip) {
SeqAnnotAsnWrite((SeqAnnotPtr) seqannot, aip, NULL);
AsnIoReset(aip);
+ } else if (outfp) {
+ /* Uncacheing causes problems with ordinal nos. vs. gi's. */
+ prune = BlastPruneHitsFromSeqAlign(seqalign,
+ format_options->number_of_descriptions, NULL);
+ ObjMgrSetHold();
+ init_buff_ex(85);
+ PrintDefLinesFromSeqAlign(prune->sap, 80, outfp,
+ format_options->print_options, FIRST_PASS, NULL);
+ free_buff();
+
+ prune = BlastPruneHitsFromSeqAlign(seqalign,
+ format_options->number_of_alignments, prune);
+ seqannot->data = prune->sap;
+ if(is_ooframe) {
+ OOFShowBlastAlignment(prune->sap, mask_loc, outfp,
+ format_options->align_options, NULL);
+ } else if (format_options->align_view != 0) {
+ ShowTextAlignFromAnnot(seqannot, 60, outfp, NULL, NULL,
+ format_options->align_options, NULL, mask_loc, NULL);
+ } else {
+ ShowTextAlignFromAnnot(seqannot, 60, outfp, NULL, NULL,
+ format_options->align_options, NULL, mask_loc,
+ FormatScoreFunc);
+ }
+ seqannot->data = seqalign;
+ prune = BlastPruneSapStructDestruct(prune);
+ ObjMgrClearHold();
+ ObjMgrFreeCache(0);
}
- /* Uncacheing causes problems with ordinal nos. vs. gi's. */
- prune = BlastPruneHitsFromSeqAlign(seqalign,
- format_options->number_of_descriptions, NULL);
- ObjMgrSetHold();
- init_buff_ex(85);
- PrintDefLinesFromSeqAlign(prune->sap, 80, outfp,
- format_options->print_options, FIRST_PASS, NULL);
- free_buff();
-
- prune = BlastPruneHitsFromSeqAlign(seqalign,
- format_options->number_of_alignments, prune);
- seqannot->data = prune->sap;
- if(is_ooframe) {
- OOFShowBlastAlignment(prune->sap, mask_loc, outfp,
- format_options->align_options, NULL);
- } else if (format_options->align_view != 0) {
- ShowTextAlignFromAnnot(seqannot, 60, outfp, NULL, NULL,
- format_options->align_options, NULL, mask_loc, NULL);
- } else {
- ShowTextAlignFromAnnot(seqannot, 60, outfp, NULL, NULL,
- format_options->align_options, NULL, mask_loc,
- FormatScoreFunc);
- }
- seqannot->data = seqalign;
- prune = BlastPruneSapStructDestruct(prune);
- ObjMgrClearHold();
- ObjMgrFreeCache(0);
seqannot = SeqAnnotFree(seqannot);
}
-
seqalign = next_seqalign;
/* Relink the mask locations so chain can be freed in the end.
The 'tmp_loc' variable points to the location that was unlinked. */
@@ -306,6 +549,10 @@ Int2 BLAST_FormatResults(SeqAlignPtr head, char* blast_database,
} /* End loop on seqaligns for different queries */
+ if (format_options->align_view == 7 && mbxp) {
+ MBXmlClose(mbxp, NULL, format_options->ungapped);
+ }
+
/* Free the mask locations. Note that mask_loc is not a real SeqLoc,
but a ValNode wrapper around the actual masking locations. */
for (mask_loc = mask_loc_head; mask_loc; ) {
@@ -469,7 +716,7 @@ FormatBlastParameters(Uint1 program_number,
add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
}
- if (hit_options->gapped_calculation) {
+ if (score_options->gapped_calculation) {
sprintf(buffer, "Gap Penalties: Existence: %ld, Extension: %ld",
(long) score_options->gap_open,
(long) score_options->gap_extend);
@@ -508,7 +755,7 @@ FormatBlastParameters(Uint1 program_number,
}
add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
- if (hit_options->gapped_calculation) {
+ if (score_options->gapped_calculation) {
sprintf(buffer,
"Number of HSP's better than %4.1f without gapping: %ld",
hit_options->expect_value,
@@ -521,7 +768,8 @@ FormatBlastParameters(Uint1 program_number,
}
}
BlastNumber2Program(program_number, &prog_name);
- qlen = query_info->total_length;
+ /* Total query length does not include the first and last sentinel byte */
+ qlen = query_info->context_offsets[query_info->last_context+1] - 1;
sfree(prog_name);
sprintf(buffer, "length of query: %ld", (long)qlen);
add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
@@ -540,7 +788,7 @@ FormatBlastParameters(Uint1 program_number,
add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
if (program_number == blast_type_blastn ||
- !hit_options->gapped_calculation)
+ !score_options->gapped_calculation)
kbp = sbp->kbp[query_info->first_context];
else
kbp = sbp->kbp_gap[query_info->first_context];
@@ -548,7 +796,7 @@ FormatBlastParameters(Uint1 program_number,
sprintf(buffer, "X1: %ld (%4.1f bits)",
(long)return_stats->x_drop_ungapped, word_options->x_dropoff);
add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
- if (hit_options->gapped_calculation) {
+ if (score_options->gapped_calculation) {
sprintf(buffer, "X2: %ld (%4.1f bits)",
(long)return_stats->x_drop_gap, ext_options->gap_x_dropoff);
add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
@@ -565,9 +813,9 @@ FormatBlastParameters(Uint1 program_number,
cutoff = 0;
if (single_query) {
evalue = hit_options->expect_value;
- BLAST_Cutoffs_simple(&cutoff, &evalue, kbp,
+ BLAST_Cutoffs(&cutoff, &evalue, kbp,
(double) query_info->eff_searchsp_array[query_info->first_context],
- FALSE);
+ FALSE, 0);
sprintf(buffer, "S2: %ld (%4.1f bits)", (long) cutoff,
(((cutoff)*(kbp->Lambda))-(kbp->logK))/NCBIMATH_LN2);
add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
@@ -771,7 +1019,7 @@ static void ScoreAndEvalueToBuffers(double bit_score, double evalue,
* that prints results before the traceback stage, e.g. the on-the-fly
* tabular output, a la the -D3 option of the old megablast.
*/
-void BLAST_PrintIntermediateResults(BlastResults* results,
+void BLAST_PrintIntermediateResults(BlastHSPResults* results,
BlastQueryInfo* query_info, SeqLocPtr query_slp,
ReadDBFILEPtr rdfp, SeqIdPtr seqid, BlastScoreBlk* sbp,
char* filename)
diff --git a/algo/blast/api/blast_format.h b/algo/blast/api/blast_format.h
index 3128a53a..8e1da44b 100644
--- a/algo/blast/api/blast_format.h
+++ b/algo/blast/api/blast_format.h
@@ -1,4 +1,4 @@
-/* $Id: blast_format.h,v 1.15 2003/08/25 22:25:46 dondosha Exp $
+/* $Id: blast_format.h,v 1.17 2003/12/03 17:30:24 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,7 +32,7 @@ Author: Ilya Dondoshansky
Contents: Functions needed for formatting of BLAST results
******************************************************************************
- * $Revision: 1.15 $
+ * $Revision: 1.17 $
* */
#ifndef __BLAST_FORMAT__
#define __BLAST_FORMAT__
@@ -61,7 +61,7 @@ typedef struct BlastFormattingOptions {
Uint4 print_options;
Boolean believe_query;
Boolean html;
- FILE *outfp;
+ void* outfp; /**< Output file: either FILE* or AsnIoPtr */
Int4 number_of_descriptions;
Int4 number_of_alignments;
Boolean ungapped; /**< Should this be here????? */
@@ -116,7 +116,7 @@ typedef struct MBXml {
*/
Int2 BLAST_FormatResults(SeqAlignPtr head, char* blast_database,
char* blast_program, Int4 num_queries,
- SeqLocPtr query_slp, BlastMask* mask_loc,
+ SeqLocPtr query_slp, BlastMaskLoc* mask_loc,
BlastFormattingOptions* format_options, Boolean is_ooframe);
/** Print the summary at the end of the BLAST report.
@@ -145,7 +145,7 @@ Int2 PrintOutputFooter(Uint1 program_number,
Int2 BLAST_PrintOutputHeader(BlastFormattingOptions* format_options,
Boolean greedy_extension, ReaddbNewArgs* readdb_args);
-void BLAST_PrintIntermediateResults(BlastResults* results,
+void BLAST_PrintIntermediateResults(BlastHSPResults* results,
BlastQueryInfo* query_info, SeqLocPtr query_slp,
ReadDBFILEPtr rdfp, SeqIdPtr seqid, BlastScoreBlk* sbp,
char* filename);
diff --git a/algo/blast/api/blast_input.c b/algo/blast/api/blast_input.c
index 04836b73..dcf2edbc 100644
--- a/algo/blast/api/blast_input.c
+++ b/algo/blast/api/blast_input.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: blast_input.c,v 1.8 2003/09/15 21:18:30 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_input.c,v 1.10 2003/12/03 17:30:25 dondosha Exp $";
/* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -31,30 +31,30 @@ Author: Ilya Dondoshansky
Contents: Reading FASTA sequences for BLAST
-$Revision: 1.8 $
+$Revision: 1.10 $
******************************************************************************/
#include <objloc.h>
#include <tofasta.h>
-#include "blast_input.h"
-#include "blast_seq.h"
+#include <algo/blast/api/blast_input.h>
+#include <algo/blast/api/blast_seq.h>
#define MAX_NUM_QUERIES 16383 /* == 1/2 INT2_MAX */
#define MAX_TOTAL_LENGTH 20000000
Boolean
BLAST_GetQuerySeqLoc(FILE *infp, Boolean query_is_na, Uint1 strand,
- Int4 start, Int4 end, BlastMask** lcase_mask, SeqLocPtr* query_slp,
+ Int4 start, Int4 end, BlastMaskLoc** lcase_mask, SeqLocPtr* query_slp,
Int4 ctr_start, Int4* num_queries)
{
Int8 total_length;
BioseqPtr query_bsp;
SeqLocPtr mask_slp, last_slp;
- BlastMask* last_mask;
+ BlastMaskLoc* last_mask;
char prefix[2]; /* for FastaToSeqEntryForDb */
Int2 ctr = ctr_start + 1; /* Counter for FastaToSeqEntryForDb */
Int4 query_index = 0;
- BlastMask* new_mask;
+ BlastMaskLoc* new_mask;
SeqEntryPtr sep;
Boolean done = TRUE;
Int4 from, to;
@@ -79,7 +79,7 @@ BLAST_GetQuerySeqLoc(FILE *infp, Boolean query_is_na, Uint1 strand,
&ctr, (lcase_mask ? &mask_slp : NULL))) != NULL)
{
if (mask_slp) {
- new_mask = BlastMaskFromSeqLoc(mask_slp, query_index);
+ new_mask = BlastMaskLocFromSeqLoc(mask_slp, query_index);
if (!last_mask)
*lcase_mask = last_mask = new_mask;
diff --git a/algo/blast/api/blast_input.h b/algo/blast/api/blast_input.h
index 60f3be47..2db0736d 100644
--- a/algo/blast/api/blast_input.h
+++ b/algo/blast/api/blast_input.h
@@ -1,4 +1,4 @@
-/* $Id: blast_input.h,v 1.9 2003/08/25 22:25:46 dondosha Exp $
+/* $Id: blast_input.h,v 1.10 2003/12/03 17:30:25 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -31,7 +31,7 @@ Author: Ilya Dondoshansky
Contents: Reading FASTA sequences for BLAST
-$Revision: 1.9 $
+$Revision: 1.10 $
******************************************************************************/
@@ -65,7 +65,7 @@ extern "C" {
*/
Boolean
BLAST_GetQuerySeqLoc(FILE *infp, Boolean query_is_na, Uint1 strand,
- Int4 from, Int4 to, BlastMask** lcase_mask, SeqLocPtr* query_slp, Int4 ctr_start,
+ Int4 from, Int4 to, BlastMaskLoc** lcase_mask, SeqLocPtr* query_slp, Int4 ctr_start,
Int4* num_queries);
/** Given a file containing sequence(s) in fasta format,
diff --git a/algo/blast/api/blast_seq.c b/algo/blast/api/blast_seq.c
index a905801d..d3a2ced0 100644
--- a/algo/blast/api/blast_seq.c
+++ b/algo/blast/api/blast_seq.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: blast_seq.c,v 1.26 2003/09/17 16:20:56 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_seq.c,v 1.33 2003/12/03 17:30:25 dondosha Exp $";
/*
* ===========================================================================
*
@@ -33,20 +33,20 @@ Author: Ilya Dondoshansky
Contents: Functions converting between SeqLocs and structures used in BLAST.
******************************************************************************
- * $Revision: 1.26 $
+ * $Revision: 1.33 $
* */
#include <seqport.h>
#include <sequtil.h>
#include <objloc.h>
-#include "blast_seq.h"
+#include <algo/blast/api/blast_seq.h>
#include <algo/blast/core/blast_filter.h>
#include <algo/blast/core/blast_util.h>
#include <algo/blast/core/blast_stat.h> /* Needed for NCBI4NA_TO_BLASTNA definition only */
-BlastMask* BlastMaskFromSeqLoc(SeqLocPtr mask_slp, Int4 index)
+BlastMaskLoc* BlastMaskLocFromSeqLoc(SeqLocPtr mask_slp, Int4 index)
{
- BlastMask* new_mask = (BlastMask*) calloc(1, sizeof(BlastMask));
+ BlastMaskLoc* new_mask = (BlastMaskLoc*) calloc(1, sizeof(BlastMaskLoc));
BlastSeqLoc* loc,* last_loc = NULL,* head_loc = NULL;
SeqIntPtr si;
@@ -69,7 +69,7 @@ BlastMask* BlastMaskFromSeqLoc(SeqLocPtr mask_slp, Int4 index)
return new_mask;
}
-SeqLocPtr BlastMaskToSeqLoc(Uint1 program_number, BlastMask* mask_loc,
+SeqLocPtr BlastMaskLocToSeqLoc(Uint1 program_number, BlastMaskLoc* mask_loc,
SeqLocPtr slp)
{
BlastSeqLoc* loc;
@@ -142,10 +142,10 @@ SeqLocPtr BlastMaskToSeqLoc(Uint1 program_number, BlastMask* mask_loc,
return mask_head;
}
-Int2 BlastMaskDNAToProtein(BlastMask** mask_loc_ptr, SeqLocPtr slp)
+Int2 BlastMaskLocDNAToProtein(BlastMaskLoc** mask_loc_ptr, SeqLocPtr slp)
{
Int2 status = 0;
- BlastMask* last_mask = NULL,* head_mask = NULL,* mask_loc;
+ BlastMaskLoc* last_mask = NULL,* head_mask = NULL,* mask_loc;
Int4 dna_length;
BlastSeqLoc* dna_loc,* prot_loc_head,* prot_loc_last;
DoubleInt* dip;
@@ -168,9 +168,9 @@ Int2 BlastMaskDNAToProtein(BlastMask** mask_loc_ptr, SeqLocPtr slp)
coordinates */
for (context = 0; context < NUM_FRAMES; ++context) {
if (!last_mask) {
- head_mask = last_mask = (BlastMask *) calloc(1, sizeof(BlastMask));
+ head_mask = last_mask = (BlastMaskLoc *) calloc(1, sizeof(BlastMaskLoc));
} else {
- last_mask->next = (BlastMask *) calloc(1, sizeof(BlastMask));
+ last_mask->next = (BlastMaskLoc *) calloc(1, sizeof(BlastMaskLoc));
last_mask = last_mask->next;
}
@@ -203,7 +203,7 @@ Int2 BlastMaskDNAToProtein(BlastMask** mask_loc_ptr, SeqLocPtr slp)
}
/* Free the mask with nucleotide coordinates */
- BlastMaskFree(*mask_loc_ptr);
+ BlastMaskLocFree(*mask_loc_ptr);
/* Return the new mask with protein coordinates */
*mask_loc_ptr = head_mask;
@@ -211,11 +211,11 @@ Int2 BlastMaskDNAToProtein(BlastMask** mask_loc_ptr, SeqLocPtr slp)
}
-Int2 BlastMaskProteinToDNA(BlastMask** mask_loc_ptr, SeqLocPtr slp)
+Int2 BlastMaskLocProteinToDNA(BlastMaskLoc** mask_loc_ptr, SeqLocPtr slp)
{
Int2 status = 0;
Int4 index;
- BlastMask* mask_loc;
+ BlastMaskLoc* mask_loc;
BlastSeqLoc* loc;
DoubleInt* dip;
Int4 dna_length;
@@ -270,6 +270,7 @@ static Int4 BLAST_SetUpQueryInfo(SeqLocPtr slp, Uint1 program,
BlastQueryInfo* query_info;
Int4* context_offsets;
Int4 index;
+ Int4 total_contexts;
if (translate)
num_frames = 6;
@@ -285,6 +286,8 @@ static Int4 BLAST_SetUpQueryInfo(SeqLocPtr slp, Uint1 program,
query_info->first_context = 0;
query_info->num_queries = ValNodeLen(slp);
query_info->last_context = query_info->num_queries*num_frames - 1;
+ total_contexts = query_info->last_context + 1;
+
if ((strand = SeqLocStrand(slp)) == Seq_strand_minus) {
if (translate)
query_info->first_context = 3;
@@ -298,14 +301,14 @@ static Int4 BLAST_SetUpQueryInfo(SeqLocPtr slp, Uint1 program,
}
if ((context_offsets = (Int4*)
- malloc((query_info->last_context+2)*sizeof(Int4))) == NULL)
+ malloc((total_contexts+1)*sizeof(Int4))) == NULL)
return -1;
if ((query_info->eff_searchsp_array =
- (Int8*) malloc((query_info->last_context+1)*sizeof(Int8))) == NULL)
+ (Int8*) malloc(total_contexts*sizeof(Int8))) == NULL)
return -1;
if ((query_info->length_adjustments =
- (Int4*) malloc((query_info->last_context+1)*sizeof(Int4))) == NULL)
+ (Int4*) malloc(total_contexts*sizeof(Int4))) == NULL)
return -1;
context_offsets[0] = 0;
@@ -352,7 +355,6 @@ static Int4 BLAST_SetUpQueryInfo(SeqLocPtr slp, Uint1 program,
context_offsets[index+1] = context_offsets[index] + length + 1;
}
}
- query_info->total_length = context_offsets[index];
*query_info_ptr = query_info;
return 0;
diff --git a/algo/blast/api/blast_seq.h b/algo/blast/api/blast_seq.h
index 967e48c6..54065509 100644
--- a/algo/blast/api/blast_seq.h
+++ b/algo/blast/api/blast_seq.h
@@ -1,4 +1,4 @@
-/* $Id: blast_seq.h,v 1.8 2003/08/25 22:25:46 dondosha Exp $
+/* $Id: blast_seq.h,v 1.9 2003/12/03 17:30:25 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -35,7 +35,7 @@ Contents: Functions converting from SeqLocs to structures used in BLAST and
Detailed Contents:
******************************************************************************
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
* */
#ifndef __BLAST_SEQ__
#define __BLAST_SEQ__
@@ -54,18 +54,18 @@ extern "C" {
#define NUM_FRAMES 6
-/** Convert a SeqLoc of type int or packed_int to a BlastMask structure.
+/** Convert a SeqLoc of type int or packed_int to a BlastMaskLoc structure.
* @param mask_slp The SeqLoc to be converted [in]
* @param index The ordinal number of the sequence to be assigned to the new
- * BlastMask
- * @return Pointer to the allocated BlastMask structure.
+ * BlastMaskLoc
+ * @return Pointer to the allocated BlastMaskLoc structure.
*/
-BlastMask* BlastMaskFromSeqLoc(SeqLocPtr mask_slp, Int4 index);
+BlastMaskLoc* BlastMaskLocFromSeqLoc(SeqLocPtr mask_slp, Int4 index);
-/** Convert a BlastMask list to a list of SeqLocs, used for formatting
+/** Convert a BlastMaskLoc list to a list of SeqLocs, used for formatting
* BLAST results.
*/
-SeqLocPtr BlastMaskToSeqLoc(Uint1 program_number, BlastMask* mask_loc,
+SeqLocPtr BlastMaskLocToSeqLoc(Uint1 program_number, BlastMaskLoc* mask_loc,
SeqLocPtr slp);
/** Duplicate masks in 6 frames for each nucleotide sequence, converting
@@ -73,13 +73,13 @@ SeqLocPtr BlastMaskToSeqLoc(Uint1 program_number, BlastMask* mask_loc,
* @param mask_loc_ptr Masks list to be modified [in] [out]
* @param slp List of nucleotide query SeqLoc's [in]
*/
-Int2 BlastMaskDNAToProtein(BlastMask** mask_loc_ptr, SeqLocPtr slp);
+Int2 BlastMaskLocDNAToProtein(BlastMaskLoc** mask_loc_ptr, SeqLocPtr slp);
/** Convert all masks' protein coordinates to nucleotide.
* @param mask_loc_ptr Masks list to be modified [in] [out]
* @param slp List of nucleotide query SeqLoc's [in]
*/
-Int2 BlastMaskProteinToDNA(BlastMask** mask_loc_ptr, SeqLocPtr slp);
+Int2 BlastMaskLocProteinToDNA(BlastMaskLoc** mask_loc_ptr, SeqLocPtr slp);
/** Given a list of query SeqLoc's, create the sequence block and the query
* info structure. This is the last time SeqLoc is needed before formatting.
diff --git a/algo/blast/api/blast_seqalign.c b/algo/blast/api/blast_seqalign.c
index d9754dc0..36445ec9 100644
--- a/algo/blast/api/blast_seqalign.c
+++ b/algo/blast/api/blast_seqalign.c
@@ -1,4 +1,4 @@
-/* $Id: blast_seqalign.c,v 1.24 2003/09/15 21:18:30 dondosha Exp $
+/* $Id: blast_seqalign.c,v 1.27 2003/12/03 17:30:25 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,12 +32,12 @@ Author: Ilya Dondoshansky
Contents: Conversion of BLAST results to the SeqAlign form
******************************************************************************
- * $Revision: 1.24 $
+ * $Revision: 1.27 $
* */
-static char const rcsid[] = "$Id: blast_seqalign.c,v 1.24 2003/09/15 21:18:30 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_seqalign.c,v 1.27 2003/12/03 17:30:25 dondosha Exp $";
-#include "blast_seqalign.h"
+#include <algo/blast/api/blast_seqalign.h>
extern Int4 LIBCALL HspArrayPurge PROTO((BlastHSP** hsp_array,
Int4 hspcnt, Boolean clear_num));
@@ -1321,7 +1321,7 @@ BLAST_GapInfoToSeqAlign(Uint1 program_number, BlastHSPList* hsp_list,
}
Int2 BLAST_ResultsToSeqAlign(Uint1 program_number,
- BlastResults* results, SeqLocPtr query_slp,
+ BlastHSPResults* results, SeqLocPtr query_slp,
BlastSeqSrc* bssp, SeqLocPtr subject_slp,
BlastScoringOptions* score_options, BlastScoreBlk* sbp,
Boolean is_gapped, SeqAlignPtr* head_seqalign)
@@ -1357,6 +1357,7 @@ Int2 BLAST_ResultsToSeqAlign(Uint1 program_number,
char* id_str = BLASTSeqSrcGetSeqIdStr(bssp, (void*) &hsp_list->oid);
subject_id = SeqIdParse(id_str);
subject_length = BLASTSeqSrcGetSeqLen(bssp, (void*) &hsp_list->oid);
+ sfree(id_str);
}
if (is_gapped) {
BLAST_GapInfoToSeqAlign(program_number, hsp_list, query_id,
diff --git a/algo/blast/api/blast_seqalign.h b/algo/blast/api/blast_seqalign.h
index 76c83b04..3a6fa3e0 100644
--- a/algo/blast/api/blast_seqalign.h
+++ b/algo/blast/api/blast_seqalign.h
@@ -1,4 +1,4 @@
-/* $Id: blast_seqalign.h,v 1.11 2003/08/25 22:25:46 dondosha Exp $
+/* $Id: blast_seqalign.h,v 1.12 2003/12/03 17:30:26 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,7 +32,7 @@ Author: Ilya Dondoshansky
Contents: Functions to convert BLAST results to the SeqAlign form
******************************************************************************
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
* */
#ifndef __BLAST_SEQALIGN__
#define __BLAST_SEQALIGN__
@@ -62,7 +62,7 @@ extern "C" {
* @param is_gapped Is this a gapped alignment search? [in]
* @param head_seqalign List of SeqAlign's [out]
*/
-Int2 BLAST_ResultsToSeqAlign(Uint1 program_number, BlastResults* results,
+Int2 BLAST_ResultsToSeqAlign(Uint1 program_number, BlastHSPResults* results,
SeqLocPtr query_slp, BlastSeqSrc* bssp, SeqLocPtr subject_slp,
BlastScoringOptions* score_options, BlastScoreBlk* sbp,
Boolean is_gapped, SeqAlignPtr* head_seqalign);
diff --git a/algo/blast/api/nmakefile b/algo/blast/api/nmakefile
deleted file mode 100644
index 19547aad..00000000
--- a/algo/blast/api/nmakefile
+++ /dev/null
@@ -1,35 +0,0 @@
-CC=cl.exe
-CFLAGS=/nologo /DWIN32 -I\\dizzy\public\ncbi\include /I..\include
-LIB=lib.exe
-LINK=link.exe
-LDFLAGS=/nologo /libpath:\\dizzy\public\ncbi\Release /libpath:. /nodefaultlib:msvcrt.lib
-LIBS=blast.lib ncbitool.lib ncbiobj.lib ncbimmdb.lib ncbimain.lib ncbi.lib user32.lib
-
-OBJ=aa_lookup.obj\
-aa_ungapped.obj\
-blast_dust.obj\
-blast_engine.obj\
-blast_extend.obj\
-blast_filter.obj\
-blast_format.obj\
-blast_gapalign.obj\
-blast_hits.obj\
-blast_message.obj\
-blast_seg.obj\
-blast_seqalign.obj\
-blast_traceback.obj\
-blast_util.obj\
-mb_lookup.obj\
-na_lookup.obj\
-util.obj
-
-all: blast.lib blast_driver.exe
-
-blast.lib : $(OBJ)
- $(LIB) /out:blast.lib $(OBJ)
-
-blast_driver.exe : blast_driver.obj blast_options.obj blast_setup.obj blast.lib
- $(LINK) $(LDFLAGS) /out:blast_driver.exe blast_driver.obj blast_options.obj blast_setup.obj $(LIBS)
-
-clean:
- del *.obj blast_driver.exe
diff --git a/algo/blast/api/seqsrc_readdb.c b/algo/blast/api/seqsrc_readdb.c
index f7e367d9..eff22dfd 100644
--- a/algo/blast/api/seqsrc_readdb.c
+++ b/algo/blast/api/seqsrc_readdb.c
@@ -1,4 +1,4 @@
-/* $Id: seqsrc_readdb.c,v 1.9 2003/09/15 21:18:30 dondosha Exp $
+/* $Id: seqsrc_readdb.c,v 1.16 2004/01/30 23:50:27 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -30,9 +30,9 @@
*
*/
-static char const rcsid[] = "$Id: seqsrc_readdb.c,v 1.9 2003/09/15 21:18:30 dondosha Exp $";
+static char const rcsid[] = "$Id: seqsrc_readdb.c,v 1.16 2004/01/30 23:50:27 dondosha Exp $";
-#include "seqsrc_readdb.h"
+#include <algo/blast/api/seqsrc_readdb.h>
#include <algo/blast/core/blast_def.h>
#include <algo/blast/core/blast_util.h>
@@ -74,6 +74,53 @@ static Int8 ReaddbGetTotLen(void* readdb_handle, void* ignoreme)
return dblength;
}
+/** Retrieves the name of the BLAST database.
+ * @param readdb_handle Pointer to initialized ReadDBFILEPtr structure [in]
+ * @param ignoreme Unused by this implementation [in]
+ */
+static char* ReaddbGetName(void* readdb_handle, void* ignoreme)
+{
+ ReadDBFILEPtr rdfp = (ReadDBFILEPtr) readdb_handle;
+
+ return strdup(readdb_get_filename(rdfp));
+}
+
+/** Retrieves the definition of the BLAST database.
+ * @param readdb_handle Pointer to initialized ReadDBFILEPtr structure [in]
+ * @param ignoreme Unused by this implementation [in]
+ */
+static char* ReaddbGetDefinition(void* readdb_handle, void* ignoreme)
+{
+ ReadDBFILEPtr rdfp = (ReadDBFILEPtr) readdb_handle;
+ char* definition = NULL;
+
+ if ((definition = readdb_get_title(rdfp)) == NULL)
+ definition = readdb_get_filename(rdfp);
+ return strdup(definition);
+}
+
+/** Retrieves the date of the BLAST database.
+ * @param readdb_handle Pointer to initialized ReadDBFILEPtr structure [in]
+ * @param ignoreme Unused by this implementation [in]
+ */
+static char* ReaddbGetDate(void* readdb_handle, void* ignoreme)
+{
+ ReadDBFILEPtr rdfp = (ReadDBFILEPtr) readdb_handle;
+
+ return strdup(readdb_get_date(rdfp));
+}
+
+/** Retrieves the date of the BLAST database.
+ * @param readdb_handle Pointer to initialized ReadDBFILEPtr structure [in]
+ * @param ignoreme Unused by this implementation [in]
+ */
+static Boolean ReaddbGetIsProt(void* readdb_handle, void* ignoreme)
+{
+ ReadDBFILEPtr rdfp = (ReadDBFILEPtr) readdb_handle;
+
+ return readdb_is_prot(rdfp);
+}
+
/** Retrieves the sequence meeting the criteria defined by its second argument.
* @param readdb_handle Pointer to initialized ReadDBFILEPtr structure [in]
* @param args Pointer to GetSeqArg structure [in]
@@ -153,6 +200,31 @@ static char* ReaddbGetSeqIdStr(void* readdb_handle, void* args)
return seqid_str;
}
+/** Retrieves the sequence identifier meeting the criteria defined by its
+ * second argument. Currently it is an ordinal id (integer value).
+ * Client code is responsible for deallocating the return value.
+ * @param readdb_handle Pointer to initialized ReadDBFILEPtr structure [in]
+ * @param args Pointer to integer indicating ordinal id [in]
+ * @return Sequence id structure generated from ASN.1 spec,
+ * cast to a void pointer.
+ */
+static void* ReaddbGetSeqId(void* readdb_handle, void* args)
+{
+ ReadDBFILEPtr rdfp = (ReadDBFILEPtr) readdb_handle;
+ Int4* oid = (Int4*) args;
+ SeqIdPtr sip = NULL;
+ char *seqid_str = NULL;
+
+ if (!rdfp || !oid)
+ return NULL;
+
+ if (!readdb_get_descriptor(rdfp, *oid, &sip, NULL)) {
+ return NULL;
+ }
+
+ return (void*) sip;
+}
+
/** Retrieve length of a given database sequence.
* @param readdb_handle Pointer to initialized ReadDBFILEPtr structure [in]
* @param args Pointer to integer indicating ordinal id [in]
@@ -222,18 +294,35 @@ static Int2 ReaddbGetNextChunk(void* readdb_handle, BlastSeqSrcIterator* itr)
{
ReadDBFILEPtr rdfp = (ReadDBFILEPtr) readdb_handle;
OIDListPtr oidlist = ReaddbFetchFirstOIDList(rdfp);
- static unsigned int current_oid = 0;
unsigned int nseqs;
if (!rdfp || !itr)
return BLAST_SEQSRC_ERROR;
- /* call get_totals_ex2?: need a less expensive and accurate way of doing
- * this */
- nseqs = ReaddbGetNumberOfSeqs(rdfp);
- if (current_oid >= nseqs) {
- return BLAST_SEQSRC_EOF;
+
+ if (itr->next_oid < rdfp->start)
+ itr->next_oid = rdfp->start;
+
+ while (rdfp) {
+ if (rdfp->stop > 0) {
+ nseqs = rdfp->stop + 1;
+ } else {
+ /* call get_totals_ex2?: need a less expensive and accurate way of
+ doing this */
+ nseqs = ReaddbGetNumberOfSeqs(rdfp);
+ }
+
+
+ if (itr->next_oid >= nseqs) {
+ if (nseqs < rdfp->num_seqs)
+ itr->next_oid = UINT4_MAX;
+ rdfp = rdfp->next;
+ } else {
+ break;
+ }
}
+ if (!rdfp)
+ return BLAST_SEQSRC_EOF;
if (oidlist) {
itr->itr_type = eOidList;
@@ -243,9 +332,9 @@ static Int2 ReaddbGetNextChunk(void* readdb_handle, BlastSeqSrcIterator* itr)
} else {
itr->itr_type = eOidRange;
NlmMutexLockEx(&ReaddbMutex);
- itr->current_pos = itr->oid_range[0] = current_oid;
- itr->oid_range[1] = MIN(current_oid + itr->chunk_sz, nseqs);
- current_oid = itr->oid_range[1];
+ itr->current_pos = itr->oid_range[0] = itr->next_oid;
+ itr->oid_range[1] = MIN(itr->next_oid + itr->chunk_sz, nseqs);
+ itr->next_oid = itr->oid_range[1];
NlmMutexUnlock(ReaddbMutex);
}
@@ -305,19 +394,30 @@ BlastSeqSrc* ReaddbSeqSrcNew(BlastSeqSrc* retval, void* args)
if ( !(rdfp = readdb_new(rargs->dbname, rargs->is_protein)))
return NULL;
- /* Initialize the BlastSeqSrc structure fields with used-defined function
+ /* Initialize the BlastSeqSrc structure fields with user-defined function
* pointers and rdfp */
SetDeleteFnPtr(retval, &ReaddbSeqSrcFree);
SetDataStructure(retval, (void*) rdfp);
SetGetNumSeqs(retval, &ReaddbGetNumSeqs);
SetGetMaxSeqLen(retval, &ReaddbGetMaxLength);
SetGetTotLen(retval, &ReaddbGetTotLen);
+ SetGetName(retval, &ReaddbGetName);
+ SetGetDefinition(retval, &ReaddbGetDefinition);
+ SetGetDate(retval, &ReaddbGetDate);
+ SetGetIsProt(retval, &ReaddbGetIsProt);
SetGetSequence(retval, &ReaddbGetSequence);
SetGetSeqIdStr(retval, &ReaddbGetSeqIdStr);
+ SetGetSeqId(retval, &ReaddbGetSeqId);
SetGetSeqLen(retval, &ReaddbGetSeqLen);
SetGetNextChunk(retval, &ReaddbGetNextChunk);
SetIterNext(retval, &ReaddbIteratorNext);
+ /* Set the range, if it is specified */
+ if (rargs->first_db_seq > 0)
+ rdfp->start = rargs->first_db_seq;
+ if (rargs->final_db_seq > 0)
+ rdfp->stop = rargs->final_db_seq;
+
return retval;
}
diff --git a/algo/blast/api/seqsrc_readdb.h b/algo/blast/api/seqsrc_readdb.h
index 6aa6abe7..cf0d5bf2 100644
--- a/algo/blast/api/seqsrc_readdb.h
+++ b/algo/blast/api/seqsrc_readdb.h
@@ -1,4 +1,4 @@
-/* $Id: seqsrc_readdb.h,v 1.7 2003/08/19 22:05:44 camacho Exp $
+/* $Id: seqsrc_readdb.h,v 1.8 2003/12/03 16:50:37 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -51,6 +51,8 @@ extern "C" {
typedef struct ReaddbNewArgs {
char* dbname; /**< Database name */
Boolean is_protein; /**< Is this database protein? */
+ Int4 first_db_seq; /**< Ordinal id of the first sequence to search */
+ Int4 final_db_seq; /**< Ordinal id of the last sequence to search */
} ReaddbNewArgs;
/** Readdb sequence source constructor
diff --git a/algo/blast/core/blast_def.h b/algo/blast/core/blast_def.h
index b605815b..c097ca8c 100644
--- a/algo/blast/core/blast_def.h
+++ b/algo/blast/core/blast_def.h
@@ -1,4 +1,4 @@
-/* $Id: blast_def.h,v 1.27 2003/10/15 16:59:43 coulouri Exp $
+/* $Id: blast_def.h,v 1.29 2003/12/03 16:31:45 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -34,7 +34,7 @@ Contents: Definitions of major structures used throughout BLAST
Detailed Contents:
******************************************************************************
- * $Revision: 1.27 $
+ * $Revision: 1.29 $
* */
#ifndef __BLAST_DEF__
#define __BLAST_DEF__
@@ -73,11 +73,11 @@ void __sfree(void** x); /* implemented in lib/util.c */
#endif
/** Structure for keeping the query masking information */
-typedef struct BlastMask {
+typedef struct BlastMaskLoc {
Int4 index; /**< Index of the query sequence this mask is applied to */
ListNode* loc_list; /**< List of mask locations */
- struct BlastMask* next; /**< Pointer to the next query mask */
-} BlastMask;
+ struct BlastMaskLoc* next; /**< Pointer to the next query mask */
+} BlastMaskLoc;
/** Structure to hold a sequence. */
typedef struct BLAST_SequenceBlk {
@@ -94,7 +94,7 @@ typedef struct BLAST_SequenceBlk {
for sequence_start */
Uint1* oof_sequence; /**< Mixed-frame protein representation of a
nucleotide sequence for out-of-frame alignment */
- BlastMask* lcase_mask; /**< Locations to be masked from operations on this
+ BlastMaskLoc* lcase_mask; /**< Locations to be masked from operations on this
sequence: lookup table for query; scanning for
subject. */
} BLAST_SequenceBlk;
@@ -105,7 +105,6 @@ typedef struct BlastQueryInfo {
Int2 first_context; /**< Index of the first element of the context array */
Int2 last_context; /**< Index of the last element of the context array */
int num_queries; /**< Number of query sequences */
- Int4 total_length; /**< Total length of all query sequences/strands/frames */
Int4* context_offsets; /**< Offsets of the individual queries in the
concatenated super-query */
Int4* length_adjustments; /**< Length adjustments for boundary conditions */
diff --git a/algo/blast/core/blast_dust.c b/algo/blast/core/blast_dust.c
index becb7636..48eec873 100644
--- a/algo/blast/core/blast_dust.c
+++ b/algo/blast/core/blast_dust.c
@@ -30,7 +30,7 @@ static char const rcsid[] = "$Id";
*
* Version Creation Date: 05/28/2003
*
-* $Revision: 1.16 $
+* $Revision: 1.17 $
*
* File Description: A utility to find low complexity NA regions.
* This parallels functionality of dust.c from the C toolkit,
@@ -206,7 +206,6 @@ dust_triplet_find (Uint1* seq_start, Int4 icur, Int4 max, Uint1* s1)
Int4 n;
Uint1* s2,* s3;
Int2 c;
- Boolean flagVD;
Uint1* seq = &seq_start[icur];
Uint1 end_byte = NCBI4NA_TO_BLASTNA[NULLB];
@@ -232,7 +231,6 @@ dust_triplet_find (Uint1* seq_start, Int4 icur, Int4 max, Uint1* s1)
*s2 |= c;
/* triplet fill loop */
- flagVD = TRUE;
while ((c = *seq++) != end_byte && n < max) {
c &= NCBI_2NA_MASK;
*s1 <<= 2;
diff --git a/algo/blast/core/blast_engine.c b/algo/blast/core/blast_engine.c
index c894e41f..864ca6e9 100644
--- a/algo/blast/core/blast_engine.c
+++ b/algo/blast/core/blast_engine.c
@@ -1,4 +1,4 @@
-/* $Id: blast_engine.c,v 1.86 2003/10/27 23:50:29 dondosha Exp $
+/* $Id: blast_engine.c,v 1.97 2003/12/10 21:31:26 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -33,7 +33,7 @@ Contents: High level BLAST functions
******************************************************************************/
-static char const rcsid[] = "$Id: blast_engine.c,v 1.86 2003/10/27 23:50:29 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_engine.c,v 1.97 2003/12/10 21:31:26 dondosha Exp $";
#include <algo/blast/core/blast_engine.h>
#include <algo/blast/core/lookup_wrap.h>
@@ -195,6 +195,11 @@ BLAST_SearchEngineCore(Uint1 program_number, BLAST_SequenceBlk* query,
combined_hsp_list = NULL;
for (chunk = 0; chunk < num_chunks; ++chunk) {
+ if (chunk > 0) {
+ offset += subject->length - DBSEQ_CHUNK_OVERLAP;
+ subject->sequence +=
+ (subject->length - DBSEQ_CHUNK_OVERLAP)/COMPRESSION_RATIO;
+ }
subject->length = MIN(total_subject_length - offset,
MAX_DBSEQ_LEN);
@@ -203,7 +208,7 @@ BLAST_SearchEngineCore(Uint1 program_number, BLAST_SequenceBlk* query,
return_stats->db_hits +=
aux_struct->WordFinder(subject, query, lookup,
gap_align->sbp->matrix, word_params, ewp, query_offsets,
- subject_offsets, OFFSET_ARRAY_SIZE, init_hitlist);
+ subject_offsets, GetOffsetArraySize(lookup), init_hitlist);
if (init_hitlist->total == 0)
continue;
@@ -249,7 +254,7 @@ BLAST_SearchEngineCore(Uint1 program_number, BLAST_SequenceBlk* query,
if (hit_options->do_sum_stats == TRUE) {
status = BLAST_LinkHsps(program_number, hsp_list, query_info,
subject, gap_align->sbp, hit_params,
- hit_options->gapped_calculation);
+ score_options->gapped_calculation);
} else if (hit_options->phi_align) {
/* These e-values will not be accurate yet, since we don't know
the number of pattern occurrencies in the database. That
@@ -259,7 +264,7 @@ BLAST_SearchEngineCore(Uint1 program_number, BLAST_SequenceBlk* query,
/* Calculate e-values for all HSPs */
status =
BLAST_GetNonSumStatsEvalue(program_number, query_info,
- hsp_list, hit_options, gap_align->sbp);
+ hsp_list, score_options, gap_align->sbp);
}
/* Discard HSPs that don't pass the e-value test */
@@ -269,13 +274,10 @@ BLAST_SearchEngineCore(Uint1 program_number, BLAST_SequenceBlk* query,
/* Allow merging of HSPs either if traceback is already
available, or if it is an ungapped search */
if (MergeHSPLists(hsp_list, &combined_hsp_list, offset,
- (Uint1) (hsp_list->traceback_done || !hit_options->gapped_calculation), FALSE)) {
+ (Uint1) (hsp_list->traceback_done || !score_options->gapped_calculation), FALSE)) {
/* HSPs from this list are moved elsewhere, reset count to 0 */
hsp_list->hspcnt = 0;
}
- offset += subject->length - DBSEQ_CHUNK_OVERLAP;
- subject->sequence +=
- (subject->length - DBSEQ_CHUNK_OVERLAP)/COMPRESSION_RATIO;
} /* End loop on chunks of subject sequence */
MergeHSPLists(combined_hsp_list, hsp_list_out, 0,
@@ -312,28 +314,80 @@ FillReturnXDropoffsInfo(BlastReturnStat* return_stats,
return 0;
}
+/* Computes the effective search space for the given parameters */
+static
+Int8 ComputeEffectiveSearchSpace(BLAST_KarlinBlk* kbp, /* [in] */
+ Uint1 program_number, /* [in] */
+ Int4 query_length, /* [in] */
+ const BlastScoringOptions*
+ scoring_options, /* [in] */
+ double alpha, /* [in] */
+ double beta, /* [in] */
+ Int8 db_length, /* [in] */
+ Int4 db_num_seqs, /* [in] */
+ Int4* length_adjustment_out /* [out] */
+ )
+{
+ Int4 length_adjustment = 0; /* length adjustment for current iteration. */
+ Int4 last_length_adjustment = 0;/* length adjustment in previous iteration.*/
+ Int4 min_query_length; /* lower bound on query length. */
+ Int2 i; /* Iteration index for calculating length adjustment */
+ Int8 effective_length, effective_db_length; /* effective lengths of
+ query and database */
+ Int8 retval = 0;
+
+ ASSERT(kbp);
+
+ min_query_length = (Int4) (1/(kbp->K));
+
+ for (i=0; i<5; i++) {
+
+ if (program_number != blast_type_blastn &&
+ scoring_options->gapped_calculation) {
+
+ length_adjustment = BLAST_Nint((((kbp->logK)+log((double)(query_length-last_length_adjustment)*(double)MAX(db_num_seqs, db_length-db_num_seqs*last_length_adjustment)))*alpha/kbp->Lambda) + beta);
+
+ } else {
+
+ length_adjustment = BLAST_Nint((kbp->logK+log((double)(query_length-last_length_adjustment)*(double)MAX(1, db_length-db_num_seqs*last_length_adjustment)))/(kbp->H));
+ }
+
+ if (length_adjustment >= query_length-min_query_length) {
+ length_adjustment = query_length-min_query_length;
+ break;
+ }
+
+ if (ABS(last_length_adjustment-length_adjustment) <= 1)
+ break;
+ last_length_adjustment = length_adjustment;
+ }
+ effective_length =
+ MAX(query_length - length_adjustment, min_query_length);
+ effective_db_length = MAX(1, db_length - db_num_seqs*length_adjustment);
+
+ retval = effective_length * effective_db_length;
+
+ if (length_adjustment_out) {
+ *length_adjustment_out = length_adjustment;
+ }
+
+ return retval;
+}
+
Int2 BLAST_CalcEffLengths (Uint1 program_number,
const BlastScoringOptions* scoring_options,
const BlastEffectiveLengthsOptions* eff_len_options,
const BlastScoreBlk* sbp, BlastQueryInfo* query_info)
{
- double alpha, beta; /*alpha and beta for new scoring system */
- Int4 min_query_length; /* lower bound on query length. */
+ double alpha=0, beta=0; /*alpha and beta for new scoring system */
Int4 length_adjustment = 0; /* length adjustment for current iteration. */
- Int4 last_length_adjustment;/* length adjustment in previous iteration.*/
Int4 index; /* loop index. */
Int4 db_num_seqs; /* number of sequences in database. */
Int8 db_length; /* total length of database. */
BLAST_KarlinBlk* *kbp_ptr; /* Array of Karlin block pointers */
- BLAST_KarlinBlk* kbp; /* Karlin-Blk pointer from ScoreBlk. */
Int4 query_length; /* length of an individual query sequence */
- Int8 effective_length, effective_db_length; /* effective lengths of
- query and database */
- Int8 effective_search_space; /* Effective search space for a given
+ Int8 effective_search_space = 0; /* Effective search space for a given
sequence/strand/frame */
- Int2 i; /* Iteration index for calculating length adjustment */
- Uint1 num_strands;
- Boolean skip = FALSE;
if (sbp == NULL || eff_len_options == NULL)
return 1;
@@ -359,67 +413,32 @@ Int2 BLAST_CalcEffLengths (Uint1 program_number,
else
kbp_ptr = sbp->kbp_std;
- if (program_number == blast_type_blastn)
- num_strands = 2;
- else
- num_strands = 1;
+ for (index = query_info->first_context;
+ index <= query_info->last_context;
+ index++) {
- for (index = query_info->first_context;
- index <= query_info->last_context; index++) {
- if ((index % num_strands) == 0)
- skip = FALSE;
if (eff_len_options->searchsp_eff) {
effective_search_space = eff_len_options->searchsp_eff;
} else {
- query_length = BLAST_GetQueryLength(query_info, index);
-
- if (query_length <= 0) {
- /* This strand of this query is not searched */
- query_info->eff_searchsp_array[index] = 0;
- query_info->length_adjustments[index] = 0;
- continue;
- }
-
- if (!skip) {
- /* Use the correct Karlin block. For blastn, two identical Karlin
- blocks are allocated for each sequence (one per strand), but we
- only need one of them.
- */
- kbp = kbp_ptr[index];
- length_adjustment = 0;
- last_length_adjustment = 0;
- min_query_length = (Int4) (1/(kbp->K));
-
- for (i=0; i<5; i++) {
- if (program_number != blast_type_blastn &&
- scoring_options->gapped_calculation) {
- length_adjustment = BLAST_Nint((((kbp->logK)+log((double)(query_length-last_length_adjustment)*(double)MAX(db_num_seqs, db_length-db_num_seqs*last_length_adjustment)))*alpha/kbp->Lambda) + beta);
- } else {
- length_adjustment = (Int4) ((kbp->logK+log((double)(query_length-last_length_adjustment)*(double)MAX(1, db_length-db_num_seqs*last_length_adjustment)))/(kbp->H));
- }
-
- if (length_adjustment >= query_length-min_query_length) {
- length_adjustment = query_length-min_query_length;
- break;
- }
-
- if (ABS(last_length_adjustment-length_adjustment) <= 1)
- break;
- last_length_adjustment = length_adjustment;
- }
- effective_length =
- MAX(query_length - length_adjustment, min_query_length);
- effective_db_length = MAX(1, db_length - db_num_seqs*length_adjustment);
-
- effective_search_space = effective_length * effective_db_length;
- skip = TRUE;
+ if ( (query_length = BLAST_GetQueryLength(query_info, index)) <= 0) {
+ continue;
}
+ /* Use the correct Karlin block. For blastn, two identical Karlin
+ blocks are allocated for each sequence (one per strand), but we
+ only need one of them.
+ */
+ effective_search_space = ComputeEffectiveSearchSpace(kbp_ptr[index],
+ program_number,
+ query_length,
+ scoring_options,
+ alpha, beta,
+ db_length,
+ db_num_seqs,
+ &length_adjustment);
}
-
query_info->eff_searchsp_array[index] = effective_search_space;
query_info->length_adjustments[index] = length_adjustment;
-
}
return 0;
@@ -504,7 +523,8 @@ BLAST_SetUpAuxStructures(Uint1 program_number,
query_info, hit_params);
BlastInitialWordParametersNew(program_number, word_options, *hit_params,
- *ext_params, sbp, query_info, eff_len_options, word_params);
+ *ext_params, sbp, query_info, eff_len_options,
+ scoring_options->gapped_calculation, word_params);
if ((status = BLAST_GapAlignStructNew(scoring_options, *ext_params,
max_subject_length, query->length, sbp, gap_align))) {
@@ -685,7 +705,7 @@ BLAST_DatabaseSearchEngine(Uint1 program_number,
const BlastEffectiveLengthsOptions* eff_len_options,
const PSIBlastOptions* psi_options,
const BlastDatabaseOptions* db_options,
- BlastResults* results, BlastReturnStat* return_stats)
+ BlastHSPResults* results, BlastReturnStat* return_stats)
{
BlastCoreAuxStruct* aux_struct = NULL;
BlastThrInfo* thr_info = NULL;
@@ -781,11 +801,11 @@ BLAST_DatabaseSearchEngine(Uint1 program_number,
/* Now sort the hit lists for all queries */
BLAST_SortResults(results);
- if (hit_options->gapped_calculation) {
+ if (!ext_options->skip_traceback && score_options->gapped_calculation) {
status =
BLAST_ComputeTraceback(program_number, results, query, query_info,
bssp, gap_align, score_options, ext_params, hit_params,
- db_options);
+ db_options, psi_options);
}
/* Do not destruct score block here */
@@ -812,7 +832,7 @@ BLAST_TwoSequencesEngine(Uint1 program_number,
const BlastEffectiveLengthsOptions* eff_len_options,
const PSIBlastOptions* psi_options,
const BlastDatabaseOptions* db_options,
- BlastResults* results, BlastReturnStat* return_stats)
+ BlastHSPResults* results, BlastReturnStat* return_stats)
{
BlastCoreAuxStruct* aux_struct = NULL;
BlastHSPList* hsp_list;
@@ -850,7 +870,7 @@ BLAST_TwoSequencesEngine(Uint1 program_number,
BlastCoreAuxStructFree(aux_struct);
sfree(word_params);
- if (hit_options->gapped_calculation) {
+ if (score_options->gapped_calculation) {
status =
BLAST_TwoSequencesTraceback(program_number, results, query,
query_info, subject, gap_align, score_options, ext_params,
diff --git a/algo/blast/core/blast_engine.h b/algo/blast/core/blast_engine.h
index bfb2c845..b072d537 100644
--- a/algo/blast/core/blast_engine.h
+++ b/algo/blast/core/blast_engine.h
@@ -1,4 +1,4 @@
-/* $Id: blast_engine.h,v 1.24 2003/09/10 19:41:02 dondosha Exp $
+/* $Id: blast_engine.h,v 1.25 2003/12/03 16:31:45 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,7 +32,7 @@ Author: Ilya Dondoshansky
Contents: High level BLAST functions
******************************************************************************
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
* */
#ifndef __BLAST_ENGINE__
#define __BLAST_ENGINE__
@@ -78,7 +78,7 @@ BLAST_DatabaseSearchEngine(Uint1 program_number,
const BlastEffectiveLengthsOptions* eff_len_options,
const PSIBlastOptions* psi_options,
const BlastDatabaseOptions* db_options,
- BlastResults* results, BlastReturnStat* return_stats);
+ BlastHSPResults* results, BlastReturnStat* return_stats);
/** The high level function performing BLAST comparison of two sequences,
* after all the setup has been done.
@@ -111,7 +111,7 @@ BLAST_TwoSequencesEngine(Uint1 program_number,
const BlastEffectiveLengthsOptions* eff_len_options,
const PSIBlastOptions* psi_options,
const BlastDatabaseOptions* db_options,
- BlastResults* results, BlastReturnStat* return_stats);
+ BlastHSPResults* results, BlastReturnStat* return_stats);
/** Function to calculate effective query length and db length as well as
* effective search space.
diff --git a/algo/blast/core/blast_extend.c b/algo/blast/core/blast_extend.c
index 16cc1d53..64f7871b 100644
--- a/algo/blast/core/blast_extend.c
+++ b/algo/blast/core/blast_extend.c
@@ -1,4 +1,4 @@
-/* $Id: blast_extend.c,v 1.42 2003/10/22 15:32:09 dondosha Exp $
+/* $Id: blast_extend.c,v 1.47 2004/01/13 16:20:04 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,10 +32,10 @@ Author: Ilya Dondoshansky
Contents: Functions to initialize structures used for BLAST extension
******************************************************************************
- * $Revision: 1.42 $
+ * $Revision: 1.47 $
* */
-static char const rcsid[] = "$Id: blast_extend.c,v 1.42 2003/10/22 15:32:09 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_extend.c,v 1.47 2004/01/13 16:20:04 dondosha Exp $";
#include <algo/blast/core/blast_extend.h>
#include <algo/blast/core/blast_options.h>
@@ -565,59 +565,61 @@ BlastnWordUngappedExtend(BLAST_SequenceBlk* query,
Int4 q_off, Int4 s_off, Int4 cutoff, Int4 X,
BlastUngappedData** ungapped_data)
{
- Uint1* q;
- Int4 sum, score;
- Uint1 ch;
- Uint1* subject0,* sf,* q_beg,* q_end,* s_end,* s,* start;
- Int2 remainder, base;
- Int4 q_avail, s_avail;
-
+ Uint1* q;
+ Int4 sum, score;
+ Uint1 ch;
+ Uint1* subject0,* sf,* q_beg,* q_end,* s_end,* s,* start;
+ Int2 remainder, base;
+ Int4 q_avail, s_avail;
+
base = 3 - (s_off % 4);
-
- subject0 = subject->sequence;
+
+ subject0 = subject->sequence;
q_avail = query->length - q_off;
s_avail = subject->length - s_off;
- q = q_beg = q_end = query->sequence + q_off;
- s = s_end = subject0 + s_off/COMPRESSION_RATIO;
- if (q_off < s_off) {
+ q = q_beg = q_end = query->sequence + q_off;
+ s = s_end = subject0 + s_off/COMPRESSION_RATIO;
+ if (q_off < s_off) {
start = subject0 + (s_off-q_off)/COMPRESSION_RATIO;
remainder = 3 - ((s_off-q_off)%COMPRESSION_RATIO);
- } else {
+ } else {
start = subject0;
remainder = 3;
- }
-
- /* Find where positive scoring starts & ends within the word hit */
- score = 0;
+ }
+
+ /* Find where positive scoring starts & ends within the word hit */
+ score = 0;
sum = 0;
- /* extend to the left */
- do {
+ /* extend to the left */
+ while ((s > start) || (s == start && base < remainder)) {
if (base == 3) {
s--;
base = 0;
- } else
- base++;
+ } else {
+ ++base;
+ }
ch = *s;
if ((sum += matrix[*--q][READDB_UNPACK_BASE_N(ch, base)]) > 0) {
q_beg = q;
score += sum;
sum = 0;
- } else if (sum < X)
+ } else if (sum < X) {
break;
- } while ((s > start) || (s == start && base < remainder));
+ }
+ }
if (score >= cutoff && !ungapped_data)
return FALSE;
- if (ungapped_data) {
+ if (ungapped_data) {
*ungapped_data = (BlastUngappedData*)
malloc(sizeof(BlastUngappedData));
- (*ungapped_data)->q_start = q_beg - query->sequence;
- (*ungapped_data)->s_start =
- s_off - (q_off - (*ungapped_data)->q_start);
- }
+ (*ungapped_data)->q_start = q_beg - query->sequence;
+ (*ungapped_data)->s_start =
+ s_off - (q_off - (*ungapped_data)->q_start);
+ }
if (q_avail < s_avail) {
sf = subject0 + (s_off + q_avail)/COMPRESSION_RATIO;
@@ -626,13 +628,14 @@ BlastnWordUngappedExtend(BLAST_SequenceBlk* query,
sf = subject0 + (subject->length)/COMPRESSION_RATIO;
remainder = 3 - ((subject->length)%COMPRESSION_RATIO);
}
- /* extend to the right */
- q = q_end;
- s = s_end;
- sum = 0;
+
+ /* extend to the right */
+ q = q_end;
+ s = s_end;
+ sum = 0;
base = 3 - (s_off % COMPRESSION_RATIO);
-
- while (s < sf || (s == sf && base > remainder)) {
+
+ while (s < sf || (s == sf && base > remainder)) {
ch = *s;
if ((sum += matrix[*q++][READDB_UNPACK_BASE_N(ch, base)]) > 0) {
q_end = q;
@@ -645,14 +648,14 @@ BlastnWordUngappedExtend(BLAST_SequenceBlk* query,
s++;
} else
base--;
- }
+ }
- if (ungapped_data) {
- (*ungapped_data)->length = q_end - q_beg;
- (*ungapped_data)->score = score;
+ if (ungapped_data) {
+ (*ungapped_data)->length = q_end - q_beg;
+ (*ungapped_data)->score = score;
(*ungapped_data)->frame = 0;
- }
-
+ }
+
return (score < cutoff);
}
@@ -781,7 +784,6 @@ Int4 BlastNaWordFinder(BLAST_SequenceBlk* subject,
Int4 i;
Uint1* s,* s_end;
Uint1* q_start = query->sequence;
- Uint1* q_end = query->sequence + query->length;
Int4 hitsfound, total_hits = 0;
Uint4 word_size, compressed_wordsize, reduced_word_length;
Uint4 extra_bytes_needed;
@@ -789,20 +791,17 @@ Int4 BlastNaWordFinder(BLAST_SequenceBlk* subject,
Uint1* q;
Int4 start_offset, last_start, next_start, last_end;
Uint1 max_bases;
- Int4 bases_in_last_byte, bases_in_extra_bytes;
word_size = COMPRESSION_RATIO*lookup->wordsize;
last_start = subject->length - word_size;
s_end = subject->sequence + subject->length/COMPRESSION_RATIO;
start_offset = 0;
- bases_in_last_byte = subject->length % COMPRESSION_RATIO;
compressed_wordsize = lookup->reduced_wordsize;
extra_bytes_needed = lookup->wordsize - compressed_wordsize;
- bases_in_extra_bytes = COMPRESSION_RATIO*extra_bytes_needed;
reduced_word_length = COMPRESSION_RATIO*compressed_wordsize;
extra_bases = lookup->word_length - word_size;
- last_end = subject->length - (word_size - reduced_word_length);
+ last_end = subject->length - word_size;
while (start_offset <= last_start) {
/* Pass the last word ending offset */
@@ -812,42 +811,41 @@ Int4 BlastNaWordFinder(BLAST_SequenceBlk* subject,
total_hits += hitsfound;
for (i = 0; i < hitsfound; ++i) {
+ /* Here it is guaranteed that subject offset is divisible by 4,
+ because we only extend to the right, so scanning stride must be
+ equal to 4. */
+ s = abs_start + (s_offsets[i])/COMPRESSION_RATIO;
q = q_start + q_offsets[i];
- s = abs_start + s_offsets[i]/COMPRESSION_RATIO;
- /* Check for extra bytes if required for longer words. */
- if (extra_bytes_needed &&
- !BlastNaCompareExtraBytes(q, s, extra_bytes_needed))
- continue;
- if (s_offsets[i] > reduced_word_length) {
- /* mini extension to the left */
- max_bases =
- MIN(4, q_offsets[i] - reduced_word_length);
- left = BlastNaMiniExtendLeft(q-reduced_word_length,
- s-compressed_wordsize-1, max_bases);
- } else {
- left = 0;
- }
- s += extra_bytes_needed;
- if (s <= s_end) {
- /* mini extension to the right */
- q += COMPRESSION_RATIO*extra_bytes_needed;
- max_bases = MIN(4, q_end - q);
- if (s == s_end)
- max_bases = MIN(max_bases, bases_in_last_byte);
+ /* Check for extra bytes if required for longer words. */
+ if (extra_bytes_needed &&
+ !BlastNaCompareExtraBytes(q+reduced_word_length,
+ s+compressed_wordsize, extra_bytes_needed))
+ continue;
+ /* mini extension to the left */
+ max_bases =
+ MIN(COMPRESSION_RATIO, MIN(q_offsets[i], s_offsets[i]));
+ left = BlastNaMiniExtendLeft(q, s-1, max_bases);
+
+ /* mini extension to the right */
+ max_bases =
+ MIN(COMPRESSION_RATIO,
+ MIN(subject->length - s_offsets[i] - lookup->wordsize,
+ query->length - q_offsets[i] - word_size));
+
+ if (max_bases > 0) {
+ s += lookup->wordsize;
+ q += word_size;
right = BlastNaMiniExtendRight(q, s, max_bases);
- } else {
- right = 0;
}
- if (left + right >= extra_bases) {
- /* Check if this diagonal has already been explored. */
- BlastnExtendInitialHit(query, subject, lookup_wrap,
+ if (left + right >= extra_bases) {
+ /* Check if this diagonal has already been explored. */
+ BlastnExtendInitialHit(query, subject, lookup_wrap,
word_params, matrix, ewp, q_offsets[i],
- s_offsets[i] + bases_in_extra_bytes + right,
+ s_offsets[i] + word_size + right,
s_offsets[i], init_hitlist);
}
-
}
start_offset = next_start;
}
@@ -872,34 +870,16 @@ BlastNaExactMatchExtend(Uint1* q_start, Uint1* s_start,
Uint4 max_bases_left, Uint4 max_bases_right, Uint4 max_length,
Boolean extend_partial_byte, Uint4* extended_right)
{
- Uint4 length = 0, extended_left = 0;
+ Uint4 length;
Uint1* q,* s;
*extended_right = 0;
- /* Extend to the left; start with previous byte */
- q = q_start - COMPRESSION_RATIO;
- s = s_start - 1;
- while (length < max_length && max_bases_left >= COMPRESSION_RATIO) {
- if (*s != PACK_WORD(q))
- break;
- length += COMPRESSION_RATIO;
- --s;
- q -= COMPRESSION_RATIO;
- max_bases_left -= COMPRESSION_RATIO;
- }
- extended_left = length;
- if (length >= max_length)
- return TRUE;
- if (extend_partial_byte && max_bases_left > 0) {
- length += BlastNaMiniExtendLeft(q+COMPRESSION_RATIO, s,
- (Uint1) MIN(max_bases_left, COMPRESSION_RATIO));
- }
- if (length >= max_length)
- return TRUE;
+ length = 0;
+
+ /* Extend to the right; start from the firstt byte (it must be the
+ first one that's guaranteed to match by the lookup table hit). */
- /* Extend to the right; start after the end of the word */
- max_bases_right = MIN(max_bases_right, max_length - length);
q = q_start;
s = s_start;
while (length < max_length && max_bases_right >= COMPRESSION_RATIO) {
@@ -911,14 +891,39 @@ BlastNaExactMatchExtend(Uint1* q_start, Uint1* s_start,
max_bases_right -= COMPRESSION_RATIO;
}
if (extend_partial_byte) {
- if (length >= max_length)
- return TRUE;
if (max_bases_right > 0) {
length += BlastNaMiniExtendRight(q, s,
(Uint1) MIN(max_bases_right, COMPRESSION_RATIO));
}
}
- *extended_right = length - extended_left;
+
+ *extended_right = length;
+
+ if (length >= max_length)
+ return TRUE;
+
+ if (max_bases_left < max_length - length)
+ return FALSE;
+ else
+ max_bases_left = max_length - length;
+
+ /* Extend to the left; start with the byte just before the first. */
+ q = q_start - COMPRESSION_RATIO;
+ s = s_start - 1;
+ while (length < max_length && max_bases_left >= COMPRESSION_RATIO) {
+ if (*s != PACK_WORD(q))
+ break;
+ length += COMPRESSION_RATIO;
+ --s;
+ q -= COMPRESSION_RATIO;
+ max_bases_left -= COMPRESSION_RATIO;
+ }
+ if (length >= max_length)
+ return TRUE;
+ if (extend_partial_byte && max_bases_left > 0) {
+ length += BlastNaMiniExtendLeft(q+COMPRESSION_RATIO, s,
+ (Uint1) MIN(max_bases_left, COMPRESSION_RATIO));
+ }
return (length >= max_length);
}
@@ -940,31 +945,35 @@ Int4 MB_WordFinder(BLAST_SequenceBlk* subject,
MBLookupTable* mb_lt = (MBLookupTable*) lookup->lut;
Uint1* s_start,* q_start,* q,* s;
Int4 hitsfound=0;
- Int4 hit_counter=0, i;
+ Int4 hit_counter=0, index;
Int4 start_offset, next_start, last_start, last_end;
- Uint4 word_length, reduced_word_length;
+ Uint4 word_length;
Uint4 max_bases_left, max_bases_right;
Int4 query_length = query->length;
+ Int4 subject_length = subject->length;
Boolean ag_blast, variable_wordsize;
Uint4 extended_right;
+ Uint4 q_off, s_off;
+ Uint1 remainder;
s_start = subject->sequence;
q_start = query->sequence;
word_length = mb_lt->word_length;
- reduced_word_length = COMPRESSION_RATIO*mb_lt->compressed_wordsize;
ag_blast = (Boolean) (word_options->extension_method == eRightAndLeft);
- variable_wordsize = word_options->variable_wordsize;
+ variable_wordsize = (Boolean) word_options->variable_wordsize;
start_offset = 0;
if (mb_lt->discontiguous) {
- last_start = subject->length - mb_lt->template_length;
+ last_start = subject_length - mb_lt->template_length;
last_end = last_start + mb_lt->word_length;
} else {
- last_end = subject->length;
- if (ag_blast)
- last_start = last_end - reduced_word_length;
- else
+ last_end = subject_length;
+ if (ag_blast) {
+ last_start =
+ last_end - COMPRESSION_RATIO*mb_lt->compressed_wordsize;
+ } else {
last_start = last_end - mb_lt->word_length;
+ }
}
/* start_offset points to the beginning of the word */
@@ -983,29 +992,36 @@ Int4 MB_WordFinder(BLAST_SequenceBlk* subject,
q_offsets, s_offsets, max_hits, &next_start);
}
if (ag_blast) {
- for (i = 0; i < hitsfound; ++i) {
- q = q_start + q_offsets[i] - s_offsets[i]%COMPRESSION_RATIO;
- s = s_start + s_offsets[i]/COMPRESSION_RATIO;
+ for (index = 0; index < hitsfound; ++index) {
+ /* Adjust offsets to the start of the next full byte in the
+ subject sequence */
+ remainder = (-s_offsets[index])%COMPRESSION_RATIO;
+ q_off = q_offsets[index] + remainder;
+ s_off = s_offsets[index] + remainder;
+ s = s_start + s_off/COMPRESSION_RATIO;
+ q = q_start + q_off;
- max_bases_left = MIN(word_length, MIN(q_offsets[i], s_offsets[i]));
-
+ max_bases_left =
+ MIN(word_length, MIN(q_off, s_off));
max_bases_right = MIN(word_length,
- MIN(query_length-q_offsets[i], last_end-s_offsets[i]));
+ MIN(query_length-q_off, subject_length-s_off));
- if (BlastNaExactMatchExtend(q, s, max_bases_left, max_bases_right,
- word_length, (Boolean) !variable_wordsize, &extended_right)) {
+ if (BlastNaExactMatchExtend(q, s, max_bases_left,
+ max_bases_right, word_length, !variable_wordsize,
+ &extended_right))
+ {
/* Check if this diagonal has already been explored and save
the hit if needed. */
BlastnExtendInitialHit(query, subject, lookup,
- word_params, matrix, ewp, q_offsets[i],
- s_offsets[i] + extended_right, s_offsets[i],
+ word_params, matrix, ewp, q_offsets[index],
+ s_off + extended_right, s_offsets[index],
init_hitlist);
}
}
} else {
- for (i = 0; i < hitsfound; ++i) {
+ for (index = 0; index < hitsfound; ++index) {
MB_ExtendInitialHit(query, subject, lookup, word_params,
- matrix, ewp, q_offsets[i], s_offsets[i], init_hitlist);
+ matrix, ewp, q_offsets[index], s_offsets[index], init_hitlist);
}
}
/* next_start returned from the ScanSubject points to the beginning
@@ -1014,7 +1030,7 @@ Int4 MB_WordFinder(BLAST_SequenceBlk* subject,
hit_counter += hitsfound;
}
- MB_ExtendWordExit(ewp, subject->length);
+ MB_ExtendWordExit(ewp, subject_length);
return hit_counter;
}
@@ -1034,30 +1050,24 @@ Int4 BlastNaWordFinder_AG(BLAST_SequenceBlk* subject,
BlastInitialWordOptions* word_options = word_params->options;
LookupTable* lookup = (LookupTable*) lookup_wrap->lut;
Uint1* s_start = subject->sequence;
- Int4 i;
- Uint1* s,* s_end;
Uint1* q_start = query->sequence;
+ Int4 index;
+ Uint1* q;
+ Uint1* s;
Int4 query_length = query->length;
Int4 subject_length = subject->length;
Int4 hitsfound, total_hits = 0;
- Uint4 extra_length, reduced_word_length, min_extra_length;
- Uint1* q;
+ Uint4 word_length;
Int4 start_offset, end_offset, next_start;
Uint1 max_bases_left, max_bases_right;
- Int4 bases_in_last_byte;
Boolean variable_wordsize = word_options->variable_wordsize;
- Int4 extended_right;
- Uint1* q_tmp,* s_tmp;
- Uint4 length;
-
- s_end = subject->sequence + subject_length/COMPRESSION_RATIO;
- bases_in_last_byte = subject_length % COMPRESSION_RATIO;
+ Uint4 extended_right;
+ Uint4 q_off, s_off; /* Adjusted offsets */
+ Uint1 remainder;
- reduced_word_length = COMPRESSION_RATIO*lookup->reduced_wordsize;
- min_extra_length = reduced_word_length - COMPRESSION_RATIO;
- extra_length = lookup->word_length - min_extra_length;
+ word_length = lookup->word_length;
start_offset = 0;
- end_offset = subject_length - reduced_word_length;
+ end_offset = subject_length - COMPRESSION_RATIO*lookup->reduced_wordsize;
/* start_offset points to the beginning of the word; end_offset is the
beginning of the last word */
@@ -1066,58 +1076,25 @@ Int4 BlastNaWordFinder_AG(BLAST_SequenceBlk* subject,
q_offsets, s_offsets, max_hits, &next_start);
total_hits += hitsfound;
- for (i = 0; i < hitsfound; ++i) {
- q = q_start + q_offsets[i] - s_offsets[i]%COMPRESSION_RATIO;
- s = s_start + s_offsets[i]/COMPRESSION_RATIO;
+ for (index = 0; index < hitsfound; ++index) {
+ remainder = (-s_offsets[index])%COMPRESSION_RATIO;
+ q_off = q_offsets[index] + remainder;
+ s_off = s_offsets[index] + remainder;
+ s = s_start + s_off/COMPRESSION_RATIO;
+ q = q_start + q_off;
max_bases_left =
- MIN(extra_length, MIN(q_offsets[i], s_offsets[i])
- - min_extra_length);
-
- max_bases_right = MIN(extra_length,
- MIN(query_length-q_offsets[i], subject_length-s_offsets[i]));
-
-
- q_tmp = q - reduced_word_length;
- s_tmp = s - lookup->reduced_wordsize;
- length = 0;
- while (max_bases_left >= COMPRESSION_RATIO) {
- if (*s_tmp != PACK_WORD(q_tmp))
- break;
- length += COMPRESSION_RATIO;
- --s_tmp;
- q_tmp -= COMPRESSION_RATIO;
- max_bases_left -= COMPRESSION_RATIO;
- }
- if (!variable_wordsize) {
- length += BlastNaMiniExtendLeft(q_tmp+COMPRESSION_RATIO, s_tmp,
- max_bases_left);
- }
- extended_right = 0;
- /* Extend to the right; start after the end of the word */
- max_bases_right = MIN(max_bases_right, extra_length - length);
- q_tmp = q;
- s_tmp = s;
- while (max_bases_right >= COMPRESSION_RATIO) {
- if (*s_tmp != PACK_WORD(q_tmp))
- break;
- extended_right += COMPRESSION_RATIO;
- ++s_tmp;
- q_tmp += COMPRESSION_RATIO;
- max_bases_right -= COMPRESSION_RATIO;
- }
- if (!variable_wordsize) {
- extended_right += BlastNaMiniExtendRight(q_tmp, s_tmp,
- max_bases_right);
- }
-
- length += extended_right;
-
- if (length >= extra_length) {
- /* Check if this diagonal has already been explored. */
- BlastnExtendInitialHit(query, subject, lookup_wrap,
- word_params, matrix, ewp, q_offsets[i],
- s_offsets[i] + extended_right, s_offsets[i], init_hitlist);
+ MIN(word_length, MIN(q_off, s_off));
+ max_bases_right = MIN(word_length,
+ MIN(query_length-q_off, subject_length-s_off));
+
+ if (BlastNaExactMatchExtend(q, s, max_bases_left, max_bases_right,
+ word_length, !variable_wordsize, &extended_right))
+ {
+ /* Check if this diagonal has already been explored. */
+ BlastnExtendInitialHit(query, subject, lookup_wrap,
+ word_params, matrix, ewp, q_offsets[index],
+ s_off + extended_right, s_offsets[index], init_hitlist);
}
}
start_offset = next_start;
diff --git a/algo/blast/core/blast_filter.c b/algo/blast/core/blast_filter.c
index 3431eca6..262683ea 100644
--- a/algo/blast/core/blast_filter.c
+++ b/algo/blast/core/blast_filter.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: blast_filter.c,v 1.34 2003/10/17 20:12:50 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_filter.c,v 1.38 2004/01/07 21:17:30 dondosha Exp $";
/*
* ===========================================================================
*
@@ -33,7 +33,7 @@ Author: Ilya Dondoshansky
Contents: All code related to query sequence masking/filtering for BLAST
******************************************************************************
- * $Revision: 1.34 $
+ * $Revision: 1.38 $
* */
#include <algo/blast/core/blast_def.h>
@@ -73,9 +73,9 @@ BlastSeqLoc* BlastSeqLocFree(BlastSeqLoc* loc)
return NULL;
}
-BlastMask* BlastMaskFree(BlastMask* mask_loc)
+BlastMaskLoc* BlastMaskLocFree(BlastMaskLoc* mask_loc)
{
- BlastMask* next_loc;
+ BlastMaskLoc* next_loc;
while (mask_loc) {
next_loc = mask_loc->next;
BlastSeqLocFree(mask_loc->loc_list);
@@ -103,7 +103,8 @@ static int DoubleIntSortByStartPosition(const void *vp1, const void *vp2)
/* This will go in place of CombineSeqLocs to combine filtered locations */
Int2
-CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out)
+CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out,
+ Int4 link_value)
{
Int2 status=0; /* return value. */
Int4 start, stop; /* USed to merge overlapping SeqLoc's. */
@@ -118,12 +119,12 @@ CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out)
/* Put all the SeqLoc's into one big linked list. */
loc_head = last_loc =
- (BlastSeqLoc*) MemDup(mask_loc, sizeof(BlastSeqLoc));
+ (BlastSeqLoc*) BlastMemDup(mask_loc, sizeof(BlastSeqLoc));
/* Copy all locations, so loc points at the end of the chain */
while (last_loc->next) {
last_loc->next =
- (BlastSeqLoc*)MemDup(last_loc->next, sizeof(BlastSeqLoc));
+ (BlastSeqLoc*) BlastMemDup(last_loc->next, sizeof(BlastSeqLoc));
last_loc = last_loc->next;
}
@@ -141,7 +142,7 @@ CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out)
di = loc_var->ptr;
if (loc_var->next)
di_next = loc_var->next->ptr;
- if (di_next && stop+1 >= di_next->i1) {
+ if (di_next && ((stop + link_value) > di_next->i1)) {
stop = MAX(stop, di_next->i2);
} else {
di_tmp = (DoubleInt*) malloc(sizeof(DoubleInt));
@@ -152,8 +153,8 @@ CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out)
else
new_loc_last = ListNodeAddPointer(&new_loc_last, 0, di_tmp);
if (loc_var->next) {
- start = di_next->i1;
- stop = di_next->i2;
+ start = di_next->i1;
+ stop = di_next->i2;
}
}
loc_var = loc_var->next;
@@ -174,7 +175,7 @@ CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out)
Int2
BLAST_ComplementMaskLocations(Uint1 program_number,
BlastQueryInfo* query_info,
- BlastMask* mask_loc, BlastSeqLoc* *complement_mask)
+ BlastMaskLoc* mask_loc, BlastSeqLoc* *complement_mask)
{
Int4 start_offset, end_offset, filter_start, filter_end;
Int4 context, index;
@@ -191,6 +192,9 @@ BLAST_ComplementMaskLocations(Uint1 program_number,
context <= query_info->last_context; ++context) {
start_offset = query_info->context_offsets[context];
end_offset = query_info->context_offsets[context+1] - 2;
+ /* For blastn: check if this strand is not searched at all */
+ if (end_offset < start_offset)
+ continue;
index = (is_na ? context / 2 : context);
reverse = (is_na && ((context & 1) != 0));
first = TRUE;
@@ -218,7 +222,7 @@ BLAST_ComplementMaskLocations(Uint1 program_number,
/* Reverse the order of the locations */
for (start_loc = mask_loc->loc_list; start_loc;
start_loc = start_loc->next) {
- loc = (BlastSeqLoc*) MemDup(start_loc, sizeof(BlastSeqLoc));
+ loc = (BlastSeqLoc*) BlastMemDup(start_loc, sizeof(BlastSeqLoc));
loc->next = prev_loc;
prev_loc = loc;
}
diff --git a/algo/blast/core/blast_filter.h b/algo/blast/core/blast_filter.h
index fcad4449..7f1e4dc7 100644
--- a/algo/blast/core/blast_filter.h
+++ b/algo/blast/core/blast_filter.h
@@ -1,4 +1,4 @@
-/* $Id: blast_filter.h,v 1.9 2003/08/11 14:57:16 dondosha Exp $
+/* $Id: blast_filter.h,v 1.11 2004/01/07 21:17:17 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -34,7 +34,7 @@ Contents: BLAST filtering functions.
Detailed Contents:
******************************************************************************
- * $Revision: 1.9 $
+ * $Revision: 1.11 $
* */
#ifndef __BLAST_FILTER__
#define __BLAST_FILTER__
@@ -55,17 +55,20 @@ BlastSeqLoc* BlastSeqLocNew(Int4 from, Int4 to);
/** Deallocate a BlastSeqLoc structure */
BlastSeqLoc* BlastSeqLocFree(BlastSeqLoc* loc);
-/** Deallocate memory for a list of BlastMask structures */
-BlastMask* BlastMaskFree(BlastMask* mask_loc);
+/** Deallocate memory for a list of BlastMaskLoc structures */
+BlastMaskLoc* BlastMaskLocFree(BlastMaskLoc* mask_loc);
/** Go through all mask locations in one sequence,
* combine any that overlap. Deallocate the memory for the locations that
* were on the list, produce a new (merged) list of locations.
* @param mask_loc The list of masks to be merged [in]
* @param mask_loc_out The new (merged) list of masks. [out]
+ * @param link_value Largest gap size between locations fow which they
+ * should be linked together [in]
*/
Int2
-CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out);
+CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out,
+ Int4 link_value);
/** This function takes the list of mask locations (i.e., regions that
* should not be searched or not added to lookup table) and makes up a set
@@ -82,7 +85,7 @@ CombineMaskLocations(BlastSeqLoc* mask_loc, BlastSeqLoc* *mask_loc_out);
*/
Int2
BLAST_ComplementMaskLocations(Uint1 program_number,
- BlastQueryInfo* query_info, BlastMask* mask_loc,
+ BlastQueryInfo* query_info, BlastMaskLoc* mask_loc,
BlastSeqLoc* *complement_mask);
/** Runs filtering functions, according to the string "instructions", on the
diff --git a/algo/blast/core/blast_gapalign.c b/algo/blast/core/blast_gapalign.c
index c4953b1a..0fe388ad 100644
--- a/algo/blast/core/blast_gapalign.c
+++ b/algo/blast/core/blast_gapalign.c
@@ -1,4 +1,4 @@
-/* $Id: blast_gapalign.c,v 1.52 2003/10/27 20:48:49 dondosha Exp $
+/* $Id: blast_gapalign.c,v 1.63 2004/01/22 15:30:30 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,10 +32,10 @@ Author: Ilya Dondoshansky
Contents: Functions to perform gapped alignment
******************************************************************************
- * $Revision: 1.52 $
+ * $Revision: 1.63 $
* */
-static char const rcsid[] = "$Id: blast_gapalign.c,v 1.52 2003/10/27 20:48:49 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_gapalign.c,v 1.63 2004/01/22 15:30:30 dondosha Exp $";
#include <algo/blast/core/blast_options.h>
#include <algo/blast/core/blast_def.h>
@@ -44,12 +44,6 @@ static char const rcsid[] = "$Id: blast_gapalign.c,v 1.52 2003/10/27 20:48:49 do
#include <algo/blast/core/blast_setup.h>
#include <algo/blast/core/greedy_align.h>
-static Int2 BLAST_GreedyNtGappedAlignment(Uint1* query, Uint1* subject,
- Int4 query_length, Int4 subject_length,
- BlastGapAlignStruct* gap_align,
- const BlastScoringOptions* score_options,
- const BlastExtensionOptions* ext_options,
- Int4 q_off, Int4 s_off, Boolean compressed_subject);
static Int2 BLAST_DynProgNtGappedAlignment(BLAST_SequenceBlk* query_blk,
BLAST_SequenceBlk* subject_blk, BlastGapAlignStruct* gap_align,
const BlastScoringOptions* score_options, BlastInitHSP* init_hsp);
@@ -832,7 +826,8 @@ static Int4 SEMI_G_ALIGN_EX(Uint1* A, Uint1* B, Int4 M, Int4 N,
BlastGapDP* dp;
Uint1* Bptr;
Int4 B_increment=1;
-
+ Int4 next_c, next_f;
+
if(!score_only) {
return ALIGN_EX(A, B, M, N, S, pei, pej, sapp, gap_align, score_options,
query_offset, reversed, reverse_sequence);
@@ -856,12 +851,12 @@ static Int4 SEMI_G_ALIGN_EX(Uint1* A, Uint1* B, Int4 M, Int4 N,
dyn_prog = (BlastGapDP*)malloc(j);
dyn_prog[0].CC = 0; c = dyn_prog[0].DD = -m;
- dyn_prog[0].FF = -m;
+ dyn_prog[0].FF = -m - decline_penalty;
for(i = 1; i <= N; i++) {
if(c < -X) break;
dyn_prog[i].CC = c;
dyn_prog[i].DD = c - m;
- dyn_prog[i].FF = c-m;
+ dyn_prog[i].FF = c - m - decline_penalty;
c -= h;
}
@@ -872,87 +867,68 @@ static Int4 SEMI_G_ALIGN_EX(Uint1* A, Uint1* B, Int4 M, Int4 N,
tt = 0; j = i;
for (j_r = 1; j_r <= M; j_r++) {
- if (!(gap_align->positionBased)){ /*AAS*/
+ if ((reverse_sequence && (A[M-j_r] == NULLB)) ||
+ (!reverse_sequence && (A[j_r] == NULLB)))
+ break;
+
+ if (!(gap_align->positionBased)){ /*AAS*/
if(reverse_sequence)
- wa = matrix[A[M-j_r]];
+ wa = matrix[A[M-j_r]];
else
- wa = matrix[A[j_r]];
- }
- else {
- if(reversed || reverse_sequence)
- {
- wa = gap_align->sbp->posMatrix[M - j_r];
- if (A[M-j_r] == NULLB) /* Prevents gapping through a NULL byte in rps-blast. */
- break;
- }
- else
- {
- wa = gap_align->sbp->posMatrix[j_r + query_offset];
- if (A[j_r] == NULLB)
- break;
- }
- }
+ wa = matrix[A[j_r]];
+ }
+ else {
+ if(reversed || reverse_sequence)
+ wa = gap_align->sbp->posMatrix[M - j_r];
+ else
+ wa = gap_align->sbp->posMatrix[j_r + query_offset];
+ }
e = c =f = MININT;
Bptr = &B[tt];
if(reverse_sequence)
- Bptr = &B[N-tt];
+ Bptr = &B[N-tt];
for (cb = i = tt, dp = &dyn_prog[i]; i < j; i++) {
- Bptr += B_increment;
- d = dp->DD;
- if (e < f) e = f;
- if (d < f) d = f;
- if (c < d || c < e) {
- if (d < e) {
- c = e;
- } else {
- c = d;
- }
- if (best_score - c > X) {
- c = dp->CC+wa[*Bptr]; f = dp->FF;
- if (tt == i) tt++;
- else { dp->CC =dp->FF= MININT;}
- } else {
- cb = i;
- if ((c-=m) > (d-=h)) {
- dp->DD = c;
- } else {
- dp->DD = d;
- }
- if (c > (e-=h)) {
- e = c;
- }
- c+=m;
- d = dp->CC+wa[*Bptr]; dp->CC = c; c=d;
- d = dp->FF; dp->FF = f-decline_penalty; f = d;
- }
- } else {
- if (best_score - c > X){
- c = dp->CC+wa[*Bptr]; f= dp->FF;
- if (tt == i) tt++;
- else { dp->CC =dp->FF= MININT;}
- } else {
- cb = i;
- if (c > best_score) {
- best_score = c;
- *pei = j_r; *pej = i;
- }
- if ((c-=m) > (d-=h)) {
- dp->DD = c;
- } else {
- dp->DD = d;
- }
- if (c > (e-=h)) {
- e = c;
- }
- c+=m;
- d = dp->FF;
- if (c-g>f) dp->FF = c-g-decline_penalty; else dp->FF = f-decline_penalty;
- f = d;
- d = dp->CC+wa[*Bptr]; dp->CC = c; c = d;
- }
- }
- dp++;
+ d = dp->DD;
+ Bptr += B_increment;
+ next_c = dp->CC+wa[*Bptr]; /* Bptr is & B[i+1]; */
+ next_f = dp->FF;
+ if (c < f) c = f;
+ if (f > d) d = f;
+ else if (c < d) c= d;
+
+ if (f > e) e = f;
+ else if (c < e) c=e;
+
+ if (best_score - c > X){
+ if (tt == i) tt++;
+ else { dp->CC = MININT; }
+ } else {
+ cb = i;
+ if (c > best_score) {
+ best_score = c;
+ *pei = j_r; *pej = i;
+ }
+ if ((c-=m) > (d-=h)) {
+ dp->DD = c;
+ } else {
+ dp->DD = d;
+ }
+ if (c > (e-=h)) {
+ e = c;
+ }
+ c+=m;
+ if (f < c-g) {
+ dp->FF = c-g-decline_penalty;
+ } else {
+ dp->FF = f-decline_penalty;
+ }
+ dp->CC = c;
+ }
+ c = next_c;
+ f = next_f;
+ dp++;
}
+
if (tt == j) break;
if (cb < j-1) { j = cb+1;}
else while (e >= best_score-X && j <= N) {
@@ -1280,6 +1256,7 @@ static Int4 OOF_SEMI_G_ALIGN(Uint1* A, Uint1* B, Int4 M, Int4 N,
Int4* wa;
BlastGapDP* dp;
Int4 factor = 1;
+ Int4 NN;
if(!score_only)
return OOF_ALIGN(A, B, M, N, S, pei, pej, sapp, gap_align, score_options,
@@ -1304,12 +1281,12 @@ static Int4 OOF_SEMI_G_ALIGN(Uint1* A, Uint1* B, Int4 M, Int4 N,
X = m;
if(N <= 0 || M <= 0) return 0;
- N+=2;
+ NN = N + 2;
j = (N + 5) * sizeof(BlastGapDP);
CD = (BlastGapDP*)calloc(1, j);
CD[0].CC = 0; c = CD[0].DD = -m;
- for(i = 3; i <= N; i+=3) {
+ for(i = 3; i <= NN; i+=3) {
CD[i].CC = c;
CD[i].DD = c - m;
CD[i-1].CC = CD[i-2].CC = CD[i-1].DD = CD[i-2].DD = MININT;
@@ -1331,9 +1308,9 @@ static Int4 OOF_SEMI_G_ALIGN(Uint1* A, Uint1* B, Int4 M, Int4 N,
}
s1 = s2 = s3 = f1= f2 = MININT; f1=f2=e1 = e2 = e3 = MININT; sc = MININT;
for(cb = i = tt, dp = &CD[i-1]; 1;) {
- if (i >= j) break;
- sc = MAX(MAX(f1, f2)-shift, s3)+wa[B[factor*i]];
- ++i;
+ if (i >= j || i > N) break;
+ sc = MAX(MAX(f1, f2)-shift, s3)+wa[B[factor*i]];
+ ++i;
f1 = s3;
s3 = (++dp)->CC; f1 = MAX(f1, s3);
@@ -1389,7 +1366,7 @@ static Int4 OOF_SEMI_G_ALIGN(Uint1* A, Uint1* B, Int4 M, Int4 N,
dp->DD = MAX(sc, d-h);
}
}
- if (i >= j) { c = e2; e2 = e1; e1 = e3; e3 = c; break; }
+ if (i >= j || i > N) { c = e2; e2 = e1; e1 = e3; e3 = c; break; }
sc = MAX(MAX(f1, f2)-shift, s1)+wa[B[factor*i]];
++i;
@@ -1426,7 +1403,7 @@ static Int4 OOF_SEMI_G_ALIGN(Uint1* A, Uint1* B, Int4 M, Int4 N,
if(cb < j) { j = cb;}
else {
c = (MAX(e1, MAX(e2, e3))+X-best_score)/h+j;
- if (c > N) c = N;
+ if (c > NN) c = NN;
if (c > j)
while (1) {
CD[j].CC = e1;
@@ -1441,7 +1418,7 @@ static Int4 OOF_SEMI_G_ALIGN(Uint1* A, Uint1* B, Int4 M, Int4 N,
}
}
c = j+4;
- if (c > N+1) c = N+1;
+ if (c > NN+1) c = NN+1;
while (j < c) {
CD[j].DD = CD[j].CC = MININT;
j++;
@@ -1525,10 +1502,11 @@ Int2 BLAST_MbGetGappedScore(Uint1 program_number,
if (!delete_hsp) {
Boolean good_hit = TRUE;
- BLAST_GreedyNtGappedAlignment(query->sequence, subject->sequence,
+ BLAST_GreedyGappedAlignment(query->sequence, subject->sequence,
query->length, subject->length, gap_align,
- score_options, ext_options, init_hsp->q_off, init_hsp->s_off,
- TRUE);
+ score_options, init_hsp->q_off, init_hsp->s_off,
+ TRUE, (ext_options->algorithm_type == EXTEND_GREEDY ?
+ TRUE : FALSE));
/* For neighboring we have a stricter criterion to keep an HSP */
if (hit_options->is_neighboring) {
Int4 hsp_length;
@@ -1589,28 +1567,11 @@ MBToGapEditScript (MBGapEditScript* ed_script)
}
-/** Greedy gapped alignment, with or without traceback.
- * Given two sequences, relevant options and an offset pair, fills the
- * gap_align structure with alignment endpoints and, if traceback is
- * performed, gap information.
- * @param query The query sequence [in]
- * @param subject The subject sequence [in]
- * @param query_length The query sequence length [in]
- * @param subject The subject sequence length [in]
- * @param gap_align The structure holding various information and memory
- * needed for gapped alignment [in] [out]
- * @param score_options Options related to scoring alignments [in]
- * @param ext_options Options related to alignment extension [in]
- * @param q_off Starting offset in query [in]
- * @param s_off Starting offset in subject [in]
- * @param compressed_subject Is subject sequence compressed? [in]
- */
-static Int2
-BLAST_GreedyNtGappedAlignment(Uint1* query, Uint1* subject,
+Int2
+BLAST_GreedyGappedAlignment(Uint1* query, Uint1* subject,
Int4 query_length, Int4 subject_length, BlastGapAlignStruct* gap_align,
const BlastScoringOptions* score_options,
- const BlastExtensionOptions* ext_options,
- Int4 q_off, Int4 s_off, Boolean compressed_subject)
+ Int4 q_off, Int4 s_off, Boolean compressed_subject, Boolean do_traceback)
{
Uint1* q;
Uint1* s;
@@ -1622,11 +1583,6 @@ BLAST_GreedyNtGappedAlignment(Uint1* query, Uint1* subject,
MBGapEditScript *ed_script_fwd=NULL, *ed_script_rev=NULL;
Uint1 rem;
GapEditScript* esp = NULL;
- /* Traceback is needed either when greedy extension does traceback
- immediately from the initial word hits, or if this is a
- final alignment. */
- Boolean do_traceback = (!compressed_subject ||
- (ext_options->algorithm_type == EXTEND_GREEDY) );
q_avail = query_length - q_off;
s_avail = subject_length - s_off;
@@ -1747,7 +1703,7 @@ static Int2 BLAST_DynProgNtGappedAlignment(BLAST_SequenceBlk* query_blk,
Boolean found_start, found_end;
Int4 q_length=0, s_length=0, score_right, score_left,
private_q_start, private_s_start;
- Int4 offset_adjustment;
+ Uint1 offset_adjustment;
Uint1* query,* subject;
found_start = FALSE;
@@ -1759,9 +1715,10 @@ static Int2 BLAST_DynProgNtGappedAlignment(BLAST_SequenceBlk* query_blk,
/* If subject offset is not at the start of a full byte,
BLAST_AlignPackedNucl won't work, so shift the alignment start
to the left */
- offset_adjustment = init_hsp->s_off % COMPRESSION_RATIO;
- q_length = init_hsp->q_off - offset_adjustment;
- s_length = init_hsp->s_off - offset_adjustment;
+ offset_adjustment =
+ COMPRESSION_RATIO - (init_hsp->s_off % COMPRESSION_RATIO);
+ q_length = init_hsp->q_off + offset_adjustment;
+ s_length = init_hsp->s_off + offset_adjustment;
if (q_length != 0 && s_length != 0) {
found_start = TRUE;
score_left = BLAST_AlignPackedNucl(query, subject, q_length, s_length,
@@ -1779,7 +1736,7 @@ static Int2 BLAST_DynProgNtGappedAlignment(BLAST_SequenceBlk* query_blk,
{
found_end = TRUE;
score_right = BLAST_AlignPackedNucl(query+q_length-1,
- subject+(s_length-1)/COMPRESSION_RATIO,
+ subject+(s_length+3)/COMPRESSION_RATIO - 1,
query_blk->length-q_length,
subject_blk->length-s_length, &(gap_align->query_stop),
&(gap_align->subject_stop), gap_align, score_options, FALSE);
@@ -2494,6 +2451,7 @@ static Int2 BLAST_ProtGappedAlignment(Uint1 program,
Int4 private_q_start, private_s_start;
Uint1* query=NULL,* subject=NULL;
Boolean switch_seq = FALSE;
+ Int4 query_length, subject_length;
if (gap_align == NULL)
return FALSE;
@@ -2504,16 +2462,22 @@ static Int2 BLAST_ProtGappedAlignment(Uint1 program,
if (program == blast_type_blastx) {
subject = subject_blk->sequence + s_length;
query = query_blk->oof_sequence + CODON_LENGTH + q_length;
+ query_length = query_blk->length - CODON_LENGTH + 1;
+ subject_length = subject_blk->length;
switch_seq = TRUE;
} else if (program == blast_type_tblastn) {
subject = subject_blk->oof_sequence + CODON_LENGTH + s_length;
query = query_blk->sequence + q_length;
+ query_length = query_blk->length;
+ subject_length = subject_blk->length - CODON_LENGTH + 1;
}
} else {
q_length = init_hsp->q_off + 1;
s_length = init_hsp->s_off + 1;
query = query_blk->sequence;
subject = subject_blk->sequence;
+ query_length = query_blk->length;
+ subject_length = subject_blk->length;
}
found_start = FALSE;
@@ -2542,12 +2506,11 @@ static Int2 BLAST_ProtGappedAlignment(Uint1 program,
}
score_right = 0;
- if (init_hsp->q_off < query_blk->length &&
- init_hsp->s_off < subject_blk->length) {
+ if (q_length < query_length && s_length < subject_length) {
found_end = TRUE;
if(score_options->is_ooframe) {
score_right = OOF_SEMI_G_ALIGN_EX(query-1, subject-1,
- query_blk->length-q_length, subject_blk->length-s_length,
+ query_length-q_length, subject_length-s_length,
NULL, &(gap_align->query_stop), &(gap_align->subject_stop),
TRUE, NULL, gap_align,
score_options, q_length, FALSE, switch_seq);
@@ -2555,12 +2518,14 @@ static Int2 BLAST_ProtGappedAlignment(Uint1 program,
gap_align->subject_stop += s_length;
} else {
score_right = SEMI_G_ALIGN_EX(query+init_hsp->q_off,
- subject+init_hsp->s_off, query_blk->length-q_length,
- subject_blk->length-s_length, NULL, &(gap_align->query_stop),
+ subject+init_hsp->s_off, query_length-q_length,
+ subject_length-s_length, NULL, &(gap_align->query_stop),
&(gap_align->subject_stop), TRUE, NULL, gap_align,
score_options, init_hsp->q_off, FALSE, FALSE);
- gap_align->query_stop += init_hsp->q_off;
- gap_align->subject_stop += init_hsp->s_off;
+ /* Make end offsets point to the byte after the end of the
+ alignment */
+ gap_align->query_stop += init_hsp->q_off + 1;
+ gap_align->subject_stop += init_hsp->s_off + 1;
}
}
@@ -2751,11 +2716,11 @@ BLAST_OOFTracebackToGapEditBlock(Int4* S, Int4 q_length,
Int2 BLAST_GappedAlignmentWithTraceback(Uint1 program, Uint1* query,
Uint1* subject, BlastGapAlignStruct* gap_align,
const BlastScoringOptions* score_options,
- const BlastExtensionOptions* ext_options,
Int4 q_start, Int4 s_start, Int4 query_length, Int4 subject_length)
{
Boolean found_start, found_end;
Int4 score_right, score_left, private_q_length, private_s_length, tmp;
+ Int4 q_length, s_length;
Int4 prev;
Int4* tback,* tback1,* p = NULL,* q;
Boolean is_ooframe = score_options->is_ooframe;
@@ -2765,25 +2730,30 @@ Int2 BLAST_GappedAlignmentWithTraceback(Uint1 program, Uint1* query,
if (gap_align == NULL)
return -1;
- /* If greedy extension was performed without traceback for preliminary
- gapped alignment, use greedy algorithm for final alignment as well. */
- if (ext_options->algorithm_type == EXTEND_GREEDY_NO_TRACEBACK) {
- return BLAST_GreedyNtGappedAlignment(query, subject,
- query_length, subject_length, gap_align,
- score_options, ext_options, q_start, s_start, FALSE);
- }
-
found_start = FALSE;
found_end = FALSE;
+ q_length = query_length;
+ s_length = subject_length;
+ if (is_ooframe) {
+ /* The mixed frame sequence is shifted to the 3rd position, so its
+ maximal available length for extension is less by 2 than its
+ total length. */
+ switch_seq = (program == blast_type_blastx);
+ if (switch_seq) {
+ q_length -= CODON_LENGTH - 1;
+ } else {
+ s_length -= CODON_LENGTH - 1;
+ }
+ }
+
tback = tback1 = (Int4*)
- malloc((subject_length + query_length)*sizeof(Int4));
+ malloc((s_length + q_length)*sizeof(Int4));
score_left = 0; prev = 3;
found_start = TRUE;
if(is_ooframe) {
- switch_seq = (program == blast_type_blastx);
/* NB: Left extension does not include starting point corresponding
to the offset pair; the right extension does. */
score_left =
@@ -2818,12 +2788,12 @@ Int2 BLAST_GappedAlignmentWithTraceback(Uint1 program, Uint1* query,
score_right = 0;
- if ((q_start < query_length) && (s_start < subject_length)) {
+ if ((q_start < q_length) && (s_start < s_length)) {
found_end = TRUE;
if(is_ooframe) {
score_right =
OOF_SEMI_G_ALIGN_EX(query+q_start-1, subject+s_start-1,
- query_length-q_start, subject_length-s_start,
+ q_length-q_start, s_length-s_start,
tback1, &private_q_length, &private_s_length, FALSE,
&tback1, gap_align, score_options, q_start, FALSE, switch_seq);
if (prev != 3 && p) {
@@ -2833,7 +2803,7 @@ Int2 BLAST_GappedAlignmentWithTraceback(Uint1 program, Uint1* query,
} else {
score_right =
SEMI_G_ALIGN_EX(query+q_start, subject+s_start,
- query_length-q_start-1, subject_length-s_start-1,
+ q_length-q_start-1, s_length-s_start-1,
tback1, &private_q_length, &private_s_length, FALSE,
&tback1, gap_align, score_options, q_start, FALSE, FALSE);
}
@@ -2897,11 +2867,8 @@ Int2 PHIGappedAlignmentWithTraceback(Uint1 program,
{
Boolean found_end;
Int4 score_right, score_left, private_q_length, private_s_length, tmp;
- Int4 prev;
Int4* tback,* tback1,* p = NULL,* q;
- Boolean is_ooframe = score_options->is_ooframe;
Int2 status = 0;
- Boolean switch_seq = FALSE;
Int4 pat_length;
if (gap_align == NULL)
@@ -2912,7 +2879,7 @@ Int2 PHIGappedAlignmentWithTraceback(Uint1 program,
tback = tback1 = (Int4*)
malloc((subject_length + query_length)*sizeof(Int4));
- score_left = 0; prev = 3;
+ score_left = 0;
score_left =
SEMI_G_ALIGN_EX(query, subject, q_start, s_start, tback,
@@ -3016,7 +2983,6 @@ static Int2 PHIGappedAlignment(Uint1 program,
Int4 q_length=0, s_length=0, score_right, score_left;
Int4 private_q_start, private_s_start;
Uint1* query,* subject;
- Boolean switch_seq = FALSE;
if (gap_align == NULL)
return FALSE;
@@ -3089,12 +3055,11 @@ Int2 PHIGetGappedScore (Uint1 program_number,
BlastHSPList** hsp_list_ptr)
{
- Boolean is_prot;
BlastHSPList* hsp_list;
BlastInitHSP** init_hsp_array;
BlastInitHSP* init_hsp;
Int4 index;
- Int4 q_start, s_start, q_end, s_end;
+ Int4 q_start, s_start;
Int2 status = 0;
BlastHitSavingOptions* hit_options = hit_params->options;
@@ -3105,7 +3070,6 @@ Int2 PHIGetGappedScore (Uint1 program_number,
if (init_hitlist->total == 0)
return 0;
- is_prot = (program_number != blast_type_blastn);
if (*hsp_list_ptr == NULL)
*hsp_list_ptr = hsp_list = BlastHSPListNew();
@@ -3123,13 +3087,11 @@ Int2 PHIGetGappedScore (Uint1 program_number,
init_hsp = init_hsp_array[index];
if (!init_hsp->ungapped_data) {
- q_start = q_end = init_hsp->q_off;
- s_start = s_end = init_hsp->s_off;
+ q_start = init_hsp->q_off;
+ s_start = init_hsp->s_off;
} else {
q_start = init_hsp->ungapped_data->q_start;
- q_end = q_start + init_hsp->ungapped_data->length - 1;
s_start = init_hsp->ungapped_data->s_start;
- s_end = s_start + init_hsp->ungapped_data->length - 1;
}
status = PHIGappedAlignment(program_number, query,
diff --git a/algo/blast/core/blast_gapalign.h b/algo/blast/core/blast_gapalign.h
index 2a8fa913..39362ae9 100644
--- a/algo/blast/core/blast_gapalign.h
+++ b/algo/blast/core/blast_gapalign.h
@@ -1,4 +1,4 @@
-/* $Id: blast_gapalign.h,v 1.27 2003/10/27 20:50:20 dondosha Exp $
+/* $Id: blast_gapalign.h,v 1.28 2003/12/10 23:14:34 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,7 +32,7 @@ Author: Ilya Dondoshansky
Contents: Structures and functions prototypes used for BLAST gapped extension
******************************************************************************
- * $Revision: 1.27 $
+ * $Revision: 1.28 $
* */
#ifndef __BLAST_GAPALIGN__
@@ -246,8 +246,6 @@ Int2 BLAST_GetGappedScore (Uint1 program_number, BLAST_SequenceBlk* query,
* @param subject The subject sequence [in]
* @param gap_align The gapped alignment structure [in] [out]
* @param score_options Scoring parameters [in]
- * @param ext_options Extension options, specifying which algorithm to use
- * for gapped extension [in]
* @param q_start Offset in query where to start alignment [in]
* @param s_start Offset in subject where to start alignment [in]
* @param subject_length Maximal allowed extension in subject [in]
@@ -256,9 +254,30 @@ Int2 BLAST_GappedAlignmentWithTraceback(Uint1 program,
Uint1* query, Uint1* subject,
BlastGapAlignStruct* gap_align,
const BlastScoringOptions* score_options,
- const BlastExtensionOptions* ext_options,
Int4 q_start, Int4 s_start, Int4 query_length, Int4 subject_length);
+/** Greedy gapped alignment, with or without traceback.
+ * Given two sequences, relevant options and an offset pair, fills the
+ * gap_align structure with alignment endpoints and, if traceback is
+ * performed, gap information.
+ * @param query The query sequence [in]
+ * @param subject The subject sequence [in]
+ * @param query_length The query sequence length [in]
+ * @param subject The subject sequence length [in]
+ * @param gap_align The structure holding various information and memory
+ * needed for gapped alignment [in] [out]
+ * @param score_options Options related to scoring alignments [in]
+ * @param q_off Starting offset in query [in]
+ * @param s_off Starting offset in subject [in]
+ * @param compressed_subject Is subject sequence compressed? [in]
+ * @param do_traceback Should traceback be saved? [in]
+ */
+Int2
+BLAST_GreedyGappedAlignment(Uint1* query, Uint1* subject,
+ Int4 query_length, Int4 subject_length, BlastGapAlignStruct* gap_align,
+ const BlastScoringOptions* score_options,
+ Int4 q_off, Int4 s_off, Boolean compressed_subject, Boolean do_traceback);
+
/** Perform a gapped alignment with traceback for PHI BLAST
* @param program Type of BLAST program [in]
* @param query The query sequence [in]
diff --git a/algo/blast/core/blast_hits.c b/algo/blast/core/blast_hits.c
index 63d18c0e..81a93ce0 100644
--- a/algo/blast/core/blast_hits.c
+++ b/algo/blast/core/blast_hits.c
@@ -1,4 +1,4 @@
-/* $Id: blast_hits.c,v 1.46 2003/10/21 22:15:34 camacho Exp $
+/* $Id: blast_hits.c,v 1.64 2004/01/21 16:11:27 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -37,10 +37,10 @@ Detailed Contents:
alignment
******************************************************************************
- * $Revision: 1.46 $
+ * $Revision: 1.64 $
* */
-static char const rcsid[] = "$Id: blast_hits.c,v 1.46 2003/10/21 22:15:34 camacho Exp $";
+static char const rcsid[] = "$Id: blast_hits.c,v 1.64 2004/01/21 16:11:27 dondosha Exp $";
#include <algo/blast/core/blast_options.h>
#include <algo/blast/core/blast_extend.h>
@@ -116,7 +116,7 @@ BlastHSP* BlastHSPFree(BlastHSP* hsp)
}
Int2 BLAST_GetNonSumStatsEvalue(Uint1 program, BlastQueryInfo* query_info,
- BlastHSPList* hsp_list, BlastHitSavingOptions* hit_options,
+ BlastHSPList* hsp_list, const BlastScoringOptions* score_options,
BlastScoreBlk* sbp)
{
BlastHSP* hsp;
@@ -124,18 +124,15 @@ Int2 BLAST_GetNonSumStatsEvalue(Uint1 program, BlastQueryInfo* query_info,
BLAST_KarlinBlk** kbp;
Int4 hsp_cnt;
Int4 index;
- Uint1 factor;
if (hsp_list == NULL)
return 1;
- if (hit_options->gapped_calculation && program != blast_type_blastn)
+ if (score_options->gapped_calculation && program != blast_type_blastn)
kbp = sbp->kbp_gap_std;
else
kbp = sbp->kbp_std;
- factor = ((program == blast_type_blastn) ? 2 : 1);
-
hsp_cnt = hsp_list->hspcnt;
hsp_array = hsp_list->hsp_array;
for (index=0; index<hsp_cnt; index++) {
@@ -151,7 +148,7 @@ Int2 BLAST_GetNonSumStatsEvalue(Uint1 program, BlastQueryInfo* query_info,
} else {
hsp->evalue =
BLAST_KarlinStoE_simple(hsp->score, kbp[hsp->context],
- (double)query_info->eff_searchsp_array[hsp->context/factor]);
+ (double)query_info->eff_searchsp_array[hsp->context]);
}
}
@@ -260,7 +257,6 @@ BlastHSPGetNumIdentical(Uint1* query, Uint1* subject,
Int4* align_length_ptr)
{
Int4 i, num_ident, align_length, q_off, s_off;
- Int2 context;
Uint1* q,* s;
GapEditBlock* gap_info;
GapEditScript* esp;
@@ -270,7 +266,6 @@ BlastHSPGetNumIdentical(Uint1* query, Uint1* subject,
if (!gap_info && is_gapped)
return -1;
- context = hsp->context;
q_off = hsp->query.offset;
s_off = hsp->subject.offset;
@@ -322,26 +317,45 @@ BlastHSPGetNumIdentical(Uint1* query, Uint1* subject,
/** Comparison callback function for sorting HSPs by e-value */
static int
-evalue_compare_hsps(const void* v1, const void* v2)
+score_compare_hsps(const void* v1, const void* v2)
{
BlastHSP* h1,* h2;
h1 = *((BlastHSP**) v1);
h2 = *((BlastHSP**) v2);
- if (h1->evalue < h2->evalue)
- return -1;
- else if (h1->evalue > h2->evalue)
- return 1;
+ /* No need to check e-values, because for the same subject sequence e-value
+ is always inverse proportional to score. However e-values are less
+ sensitive, since they both can be 0, when scores are large but
+ different. */
if (h1->score > h2->score)
return -1;
else if (h1->score < h2->score)
return 1;
+ /* Tie-breakers: decreasing subject offsets; decreasing subject ends,
+ decreasing query offsets, decreasing query ends */
+ else if (h1->subject.offset > h2->subject.offset)
+ return -1;
+ else if (h1->subject.offset < h2->subject.offset)
+ return 1;
+ else if (h1->subject.end > h2->subject.end)
+ return -1;
+ else if (h1->subject.end < h2->subject.end)
+ return 1;
+ else if (h1->query.offset > h2->query.offset)
+ return -1;
+ else if (h1->query.offset < h2->query.offset)
+ return 1;
+ else if (h1->query.end > h2->query.end)
+ return -1;
+ else if (h1->query.end < h2->query.end)
+ return 1;
+
return 0;
}
-/** Comparison callback function for sorting HSPs by diagonal and removing
- * the HSPs contained in or identical to other HSPs.
+/** Comparison callback function for sorting HSPs by diagonal and flagging
+ * the HSPs contained in or identical to other HSPs for future deletion.
*/
static int
diag_uniq_compare_hsps(const void* v1, const void* v2)
@@ -364,13 +378,6 @@ diag_uniq_compare_hsps(const void* v1, const void* v2)
else if (h1->context > h2->context)
return 1;
- /* If the two HSP's have same coordinates, they are equal */
- if (h1->query.offset == h2->query.offset &&
- h1->query.end == h2->query.end &&
- h1->subject.offset == h2->subject.offset &&
- h1->subject.end == h2->subject.end)
- return 0;
-
/* Check if one HSP is contained in the other, if so,
leave only the longer one, given it has lower evalue */
if (h1->query.offset >= h2->query.offset &&
@@ -378,21 +385,33 @@ diag_uniq_compare_hsps(const void* v1, const void* v2)
h1->subject.offset >= h2->subject.offset &&
h1->subject.end <= h2->subject.end &&
h1->evalue >= h2->evalue) {
- *hp1 = BlastHSPFree(*hp1);
- return 1;
+ (*hp1)->score = 0;
} else if (h1->query.offset <= h2->query.offset &&
h1->query.end >= h2->query.end &&
h1->subject.offset <= h2->subject.offset &&
h1->subject.end >= h2->subject.end &&
h1->evalue <= h2->evalue) {
- *hp2 = BlastHSPFree(*hp2);
- return -1;
+ (*hp2)->score = 0;
}
return (h1->query.offset - h1->subject.offset) -
(h2->query.offset - h2->subject.offset);
}
+static int
+null_compare_hsps(const void* v1, const void* v2)
+{
+ BlastHSP* h1,* h2;
+
+ h1 = *((BlastHSP**) v1);
+ h2 = *((BlastHSP**) v2);
+
+ if ((h1 && h2) || (!h1 && !h2))
+ return 0;
+ else if (!h1) return 1;
+ else return -1;
+}
+
/** Are the two HSPs within a given diagonal distance of each other? */
#define MB_HSP_CLOSE(q1, q2, s1, s2, c) (ABS(((q1)-(s1)) - ((q2)-(s2))) < (c))
@@ -406,11 +425,22 @@ BlastSortUniqHspArray(BlastHSPList* hsp_list)
Int2 context;
double evalue;
- qsort(hsp_list->hsp_array, hsp_list->hspcnt, sizeof(BlastHSP*),
- diag_uniq_compare_hsps);
+ qsort(hsp_array, hsp_list->hspcnt, sizeof(BlastHSP*),
+ diag_uniq_compare_hsps);
+ /* Delete all HSPs that were flagged in qsort */
+ for (index = 0, new_hspcnt = 0; index < hsp_list->hspcnt; ++index) {
+ if (hsp_array[index]->score == 0) {
+ hsp_array[index] = BlastHSPFree(hsp_array[index]);
+ }
+ }
+ /* Move all nulled out HSPs to the end */
+ qsort(hsp_array, hsp_list->hspcnt, sizeof(BlastHSP*),
+ null_compare_hsps);
+
for (index=1, new_hspcnt=0; index<hsp_list->hspcnt; index++) {
- if (hsp_array[index]==NULL)
- continue;
+ if (!hsp_array[index])
+ break;
+
q_off = hsp_array[index]->query.offset;
s_off = hsp_array[index]->subject.offset;
q_end = hsp_array[index]->query.end;
@@ -461,64 +491,31 @@ BlastSortUniqHspArray(BlastHSPList* hsp_list)
return 0;
}
-/** Reevaluate the HSPs in an HSP list, using ambiguity information.
- * This is/can only done either for an ungapped search, or if traceback is
- * already available.
- * Subject sequence is uncompressed and saved here. Number of identities is
- * calculated for each HSP along the way.
- * @param hsp_list The list of HSPs for one subject sequence [in] [out]
- * @param query_blk The query sequence [in]
- * @param subject_blk The subject sequence [in] [out]
- * @param hit_options The options related to saving hits [in]
- * @param query_info Auxiliary query information [in]
- * @param sbp The statistical information [in]
- * @param score_options The scoring options [in]
- * @param rdfp The BLAST database structure (for retrieving uncompressed
- * sequence) [in]
- */
-static Int2
-BLAST_ReevaluateWithAmbiguities(BlastHSPList* hsp_list,
- BLAST_SequenceBlk* query_blk, BLAST_SequenceBlk* subject_blk,
- const BlastHitSavingOptions* hit_options, BlastQueryInfo* query_info,
- BlastScoreBlk* sbp, const BlastScoringOptions* score_options,
- const BlastSeqSrc* bssp)
+Boolean ReevaluateHSPWithAmbiguities(BlastHSP* hsp,
+ Uint1* query_start, Uint1* subject_start,
+ const BlastHitSavingOptions* hit_options,
+ const BlastScoringOptions* score_options,
+ BlastQueryInfo* query_info, BlastScoreBlk* sbp)
{
Int4 sum, score, gap_open, gap_extend;
Int4** matrix;
- BlastHSP** hsp_array,* hsp;
- Uint1* query,* subject,* query_start,* subject_start = NULL;
+ Uint1* query,* subject;
Uint1* new_q_start,* new_s_start,* new_q_end,* new_s_end;
- Int4 index, context, hspcnt, i;
+ Int4 index;
Int2 factor = 1;
Uint1 mask = 0x0f;
- GapEditScript* esp,* last_esp,* prev_esp,* first_esp;
- Boolean purge, delete_hsp;
+ GapEditScript* esp,* last_esp = NULL,* prev_esp,* first_esp = NULL;
+ Boolean delete_hsp;
double searchsp_eff;
- Int4 last_esp_num;
- Int2 status = 0;
+ Int4 last_esp_num = 0;
Int4 align_length;
- BLAST_KarlinBlk** kbp;
- GetSeqArg seq_arg;
-
- if (!hsp_list)
- return status;
-
- hspcnt = hsp_list->hspcnt;
- hsp_array = hsp_list->hsp_array;
- memset((void*) &seq_arg, 0, sizeof(seq_arg));
-
- /* In case of no traceback, return without doing anything */
- if (!hsp_list->traceback_done && hit_options->gapped_calculation) {
- return status;
- }
-
- if (hsp_list->hspcnt == 0)
- /* All HSPs have been deleted */
- return status;
+ BLAST_KarlinBlk* kbp;
+ Boolean gapped_calculation = score_options->gapped_calculation;
/* NB: this function is called only for BLASTn, so we know where the
Karlin block is */
- kbp = sbp->kbp_std;
+ kbp = sbp->kbp_std[hsp->context];
+ searchsp_eff = (double)query_info->eff_searchsp_array[hsp->context];
if (score_options->gap_open == 0 && score_options->gap_extend == 0) {
if (score_options->reward % 2 == 1)
@@ -533,79 +530,70 @@ BLAST_ReevaluateWithAmbiguities(BlastHSPList* hsp_list,
matrix = sbp->matrix;
- /* Retrieve the unpacked subject sequence and save it in the
- sequence_start element of the subject structure.
- NB: for the BLAST 2 Sequences case, the uncompressed sequence must
- already be there */
- if (bssp) {
- seq_arg.oid = subject_blk->oid;
- seq_arg.encoding = BLASTNA_ENCODING;
- BLASTSeqSrcGetSequence(bssp, (void*) &seq_arg);
-
-#if 0
- readdb_get_sequence_ex(rdfp, subject_blk->oid,
- &subject_blk->sequence_start, &buf_len, TRUE);
- subject_blk->sequence = subject_blk->sequence_start + 1;
- subject_blk->sequence_start_allocated = TRUE;
-#endif
- subject_blk->sequence_start = seq_arg.seq->sequence_start;
- subject_blk->sequence = seq_arg.seq->sequence_start + 1;
- }
- /* The sequence in blastna encoding is now stored in sequence_start */
- subject_start = subject_blk->sequence_start + 1;
-
- purge = FALSE;
- for (index=0; index<hspcnt; index++) {
- if (hsp_array[index] == NULL)
- continue;
- else
- hsp = hsp_array[index];
-
- context = hsp->context;
-
- query_start = query_blk->sequence + query_info->context_offsets[context];
- searchsp_eff = (double)query_info->eff_searchsp_array[context/2];
-
- query = query_start + hsp->query.offset;
- subject = subject_start + hsp->subject.offset;
- score = 0;
- sum = 0;
- new_q_start = new_q_end = query;
- new_s_start = new_s_end = subject;
- i = 0;
-
+ query = query_start + hsp->query.offset;
+ subject = subject_start + hsp->subject.offset;
+ score = 0;
+ sum = 0;
+ new_q_start = new_q_end = query;
+ new_s_start = new_s_end = subject;
+ index = 0;
+
+ if (!gapped_calculation) {
+ for (index = 0; index < hsp->subject.length; ++index) {
+ sum += factor*matrix[*query & mask][*subject];
+ query++;
+ subject++;
+ if (sum < 0) {
+ if (BLAST_KarlinStoE_simple(score, kbp, searchsp_eff)
+ > hit_options->expect_value) {
+ /* Start from new offset */
+ new_q_start = query;
+ new_s_start = subject;
+ score = sum = 0;
+ } else {
+ /* Stop here */
+ break;
+ }
+ } else if (sum > score) {
+ /* Remember this point as the best scoring end point */
+ score = sum;
+ new_q_end = query;
+ new_s_end = subject;
+ }
+ }
+ } else {
esp = hsp->gap_info->esp;
prev_esp = NULL;
last_esp = first_esp = esp;
last_esp_num = 0;
-
+
while (esp) {
if (esp->op_type == GAPALIGN_SUB) {
sum += factor*matrix[*query & mask][*subject];
query++;
subject++;
- i++;
+ index++;
} else if (esp->op_type == GAPALIGN_DEL) {
sum -= gap_open + gap_extend * esp->num;
subject += esp->num;
- i += esp->num;
+ index += esp->num;
} else if (esp->op_type == GAPALIGN_INS) {
sum -= gap_open + gap_extend * esp->num;
query += esp->num;
- i += esp->num;
+ index += esp->num;
}
if (sum < 0) {
- if (BLAST_KarlinStoE_simple(score, kbp[context],
- searchsp_eff) > hit_options->expect_value) {
+ if (BLAST_KarlinStoE_simple(score, kbp, searchsp_eff)
+ > hit_options->expect_value) {
/* Start from new offset */
new_q_start = query;
new_s_start = subject;
score = sum = 0;
- if (i < esp->num) {
- esp->num -= i;
+ if (index < esp->num) {
+ esp->num -= index;
first_esp = esp;
- i = 0;
+ index = 0;
} else {
first_esp = esp->next;
}
@@ -622,32 +610,34 @@ BLAST_ReevaluateWithAmbiguities(BlastHSPList* hsp_list,
/* Remember this point as the best scoring end point */
score = sum;
last_esp = esp;
- last_esp_num = i;
+ last_esp_num = index;
new_q_end = query;
new_s_end = subject;
}
- if (i >= esp->num) {
- i = 0;
+ if (index >= esp->num) {
+ index = 0;
prev_esp = esp;
esp = esp->next;
}
- }
-
- score /= factor;
+ } /* loop on edit scripts */
+ } /* if (gapped_calculation) */
- delete_hsp = FALSE;
- hsp->score = score;
- hsp->evalue =
- BLAST_KarlinStoE_simple(score, kbp[context], searchsp_eff);
- if (hsp->evalue > hit_options->expect_value) {
- delete_hsp = TRUE;
- } else {
- hsp->query.length = new_q_end - new_q_start;
- hsp->subject.length = new_s_end - new_s_start;
- hsp->query.offset = new_q_start - query_start;
- hsp->query.end = hsp->query.offset + hsp->query.length;
- hsp->subject.offset = new_s_start - subject_start;
- hsp->subject.end = hsp->subject.offset + hsp->subject.length;
+ score /= factor;
+
+ delete_hsp = FALSE;
+ hsp->score = score;
+ hsp->evalue =
+ BLAST_KarlinStoE_simple(score, kbp, searchsp_eff);
+ if (hsp->evalue > hit_options->expect_value) {
+ delete_hsp = TRUE;
+ } else {
+ hsp->query.length = new_q_end - new_q_start;
+ hsp->subject.length = new_s_end - new_s_start;
+ hsp->query.offset = new_q_start - query_start;
+ hsp->query.end = hsp->query.offset + hsp->query.length;
+ hsp->subject.offset = new_s_start - subject_start;
+ hsp->subject.end = hsp->subject.offset + hsp->subject.length;
+ if (gapped_calculation) {
/* Make corrections in edit block and free any parts that
are no longer needed */
if (first_esp != hsp->gap_info->esp) {
@@ -659,17 +649,103 @@ BLAST_ReevaluateWithAmbiguities(BlastHSPList* hsp_list,
last_esp->next = NULL;
}
last_esp->num = last_esp_num;
- BlastHSPGetNumIdentical(query_start, subject_start, hsp,
- hit_options->gapped_calculation, &hsp->num_ident, &align_length);
- /* Check if this HSP passes the percent identity test */
- if (((double)hsp->num_ident) / align_length * 100 <
- hit_options->percent_identity)
- delete_hsp = TRUE;
}
+ BlastHSPGetNumIdentical(query_start, subject_start, hsp,
+ gapped_calculation, &hsp->num_ident, &align_length);
+ /* Check if this HSP passes the percent identity test */
+ if (((double)hsp->num_ident) / align_length * 100 <
+ hit_options->percent_identity)
+ delete_hsp = TRUE;
+ }
+
+ if (delete_hsp) { /* This HSP is now below the cutoff */
+ if (gapped_calculation && first_esp != NULL &&
+ first_esp != hsp->gap_info->esp)
+ GapEditScriptDelete(first_esp);
+ }
+
+ return delete_hsp;
+}
+
+/** Reevaluate all HSPs in an HSP list, using ambiguity information.
+ * This is/can only done either for an ungapped search, or if traceback is
+ * already available.
+ * Subject sequence is uncompressed and saved here. Number of identities is
+ * calculated for each HSP along the way.
+ * @param hsp_list The list of HSPs for one subject sequence [in] [out]
+ * @param query_blk The query sequence [in]
+ * @param subject_blk The subject sequence [in] [out]
+ * @param hit_options The options related to saving hits [in]
+ * @param query_info Auxiliary query information [in]
+ * @param sbp The statistical information [in]
+ * @param score_options The scoring options [in]
+ * @param rdfp The BLAST database structure (for retrieving uncompressed
+ * sequence) [in]
+ */
+static Int2
+ReevaluateHSPListWithAmbiguities(BlastHSPList* hsp_list,
+ BLAST_SequenceBlk* query_blk, BLAST_SequenceBlk* subject_blk,
+ const BlastHitSavingOptions* hit_options, BlastQueryInfo* query_info,
+ BlastScoreBlk* sbp, const BlastScoringOptions* score_options,
+ const BlastSeqSrc* bssp)
+{
+ BlastHSP** hsp_array,* hsp;
+ Uint1* query_start,* subject_start = NULL;
+ Int4 index, context, hspcnt;
+ Boolean purge, delete_hsp;
+ Int2 status = 0;
+ GetSeqArg seq_arg;
+ Boolean gapped_calculation = score_options->gapped_calculation;
+ if (!hsp_list)
+ return status;
+
+ hspcnt = hsp_list->hspcnt;
+ hsp_array = hsp_list->hsp_array;
+ memset((void*) &seq_arg, 0, sizeof(seq_arg));
+
+ /* In case of no traceback, return without doing anything */
+ if (!hsp_list->traceback_done && gapped_calculation) {
+ if (hsp_list->hspcnt > 1)
+ status = BlastSortUniqHspArray(hsp_list);
+ return status;
+ }
+
+ if (hsp_list->hspcnt == 0)
+ /* All HSPs have been deleted */
+ return status;
+
+ /* Retrieve the unpacked subject sequence and save it in the
+ sequence_start element of the subject structure.
+ NB: for the BLAST 2 Sequences case, the uncompressed sequence must
+ already be there */
+ if (bssp) {
+ seq_arg.oid = subject_blk->oid;
+ seq_arg.encoding = BLASTNA_ENCODING;
+ BLASTSeqSrcGetSequence(bssp, (void*) &seq_arg);
+
+ subject_blk->sequence_start = seq_arg.seq->sequence_start;
+ subject_blk->sequence = seq_arg.seq->sequence_start + 1;
+ }
+ /* The sequence in blastna encoding is now stored in sequence_start */
+ subject_start = subject_blk->sequence_start + 1;
+
+ purge = FALSE;
+ for (index=0; index<hspcnt; index++) {
+ if (hsp_array[index] == NULL)
+ continue;
+ else
+ hsp = hsp_array[index];
+
+ context = hsp->context;
+
+ query_start = query_blk->sequence + query_info->context_offsets[context];
+
+ delete_hsp =
+ ReevaluateHSPWithAmbiguities(hsp, query_start, subject_start,
+ hit_options, score_options, query_info, sbp);
+
if (delete_hsp) { /* This HSP is now below the cutoff */
- if (first_esp != NULL && first_esp != hsp->gap_info->esp)
- GapEditScriptDelete(first_esp);
hsp_array[index] = BlastHSPFree(hsp_array[index]);
purge = TRUE;
}
@@ -758,8 +834,10 @@ evalue_compare_hsp_lists(const void* v1, const void* v2)
h2 = *(BlastHSPList**) v2;
/* If any of the HSP lists is empty, it is considered "worse" than the
- other */
- if (h1->hspcnt == 0)
+ other, unless the other is also empty. */
+ if (h1->hspcnt == 0 && h2->hspcnt == 0)
+ return 0;
+ else if (h1->hspcnt == 0)
return 1;
else if (h2->hspcnt == 0)
return -1;
@@ -827,6 +905,7 @@ static void InsertBlastHSPListInHeap(BlastHitList* hit_list,
}
hit_list->worst_evalue =
hit_list->hsplist_array[0]->hsp_array[0]->evalue;
+ hit_list->low_score = hit_list->hsplist_array[0]->hsp_array[0]->score;
}
/** Insert a new HSP list into the hit list.
@@ -858,7 +937,11 @@ static Int2 BLAST_UpdateHitList(BlastHitList* hit_list,
hit_list->hsplist_array[hit_list->hsplist_count++] = hsp_list;
hit_list->worst_evalue =
MAX(hsp_list->hsp_array[0]->evalue, hit_list->worst_evalue);
- } else if (hsp_list->hsp_array[0]->evalue >= hit_list->worst_evalue) {
+ hit_list->low_score =
+ MIN(hsp_list->hsp_array[0]->score, hit_list->low_score);
+ } else if ((hsp_list->hsp_array[0]->evalue > hit_list->worst_evalue) ||
+ ((hsp_list->hsp_array[0]->evalue == hit_list->worst_evalue) &&
+ (hsp_list->hsp_array[0]->score <= hit_list->low_score))) {
/* This hit list is less significant than any of those already saved;
discard it */
BlastHSPListFree(hsp_list);
@@ -887,6 +970,7 @@ static BlastHitList* BLAST_HitListNew(Int4 hitlist_size)
BlastHitList* new_hitlist = (BlastHitList*)
calloc(1, sizeof(BlastHitList));
new_hitlist->hsplist_max = hitlist_size;
+ new_hitlist->low_score = INT4_MAX;
return new_hitlist;
}
@@ -908,9 +992,9 @@ static BlastHitList* BLAST_HitListFree(BlastHitList* hitlist)
static BlastHSPList* BlastHSPListDup(BlastHSPList* hsp_list)
{
BlastHSPList* new_hsp_list = (BlastHSPList*)
- MemDup(hsp_list, sizeof(BlastHSPList));
+ BlastMemDup(hsp_list, sizeof(BlastHSPList));
new_hsp_list->hsp_array = (BlastHSP**)
- MemDup(hsp_list->hsp_array, hsp_list->hspcnt*sizeof(BlastHSP*));
+ BlastMemDup(hsp_list->hsp_array, hsp_list->hspcnt*sizeof(BlastHSP*));
new_hsp_list->allocated = hsp_list->hspcnt;
return new_hsp_list;
@@ -918,7 +1002,7 @@ static BlastHSPList* BlastHSPListDup(BlastHSPList* hsp_list)
/* Documentation in blast_hits.h */
Int2 BLAST_SaveHitlist(Uint1 program, BLAST_SequenceBlk* query,
- BLAST_SequenceBlk* subject, BlastResults* results,
+ BLAST_SequenceBlk* subject, BlastHSPResults* results,
BlastHSPList* hsp_list, BlastHitSavingParameters* hit_parameters,
BlastQueryInfo* query_info, BlastScoreBlk* sbp,
const BlastScoringOptions* score_options, const BlastSeqSrc* bssp,
@@ -935,7 +1019,7 @@ Int2 BLAST_SaveHitlist(Uint1 program, BLAST_SequenceBlk* query,
return 0;
if (program == blast_type_blastn) {
- status = BLAST_ReevaluateWithAmbiguities(hsp_list, query, subject,
+ status = ReevaluateHSPListWithAmbiguities(hsp_list, query, subject,
hit_options, query_info, sbp, score_options, bssp);
context_factor = 2;
} else if (program == blast_type_blastx ||
@@ -948,7 +1032,7 @@ Int2 BLAST_SaveHitlist(Uint1 program, BLAST_SequenceBlk* query,
/* Sort the HSPs by e-value */
if (hsp_list->hspcnt > 1) {
qsort(hsp_list->hsp_array, hsp_list->hspcnt, sizeof(BlastHSP*),
- evalue_compare_hsps);
+ score_compare_hsps);
}
/* *******************************************************************
@@ -1037,12 +1121,12 @@ Int2 BLAST_SaveHitlist(Uint1 program, BLAST_SequenceBlk* query,
return 0;
}
-Int2 BLAST_ResultsInit(Int4 num_queries, BlastResults** results_ptr)
+Int2 BLAST_ResultsInit(Int4 num_queries, BlastHSPResults** results_ptr)
{
- BlastResults* results;
+ BlastHSPResults* results;
Int2 status = 0;
- results = (BlastResults*) malloc(sizeof(BlastResults));
+ results = (BlastHSPResults*) malloc(sizeof(BlastHSPResults));
results->num_queries = num_queries;
results->hitlist_array = (BlastHitList**)
@@ -1052,7 +1136,7 @@ Int2 BLAST_ResultsInit(Int4 num_queries, BlastResults** results_ptr)
return status;
}
-BlastResults* BLAST_ResultsFree(BlastResults* results)
+BlastHSPResults* BLAST_ResultsFree(BlastHSPResults* results)
{
Int4 index;
@@ -1066,7 +1150,25 @@ BlastResults* BLAST_ResultsFree(BlastResults* results)
return NULL;
}
-Int2 BLAST_SortResults(BlastResults* results)
+static void BlastHitListPurge(BlastHitList* hit_list)
+{
+ Int4 index, hsplist_count;
+
+ if (!hit_list)
+ return;
+
+ hsplist_count = hit_list->hsplist_count;
+ for (index = 0; index < hsplist_count &&
+ hit_list->hsplist_array[index]->hspcnt > 0; ++index);
+
+ hit_list->hsplist_count = index;
+ /* Free all empty HSP lists */
+ for ( ; index < hsplist_count; ++index) {
+ BlastHSPListFree(hit_list->hsplist_array[index]);
+ }
+}
+
+Int2 BLAST_SortResults(BlastHSPResults* results)
{
Int4 index;
BlastHitList* hit_list;
@@ -1077,6 +1179,7 @@ Int2 BLAST_SortResults(BlastResults* results)
qsort(hit_list->hsplist_array, hit_list->hsplist_count,
sizeof(BlastHSPList*), evalue_compare_hsp_lists);
}
+ BlastHitListPurge(hit_list);
}
return 0;
}
@@ -1287,8 +1390,7 @@ BLAST_MergeHsps(BlastHSP* hsp1, BlastHSP* hsp2, Int4 start)
if (new_segment1->s_end <= new_segment2->s_end) {
new_segment1 = new_segment1->next;
num1++;
- }
- if (new_segment1->s_end >= new_segment2->s_end) {
+ } else {
new_segment2 = new_segment2->next;
num2++;
}
diff --git a/algo/blast/core/blast_hits.h b/algo/blast/core/blast_hits.h
index 17b0bfa6..f10f6edf 100644
--- a/algo/blast/core/blast_hits.h
+++ b/algo/blast/core/blast_hits.h
@@ -1,4 +1,4 @@
-/* $Id: blast_hits.h,v 1.13 2003/09/25 15:15:55 dondosha Exp $
+/* $Id: blast_hits.h,v 1.18 2003/12/12 22:57:31 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,7 +32,7 @@ Author: Ilya Dondoshansky
Contents: Structures used for saving BLAST hits
******************************************************************************
- * $Revision: 1.13 $
+ * $Revision: 1.18 $
* */
#ifndef __BLAST_HITS__
#define __BLAST_HITS__
@@ -49,18 +49,19 @@ typedef struct BlastHitList {
Int4 hsplist_count; /**< Filled size of the HSP lists array */
Int4 hsplist_max; /**< Maximal allowed size of the HSP lists array */
double worst_evalue; /**< Highest of the best e-values among the HSP
- lists */
+ lists */
+ Int4 low_score; /**< The lowest of the best scores among the HSP lists */
Boolean heapified; /**< Is this hit list already heapified? */
BlastHSPList** hsplist_array; /**< Array of HSP lists for individual
database hits */
} BlastHitList;
/** The structure to contain all BLAST results, for multiple queries */
-typedef struct BlastResults {
+typedef struct BlastHSPResults {
Int4 num_queries; /**< Number of query sequences */
BlastHitList** hitlist_array; /**< Array of results for individual
query sequences */
-} BlastResults;
+} BlastHSPResults;
/** BLAST_SaveHitlist
* Save the current hit list to appropriate places in the results structure
@@ -81,7 +82,7 @@ typedef struct BlastResults {
* @param thr_info Information shared between multiple search threads [in]
*/
Int2 BLAST_SaveHitlist(Uint1 program, BLAST_SequenceBlk* query,
- BLAST_SequenceBlk* subject, BlastResults* results,
+ BLAST_SequenceBlk* subject, BlastHSPResults* results,
BlastHSPList* hsp_list, BlastHitSavingParameters* hit_parameters,
BlastQueryInfo* query_info, BlastScoreBlk* sbp,
const BlastScoringOptions* score_options, const BlastSeqSrc* bssp,
@@ -92,10 +93,10 @@ Int2 BLAST_SaveHitlist(Uint1 program, BLAST_SequenceBlk* query,
* for [in]
* @param results_ptr The allocated structure [out]
*/
-Int2 BLAST_ResultsInit(Int4 num_queries, BlastResults** results_ptr);
+Int2 BLAST_ResultsInit(Int4 num_queries, BlastHSPResults** results_ptr);
/** Sort each hit list in the BLAST results by best e-value */
-Int2 BLAST_SortResults(BlastResults* results);
+Int2 BLAST_SortResults(BlastHSPResults* results);
/** Calculate the expected values for all HSPs in a hit list. In case of
* multiple queries, the offsets are assumed to be already adjusted to
@@ -104,11 +105,11 @@ Int2 BLAST_SortResults(BlastResults* results);
* @param query_info Auxiliary query information - needed only for effective
search space calculation if it is not provided [in]
* @param hsp_list List of HSPs for one subject sequence [in] [out]
- * @param hit_options Options containing the e-value cut-off [in]
+ * @param score_options Needed only to check if gapped calculation is done [in]
* @param sbp Structure containing statistical information [in]
*/
Int2 BLAST_GetNonSumStatsEvalue(Uint1 program, BlastQueryInfo* query_info,
- BlastHSPList* hsp_list, BlastHitSavingOptions* hit_options,
+ BlastHSPList* hsp_list, const BlastScoringOptions* score_options,
BlastScoreBlk* sbp);
/** Calculate e-value for an HSP found by PHI BLAST.
@@ -132,6 +133,26 @@ void PHIGetEvalue(BlastHSPList* hsp_list, BlastScoreBlk* sbp);
Int2 BLAST_ReapHitlistByEvalue(BlastHSPList* hsp_list,
BlastHitSavingOptions* hit_options);
+/** Reevaluate the HSP's score, e-value and percent identity after taking
+ * into account the ambiguity information. Needed for blastn only, either
+ * after a greedy gapped extension, or for ungapped search.
+ * @param hsp The HSP structure [in] [out]
+ * @param query_start Pointer to the start of the query sequence [in]
+ * @param subject_start Pointer to the start of the subject sequence [in]
+ * @param hit_options Hit saving options with e-value cut-off [in]
+ * @param score_options Scoring options [in]
+ * @param query_info Query information structure, containing effective search
+ * space(s) [in]
+ * @param sbp Score block with Karlin-Altschul parameters [in]
+ * @return Should this HSP be deleted after the score reevaluation?
+ */
+Boolean ReevaluateHSPWithAmbiguities(BlastHSP* hsp,
+ Uint1* query_start, Uint1* subject_start,
+ const BlastHitSavingOptions* hit_options,
+ const BlastScoringOptions* score_options,
+ BlastQueryInfo* query_info, BlastScoreBlk* sbp);
+
+
/** Cleans out the NULLed out HSP's from the HSP array,
* moving the BLAST_HSPPtr's up to fill in the gaps.
* @param hsp_array Array of pointers to HSP structures [in]
@@ -193,7 +214,7 @@ BlastHSP* BlastHSPFree(BlastHSP* hsp);
BlastHSPList* BlastHSPListFree(BlastHSPList* hsp_list);
/** Deallocate memory for BLAST results */
-BlastResults* BLAST_ResultsFree(BlastResults* results);
+BlastHSPResults* BLAST_ResultsFree(BlastHSPResults* results);
#ifdef __cplusplus
}
diff --git a/algo/blast/core/blast_lookup.c b/algo/blast/core/blast_lookup.c
index 9177a990..3215ec7a 100644
--- a/algo/blast/core/blast_lookup.c
+++ b/algo/blast/core/blast_lookup.c
@@ -1,4 +1,4 @@
-/* $Id: blast_lookup.c,v 1.3 2003/10/22 16:45:28 dondosha Exp $
+/* $Id: blast_lookup.c,v 1.16 2004/01/26 19:39:27 coulouri Exp $
* ===========================================================================
*
@@ -29,9 +29,9 @@
#include <algo/blast/core/blast_def.h>
#include <algo/blast/core/blast_options.h>
#include <algo/blast/core/blast_lookup.h>
-#include <algo/blast/core/util.h>
+#include <algo/blast/core/lookup_util.h>
-static char const rcsid[] = "$Id: blast_lookup.c,v 1.3 2003/10/22 16:45:28 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_lookup.c,v 1.16 2004/01/26 19:39:27 coulouri Exp $";
static void AddWordHits( LookupTable *lookup,
Int4** matrix,
@@ -65,12 +65,21 @@ Int4 LookupTableNew(const LookupTableOptions* opt,
Boolean is_protein)
{
LookupTable* lookup = *lut =
- (LookupTable*) malloc(sizeof(LookupTable));
+ (LookupTable*) calloc(1, sizeof(LookupTable));
+
+ ASSERT(lookup != NULL);
if (is_protein) {
+ Int4 i;
+
lookup->charsize = ilog2(opt->alphabet_size) + 1;
lookup->wordsize = opt->word_size;
- lookup->backbone_size = iexp(2,lookup->charsize*opt->word_size);
+
+ lookup->backbone_size = 0;
+ for(i=0;i<lookup->wordsize;i++)
+ lookup->backbone_size |= (opt->alphabet_size - 1) << (i * lookup->charsize);
+ lookup->backbone_size += 1;
+
lookup->mask = makemask(opt->word_size * lookup->charsize);
} else {
lookup->word_length = opt->word_size;
@@ -90,8 +99,11 @@ Int4 LookupTableNew(const LookupTableOptions* opt,
lookup->threshold = opt->threshold;
lookup->thin_backbone =
(Int4**) calloc(lookup->backbone_size , sizeof(Int4*));
- lookup->use_pssm = opt->use_pssm;
+ ASSERT(lookup->thin_backbone != NULL);
+ lookup->use_pssm = opt->use_pssm;
+ lookup->neighbors=NULL;
+ lookup->overflow=NULL;
return 0;
}
@@ -105,16 +117,18 @@ Int4 BlastAaLookupAddWordHit(LookupTable* lookup, /* in/out: the lookup table */
Int4 * chain = NULL;
/* compute its index, */
+
_ComputeIndex(lookup->wordsize,lookup->charsize,lookup->mask, w, &index);
ASSERT(index < lookup->backbone_size);
-
+
/* if backbone cell is null, initialize a new chain */
if (lookup->thin_backbone[index] == NULL)
{
chain_size = 8;
hits_in_chain = 0;
- chain = (Int4*) malloc( chain_size * sizeof(Int4) );
+ chain = (Int4*) calloc( chain_size, sizeof(Int4) );
+ ASSERT(chain != NULL);
chain[0] = chain_size;
chain[1] = hits_in_chain;
lookup->thin_backbone[index] = chain;
@@ -132,6 +146,8 @@ Int4 BlastAaLookupAddWordHit(LookupTable* lookup, /* in/out: the lookup table */
{
chain_size = chain_size * 2;
chain = (Int4*) realloc(chain, chain_size * sizeof(Int4) );
+ ASSERT(chain != NULL);
+
lookup->thin_backbone[index] = chain;
chain[0] = chain_size;
}
@@ -156,10 +172,12 @@ Int4 _BlastAaLookupFinalize(LookupTable* lookup)
/* allocate the new lookup table */
lookup->thick_backbone = (LookupBackboneCell *)
calloc(lookup->backbone_size , sizeof(LookupBackboneCell));
+ ASSERT(lookup->thick_backbone != NULL);
/* allocate the pv_array */
lookup->pv = (PV_ARRAY_TYPE *)
- calloc((lookup->backbone_size >> PV_ARRAY_BTS) , sizeof(PV_ARRAY_TYPE));
+ calloc((lookup->backbone_size >> PV_ARRAY_BTS) + 1 , sizeof(PV_ARRAY_TYPE));
+ ASSERT(lookup->pv != NULL);
/* find out how many cells have >3 hits */
for(i=0;i<lookup->backbone_size;i++)
@@ -175,7 +193,8 @@ Int4 _BlastAaLookupFinalize(LookupTable* lookup)
lookup->longest_chain = longest_chain;
/* allocate the overflow array */
- lookup->overflow = (Int4*) malloc( overflow_cells_needed * sizeof(Int4) );
+ lookup->overflow = (Int4*) calloc( overflow_cells_needed, sizeof(Int4) );
+ ASSERT(lookup->overflow != NULL);
/* for each position in the lookup table backbone, */
for(i=0;i<lookup->backbone_size;i++)
@@ -207,7 +226,7 @@ for(i=0;i<lookup->backbone_size;i++)
num_overflows++;
lookup->thick_backbone[i].num_used = lookup->thin_backbone[i][1];
- lookup->thick_backbone[i].payload.overflow = & (lookup->overflow[overflow_cursor]);
+ lookup->thick_backbone[i].payload.overflow_cursor = overflow_cursor;
for(j=0;j<lookup->thin_backbone[i][1];j++)
{
lookup->overflow[overflow_cursor] = lookup->thin_backbone[i][j+2];
@@ -260,6 +279,7 @@ static NCBI_INLINE void _ComputeIndex(Int4 wordsize,
Int4 i;
*index = 0;
+
for(i=0;i<wordsize;i++)
{
*index = ((*index << charsize) | word[i]) & mask;
@@ -337,7 +357,7 @@ Int4 BlastAaScanSubject(const LookupTableWrap* lookup_wrap,
src = lookup->thick_backbone[index].payload.entries;
else
/* hits live in overflow array */
- src = lookup->thick_backbone[index].payload.overflow;
+ src = & (lookup->overflow [ lookup->thick_backbone[index].payload.overflow_cursor ] );
/* copy the hits. */
for(i=0;i<numhits;i++)
@@ -390,8 +410,8 @@ Int4 BlastAaLookupIndexQueries(LookupTable* lookup,
}
/* free neighbor array*/
- sfree(lookup->neighbors);
- lookup->neighbors=NULL;
+ if (lookup->neighbors != NULL)
+ sfree(lookup->neighbors);
return 0;
}
@@ -408,7 +428,7 @@ Int4 _BlastAaLookupIndexQuery(LookupTable* lookup,
for(loc=location; loc; loc=loc->next)
{
from = ((DoubleInt*) loc->ptr)->i1;
- to = ((DoubleInt*) loc->ptr)->i2 - lookup->wordsize;
+ to = ((DoubleInt*) loc->ptr)->i2 - lookup->wordsize + 1;
for(w=from;w<=to;w++)
{
@@ -436,6 +456,7 @@ Int4 MakeAllWordSequence(LookupTable* lookup)
lookup->neighbors_length = len;
lookup->neighbors = (Uint1*) malloc( len );
+ ASSERT(lookup->neighbors != NULL);
/* generate the de Bruijn sequence */
@@ -444,30 +465,34 @@ Int4 MakeAllWordSequence(LookupTable* lookup)
/* unwrap it */
for(i=0;i<(n-1);i++)
- lookup->neighbors[len-((n-1)+1)+i] = lookup->neighbors[i];
+ lookup->neighbors[len-n+1+i] = lookup->neighbors[i];
return 0;
}
Int4 AddNeighboringWords(LookupTable* lookup, Int4 ** matrix, BLAST_SequenceBlk* query, Int4 offset)
{
- Uint1* w = NULL;
-
-
- if (query)
- w = query->sequence + offset;
- if (lookup->threshold == 0)
+ if (lookup->use_pssm)
+ {
+ AddPSSMWordHits(lookup, matrix, offset);
+ }
+ else
+ {
+ Uint1* w = NULL;
+ ASSERT(query != NULL);
+ w = query->sequence + offset;
+
+ if (lookup->threshold == 0)
{
BlastAaLookupAddWordHit(lookup, w, offset);
lookup->exact_matches++;
- return 0;
}
-
- if (lookup->use_pssm)
- AddPSSMWordHits(lookup, matrix, offset);
- else
+ else
+ {
AddWordHits(lookup, matrix, w, offset);
+ }
+ }
return 0;
}
@@ -475,7 +500,7 @@ static void AddWordHits(LookupTable* lookup, Int4** matrix,
Uint1* word, Int4 offset)
{
Uint1* s = lookup->neighbors;
- Uint1* s_end=s + lookup->neighbors_length - lookup->wordsize;
+ Uint1* s_end=s + lookup->neighbors_length - lookup->wordsize + 1;
Uint1* w = word;
Uint1 different;
Int4 score;
@@ -500,7 +525,13 @@ static void AddWordHits(LookupTable* lookup, Int4** matrix,
while (s < s_end)
{
if ( (s[0] == w[0]) || (p0[s[0]] >= threshold) )
+ {
BlastAaLookupAddWordHit(lookup,s,offset);
+ if (s[0] == w[0])
+ lookup->exact_matches++;
+ else
+ lookup->neighbor_matches++;
+ }
s++;
}
@@ -516,7 +547,13 @@ static void AddWordHits(LookupTable* lookup, Int4** matrix,
different = (w[0] ^ s[0]) | (w[1] ^ s[1]);
if ( !different || (score >= threshold) )
+ {
BlastAaLookupAddWordHit(lookup,s,offset);
+ if (!different)
+ lookup->exact_matches++;
+ else
+ lookup->neighbor_matches++;
+ }
s++;
}
@@ -533,7 +570,13 @@ static void AddWordHits(LookupTable* lookup, Int4** matrix,
different = (w[0] ^ s[0]) | (w[1] ^ s[1]) | (w[2] ^ s[2]);
if ( !different || (score >= threshold) )
+ {
BlastAaLookupAddWordHit(lookup,s,offset);
+ if (!different)
+ lookup->exact_matches++;
+ else
+ lookup->neighbor_matches++;
+ }
s++;
}
@@ -551,7 +594,13 @@ static void AddWordHits(LookupTable* lookup, Int4** matrix,
}
if ( !different || (score >= threshold) )
+ {
BlastAaLookupAddWordHit(lookup,s,offset);
+ if (!different)
+ lookup->exact_matches++;
+ else
+ lookup->neighbor_matches++;
+ }
s++;
}
@@ -731,8 +780,7 @@ Int4 BlastNaScanSubject_AG(const LookupTableWrap* lookup_wrap,
if (NA_PV_TEST(pv_array, index, PV_ARRAY_BTS)) {
num_hits = lookup->thick_backbone[index].num_used;
- if (num_hits == 0)
- continue;
+ ASSERT(num_hits != 0);
if (num_hits > (max_hits - total_hits))
break;
if ( num_hits <= HITS_ON_BACKBONE )
@@ -740,11 +788,9 @@ Int4 BlastNaScanSubject_AG(const LookupTableWrap* lookup_wrap,
lookup_pos = lookup->thick_backbone[index].payload.entries;
else
/* hits live in overflow array */
- lookup_pos = (Int4*)
- (lookup->thick_backbone[index].payload.overflow);
+ lookup_pos = & ( lookup->overflow[lookup->thick_backbone[index].payload.overflow_cursor] );
- s_off =
- ((s - abs_start) + compressed_wordsize)*COMPRESSION_RATIO;
+ s_off = (s - abs_start)*COMPRESSION_RATIO;
while (num_hits) {
q_off = *((Uint4 *) lookup_pos); /* get next query offset */
lookup_pos++;
@@ -770,13 +816,13 @@ Int4 BlastNaScanSubject_AG(const LookupTableWrap* lookup_wrap,
index = 0;
for (i = 0; i < compressed_wordsize; ++i)
index = ((index)<<FULL_BYTE_SHIFT) | (*s++);
+
adjusted_index =
- (((index)<<bit) & lookup->mask) | ((*s)>>(FULL_BYTE_SHIFT-bit));
+ BlastNaLookupAdjustIndex(s, index, lookup->mask, bit);
if (NA_PV_TEST(pv_array, adjusted_index, PV_ARRAY_BTS)) {
num_hits = lookup->thick_backbone[adjusted_index].num_used;
- if (num_hits == 0)
- continue;
+ ASSERT(num_hits != 0);
if (num_hits > (max_hits - total_hits))
break;
if ( num_hits <= HITS_ON_BACKBONE )
@@ -784,8 +830,7 @@ Int4 BlastNaScanSubject_AG(const LookupTableWrap* lookup_wrap,
lookup_pos = lookup->thick_backbone[adjusted_index].payload.entries;
else
/* hits live in overflow array */
- lookup_pos = (Int4*)
- (lookup->thick_backbone[adjusted_index].payload.overflow);
+ lookup_pos = & (lookup->overflow [ lookup->thick_backbone[adjusted_index].payload.overflow_cursor]);
while (num_hits) {
q_off = *((Uint4 *) lookup_pos); /* get next query offset */
@@ -793,7 +838,7 @@ Int4 BlastNaScanSubject_AG(const LookupTableWrap* lookup_wrap,
num_hits--;
q_offsets[total_hits] = q_off;
- s_offsets[total_hits++] = s_off + reduced_word_length;
+ s_offsets[total_hits++] = s_off;
}
}
}
@@ -818,105 +863,54 @@ Int4 BlastNaScanSubject(const LookupTableWrap* lookup_wrap,
Int4 q_off;
PV_ARRAY_TYPE *pv_array = lookup->pv;
Int4 total_hits = 0;
- Boolean full_byte_scan = (lookup->scan_step % COMPRESSION_RATIO == 0);
+ Int4 reduced_word_length = lookup->reduced_wordsize*COMPRESSION_RATIO;
Int4 i;
abs_start = subject->sequence;
s = abs_start + start_offset/COMPRESSION_RATIO;
/* s_end points to the place right after the last full sequence byte */
- s_end = abs_start + (*end_offset)/COMPRESSION_RATIO;
+ s_end =
+ abs_start + (*end_offset + reduced_word_length)/COMPRESSION_RATIO;
+
index = 0;
/* Compute the first index */
for (i = 0; i < lookup->reduced_wordsize; ++i)
index = ((index)<<FULL_BYTE_SHIFT) | *s++;
- if (full_byte_scan) {
- /* s points to the byte right after the end of the current word */
- while (s <= s_end) {
- if (NA_PV_TEST(pv_array, index, PV_ARRAY_BTS)) {
- num_hits = lookup->thick_backbone[index].num_used;
- if (num_hits == 0)
- continue;
- if (num_hits > (max_hits - total_hits))
- break;
- if ( num_hits <= HITS_ON_BACKBONE )
- /* hits live in thick_backbone */
- lookup_pos = lookup->thick_backbone[index].payload.entries;
- else
- /* hits live in overflow array */
- lookup_pos =
- (Int4*)(lookup->thick_backbone[index].payload.overflow);
-
- /* Save the hits offsets */
- s_off = (s - abs_start)*COMPRESSION_RATIO;
- while (num_hits) {
- q_off = *((Uint4 *) lookup_pos); /* get next query offset */
- lookup_pos++;
- num_hits--;
-
- q_offsets[total_hits] = q_off;
- s_offsets[total_hits++] = s_off;
- }
- }
-
- /* Compute the next value of the index */
- index = (((index)<<FULL_BYTE_SHIFT) & lookup->mask) | (*s++);
-
- }
- /* Ending offset should point to the start of the word that ends
- at s */
- *end_offset = ((s - abs_start) - lookup->reduced_wordsize)*COMPRESSION_RATIO;
- } else {
- Int4 scan_shift = 2*lookup->scan_step;
- Uint1 bit = 2*(start_offset % COMPRESSION_RATIO);
- Int4 adjusted_index;
-
- /* s points to the byte right after the end of the current word */
- while (s <= s_end) {
- /* Adjust the word index by the base within a byte */
- adjusted_index = BlastNaLookupAdjustIndex(s, index, lookup->mask,
- bit);
+ /* s points to the byte right after the end of the current word */
+ while (s <= s_end) {
+ if (NA_PV_TEST(pv_array, index, PV_ARRAY_BTS)) {
+ num_hits = lookup->thick_backbone[index].num_used;
+ ASSERT(num_hits != 0);
+ if (num_hits > (max_hits - total_hits))
+ break;
+ if ( num_hits <= HITS_ON_BACKBONE )
+ /* hits live in thick_backbone */
+ lookup_pos = lookup->thick_backbone[index].payload.entries;
+ else
+ /* hits live in overflow array */
+ lookup_pos = & (lookup->overflow[lookup->thick_backbone[index].payload.overflow_cursor]);
- if (NA_PV_TEST(pv_array, index, PV_ARRAY_BTS)) {
- num_hits = lookup->thick_backbone[index].num_used;
- if (num_hits == 0)
- continue;
- if (num_hits > (max_hits - total_hits))
- break;
- if ( num_hits <= HITS_ON_BACKBONE )
- /* hits live in thick_backbone */
- lookup_pos = lookup->thick_backbone[index].payload.entries;
- else
- /* hits live in overflow array */
- lookup_pos =
- (Int4*)(lookup->thick_backbone[index].payload.overflow);
+ /* Save the hits offsets */
+ s_off = (s - abs_start)*COMPRESSION_RATIO - reduced_word_length;
+ while (num_hits) {
+ q_off = *((Uint4 *) lookup_pos); /* get next query offset */
+ lookup_pos++;
+ num_hits--;
- /* Save the hits offsets */
- s_off = (s - abs_start)*COMPRESSION_RATIO + bit/2;
- while (num_hits) {
- q_off = *((Uint4 *) lookup_pos); /* get next query offset */
- lookup_pos++;
- num_hits--;
-
- q_offsets[total_hits] = q_off;
- s_offsets[total_hits++] = s_off;
- }
- }
- bit += scan_shift;
- if (bit >= FULL_BYTE_SHIFT) {
- /* Advance to the next full byte */
- bit -= FULL_BYTE_SHIFT;
- index = BlastNaLookupComputeIndex(FULL_BYTE_SHIFT,
- lookup->mask, s++, index);
+ q_offsets[total_hits] = q_off;
+ s_offsets[total_hits++] = s_off;
}
}
- /* Ending offset should point to the start of the word that ends
- at s */
- *end_offset =
- ((s - abs_start) - lookup->reduced_wordsize)*COMPRESSION_RATIO
- + bit/2;
+
+ /* Compute the next value of the index */
+ index = (((index)<<FULL_BYTE_SHIFT) & lookup->mask) | (*s++);
+
}
+ /* Ending offset should point to the start of the word that ends
+ at s */
+ *end_offset = (s - abs_start)*COMPRESSION_RATIO - reduced_word_length;
return total_hits;
}
@@ -981,7 +975,8 @@ static Int4 BlastNaLookupAddWordHit(LookupTable* lookup, Uint1* w,
{
chain_size = 8;
hits_in_chain = 0;
- chain = malloc( chain_size * sizeof(Int4) );
+ chain = calloc( chain_size, sizeof(Int4) );
+ ASSERT(chain != NULL);
chain[0] = chain_size;
chain[1] = hits_in_chain;
lookup->thin_backbone[index] = chain;
@@ -999,6 +994,7 @@ static Int4 BlastNaLookupAddWordHit(LookupTable* lookup, Uint1* w,
{
chain_size = chain_size * 2;
chain = realloc(chain, chain_size * sizeof(Int4) );
+ ASSERT(chain != NULL);
lookup->thin_backbone[index] = chain;
chain[0] = chain_size;
}
@@ -1025,12 +1021,12 @@ Int4 BlastNaLookupIndexQuery(LookupTable* lookup, BLAST_SequenceBlk* query,
for(loc=location; loc; loc=loc->next) {
from = ((DoubleInt*) loc->ptr)->i1;
- to = ((DoubleInt*) loc->ptr)->i2;
+ to = ((DoubleInt*) loc->ptr)->i2 + 1;
sequence = query->sequence + from;
- /* Make the offsets point to the ends of the words */
- from += lookup->reduced_wordsize*COMPRESSION_RATIO;
- for(offset = from; offset < to; offset++) {
+ /* Last offset is such that full word fits in the sequence */
+ to -= lookup->reduced_wordsize*COMPRESSION_RATIO;
+ for(offset = from; offset <= to; offset++) {
BlastNaLookupAddWordHit(lookup, sequence, offset);
++sequence;
}
diff --git a/algo/blast/core/blast_lookup.h b/algo/blast/core/blast_lookup.h
index 1d6deba1..77c7d027 100644
--- a/algo/blast/core/blast_lookup.h
+++ b/algo/blast/core/blast_lookup.h
@@ -1,4 +1,4 @@
-/* $Id: blast_lookup.h,v 1.1 2003/09/10 19:37:26 dondosha Exp $
+/* $Id: blast_lookup.h,v 1.2 2004/01/26 19:39:27 coulouri Exp $
* ===========================================================================
*
@@ -75,7 +75,7 @@ extern "C" {
Int4 num_used; /* num valid positions */
union {
- Int4* overflow;
+ Int4 overflow_cursor;
Int4 entries[HITS_ON_BACKBONE];
} payload;
diff --git a/algo/blast/core/blast_options.c b/algo/blast/core/blast_options.c
index 083e7896..e773bce5 100644
--- a/algo/blast/core/blast_options.c
+++ b/algo/blast/core/blast_options.c
@@ -26,6 +26,27 @@
**************************************************************************
*
* $Log: blast_options.c,v $
+ * Revision 1.75 2003/12/31 20:04:47 dondosha
+ * Round best stride to a number divisible by 4 for all values except 6 and 7
+ *
+ * Revision 1.74 2003/12/31 16:04:37 coulouri
+ * use -1 to disable protein neighboring words
+ *
+ * Revision 1.73 2003/12/08 16:03:05 coulouri
+ * Propagate protein neighboring threshold even if it is zero
+ *
+ * Revision 1.72 2003/11/24 23:18:32 dondosha
+ * Added gap_decay_rate argument to BLAST_Cutoffs; removed BLAST_Cutoffs_simple
+ *
+ * Revision 1.71 2003/11/12 18:17:46 dondosha
+ * Correction in calculating scanning stride
+ *
+ * Revision 1.70 2003/11/04 23:22:47 dondosha
+ * Do not calculate hit saving cutoff score for PHI BLAST
+ *
+ * Revision 1.69 2003/10/30 19:34:01 dondosha
+ * Removed gapped_calculation from BlastHitSavingOptions structure
+ *
* Revision 1.68 2003/10/24 20:55:10 camacho
* Rename GetDefaultStride
*
@@ -328,7 +349,7 @@
*
*/
-static char const rcsid[] = "$Id: blast_options.c,v 1.68 2003/10/24 20:55:10 camacho Exp $";
+static char const rcsid[] = "$Id: blast_options.c,v 1.75 2003/12/31 20:04:47 dondosha Exp $";
#include <algo/blast/core/blast_options.h>
#include <algo/blast/core/blast_gapalign.h>
@@ -473,7 +494,7 @@ BlastInitialWordParametersNew(Uint1 program_number,
BlastExtensionParameters* ext_params, BlastScoreBlk* sbp,
BlastQueryInfo* query_info,
const BlastEffectiveLengthsOptions* eff_len_options,
- BlastInitialWordParameters* *parameters)
+ Boolean gapped_calculation, BlastInitialWordParameters* *parameters)
{
Int4 context = query_info->first_context;
Int4 cutoff_score = 0, s2 = 0;
@@ -493,8 +514,7 @@ BlastInitialWordParametersNew(Uint1 program_number,
(*parameters)->x_dropoff = (Int4)
ceil(word_options->x_dropoff*NCBIMATH_LN2/sbp->kbp_std[context]->Lambda);
- if (hit_params->options->gapped_calculation &&
- program_number != blast_type_blastn)
+ if (program_number != blast_type_blastn && gapped_calculation)
kbp = sbp->kbp_gap[context];
else
kbp = sbp->kbp_std[context];
@@ -507,14 +527,14 @@ BlastInitialWordParametersNew(Uint1 program_number,
eff_len_options->dbseq_num;
e2 = UNGAPPED_CUTOFF_EVALUE;
- BLAST_Cutoffs(&s2, &e2, kbp, MIN(avglen, qlen), avglen, TRUE);
+ BLAST_Cutoffs(&s2, &e2, kbp, MIN(avglen, qlen)*avglen, TRUE,
+ hit_params->gap_decay_rate);
cutoff_score = MIN(hit_params->cutoff_score, s2);
/* For non-blastn programs, the cutoff score should not be larger than
gap trigger */
- if (hit_params->options->gapped_calculation &&
- program_number != blast_type_blastn) {
+ if (gapped_calculation && program_number != blast_type_blastn) {
(*parameters)->cutoff_score =
MIN((Int4)ext_params->gap_trigger, cutoff_score);
} else {
@@ -741,6 +761,16 @@ BlastScoringOptionsValidate(Uint1 program_number,
if (options == NULL)
return 1;
+ if (program_number == blast_type_tblastx &&
+ options->gapped_calculation)
+ {
+ Int4 code=2;
+ Int4 subcode=1;
+ Blast_MessageWrite(blast_msg, 2, code, subcode,
+ "Gapped search is not allowed for tblastx");
+ return (Int2) code;
+ }
+
if (program_number == blast_type_blastn)
{
if (options->penalty >= 0)
@@ -893,6 +923,8 @@ Int4 CalculateBestStride(Int4 word_size, Boolean var_words, Int4 lut_type)
{
Int4 lut_width;
Int4 extra = 1;
+ Uint1 remainder;
+ Int4 stride;
if (lut_type == MB_LOOKUP_TABLE)
lut_width = 12;
@@ -901,10 +933,18 @@ Int4 CalculateBestStride(Int4 word_size, Boolean var_words, Int4 lut_type)
else
lut_width = 4;
- if (var_words && ((word_size % COMPRESSION_RATIO) == 0) )
+ remainder = word_size % COMPRESSION_RATIO;
+
+ if (var_words && (remainder == 0) )
extra = COMPRESSION_RATIO;
- return word_size - lut_width + extra;
+ stride = word_size - lut_width + extra;
+
+ remainder = stride % 4;
+
+ if (stride > 8 || (stride > 4 && remainder == 1) )
+ stride -= remainder;
+ return stride;
}
Int2
@@ -927,8 +967,16 @@ BLAST_FillLookupTableOptions(LookupTableOptions* options,
}
}
- if (threshold)
+ /* if the supplied threshold is -1, disable neighboring words */
+ if (threshold == -1)
+ options->threshold = 0;
+
+ /* if the supplied threshold is > 0, use it */
+ if (threshold > 0)
options->threshold = threshold;
+
+ /* otherwise, use the default */
+
if (use_pssm)
options->use_pssm = use_pssm;
if (word_size)
@@ -937,7 +985,7 @@ BLAST_FillLookupTableOptions(LookupTableOptions* options,
if (!ag_blast) {
options->scan_step = COMPRESSION_RATIO;
} else {
- options->scan_step = CalculateBestStride(word_size, variable_wordsize,
+ options->scan_step = CalculateBestStride(options->word_size, variable_wordsize,
options->lut_type);
}
}
@@ -1070,7 +1118,6 @@ BLAST_FillHitSavingOptions(BlastHitSavingOptions* options,
if (!options)
return 1;
- options->gapped_calculation = is_gapped;
if (hitlist_size)
options->hitlist_size = hitlist_size;
if (evalue)
@@ -1087,14 +1134,6 @@ BlastHitSavingOptionsValidate(Uint1 program_number,
if (options == NULL)
return 1;
- if (program_number == blast_type_tblastx && options->gapped_calculation) {
- Int4 code=2;
- Int4 subcode=1;
- Blast_MessageWrite(blast_msg, 2, code, subcode,
- "Gapped search is not allowed for tblastx");
- return (Int2) code;
- }
-
if (options->hitlist_size < 1)
{
Int4 code=1;
@@ -1135,6 +1174,7 @@ BlastHitSavingParametersNew(Uint1 program_number,
BlastHitSavingParameters* params;
BLAST_KarlinBlk* kbp;
double evalue = options->expect_value;
+ Boolean gapped_calculation = TRUE;
if (!options || !parameters)
return 1;
@@ -1149,20 +1189,24 @@ BlastHitSavingParametersNew(Uint1 program_number,
params->handle_results = handle_results;
- if (sbp->kbp_gap && sbp->kbp_gap[query_info->first_context])
+ if (sbp->kbp_gap && sbp->kbp_gap[query_info->first_context]) {
kbp = sbp->kbp_gap[query_info->first_context];
- else
+ } else {
kbp = sbp->kbp[query_info->first_context];
+ gapped_calculation = FALSE;
+ }
if (options->cutoff_score > 0) {
params->cutoff_score = options->cutoff_score;
- } else {
- BLAST_Cutoffs_simple(&(params->cutoff_score), &evalue, kbp,
+ } else if (!options->phi_align) {
+ BLAST_Cutoffs(&(params->cutoff_score), &evalue, kbp,
(double)query_info->eff_searchsp_array[query_info->first_context],
- FALSE);
+ FALSE, 0);
+ } else {
+ params->cutoff_score = 0;
}
- if (program_number == blast_type_blastn || !options->gapped_calculation) {
+ if (program_number == blast_type_blastn || !gapped_calculation) {
params->gap_prob = BLAST_GAP_PROB;
params->gap_decay_rate = BLAST_GAP_DECAY_RATE;
} else {
diff --git a/algo/blast/core/blast_options.h b/algo/blast/core/blast_options.h
index bfc60f28..14ff03fb 100644
--- a/algo/blast/core/blast_options.h
+++ b/algo/blast/core/blast_options.h
@@ -1,4 +1,4 @@
-/* $Id: blast_options.h,v 1.49 2003/10/24 20:54:54 camacho Exp $
+/* $Id: blast_options.h,v 1.51 2003/12/03 16:25:01 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -36,7 +36,7 @@ Detailed Contents:
- Options to be used for different tasks of the BLAST search
******************************************************************************
- * $Revision: 1.49 $
+ * $Revision: 1.51 $
* */
#ifndef __BLASTOPTIONS__
@@ -221,6 +221,7 @@ typedef struct BlastExtensionOptions {
double gap_trigger;/**< Score in bits for starting gapped extension */
Int4 algorithm_type; /**< E.g. for blastn: dynamic programming;
greedy without traceback; greedy with traceback */
+ Boolean skip_traceback; /**< Is traceback information needed in results? */
} BlastExtensionOptions;
typedef struct BlastExtensionParameters {
@@ -277,8 +278,6 @@ typedef struct BlastHitSavingOptions {
Boolean is_neighboring; /**< FIXME: neighboring is specified by a percent
identity and a minimum hit length */
- Boolean gapped_calculation; /**< gapping is used. */
-
/* Will be dealt with when needed *
Uint1 handle_results_method; **< Formatting results on the fly if set to
non-zero */
@@ -464,6 +463,7 @@ BlastInitialWordParametersFree(BlastInitialWordParameters* parameters);
* @param sbp Statistical (Karlin-Altschul) information [in]
* @param query_info Query information [in]
* @param eff_len_options Effective lengths options [in]
+ * @param gapped_calculation Is gapped calculation used for statistics? [in]
* @param parameters Resulting parameters [out]
*/
Int2
@@ -473,7 +473,7 @@ BlastInitialWordParametersNew(Uint1 program_number,
BlastExtensionParameters* ext_params, BlastScoreBlk* sbp,
BlastQueryInfo* query_info,
const BlastEffectiveLengthsOptions* eff_len_options,
- BlastInitialWordParameters* *parameters);
+ Boolean gapped_calculation, BlastInitialWordParameters* *parameters);
/** Deallocate memory for BlastExtensionOptions.
* @param options Structure to free [in]
diff --git a/algo/blast/core/blast_seqsrc.c b/algo/blast/core/blast_seqsrc.c
index 9b276076..942953a2 100644
--- a/algo/blast/core/blast_seqsrc.c
+++ b/algo/blast/core/blast_seqsrc.c
@@ -1,4 +1,4 @@
-/* $Id: blast_seqsrc.c,v 1.13 2003/08/25 22:27:40 dondosha Exp $
+/* $Id: blast_seqsrc.c,v 1.15 2003/12/08 22:43:50 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -30,7 +30,7 @@
*
*/
-static char const rcsid[] = "$Id: blast_seqsrc.c,v 1.13 2003/08/25 22:27:40 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_seqsrc.c,v 1.15 2003/12/08 22:43:50 dondosha Exp $";
#include <algo/blast/core/blast_seqsrc.h>
@@ -40,15 +40,26 @@ struct BlastSeqSrc {
BlastSeqSrcConstructor NewFnPtr; /**< Constructor */
BlastSeqSrcDestructor DeleteFnPtr; /**< Destructor */
+ /* Functions to get information about database as a whole */
GetInt4FnPtr GetNumSeqs; /**< Get number of sequences in set */
GetInt4FnPtr GetMaxSeqLen; /**< Get length of longest seq in set */
GetInt8FnPtr GetTotLen; /**< Get tot length of all seqs in set */
+ GetStrFnPtr GetName; /**< Get the name of the database */
+ GetStrFnPtr GetDefinition; /**< Get the database definition */
+ GetStrFnPtr GetDate; /**< Get the date of the database */
+ GetBoolFnPtr GetIsProt; /**< Find if database is a protein or
+ nucleotide */
+
+ /* Functions to get information about individual sequences */
GetSeqBlkFnPtr GetSequence; /**< Retrieve individual sequence */
- GetSeqIdFnPtr GetSeqIdStr; /**< Retrieve sequence identifier */
+ GetStrFnPtr GetSeqIdStr; /**< Retrieve sequence identifier string */
+ GetSeqIdFnPtr GetSeqId; /**< Retrieve sequence identifier */
GetInt4FnPtr GetSeqLen; /**< Retrieve given sequence length */
+
+ /* Functions to iterate over sequences in the database */
GetNextChunkFnPtr GetNextChunk; /**< Get next chunk of seq indices */
AdvanceIteratorFnPtr IterNext; /**< Gets next oid from the iterator */
-
+
void* DataStructure; /**< ADT holding the sequence data */
};
@@ -166,8 +177,15 @@ DEFINE_MEMBER_FUNCTIONS(void*, DataStructure, BlastSeqSrc*)
DEFINE_MEMBER_FUNCTIONS(GetInt4FnPtr, GetNumSeqs, BlastSeqSrc*)
DEFINE_MEMBER_FUNCTIONS(GetInt4FnPtr, GetMaxSeqLen, BlastSeqSrc*)
DEFINE_MEMBER_FUNCTIONS(GetInt8FnPtr, GetTotLen, BlastSeqSrc*)
+
+DEFINE_MEMBER_FUNCTIONS(GetStrFnPtr, GetName, BlastSeqSrc*)
+DEFINE_MEMBER_FUNCTIONS(GetStrFnPtr, GetDefinition, BlastSeqSrc*)
+DEFINE_MEMBER_FUNCTIONS(GetStrFnPtr, GetDate, BlastSeqSrc*)
+DEFINE_MEMBER_FUNCTIONS(GetBoolFnPtr, GetIsProt, BlastSeqSrc*)
+
DEFINE_MEMBER_FUNCTIONS(GetSeqBlkFnPtr, GetSequence, BlastSeqSrc*)
-DEFINE_MEMBER_FUNCTIONS(GetSeqIdFnPtr, GetSeqIdStr, BlastSeqSrc*)
+DEFINE_MEMBER_FUNCTIONS(GetStrFnPtr, GetSeqIdStr, BlastSeqSrc*)
+DEFINE_MEMBER_FUNCTIONS(GetSeqIdFnPtr, GetSeqId, BlastSeqSrc*)
DEFINE_MEMBER_FUNCTIONS(GetInt4FnPtr, GetSeqLen, BlastSeqSrc*)
DEFINE_MEMBER_FUNCTIONS(GetNextChunkFnPtr, GetNextChunk, BlastSeqSrc*)
DEFINE_MEMBER_FUNCTIONS(AdvanceIteratorFnPtr, IterNext, BlastSeqSrc*)
diff --git a/algo/blast/core/blast_seqsrc.h b/algo/blast/core/blast_seqsrc.h
index 4455eee5..c5cf24fb 100644
--- a/algo/blast/core/blast_seqsrc.h
+++ b/algo/blast/core/blast_seqsrc.h
@@ -1,4 +1,4 @@
-/* $Id: blast_seqsrc.h,v 1.9 2003/08/21 19:38:50 camacho Exp $
+/* $Id: blast_seqsrc.h,v 1.12 2003/12/15 18:20:46 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -76,10 +76,23 @@ typedef Int4 (*GetInt4FnPtr) (void*, void*);
* passed to user-defined implementation */
typedef Int8 (*GetInt8FnPtr) (void*, void*);
-/** Function pointer typedef to return a null terminated string containing a
- * sequence identifier. First argument is the BlastSeqSrc structure used, second
+/** Function pointer typedef to return a null terminated string.
+ * First argument is the BlastSeqSrc structure used, second
* argument is passed to user-defined implementation. */
-typedef char* (*GetSeqIdFnPtr) (void*, void*);
+typedef char* (*GetStrFnPtr) (void*, void*);
+
+
+/** Function pointer typedef to return a boolean value.
+ * First argument is the BlastSeqSrc structure used, second
+ * argument is passed to user-defined implementation. */
+typedef Boolean (*GetBoolFnPtr) (void*, void*);
+
+
+/** Function pointer typedef to return a sequence identifier. The returned SeqId
+ * is cast to a void pointer.
+ * First argument is the BlastSeqSrc structure used, second
+ * argument is passed to user-defined implementation. */
+typedef void* (*GetSeqIdFnPtr) (void*, void*);
/** Function pointer typedef to retrieve sequences from data structure embedded
* in the BlastSeqSrc structure.
@@ -128,6 +141,8 @@ typedef struct BlastSeqSrcIterator {
/** Size of the chunks to advance over the BlastSeqSrc, also size of
* oid_list member */
unsigned int chunk_sz;
+ /* Starting oid for the next chunk/range */
+ unsigned int next_oid;
} BlastSeqSrcIterator;
/** Allocated and initialized an iterator over a BlastSeqSrc.
@@ -199,10 +214,20 @@ BlastSeqSrc* BlastSeqSrcFree(BlastSeqSrc* bssp);
(*GetGetMaxSeqLen(bssp))(GetDataStructure(bssp), NULL)
#define BLASTSeqSrcGetTotLen(bssp) \
(*GetGetTotLen(bssp))(GetDataStructure(bssp), NULL)
+#define BLASTSeqSrcGetName(bssp) \
+ (*GetGetName(bssp))(GetDataStructure(bssp), NULL)
+#define BLASTSeqSrcGetDefinition(bssp) \
+ (*GetGetDefinition(bssp))(GetDataStructure(bssp), NULL)
+#define BLASTSeqSrcGetDate(bssp) \
+ (*GetGetDate(bssp))(GetDataStructure(bssp), NULL)
+#define BLASTSeqSrcGetIsProt(bssp) \
+ (*GetGetIsProt(bssp))(GetDataStructure(bssp), NULL)
#define BLASTSeqSrcGetSequence(bssp, arg) \
(*GetGetSequence(bssp))(GetDataStructure(bssp), arg)
#define BLASTSeqSrcGetSeqIdStr(bssp, arg) \
(*GetGetSeqIdStr(bssp))(GetDataStructure(bssp), arg)
+#define BLASTSeqSrcGetSeqId(bssp, arg) \
+ (*GetGetSeqId(bssp))(GetDataStructure(bssp), arg)
#define BLASTSeqSrcGetSeqLen(bssp, arg) \
(*GetGetSeqLen(bssp))(GetDataStructure(bssp), arg)
#define BLASTSeqSrcGetNextChunk(bssp, iterator) \
@@ -225,8 +250,13 @@ DECLARE_MEMBER_FUNCTIONS(void*, DataStructure, BlastSeqSrc*);
DECLARE_MEMBER_FUNCTIONS(GetInt4FnPtr, GetNumSeqs, BlastSeqSrc*);
DECLARE_MEMBER_FUNCTIONS(GetInt4FnPtr, GetMaxSeqLen, BlastSeqSrc*);
DECLARE_MEMBER_FUNCTIONS(GetInt8FnPtr, GetTotLen, BlastSeqSrc*);
+DECLARE_MEMBER_FUNCTIONS(GetStrFnPtr, GetName, BlastSeqSrc*);
+DECLARE_MEMBER_FUNCTIONS(GetStrFnPtr, GetDefinition, BlastSeqSrc*);
+DECLARE_MEMBER_FUNCTIONS(GetStrFnPtr, GetDate, BlastSeqSrc*);
+DECLARE_MEMBER_FUNCTIONS(GetBoolFnPtr, GetIsProt, BlastSeqSrc*);
DECLARE_MEMBER_FUNCTIONS(GetSeqBlkFnPtr, GetSequence, BlastSeqSrc*);
-DECLARE_MEMBER_FUNCTIONS(GetSeqIdFnPtr, GetSeqIdStr, BlastSeqSrc*);
+DECLARE_MEMBER_FUNCTIONS(GetStrFnPtr, GetSeqIdStr, BlastSeqSrc*);
+DECLARE_MEMBER_FUNCTIONS(GetSeqIdFnPtr, GetSeqId, BlastSeqSrc*);
DECLARE_MEMBER_FUNCTIONS(GetInt4FnPtr, GetSeqLen, BlastSeqSrc*);
DECLARE_MEMBER_FUNCTIONS(GetNextChunkFnPtr, GetNextChunk, BlastSeqSrc*);
DECLARE_MEMBER_FUNCTIONS(AdvanceIteratorFnPtr, IterNext, BlastSeqSrc*);
diff --git a/algo/blast/core/blast_setup.c b/algo/blast/core/blast_setup.c
index 6cda6a1e..3e478246 100644
--- a/algo/blast/core/blast_setup.c
+++ b/algo/blast/core/blast_setup.c
@@ -1,5 +1,5 @@
static char const rcsid[] =
- "$Id: blast_setup.c,v 1.62 2003/10/27 23:02:11 dondosha Exp $";
+ "$Id: blast_setup.c,v 1.65 2004/01/07 21:44:36 dondosha Exp $";
/* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,7 +32,7 @@ Author: Tom Madden
Contents: Utilities initialize/setup BLAST.
-$Revision: 1.62 $
+$Revision: 1.65 $
******************************************************************************/
@@ -394,7 +394,7 @@ Int2 BLAST_MainSetUp(Uint1 program_number,
const BlastHitSavingOptions * hit_options,
BLAST_SequenceBlk * query_blk,
BlastQueryInfo * query_info,
- BlastSeqLoc ** lookup_segments, BlastMask * *filter_out,
+ BlastSeqLoc ** lookup_segments, BlastMaskLoc * *filter_out,
BlastScoreBlk * *sbpp, Blast_Message * *blast_message)
{
BlastScoreBlk *sbp;
@@ -407,10 +407,10 @@ Int2 BLAST_MainSetUp(Uint1 program_number,
BlastSeqLoc *filter_slp = NULL; /* SeqLocPtr computed for filtering. */
BlastSeqLoc *filter_slp_combined; /* Used to hold combined SeqLoc's */
BlastSeqLoc *loc; /* Iterator variable */
- BlastMask *last_filter_out = NULL;
+ BlastMaskLoc *last_filter_out = NULL;
Uint1 *buffer; /* holds sequence for plus strand or protein. */
Boolean reverse; /* Indicates the strand when masking filtered locations */
- BlastMask *mask_slp, *next_mask_slp; /* Auxiliary locations for lower
+ BlastMaskLoc *mask_slp, *next_mask_slp; /* Auxiliary locations for lower
case masks */
Int4 context_offset;
Boolean no_forward_strand;
@@ -502,15 +502,20 @@ Int2 BLAST_MainSetUp(Uint1 program_number,
/* Attach the lower case mask locations to the filter locations
and combine them */
- if (filter_slp && mask_slp) {
- for (loc = filter_slp; loc->next; loc = loc->next) ;
- loc->next = mask_slp->loc_list;
+ if (mask_slp) {
+ if (filter_slp) {
+ for (loc = filter_slp; loc->next; loc = loc->next);
+ loc->next = mask_slp->loc_list;
+ } else {
+ filter_slp = mask_slp->loc_list;
+ }
/* Set location list to NULL, to allow safe memory deallocation */
mask_slp->loc_list = NULL;
}
filter_slp_combined = NULL;
- CombineMaskLocations(filter_slp, &filter_slp_combined);
+ CombineMaskLocations(filter_slp, &filter_slp_combined, 0);
+
filter_slp = BlastSeqLocFree(filter_slp);
/* NB: for translated searches filter locations are returned in
@@ -520,10 +525,10 @@ Int2 BLAST_MainSetUp(Uint1 program_number,
if (filter_slp_combined) {
if (!last_filter_out) {
last_filter_out = *filter_out =
- (BlastMask *) calloc(1, sizeof(BlastMask));
+ (BlastMaskLoc *) calloc(1, sizeof(BlastMaskLoc));
} else {
last_filter_out->next =
- (BlastMask *) calloc(1, sizeof(BlastMask));
+ (BlastMaskLoc *) calloc(1, sizeof(BlastMaskLoc));
last_filter_out = last_filter_out->next;
}
last_filter_out->index = index;
@@ -561,7 +566,7 @@ Int2 BLAST_MainSetUp(Uint1 program_number,
/* Free the filtering locations if masking done for lookup table only */
if (mask_at_hash) {
- *filter_out = BlastMaskFree(*filter_out);
+ *filter_out = BlastMaskLocFree(*filter_out);
}
/* Get "ideal" values if the calculated Karlin-Altschul params bad. */
diff --git a/algo/blast/core/blast_setup.h b/algo/blast/core/blast_setup.h
index 601de5b1..9ee94279 100644
--- a/algo/blast/core/blast_setup.h
+++ b/algo/blast/core/blast_setup.h
@@ -30,13 +30,16 @@ Author: Tom Madden
Contents: Utilities initialize/setup BLAST.
-$Revision: 1.25 $
+$Revision: 1.26 $
******************************************************************************/
/*
*
* $Log: blast_setup.h,v $
+* Revision 1.26 2003/12/03 16:31:46 dondosha
+* Renamed BlastMask to BlastMaskLoc, BlastResults to BlastHSPResults, to avoid name conflicts
+*
* Revision 1.25 2003/09/10 19:43:05 dondosha
* Changed #includes in accordance with lookup table code reorganization
*
@@ -216,7 +219,7 @@ Int2 BLAST_MainSetUp(Uint1 program_number,
const BlastHitSavingOptions* hit_options,
BLAST_SequenceBlk* query_blk,
BlastQueryInfo* query_info, BlastSeqLoc* *lookup_segments,
- BlastMask* *filter_slp_out,
+ BlastMaskLoc* *filter_slp_out,
BlastScoreBlk* *sbpp, Blast_Message* *blast_message);
#ifdef __cplusplus
diff --git a/algo/blast/core/blast_stat.c b/algo/blast/core/blast_stat.c
index 6d87f656..e338b124 100644
--- a/algo/blast/core/blast_stat.c
+++ b/algo/blast/core/blast_stat.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: blast_stat.c,v 1.39 2003/10/16 15:55:22 coulouri Exp $";
+static char const rcsid[] = "$Id: blast_stat.c,v 1.45 2003/12/05 16:03:57 camacho Exp $";
/* ===========================================================================
*
@@ -49,8 +49,26 @@ Detailed Contents:
- calculate pseuod-scores from p-values.
******************************************************************************
- * $Revision: 1.39 $
+ * $Revision: 1.45 $
* $Log: blast_stat.c,v $
+ * Revision 1.45 2003/12/05 16:03:57 camacho
+ * Remove compiler warnings
+ *
+ * Revision 1.44 2003/11/28 22:39:11 camacho
+ * + static keyword to BlastKarlinLtoH
+ *
+ * Revision 1.43 2003/11/28 15:03:48 camacho
+ * Added static keyword to BlastKarlinLtoH
+ *
+ * Revision 1.42 2003/11/26 19:12:13 madden
+ * code to simplify some routines and use NlmKarlinLambdaNR in place of BlastKarlinLambdaBis (following Mike Gertzs changes to blastkar.c )
+ *
+ * Revision 1.41 2003/11/24 23:18:32 dondosha
+ * Added gap_decay_rate argument to BLAST_Cutoffs; removed BLAST_Cutoffs_simple
+ *
+ * Revision 1.40 2003/11/19 15:17:42 dondosha
+ * Removed unused members from Karlin block structure
+ *
* Revision 1.39 2003/10/16 15:55:22 coulouri
* fix uninitialized variables
*
@@ -271,9 +289,11 @@ static Uint1 ncbieaa_to_ncbistdaa[128]={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+#if 0 /* Is this really needed ? */
static Uint1 ncbistdaa_to_ncbieaa[BLASTAA_SIZE]={
'-','A','B','C','D','E','F','G','H','I','K','L','M',
'N','P','Q','R','S','T','V','W','X','Y','Z','U','*'};
+#endif
/* Used in BlastKarlinBlkGappedCalc */
typedef double array_of_8[8];
@@ -1392,6 +1412,10 @@ typedef struct BLAST_LetterProb {
double p;
} BLAST_LetterProb;
+#if 0
+
+/* Unused for right now, but do not remove */
+
/* M. O. Dayhoff amino acid background frequencies */
static BLAST_LetterProb Dayhoff_prob[] = {
{ 'A', 87.13 },
@@ -1439,6 +1463,7 @@ static BLAST_LetterProb Altschul_prob[] = {
{ 'W', 13.00 },
{ 'Y', 32.00 }
};
+#endif
/* amino acid background frequencies from Robinson and Robinson */
static BLAST_LetterProb Robinson_prob[] = {
@@ -1817,6 +1842,7 @@ BlastScoreFreqCalc(BlastScoreBlk* sbp, BLAST_ScoreFreq* sfp, BLAST_ResFreq* rfp1
#define DIMOFP0 (iter*range + 1)
#define DIMOFP0_MAX (BLAST_KARLIN_K_ITER_MAX*BLAST_SCORE_RANGE_MAX+1)
+
static double
BlastKarlinLHtoK(BLAST_ScoreFreq* sfp, double lambda, double H)
{
@@ -1835,8 +1861,8 @@ BlastKarlinLHtoK(BLAST_ScoreFreq* sfp, double lambda, double H)
double Sum, av, oldsum, oldsum2, score_avg;
int iter;
double sumlimit;
- double* p,* ptrP,* ptr1,* ptr2,* ptr1e;
- double etolami, etolam;
+ double* p, * ptrP, * ptr1, * ptr2, * ptr1e;
+ double x;
Boolean bi_modal_score = FALSE;
if (lambda <= 0. || H <= 0.) {
@@ -1865,7 +1891,7 @@ BlastKarlinLHtoK(BLAST_ScoreFreq* sfp, double lambda, double H)
range = high - low;
av = H/lambda;
- etolam = exp((double)lambda);
+ x = exp((double) -lambda);
if (low == -1 || high == 1) {
if (high == 1)
@@ -1874,7 +1900,7 @@ BlastKarlinLHtoK(BLAST_ScoreFreq* sfp, double lambda, double H)
score_avg = sfp->score_avg / d;
K = (score_avg * score_avg) / av;
}
- return K * (1.0 - 1./etolam);
+ return K * (1.0 - x);
}
sumlimit = BLAST_KARLIN_K_SUMLIMIT_DEFAULT;
@@ -1917,11 +1943,13 @@ BlastKarlinLHtoK(BLAST_ScoreFreq* sfp, double lambda, double H)
if (ptrP - P0 <= range)
--last;
}
- etolami = BLAST_Powi((double)etolam, lo - 1);
- for (sum = 0., i = lo; i != 0; ++i) {
- etolami *= etolam;
- sum += *++ptrP * etolami;
- }
+ /* Horner's rule */
+ sum = *++ptrP;
+ for( i = lo + 1; i < 0; i++ ) {
+ sum = *++ptrP + sum * x;
+ }
+ sum *= x;
+
for (; i <= hi; ++i)
sum += *++ptrP;
oldsum2 = oldsum;
@@ -1942,157 +1970,168 @@ BlastKarlinLHtoK(BLAST_ScoreFreq* sfp, double lambda, double H)
}
}
- if (etolam > 0.05)
- {
- etolami = 1 / etolam;
- K = exp((double)-2.0*Sum) / (av*(1.0 - etolami));
+ if (x < 1.0 / 0.05 ) {
+ K = exp((double)-2.0*Sum) / (av*(1.0 - x));
+ } else {
+ K = -exp((double)-2.0*Sum) / (av*BLAST_Expm1(-(double)lambda));
}
- else
- K = -exp((double)-2.0*Sum) / (av*BLAST_Expm1(-(double)lambda));
CleanUp:
#ifndef BLAST_KARLIN_K_STACKP
if (P0 != NULL)
sfree(P0);
#endif
+
return K;
}
-/******************* Fast Lambda Calculation Subroutine ************************
- Version 1.0 May 16, 1991
- Program by: Stephen Altschul
-
- Uses Newton-Raphson method (fast) to solve for Lambda, given an initial
- guess (lambda0) obtained perhaps by the bisection method.
-*******************************************************************************/
-
-/*
- BlastKarlinLambdaBis
+/**
+ * Find positive solution to sum_{i=low}^{high} exp(i lambda) = 1.
+ *
+ * @param probs probabilities of a score occuring
+ * @param d the gcd of the possible scores. This equals 1 if the scores
+ * are not a lattice
+ * @param low the lowest possible score
+ * @param high the highest possible score
+ * @param lambda0 an initial value for lambda
+ * @param tolx the tolerance to which lambda must be computed
+ * @param itmax the maximum number of times the function may be
+ * evaluated
+ * @param maxNewton the maximum permissible number of Newton
+ * iteration. After that the computation will proceed by bisection.
+ * @param itn a pointer to an integer that will receive the actually
+ * number of iterations performed.
+ *
+ * Let phi(lambda) = sum_{i=low}^{high} exp(i lambda) - 1. Then phi(lambda)
+ * may be written
+ *
+ * phi(lamdba) = exp(u lambda) p( exp(-lambda) )
+ *
+ * where p(x) is a polynomial that has exactly two zeros, one at x = 1
+ * and one at y = exp(-lamdba). It is simpler, more numerically
+ * efficient and stable to apply Newton's method to p(x) than to
+ * phi(lambda).
+ *
+ * We define a safeguarded Newton iteration as follows. Let the
+ * initial interval of uncertainty be [0,1]. If p'(x) >= 0, we bisect
+ * the interval. Otherwise we try a Newton step. If the Newton iterate
+ * lies in the current interval of uncertainty and it reduces the
+ * value of | p(x) | by at least 10%, we accept the new
+ * point. Otherwise, we bisect the current interval of uncertainty.
+ * It is clear that this method converges to a zero of p(x). Since
+ * p'(x) > 0 in an interval containing x = 1, the method cannot
+ * converge to x = 1 and therefore converges to the only other zero,
+ * y.
+ */
- Calculate Lambda using the bisection method (slow).
-*/
-static double
-BlastKarlinLambdaBis(BLAST_ScoreFreq* sfp)
+static double
+NlmKarlinLambdaNR( double* probs, Int4 d, Int4 low, Int4 high, double lambda0, double tolx,
+ Int4 itmax, Int4 maxNewton, Int4 * itn )
{
- register double* sprob;
- double lambda, up, newval;
- Int4 i, low, high, d;
- int j;
- register double sum, x0, x1;
-
- if (sfp->score_avg >= 0.) {
- return -1.;
- }
- low = sfp->obs_min;
- high = sfp->obs_max;
- if (BlastScoreChk(low, high) != 0)
- return -1.;
+ Int4 k;
+ double x0, x, a = 0, b = 1;
+ double f = 4; /* Larger than any possible value of the poly in [0,1] */
+ Int4 isNewton = 0; /* we haven't yet taken a Newton step. */
- sprob = sfp->sprob;
-
- /* Find greatest common divisor of all scores */
- for (i = 1, d = -low; i <= high-low && d > 1; ++i) {
- if (sprob[i+low] != 0)
- d = BLAST_Gcd(d, i);
- }
+ assert( d > 0 );
- high = high / d;
- low = low / d;
-
- up = BLAST_KARLIN_LAMBDA0_DEFAULT;
- for (lambda=0.; ; ) {
- up *= 2;
- x0 = exp((double)up);
- x1 = BLAST_Powi((double)x0, low - 1);
- if (x1 > 0.) {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i*d] * (x1 *= x0);
- }
- else {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i*d] * exp(up * i);
- }
- if (sum >= 1.0)
- break;
- lambda = up;
- }
+ x0 = exp( -lambda0 );
+ x = ( 0 < x0 && x0 < 1 ) ? x0 : .5;
+
+ for( k = 0; k < itmax; k++ ) { /* all iteration indices k */
+ Int4 i;
+ double g, fold = f;
+ Int4 wasNewton = isNewton; /* If true, then the previous step was a */
+ /* Newton step */
+ isNewton = 0; /* Assume that this step is not */
+
+ /* Horner's rule for evaluating a polynomial and its derivative */
+ g = 0;
+ f = probs[low];
+ for( i = low + d; i < 0; i += d ) {
+ g = x * g + f;
+ f = f * x + probs[i];
+ }
+ g = x * g + f;
+ f = f * x + probs[0] - 1;
+ for( i = d; i <= high; i += d ) {
+ g = x * g + f;
+ f = f * x + probs[i];
+ }
+ /* End Horner's rule */
+
+ if( f > 0 ) {
+ a = x; /* move the left endpoint */
+ } else if( f < 0 ) {
+ b = x; /* move the right endpoint */
+ } else { /* f == 0 */
+ break; /* x is an exact solution */
+ }
+ if( b - a < 2 * a * ( 1 - b ) * tolx ) {
+ /* The midpoint of the interval converged */
+ x = (a + b) / 2; break;
+ }
- for (j=0; j<BLAST_KARLIN_LAMBDA_ITER_DEFAULT; ++j) {
- newval = (lambda + up) / 2.;
- x0 = exp((double)newval);
- x1 = BLAST_Powi((double)x0, low - 1);
- if (x1 > 0.) {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i*d] * (x1 *= x0);
- }
- else {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i*d] * exp(newval * i);
- }
- if (sum > 1.0)
- up = newval;
- else
- lambda = newval;
- }
- return (lambda + up) / (2. * d);
+ if( k >= maxNewton ||
+ /* If convergence of Newton's method appears to be failing; or */
+ ( wasNewton && fabs( f ) > .9 * fabs(fold) ) ||
+ /* if the previous iteration was a Newton step but didn't decrease
+ * f sufficiently; or */
+ g >= 0
+ /* if a Newton step will move us away from the desired solution */
+ ) { /* then */
+ /* bisect */
+ x = (a + b)/2;
+ } else {
+ /* try a Newton step */
+ double p = - f/g;
+ double y = x + p;
+ if( y <= a || y >= b ) { /* The proposed iterate is not in (a,b) */
+ x = (a + b)/2;
+ } else { /* The proposed iterate is in (a,b). Accept it. */
+ isNewton = 1;
+ x = y;
+ if( fabs( p ) < tolx * x * (1-x) ) break; /* Converged */
+ } /* else the proposed iterate is in (a,b) */
+ } /* else try a Newton step. */
+ } /* end for all iteration indices k */
+ *itn = k;
+ return -log(x)/d;
}
+
static double
BlastKarlinLambdaNR(BLAST_ScoreFreq* sfp)
{
Int4 low; /* Lowest score (must be negative) */
Int4 high; /* Highest score (must be positive) */
- int j;
+ Int4 itn;
Int4 i, d;
- double* sprob;
- double lambda0, sum, slope, temp, x0, x1, amt;
+ double* sprob;
+ double returnValue;
low = sfp->obs_min;
high = sfp->obs_max;
if (sfp->score_avg >= 0.) { /* Expected score must be negative */
return -1.0;
}
- if (BlastScoreChk(low, high) != 0)
- return -1.;
-
- lambda0 = BLAST_KARLIN_LAMBDA0_DEFAULT;
-
+ if (BlastScoreChk(low, high) != 0) return -1.;
+
sprob = sfp->sprob;
- /* Find greatest common divisor of all scores */
- for (i = 1, d = -low; i <= high-low && d > 1; ++i) {
- if (sprob[i+low] != 0)
- d = BLAST_Gcd(d, i);
- }
-
- high = high / d;
- low = low / d;
- /* Calculate lambda */
-
- for (j=0; j<20; ++j) { /* limit of 20 should never be close-approached */
- sum = -1.0;
- slope = 0.0;
- if (lambda0 < 0.01)
- break;
- x0 = exp((double)lambda0);
- x1 = BLAST_Powi((double)x0, low - 1);
- if (x1 == 0.)
- break;
- for (i=low; i<=high; i++) {
- sum += (temp = sprob[i*d] * (x1 *= x0));
- slope += temp * i;
- }
- lambda0 -= (amt = sum/slope);
- if (ABS(amt/lambda0) < BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT) {
- /*
- Does it appear that we may be on the verge of converging
- to the ever-present, zero-valued solution?
- */
- if (lambda0 > BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT)
- return lambda0 / d;
- break;
+ /* Find greatest common divisor of all scores */
+ for (i = 1, d = -low; i <= high-low && d > 1; ++i) {
+ if (sprob[i+low] != 0) {
+ d = BLAST_Gcd(d, i);
}
}
- return BlastKarlinLambdaBis(sfp);
+ returnValue =
+ NlmKarlinLambdaNR( sprob, d, low, high,
+ BLAST_KARLIN_LAMBDA0_DEFAULT,
+ BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT,
+ 20, 20 + BLAST_KARLIN_LAMBDA_ITER_DEFAULT, &itn );
+
+
+ return returnValue;
}
/*
@@ -2100,34 +2139,33 @@ BlastKarlinLambdaNR(BLAST_ScoreFreq* sfp)
Calculate H, the relative entropy of the p's and q's
*/
-static double
+static double
BlastKarlinLtoH(BLAST_ScoreFreq* sfp, double lambda)
{
Int4 score;
- double av, etolam, etolami;
+ double H, etonlam, sum, scale;
+
+ double *probs = sfp->sprob;
+ Int4 low = sfp->obs_min, high = sfp->obs_max;
if (lambda < 0.) {
return -1.;
}
- if (BlastScoreChk(sfp->obs_min, sfp->obs_max) != 0)
- return -1.;
-
- etolam = exp((double)lambda);
- etolami = BLAST_Powi((double)etolam, sfp->obs_min - 1);
- if (etolami > 0.)
- {
- av = 0.0;
- for (score=sfp->obs_min; score<=sfp->obs_max; score++)
- av += sfp->sprob[score] * score * (etolami *= etolam);
- }
- else
- {
- av = 0.0;
- for (score=sfp->obs_min; score<=sfp->obs_max; score++)
- av += sfp->sprob[score] * score * exp(lambda * score);
- }
-
- return lambda * av;
+ if (BlastScoreChk(low, high) != 0) return -1.;
+
+ etonlam = exp( - lambda );
+ sum = low * probs[low];
+ for( score = low + 1; score <= high; score++ ) {
+ sum = score * probs[score] + etonlam * sum;
+ }
+
+ scale = BLAST_Powi( etonlam, high );
+ if( scale > 0 ) {
+ H = lambda * sum/scale;
+ } else { /* Underflow of exp( -lambda * high ) */
+ H = lambda * exp( lambda * high + log(sum) );
+ }
+ return H;
}
/**************** Statistical Significance Parameter Subroutine ****************
@@ -2203,35 +2241,34 @@ BlastKarlinBlkCalc(BLAST_KarlinBlk* kbp, BLAST_ScoreFreq* sfp)
/* Calculate the parameter Lambda */
- kbp->Lambda_real = kbp->Lambda = BlastKarlinLambdaNR(sfp);
+ kbp->Lambda = BlastKarlinLambdaNR(sfp);
if (kbp->Lambda < 0.)
goto ErrExit;
/* Calculate H */
- kbp->H_real = kbp->H = BlastKarlinLtoH(sfp, kbp->Lambda);
+ kbp->H = BlastKarlinLtoH(sfp, kbp->Lambda);
if (kbp->H < 0.)
goto ErrExit;
/* Calculate K and log(K) */
- kbp->K_real = kbp->K = BlastKarlinLHtoK(sfp, kbp->Lambda, kbp->H);
+ kbp->K = BlastKarlinLHtoK(sfp, kbp->Lambda, kbp->H);
if (kbp->K < 0.)
goto ErrExit;
- kbp->logK_real = kbp->logK = log(kbp->K);
+ kbp->logK = log(kbp->K);
/* Normal return */
return 0;
ErrExit:
- kbp->Lambda = kbp->H = kbp->K
- = kbp->Lambda_real = kbp->H_real = kbp->K_real = -1.;
+ kbp->Lambda = kbp->H = kbp->K = -1.;
#ifdef BLASTKAR_HUGE_VAL
- kbp->logK_real = kbp->logK = BLASTKAR_HUGE_VAL;
+ kbp->logK = BLASTKAR_HUGE_VAL;
#else
- kbp->logK_real = kbp->logK = 1.e30;
+ kbp->logK = 1.e30;
#endif
return 1;
}
@@ -2741,10 +2778,10 @@ BLAST_KarlinkGapBlkFill(BLAST_KarlinBlk* kbp, Int4 gap_open, Int4 gap_extend, In
{
if (kbp)
{
- kbp->Lambda_real = kbp->Lambda = values[index][3];
- kbp->K_real = kbp->K = values[index][4];
- kbp->logK_real = kbp->logK = log(kbp->K);
- kbp->H_real = kbp->H = values[index][5];
+ kbp->Lambda = values[index][3];
+ kbp->K = values[index][4];
+ kbp->logK = log(kbp->K);
+ kbp->H = values[index][5];
}
found_values = TRUE;
break;
@@ -2867,24 +2904,6 @@ BlastGapDecay(double pvalue, unsigned nsegs, double decayrate)
return pvalue / ((1. - decayrate) * BLAST_Powi(decayrate, nsegs - 1));
}
-/*
- BlastCutoffs
-
- Calculate the cutoff score, S, and the highest expected score.
-
- WRG (later modified by TLM).
-*/
-Int2
-BLAST_Cutoffs(Int4 *S, /* cutoff score */
- double* E, /* expected no. of HSPs scoring at or above S */
- BLAST_KarlinBlk* kbp,
- double qlen, /* length of query sequence */
- double dblen, /* length of database or database sequence */
- Boolean dodecay) /* TRUE ==> use gapdecay feature */
-{
- return BLAST_Cutoffs_simple(S, E, kbp, qlen*dblen, dodecay);
-}
-
/* Smallest float that might not cause a floating point exception in
S = (Int4) (ceil( log((double)(K * searchsp / E)) / Lambda ));
below.
@@ -2913,12 +2932,18 @@ BlastKarlinEtoS_simple(double E, /* Expect value */
return S;
}
+/*
+ BlastCutoffs
+ Calculate the cutoff score, S, and the highest expected score.
+ WRG (later modified by TLM).
+*/
Int2
-BLAST_Cutoffs_simple(Int4 *S, /* cutoff score */
+BLAST_Cutoffs(Int4 *S, /* cutoff score */
double* E, /* expected no. of HSPs scoring at or above S */
BLAST_KarlinBlk* kbp,
double searchsp, /* size of search space. */
- Boolean dodecay) /* TRUE ==> use gapdecay feature */
+ Boolean dodecay, /* TRUE ==> use gapdecay feature */
+ double gap_decay_rate)
{
Int4 s = *S, es;
double e = *E, esave;
@@ -2936,7 +2961,7 @@ BLAST_Cutoffs_simple(Int4 *S, /* cutoff score */
if (e > 0.)
{
if (dodecay)
- e = BlastGapDecayInverse(e, 1, 0.5);
+ e = BlastGapDecayInverse(e, 1, gap_decay_rate);
es = BlastKarlinEtoS_simple(e, kbp, searchsp);
}
/*
@@ -2955,7 +2980,7 @@ BLAST_Cutoffs_simple(Int4 *S, /* cutoff score */
{
e = BLAST_KarlinStoE_simple(s, kbp, searchsp);
if (dodecay)
- e = BlastGapDecay(e, 1, 0.5);
+ e = BlastGapDecay(e, 1, gap_decay_rate);
*E = e;
}
diff --git a/algo/blast/core/blast_stat.h b/algo/blast/core/blast_stat.h
index bee0d836..fc0cacc7 100644
--- a/algo/blast/core/blast_stat.h
+++ b/algo/blast/core/blast_stat.h
@@ -1,4 +1,4 @@
-/* $Id: blast_stat.h,v 1.17 2003/08/11 14:57:16 dondosha Exp $
+/* $Id: blast_stat.h,v 1.19 2003/11/24 23:18:18 dondosha Exp $
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
@@ -32,7 +32,7 @@ Contents: definitions and prototypes used by blastkar.c to calculate BLAST
******************************************************************************/
-/* $Revision: 1.17 $
+/* $Revision: 1.19 $
* */
#ifndef __BLASTKAR__
#define __BLASTKAR__
@@ -105,9 +105,6 @@ typedef struct BLAST_KarlinBlk {
double Lambda; /* Lambda value used in statistics */
double K, logK; /* K value used in statistics */
double H; /* H value used in statistics */
- /* "real" values are ones actually found, may be replaced by above */
- double Lambda_real, K_real, logK_real, H_real;
- Int4 q_frame, s_frame; /* reading frame for query and subject.*/
double paramC; /* for use in seed. */
} BLAST_KarlinBlk;
@@ -273,10 +270,16 @@ char* BLAST_PrintAllowedValues(const char *matrix, Int4 gap_open, Int4 gap_exten
double BLAST_KarlinStoE_simple (Int4 S, BLAST_KarlinBlk* kbp, double searchsp);
-Int2 BLAST_Cutoffs (Int4 *S, double* E, BLAST_KarlinBlk* kbp, double qlen, double dblen, Boolean dodecay);
-
-
-Int2 BLAST_Cutoffs_simple (Int4 *S, double* E, BLAST_KarlinBlk* kbp, double search_sp, Boolean dodecay);
+/** Calculate the cutoff score from the expected number of HSPs or vice versa.
+ * @param S The calculated score [in] [out]
+ * @param E The calculated e-value [in] [out]
+ * @param kbp The Karlin-Altschul statistical parameters [in]
+ * @param searchsp The effective search space [in]
+ * @param dodecay Use gap decay feature? [in]
+ * @param gap_decay_rate Gap decay rate to use, if dodecay is set [in]
+ */
+Int2 BLAST_Cutoffs (Int4 *S, double* E, BLAST_KarlinBlk* kbp,
+ double searchsp, Boolean dodecay, double gap_decay_rate);
/* Functions to calculate SumE (for large and small gaps). */
double BLAST_SmallGapSumE (BLAST_KarlinBlk* kbp, Int4 gap, double gap_prob, double gap_decay_rate, Int2 num, double xsum, Int4 query_length, Int4 subject_length);
diff --git a/algo/blast/core/blast_toolkit.h b/algo/blast/core/blast_toolkit.h
new file mode 100644
index 00000000..0213cff5
--- /dev/null
+++ b/algo/blast/core/blast_toolkit.h
@@ -0,0 +1,7 @@
+#ifndef _BLAST_TOOLKIT__H_
+#define _BLAST_TOOLKIT__H_
+
+/* C toolkit */
+#include <ncbistd.h>
+
+#endif
diff --git a/algo/blast/core/blast_traceback.c b/algo/blast/core/blast_traceback.c
index 4ef15360..2e6d8dd9 100644
--- a/algo/blast/core/blast_traceback.c
+++ b/algo/blast/core/blast_traceback.c
@@ -1,4 +1,4 @@
-/* $Id: blast_traceback.c,v 1.58 2003/10/29 05:13:02 camacho Exp $
+/* $Id: blast_traceback.c,v 1.70 2004/01/28 22:07:13 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -41,7 +41,7 @@ Detailed Contents:
#include <algo/blast/core/blast_util.h>
#include <algo/blast/core/link_hsps.h>
-static char const rcsid[] = "$Id: blast_traceback.c,v 1.58 2003/10/29 05:13:02 camacho Exp $";
+static char const rcsid[] = "$Id: blast_traceback.c,v 1.70 2004/01/28 22:07:13 dondosha Exp $";
/** Comparison function for sorting HSPs by score.
* Ties are broken based on subject sequence offsets.
@@ -239,7 +239,6 @@ BlastHSPGetNumIdentical(Uint1* query, Uint1* subject, BlastHSP* hsp,
Boolean gapped_calculation, Int4* num_ident_ptr, Int4* align_length_ptr)
{
Int4 i, num_ident, align_length, q_off, s_off;
- Int2 context;
Uint1* q,* s;
GapEditBlock* gap_info;
GapEditScript* esp;
@@ -249,7 +248,6 @@ BlastHSPGetNumIdentical(Uint1* query, Uint1* subject, BlastHSP* hsp,
if (!gap_info && gapped_calculation)
return -1;
- context = hsp->context;
q_off = hsp->query.offset;
s_off = hsp->subject.offset;
@@ -300,26 +298,20 @@ BlastOOFGetNumIdentical(Uint1* query_seq, Uint1* subject_seq,
BlastHSP* hsp, Uint1 program,
Int4* num_ident_ptr, Int4* align_length_ptr)
{
- Int4 i, num_ident, align_length, q_off, s_off;
- Int2 context;
+ Int4 i, num_ident, align_length;
Uint1* q,* s;
GapEditScript* esp;
if (!hsp->gap_info || !subject_seq || !query_seq)
return -1;
- context = hsp->context;
if (program == blast_type_tblastn) {
- q_off = hsp->query.offset;
- s_off = hsp->subject.offset;
- q = &query_seq[q_off];
- s = &subject_seq[s_off];
+ q = &query_seq[hsp->query.offset];
+ s = &subject_seq[hsp->subject.offset];
} else {
- s_off = hsp->query.offset;
- q_off = hsp->subject.offset;
- s = &query_seq[q_off];
- q = &subject_seq[s_off];
+ s = &query_seq[hsp->query.offset];
+ q = &subject_seq[hsp->subject.offset];
}
num_ident = 0;
align_length = 0;
@@ -383,6 +375,9 @@ static void SavePatternLengthInGapAlignStruct(Int4 length,
gap_align->query_stop = length;
}
+
+#define MAX_FULL_TRANSLATION 2100
+
/** Compute gapped alignment with traceback for all HSPs from a single
* query/subject sequence pair.
* @param program_number Type of BLAST program [in]
@@ -405,10 +400,11 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
const BlastScoringOptions* score_options,
const BlastExtensionOptions* ext_options,
BlastHitSavingParameters* hit_params,
- const BlastDatabaseOptions* db_options)
+ const BlastDatabaseOptions* db_options,
+ const PSIBlastOptions* psi_options)
{
Int4 index, index1, index2;
- Boolean hsp_start_is_contained, hsp_end_is_contained, do_not_do;
+ Boolean hsp_start_is_contained, hsp_end_is_contained;
BlastHSP* hsp,* hsp1=NULL,* hsp2;
Uint1* query,* subject,* subject_start = NULL;
Int4 query_length, query_length_orig;
@@ -419,9 +415,7 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
BlastHitSavingOptions* hit_options = hit_params->options;
Int4 min_score_to_keep = hit_params->cutoff_score;
Int4 align_length;
- /** THE FOLLOWING HAS TO BE PASSED IN THE ARGUMENTS!!!!!
- DEFINED INSIDE TEMPORARILY, ONLY TO ALLOW COMPILATION */
- double scalingFactor = 1.0;
+ double scalingFactor = ((psi_options) ? psi_options->scalingFactor : 1.0);
Int4 new_hspcnt = 0;
Boolean is_ooframe = score_options->is_ooframe;
Int4 context_offset;
@@ -433,6 +427,9 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
Uint1* nucl_sequence = NULL;
BLAST_KarlinBlk** kbp;
Boolean phi_align = (hit_options->phi_align);
+ Boolean greedy_traceback;
+ Boolean partial_translation = FALSE;
+ Int4 start_shift = 0, translation_length;
if (hsp_list->hspcnt == 0) {
return 0;
@@ -443,22 +440,31 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
if (translate_subject) {
if (!db_options)
return -1;
+ partial_translation = (subject_blk->length > MAX_FULL_TRANSLATION);
+
+ /* If mixed-frame sequence is already available, then no need to translate
+ again */
+ if (is_ooframe && subject_blk->oof_sequence)
+ partial_translation = FALSE;
+
nucl_sequence = subject_blk->sequence_start;
- if (is_ooframe) {
- BLAST_GetAllTranslations(nucl_sequence, NCBI4NA_ENCODING,
- subject_blk->length, db_options->gen_code_string,
- &translation_buffer, &frame_offsets, &subject_blk->oof_sequence);
- } else {
- BLAST_GetAllTranslations(nucl_sequence, NCBI4NA_ENCODING,
- subject_blk->length, db_options->gen_code_string,
- &translation_buffer, &frame_offsets, NULL);
+ if (!partial_translation) {
+ if (is_ooframe) {
+ BLAST_GetAllTranslations(nucl_sequence, NCBI4NA_ENCODING,
+ subject_blk->length, db_options->gen_code_string,
+ &translation_buffer, &frame_offsets,
+ &subject_blk->oof_sequence);
+ } else {
+ BLAST_GetAllTranslations(nucl_sequence, NCBI4NA_ENCODING,
+ subject_blk->length, db_options->gen_code_string,
+ &translation_buffer, &frame_offsets, NULL);
+ }
}
}
if (!is_ooframe) {
if (!translate_subject) {
subject_start = subject_blk->sequence;
- subject_length = subject_blk->length;
}
} else {
/* Out-of-frame gapping: need to use a mixed-frame sequence */
@@ -467,8 +473,8 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
} else {
subject = subject_start = subject_blk->oof_sequence + CODON_LENGTH;
}
- subject_length = subject_blk->length;
}
+ subject_length = subject_blk->length;
for (index=0; index < hsp_list->hspcnt; index++) {
hsp_start_is_contained = FALSE;
@@ -526,18 +532,57 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
}
}
- if (translate_subject && !is_ooframe) {
- Int2 context = FrameToContext(hsp->subject.frame);
- subject_start = translation_buffer + frame_offsets[context] + 1;
- subject_length =
- frame_offsets[context+1] - frame_offsets[context] - 1;
- }
-
- do_not_do = FALSE;
-
- if (do_not_do == FALSE && (hsp_start_is_contained == FALSE ||
+ if ((hsp_start_is_contained == FALSE ||
hsp_end_is_contained == FALSE || hsp->score > hsp1->score)) {
- if (!is_ooframe &&
+
+ if (translate_subject && partial_translation) {
+ Int4 nucl_shift;
+ sfree(translation_buffer);
+ start_shift =
+ MAX(0, 3*hsp->subject.offset - MAX_FULL_TRANSLATION);
+ translation_length =
+ MIN(3*hsp->subject.end + MAX_FULL_TRANSLATION,
+ subject_blk->length) - start_shift;
+ if (hsp->subject.frame > 0) {
+ nucl_shift = start_shift;
+ } else {
+ nucl_shift = subject_blk->length - start_shift
+ - translation_length;
+ }
+
+ if (is_ooframe) {
+ sfree(subject_blk->oof_sequence);
+ GetPartialTranslation(nucl_sequence+nucl_shift,
+ translation_length, hsp->subject.frame,
+ db_options->gen_code_string, &translation_buffer,
+ NULL, &subject_blk->oof_sequence);
+ } else {
+ GetPartialTranslation(nucl_sequence+nucl_shift,
+ translation_length, hsp->subject.frame,
+ db_options->gen_code_string, &translation_buffer,
+ &subject_length, NULL);
+ }
+ /* Below, the start_shift will be used for the protein
+ coordinates, so need to divide it by 3 */
+ start_shift /= CODON_LENGTH;
+ hsp->subject.offset -= start_shift;
+ hsp->subject.gapped_start -= start_shift;
+ }
+
+ if (translate_subject && !is_ooframe) {
+ if (!partial_translation) {
+ Int2 context = FrameToContext(hsp->subject.frame);
+ subject_start = translation_buffer + frame_offsets[context] + 1;
+ subject_length =
+ frame_offsets[context+1] - frame_offsets[context] - 1;
+ } else {
+ subject_start = translation_buffer + 1;
+ /* Subject length is already assigned in call to
+ GetPartialTranslation. */
+ }
+ }
+
+ if (!phi_align && !is_ooframe &&
(((hsp->query.gapped_start == 0 &&
hsp->subject.gapped_start == 0) ||
!BLAST_CheckStartForGappedAlignment(hsp, query,
@@ -565,6 +610,9 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
subject = subject_start;
+ greedy_traceback = (ext_options->algorithm_type ==
+ EXTEND_GREEDY_NO_TRACEBACK);
+
/* Perform the gapped extension with traceback */
if (phi_align) {
Int4 pat_length = GetPatternLengthFromBlastHSP(hsp);
@@ -572,9 +620,13 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
PHIGappedAlignmentWithTraceback(program_number, query, subject,
gap_align, score_options, q_start, s_start, query_length,
subject_length);
+ } else if (greedy_traceback) {
+ BLAST_GreedyGappedAlignment(query, subject,
+ query_length, subject_length, gap_align,
+ score_options, q_start, s_start, FALSE, TRUE);
} else {
BLAST_GappedAlignmentWithTraceback(program_number, query, subject,
- gap_align, score_options, ext_options, q_start, s_start,
+ gap_align, score_options, q_start, s_start,
query_length, subject_length);
}
@@ -590,6 +642,11 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
hsp->gap_info = gap_align->edit_block;
gap_align->edit_block = NULL;
+
+ if (greedy_traceback) {
+ ReevaluateHSPWithAmbiguities(hsp, query, subject, hit_options,
+ score_options, query_info, sbp);
+ }
if (hsp->gap_info) {
hsp->gap_info->frame1 = hsp->query.frame;
@@ -620,6 +677,14 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
&align_length);
}
+ if (start_shift > 0) {
+ hsp->subject.offset += start_shift;
+ hsp->subject.end += start_shift;
+ hsp->subject.gapped_start += start_shift;
+ if (hsp->gap_info)
+ hsp->gap_info->start2 += start_shift;
+ }
+
if (hsp->num_ident * 100 <
align_length * hit_options->percent_identity) {
keep = FALSE;
@@ -627,7 +692,7 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
if (program_number == blast_type_blastp ||
program_number == blast_type_blastn) {
- if (hit_options->gapped_calculation &&
+ if (score_options->gapped_calculation &&
program_number != blast_type_blastn)
kbp = sbp->kbp_gap;
else
@@ -724,7 +789,7 @@ BlastHSPListGetTraceback(Uint1 program_number, BlastHSPList* hsp_list,
PHIGetEvalue(hsp_list, sbp);
} else {
BLAST_GetNonSumStatsEvalue(program_number, query_info, hsp_list,
- hit_options, sbp);
+ score_options, sbp);
}
BLAST_ReapHitlistByEvalue(hsp_list, hit_options);
@@ -775,13 +840,14 @@ static Uint1 GetTracebackEncoding(Uint1 program_number)
return encoding;
}
-Int2 BLAST_ComputeTraceback(Uint1 program_number, BlastResults* results,
+Int2 BLAST_ComputeTraceback(Uint1 program_number, BlastHSPResults* results,
BLAST_SequenceBlk* query, BlastQueryInfo* query_info,
const BlastSeqSrc* bssp, BlastGapAlignStruct* gap_align,
const BlastScoringOptions* score_options,
const BlastExtensionParameters* ext_params,
BlastHitSavingParameters* hit_params,
- const BlastDatabaseOptions* db_options)
+ const BlastDatabaseOptions* db_options,
+ const PSIBlastOptions* psi_options)
{
Int2 status = 0;
Int4 query_index, subject_index;
@@ -827,7 +893,7 @@ Int2 BLAST_ComputeTraceback(Uint1 program_number, BlastResults* results,
BlastHSPListGetTraceback(program_number, hsp_list, query,
seq_arg.seq, query_info, gap_align, sbp, score_options,
- ext_params->options, hit_params, db_options);
+ ext_params->options, hit_params, db_options, psi_options);
}
}
}
@@ -841,7 +907,7 @@ Int2 BLAST_ComputeTraceback(Uint1 program_number, BlastResults* results,
}
Int2 BLAST_TwoSequencesTraceback(Uint1 program_number,
- BlastResults* results,
+ BlastHSPResults* results,
BLAST_SequenceBlk* query, BlastQueryInfo* query_info,
BLAST_SequenceBlk* subject,
BlastGapAlignStruct* gap_align,
@@ -855,7 +921,6 @@ Int2 BLAST_TwoSequencesTraceback(Uint1 program_number,
BlastHitList* hit_list;
BlastHSPList* hsp_list;
BlastScoreBlk* sbp;
- Uint1 encoding=ERROR_ENCODING;
Boolean db_is_na;
if (!results || !query_info || !subject) {
@@ -874,8 +939,6 @@ Int2 BLAST_TwoSequencesTraceback(Uint1 program_number,
sbp = gap_align->sbp;
- encoding = GetTracebackEncoding(program_number);
-
if (db_is_na) {
/* Two sequences case: free the compressed sequence */
sfree(subject->sequence);
@@ -895,7 +958,7 @@ Int2 BLAST_TwoSequencesTraceback(Uint1 program_number,
if (!hsp_list->traceback_done) {
BlastHSPListGetTraceback(program_number, hsp_list, query, subject,
query_info, gap_align, sbp, score_options, ext_params->options,
- hit_params, db_options);
+ hit_params, db_options, NULL);
}
}
diff --git a/algo/blast/core/blast_traceback.h b/algo/blast/core/blast_traceback.h
index fecef7d7..7226e3fa 100644
--- a/algo/blast/core/blast_traceback.h
+++ b/algo/blast/core/blast_traceback.h
@@ -1,4 +1,4 @@
-/* $Id: blast_traceback.h,v 1.13 2003/10/29 05:13:38 camacho Exp $
+/* $Id: blast_traceback.h,v 1.15 2003/12/03 16:31:46 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -33,7 +33,7 @@ Contents: Functions to do gapped alignment with traceback and/or convert
results to the SeqAlign form
******************************************************************************
- * $Revision: 1.13 $
+ * $Revision: 1.15 $
* */
#ifndef __BLAST_TRACEBACK__
#define __BLAST_TRACEBACK__
@@ -57,14 +57,16 @@ extern "C" {
* @param ext_params Gapped extension parameters [in]
* @param hit_params Parameters for saving hits [in]
* @param db_options Options containing database genetic code string [in]
+ * @param psi_options Options specific to PSI BLAST [in]
*/
-Int2 BLAST_ComputeTraceback(Uint1 program_number, BlastResults* results,
+Int2 BLAST_ComputeTraceback(Uint1 program_number, BlastHSPResults* results,
BLAST_SequenceBlk* query, BlastQueryInfo* query_info,
const BlastSeqSrc* bssp, BlastGapAlignStruct* gap_align,
const BlastScoringOptions* score_options,
const BlastExtensionParameters* ext_params,
BlastHitSavingParameters* hit_params,
- const BlastDatabaseOptions* db_options);
+ const BlastDatabaseOptions* db_options,
+ const PSIBlastOptions* psi_options);
/** Given the preliminary alignment results from a two sequences search
* (possibly with multiple query sequences), redo the gapped alignment
@@ -81,7 +83,7 @@ Int2 BLAST_ComputeTraceback(Uint1 program_number, BlastResults* results,
* @param db_options Options containing database genetic code string [in]
*/
Int2 BLAST_TwoSequencesTraceback(Uint1 program_number,
- BlastResults* results, BLAST_SequenceBlk* query,
+ BlastHSPResults* results, BLAST_SequenceBlk* query,
BlastQueryInfo* query_info, BLAST_SequenceBlk* subject,
BlastGapAlignStruct* gap_align,
const BlastScoringOptions* score_options,
diff --git a/algo/blast/core/blast_util.c b/algo/blast/core/blast_util.c
index b6c8fe4b..42c43ef2 100644
--- a/algo/blast/core/blast_util.c
+++ b/algo/blast/core/blast_util.c
@@ -1,4 +1,4 @@
-/* $Id: blast_util.c,v 1.51 2003/10/21 13:02:36 camacho Exp $
+/* $Id: blast_util.c,v 1.55 2004/01/28 02:57:35 ucko Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,7 +32,7 @@ Author: Ilya Dondoshansky
Contents: Various BLAST utilities
******************************************************************************
- * $Revision: 1.51 $
+ * $Revision: 1.55 $
* */
#include <algo/blast/core/blast_def.h>
@@ -40,7 +40,7 @@ Contents: Various BLAST utilities
#include <algo/blast/core/blast_stat.h>
#include <algo/blast/core/blast_filter.h>
-static char const rcsid[] = "$Id: blast_util.c,v 1.51 2003/10/21 13:02:36 camacho Exp $";
+static char const rcsid[] = "$Id: blast_util.c,v 1.55 2004/01/28 02:57:35 ucko Exp $";
Int2
BlastSetUp_SeqBlkNew (const Uint1* buffer, Int4 length, Int2 context,
@@ -93,6 +93,7 @@ Int2 BlastSeqBlkSetSequence(BLAST_SequenceBlk* seq_blk,
seq_blk->sequence_start = (Uint1*) sequence;
seq_blk->sequence = (Uint1*) sequence + 1;
seq_blk->length = seqlen;
+ seq_blk->oof_sequence = NULL;
return 0;
}
@@ -106,6 +107,7 @@ Int2 BlastSeqBlkSetCompressedSequence(BLAST_SequenceBlk* seq_blk,
seq_blk->sequence_allocated = TRUE;
seq_blk->sequence = (Uint1*) sequence;
+ seq_blk->oof_sequence = NULL;
return 0;
}
@@ -136,12 +138,14 @@ MakeBlastSequenceBlk(ReadDBFILEPtr db, BLAST_SequenceBlk** seq_blk,
Int2 BlastSequenceBlkClean(BLAST_SequenceBlk* seq_blk)
{
if (!seq_blk)
- return 1;
+ return 1;
if (seq_blk->sequence_allocated)
- sfree(seq_blk->sequence);
+ sfree(seq_blk->sequence);
if (seq_blk->sequence_start_allocated)
- sfree(seq_blk->sequence_start);
+ sfree(seq_blk->sequence_start);
+ if (seq_blk->oof_sequence)
+ sfree(seq_blk->oof_sequence);
return 0;
}
@@ -152,7 +156,7 @@ BLAST_SequenceBlk* BlastSequenceBlkFree(BLAST_SequenceBlk* seq_blk)
return NULL;
BlastSequenceBlkClean(seq_blk);
- BlastMaskFree(seq_blk->lcase_mask);
+ BlastMaskLocFree(seq_blk->lcase_mask);
sfree(seq_blk);
return NULL;
}
@@ -894,6 +898,60 @@ Int2 BLAST_GetAllTranslations(const Uint1* nucl_seq, Uint1 encoding,
return 0;
}
+int GetPartialTranslation(const Uint1* nucl_seq,
+ Int4 nucl_length, Int2 frame, Uint1* genetic_code,
+ Uint1** translation_buffer_ptr, Int4* protein_length,
+ Uint1** mixed_seq_ptr)
+{
+ Uint1* translation_buffer;
+ Uint1* nucl_seq_rev = NULL;
+ Int4 length;
+
+ if ((*translation_buffer_ptr = translation_buffer =
+ (Uint1*) malloc(2*(nucl_length+1)+1)) == NULL)
+ return -1;
+
+ if (frame < 0) {
+ /* First produce the reverse strand of the nucleotide sequence */
+ GetReverseNuclSequence(nucl_seq, nucl_length, &nucl_seq_rev);
+ }
+
+ if (!mixed_seq_ptr) {
+ length =
+ BLAST_GetTranslation(nucl_seq, nucl_seq_rev,
+ nucl_length, frame, translation_buffer, genetic_code);
+ if (protein_length)
+ *protein_length = length;
+ } else {
+ Int4 index;
+ Int2 frame_sign = ((frame < 0) ? -1 : 1);
+ Int4 offset = 0;
+ Int4 frame_offsets[3];
+ Uint1* seq;
+
+ for (index = 1; index <= 3; ++index) {
+ length =
+ BLAST_GetTranslation(nucl_seq, nucl_seq_rev,
+ nucl_length, frame_sign*index, translation_buffer+offset,
+ genetic_code);
+ frame_offsets[index-1] = offset;
+ offset += length + 1;
+ }
+
+ *mixed_seq_ptr = (Uint1*) malloc(2*(nucl_length+1));
+
+ for (index = 0, seq = *mixed_seq_ptr; index <= nucl_length;
+ ++index, ++seq) {
+ *seq = translation_buffer[frame_offsets[index%3]+(index/3)];
+ }
+ }
+
+ sfree(nucl_seq_rev);
+
+ return 0;
+}
+
+
Int2 FrameToContext(Int2 frame)
{
if (frame > 0)
diff --git a/algo/blast/core/blast_util.h b/algo/blast/core/blast_util.h
index 5f360812..b5f8f418 100644
--- a/algo/blast/core/blast_util.h
+++ b/algo/blast/core/blast_util.h
@@ -1,4 +1,4 @@
-/* $Id: blast_util.h,v 1.34 2003/10/21 13:02:28 camacho Exp $
+/* $Id: blast_util.h,v 1.36 2004/01/28 02:57:29 ucko Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -34,7 +34,7 @@ Contents: Various auxiliary BLAST utility functions
Detailed Contents:
******************************************************************************
- * $Revision: 1.34 $
+ * $Revision: 1.36 $
* */
#ifndef __BLAST_UTIL__
#define __BLAST_UTIL__
@@ -152,6 +152,8 @@ Int4 BLAST_GetTranslation(const Uint1* query_seq,
const Uint1* query_seq_rev, Int4 nt_length, Int2 frame, Uint1* buffer,
const Uint1* genetic_code);
+
+
/** Translate a nucleotide sequence without ambiguity codes.
* This is used for the first-pass translation of the database.
* The genetic code to be used is determined by the translation_table
@@ -270,6 +272,25 @@ Int2 BLAST_GetAllTranslations(const Uint1* nucl_seq, Uint1 encoding,
Uint1** translation_buffer_ptr, Int4** frame_offsets_ptr,
Uint1** mixed_seq_ptr);
+/** Get one frame translation - needed when only parts of subject sequences
+ * are translated.
+ * @param nucl_seq Pointer to start of nucleotide sequence to be translated [in]
+ * @param nucl_length Length of nucleotide sequence to be translated [in]
+ * @param frame What frame to translate into [in]
+ * @param genetic_code What genetic code to use? [in]
+ * @param translation_buffer_ptr Pointer to buffer with translated
+ * sequence [out]
+ * @param protein_length Length of the translation buffer [out]
+ * @param mixed_seq_ptr Pointer to buffer with mixed frame sequence, in case
+ * of out-of-frame gapping; buffer filled only if argument
+ * not NULL. [out]
+ */
+int GetPartialTranslation(const Uint1* nucl_seq,
+ Int4 nucl_length, Int2 frame, Uint1* genetic_code,
+ Uint1** translation_buffer_ptr, Int4* protein_length,
+ Uint1** mixed_seq_ptr);
+
+
/** Convert translation frame into a context for the concatenated translation
* buffer.
*/
diff --git a/algo/blast/core/link_hsps.c b/algo/blast/core/link_hsps.c
index e47f2149..bce27428 100644
--- a/algo/blast/core/link_hsps.c
+++ b/algo/blast/core/link_hsps.c
@@ -1,4 +1,4 @@
-/* $Id: link_hsps.c,v 1.16 2003/10/16 15:52:08 coulouri Exp $
+/* $Id: link_hsps.c,v 1.18 2004/01/27 16:50:41 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -38,7 +38,7 @@ Detailed Contents:
#include <algo/blast/core/link_hsps.h>
#include <algo/blast/core/blast_util.h>
-static char const rcsid[] = "$Id: link_hsps.c,v 1.16 2003/10/16 15:52:08 coulouri Exp $";
+static char const rcsid[] = "$Id: link_hsps.c,v 1.18 2004/01/27 16:50:41 dondosha Exp $";
#define WINDOW_SIZE 20
static double
@@ -497,6 +497,7 @@ link_hsps(Uint1 program_number, BlastHSPList* hsp_list,
for (index=0;index<number_of_hsps;index++)
{
H=hsp_array[index];
+ H->start_of_chain = FALSE;
hp_frame_number[cur_frame]++;
H->prev= index ? hsp_array[index-1] : NULL;
@@ -1231,7 +1232,6 @@ new_link_hsps(Uint1 program_number, BlastHSPList* hsp_list,
hsp->next = score_hsp_array[index];
}
- sfree(subject_seq);
sfree(score_hsp_array);
sfree(offset_hsp_array);
sfree(end_hsp_array);
diff --git a/algo/blast/core/lookup_util.c b/algo/blast/core/lookup_util.c
index 96e65430..9facc84c 100644
--- a/algo/blast/core/lookup_util.c
+++ b/algo/blast/core/lookup_util.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: util.c,v 1.6 2003/08/11 15:02:00 dondosha Exp $";
+static char const rcsid[] = "$Id: lookup_util.c,v 1.7 2003/11/20 15:29:12 coulouri Exp $";
/*
@@ -28,7 +28,7 @@ static char const rcsid[] = "$Id: util.c,v 1.6 2003/08/11 15:02:00 dondosha Exp
*/
-#include <algo/blast/core/util.h>
+#include <algo/blast/core/lookup_util.h>
void __sfree(void **x)
{
diff --git a/algo/blast/core/lookup_util.h b/algo/blast/core/lookup_util.h
index 63cec11d..c443f681 100644
--- a/algo/blast/core/lookup_util.h
+++ b/algo/blast/core/lookup_util.h
@@ -1,4 +1,4 @@
-/* $Id: util.h,v 1.7 2003/08/11 14:57:16 dondosha Exp $
+/* $Id: lookup_util.h,v 1.7 2003/08/11 14:57:16 dondosha Exp $
* ===========================================================================
*
diff --git a/algo/blast/core/mb_lookup.c b/algo/blast/core/mb_lookup.c
index 45e20c9c..50488e9d 100644
--- a/algo/blast/core/mb_lookup.c
+++ b/algo/blast/core/mb_lookup.c
@@ -1,4 +1,4 @@
-/* $Id: mb_lookup.c,v 1.20 2003/10/20 20:41:14 dondosha Exp $
+/* $Id: mb_lookup.c,v 1.26 2004/01/05 19:23:58 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -34,14 +34,14 @@ Contents: Functions responsible for the creation of a lookup table
Detailed Contents:
******************************************************************************
- * $Revision: 1.20 $
+ * $Revision: 1.26 $
*/
#include <algo/blast/core/blast_options.h>
#include <algo/blast/core/blast_def.h>
#include <algo/blast/core/mb_lookup.h>
-static char const rcsid[] = "$Id: mb_lookup.c,v 1.20 2003/10/20 20:41:14 dondosha Exp $";
+static char const rcsid[] = "$Id: mb_lookup.c,v 1.26 2004/01/05 19:23:58 dondosha Exp $";
MBLookupTable* MBLookupTableDestruct(MBLookupTable* mb_lt)
{
@@ -103,6 +103,9 @@ static DiscTemplateType GetDiscTemplateType(Int2 weight, Uint1 length,
return TEMPL_CONTIGUOUS; /* All unsupported cases default to 0 */
}
+#define SMALL_QUERY_CUTOFF 15000
+#define LARGE_QUERY_CUTOFF 800000
+
/** Documentation in mb_lookup.h */
Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
MBLookupTable** mb_lt_ptr,
@@ -121,6 +124,7 @@ Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
Int4 pv_shift, pv_array_bts, pv_size, pv_index;
Int2 word_length, extra_length;
Int4 last_offset;
+ Int4 table_entries;
#ifdef USE_HASH_TABLE
Int4 hash_shift, hash_mask, crc, size, length;
Uint1* hash_buf;
@@ -166,8 +170,51 @@ Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
mb_lt->hashsize = 1<<size;
hash_shift = (32 - size)/2;
hash_mask = mb_lt->hashsize - 1;
+ pv_shift = 0;
+
#else
- mb_lt->hashsize = (1<<(8*width));
+
+ if (width == 2) {
+ mb_lt->hashsize = 1 << 16;
+ pv_shift = 0;
+ }
+ else {
+
+ /* determine the approximate number of hashtable entries */
+ table_entries = 0;
+ for (loc = location; loc; loc = loc->next) {
+ from = ((DoubleInt*) loc->ptr)->i1;
+ to = ((DoubleInt*) loc->ptr)->i2;
+ table_entries += (to - from);
+ }
+
+ /* To fit in the external cache of latter-day micro-
+ processors, the PV array must be compressed. pv_shift
+ below is the power of two that the array size is
+ divided by. The target PV array size is 128 kBytes.
+
+ If the query is too small or too large, the compression
+ should be higher. Small queries don't reuse the PV array,
+ and large queries saturate it. In either case, cache
+ is better used on other data. */
+
+ if (lookup_options->word_size == 11 && lookup_options->mb_template_length > 0) {
+ mb_lt->hashsize = 1 << 22;
+ if( table_entries <= SMALL_QUERY_CUTOFF ||
+ table_entries >= LARGE_QUERY_CUTOFF )
+ pv_shift = 3;
+ else
+ pv_shift = 2;
+ }
+ else {
+ mb_lt->hashsize = 1 << 24;
+ if( table_entries <= SMALL_QUERY_CUTOFF ||
+ table_entries >= LARGE_QUERY_CUTOFF )
+ pv_shift = 5;
+ else
+ pv_shift = 4;
+ }
+ }
#endif
if (lookup_options->mb_template_length > 0) {
@@ -210,14 +257,10 @@ Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
}
if (two_templates) {
- if (lookup_options->word_size >= 12) {
- if ((mb_lt->hashtable2 = (Int4*)
- calloc(mb_lt->hashsize, sizeof(Int4))) == NULL) {
- MBLookupTableDestruct(mb_lt);
- return -1;
- }
- } else {/* For weight 11 no need for extra main table */
- mb_lt->hashtable2 = mb_lt->hashtable;
+ if ((mb_lt->hashtable2 = (Int4*)
+ calloc(mb_lt->hashsize, sizeof(Int4))) == NULL) {
+ MBLookupTableDestruct(mb_lt);
+ return -1;
}
if ((mb_lt->next_pos2 = (Int4*)
calloc((query_length+1), sizeof(Int4))) == NULL) {
@@ -227,18 +270,24 @@ Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
}
for (loc = location; loc; loc = loc->next) {
+ /* We want index to be always pointing to the start of the word.
+ Since sequence pointer points to the end of the word, subtract
+ word length from the loop boundaries.
+ */
from = ((DoubleInt*) loc->ptr)->i1;
- to = ((DoubleInt*) loc->ptr)->i2;
+ to = ((DoubleInt*) loc->ptr)->i2 - word_length;
seq = query->sequence_start + from;
pos = seq + word_length;
ecode = 0;
-
- last_offset = to + 1 - extra_length;
+ /* Also add 1 to all indices, because lookup table indices count
+ from 1. */
+ from -= word_length - 2;
+ last_offset = to + 2 - extra_length;
amb_cond = TRUE;
- for (index = from + 1; index <= last_offset; index++) {
+ for (index = from; index <= last_offset; index++) {
val = *++seq;
if ((val & nuc_mask) != 0) { /* ambiguity or gap */
ecode = 0;
@@ -326,15 +375,14 @@ Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
if (two_templates) {
switch (template_type) {
case TEMPL_11_16:
- ecode2 = GET_WORD_INDEX_11_16_OPT(ecode) |
- SECOND_TEMPLATE_BIT;
+ ecode2 = GET_WORD_INDEX_11_16_OPT(ecode);
break;
case TEMPL_12_16:
ecode2 = GET_WORD_INDEX_12_16_OPT(ecode);
break;
case TEMPL_11_18:
ecode2 = (GET_WORD_INDEX_11_18_OPT(ecode)) |
- (GET_EXTRA_CODE_18_OPT(seq)) | SECOND_TEMPLATE_BIT;
+ (GET_EXTRA_CODE_18_OPT(seq));
break;
case TEMPL_12_18:
ecode2 = (GET_WORD_INDEX_12_18_OPT(ecode)) |
@@ -342,7 +390,7 @@ Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
break;
case TEMPL_11_21:
ecode2 = (GET_WORD_INDEX_11_21_OPT(ecode)) |
- (GET_EXTRA_CODE_21_OPT(seq)) | SECOND_TEMPLATE_BIT;
+ (GET_EXTRA_CODE_21_OPT(seq));
break;
case TEMPL_12_21:
ecode2 = (GET_WORD_INDEX_12_21_OPT(ecode)) |
@@ -374,16 +422,7 @@ Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
}
}
-#ifdef USE_HASH_TABLE
- /* If hash table is used instead of index table, no need for extra reduction
- of pv_array size */
- pv_shift = 0;
-#else
- /* For 12-mer based lookup table need to make presense bit array much
- smaller, so it stays in cache, even though this allows for collisions */
- pv_shift = (width < 3) ? 0 : 5;
-#endif
- mb_lt->pv_array_bts = pv_array_bts = PV_ARRAY_BTS + pv_shift;
+ mb_lt->pv_array_bts = pv_array_bts = PV_ARRAY_BTS + pv_shift;
#ifdef QUESTION_PV_ARRAY_USE
if (mb_lt->num_unique_pos_added <
@@ -443,7 +482,6 @@ Int2 MB_LookupTableNew(BLAST_SequenceBlk* query, ListNode* location,
mb_lt->longest_chain = longest_chain;
-
*mb_lt_ptr = mb_lt;
return 0;
@@ -500,6 +538,10 @@ Int4 MB_AG_ScanSubject(const LookupTableWrap* lookup_wrap,
Boolean full_byte_scan = mb_lt->full_byte_scan;
Uint1 pv_array_bts = mb_lt->pv_array_bts;
+ /* Since the test for number of hits here is done after adding them,
+ subtract the longest chain length from the allowed offset array size. */
+ max_hits -= mb_lt->longest_chain;
+
abs_start = subject->sequence;
s = abs_start + start_offset/COMPRESSION_RATIO;
compressed_scan_step = mb_lt->scan_step / COMPRESSION_RATIO;
@@ -518,15 +560,14 @@ Int4 MB_AG_ScanSubject(const LookupTableWrap* lookup_wrap,
if (NA_PV_TEST(pv_array, index, pv_array_bts)) {
q_off = mb_lt->hashtable[index];
- s_off =
- ((s - abs_start) + compressed_wordsize)*COMPRESSION_RATIO;
+ s_off = (s - abs_start)*COMPRESSION_RATIO;
+ if (q_off && (total_hits >= max_hits))
+ break;
while (q_off) {
- q_offsets[total_hits] = q_off;
+ q_offsets[total_hits] = q_off - 1;
s_offsets[total_hits++] = s_off;
q_off = mb_lt->next_pos[q_off];
}
- if (total_hits >= max_hits)
- break;
}
}
*end_offset = (s - abs_start)*COMPRESSION_RATIO;
@@ -544,16 +585,15 @@ Int4 MB_AG_ScanSubject(const LookupTableWrap* lookup_wrap,
/* Adjust the word index by the base within a byte */
adjusted_index = BlastNaLookupAdjustIndex(s, index, mb_lt->mask,
bit);
-
if (NA_PV_TEST(pv_array, adjusted_index, pv_array_bts)) {
q_off = mb_lt->hashtable[adjusted_index];
+ if (q_off && (total_hits >= max_hits))
+ break;
while (q_off) {
- q_offsets[total_hits] = q_off;
- s_offsets[total_hits++] = s_off + word_size;
+ q_offsets[total_hits] = q_off - 1;
+ s_offsets[total_hits++] = s_off;
q_off = mb_lt->next_pos[q_off];
}
- if (total_hits >= max_hits)
- break;
}
}
*end_offset = s_off;
@@ -568,33 +608,30 @@ Int4 MB_AG_ScanSubject(const LookupTableWrap* lookup_wrap,
* the word (needed when word template is longer than 16 bases) [in]
* @param word A piece of the sequence packed into an integer [in]
* @param template_type What type of discontiguous word template to use [in]
- * @param second_template_bit When index has fewer bits than the lookup table
- * width, the indices for the second template are distinguished from
- * those for the first template by setting a special bit. [in]
* @return The lookup table index of the discontiguous word [out]
*/
static NCBI_INLINE Int4 ComputeDiscontiguousIndex(Uint1* subject, Int4 word,
- Uint1 template_type, Int4 second_template_bit)
+ Uint1 template_type)
{
Int4 index;
Int4 extra_code;
switch (template_type) {
case TEMPL_11_16:
- index = GET_WORD_INDEX_11_16(word) | second_template_bit;
+ index = GET_WORD_INDEX_11_16(word);
break;
case TEMPL_12_16:
index = GET_WORD_INDEX_12_16(word);
break;
case TEMPL_11_16_OPT:
- index = GET_WORD_INDEX_11_16_OPT(word) | second_template_bit;
+ index = GET_WORD_INDEX_11_16_OPT(word);
break;
case TEMPL_12_16_OPT:
index = GET_WORD_INDEX_12_16_OPT(word);
break;
case TEMPL_11_18:
extra_code = (Int4) GET_EXTRA_CODE_PACKED_4_18(subject);
- index = (GET_WORD_INDEX_11_18(word) | extra_code) | second_template_bit;
+ index = (GET_WORD_INDEX_11_18(word) | extra_code);
break;
case TEMPL_12_18:
extra_code = (Int4) GET_EXTRA_CODE_PACKED_4_18(subject);
@@ -602,8 +639,7 @@ static NCBI_INLINE Int4 ComputeDiscontiguousIndex(Uint1* subject, Int4 word,
break;
case TEMPL_11_18_OPT:
extra_code = (Int4) GET_EXTRA_CODE_PACKED_4_18_OPT(subject);
- index = (GET_WORD_INDEX_11_18_OPT(word) | extra_code) |
- second_template_bit;
+ index = (GET_WORD_INDEX_11_18_OPT(word) | extra_code);
break;
case TEMPL_12_18_OPT:
extra_code = (Int4) GET_EXTRA_CODE_PACKED_4_18_OPT(subject);
@@ -611,8 +647,7 @@ static NCBI_INLINE Int4 ComputeDiscontiguousIndex(Uint1* subject, Int4 word,
break;
case TEMPL_11_21:
extra_code = (Int4) GET_EXTRA_CODE_PACKED_4_21(subject);
- index = (GET_WORD_INDEX_11_21(word) | extra_code) |
- second_template_bit;
+ index = (GET_WORD_INDEX_11_21(word) | extra_code);
break;
case TEMPL_12_21:
extra_code = (Int4) GET_EXTRA_CODE_PACKED_4_21(subject);
@@ -620,8 +655,7 @@ static NCBI_INLINE Int4 ComputeDiscontiguousIndex(Uint1* subject, Int4 word,
break;
case TEMPL_11_21_OPT:
extra_code = (Int4) GET_EXTRA_CODE_PACKED_4_21_OPT(subject);
- index = (GET_WORD_INDEX_11_21_OPT(word) | extra_code) |
- second_template_bit;
+ index = (GET_WORD_INDEX_11_21_OPT(word) | extra_code);
break;
case TEMPL_12_21_OPT:
extra_code = (Int4) GET_EXTRA_CODE_PACKED_4_21_OPT(subject);
@@ -650,13 +684,10 @@ static NCBI_INLINE Int4 ComputeDiscontiguousIndex(Uint1* subject, Int4 word,
* a compressed sequence byte [in]
* @param template_type What discontiguous word template to use for index
* computation [in]
- * @param second_template_bit Bit to set if this index is for a second
- * template [in]
* @return The lookup index for the discontiguous word.
*/
static NCBI_INLINE Int4 ComputeDiscontiguousIndex_1b(const Uint1* word_start,
- Int4 word, Uint1 sequence_bit, Uint1 template_type,
- Int4 second_template_bit)
+ Int4 word, Uint1 sequence_bit, Uint1 template_type)
{
Int4 index;
Uint1* subject = (Uint1 *) word_start;
@@ -672,21 +703,20 @@ static NCBI_INLINE Int4 ComputeDiscontiguousIndex_1b(const Uint1* word_start,
switch (template_type) {
case TEMPL_11_16:
- index = GET_WORD_INDEX_11_16(word) | second_template_bit;
+ index = GET_WORD_INDEX_11_16(word);
break;
case TEMPL_12_16:
index = GET_WORD_INDEX_12_16(word);
break;
case TEMPL_11_16_OPT:
- index = GET_WORD_INDEX_11_16_OPT(word) | second_template_bit;
+ index = GET_WORD_INDEX_11_16_OPT(word);
break;
case TEMPL_12_16_OPT:
index = GET_WORD_INDEX_12_16_OPT(word);
break;
case TEMPL_11_18:
GET_EXTRA_CODE_PACKED_18(subject, bit, tmpval, extra_code);
- index = (GET_WORD_INDEX_11_18(word) | extra_code) |
- second_template_bit;
+ index = (GET_WORD_INDEX_11_18(word) | extra_code);
break;
case TEMPL_12_18:
GET_EXTRA_CODE_PACKED_18(subject, bit, tmpval, extra_code);
@@ -694,8 +724,7 @@ static NCBI_INLINE Int4 ComputeDiscontiguousIndex_1b(const Uint1* word_start,
break;
case TEMPL_11_18_OPT:
GET_EXTRA_CODE_PACKED_18_OPT(subject, bit, tmpval, extra_code);
- index = (GET_WORD_INDEX_11_18_OPT(word) | extra_code) |
- second_template_bit;
+ index = (GET_WORD_INDEX_11_18_OPT(word) | extra_code);
break;
case TEMPL_12_18_OPT:
GET_EXTRA_CODE_PACKED_18_OPT(subject, bit, tmpval, extra_code);
@@ -703,8 +732,7 @@ static NCBI_INLINE Int4 ComputeDiscontiguousIndex_1b(const Uint1* word_start,
break;
case TEMPL_11_21:
GET_EXTRA_CODE_PACKED_21(subject, bit, tmpval, extra_code);
- index = (GET_WORD_INDEX_11_21(word) | extra_code) |
- second_template_bit;
+ index = (GET_WORD_INDEX_11_21(word) | extra_code);
break;
case TEMPL_12_21:
GET_EXTRA_CODE_PACKED_21(subject, bit, tmpval, extra_code);
@@ -712,8 +740,7 @@ static NCBI_INLINE Int4 ComputeDiscontiguousIndex_1b(const Uint1* word_start,
break;
case TEMPL_11_21_OPT:
GET_EXTRA_CODE_PACKED_21_OPT(subject, bit, tmpval, extra_code);
- index = (GET_WORD_INDEX_11_21_OPT(word) | extra_code) |
- second_template_bit;
+ index = (GET_WORD_INDEX_11_21_OPT(word) | extra_code);
break;
case TEMPL_12_21_OPT:
GET_EXTRA_CODE_PACKED_21_OPT(subject, bit, tmpval, extra_code);
@@ -747,33 +774,42 @@ Int4 MB_ScanSubject(const LookupTableWrap* lookup,
Uint4* q_ptr = q_offsets,* s_ptr = s_offsets;
PV_ARRAY_TYPE *pv_array = mb_lt->pv_array;
Uint1 pv_array_bts = mb_lt->pv_array_bts;
+ Int4 compressed_wordsize = mb_lt->compressed_wordsize;
#ifdef DEBUG_LOG
FILE *logfp0 = fopen("new0.log", "a");
#endif
+ /* Since the test for number of hits here is done after adding them,
+ subtract the longest chain length from the allowed offset array size.
+ */
+ max_hits -= mb_lt->longest_chain;
+
abs_start = subject->sequence;
s = abs_start + start_offset/COMPRESSION_RATIO;
s_end = abs_start + (*end_offset)/COMPRESSION_RATIO;
s = BlastNaLookupInitIndex(mb_lt->compressed_wordsize, s, &index);
+ /* In the following code, s points to the byte right after the end of
+ the word. */
while (s <= s_end) {
if (NA_PV_TEST(pv_array, index, pv_array_bts)) {
query_offset = mb_lt->hashtable[index];
- subject_offset = (s - abs_start)*COMPRESSION_RATIO;
+ subject_offset =
+ ((s - abs_start) - compressed_wordsize)*COMPRESSION_RATIO;
+ if (query_offset && (hitsfound >= max_hits))
+ break;
while (query_offset) {
#ifdef DEBUG_LOG
fprintf(logfp0, "%ld\t%ld\t%ld\n", query_offset,
subject_offset, index);
#endif
- *(q_ptr++) = query_offset;
+ *(q_ptr++) = query_offset - 1;
*(s_ptr++) = subject_offset;
++hitsfound;
query_offset = mb_lt->next_pos[query_offset];
}
- if (hitsfound >= max_hits)
- break;
}
/* Compute the next value of the lookup index
(shifting sequence by a full byte) */
@@ -782,7 +818,7 @@ Int4 MB_ScanSubject(const LookupTableWrap* lookup,
}
*end_offset =
- ((s - abs_start) - mb_lt->compressed_wordsize)*COMPRESSION_RATIO;
+ ((s - abs_start) - compressed_wordsize)*COMPRESSION_RATIO;
#ifdef DEBUG_LOG
fclose(logfp0);
#endif
@@ -808,11 +844,16 @@ Int4 MB_DiscWordScanSubject(const LookupTableWrap* lookup,
Uint1 second_template_type = mb_lt->second_template_type;
PV_ARRAY_TYPE *pv_array = mb_lt->pv_array;
Uint1 pv_array_bts = mb_lt->pv_array_bts;
+ Int4 compressed_wordsize = mb_lt->compressed_wordsize;
#ifdef DEBUG_LOG
FILE *logfp0 = fopen("new0.log", "a");
#endif
+ /* Since the test for number of hits here is done after adding them,
+ subtract the longest chain length from the allowed offset array size. */
+ max_hits -= mb_lt->longest_chain;
+
abs_start = subject->sequence;
s_start = abs_start + start_offset/COMPRESSION_RATIO;
s_end = abs_start + (*end_offset)/COMPRESSION_RATIO;
@@ -823,33 +864,36 @@ Int4 MB_DiscWordScanSubject(const LookupTableWrap* lookup,
if (full_byte_scan) {
while (s <= s_end) {
- index = ComputeDiscontiguousIndex(s, word, template_type, 0);
+ index = ComputeDiscontiguousIndex(s, word, template_type);
if (two_templates) {
- index2 = ComputeDiscontiguousIndex(s, word, second_template_type,
- SECOND_TEMPLATE_BIT);
+ index2 = ComputeDiscontiguousIndex(s, word, second_template_type);
}
if (NA_PV_TEST(pv_array, index, pv_array_bts)) {
query_offset = mb_lt->hashtable[index];
- subject_offset = (s - abs_start)*COMPRESSION_RATIO;
+ subject_offset =
+ ((s - abs_start) - compressed_wordsize)*COMPRESSION_RATIO;
+ if (query_offset && (hitsfound >= max_hits))
+ break;
while (query_offset) {
#ifdef DEBUG_LOG
fprintf(logfp0, "%ld\t%ld\t%ld\n", query_offset,
subject_offset, index);
#endif
- *(q_ptr++) = query_offset;
+ *(q_ptr++) = query_offset - 1;
*(s_ptr++) = subject_offset;
++hitsfound;
query_offset = mb_lt->next_pos[query_offset];
}
- if (hitsfound >= max_hits)
- break;
}
if (two_templates && NA_PV_TEST(pv_array, index2, pv_array_bts)) {
query_offset = mb_lt->hashtable2[index2];
- subject_offset = (s - abs_start)*COMPRESSION_RATIO;
+ subject_offset =
+ ((s - abs_start) - compressed_wordsize)*COMPRESSION_RATIO;
+ if (query_offset && (hitsfound >= max_hits))
+ break;
while (query_offset) {
- q_offsets[hitsfound] = query_offset;
+ q_offsets[hitsfound] = query_offset - 1;
s_offsets[hitsfound++] = subject_offset;
query_offset = mb_lt->next_pos2[query_offset];
}
@@ -868,33 +912,39 @@ Int4 MB_DiscWordScanSubject(const LookupTableWrap* lookup,
bit);
index = ComputeDiscontiguousIndex_1b(s, adjusted_word, bit,
- template_type, 0);
+ template_type);
if (two_templates)
index2 = ComputeDiscontiguousIndex_1b(s, adjusted_word, bit,
- second_template_type, SECOND_TEMPLATE_BIT);
+ second_template_type);
if (NA_PV_TEST(pv_array, index, pv_array_bts)) {
query_offset = mb_lt->hashtable[index];
- subject_offset = (s - abs_start)*COMPRESSION_RATIO + bit/2;
+ subject_offset =
+ ((s - abs_start) - compressed_wordsize)*COMPRESSION_RATIO
+ + bit/2;
+ if (query_offset && (hitsfound >= max_hits))
+ break;
while (query_offset) {
#ifdef DEBUG_LOG
fprintf(logfp0, "%ld\t%ld\t%ld\n", query_offset,
subject_offset, index);
#endif
- *(q_ptr++) = query_offset;
+ *(q_ptr++) = query_offset - 1;
*(s_ptr++) = subject_offset;
++hitsfound;
query_offset = mb_lt->next_pos[query_offset];
}
- if (hitsfound >= max_hits)
- break;
}
if (two_templates && NA_PV_TEST(pv_array, index2, pv_array_bts)) {
query_offset = mb_lt->hashtable2[index2];
- subject_offset = (s - abs_start)*COMPRESSION_RATIO + bit/2;
+ subject_offset =
+ ((s - abs_start) - compressed_wordsize)*COMPRESSION_RATIO
+ + bit/2;
+ if (query_offset && (hitsfound >= max_hits))
+ break;
while (query_offset) {
- q_offsets[hitsfound] = query_offset;
+ q_offsets[hitsfound] = query_offset - 1;
s_offsets[hitsfound++] = subject_offset;
query_offset = mb_lt->next_pos2[query_offset];
}
@@ -909,7 +959,7 @@ Int4 MB_DiscWordScanSubject(const LookupTableWrap* lookup,
}
}
*end_offset =
- ((s - abs_start) - mb_lt->compressed_wordsize)*COMPRESSION_RATIO;
+ ((s - abs_start) - compressed_wordsize)*COMPRESSION_RATIO;
#ifdef DEBUG_LOG
fclose(logfp0);
#endif
diff --git a/algo/blast/core/ncbi_math.c b/algo/blast/core/ncbi_math.c
index d5a62a80..a0c05a02 100644
--- a/algo/blast/core/ncbi_math.c
+++ b/algo/blast/core/ncbi_math.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 10/23/91
*
-* $Revision: 1.6 $
+* $Revision: 1.7 $
*
* File Description:
* portable math functions
@@ -42,6 +42,9 @@
* 12-22-93 Schuler Converted ERRPOST((...)) to ErrPostEx(...)
*
* $Log: ncbi_math.c,v $
+* Revision 1.7 2003/12/05 16:03:57 camacho
+* Remove compiler warnings
+*
* Revision 1.6 2003/09/26 20:39:32 dondosha
* Rearranged code so it compiles
*
@@ -110,8 +113,10 @@
#include <algo/blast/core/ncbi_math.h>
+#if 0
extern char * g_corelib;
static char * _this_file = __FILE__;
+#endif
/*
diff --git a/algo/blast/core/ncbi_std.c b/algo/blast/core/ncbi_std.c
index 52562500..7935e05a 100644
--- a/algo/blast/core/ncbi_std.c
+++ b/algo/blast/core/ncbi_std.c
@@ -1,7 +1,7 @@
#include <algo/blast/core/blast_def.h> /* for sfree() macro */
#include <algo/blast/core/ncbi_std.h>
-void * MemDup (const void *orig, size_t size)
+void * BlastMemDup (const void *orig, size_t size)
{
void* copy;
diff --git a/algo/blast/core/ncbi_std.h b/algo/blast/core/ncbi_std.h
index e95105d9..0f272a8d 100644
--- a/algo/blast/core/ncbi_std.h
+++ b/algo/blast/core/ncbi_std.h
@@ -1,4 +1,4 @@
-/* $Id: ncbi_std.h,v 1.19 2003/09/11 16:58:42 dondosha Exp $
+/* $Id: ncbi_std.h,v 1.23 2003/12/09 18:51:40 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -35,7 +35,7 @@ Contents: Type and macro definitions from C toolkit that are not defined in
Detailed Contents:
******************************************************************************
- * $Revision: 1.19 $
+ * $Revision: 1.23 $
* */
#ifndef __NCBI_STD__
#define __NCBI_STD__
@@ -44,19 +44,12 @@ Detailed Contents:
#include <stdlib.h>
#include <string.h>
-#ifndef _MSC_VER
-#include <strings.h>
-#endif
-
#include <math.h>
#include <ctype.h>
#include <assert.h>
-#ifndef NCBI_C_TOOLKIT
-#include <corelib/ncbitype.h>
-#else
-#include <ncbistd.h>
-#endif
+/* which toolkit are we using? */
+#include "blast_toolkit.h"
#include <algo/blast/core/ncbi_math.h>
@@ -88,7 +81,7 @@ extern "C" {
#define strdup _strdup
#endif
-#ifndef NCBI_C_TOOLKIT
+#ifndef _NCBISTD_ /* if we're not in the C toolkit... */
typedef Uint1 Boolean;
#ifndef TRUE
#define TRUE 1
@@ -120,7 +113,7 @@ typedef Uint1 Boolean;
/* low-level ANSI-style functions */
-#ifndef NCBI_C_TOOLKIT
+#ifndef _NCBISTD_ /* if we're not in the C toolkit ... */
#define UINT4_MAX 4294967295U
#define INT4_MAX 2147483647
#define INT4_MIN (-2147483647-1)
@@ -142,9 +135,9 @@ typedef Uint1 Boolean;
#else
-#endif /* NCBI_C_TOOLKIT */
+#endif /* _NCBISTD_ */
-extern void* MemDup (const void *orig, size_t size);
+extern void* BlastMemDup (const void *orig, size_t size);
/******************************************************************************/
diff --git a/algo/blast/core/pattern.c b/algo/blast/core/pattern.c
index f1dd2f0a..b569520b 100644
--- a/algo/blast/core/pattern.c
+++ b/algo/blast/core/pattern.c
@@ -1,4 +1,4 @@
-/* $Id: pattern.c,v 1.6 2003/10/16 15:52:08 coulouri Exp $
+/* $Id: pattern.c,v 1.8 2003/12/04 16:27:13 camacho Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,13 +32,13 @@ Author: Ilya Dondoshansky
Contents: Functions for finding pattern matches in sequence.
******************************************************************************
- * $Revision: 1.6 $
+ * $Revision: 1.8 $
* */
#include <algo/blast/core/blast_def.h>
#include <algo/blast/core/pattern.h>
-static char const rcsid[] = "$Id: pattern.c,v 1.6 2003/10/16 15:52:08 coulouri Exp $";
+static char const rcsid[] = "$Id: pattern.c,v 1.8 2003/12/04 16:27:13 camacho Exp $";
/*Looks for 1 bits in the same position of s and mask
Let rightOne be the rightmost position where s and mask both have
@@ -147,7 +147,8 @@ static Int4 find_hitsS_DNA(Int4* hitArray, const Uint1* seq, Int4 pos, Int4 len,
remain = len % 4;
}
for (i = 0; i < end; i++) {
- if (tmp = (prefixMatchedBitPattern & patternSearch->DNAwhichPrefixPosPtr[seq[i]])) {
+ if ( (tmp = (prefixMatchedBitPattern &
+ patternSearch->DNAwhichPrefixPosPtr[seq[i]]))) {
for (j = 0; j < 4; j++) {
if (tmp & patternSearch->match_mask) {
hitArray[twiceNumHits++] = i*4+j + pos;
@@ -160,7 +161,8 @@ static Int4 find_hitsS_DNA(Int4* hitArray, const Uint1* seq, Int4 pos, Int4 len,
prefixMatchedBitPattern = (((prefixMatchedBitPattern << 4) | mask2) & patternSearch->DNAwhichSuffixPosPtr[seq[i]]);
}
/* In the last byte check bits only up to 'remain' */
- if (tmp = (prefixMatchedBitPattern & patternSearch->DNAwhichPrefixPosPtr[seq[i]])) {
+ if ( (tmp = (prefixMatchedBitPattern &
+ patternSearch->DNAwhichPrefixPosPtr[seq[i]]))) {
for (j = 0; j < remain; j++) {
if (tmp & patternSearch->match_mask) {
hitArray[twiceNumHits++] = i*4+j + pos;
@@ -223,7 +225,7 @@ static Int4 and(Int4 *result, Int4 *a, Int4 *b, patternSearchItems *patternSearc
Int4 returnValue = 0;
for (i = 0; i < patternSearch->numWords; i++)
- if (result[i] = (a[i] & b[i]))
+ if ( (result[i] = (a[i] & b[i]) ) )
returnValue = 1;
return returnValue;
}
@@ -386,7 +388,7 @@ static Int4 find_hitsLL(Int4 *hitArray, const Uint1* seq, Int4 len, Boolean is_d
return twiceNumHits;
}
-Int4 find_hits(Int4 *hitArray, const Uint1* seq, Int4 len,
+Int4 FindPatternHits(Int4 *hitArray, const Uint1* seq, Int4 len,
Boolean is_dna, patternSearchItems * patternSearch)
{
if (patternSearch->flagPatternLength == ONE_WORD_PATTERN)
diff --git a/algo/blast/core/pattern.h b/algo/blast/core/pattern.h
index dcdf12c3..48b23448 100644
--- a/algo/blast/core/pattern.h
+++ b/algo/blast/core/pattern.h
@@ -1,4 +1,4 @@
-/* $Id: pattern.h,v 1.1 2003/09/09 22:03:54 dondosha Exp $
+/* $Id: pattern.h,v 1.2 2003/12/03 16:22:55 dondosha Exp $
* ===========================================================================
*
@@ -34,7 +34,7 @@ Contents: Functions for finding pattern matches in sequence.
Detailed Contents:
******************************************************************************
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* */
#include <algo/blast/core/blast_def.h>
@@ -130,7 +130,7 @@ typedef struct seedSearchItems {
* @param patternSearch Pattern information [in]
* @return Twice the number of hits (length of hitArray filled in)
*/
-Int4 find_hits(Int4 *hitArray, const Uint1* seq, Int4 len,
+Int4 FindPatternHits(Int4 *hitArray, const Uint1* seq, Int4 len,
Boolean is_dna, patternSearchItems * patternSearch);
#ifdef __cplusplus
diff --git a/algo/blast/core/phi_lookup.c b/algo/blast/core/phi_lookup.c
index 48e6d21e..37251294 100644
--- a/algo/blast/core/phi_lookup.c
+++ b/algo/blast/core/phi_lookup.c
@@ -1,4 +1,4 @@
-/* $Id: phi_lookup.c,v 1.6 2003/10/16 15:52:08 coulouri Exp $
+/* $Id: phi_lookup.c,v 1.7 2003/12/03 16:23:08 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,7 +32,7 @@ Author: Ilya Dondoshansky
Contents: Functions for accessing the lookup table for PHI-BLAST
******************************************************************************
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
* */
#include <algo/blast/core/blast_def.h>
@@ -41,7 +41,7 @@ Contents: Functions for accessing the lookup table for PHI-BLAST
#include <algo/blast/core/phi_lookup.h>
#include <algo/blast/core/blast_message.h>
-static char const rcsid[] = "$Id: phi_lookup.c,v 1.6 2003/10/16 15:52:08 coulouri Exp $";
+static char const rcsid[] = "$Id: phi_lookup.c,v 1.7 2003/12/03 16:23:08 dondosha Exp $";
#define seedepsilon 0.00001
#define allone ((1 << ALPHABET_SIZE) - 1)
@@ -689,8 +689,8 @@ Int4 PHIBlastIndexQuery(PHILookupTable* lookup,
offset = 0;
sequence = query->sequence + from;
- twiceNumHits = find_hits(hitArray, sequence, loc_length, is_dna,
- pattern_info);
+ twiceNumHits = FindPatternHits(hitArray, sequence, loc_length, is_dna,
+ pattern_info);
for (i = 0; i < twiceNumHits; i += 2) {
PHIBlastAddPatternHit(lookup, hitArray[i+1]+from,
@@ -734,8 +734,8 @@ Int4 PHIBlastScanSubject(const LookupTableWrap* lookup_wrap,
*/
*offset_ptr = subject_blk->length;
- twiceNumHits = find_hits(hitArray, subject, subject_blk->length,
- lookup->is_dna, lookup->pattern_info);
+ twiceNumHits = FindPatternHits(hitArray, subject, subject_blk->length,
+ lookup->is_dna, lookup->pattern_info);
for (i = 0; i < twiceNumHits; i += 2) {
diff --git a/api/alignval.c b/api/alignval.c
index bf3a64b7..cd926db3 100644
--- a/api/alignval.c
+++ b/api/alignval.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 6/3/99
*
-* $Revision: 6.37 $
+* $Revision: 6.38 $
*
* File Description: To validate sequence alignment.
*
@@ -67,6 +67,7 @@ typedef struct saval {
Boolean delete_salp;
Boolean delete_bsp;
Boolean retdel;
+ Boolean do_hist_assembly;
ValNodePtr ids;
Uint2 entityID;
Boolean dirty;
@@ -1840,6 +1841,7 @@ NLM_EXTERN Boolean ValidateSeqAlign (SeqAlignPtr salp, Uint2 entityID, Boolean m
sv.delete_salp = delete_salp;
sv.delete_bsp = delete_bsp;
sv.retdel = TRUE;
+ sv.do_hist_assembly = FALSE;
sv.ids = NULL;
sv.entityID = entityID;
sv.dirty = FALSE;
@@ -1963,7 +1965,7 @@ NLM_EXTERN Int2 LIBCALLBACK ValidateSeqAlignFromData (Pointer data)
ValidateSeqAlign (salp, 0, TRUE, TRUE, TRUE, FALSE, FALSE, NULL);
}
if (sep!=NULL) {
- ValidateSeqAlignInSeqEntry (sep, TRUE, TRUE, TRUE, TRUE, FALSE);
+ ValidateSeqAlignInSeqEntry (sep, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE);
}
return OM_MSG_RET_DONE;
}
@@ -2008,7 +2010,9 @@ static void ValidateSeqAlignCallback (SeqEntryPtr sep, Pointer mydata,
bsp = (BioseqPtr) sep->data.ptrvalue;
if (bsp!=NULL) {
ValidateSeqAlignInAnnot (bsp->annot, svp);
- ValidateSeqAlignInHist (bsp->hist, svp);
+ if (svp != NULL && svp->do_hist_assembly) {
+ ValidateSeqAlignInHist (bsp->hist, svp);
+ }
}
}
else if(IS_Bioseq_set(sep)) {
@@ -2024,7 +2028,8 @@ static void ValidateSeqAlignCallback (SeqEntryPtr sep, Pointer mydata,
NLM_EXTERN Boolean ValidateSeqAlignInSeqEntry (SeqEntryPtr sep, Boolean message,
Boolean msg_success, Boolean find_remote_bsp,
- Boolean delete_bsp, Boolean delete_salp)
+ Boolean delete_bsp, Boolean delete_salp,
+ Boolean do_hist_assembly)
{
SeqEntryPtr sep_head;
Uint2 entityID;
@@ -2042,6 +2047,7 @@ NLM_EXTERN Boolean ValidateSeqAlignInSeqEntry (SeqEntryPtr sep, Boolean message,
sv.delete_salp = delete_salp;
sv.delete_bsp = delete_bsp;
sv.retdel = TRUE;
+ sv.do_hist_assembly = do_hist_assembly;
sv.ids = NULL;
sv.entityID = entityID;
sv.dirty = FALSE;
@@ -2058,9 +2064,10 @@ NLM_EXTERN Boolean ValidateSeqAlignInSeqEntry (SeqEntryPtr sep, Boolean message,
/* alignment validator private for regular validator */
-NLM_EXTERN Boolean ValidateSeqAlignWithinValidator (ValidStructPtr vsp, SeqEntryPtr sep);
-NLM_EXTERN Boolean ValidateSeqAlignWithinValidator (ValidStructPtr vsp, SeqEntryPtr sep)
+NLM_EXTERN Boolean ValidateSeqAlignWithinValidator (ValidStructPtr vsp, SeqEntryPtr sep, Boolean find_remote_bsp, Boolean do_hist_assembly);
+
+NLM_EXTERN Boolean ValidateSeqAlignWithinValidator (ValidStructPtr vsp, SeqEntryPtr sep, Boolean find_remote_bsp, Boolean do_hist_assembly)
{
GatherContext gc;
@@ -2076,7 +2083,7 @@ NLM_EXTERN Boolean ValidateSeqAlignWithinValidator (ValidStructPtr vsp, SeqEntry
vsp->sfp = NULL;
vsp->descr = NULL;
MemSet ((Pointer) &gc, 0, sizeof (GatherContext));
- rsult = ValidateSeqAlignInSeqEntry (sep, FALSE, FALSE, TRUE, FALSE, FALSE);
+ rsult = ValidateSeqAlignInSeqEntry (sep, FALSE, FALSE, find_remote_bsp, FALSE, FALSE, do_hist_assembly);
useLockByID = TRUE;
useValErr = FALSE;
useVsp = NULL;
diff --git a/api/alignval.h b/api/alignval.h
index 764bccdc..f73a04b6 100644
--- a/api/alignval.h
+++ b/api/alignval.h
@@ -29,13 +29,16 @@
*
* Version Creation Date: 6/3/99
*
-* $Revision: 6.13 $
+* $Revision: 6.14 $
*
* File Description:
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: alignval.h,v $
+* Revision 6.14 2003/11/14 18:06:42 kans
+* added do_hist_assembly parameter
+*
* Revision 6.13 1999/11/23 21:47:31 vakatov
* Fixed for C++ and/or DLL compilation
*
@@ -79,8 +82,8 @@ NLM_EXTERN Boolean ValidateSeqAlign (SeqAlignPtr salp, Uint2 entityID, Boolean m
NLM_EXTERN Boolean ValidateSeqAlignInSeqEntry (SeqEntryPtr sep, Boolean message,
Boolean msg_success, Boolean find_remote_bsp,
- Boolean delete_bsp, Boolean delete_salp);
-
+ Boolean delete_bsp, Boolean delete_salp,
+ Boolean do_hist_assembly);
#define Err_SeqId 1
diff --git a/api/aliread.c b/api/aliread.c
index 7af5ffe4..5c1bcbfb 100644
--- a/api/aliread.c
+++ b/api/aliread.c
@@ -383,7 +383,7 @@ CharPtr ReadAlignFileLine (FILE PNTR alignFilePtr,
Int4 segmentLen = 0;
Int4 segmentCount = 1;
Boolean done = FALSE;
- Char ch;
+ Char ch = 0;
/* Allocate memory for the line. More */
/* can be added later as necessary. */
@@ -408,11 +408,14 @@ CharPtr ReadAlignFileLine (FILE PNTR alignFilePtr,
{
done = TRUE;
ch = (Char) NLM_GETC (alignFilePtr);
- if (ch != '\r')
+ if (ch != '\r') {
ungetc (ch, alignFilePtr);
+
+ }
}
- else if (ch == '\r')
- done = TRUE;
+ else if (ch == '\r') {
+ done = TRUE;
+ }
else
{
lineStr[totalLen] = ch;
@@ -450,6 +453,7 @@ CharPtr ReadAlignFileLine (FILE PNTR alignFilePtr,
*isEOF = TRUE;
lineStr[totalLen] = '\0';
+
return lineStr;
}
@@ -1160,8 +1164,9 @@ ValNodePtr Ali_ReadLines (FILE PNTR alignFilePtr,
lineStr = ReadAlignFileLine(alignFilePtr, errorListPtr,
configPtr, &isEOF);
- if (lineStr == NULL)
+ if (lineStr == NULL) {
return NULL;
+ }
rowNum++;
diff --git a/api/asn2gnb1.c b/api/asn2gnb1.c
index deccca09..3108ce82 100644
--- a/api/asn2gnb1.c
+++ b/api/asn2gnb1.c
@@ -1,4 +1,4 @@
-/* asn2gnbk.c
+/* asn2gnb1.c
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -23,14 +23,14 @@
*
* ===========================================================================
*
-* File Name: asn2gnbk.c
+* File Name: asn2gnb1.c
*
* Author: Karl Sirotkin, Tom Madden, Tatiana Tatusov, Jonathan Kans,
* Mati Shomrat
*
* Version Creation Date: 10/21/98
*
-* $Revision: 6.729 $
+* $Revision: 1.2 $
*
* File Description: New GenBank flatfile generator - work in progress
*
@@ -55,7 +55,7 @@
#include <gbftdef.h>
#include <edutil.h>
#include <alignmgr2.h>
-#include <asn2gnbp.h>
+#include <asn2gnbi.h>
#ifdef WIN_MAC
#if __profile__
@@ -63,1183 +63,324 @@
#endif
#endif
-#define ASN2FF_EMBL_MAX 78
-#define ASN2FF_GB_MAX 79
-#define SEQID_MAX_LEN 41
-
-#define TILDE_IGNORE 0
-#define TILDE_TO_SPACES 1
-#define TILDE_EXPAND 2
-#define TILDE_OLD_EXPAND 3
-
-
-/* flags set by mode to customize behavior */
-
-typedef struct asn2gbflags {
- Boolean suppressLocalID;
- Boolean validateFeats;
- Boolean ignorePatPubs;
- Boolean dropShortAA;
- Boolean avoidLocusColl;
- Boolean iupacaaOnly;
- Boolean dropBadCitGens;
- Boolean noAffilOnUnpub;
- Boolean dropIllegalQuals;
- Boolean checkQualSyntax;
- Boolean needRequiredQuals;
- Boolean needOrganismQual;
- Boolean needAtLeastOneRef;
- Boolean citArtIsoJta;
- Boolean dropBadDbxref;
- Boolean useEmblMolType;
- Boolean hideBankItComment;
- Boolean checkCDSproductID;
- Boolean suppressSegLoc;
- Boolean srcQualsToNote;
- Boolean hideEmptySource;
- Boolean goQualsToNote;
- Boolean geneSynsToNote;
- Boolean selenocysteineToNote;
- Boolean forGbRelease;
-} Asn2gbFlags, PNTR Asn2gbFlagsPtr;
-
-/* internal Asn2gbSect structure has fields on top of Asn2gbSect fields */
-
-typedef struct int_Asn2gbSect {
- Asn2gbSect asp;
- SeqPortPtr spp;
-} IntAsn2gbSect, PNTR IntAsn2gbSectPtr;
-
-/* string structure */
-
-#define STRING_BUF_LEN 1024
-
-typedef struct stringitem {
- struct stringitem *curr;
- struct stringitem *next;
- Pointer iajp;
- Char buf [STRING_BUF_LEN];
- Int4 pos;
-} StringItem, PNTR StringItemPtr;
-
-/* internal asn2gbjob structure has fields on top of Asn2gbJob fields */
-
-typedef struct int_asn2gb_job {
- Asn2gbJob ajp;
- FmtType format;
- ModType mode;
- Asn2gbFlags flags;
- Boolean showFarTransl;
- Boolean transIfNoProd;
- Boolean alwaysTranslCds;
- Boolean showTranscript;
- Boolean showPeptide;
- Boolean transientSeqPort;
- Boolean masterStyle;
- Boolean newSourceOrg;
- ValNodePtr lockedBspList;
- Boolean relModeError;
- Boolean skipProts;
- Boolean skipMrnas;
- IndxPtr index;
- GBSeqPtr gbseq;
- StringItemPtr pool;
- Boolean www;
-} IntAsn2gbJob, PNTR IntAsn2gbJobPtr;
-
-/* structure for storing working parameters while building asn2gb_job structure */
-
-typedef struct asn2gbwork {
- IntAsn2gbJobPtr ajp;
- Uint2 entityID;
-
- FmtType format;
- ModType mode;
- StlType style;
-
- ValNodePtr pubhead; /* for collecting publications */
- ValNodePtr srchead; /* for collecting biosources */
-
- /* linked lists of paragraphs, sections, blocks */
-
- ValNodePtr sectionList;
- ValNodePtr blockList; /* reset for each new section */
-
- /* most recent node of linked lists, for quickly adding next node */
-
- ValNodePtr lastsection;
- ValNodePtr lastblock; /* reset for each new section */
-
- Int4 currsection;
-
- /* section fields needed for populating blocks */
-
- Asn2gbSectPtr asp;
-
- BioseqPtr target;
- BioseqPtr parent;
- BioseqPtr bsp;
- BioseqPtr refs;
- SeqLocPtr slp;
- Uint2 seg;
- Int4 numsegs;
- Int4 partcount;
- Int4 from;
- Int4 to;
- Boolean showAllFeats;
-
- Boolean contig;
- Boolean showconfeats;
- Boolean showconsource;
-
- Boolean onlyNearFeats;
- Boolean farFeatsSuppress;
- Boolean nearFeatsSuppress;
-
- Boolean citSubsFirst;
- Boolean hideGeneFeats;
- Boolean newLocusLine;
- Boolean showBaseCount;
-
- Boolean hideImpFeats;
- Boolean hideRemImpFeats;
- Boolean hideSnpFeats;
- Boolean hideExonFeats;
- Boolean hideIntronFeats;
- Boolean hideMiscFeats;
- Boolean hideCddFeats;
- Boolean hideCdsProdFeats;
-
- Boolean hideGeneRIFs;
- Boolean onlyGeneRIFs;
- Boolean latestGeneRIFs;
-
- Boolean showRefs;
+/* utility functions */
- Boolean isGPS;
- Boolean copyGpsCdsUp;
- Boolean copyGpsGeneDown;
+NLM_EXTERN ValNodePtr ValNodeCopyStrToHead (ValNodePtr PNTR head, Int2 choice, CharPtr str)
- Boolean showContigAndSeq;
+{
+ ValNodePtr newnode;
- Char basename [SEQID_MAX_LEN];
+ if (head == NULL || str == NULL) return NULL;
- SeqFeatPtr lastsfp;
- SeqAnnotPtr lastsap;
- Int4 lastleft;
- Int4 lastright;
+ newnode = ValNodeNew (NULL);
+ if (newnode == NULL) return NULL;
- Boolean firstfeat;
- Boolean featseen;
+ newnode->choice = (Uint1) choice;
+ newnode->data.ptrvalue = StringSave (str);
- SeqSubmitPtr ssp;
- Boolean hup;
+ newnode->next = *head;
+ *head = newnode;
- Boolean stream;
+ return newnode;
+}
- Boolean failed;
-} Asn2gbWork, PNTR Asn2gbWorkPtr;
+/* the val node strings mechanism will be replaced by a more efficient method later */
-/* array for assigning biosource and feature data fields to qualifiers */
-/* should be allocated to MAX (ASN2GNBK_TOTAL_SOURCE, ASN2GNBK_TOTAL_FEATUR) */
+NLM_EXTERN CharPtr MergeFFValNodeStrs (
+ ValNodePtr list
+)
-typedef union qualval {
- CharPtr str;
- Boolean ble;
- Int4 num;
- ValNodePtr vnp;
- GBQualPtr gbq;
- OrgModPtr omp;
- SubSourcePtr ssp;
- CodeBreakPtr cbp;
- SeqLocPtr slp;
- SeqIdPtr sip;
- tRNAPtr trp;
- UserObjectPtr uop;
- UserFieldPtr ufp;
-} QualVal, PNTR QualValPtr;
+{
+ size_t len;
+ CharPtr ptr;
+ CharPtr str;
+ CharPtr tmp;
+ ValNodePtr vnp;
-/* structure passed to individual paragraph format functions */
-typedef struct asn2gbformat {
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- QualValPtr qvp;
-
- FmtType format;
-} Asn2gbFormat, PNTR Asn2gbFormatPtr;
-
-
-/* Seq-hist replacedBy is preformatted into string field, */
-/* then comment descriptors, Map location:, and Region:, */
-/* then comment features, finally HTGS */
-
-typedef struct comment_block {
- ASN2GB_BASE_BLOCK
- Boolean first;
-} CommentBlock, PNTR CommentBlockPtr;
-
-/* internal reference block has fields on top of RefBlock fields */
-
-typedef struct int_ref_block {
- RefBlock rb;
- DatePtr date; /* internal sorting use only */
- SeqLocPtr loc; /* final location on target bioseq */
- CharPtr authstr; /* author string */
- Uint2 index; /* index if feature on target bioseq */
- Boolean justuids; /* gibb pub with uids and Figure, etc. */
- CharPtr fig; /* figure string from equivalent gibb pub */
- CharPtr maploc; /* maploc string from equivalent gibb pub */
- Boolean poly_a; /* poly_a field from equivalent gibb pub */
-} IntRefBlock, PNTR IntRefBlockPtr;
-
-/* internal source block has fields on top of BaseBlock fields */
-
-typedef struct int_src_block {
- BaseBlock bb;
- Boolean is_descriptor;
- Boolean is_focus;
- Boolean is_synthetic;
- BioSourcePtr biop;
- Uint4 orghash;
- Uint4 modhash;
- Uint4 subhash;
- Uint4 xrfhash;
- SeqLocPtr loc; /* final location on target bioseq */
- CharPtr taxname;
- CharPtr comment;
- OrgModPtr omp;
- SubSourcePtr ssp;
- ValNodePtr vnp;
- Int4 left;
- Int4 right;
-} IntSrcBlock, PNTR IntSrcBlockPtr;
-
-/* internal feature block has fields on top of FeatBlock fields */
-
-typedef struct int_feat_block {
- FeatBlock fb;
- Boolean mapToNuc;
- Boolean mapToProt;
- Boolean mapToGen;
- Boolean mapToMrna;
- Boolean mapToPep;
- Boolean isCDS; /* set if using IntCdsBlock */
- Boolean firstfeat;
-} IntFeatBlock, PNTR IntFeatBlockPtr;
-
-/* internal cds block has fields on top of IntFeatBlock fields */
-
-typedef struct int_cds_block {
- IntFeatBlock ifb;
- FeatBlock fb;
- CharPtr fig; /* figure string from pub */
- CharPtr maploc; /* maploc string from pub */
-} IntCdsBlock, PNTR IntCdsBlockPtr;
-
-
-/* enumerated qualifier category definitions */
-
-typedef enum {
- Qual_class_ignore = 0,
- Qual_class_string,
- Qual_class_tilde,
- Qual_class_sgml,
- Qual_class_boolean,
- Qual_class_int,
- Qual_class_evidence,
- Qual_class_valnode,
- Qual_class_EC_valnode,
- Qual_class_xtraprds,
- Qual_class_quote,
- Qual_class_EC_quote,
- Qual_class_noquote,
- Qual_class_label,
- Qual_class_number,
- Qual_class_paren,
- Qual_class_region,
- Qual_class_replace,
- Qual_class_consplice,
- Qual_class_bond,
- Qual_class_site,
- Qual_class_L_R_B,
- Qual_class_rpt,
- Qual_class_organelle,
- Qual_class_orgmod,
- Qual_class_subsource,
- Qual_class_code_break,
- Qual_class_anti_codon,
- Qual_class_codon,
- Qual_class_method,
- Qual_class_pubset,
- Qual_class_db_xref,
- Qual_class_seq_id,
- Qual_class_seq_loc,
- Qual_class_its,
- Qual_class_sec_str,
- Qual_class_trna_codons,
- Qual_class_translation,
- Qual_class_transcription,
- Qual_class_peptide,
- Qual_class_protnames,
- Qual_class_illegal,
- Qual_class_note,
- Qual_class_rpt_unit,
- Qual_class_product,
- Qual_class_model_ev,
- Qual_class_gene_syn,
- Qual_class_locus_tag,
- Qual_class_go
-} QualType;
-
-/* source 'feature' */
-
-/* some qualifiers will require additional content verification not
- explicitly indicated by the class type */
-
-typedef enum {
- SCQUAL_acronym = 1,
- SCQUAL_anamorph,
- SCQUAL_authority,
- SCQUAL_biotype,
- SCQUAL_biovar,
- SCQUAL_breed,
- SCQUAL_cell_line,
- SCQUAL_cell_type,
- SCQUAL_chemovar,
- SCQUAL_chromosome,
- SCQUAL_citation,
- SCQUAL_clone,
- SCQUAL_clone_lib,
- SCQUAL_common,
- SCQUAL_common_name,
- SCQUAL_country,
- SCQUAL_cultivar,
- SCQUAL_db_xref,
- SCQUAL_org_xref,
- SCQUAL_dev_stage,
- SCQUAL_dosage,
- SCQUAL_ecotype,
- SCQUAL_endogenous_virus_name,
- SCQUAL_environmental_sample,
- SCQUAL_extrachrom,
- SCQUAL_focus,
- SCQUAL_forma,
- SCQUAL_forma_specialis,
- SCQUAL_frequency,
- SCQUAL_gb_acronym,
- SCQUAL_gb_anamorph,
- SCQUAL_gb_synonym,
- SCQUAL_genotype,
- SCQUAL_germline,
- SCQUAL_group,
- SCQUAL_haplotype,
- SCQUAL_ins_seq_name,
- SCQUAL_isolate,
- SCQUAL_isolation_source,
- SCQUAL_lab_host,
- SCQUAL_label,
- SCQUAL_macronuclear,
- SCQUAL_map,
- SCQUAL_mol_type,
- SCQUAL_note,
- SCQUAL_old_lineage,
- SCQUAL_old_name,
- SCQUAL_organism,
- SCQUAL_organelle,
- SCQUAL_orgmod_note,
- SCQUAL_pathovar,
- SCQUAL_plasmid_name,
- SCQUAL_plastid_name,
- SCQUAL_pop_variant,
- SCQUAL_rearranged,
- SCQUAL_segment,
- SCQUAL_seqfeat_note,
- SCQUAL_sequenced_mol,
- SCQUAL_serogroup,
- SCQUAL_serotype,
- SCQUAL_serovar,
- SCQUAL_sex,
- SCQUAL_spec_or_nat_host,
- SCQUAL_specimen_voucher,
- SCQUAL_strain,
- SCQUAL_sub_clone,
- SCQUAL_sub_group,
- SCQUAL_sub_species,
- SCQUAL_sub_strain,
- SCQUAL_sub_type,
- SCQUAL_subsource_note,
- SCQUAL_synonym,
- SCQUAL_teleomorph,
- SCQUAL_tissue_lib,
- SCQUAL_tissue_type,
- SCQUAL_transgenic,
- SCQUAL_transposon_name,
- SCQUAL_type,
- SCQUAL_unstructured,
- SCQUAL_usedin,
- SCQUAL_variety,
- SCQUAL_zero_orgmod,
- SCQUAL_one_orgmod,
- SCQUAL_zero_subsrc,
- ASN2GNBK_TOTAL_SOURCE
-} SourceType;
-
-/* ordering arrays for qualifiers and note components */
-
-static Uint1 source_qual_order [] = {
- SCQUAL_organism,
-
- SCQUAL_organelle,
-
- SCQUAL_mol_type,
-
- SCQUAL_strain,
- SCQUAL_sub_strain,
- SCQUAL_variety,
- SCQUAL_serotype,
- SCQUAL_serovar,
- SCQUAL_cultivar,
- SCQUAL_isolate,
- SCQUAL_isolation_source,
- SCQUAL_spec_or_nat_host,
- SCQUAL_sub_species,
- SCQUAL_specimen_voucher,
-
- SCQUAL_db_xref,
- SCQUAL_org_xref,
-
- SCQUAL_chromosome,
-
- SCQUAL_segment,
-
- SCQUAL_map,
- SCQUAL_clone,
- SCQUAL_sub_clone,
- SCQUAL_haplotype,
- SCQUAL_sex,
- SCQUAL_cell_line,
- SCQUAL_cell_type,
- SCQUAL_tissue_type,
- SCQUAL_clone_lib,
- SCQUAL_dev_stage,
- SCQUAL_ecotype,
- SCQUAL_frequency,
-
- SCQUAL_germline,
- SCQUAL_rearranged,
- SCQUAL_transgenic,
- SCQUAL_environmental_sample,
-
- SCQUAL_lab_host,
- SCQUAL_pop_variant,
- SCQUAL_tissue_lib,
-
- SCQUAL_plasmid_name,
- SCQUAL_transposon_name,
- SCQUAL_ins_seq_name,
-
- SCQUAL_country,
-
- SCQUAL_focus,
-
- SCQUAL_note,
-
- SCQUAL_sequenced_mol,
- SCQUAL_label,
- SCQUAL_usedin,
- SCQUAL_citation,
- 0
-};
+ if (list == NULL) return NULL;
-static Uint1 source_desc_note_order [] = {
- SCQUAL_seqfeat_note,
- SCQUAL_orgmod_note,
- SCQUAL_subsource_note,
-
- SCQUAL_type,
- SCQUAL_sub_type,
- SCQUAL_serogroup,
- SCQUAL_pathovar,
- SCQUAL_chemovar,
- SCQUAL_biovar,
- SCQUAL_biotype,
- SCQUAL_group,
- SCQUAL_sub_group,
- SCQUAL_common,
- SCQUAL_acronym,
- SCQUAL_dosage,
-
- SCQUAL_authority,
- SCQUAL_forma,
- SCQUAL_forma_specialis,
- SCQUAL_synonym,
- SCQUAL_anamorph,
- SCQUAL_teleomorph,
- SCQUAL_breed,
-
- SCQUAL_genotype,
- SCQUAL_plastid_name,
-
- SCQUAL_endogenous_virus_name,
-
- SCQUAL_common_name,
-
- SCQUAL_zero_orgmod,
- SCQUAL_one_orgmod,
- SCQUAL_zero_subsrc,
-
- /* SCQUAL_old_lineage, */
-
- /* SCQUAL_old_name, */
- 0
-};
+ for (vnp = list, len = 0; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ len += StringLen (str);
+ }
+ if (len == 0) return NULL;
-static Uint1 source_feat_note_order [] = {
- SCQUAL_unstructured,
-
- SCQUAL_type,
- SCQUAL_sub_type,
- SCQUAL_serogroup,
- SCQUAL_pathovar,
- SCQUAL_chemovar,
- SCQUAL_biovar,
- SCQUAL_biotype,
- SCQUAL_group,
- SCQUAL_sub_group,
- SCQUAL_common,
- SCQUAL_acronym,
- SCQUAL_dosage,
-
- SCQUAL_authority,
- SCQUAL_forma,
- SCQUAL_forma_specialis,
- SCQUAL_synonym,
- SCQUAL_anamorph,
- SCQUAL_teleomorph,
- SCQUAL_breed,
-
- SCQUAL_genotype,
- SCQUAL_plastid_name,
-
- SCQUAL_endogenous_virus_name,
-
- SCQUAL_seqfeat_note,
- SCQUAL_orgmod_note,
- SCQUAL_subsource_note,
-
- SCQUAL_common_name,
-
- SCQUAL_zero_orgmod,
- SCQUAL_one_orgmod,
- SCQUAL_zero_subsrc,
-
- /* SCQUAL_old_lineage, */
-
- /* SCQUAL_old_name, */
- 0
-};
+ ptr = MemNew (sizeof (Char) * (len + 2));
+ if (ptr == NULL) return NULL;
-typedef struct sourcequal {
- CharPtr name;
- Uint1 qualclass;
-} SourceQual, PNTR SourceQualPtr;
-
-static SourceQual asn2gnbk_source_quals [ASN2GNBK_TOTAL_SOURCE] = {
- { "", Qual_class_ignore },
- { "acronym", Qual_class_orgmod },
- { "anamorph", Qual_class_orgmod },
- { "authority", Qual_class_orgmod },
- { "biotype", Qual_class_orgmod },
- { "biovar", Qual_class_orgmod },
- { "breed", Qual_class_orgmod },
- { "cell_line", Qual_class_subsource },
- { "cell_type", Qual_class_subsource },
- { "chemovar", Qual_class_orgmod },
- { "chromosome", Qual_class_subsource },
- { "citation", Qual_class_pubset },
- { "clone", Qual_class_subsource },
- { "clone_lib", Qual_class_subsource },
- { "common", Qual_class_orgmod },
- { "common", Qual_class_string },
- { "country", Qual_class_subsource },
- { "cultivar", Qual_class_orgmod },
- { "db_xref", Qual_class_db_xref },
- { "db_xref", Qual_class_db_xref },
- { "dev_stage", Qual_class_subsource },
- { "dosage", Qual_class_orgmod },
- { "ecotype", Qual_class_orgmod },
- { "endogenous_virus", Qual_class_subsource },
- { "environmental_sample", Qual_class_subsource },
- { "extrachromosomal", Qual_class_boolean },
- { "focus", Qual_class_boolean },
- { "forma", Qual_class_orgmod },
- { "forma_specialis", Qual_class_orgmod },
- { "frequency", Qual_class_subsource },
- { "gb_acronym", Qual_class_orgmod },
- { "gb_anamorph", Qual_class_orgmod },
- { "gb_synonym", Qual_class_orgmod },
- { "genotype", Qual_class_subsource },
- { "germline", Qual_class_subsource },
- { "group", Qual_class_orgmod },
- { "haplotype", Qual_class_subsource },
- { "insertion_seq", Qual_class_subsource },
- { "isolate", Qual_class_orgmod },
- { "isolation_source", Qual_class_subsource },
- { "lab_host", Qual_class_subsource },
- { "label", Qual_class_label },
- { "macronuclear", Qual_class_boolean },
- { "map", Qual_class_subsource },
- { "mol_type", Qual_class_string },
- { "note", Qual_class_note },
- { "old_lineage", Qual_class_orgmod },
- { "old_name", Qual_class_orgmod },
- { "organism", Qual_class_string },
- { "organelle", Qual_class_organelle },
- { "orgmod_note", Qual_class_orgmod },
- { "pathovar", Qual_class_orgmod },
- { "plasmid", Qual_class_subsource },
- { "plastid", Qual_class_subsource },
- { "pop_variant", Qual_class_subsource },
- { "rearranged", Qual_class_subsource },
- { "segment", Qual_class_subsource },
- { "seqfeat_note", Qual_class_string },
- { "sequenced_mol", Qual_class_quote },
- { "serogroup", Qual_class_orgmod },
- { "serotype", Qual_class_orgmod },
- { "serovar", Qual_class_orgmod },
- { "sex", Qual_class_subsource },
- { "specific_host", Qual_class_orgmod },
- { "specimen_voucher", Qual_class_orgmod },
- { "strain", Qual_class_orgmod },
- { "sub_clone", Qual_class_subsource },
- { "subgroup", Qual_class_orgmod },
- { "sub_species", Qual_class_orgmod },
- { "sub_strain", Qual_class_orgmod },
- { "subtype", Qual_class_orgmod },
- { "subsource_note", Qual_class_subsource },
- { "synonym", Qual_class_orgmod },
- { "teleomorph", Qual_class_orgmod },
- { "tissue_lib", Qual_class_subsource },
- { "tissue_type", Qual_class_subsource },
- { "transgenic", Qual_class_subsource },
- { "transposon", Qual_class_subsource },
- { "type", Qual_class_orgmod },
- { "unstructured", Qual_class_valnode },
- { "usedin", Qual_class_quote },
- { "variety", Qual_class_orgmod },
- { "?", Qual_class_orgmod },
- { "?", Qual_class_orgmod },
- { "?", Qual_class_subsource },
-};
+ for (vnp = list, tmp = ptr; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ tmp = StringMove (tmp, str);
+ }
-static Int2 subSourceToSourceIdx [30] = {
- SCQUAL_zero_subsrc,
- SCQUAL_chromosome,
- SCQUAL_map,
- SCQUAL_clone,
- SCQUAL_sub_clone,
- SCQUAL_haplotype,
- SCQUAL_genotype,
- SCQUAL_sex,
- SCQUAL_cell_line,
- SCQUAL_cell_type,
- SCQUAL_tissue_type,
- SCQUAL_clone_lib,
- SCQUAL_dev_stage,
- SCQUAL_frequency,
- SCQUAL_germline,
- SCQUAL_rearranged,
- SCQUAL_lab_host,
- SCQUAL_pop_variant,
- SCQUAL_tissue_lib,
- SCQUAL_plasmid_name,
- SCQUAL_transposon_name,
- SCQUAL_ins_seq_name,
- SCQUAL_plastid_name,
- SCQUAL_country,
- SCQUAL_segment,
- SCQUAL_endogenous_virus_name,
- SCQUAL_transgenic,
- SCQUAL_environmental_sample,
- SCQUAL_isolation_source,
- SCQUAL_subsource_note
-};
+ return ptr;
+}
-typedef enum {
- FTQUAL_allele = 1,
- FTQUAL_anticodon,
- FTQUAL_bond,
- FTQUAL_bond_type,
- FTQUAL_bound_moiety,
- FTQUAL_cds_product,
- FTQUAL_citation,
- FTQUAL_clone,
- FTQUAL_coded_by,
- FTQUAL_codon,
- FTQUAL_codon_start,
- FTQUAL_cons_splice,
- FTQUAL_db_xref,
- FTQUAL_derived_from,
- FTQUAL_direction,
- FTQUAL_EC_number,
- FTQUAL_evidence,
- FTQUAL_exception,
- FTQUAL_exception_note,
- FTQUAL_figure,
- FTQUAL_frequency,
- FTQUAL_function,
- FTQUAL_gene,
- FTQUAL_gene_desc,
- FTQUAL_gene_allele,
- FTQUAL_gene_map,
- FTQUAL_gene_syn,
- FTQUAL_gene_syn_refseq,
- FTQUAL_gene_note,
- FTQUAL_gene_xref,
- FTQUAL_go_component,
- FTQUAL_go_function,
- FTQUAL_go_process,
- FTQUAL_heterogen,
- FTQUAL_illegal_qual,
- FTQUAL_insertion_seq,
- FTQUAL_label,
- FTQUAL_locus_tag,
- FTQUAL_map,
- FTQUAL_maploc,
- FTQUAL_mod_base,
- FTQUAL_modelev,
- FTQUAL_note,
- FTQUAL_number,
- FTQUAL_operon,
- FTQUAL_organism,
- FTQUAL_partial,
- FTQUAL_PCR_conditions,
- FTQUAL_peptide,
- FTQUAL_phenotype,
- FTQUAL_product,
- FTQUAL_product_quals,
- FTQUAL_prot_activity,
- FTQUAL_prot_comment,
- FTQUAL_prot_EC_number,
- FTQUAL_prot_note,
- FTQUAL_prot_method,
- FTQUAL_prot_conflict,
- FTQUAL_prot_desc,
- FTQUAL_prot_missing,
- FTQUAL_prot_name,
- FTQUAL_prot_names,
- FTQUAL_protein_id,
- FTQUAL_pseudo,
- FTQUAL_region,
- FTQUAL_region_name,
- FTQUAL_replace,
- FTQUAL_rpt_family,
- FTQUAL_rpt_type,
- FTQUAL_rpt_unit,
- FTQUAL_rrna_its,
- FTQUAL_sec_str_type,
- FTQUAL_selenocysteine,
- FTQUAL_selenocysteine_note,
- FTQUAL_seqfeat_note,
- FTQUAL_site,
- FTQUAL_site_type,
- FTQUAL_standard_name,
- FTQUAL_transcription,
- FTQUAL_transcript_id,
- FTQUAL_transcript_id_note, /* !!! remove October 15, 2003 !!! */
- FTQUAL_transl_except,
- FTQUAL_transl_table,
- FTQUAL_translation,
- FTQUAL_transposon,
- FTQUAL_trna_aa,
- FTQUAL_trna_codons,
- FTQUAL_usedin,
- FTQUAL_xtra_prod_quals,
- ASN2GNBK_TOTAL_FEATUR
-} FtQualType;
-
-/* ordering arrays for qualifiers and note components */
-
-static Uint1 feat_qual_order [] = {
- FTQUAL_partial,
- FTQUAL_gene,
-
- FTQUAL_locus_tag,
- FTQUAL_gene_syn_refseq,
-
- FTQUAL_gene_allele,
-
- FTQUAL_operon,
-
- FTQUAL_product,
-
- FTQUAL_prot_EC_number,
- FTQUAL_prot_activity,
-
- FTQUAL_standard_name,
- FTQUAL_coded_by,
- FTQUAL_derived_from,
-
- FTQUAL_prot_name,
- FTQUAL_region_name,
- FTQUAL_bond_type,
- FTQUAL_site_type,
- FTQUAL_sec_str_type,
- FTQUAL_heterogen,
-
- FTQUAL_note,
- FTQUAL_citation,
-
- FTQUAL_number,
-
- FTQUAL_pseudo,
- FTQUAL_selenocysteine,
-
- FTQUAL_codon_start,
-
- FTQUAL_anticodon,
- FTQUAL_bound_moiety,
- FTQUAL_clone,
- FTQUAL_cons_splice,
- FTQUAL_direction,
- FTQUAL_function,
- FTQUAL_evidence,
- FTQUAL_exception,
- FTQUAL_frequency,
- FTQUAL_EC_number,
- FTQUAL_gene_map,
- FTQUAL_allele,
- FTQUAL_map,
- FTQUAL_mod_base,
- FTQUAL_PCR_conditions,
- FTQUAL_phenotype,
- FTQUAL_rpt_family,
- FTQUAL_rpt_type,
- FTQUAL_rpt_unit,
- FTQUAL_insertion_seq,
- FTQUAL_transposon,
- FTQUAL_usedin,
-
- FTQUAL_illegal_qual,
-
- FTQUAL_replace,
-
- FTQUAL_transl_except,
- FTQUAL_transl_table,
- FTQUAL_codon,
- FTQUAL_organism,
- FTQUAL_label,
- FTQUAL_cds_product,
- FTQUAL_protein_id,
- FTQUAL_transcript_id,
- FTQUAL_db_xref,
- FTQUAL_gene_xref,
- FTQUAL_translation,
- FTQUAL_transcription,
- FTQUAL_peptide,
- 0
-};
-/*
-prot_names after seqfeat_note - gi|4210642|emb|AJ005084.1|HBVAJ5084
-prot_conflict after prot_desc - gi|61183|emb|V01135.1|PIVM02
-figure after prot_desc - gi|400553|gb|S64006.1|
-seqfeat_note after prot_desc - gi|431713|gb|L20354.1|STVPATPOLB
- but prot_desc after seqfeat_note - AF252556.1
-prot_names after figure - gi|234022|gb|S56149.1|S56149
-seqfeat_note after prot_conflict after figure - gi|234046|gb|S51392.1|S51392
-prot_method after prot_comment (descriptor) after prot_note after prot_desc
-region after seqfeat_note - gi|6554164|gb|AF043644.3|AF043644
-prot_desc after prot_names - gi|6581069|gb|AF202541.1|AF202541 - cannot do !!!
-gene_syn after gene_desc - gi|3386543|gb|AF079528.1|AF079528
-pseudo after note - gi|6598562|gb|AC006419.3|AC006419
-*/
+NLM_EXTERN void AddValNodeString (
+ ValNodePtr PNTR head,
+ CharPtr prefix,
+ CharPtr string,
+ CharPtr suffix
+)
-static Uint1 feat_note_order [] = {
- FTQUAL_transcript_id_note, /* !!! remove October 15, 2003 !!! */
- FTQUAL_gene_desc,
- FTQUAL_gene_syn,
- FTQUAL_trna_codons,
- FTQUAL_prot_desc,
- FTQUAL_prot_note,
- FTQUAL_prot_comment,
- FTQUAL_prot_method,
- FTQUAL_figure,
- FTQUAL_maploc,
- FTQUAL_prot_conflict,
- FTQUAL_prot_missing,
- FTQUAL_seqfeat_note,
- FTQUAL_exception_note,
- FTQUAL_region,
- FTQUAL_selenocysteine_note,
- FTQUAL_prot_names,
- FTQUAL_bond,
- FTQUAL_site,
- FTQUAL_rrna_its,
- FTQUAL_xtra_prod_quals,
- FTQUAL_modelev,
- /* GO terms appear as own qualifiers in RefSeq records, Sequin or Dump mode */
- FTQUAL_go_component,
- FTQUAL_go_function,
- FTQUAL_go_process,
- 0
-};
+{
+ Char buf [256];
+ CharPtr freeme = NULL;
+ size_t len;
+ CharPtr newstr;
+ CharPtr strptr;
-typedef struct featurqual {
- CharPtr name;
- Uint1 qualclass;
-} FeaturQual, PNTR FeaturQualPtr;
-
-static FeaturQual asn2gnbk_featur_quals [ASN2GNBK_TOTAL_FEATUR] = {
- { "", Qual_class_ignore },
- { "allele", Qual_class_quote },
- { "anticodon", Qual_class_anti_codon },
- { "bond", Qual_class_bond },
- { "bond_type", Qual_class_bond },
- { "bound_moiety", Qual_class_quote },
- { "product", Qual_class_string },
- { "citation", Qual_class_pubset },
- { "clone", Qual_class_quote },
- { "coded_by", Qual_class_seq_loc },
- { "codon", Qual_class_codon },
- { "codon_start", Qual_class_int },
- { "cons_splice", Qual_class_consplice },
- { "db_xref", Qual_class_db_xref },
- { "derived_from", Qual_class_seq_loc },
- { "direction", Qual_class_L_R_B },
- { "EC_number", Qual_class_EC_quote },
- { "evidence", Qual_class_evidence },
- { "exception", Qual_class_string },
- { "exception_note", Qual_class_string },
- { "figure", Qual_class_string },
- { "frequency", Qual_class_quote },
- { "function", Qual_class_quote },
- { "gene", Qual_class_sgml },
- { "gene_desc", Qual_class_string },
- { "allele", Qual_class_string },
- { "map", Qual_class_string },
- { "gene_syn", Qual_class_gene_syn },
- { "synonym", Qual_class_gene_syn },
- { "gene_note", Qual_class_string },
- { "db_xref", Qual_class_db_xref },
- { "go_component", Qual_class_go },
- { "go_function", Qual_class_go },
- { "go_process", Qual_class_go },
- { "heterogen", Qual_class_string },
- { "illegal", Qual_class_illegal },
- { "insertion_seq", Qual_class_quote },
- { "label", Qual_class_label },
- { "locus_tag", Qual_class_locus_tag },
- { "map", Qual_class_quote },
- { "maploc", Qual_class_string },
- { "mod_base", Qual_class_noquote },
- { "model_evidence", Qual_class_model_ev },
- { "note", Qual_class_note },
- { "number", Qual_class_number },
- { "operon", Qual_class_quote },
- { "organism", Qual_class_quote },
- { "partial", Qual_class_boolean },
- { "PCR_conditions", Qual_class_quote },
- { "peptide", Qual_class_peptide },
- { "phenotype", Qual_class_quote },
- { "product", Qual_class_product },
- { "product", Qual_class_quote },
- { "function", Qual_class_valnode },
- { "prot_comment", Qual_class_string },
- { "EC_number", Qual_class_EC_valnode },
- { "prot_note", Qual_class_string },
- { "prot_method", Qual_class_method },
- { "prot_conflict", Qual_class_string },
- { "prot_desc", Qual_class_string },
- { "prot_missing", Qual_class_string },
- { "name", Qual_class_tilde },
- { "prot_names", Qual_class_protnames },
- { "protein_id", Qual_class_seq_id },
- { "pseudo", Qual_class_boolean },
- { "region", Qual_class_region },
- { "region_name", Qual_class_string },
- { "replace", Qual_class_replace },
- { "rpt_family", Qual_class_quote },
- { "rpt_type", Qual_class_rpt },
- { "rpt_unit", Qual_class_rpt_unit },
- { "rrna_its", Qual_class_its },
- { "sec_str_type", Qual_class_sec_str },
- { "selenocysteine", Qual_class_boolean },
- { "selenocysteine", Qual_class_string },
- { "seqfeat_note", Qual_class_string },
- { "site", Qual_class_site },
- { "site_type", Qual_class_site },
- { "standard_name", Qual_class_quote },
- { "transcription", Qual_class_transcription },
- { "transcript_id", Qual_class_seq_id },
- { "tscpt_id_note", Qual_class_seq_id }, /* !!! remove October 15, 2003 !!! */
- { "transl_except", Qual_class_code_break },
- { "transl_table", Qual_class_int },
- { "translation", Qual_class_translation },
- { "transposon", Qual_class_quote },
- { "trna_aa", Qual_class_ignore },
- { "trna_codons", Qual_class_trna_codons },
- { "usedin", Qual_class_paren },
- { "xtra_products", Qual_class_xtraprds }
-};
+ len = StringLen (prefix) + StringLen (string) + StringLen (suffix);
+ if (len == 0) return;
-static Boolean AllowedValQual (Uint2 featureKey, FtQualType qualKey);
+ if (len < sizeof (buf)) {
+ /* if new string fits in stack buffer, no need to allocate */
-/* ********************************************************************** */
+ MemSet ((Pointer) buf, 0, sizeof (buf));
+ newstr = buf;
-/* URLs */
+ } else {
-#define MAX_WWWBUF 328
+ /* new string bigger than stack buffer, so allocate sufficient string */
-static Char link_feat [MAX_WWWBUF];
-#define DEF_LINK_FEAT "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?"
+ newstr = (CharPtr) MemNew (sizeof (Char) * (len + 2));
+ if (newstr == NULL) return;
-static Char link_seq [MAX_WWWBUF];
-#define DEF_LINK_SEQ "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?"
+ /* allocated string will be freed at end of function */
-static Char link_wgs [MAX_WWWBUF];
-#define DEF_LINK_WGS "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?"
+ freeme = newstr;
+ }
-static Char link_omim [MAX_WWWBUF];
-#define DEF_LINK_OMIM "http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id="
+ strptr = newstr;
-static Char ref_link [MAX_WWWBUF];
-#define DEF_LINK_REF "http://www.ncbi.nlm.nih.gov/RefSeq/"
+ if (prefix != NULL) {
+ strptr = StringMove (strptr, prefix);
+ }
-static Char nt_link [MAX_WWWBUF];
-#define DEF_LINK_NT "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?view=graph&val="
+ if (string != NULL) {
+ strptr = StringMove (strptr, string);
+ }
-static Char doc_link [MAX_WWWBUF];
-#define DEF_LINK_DOC "http://www.ncbi.nlm.nih.gov/genome/guide/build.html"
+ if (suffix != NULL) {
+ strptr = StringMove (strptr, suffix);
+ }
-static Char ev_link [MAX_WWWBUF];
-#define DEF_LINK_EV "http://www.ncbi.nlm.nih.gov/sutils/evv.cgi?"
+ /* currently just makes a valnode list, to be enhanced later */
-static Char ec_link [MAX_WWWBUF];
-#define DEF_LINK_EC "http://www.expasy.ch/cgi-bin/nicezyme.pl?"
+ ValNodeCopyStr (head, 0, newstr);
-static Char link_tax [MAX_WWWBUF];
-#define DEF_LINK_TAX "http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?"
+ /* if large string was allocated, free it now */
-static Char link_ff [MAX_WWWBUF];
-#define DEF_LINK_FF "/cgi-bin/Entrez/getfeat?"
+ if (freeme != NULL) {
+ MemFree (freeme);
+ }
+}
-static Char link_muid [MAX_WWWBUF];
-#define DEF_LINK_MUID "/entrez/utils/qmap.cgi?"
-static Char link_ace [MAX_WWWBUF];
-#define DEF_LINK_ACE "http://www.ncbi.nlm.nih.gov/IEB/Research/Acembly/av.cgi?db=worm&c=gene&q="
+NLM_EXTERN void FFAddString_NoRedund (
+ StringItemPtr unique,
+ CharPtr prefix,
+ CharPtr string,
+ CharPtr suffix
+)
+{
+ CharPtr str = string;
+ Int4 foundPos = 0;
+ Boolean wholeWord = FALSE;
-static Char link_code [MAX_WWWBUF];
-#define DEF_LINK_CODE "http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi?"
+ if ( StringHasNoText(prefix) &&
+ StringHasNoText(string) &&
+ StringHasNoText(suffix) ) return;
-static Char link_fly [MAX_WWWBUF];
-#define DEF_LINK_FLY "http://flybase.bio.indiana.edu/.bin/fbidq.html?"
+ if (StringNICmp (string, "tRNA-", 5) == 0) {
+ str = string+5;
+ }
-static Char link_fly_fban [MAX_WWWBUF];
-#define DEF_LINK_FBAN "http://www.fruitfly.org/cgi-bin/annot/fban?"
+ while ( foundPos >= 0 && !wholeWord ) {
+ foundPos = FFStringSearch(unique, str, foundPos);
+ if ( foundPos >= 0 ) {
+ wholeWord = IsWholeWordSubstr(unique, foundPos, str);
+ foundPos += StringLen(str);
+ }
+ }
-static Char link_fly_fbgn [MAX_WWWBUF];
-#define DEF_LINK_FBGN "http://flybase.bio.indiana.edu/.bin/fbidq.html?"
+ if ( foundPos < 0 || !wholeWord ) {
+ FFAddTextToString(unique, prefix, string, suffix, FALSE, FALSE, TILDE_IGNORE);
+ }
+}
-static Char link_cog [MAX_WWWBUF];
-#define DEF_LINK_COG "http://www.ncbi.nlm.nih.gov/cgi-bin/COG/palox?"
-static Char link_sgd [MAX_WWWBUF];
-#define DEF_LINK_SGD "/cgi-bin/Entrez/referer?http://genome-www4.stanford.edu/cgi-bin/SGD/locus.pl?locus="
-static Char link_gdb [MAX_WWWBUF];
-#define DEF_LINK_GDB "http://gdbwww.gdb.org/gdb-bin/genera/genera/hgd/DBObject/GDB:"
+/* s_AddPeriodToEnd () -- Adds a '.' to the end of a given string if */
+/* there is not already one there. */
+/* */
+/* Note that this adds one character to the */
+/* length of the string, leading to a */
+/* memory overrun if space was not previously */
+/* allocated for this. */
-static Char link_ck [MAX_WWWBUF];
-#define DEF_LINK_CK "http://flybane.berkeley.edu/cgi-bin/cDNA/CK_clone.pl?db=CK&dbid="
+NLM_EXTERN void s_AddPeriodToEnd (CharPtr someString)
+{
+ Int4 len;
-static Char link_rice [MAX_WWWBUF];
-#define DEF_LINK_RICE "http://ars-genome.cornell.edu/cgi-bin/WebAce/webace?db=ricegenes&class=Marker&object="
+ if (StringHasNoText (someString)) return;
+ len = StringLen (someString);
+ if (len < 1) return;
+ if (someString[len-1] != '.')
+ {
+ someString[len] = '.';
+ someString[len+1] = '\0';
+ }
+}
-static Char link_sp [MAX_WWWBUF];
-#define DEF_LINK_SP "/cgi-bin/Entrez/referer?http://expasy.hcuge.ch/cgi-bin/sprot-search-ac%3f"
+/* s_RemovePeriodFromEnd () -- If the last character in a given */
+/* string is a '.', removes it. */
-static Char link_pdb [MAX_WWWBUF];
-#define DEF_LINK_PDB "/cgi-bin/Entrez/referer?http://expasy.hcuge.ch/cgi-bin/get-pdb-entry%3f"
+NLM_EXTERN Boolean s_RemovePeriodFromEnd (CharPtr someString)
+{
+ Int4 len;
-static Char link_UniSTS [MAX_WWWBUF];
-#define DEF_LINK_UniSTS "http://www.ncbi.nlm.nih.gov/genome/sts/sts.cgi?uid="
+ if (StringHasNoText (someString)) return FALSE;
+ len = StringLen (someString);
+ if (len < 1) return FALSE;
+ if (someString[len-1] == '.') {
+ someString[len-1] = '\0';
+ return TRUE;
+ }
+ return FALSE;
+}
-static Char link_dbSTS [MAX_WWWBUF];
-#define DEF_LINK_dbSTS "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?"
+/**/
+/* isEllipsis () - Determines if a string ends in an ellipses */
+/**/
-static Char link_dbEST [MAX_WWWBUF];
-#define DEF_LINK_dbEST "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?"
+NLM_EXTERN Boolean IsEllipsis (
+ CharPtr str
+)
-static Char link_omim [MAX_WWWBUF];
-#define DEF_LINK_OMIM "http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id="
+{
+ size_t len;
+ CharPtr ptr;
-static Char link_locus [MAX_WWWBUF];
-#define DEF_LINK_LOCUS "http://www.ncbi.nlm.nih.gov/LocusLink/LocRpt.cgi?l="
+ if (StringHasNoText (str)) return FALSE;
+ len = StringLen (str);
+ if (len < 3) return FALSE;
+ ptr = str + len - 3;
+ return (Boolean) (ptr [0] == '.' && ptr [1] == '.' && ptr [2] == '.');
+}
-static Char link_snp [MAX_WWWBUF];
-#define DEF_LINK_SNP "http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?type=rs&rs="
+NLM_EXTERN void A2GBSeqLocReplaceID (
+ SeqLocPtr newloc,
+ SeqLocPtr ajpslp
+)
-static Char link_ratmap [MAX_WWWBUF];
-#define DEF_LINK_RATMAP "http://ratmap.gen.gu.se/action.lasso?-database=RATMAPfmPro&-layout=Detail&-response=/RM/Detail+Format.html&-search&-recid="
+{
+ BioseqPtr bsp;
+ SeqIdPtr sip;
-static Char link_rgd [MAX_WWWBUF];
-#define DEF_LINK_RGD "http://rgd.mcw.edu/query/query.cgi?id="
+ bsp = BioseqFindFromSeqLoc (ajpslp);
+ if (bsp == NULL) return;
+ sip = SeqIdFindBest (bsp->id, 0);
+ SeqLocReplaceID (newloc, sip);
+}
-static Char link_mgd [MAX_WWWBUF];
-#define DEF_LINK_MGD "http://www.informatics.jax.org/searches/accession_report.cgi?id=MGI:"
+NLM_EXTERN CharPtr asn2gb_PrintDate (
+ DatePtr dp
+)
-static Char link_cdd [MAX_WWWBUF];
-#define DEF_LINK_CDD "http://www.ncbi.nlm.nih.gov/Structure/cdd/cddsrv.cgi?uid="
+{
+ Char buf [30];
+ size_t len;
-static Char link_niaest [MAX_WWWBUF];
-#define DEF_LINK_NIAEST "http://lgsun.grc.nia.nih.gov/cgi-bin/pro3?sname1="
+ if (dp == NULL) return NULL;
-static Char link_worm_base [MAX_WWWBUF];
-#define DEF_LINK_WORM_BASE "http://www.wormbase.org/db/get?class=Sequence;name="
+ if (DatePrint (dp, buf)) {
+ if (StringICmp (buf, "Not given") != 0) {
+ len = StringLen (buf);
+ if (len > 0) {
+ if (buf [len - 1] == '\n') {
+ if (buf [len - 2] == '.') {
+ buf [len - 2] = '\0';
+ } else {
+ buf [len - 1] = '\0';
+ }
+ }
+ }
+ return StringSave (buf);
+ }
+ }
-static Char link_worfdb [MAX_WWWBUF];
-#define DEF_LINK_WORFDB "http://worfdb.dfci.harvard.edu/search.pl?form=1&search="
+ return NULL;
+}
-static Char link_nextdb [MAX_WWWBUF];
-#define DEF_LINK_NEXTDB "http://nematode.lab.nig.ac.jp/cgi-bin/db/ShowGeneInfo.sh?celk="
+static CharPtr month_names [] = {
+ "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
+ "JUL", "AUG", "SEP", "OCT", "NOV", "DEC",
+ "??"
+};
-static Char link_imgt [MAX_WWWBUF];
-#define DEF_LINK_IMGT "http://imgt.cines.fr:8104/cgi-bin/IMGTlect.jv?query=202+"
+NLM_EXTERN CharPtr DateToFF (
+ CharPtr buf,
+ DatePtr dp,
+ Boolean citSub
+)
-static Char link_ifo [MAX_WWWBUF];
-#define DEF_LINK_IFO "http://www.ifo.or.jp/index_e.html"
+{
+ Int2 day;
+ Int2 month;
+ Int2 year;
-static Char link_jcm [MAX_WWWBUF];
-#define DEF_LINK_JCM "http://www.jcm.riken.go.jp/cgi-bin/jcm/jcm_number?JCM="
+ if (buf != NULL) {
+ *buf = '\0';
+ }
+ if (dp == NULL) return NULL;
-static Char link_isfinder [MAX_WWWBUF];
-#define DEF_LINK_ISFINDER "http://www-is.biotoul.fr/scripts/is/is_spec.idc?name="
+ if (dp->data [0] == 0) {
-static Char link_gabi [MAX_WWWBUF];
-#define DEF_LINK_GABI "https://gabi.rzpd.de/cgi-bin-protected/GreenCards.pl.cgi?Mode=ShowBioObject&BioObjectName="
+ StringCpy (buf, dp->str);
-static Char link_fantom [MAX_WWWBUF];
-#define DEF_LINK_FANTOM "http://fantom.gsc.riken.go.jp/db/view/main.cgi?masterid="
+ } else if (dp->data [0] == 1) {
-static Char link_interpro [MAX_WWWBUF];
-#define DEF_LINK_INTERPRO "http://www.ebi.ac.uk/interpro/ISearch?mode=ipr&query="
+ year = 1900 + (Int2) dp->data [1];
+ month = (Int2) dp->data [2];
+ day = (Int2) dp->data [3];
-static Char link_genedb [MAX_WWWBUF];
-#define DEF_LINK_GENEDB "http://www.genedb.org/genedb/Dispatcher?formType=navBar&submit=Search+for&organism=All%3Apombe%3Acerevisiae%3Adicty%3Aasp%3Atryp%3Aleish%3Amalaria%3Astyphi%3Aglossina&desc=yes&ohmr=%2F&name="
+ if (citSub) {
+ if (month < 1 || month > 12) {
+ month = 13;
+ }
+ if (day < 1 || day > 31) {
+ day = 0;
+ }
+ } else {
+ if (month < 1 || month > 12) {
+ month = 1;
+ }
+ if (day < 1 || day > 31) {
+ day = 1;
+ }
+ }
-static Char link_zfin [MAX_WWWBUF];
-#define DEF_LINK_ZFIN "http://zfin.org/cgi-bin/webdriver?MIval=aa-markerview.apg&OID="
+ if (day < 1) {
+ sprintf (buf, "??-%s-%ld",
+ month_names [month-1], (long) year);
+ } else if (day < 10) {
+ sprintf (buf, "0%ld-%s-%ld",
+ (long) day, month_names [month-1], (long) year);
+ } else {
+ sprintf(buf, "%ld-%s-%ld",
+ (long) day, month_names [month-1], (long) year);
+ }
+ }
-static Char link_rebase [MAX_WWWBUF];
-#define DEF_LINK_REBASE "http://rebase.neb.com/rebase/enz/"
+ return buf;
+}
-/* utility functions */
-static StringItemPtr FFGetString (IntAsn2gbJobPtr ajp)
+NLM_EXTERN StringItemPtr FFGetString (IntAsn2gbJobPtr ajp)
{
StringItemPtr sip;
@@ -1260,7 +401,7 @@ static StringItemPtr FFGetString (IntAsn2gbJobPtr ajp)
return sip;
}
-static void FFRecycleString (IntAsn2gbJobPtr ajp, StringItemPtr ffstring)
+NLM_EXTERN void FFRecycleString (IntAsn2gbJobPtr ajp, StringItemPtr ffstring)
{
StringItemPtr nxt;
@@ -1280,7 +421,7 @@ static void FFRecycleString (IntAsn2gbJobPtr ajp, StringItemPtr ffstring)
ffstring->curr = NULL;
}
-static void FFAddOneChar (
+NLM_EXTERN void FFAddOneChar (
StringItemPtr sip,
Char ch,
Boolean convertQuotes
@@ -1302,11 +443,11 @@ static void FFAddOneChar (
current->pos++;
}
-static void FFAddNewLine(StringItemPtr ffstring) {
+NLM_EXTERN void FFAddNewLine(StringItemPtr ffstring) {
FFAddOneChar(ffstring, '\n', FALSE);
}
-static void FFAddNChar (
+NLM_EXTERN void FFAddNChar (
StringItemPtr sip,
Char ch,
Int4 n,
@@ -1321,7 +462,7 @@ static void FFAddNChar (
}
-static void FFExpandTildes (StringItemPtr sip, CharPtr PNTR cpp) {
+NLM_EXTERN void FFExpandTildes (StringItemPtr sip, CharPtr PNTR cpp) {
Char replace = **cpp;
if ( **cpp == '~' ) {
@@ -1337,7 +478,7 @@ static void FFExpandTildes (StringItemPtr sip, CharPtr PNTR cpp) {
}
-static void FFReplaceTildesWithSpaces (StringItemPtr ffstring, CharPtr PNTR cpp) {
+NLM_EXTERN void FFReplaceTildesWithSpaces (StringItemPtr ffstring, CharPtr PNTR cpp) {
Char replace = **cpp, lookahead;
CharPtr cptr = *cpp;
@@ -1363,7 +504,7 @@ static void FFReplaceTildesWithSpaces (StringItemPtr ffstring, CharPtr PNTR cpp)
FFAddOneChar(ffstring, replace, FALSE);
}
-static void FFOldExpand (StringItemPtr sip, CharPtr PNTR cpp) {
+NLM_EXTERN void FFOldExpand (StringItemPtr sip, CharPtr PNTR cpp) {
/* "~" -> "\n", "~~" or "~~ ~~" -> "\n\n" */
CharPtr cp = *cpp;
Char current = *cp;
@@ -1399,7 +540,44 @@ static void FFOldExpand (StringItemPtr sip, CharPtr PNTR cpp) {
}
}
-static void AddStringWithTildes (StringItemPtr ffstring, CharPtr string)
+NLM_EXTERN void AddCommentStringWithTildes (StringItemPtr ffstring, CharPtr string)
+{
+/* One "~" is a new line, "~~" or "~~ ~~" means 2 returns */
+
+ /* Int2 i; */
+
+ while (*string != '\0') {
+ if (*string == '`' && *(string+1) == '~') {
+ FFAddOneChar(ffstring, '~', FALSE);
+ string += 2;
+ } else if (*string == '~') {
+ FFAddOneChar(ffstring, '\n', FALSE);
+ string++;
+ if (*string == '~') {
+ /*
+ for (i = 0; i < 12; i++) {
+ FFAddOneChar(ffstring, ' ', FALSE);
+ }
+ */
+ FFAddOneChar(ffstring, '\n', FALSE);
+ string++;
+ if (*string == ' ' && *(string+1) == '~' && *(string+2) == '~') {
+ string += 3;
+ }
+ }
+ } else if (*string == '\"') {
+ *string = '\'';
+ FFAddOneChar(ffstring, *string, FALSE);
+ string++;
+ } else {
+ FFAddOneChar(ffstring, *string, FALSE);
+ string++;
+ }
+ }
+} /* AddCommentStringWithTildes */
+
+
+NLM_EXTERN void AddStringWithTildes (StringItemPtr ffstring, CharPtr string)
{
/* One "~" is a new line, "~~" or "~~ ~~" means 2 returns */
@@ -1429,7 +607,7 @@ static void AddStringWithTildes (StringItemPtr ffstring, CharPtr string)
} /* AddStringWithTildes */
-static void FFProcessTildes (StringItemPtr sip, CharPtr PNTR cpp, Int2 tildeAction) {
+NLM_EXTERN void FFProcessTildes (StringItemPtr sip, CharPtr PNTR cpp, Int2 tildeAction) {
switch (tildeAction) {
@@ -1452,7 +630,7 @@ static void FFProcessTildes (StringItemPtr sip, CharPtr PNTR cpp, Int2 tildeActi
}
}
-static void FFAddPeriod (StringItemPtr sip) {
+NLM_EXTERN void FFAddPeriod (StringItemPtr sip) {
Int4 i;
Char ch = '\0';
StringItemPtr riter = sip->curr, prev;
@@ -1491,7 +669,7 @@ static void FFAddPeriod (StringItemPtr sip) {
}
}
-static void FFAddOneString (
+NLM_EXTERN void FFAddOneString (
StringItemPtr sip,
CharPtr string,
Boolean addPeriod,
@@ -1517,10 +695,7 @@ static void FFAddOneString (
}
}
-static Boolean GetWWW (IntAsn2gbJobPtr ajp);
-static Boolean FFIsStartOfLink (StringItemPtr iter, Int4 pos);
-
-static void FFCatenateSubString (
+NLM_EXTERN void FFCatenateSubString (
StringItemPtr dest,
StringItemPtr start_sip, Int4 start_pos,
StringItemPtr end_sip, Int4 end_pos
@@ -1596,7 +771,7 @@ static void FFCatenateSubString (
}
-static CharPtr FFToCharPtr (StringItemPtr sip) {
+NLM_EXTERN CharPtr FFToCharPtr (StringItemPtr sip) {
Int4 size = 0, i;
StringItemPtr iter;
CharPtr result, temp;
@@ -1623,7 +798,7 @@ static CharPtr FFToCharPtr (StringItemPtr sip) {
/* word wrap functions */
-static void FFSkipLink (StringItemPtr PNTR iterp, Int4Ptr ip) {
+NLM_EXTERN void FFSkipLink (StringItemPtr PNTR iterp, Int4Ptr ip) {
StringItemPtr iter = *iterp;
Int4 i = *ip;
@@ -1645,14 +820,13 @@ static void FFSkipLink (StringItemPtr PNTR iterp, Int4Ptr ip) {
*ip = i;
}
-static Boolean FFIsStartOfLink (StringItemPtr iter, Int4 pos) {
+NLM_EXTERN Boolean FFIsStartOfLink (StringItemPtr iter, Int4 pos) {
static CharPtr start_link = "<A HREF";
static CharPtr end_link = "</A>";
Int4 start_len = StringLen(start_link);
Int4 end_len = StringLen(end_link);
Char temp[10];
Int4 i;
- StringItemPtr current = NULL;
if ( iter == NULL || pos >= iter->pos ) return FALSE;
if ( iter->buf[pos] != '<' ) return FALSE;
@@ -1683,13 +857,13 @@ static Boolean FFIsStartOfLink (StringItemPtr iter, Int4 pos) {
}
-static void FFSavePosition(StringItemPtr ffstring, StringItemPtr PNTR bufptr, Int4 PNTR posptr) {
+NLM_EXTERN void FFSavePosition(StringItemPtr ffstring, StringItemPtr PNTR bufptr, Int4 PNTR posptr) {
*bufptr = ffstring->curr;
*posptr = ffstring->curr->pos;
}
-static void FFTrim (
+NLM_EXTERN void FFTrim (
StringItemPtr ffstring,
StringItemPtr line_start,
Int4 line_pos,
@@ -1752,7 +926,8 @@ static void FFTrim (
/* already exists in the line, in such case we break at the 'new-line' */
/* spaces, dashes and new-lines will be broken at that character wheras for */
/* commas we break at the character following the comma. */
-static void FFCalculateLineBreak (
+
+NLM_EXTERN void FFCalculateLineBreak (
StringItemPtr PNTR break_sip, Int4 PNTR break_pos,
Int4 init_indent, Int4 visible
)
@@ -1876,7 +1051,7 @@ static void FFCalculateLineBreak (
}
}
-static void FFLineWrap (
+NLM_EXTERN void FFLineWrap (
StringItemPtr dest,
StringItemPtr src,
Int4 init_indent,
@@ -1935,7 +1110,7 @@ static void FFLineWrap (
/* === */
-static void FFStartPrint (
+NLM_EXTERN void FFStartPrint (
StringItemPtr sip,
FmtType format,
Int4 gb_init_indent,
@@ -1962,7 +1137,7 @@ static void FFStartPrint (
}
}
-static void FFAddTextToString (
+NLM_EXTERN void FFAddTextToString (
StringItemPtr ffstring,
CharPtr prefix,
CharPtr string,
@@ -1983,7 +1158,7 @@ static void FFAddTextToString (
}
-static CharPtr FFEndPrint (
+NLM_EXTERN CharPtr FFEndPrint (
IntAsn2gbJobPtr ajp,
StringItemPtr ffstring,
FmtType format,
@@ -2010,7 +1185,7 @@ static CharPtr FFEndPrint (
return result;
}
-static Uint4 FFLength(StringItemPtr ffstring) {
+NLM_EXTERN Uint4 FFLength(StringItemPtr ffstring) {
Uint4 len = 0;
StringItemPtr current;
@@ -2022,7 +1197,7 @@ static Uint4 FFLength(StringItemPtr ffstring) {
}
-static Char FFCharAt(StringItemPtr ffstring, Uint4 pos) {
+NLM_EXTERN Char FFCharAt(StringItemPtr ffstring, Uint4 pos) {
Uint4 count = 0, inbufpos;
StringItemPtr current = NULL;
@@ -2041,7 +1216,7 @@ static Char FFCharAt(StringItemPtr ffstring, Uint4 pos) {
}
-static Char FFFindChar (
+NLM_EXTERN Char FFFindChar (
StringItemPtr ffstring, /* StringItem to search in */
StringItemPtr start_buf, /* the position of the last char searched for (buffer) */
Uint4 start_pos, /* the position of the last char searched for (pos) */
@@ -2086,7 +1261,7 @@ static Char FFFindChar (
return result;
}
-static Boolean FFEmpty(StringItemPtr ffstring) {
+NLM_EXTERN Boolean FFEmpty(StringItemPtr ffstring) {
if ( ffstring != NULL && ffstring->pos != 0 ) {
return FALSE;
}
@@ -2182,7 +1357,7 @@ static void ComputeGoodSuffix(const CharPtr pattern, Uint4 good_suffix[])
* searches for a pattern in a StringItem.
* Using the Boyer-Moore algorithm for the search.
*/
-static Int4 FFStringSearch (
+NLM_EXTERN Int4 FFStringSearch (
StringItemPtr text,
const CharPtr pattern,
Uint4 position )
@@ -2227,7 +1402,8 @@ static Int4 FFStringSearch (
/* word or phrase -- i.e. is it both */
/* preceded and followed by white space. */
/* */
-static Boolean IsWholeWordSubstr (
+
+NLM_EXTERN Boolean IsWholeWordSubstr (
StringItemPtr searchStr,
Uint4 foundPos,
CharPtr subStr
@@ -2258,8576 +1434,9 @@ static Boolean IsWholeWordSubstr (
}
-/* www utility functions */
-
-static Boolean GetWWW (IntAsn2gbJobPtr ajp) {
- return ajp->www;
-}
-
-static void FiniWWW (IntAsn2gbJobPtr ajp) {
- ajp->www = FALSE;
-}
-
-static void InitWWW (IntAsn2gbJobPtr ajp)
-{
- ajp->www = TRUE;
-
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_FEAT", DEF_LINK_FEAT, link_feat, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_WGS", DEF_LINK_WGS, link_wgs, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_OMIM", DEF_LINK_OMIM, link_omim, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_REF", DEF_LINK_REF, ref_link, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_NT", DEF_LINK_NT, nt_link, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_DOC", DEF_LINK_DOC, doc_link, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_EV", DEF_LINK_EV, ev_link, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_EC", DEF_LINK_EC, ec_link, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_FF", DEF_LINK_FF, link_ff, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_MUID", DEF_LINK_MUID, link_muid, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_FF", DEF_LINK_FF, link_ff, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_MUID", DEF_LINK_MUID, link_muid, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_ACE", DEF_LINK_ACE, link_ace, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_TAX", DEF_LINK_TAX, link_tax, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_CODE", DEF_LINK_CODE, link_code, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_FLY", DEF_LINK_FLY, link_fly, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_COG", DEF_LINK_COG, link_cog, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SGD", DEF_LINK_SGD, link_sgd, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SGD", DEF_LINK_GDB, link_gdb, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_CK", DEF_LINK_CK, link_ck, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_RICE", DEF_LINK_RICE, link_rice, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SP", DEF_LINK_SP, link_sp, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_PDB", DEF_LINK_PDB, link_pdb, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_OMIM", DEF_LINK_OMIM, link_omim, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_UniSTS", DEF_LINK_UniSTS, link_UniSTS, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_dbSTS", DEF_LINK_dbSTS, link_dbSTS, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_dbEST", DEF_LINK_dbEST, link_dbEST, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_LOCUS", DEF_LINK_LOCUS, link_locus, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_SNP", DEF_LINK_SNP, link_snp, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_RATMAP", DEF_LINK_RATMAP, link_ratmap, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_RGD", DEF_LINK_RGD, link_rgd, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_MGD", DEF_LINK_MGD, link_mgd, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_FBGN", DEF_LINK_FBGN, link_fly_fbgn, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_FBAN", DEF_LINK_FBAN, link_fly_fban, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_CDD", DEF_LINK_CDD, link_cdd, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_NIAEST", DEF_LINK_NIAEST, link_niaest, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_WORM_BASE", DEF_LINK_WORM_BASE, link_worm_base, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_WORFDB", DEF_LINK_WORFDB, link_worfdb, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_NEXTDB", DEF_LINK_NEXTDB, link_nextdb, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_IMGT", DEF_LINK_IMGT, link_imgt, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_IFO", DEF_LINK_IFO, link_ifo, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_JCM", DEF_LINK_JCM, link_jcm, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_ISFINDER", DEF_LINK_ISFINDER, link_isfinder, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_GABI", DEF_LINK_GABI, link_gabi, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_FANTOM", DEF_LINK_FANTOM, link_fantom, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_INTERPRO", DEF_LINK_INTERPRO, link_interpro, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_GENEDB", DEF_LINK_GENEDB, link_genedb, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_ZFIN", DEF_LINK_ZFIN, link_zfin, MAX_WWWBUF);
- GetAppParam ("NCBI", "WWWENTREZ", "LINK_REBASE", DEF_LINK_REBASE, link_rebase, MAX_WWWBUF);
-}
-
-
-static void FF_www_gcode (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr gcode
-)
-{
-
- if ( GetWWW(ajp) ) {
- FFAddOneString(ffstring, "<a href=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, link_code, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "mode=c#SG", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, gcode, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '>', FALSE);
- FFAddOneString(ffstring, gcode, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, gcode, FALSE, FALSE, TILDE_IGNORE);
- }
-}
-
-static void FF_AddECnumber (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr str
-)
-{
- if ( GetWWW(ajp) ) {
- FFAddOneString(ffstring, "<a href=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, ec_link, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '>', FALSE);
- FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- }
-}
-
-
-
-static void FF_www_featloc(StringItemPtr ffstring, CharPtr loc)
-{
- CharPtr ptr;
-
- if (loc == NULL) return;
-
- for ( ptr = loc; *ptr != '\0'; ++ptr ) {
- switch (*ptr) {
- case '<' :
- /*FFAddOneString(ffstring, "<", FALSE, FALSE, TILDE_IGNORE);*/
- FFAddOneString(ffstring, "&lt;", FALSE, FALSE, TILDE_IGNORE);
- break;
- case '>' :
- /*FFAddOneString(ffstring, ">", FALSE, FALSE, TILDE_IGNORE);*/
- FFAddOneString(ffstring, "&gt;", FALSE, FALSE, TILDE_IGNORE);
- break;
- default:
- FFAddOneChar(ffstring, *ptr, FALSE);
- break;
- }
- }
-}
-
-
-static void FF_www_db_xref_std (
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier,
- CharPtr link
-)
-{
- while (*identifier == ' ')
- identifier++;
-
- FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "<a href=", link, identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, ">", identifier, "</a>", FALSE, FALSE, TILDE_IGNORE);
-}
-
-static void FF_www_db_xref_fly (
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- CharPtr link = link_fly;
-
- if ( StringStr(identifier, "FBa") != NULL ) {
- link = link_fly_fban;
- }
- if ( StringStr(identifier, "FBg") != NULL ) {
- link = link_fly_fbgn;
- }
-
- FF_www_db_xref_std(ffstring, db, identifier, link);
-}
-
-static void FF_www_db_xref_mgd (
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- if (StringNICmp (identifier, "MGI:", 4) == 0) {
- identifier += 4;
- }
-
- FF_www_db_xref_std(ffstring, "MGI", identifier, link_mgd);
-}
-
-static void FF_www_db_xref_pid(
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- if ( *identifier != 'g' ) {
- FF_www_db_xref_std(ffstring, db, identifier, link_seq);
- return;
- }
- ++identifier;
-
- FFAddTextToString(ffstring, NULL, db, ":g", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "<a href=", link_seq, "val=", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, identifier, ">", identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
-}
-
-/*prefix = "<a href=%sval=gnl|dbest|%s>"; */
-static void FF_www_db_xref_dbEST(
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- while (*identifier == ' ')
- identifier++;
-
- FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "<a href=", link_dbEST, "val=gnl|dbest|", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, identifier, ">", identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
-}
-
-static void FF_www_db_xref_dbSTS(
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- while (*identifier == ' ')
- identifier++;
-
- FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "<a href=", link_dbSTS, "val=gnl|dbsst|", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, identifier, ">", identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
-}
-
-static void FF_www_db_xref_niaEST(
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- while (*identifier == ' ')
- identifier++;
-
- FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "<a href=", link_niaest, identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "&val=1>", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
-}
-
-
-static void FF_www_db_xref_ifo(
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- while (*identifier == ' ')
- identifier++;
-
- FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "<a href=", link_ifo, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
-}
-
-
-static void FF_www_db_xref_gdb(
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- CharPtr start;
- Char id[20], PNTR idp = id;
-
- FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
-
- if ( (start = StringStr(identifier, "G00-")) != NULL ) {
- /* G00-id-id */
- start += StringLen("G00-");
- while ( *start != '\0' ) {
- if ( *start != '-' ) {
- *idp++ = *start++;
- } else {
- *start++;
- }
- }
- *idp = '\0';
- FFAddTextToString(ffstring, "<a href=", link_gdb, id, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, ">", identifier, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else if ( IS_DIGIT(*identifier) ) {
- /* id */
- FFAddTextToString(ffstring, "<a href=", link_gdb, identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, ">", identifier, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, identifier, FALSE, FALSE, TILDE_IGNORE);
- }
-}
-
-static void FF_www_db_xref_rebase (
- StringItemPtr ffstring,
- CharPtr db,
- CharPtr identifier
-)
-{
- while (*identifier == ' ')
- identifier++;
-
- FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "<a href=", link_rebase, identifier, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, ".html>", identifier, "</a>", FALSE, FALSE, TILDE_IGNORE);
-}
-
-
-static void Do_www_db_xref(
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr db, CharPtr identifier
-)
-{
- if ( ffstring == NULL || db == NULL || identifier == NULL ) return;
-
- if ( StringCmp(db, "FLYBASE") == 0) {
- FF_www_db_xref_fly(ffstring, db, identifier);
- } else if ( StringCmp(db , "COG") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_cog);
- } else if ( StringCmp(db , "UniSTS") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_UniSTS);
- } else if ( StringCmp(db , "LocusID") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_locus);
- } else if ( StringCmp(db , "InterimID") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_locus);
- } else if ( StringCmp(db , "MIM") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_omim);
- } else if ( StringCmp(db , "SGD") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_sgd);
- } else if ( StringCmp(db , "IMGT/LIGM") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_imgt);
- } else if ( StringCmp(db , "CK") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_ck);
- } else if ( StringCmp(db , "RiceGenes") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_rice);
- } else if ( StringCmp(db , "dbSNP") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_snp);
- } else if ( StringCmp(db , "RATMAP") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_ratmap);
- } else if ( StringCmp(db , "RGD") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_rgd);
- } else if ( StringCmp(db , "MGD") == 0) {
- FF_www_db_xref_mgd(ffstring, db, identifier);
- } else if ( StringCmp(db , "CDD") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_cdd);
- } else if ( StringCmp(db , "JCM") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_jcm);
- } else if ( StringCmp(db , "ISFinder") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_isfinder);
- } else if ( StringCmp(db , "GABI") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_gabi);
- } else if ( StringCmp(db , "ZFIN") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_zfin);
- } else if ( StringCmp(db , "FANTOM_DB") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_fantom);
- } else if ( StringCmp(db , "Interpro") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_interpro);
- } else if ( StringCmp(db , "GeneDB") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_genedb);
- } else if ( StringCmp(db , "PID") == 0) {
- FF_www_db_xref_pid(ffstring, db, identifier);
- } else if ( StringCmp(db , "dbEST") == 0) {
- FF_www_db_xref_dbEST(ffstring, db, identifier);
- } else if ( StringCmp(db , "dbSTS") == 0) {
- FF_www_db_xref_dbSTS(ffstring, db, identifier);
- } else if ( StringCmp(db , "niaEST") == 0) {
- FF_www_db_xref_niaEST(ffstring, db, identifier);
- } else if ( StringCmp(db , "WormBase") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_worm_base);
- } else if ( StringCmp(db , "AceView/WormGenes") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_ace);
- } else if ( StringCmp(db , "WorfDB") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_worfdb);
- } else if ( StringCmp(db , "NextDB") == 0) {
- FF_www_db_xref_std(ffstring, db, identifier, link_nextdb);
- } else if ( StringCmp(db , "IFO") == 0) {
- FF_www_db_xref_ifo(ffstring, db, identifier);
- } else if ( StringCmp(db , "GDB") == 0) {
- FF_www_db_xref_gdb(ffstring, db, identifier);
- } else if ( StringCmp(db , "REBASE") == 0) {
- FF_www_db_xref_rebase(ffstring, db, identifier);
-
- } else {
- /* default: no link just the text */
- FFAddTextToString(ffstring, db, ":", identifier, FALSE, FALSE, TILDE_IGNORE);
- }
-}
-
-static void FF_www_db_xref(
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr db, CharPtr identifier
-)
-{
- if ( ffstring == NULL || db == NULL || identifier == NULL ) return;
-
- if ( GetWWW(ajp) ) {
- Do_www_db_xref (ajp, ffstring, db, identifier);
- } else { /* not in www mode */
- if (StringCmp(db , "MGD") == 0) {
- if (StringNICmp (identifier, "MGI:", 4) == 0) {
- identifier += 4;
- }
- FFAddTextToString(ffstring, "MGI", ":", identifier, FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddTextToString(ffstring, db, ":", identifier, FALSE, FALSE, TILDE_IGNORE);
- }
- }
-}
-
-/* public function to get URLs for collaboration-approved db_xrefs */
-
-static Boolean links_loaded = FALSE;
-
-NLM_EXTERN CharPtr asn2gnbk_dbxref (
- DbtagPtr dbt
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Char buf [80];
- StringItemPtr ffstring;
- ObjectIdPtr oip;
- CharPtr ptr;
- CharPtr str;
- CharPtr tmp;
-
- if (dbt == NULL) return NULL;
- if (StringHasNoText (dbt->db)) return NULL;
- oip = dbt->tag;
- if (oip == NULL) return NULL;
-
- if (! StringHasNoText (oip->str)) {
- if (StringLen (dbt->db) + StringLen (oip->str) < 80) {
- sprintf (buf, "%s", oip->str);
- }
- } else {
- sprintf (buf, "%ld", (long) oip->id);
- }
-
- ajp = (IntAsn2gbJobPtr) MemNew (sizeof (IntAsn2gbJob));
- if (ajp == NULL) return NULL;
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return NULL;
-
- if (! links_loaded) {
- InitWWW (ajp);
- links_loaded = TRUE;
- }
- ajp->www = TRUE;
-
- Do_www_db_xref (ajp, ffstring, dbt->db, buf);
-
- ajp->www = FALSE;
-
- str = FFToCharPtr (ffstring);
-
- FFRecycleString (ajp, ffstring);
- MemFree (ajp);
-
- tmp = StringChr (str, '<');
- if (tmp != NULL) {
- ptr = StringSave (tmp);
- tmp = StringChr (ptr, '>');
- if (tmp != NULL) {
- tmp++;
- *tmp = '\0';
- }
- MemFree (str);
- str = ptr;
- } else {
- str = MemFree (str);
- }
-
- return str;
-}
-
-static void FF_www_protein_id(
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr seqid
-)
-{
-
- if ( GetWWW(ajp) ) {
- FFAddOneString(ffstring, "<a href=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, link_seq, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "val=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, seqid, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '>', FALSE);
- FFAddOneString(ffstring, seqid, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, seqid, FALSE, FALSE, TILDE_IGNORE);
- }
-}
-
-static void FF_www_muid(
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- Int4 muid
-)
-{
- Char numbuf[40];
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString(ffstring, "<a href=", link_muid, NULL, FALSE, FALSE, TILDE_IGNORE);
- sprintf(numbuf, "%ld", (long)muid);
- FFAddTextToString(ffstring, "uid=", numbuf, "&form=6&db=m&Dopt=r>", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, numbuf, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- sprintf(numbuf, "%ld", (long)muid);
- FFAddOneString(ffstring, numbuf, FALSE, FALSE, TILDE_IGNORE);
- }
-}
-
-static void FF_www_accession (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr cstring
-)
-{
- if (cstring == NULL || ffstring == NULL) return;
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "val=", cstring, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, cstring, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, cstring, FALSE, FALSE, TILDE_IGNORE);
- }
- return;
-}
-
-static CharPtr TxtSave (CharPtr text, size_t len)
-
-{
- CharPtr str = NULL;
-
- if ((text == NULL) || (len == 0))
- return str;
-
- str = MemNew((size_t)(len + 1));
- MemCopy(str, text, (size_t)len);
-
- return (str);
-}
-
-static Boolean FF_www_dbsource(
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr str,
- Boolean first,
- Uint1 choice
-)
-{
- CharPtr temp, end, text, loc, link=NULL;
- Int2 j;
-
- if( GetWWW(ajp) ) {
- if (choice == SEQID_PIR /*|| choice == SEQID_SWISSPROT */) {
- link = link_seq;
- } else if (choice == SEQID_PDB || choice == SEQID_PRF) {
- link = link_seq;
- } else if (choice == SEQID_EMBL || choice == SEQID_GENBANK ||
- choice == SEQID_DDBJ || choice == SEQID_GIBBSQ ||
- choice == SEQID_GIBBMT || choice == SEQID_GI ||
- choice == SEQID_GIIM || choice == SEQID_OTHER ||
- choice == SEQID_TPG || choice == SEQID_TPE || choice == SEQID_TPD) {
- link = link_seq;
- } else {
- AddStringWithTildes(ffstring, str);
- return TRUE;
- }
-
- if ((text = StringStr(str, "accession")) != NULL) {
- end = text + 9;
- j = 9;
- while (*end == ' ') {
- ++end;
- j++;
- }
- if (first == FALSE) {
- FFAddOneString(ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
- }
- loc = TxtSave (str, end-str - j);
- FFAddOneString(ffstring, loc, FALSE, FALSE, TILDE_IGNORE);
- MemFree (loc);
- for (; text != end; ++text ) {
- FFAddOneChar(ffstring, *text, FALSE);
- }
-
- temp = text;
- end += StringLen(text) - 1;
- if ( *end != ';' ) {
- ++end;
- }
-
- FFAddTextToString(ffstring, "<a href=", link, "val=", FALSE, FALSE, TILDE_IGNORE);
- for (text = temp; text != end; ++text ) {
- FFAddOneChar(ffstring, *text, FALSE);
- }
- FFAddOneString(ffstring, ">", FALSE, FALSE, TILDE_IGNORE);
-
- text = temp;
- FFAddOneString(ffstring, text, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- if (first == FALSE) {
- FFAddOneString(ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- }
- } else {
- AddStringWithTildes(ffstring, str);
- }
- return TRUE;
-}
-
-
-/* old utility functions */
-
-static ValNodePtr ValNodeCopyStrToHead (ValNodePtr PNTR head, Int2 choice, CharPtr str)
-
-{
- ValNodePtr newnode;
-
- if (head == NULL || str == NULL) return NULL;
-
- newnode = ValNodeNew (NULL);
- if (newnode == NULL) return NULL;
-
- newnode->choice = (Uint1) choice;
- newnode->data.ptrvalue = StringSave (str);
-
- newnode->next = *head;
- *head = newnode;
-
- return newnode;
-}
-
-/* the val node strings mechanism will be replaced by a more efficient method later */
-
-static CharPtr MergeValNodeStrings (
- ValNodePtr list
-)
-
-{
- size_t len;
- CharPtr ptr;
- CharPtr str;
- CharPtr tmp;
- ValNodePtr vnp;
-
-
- if (list == NULL) return NULL;
-
- for (vnp = list, len = 0; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- len += StringLen (str);
- }
- if (len == 0) return NULL;
-
- ptr = MemNew (sizeof (Char) * (len + 2));
- if (ptr == NULL) return NULL;
-
- for (vnp = list, tmp = ptr; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- tmp = StringMove (tmp, str);
- }
-
- return ptr;
-}
-
-
-static void AddValNodeString (
- ValNodePtr PNTR head,
- CharPtr prefix,
- CharPtr string,
- CharPtr suffix
-)
-
-{
- Char buf [256];
- CharPtr freeme = NULL;
- size_t len;
- CharPtr newstr;
- CharPtr strptr;
-
- len = StringLen (prefix) + StringLen (string) + StringLen (suffix);
- if (len == 0) return;
-
- if (len < sizeof (buf)) {
-
- /* if new string fits in stack buffer, no need to allocate */
-
- MemSet ((Pointer) buf, 0, sizeof (buf));
- newstr = buf;
-
- } else {
-
- /* new string bigger than stack buffer, so allocate sufficient string */
-
- newstr = (CharPtr) MemNew (sizeof (Char) * (len + 2));
- if (newstr == NULL) return;
-
- /* allocated string will be freed at end of function */
-
- freeme = newstr;
- }
-
- strptr = newstr;
-
- if (prefix != NULL) {
- strptr = StringMove (strptr, prefix);
- }
-
- if (string != NULL) {
- strptr = StringMove (strptr, string);
- }
-
- if (suffix != NULL) {
- strptr = StringMove (strptr, suffix);
- }
-
- /* currently just makes a valnode list, to be enhanced later */
-
- ValNodeCopyStr (head, 0, newstr);
-
- /* if large string was allocated, free it now */
-
- if (freeme != NULL) {
- MemFree (freeme);
- }
-}
-
-
-static void FFAddString_NoRedund (
- StringItemPtr unique,
- CharPtr prefix,
- CharPtr string,
- CharPtr suffix
-)
-{
- CharPtr str = string;
- Int4 foundPos = 0;
- Boolean wholeWord = FALSE;
-
- if ( StringHasNoText(prefix) &&
- StringHasNoText(string) &&
- StringHasNoText(suffix) ) return;
-
- if (StringNICmp (string, "tRNA-", 5) == 0) {
- str = string+5;
- }
-
- while ( foundPos >= 0 && !wholeWord ) {
- foundPos = FFStringSearch(unique, str, foundPos);
- if ( foundPos >= 0 ) {
- wholeWord = IsWholeWordSubstr(unique, foundPos, str);
- foundPos += StringLen(str);
- }
- }
-
- if ( foundPos < 0 || !wholeWord ) {
- FFAddTextToString(unique, prefix, string, suffix, FALSE, FALSE, TILDE_IGNORE);
- }
-}
-
-
-
-/* s_AddPeriodToEnd () -- Adds a '.' to the end of a given string if */
-/* there is not already one there. */
-/* */
-/* Note that this adds one character to the */
-/* length of the string, leading to a */
-/* memory overrun if space was not previously */
-/* allocated for this. */
-
-static void s_AddPeriodToEnd (CharPtr someString)
-{
- Int4 len;
-
- if (StringHasNoText (someString)) return;
- len = StringLen (someString);
- if (len < 1) return;
- if (someString[len-1] != '.')
- {
- someString[len] = '.';
- someString[len+1] = '\0';
- }
-}
-
-/* s_RemovePeriodFromEnd () -- If the last character in a given */
-/* string is a '.', removes it. */
-
-static Boolean s_RemovePeriodFromEnd (CharPtr someString)
-{
- Int4 len;
-
- if (StringHasNoText (someString)) return FALSE;
- len = StringLen (someString);
- if (len < 1) return FALSE;
- if (someString[len-1] == '.') {
- someString[len-1] = '\0';
- return TRUE;
- }
- return FALSE;
-}
-
-/**/
-/* isEllipsis () - Determines if a string ends in an ellipses */
-/**/
-
-static Boolean IsEllipsis (
- CharPtr str
-)
-
-{
- size_t len;
- CharPtr ptr;
-
- if (StringHasNoText (str)) return FALSE;
- len = StringLen (str);
- if (len < 3) return FALSE;
- ptr = str + len - 3;
- return (Boolean) (ptr [0] == '.' && ptr [1] == '.' && ptr [2] == '.');
-}
-
-static void A2GBSeqLocReplaceID (
- SeqLocPtr newloc,
- SeqLocPtr ajpslp
-)
-
-{
- BioseqPtr bsp;
- SeqIdPtr sip;
-
- bsp = BioseqFindFromSeqLoc (ajpslp);
- if (bsp == NULL) return;
- sip = SeqIdFindBest (bsp->id, 0);
- SeqLocReplaceID (newloc, sip);
-}
-
-static CharPtr asn2gb_PrintDate (
- DatePtr dp
-)
-
-{
- Char buf [30];
- size_t len;
-
- if (dp == NULL) return NULL;
-
- if (DatePrint (dp, buf)) {
- if (StringICmp (buf, "Not given") != 0) {
- len = StringLen (buf);
- if (len > 0) {
- if (buf [len - 1] == '\n') {
- if (buf [len - 2] == '.') {
- buf [len - 2] = '\0';
- } else {
- buf [len - 1] = '\0';
- }
- }
- }
- return StringSave (buf);
- }
- }
-
- return NULL;
-}
-
-static CharPtr month_names [] = {
- "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
- "JUL", "AUG", "SEP", "OCT", "NOV", "DEC",
- "??"
-};
-
-static CharPtr DateToGB (
- CharPtr buf,
- DatePtr dp,
- Boolean citSub
-)
-
-{
- Int2 day;
- Int2 month;
- Int2 year;
-
- if (buf != NULL) {
- *buf = '\0';
- }
- if (dp == NULL) return NULL;
-
- if (dp->data [0] == 0) {
-
- StringCpy (buf, dp->str);
-
- } else if (dp->data [0] == 1) {
-
- year = 1900 + (Int2) dp->data [1];
- month = (Int2) dp->data [2];
- day = (Int2) dp->data [3];
-
- if (citSub) {
- if (month < 1 || month > 12) {
- month = 13;
- }
- if (day < 1 || day > 31) {
- day = 0;
- }
- } else {
- if (month < 1 || month > 12) {
- month = 1;
- }
- if (day < 1 || day > 31) {
- day = 1;
- }
- }
-
- if (day < 1) {
- sprintf (buf, "??-%s-%ld",
- month_names [month-1], (long) year);
- } else if (day < 10) {
- sprintf (buf, "0%ld-%s-%ld",
- (long) day, month_names [month-1], (long) year);
- } else {
- sprintf(buf, "%ld-%s-%ld",
- (long) day, month_names [month-1], (long) year);
- }
- }
-
- return buf;
-}
-
-
-/* ********************************************************************** */
-
-/* format functions allocate printable string for given paragraph */
-
-static CharPtr DefaultFormatBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- if (afp == NULL || bbp == NULL) return NULL;
-
- /* default format function assumes string pre-allocated by add block function */
-
- return StringSaveNoNull (bbp->string);
-}
-
-/* superset of http://www.ncbi.nlm.nih.gov/collab/db_xref.html and RefSeq db_xrefs */
-
-static CharPtr legalDbXrefs [] = {
- "PIDe", "PIDd", "PIDg", "PID",
- "AceView/WormGenes",
- "ATCC",
- "ATCC(in host)",
- "ATCC(dna)",
- "BDGP_EST",
- "BDGP_INS",
- "CDD",
- "CK",
- "COG",
- "dbEST",
- "dbSNP",
- "dbSTS",
- "ENSEMBL",
- "ESTLIB",
- "FANTOM_DB",
- "FLYBASE",
- "GABI",
- "GDB",
- "GeneDB",
- "GeneID",
- "GI",
- "GO",
- "GOA",
- "IFO",
- "IMGT/LIGM",
- "IMGT/HLA",
- "InterimID",
- "Interpro",
- "ISFinder",
- "JCM",
- "LocusID",
- "MaizeDB",
- "MGD",
- "MGI",
- "MIM",
- "NextDB",
- "niaEST",
- "PIR",
- "PSEUDO",
- "RATMAP",
- "RiceGenes",
- "REMTREMBL",
- "RGD",
- "RZPD",
- "SGD",
- "SoyBase",
- "SPTREMBL",
- "SWISS-PROT",
- "taxon",
- "UniGene",
- "UniSTS",
- "WorfDB",
- "WormBase",
- "ZFIN",
- NULL
-};
-
-static CharPtr legalRefSeqDbXrefs [] = {
- "REBASE",
- NULL
-};
-
-static CharPtr organellePrefix [] = {
- NULL,
- NULL,
- "Chloroplast ",
- "Chromoplast ",
- "Kinetoplast ",
- "Mitochondrion ",
- "Plastid ",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- "Cyanelle ",
- NULL,
- NULL,
- "Nucleomorph ",
- "Apicoplast ",
- "Leucoplast ",
- "Proplastid ",
- NULL
-};
-
-static CharPtr newOrganellePrefix [] = {
- NULL,
- NULL,
- "chloroplast ",
- "chromoplast ",
- "kinetoplast ",
- "mitochondrion ",
- "plastid ",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- "cyanelle ",
- NULL,
- NULL,
- "nucleomorph ",
- "apicoplast ",
- "leucoplast ",
- "proplastid ",
- NULL
-};
-
-static CharPtr FormatSourceBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- CharPtr acr = NULL;
- Boolean addPeriod = TRUE;
- IntAsn2gbJobPtr ajp;
- CharPtr ana = NULL;
- Asn2gbSectPtr asp;
- BioSourcePtr biop = NULL;
- CharPtr com = NULL;
- CharPtr common = NULL;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- CharPtr gbacr = NULL;
- CharPtr gbana = NULL;
- GBBlockPtr gbp = NULL;
- GBSeqPtr gbseq;
- CharPtr gbsyn = NULL;
- Uint1 genome;
- ValNodePtr mod = NULL;
- OrgModPtr omp = NULL;
- OrgNamePtr onp;
- CharPtr organelle = NULL;
- OrgRefPtr orp;
- CharPtr prefix = " (";
- SeqDescrPtr sdp;
- CharPtr second = NULL;
- SeqFeatPtr sfp;
- CharPtr str;
- CharPtr syn = NULL;
- CharPtr taxname = NULL;
- Boolean using_anamorph = FALSE;
- StringItemPtr ffstring, temp;
-
- if (afp == NULL || bbp == NULL) return NULL;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
-
- if (! StringHasNoText (bbp->string)) return StringSave (bbp->string);
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return NULL;
-
- if (bbp->itemtype == OBJ_SEQDESC) {
- sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID, 0, NULL, &dcontext);
- if (sdp != NULL) {
- if (dcontext.seqdesctype == Seq_descr_source) {
- biop = (BioSourcePtr) sdp->data.ptrvalue;
- } else if (dcontext.seqdesctype == Seq_descr_genbank) {
- gbp = (GBBlockPtr) sdp->data.ptrvalue;
- }
- }
- } else if (bbp->itemtype == OBJ_SEQFEAT) {
- sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
- if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_BIOSRC) {
- biop = (BioSourcePtr) sfp->data.value.ptrvalue;
- }
- }
- if (gbp != NULL) {
- common = gbp->source;
- }
-
- if (biop != NULL) {
- genome = biop->genome;
- if (genome <= 19) {
- if (ajp->newSourceOrg && (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT)) {
- organelle = newOrganellePrefix [genome];
- } else {
- organelle = organellePrefix [genome];
- }
- }
- orp = biop->org;
- if (orp != NULL) {
- taxname = orp->taxname;
- common = orp->common;
- mod = orp->mod;
- onp = orp->orgname;
- if (onp != NULL) {
-
- if (ajp->newSourceOrg) {
- for (omp = onp->mod; omp != NULL; omp = omp->next) {
- switch (omp->subtype) {
- case ORGMOD_common :
- com = omp->subname;
- break;
- case ORGMOD_acronym :
- acr = omp->subname;
- break;
- case ORGMOD_synonym :
- syn = omp->subname;
- break;
- case ORGMOD_anamorph :
- ana = omp->subname;
- break;
- case ORGMOD_gb_acronym :
- gbacr = omp->subname;
- break;
- case ORGMOD_gb_anamorph :
- gbana = omp->subname;
- break;
- case ORGMOD_gb_synonym :
- gbsyn = omp->subname;
- break;
- default :
- break;
- }
- }
-
- if (StringHasNoText (second)) {
- second = syn;
- using_anamorph = FALSE;
- }
- if (StringHasNoText (second)) {
- second = acr;
- using_anamorph = FALSE;
- }
- if (StringHasNoText (second)) {
- second = ana;
- using_anamorph = TRUE;
- }
- if (StringHasNoText (second)) {
- second = com;
- using_anamorph = FALSE;
- }
-
- if (StringHasNoText (second)) {
- second = gbsyn;
- using_anamorph = FALSE;
- }
- if (StringHasNoText (second)) {
- second = gbacr;
- using_anamorph = FALSE;
- }
- if (StringHasNoText (second)) {
- second = gbana;
- using_anamorph = TRUE;
- }
-
- if (StringHasNoText (second)) {
- second = common;
- using_anamorph = FALSE;
- }
- if (using_anamorph) {
- prefix = " (anamorph: ";
- }
- }
- }
- }
- }
-
- /* If the organelle prefix is already on the */
- /* name, don't add it. */
-
- if (StringNCmp (organelle, taxname, StringLen (organelle)) == 0)
- organelle = "";
-
- if (StringHasNoText (common)) {
- common = taxname;
- }
- if (StringHasNoText (common)) {
- common = "Unknown.";
- }
- if (StringHasNoText (taxname)) {
- taxname = "Unknown.";
- }
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
-
- temp = FFGetString(ajp);
-
- if (ajp->newSourceOrg) {
-
- if (! StringHasNoText (organelle)) {
- FFAddTextToString(temp, NULL, organelle, NULL, FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddTextToString(temp, NULL, taxname, NULL, FALSE, FALSE, TILDE_IGNORE);
- if (! StringHasNoText (second)) {
- FFAddTextToString(temp, prefix, second, ")", FALSE, FALSE, TILDE_IGNORE);
- }
- addPeriod = FALSE;
-
- } else {
- FFAddTextToString(temp, NULL, common, NULL, FALSE, FALSE, TILDE_IGNORE);
- while (mod != NULL) {
- str = (CharPtr) mod->data.ptrvalue;
- if (! StringHasNoText (str)) {
- FFAddTextToString(temp, " ", str, NULL, FALSE, FALSE, TILDE_IGNORE);
- }
- mod = mod->next;
- }
- }
-
- str = FFToCharPtr(temp);
- if (StringCmp (str, ".") == 0) {
- str = MemFree (str);
- }
- FFRecycleString(ajp, temp);
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- gbseq->source = StringSave (str);
- }
-
-
- FFStartPrint(ffstring, afp->format, 0, 12, "SOURCE", 12, 5, 5, "OS", TRUE);
- if (str != NULL) {
- FFAddTextToString(ffstring, NULL, str, NULL, addPeriod, FALSE, TILDE_TO_SPACES);
- } else {
- FFAddOneChar(ffstring, '.', FALSE);
- }
-
- MemFree (str);
-
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
-
- FFStartPrint(ffstring, afp->format, 0, 12, "SOURCE", 12, 5, 5, "OS", TRUE);
- FFAddTextToString(ffstring, organelle, taxname, NULL, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddTextToString(ffstring, " (", common, ")", FALSE, FALSE, TILDE_TO_SPACES);
-
- }
-
- str = FFEndPrint(ajp, ffstring, afp->format, 12, 12, 0, 5, "OS");
- FFRecycleString(ajp, ffstring);
- return str;
-}
-
-static CharPtr FormatOrganismBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BioSourcePtr biop = NULL;
- Char ch;
- CharPtr common = NULL;
- DbtagPtr dbt;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- GBSeqPtr gbseq;
- Uint1 genome;
- CharPtr lineage = NULL;
- ObjectIdPtr oip;
- OrgNamePtr onp;
- CharPtr organelle = NULL;
- OrgRefPtr orp;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp;
- CharPtr str;
- Int4 taxid = -1;
- CharPtr taxname = NULL;
- CharPtr tmp;
- CharPtr ptr;
- ValNodePtr vnp;
- StringItemPtr ffstring, temp;
- Char buf [16];
-
- if (afp == NULL || bbp == NULL) return NULL;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
-
-
- if (! StringHasNoText (bbp->string)) return StringSave (bbp->string);
-
- if (bbp->itemtype == OBJ_SEQDESC) {
- sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID, 0, NULL, &dcontext);
- if (sdp != NULL && dcontext.seqdesctype == Seq_descr_source) {
- biop = (BioSourcePtr) sdp->data.ptrvalue;
- }
- } else if (bbp->itemtype == OBJ_SEQFEAT) {
- sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
- if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_BIOSRC) {
- biop = (BioSourcePtr) sfp->data.value.ptrvalue;
- }
- }
- if (biop != NULL) {
- genome = biop->genome;
- if (genome <= 19) {
- organelle = organellePrefix [genome];
- }
- orp = biop->org;
- if (orp != NULL) {
- taxname = orp->taxname;
- common = orp->common;
- onp = orp->orgname;
- if (onp != NULL) {
- lineage = onp->lineage;
- }
- for (vnp = orp->db; vnp != NULL; vnp = vnp->next) {
- dbt = (DbtagPtr) vnp->data.ptrvalue;
- if (dbt == NULL) continue;
- if (StringCmp (dbt->db, "taxon") == 0) {
- oip = dbt->tag;
- if (oip != NULL) {
- taxid = oip->id;
- }
- }
- }
- }
- }
-
- /* If the organelle prefix is already on the */
- /* name, don't add it. */
-
- if (StringNCmp (organelle, taxname, StringLen (organelle)) == 0)
- organelle = "";
-
- if (StringHasNoText (common)) {
- common = taxname;
- }
- if (StringHasNoText (common)) {
- common = "Unknown.";
- }
- if (StringHasNoText (taxname)) {
- taxname = "Unknown.";
- }
- if (StringHasNoText (lineage)) {
- lineage = "Unclassified.";
- }
-
- ffstring = FFGetString(ajp);
- temp = FFGetString(ajp);
- if ( ffstring == NULL || temp == NULL ) return NULL;
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
-
- FFStartPrint(temp, afp->format, 2, 12, "ORGANISM", 12, 5, 5, "OC", FALSE);
- if (! ajp->newSourceOrg) {
- FFAddOneString(temp, organelle, FALSE, FALSE, TILDE_IGNORE);
- }
- if (StringNICmp (taxname, "Unknown", 7) != 0) {
- if ( GetWWW(ajp) ) {
- if (taxid != -1) {
- FFAddOneString(temp, "<a href=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(temp, link_tax, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(temp, "id=", FALSE, FALSE, TILDE_IGNORE);
- sprintf (buf, "%ld", (long) taxid);
- FFAddOneString(temp, buf, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(temp, ">", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(temp, "<a href=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(temp, link_tax, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(temp, "name=", FALSE, FALSE, TILDE_IGNORE);
- tmp = StringSave (taxname);
- if (tmp != NULL) {
- ptr = tmp;
- ch = *ptr;
- while (ch != '\0') {
- if (IS_WHITESP (ch)) {
- *ptr = '+';
- }
- ptr++;
- ch = *ptr;
- }
- FFAddOneString(temp, tmp, FALSE, FALSE, TILDE_IGNORE);
- MemFree (tmp);
- }
- FFAddOneString(temp, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString(temp, taxname, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(temp, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(temp, taxname, FALSE, FALSE, TILDE_IGNORE);
- }
- } else {
- FFAddOneString(temp, taxname, FALSE, FALSE, TILDE_IGNORE);
- }
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- FFRecycleString(ajp, temp);
-
- temp = FFGetString(ajp);
- FFStartPrint(temp, afp->format, 12, 12, NULL, 0, 5, 5, "OC", FALSE);
- FFAddTextToString(temp, NULL, lineage, NULL, TRUE, FALSE, TILDE_TO_SPACES);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- FFRecycleString(ajp, temp);
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- temp = FFGetString(ajp);
- if (! ajp->newSourceOrg) {
- FFAddOneString(temp, organelle, FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString(temp, taxname, FALSE, FALSE, TILDE_IGNORE);
- gbseq->organism = FFToCharPtr(temp);
- gbseq->taxonomy = StringSave (lineage);
- FFRecycleString(ajp, temp);
- }
-
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- FFStartPrint(temp, afp->format, 12, 12, NULL, 0, 5, 5, "OC", FALSE);
- FFAddTextToString(temp, NULL, lineage, NULL, TRUE, FALSE, TILDE_TO_SPACES);
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "OC");
- }
-
-
- str = FFToCharPtr(ffstring);
- FFRecycleString(ajp, ffstring);
- return str;
-}
-
-/* format references section */
-
-static AuthListPtr GetAuthListPtr (
- PubdescPtr pdp,
- CitSubPtr csp
-)
-
-{
- AuthListPtr alp = NULL;
- CitArtPtr cap;
- CitBookPtr cbp;
- CitGenPtr cgp;
- CitPatPtr cpp;
- ValNodePtr vnp;
-
- if (csp != NULL) {
- alp = csp->authors;
- if (alp != NULL) return alp;
- }
- if (pdp == NULL) return NULL;
-
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- switch (vnp->choice) {
- case PUB_Gen :
- cgp = (CitGenPtr) vnp->data.ptrvalue;
- if (cgp != NULL) {
- alp = cgp->authors;
- }
- break;
- case PUB_Sub :
- csp = (CitSubPtr) vnp->data.ptrvalue;
- if (csp != NULL) {
- alp = csp->authors;
- }
- break;
- case PUB_Article :
- cap = (CitArtPtr) vnp->data.ptrvalue;
- if (cap != NULL) {
- alp = cap->authors;
- }
- break;
- case PUB_Book :
- case PUB_Proc :
- case PUB_Man :
- cbp = (CitBookPtr) vnp->data.ptrvalue;
- if (cbp != NULL) {
- alp = cbp->authors;
- }
- break;
- case PUB_Patent :
- cpp = (CitPatPtr) vnp->data.ptrvalue;
- if (cpp != NULL) {
- alp = cpp->authors;
- }
- break;
- default :
- break;
- }
-
- if (alp != NULL) return alp;
- }
-
- return NULL;
-}
-
-static CharPtr MakeSingleAuthorString (
- FmtType format,
- CharPtr prefix,
- CharPtr name,
- CharPtr initials,
- CharPtr suffix,
- IndxPtr index,
- GBReferencePtr gbref
-)
-
-{
- Char ch;
- Char dummy [10];
- size_t len;
- CharPtr nametoindex;
- CharPtr ptr;
- CharPtr str;
- CharPtr tmp;
-
- if (name == NULL) return NULL;
-
- /* !!! clean up 'et al' as (presumably) last author !!! */
-
- /* !!! temporary to suppress diff !!! */
- {
- if (StringLen (name) <= 6 &&
- (StringNICmp (name, "et al", 5) == 0 || StringNICmp (name, "et,al", 5) == 0)) {
- if (StringCmp (prefix, " and ") == 0) {
- prefix = NULL;
- dummy [0] = ' ';
- StringNCpy_0 (dummy + 1, name, sizeof (dummy) - 1);
- name = dummy;
- }
- }
- }
- /*
- if (StringLen (name) <= 6 &&
- (StringNICmp (name, "et al", 5) == 0 || StringNICmp (name, "et,al", 5) == 0)) {
- name = "et al.";
- if (StringCmp (prefix, " and ") == 0) {
- prefix = ", ";
- }
- }
- */
-
- len = StringLen (name) + StringLen (initials) + StringLen (suffix) + StringLen (prefix);
- str = MemNew (sizeof (Char) * (len + 4));
- if (str == NULL) return NULL;
-
- ptr = str;
- if (! StringHasNoText (prefix)) {
- ptr = StringMove (ptr, prefix);
- }
- nametoindex = ptr;
-
- /* initials and suffix to support structured name fields */
-
- tmp = StringMove (ptr, name);
- if (! StringHasNoText (initials)) {
- tmp = StringMove (tmp, ",");
- tmp = StringMove (tmp, initials);
- }
- if (! StringHasNoText (suffix)) {
- tmp = StringMove (tmp, " ");
- tmp = StringMove (tmp, suffix);
- }
-
- /* optionally populate indexes for NCBI internal database */
-
- if (index != NULL) {
- ValNodeCopyStrToHead (&(index->authors), 0, nametoindex);
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (gbref != NULL) {
- ValNodeCopyStr (&(gbref->authors), 0, nametoindex);
- }
-
- /* if embl, remove commas in individual names, starting after prefix */
-
- if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
- tmp = ptr;
- ch = *tmp;
- while (ch != '\0') {
- if (ch == ',') {
- *tmp = ' ';
- }
- tmp++;
- ch = *tmp;
- }
- }
-
- return str;
-}
-
-static CharPtr GetAuthorsString (
- FmtType format,
- AuthListPtr alp,
- CharPtr PNTR consortP,
- IndxPtr index,
- GBReferencePtr gbref
-)
-
-{
- AuthorPtr ap;
- ValNodePtr conslist;
- Int2 count;
- ValNodePtr head = NULL;
- ValNodePtr names;
- ValNodePtr next;
- NameStdPtr nsp;
- PersonIdPtr pid;
- ValNodePtr pidlist;
- CharPtr prefix = NULL;
- CharPtr str;
- ValNodePtr vnp;
-
- if (alp == NULL) return NULL;
-
- alp = AsnIoMemCopy ((Pointer) alp,
- (AsnReadFunc) AuthListAsnRead,
- (AsnWriteFunc) AuthListAsnWrite);
- if (alp == NULL) return NULL;
-
- count = 0;
- if (alp->choice == 1) {
-
- pidlist = NULL;
- conslist = NULL;
-
- for (names = alp->names; names != NULL; names = names->next) {
- ap = (AuthorPtr) names->data.ptrvalue;
- if (ap == NULL) continue;
- pid = ap->name;
- if (pid == NULL) continue;
- if (pid->choice == 2 || pid->choice == 3 || pid->choice == 4) {
- ValNodeAddPointer (&pidlist, 0, (Pointer) pid);
- } else if (pid->choice == 5) {
- ValNodeAddPointer (&conslist, 0, (Pointer) pid);
- }
- }
-
- for (vnp = pidlist; vnp != NULL; vnp = vnp->next) {
- next = vnp->next;
- if (next == NULL) {
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- if (count == 0) {
- prefix = NULL;
- } else {
- prefix = " and ";
- }
- }
- }
- str = NULL;
- pid = (PersonIdPtr) vnp->data.ptrvalue;
- if (pid->choice == 2) {
- nsp = (NameStdPtr) pid->data;
- if (nsp != NULL) {
- if (! StringHasNoText (nsp->names [0])) {
- str = MakeSingleAuthorString (format, prefix, nsp->names [0], nsp->names [4], nsp->names [5], index, gbref);
- } else if (! StringHasNoText (nsp->names [3])) {
- str = MakeSingleAuthorString (format, prefix, nsp->names [3], NULL, NULL, index, gbref);
- }
- }
- } else if (pid->choice == 3 || pid->choice == 4) {
- str = MakeSingleAuthorString (format, prefix, (CharPtr) pid->data, NULL, NULL, index, gbref);
- }
- if (str != NULL) {
- ValNodeAddStr (&head, 0, str);
- count++;
- }
- prefix = ", ";
- }
-
- for (vnp = conslist; vnp != NULL; vnp = vnp->next) {
- str = NULL;
- pid = (PersonIdPtr) vnp->data.ptrvalue;
- if (pid->choice == 5) {
- str = MakeSingleAuthorString (format, NULL, (CharPtr) pid->data, NULL, NULL, index, NULL);
- if ((! StringHasNoText (str)) && consortP != NULL && *consortP == NULL) {
- *consortP = StringSave (str);
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (gbref != NULL) {
- gbref->consortium = StringSave (str);
- }
-
- str = MemFree (str);
- }
- }
-
- ValNodeFree (pidlist);
- ValNodeFree (conslist);
-
- } else if (alp->choice == 2 || alp->choice == 3) {
- for (vnp = alp->names; vnp != NULL; vnp = vnp->next) {
- next = vnp->next;
- if (next == NULL) {
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- if (count == 0) {
- prefix = NULL;
- } else {
- prefix = " and ";
- }
- }
- }
- str = MakeSingleAuthorString (format, prefix, (CharPtr) vnp->data.ptrvalue, NULL, NULL, index, gbref);
- if (str != NULL) {
- ValNodeAddStr (&head, 0, str);
- count++;
- }
- prefix = ", ";
- }
- }
-
- str = MergeValNodeStrings (head);
-
- ValNodeFreeData (head);
-
- AuthListFree (alp);
-
- return str;
-}
-
-/*
-Strips all spaces in string in following manner. If the function
-meet several spaces (spaces and tabs) in succession it replaces them
-with one space. Strips all spaces after '(' and before ')'
-*/
-
-static void StrStripSpaces (
- CharPtr str
-)
-
-{
- CharPtr new_str;
-
- if (str == NULL) return;
-
- new_str = str;
- while (*str != '\0') {
- *new_str++ = *str;
- if (*str == ' ' || *str == '\t' || *str == '(') {
- for (str++; *str == ' ' || *str == '\t'; str++) continue;
- if (*str == ')' || *str == ',') {
- new_str--;
- }
- } else {
- str++;
- }
- }
- *new_str = '\0';
-}
-
-static Boolean AllCaps (
- CharPtr p
-)
-
-{
- if (p == NULL) return FALSE;
-
- for (p++; p != NULL && *p != '\0'; p++) {
- if (IS_LOWER (*p)) return FALSE;
- }
- return TRUE;
-}
-
-static void CleanEquals (
- CharPtr p
-)
-
-{
- if (p == NULL) return;
-
- for (; *p != '\0'; p++) {
- if (*p == '\"') {
- *p = '\'';
- }
- }
-}
-
-static CharPtr GetPubTitle (
- FmtType format,
- PubdescPtr pdp,
- CitSubPtr csp
-)
-
-{
- CitArtPtr cap;
- CitBookPtr cbp;
- CitGenPtr cgp;
- Char ch;
- CitPatPtr cpp;
- MedlineEntryPtr mep;
- CharPtr ptr;
- CharPtr title = NULL;
- ValNodePtr ttl = NULL;
- ValNodePtr vnp;
-
- if (csp != NULL) {
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- title = "Direct Submission";
- return StringSave (title);
- } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
- return NULL;
- }
- }
- if (pdp == NULL) return NULL;
-
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- switch (vnp->choice) {
- case PUB_Gen :
- cgp = (CitGenPtr) vnp->data.ptrvalue;
- if (cgp != NULL) {
- if (! StringHasNoText (cgp->title)) return StringSave (cgp->title);
- if (! StringHasNoText (cgp->cit)) {
- ptr = StringStr (cgp->cit, "Title=\"");
- if (ptr != NULL) {
- title = StringSave (ptr + 7);
- for (ptr = title; *ptr != '\0'; ptr++) {
- if (*ptr == '"') {
- *ptr = '\0';
- break;
- }
- }
- return title;
- }
- }
- }
- break;
- case PUB_Sub :
- csp = (CitSubPtr) vnp->data.ptrvalue;
- if (csp != NULL) {
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- title = "Direct Submission";
- return StringSave (title);
- } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
- return NULL;
- }
- }
- break;
- case PUB_Medline :
- mep = (MedlineEntryPtr) vnp->data.ptrvalue;
- if (mep != NULL) {
- cap = mep->cit;
- if (cap != NULL) {
- ttl = cap->title;
- }
- }
- break;
- case PUB_Article :
- cap = (CitArtPtr) vnp->data.ptrvalue;
- if (cap != NULL) {
- ttl = cap->title;
- }
- break;
- /* case PUB_Book : */
- case PUB_Proc :
- case PUB_Man :
- cbp = (CitBookPtr) vnp->data.ptrvalue;
- if (cbp != NULL) {
- ttl = cbp->title;
- if (ttl != NULL) {
- title = (CharPtr) ttl->data.ptrvalue;
- if (! StringHasNoText (title)) {
- title = StringSave (title);
- if (StringLen (title) > 3) {
- ch = *title;
- if (IS_LOWER (ch)) {
- *title = TO_UPPER (ch);
- }
- ptr = title;
- if (AllCaps (ptr)) {
- for (ptr++; ptr != NULL && *ptr != '\0'; ptr++) {
- ch = *ptr;
- *ptr = TO_LOWER (ch);
- }
- }
- }
- return title;
- }
- }
- }
- break;
- case PUB_Patent :
- cpp = (CitPatPtr) vnp->data.ptrvalue;
- if (cpp != NULL) {
- title = cpp->title;
- if (! StringHasNoText (title)) {
- return StringSave (title);
- }
- }
- break;
- default :
- break;
- }
-
- if (ttl != NULL) {
- title = (CharPtr) ttl->data.ptrvalue;
- if (! StringHasNoText (title)) {
- return StringSave (title);
- }
- }
- }
-
- return NULL;
-}
-
-static void CleanPubTitle (
- CharPtr title
-)
-
-{
- CharPtr p;
- Boolean remove_it;
-
- if (title == NULL) return;
-
- CleanEquals (title);
-
- for (p = title + StringLen (title) - 1; p > title + 2; p--) {
- if (*p == ' ') {
- *p = '\0';
- } else if (*p == '.') {
- remove_it = FALSE;
- if (p > title + 5) {
- if (*(p - 1) != '.' || *(p - 2) != '.') {
- remove_it = TRUE;
- }
- }
- if (remove_it) {
- *p = '\0';
- }
- break;
- } else {
- break;
- }
- }
-}
-
-/*
-medline type page numbering is expanded (e.g., 125-35 -> 125-135,
-F124-34 -> F124-F134, 12a-c -> 12a-12c).
-If only one page is given, this is output without a dash.
-Expanded numbering is validated to ensure that the
-first number is smaller than or equal to the second and
-that the first letter is less than or identical to the second
-(i.e., a < c). If the input is all letters (i.e., roman numerals)
-this is not validated.
-
-Return values:
- 0 : valid page numbering.
--1 : invalid page numbering.
-*/
-
-#define MAX_PAGE_DIGITS 12
-
-static Int2 FixPages (
- CharPtr out_pages,
- CharPtr in_pages
-)
-
-{
- Boolean dash=TRUE, first_alpha;
- Char firstbegin[MAX_PAGE_DIGITS];
- Char secondbegin[MAX_PAGE_DIGITS];
- Char firstend[MAX_PAGE_DIGITS];
- Char secondend[MAX_PAGE_DIGITS];
- Char temp[MAX_PAGE_DIGITS];
- CharPtr alphabegin, numbegin, alphaend, numend, ptr, in=in_pages;
- Int2 diff, index, retval=0;
- Int2 length_nb, length_ab, length_ne, length_ae;
- Int4 num1=0, num2=0;
-
- if (in_pages == NULL) return retval;
-
- while (*in != '\0')
- { /* Check for digits in input*/
- if (IS_DIGIT(*in))
- break;
- in++;
- }
-
- if (*in == '\0' || (in != in_pages && *(in-1) == ' '))
- { /* if all letters (i.e. roman numerals), put out. */
- out_pages = StringCpy(out_pages, in_pages);
- return retval;
- }
-
- in = in_pages;
- if (IS_DIGIT(*in))
- { /* Do digits come first? */
- first_alpha = FALSE;
- index=0;
- while (IS_DIGIT(*in) || *in == ' ')
- {
- firstbegin[index] = *in;
- if (*in != ' ')
- index++;
- in++;
- if (*in == '-')
- break;
-
- }
- firstbegin[index] = '\0';
- index=0;
- if (*in != '-')
- { /* After digits look for letters. */
- while (IS_ALPHA(*in) || *in == ' ')
- {
- secondbegin[index] = *in;
- index++;
- in++;
- if (*in == '-')
- break;
- }
- }
- secondbegin[index] = '\0';
- if (*in == '-') /* if dash is not present, note */
- in++;
- else
- dash=FALSE;
- index=0;
- while (IS_DIGIT(*in) || *in == ' ')
- { /* Look for digits. */
- firstend[index] = *in;
- if (*in != ' ')
- index++;
- in++;
- }
- firstend[index] = '\0';
- index=0;
- if (*in != '\0')
- { /* Look for letters again. */
- while (IS_ALPHA(*in) || *in == ' ')
- {
- secondend[index] = *in;
- index++;
- in++;
- }
- }
- secondend[index] = '\0';
- }
- else
- { /* Do letters come first? */
- first_alpha = TRUE;
- index=0;
- while (IS_ALPHA(*in) || *in == ' ')
- {
- firstbegin[index] = *in;
- index++;
- in++;
- if (*in == '-')
- break;
- }
- firstbegin[index] = '\0';
- index=0;
- if (*in != '-')
- { /* After letters look for digits. */
- while (IS_DIGIT(*in) || *in == ' ')
- {
- secondbegin[index] = *in;
- if (*in != ' ')
- index++;
- in++;
- if (*in == '-')
- break;
- }
- }
- secondbegin[index] = '\0';
- if (*in == '-') /* Note if dash is missing. */
- in++;
- else
- dash=FALSE;
- index=0;
- while (IS_ALPHA(*in) || *in == ' ')
- { /* Look for letters again. */
- firstend[index] = *in;
- index++;
- in++;
- }
- firstend[index] = '\0';
- index=0;
- if (*in != '\0')
- { /* Any digits here? */
- while (IS_DIGIT(*in) || *in == ' ')
- {
- secondend[index] = *in;
- if (*in != ' ')
- index++;
- in++;
- }
- }
- secondend[index] = '\0';
- }
-
- if (first_alpha)
- {
- alphabegin = firstbegin;
- numbegin = secondbegin;
- alphaend = firstend;
- numend = secondend;
- }
- else
- {
- numbegin = firstbegin;
- alphabegin = secondbegin;
- numend = firstend;
- alphaend = secondend;
- }
-
- length_nb = StringLen(numbegin);
- length_ab = StringLen(alphabegin);
- length_ne = StringLen(numend);
- length_ae = StringLen(alphaend);
-
- /* If no dash, but second letters or numbers present, reject. */
- if (dash == FALSE)
- {
- if (length_ne != 0 || length_ae != 0)
- retval = -1;
- }
- /* Check for situations like "AAA-123" or "222-ABC". */
- if (dash == TRUE)
- {
- if (length_ne == 0 && length_ab == 0)
- retval = -1;
- else if (length_ae == 0 && length_nb == 0)
- retval = -1;
- }
-
- /* The following expands "F502-512" into "F502-F512" and
- checks, for entries like "12a-12c" that a > c. "12aa-12ab",
- "125G-137A", "125-G137" would be rejected. */
- if (retval == 0)
- {
- if (length_ab > 0)
- {
- if (length_ae > 0)
- {
- if (StringCmp(alphabegin, alphaend) != 0)
- {
- if (length_ab != 1 || length_ae != 1)
- retval = -1;
- else if (*alphabegin > *alphaend)
- retval = -1;
- }
- }
- else
- {
- alphaend = alphabegin;
- length_ae = length_ab;
- }
- }
- else if (length_ae > 0)
- retval = -1;
- }
-
-/* The following expands "125-37" into "125-137". */
- if (retval == 0)
- {
- if (length_nb > 0)
- {
- if (length_ne > 0)
- {
- diff = length_nb - length_ne;
- if (diff > 0)
- {
- index=0;
- while (numend[index] != '\0')
- {
- temp[index+diff] = numend[index];
- index++;
- }
- temp[index+diff] = numend[index];
- for (index=0; index<diff; index++)
- temp[index] = numbegin[index];
- index=0;
- while (temp[index] != '\0')
- {
- numend[index] = temp[index];
- index++;
- }
- numend[index] = temp[index];
- }
- }
- else
- {
- numend = numbegin;
- length_ne = length_nb;
- }
-
- }
- else if (length_ne > 0)
- retval = -1;
- /* Check that the first number is <= the second (expanded) number. */
- if (retval == 0)
- {
- /* sscanf(numbegin, "%ld", &num_type);
- num1 = (Int4) num_type;
- sscanf( numend, "%ld", &num_type);
- num2 = (Int4) num_type;
- */
- num1 = (Int4) atol(numbegin);
- num2 = (Int4) atol(numend);
- if (num2 < num1)
- retval = -1;
- }
- }
-
- if (retval == -1)
- {
- out_pages = StringCpy(out_pages, in_pages);
- }
- else
- {
- ptr = out_pages;
- /* Place expanded and validated page numbers into "out_pages". */
- if (first_alpha)
- {
- while (*alphabegin != '\0')
- {
- *ptr = *alphabegin;
- alphabegin++;
- ptr++;
- }
- while (*numbegin != '\0')
- {
- *ptr = *numbegin;
- numbegin++;
- ptr++;
- }
- if (dash == TRUE)
- {
- *ptr = '-';
- ptr++;
- while (*alphaend != '\0')
- {
- *ptr = *alphaend;
- alphaend++;
- ptr++;
- }
- while (*numend != '\0')
- {
- *ptr = *numend;
- numend++;
- ptr++;
- }
- }
- *ptr = '\0';
- }
- else
- {
- while (*numbegin != '\0')
- {
- *ptr = *numbegin;
- numbegin++;
- ptr++;
- }
- while (*alphabegin != '\0')
- {
- *ptr = *alphabegin;
- alphabegin++;
- ptr++;
- }
- if (dash == TRUE)
- {
- *ptr = '-';
- ptr++;
- while (*numend != '\0')
- {
- *ptr = *numend;
- numend++;
- ptr++;
- }
- while (*alphaend != '\0')
- {
- *ptr = *alphaend;
- alphaend++;
- ptr++;
- }
- }
- *ptr = '\0';
- }
- }
- return retval;
-}
-
-/* !!! still need to add StripParanthesis equivalent !!! */
-
-static void DoSup (
- ValNodePtr PNTR head,
- CharPtr issue,
- CharPtr part_sup,
- CharPtr part_supi
-)
-
-{
- size_t len;
- CharPtr str;
- CharPtr temp;
-
- len = StringLen (issue) + StringLen (part_sup) + StringLen (part_supi) + 25;
- str = MemNew (sizeof (Char) * len);
- if (str == NULL) return;
- temp = str;
-
- if (! StringHasNoText (part_sup)) {
- *temp = ' ';
- temp++;
- temp = StringMove (temp, part_sup);
- }
- if (StringHasNoText (issue) && StringHasNoText (part_supi)) {
- ValNodeCopyStr (head, 0, str);
- MemFree (str);
- return;
- }
- *temp = ' ';
- temp++;
- *temp = '(';
- temp++;
- if (! StringHasNoText (issue)) {
- temp = StringMove (temp, issue);
- }
- if (! StringHasNoText (part_supi)) {
- *temp = ' ';
- temp++;
- temp = StringMove (temp, part_supi);
- }
- *temp = ')';
- temp++;
- ValNodeCopyStr (head, 0, str);
- MemFree (str);
-}
-
-static CharPtr FormatCitJour (
- FmtType format,
- Boolean citArtIsoJta,
- CitJourPtr cjp
-)
-
-{
- Char buf [256];
- DatePtr dp;
- ValNodePtr head = NULL;
- ImprintPtr imp;
- CharPtr issue = NULL;
- Char pages [128];
- CharPtr part_sup = NULL;
- CharPtr part_supi = NULL;
- CharPtr rsult = NULL;
- CharPtr title;
- ValNodePtr ttl;
- CharPtr volume;
- Char year [8];
-
- if (cjp == NULL) return NULL;
-
- ttl = cjp->title;
- if (ttl == NULL) return NULL;
-
- /* always use iso_jta title if present */
-
- while (ttl != NULL && ttl->choice != Cit_title_iso_jta) {
- ttl = ttl->next;
- }
-
- /* release mode requires iso_jta title */
-
- if (ttl == NULL) {
- if (citArtIsoJta) return NULL;
- ttl = cjp->title;
- }
-
- imp = cjp->imp;
- if (imp == NULL) return NULL;
-
- dp = imp->date;
- year [0] = '\0';
- if (dp != NULL) {
- if (dp->data [0] == 1) {
- if (dp->data [1] != 0) {
- sprintf (year, " (%ld)", (long) (1900 + dp->data [1]));
- }
- } else {
- StringCpy (year, " (");
- StringNCat (year, dp->str, 4);
- StringCat (year, ")");
- }
- }
-
- if (imp->prepub == 1 || imp->prepub == 255) {
- sprintf (buf, "Unpublished %s", year);
- return StringSave (buf);
- }
-
- title = (CharPtr) ttl->data.ptrvalue;
- if (StringLen (title) < 3) return StringSave (".");
-
- ValNodeCopyStr (&head, 0, title);
-
- volume = imp->volume;
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- issue = imp->issue;
- part_sup = imp->part_sup;
- part_supi = imp->part_supi;
- }
- pages [0] = '\0';
- FixPages (pages, imp->pages);
-
- if (! StringHasNoText (volume)) {
- AddValNodeString (&head, " ", volume, NULL);
- }
-
- if ((! StringHasNoText (volume)) || (! StringHasNoText (pages))) {
- DoSup (&head, issue, part_sup, part_supi);
- }
-
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- if (! StringHasNoText (pages)) {
- AddValNodeString (&head, ", ", pages, NULL);
- }
- } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
- if (! StringHasNoText (pages)) {
- AddValNodeString (&head, ":", pages, NULL);
- } else if (imp->prepub == 2 || (StringHasNoText (volume))) {
- ValNodeCopyStr (&head, 0, " 0:0-0");
- }
- }
-
- ValNodeCopyStr (&head, 0, year);
-
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- if (imp->prepub == 2) {
- ValNodeCopyStr (&head, 0, " In press");
- }
- }
-
- rsult = MergeValNodeStrings (head);
- ValNodeFreeData (head);
-
- return rsult;
-}
-
-static CharPtr MakeAffilStr (
- AffilPtr afp
-)
-
-{
- ValNodePtr head = NULL;
- CharPtr prefix = "";
- CharPtr rsult = NULL;
-
- if (afp == NULL) return NULL;
-
- if (! StringHasNoText (afp->affil)) {
- ValNodeCopyStr (&head, 0, afp->affil);
- prefix = ", ";
- }
-
- if (afp->choice == 2) {
- if (! StringHasNoText (afp->div)) {
- AddValNodeString (&head, prefix, afp->div, NULL);
- prefix = ", ";
- }
- if (! StringHasNoText (afp->street)) {
- AddValNodeString (&head, prefix, afp->street, NULL);
- prefix = ", ";
- }
- if (! StringHasNoText (afp->city)) {
- AddValNodeString (&head, prefix, afp->city, NULL);
- prefix = ", ";
- }
- if (! StringHasNoText (afp->sub)) {
- AddValNodeString (&head, prefix, afp->sub, NULL);
- prefix = ", ";
- }
- if (! StringHasNoText (afp->country)) {
- AddValNodeString (&head, prefix, afp->country, NULL);
- prefix = ", ";
- }
- }
-
- rsult = MergeValNodeStrings (head);
- ValNodeFreeData (head);
-
- return rsult;
-}
-
-static CharPtr GetAffil (
- AffilPtr afp
-)
-
-{
- Boolean need_comma=FALSE;
- CharPtr string=NULL, temp, ptr;
- Char ch;
- Int2 aflen=15;
-
- if (afp == NULL) return NULL;
- if (afp) {
- if (afp -> choice == 1){
- if (afp -> affil){
- aflen += StringLen(afp -> affil);
- }
- }else if (afp -> choice == 2){
- aflen += StringLen (afp -> affil) +
- StringLen (afp -> div) +
- StringLen (afp -> city) +
- StringLen (afp -> sub) +
- StringLen (afp -> street) +
- StringLen (afp -> country) + StringLen(afp->postal_code);
- }
-
- temp = string = MemNew(aflen);
-
- if ( afp -> choice == 1){
- if (afp -> affil){
- ptr = afp->affil;
- while ((*temp = *ptr) != '\0')
- {
- temp++; ptr++;
- }
- }
- }else if (afp -> choice == 2){
-
- if( afp -> div) {
- if (need_comma)
- {
- *temp = ','; temp++;
- *temp = ' '; temp++;
- }
- ptr = afp->div;
- while ((*temp = *ptr) != '\0')
- {
- temp++; ptr++;
- }
- need_comma = TRUE;
- }
-
- if(afp -> affil) {
- if (need_comma)
- {
- *temp = ','; temp++;
- *temp = ' '; temp++;
- }
- ptr = afp->affil;
- while ((*temp = *ptr) != '\0')
- {
- temp++; ptr++;
- }
- need_comma = TRUE;
- }
-
- if(afp -> street) {
- if (need_comma)
- {
- *temp = ','; temp++;
- *temp = ' '; temp++;
- }
- ptr = afp->street;
- while ((*temp = *ptr) != '\0')
- {
- temp++; ptr++;
- }
- need_comma = TRUE;
- }
-
- if( afp -> city) {
- if (need_comma)
- {
- *temp = ','; temp++;
- *temp = ' '; temp++;
- }
- ptr = afp->city;
- while ((*temp = *ptr) != '\0')
- {
- temp++; ptr++;
- }
- need_comma = TRUE;
- }
-
- if( afp -> sub) {
- if (need_comma)
- {
- *temp = ','; temp++;
- *temp = ' '; temp++;
- }
- ptr = afp->sub;
- while ((*temp = *ptr) != '\0')
- {
- temp++; ptr++;
- }
- need_comma = TRUE;
- }
-
- if( afp -> postal_code){
- *temp = ' ';
- temp++;
- ptr = afp->postal_code;
- while ((*temp = *ptr) != '\0')
- {
- temp++; ptr++;
- }
- }
-
- if( afp -> country){
- if (need_comma)
- {
- *temp = ','; temp++;
- *temp = ' '; temp++;
- }
- ptr = afp->country;
- while ((*temp = *ptr) != '\0')
- {
- temp++; ptr++;
- }
- need_comma = TRUE;
- }
- }
- temp++;
- *temp = '\0';
- }
-
- /* convert double quotes to single quotes */
-
- ptr = string;
- ch = *ptr;
- while (ch != '\0') {
- if (ch == '\"') {
- *ptr = '\'';
- }
- ptr++;
- ch = *ptr;
- }
-
- return string;
-}
-
-static CharPtr FormatCitBookArt (
- FmtType format,
- CitBookPtr cbp
-)
-
-{
- AffilPtr afp;
- AuthListPtr alp;
- CharPtr book_title = NULL;
- Char buf [256];
- Char ch;
- DatePtr dp;
- ValNodePtr head = NULL;
- ImprintPtr imp;
- CharPtr issue = NULL;
- ValNodePtr names = NULL;
- Char pages [128];
- CharPtr part_sup = NULL;
- CharPtr part_supi = NULL;
- CharPtr rsult = NULL;
- CharPtr str;
- CharPtr title;
- ValNodePtr ttl;
- ValNodePtr vnp;
- CharPtr volume;
- Char year [8];
-
- if (cbp == NULL) return NULL;
-
- ttl = cbp->title;
- if (ttl == NULL) return NULL;
-
- imp = cbp->imp;
- if (imp == NULL) return NULL;
-
- dp = imp->date;
- year [0] = '\0';
- if (dp != NULL) {
- if (dp->data [0] == 1) {
- if (dp->data [1] != 0) {
- sprintf (year, "(%ld)", (long) (1900 + dp->data [1]));
- }
- } else {
- StringCpy (year, "(");
- StringNCat (year, dp->str, 4);
- StringCpy (year, ")");
- }
- }
-
- if (imp->prepub == 1 || imp->prepub == 255) {
- sprintf (buf, "Unpublished %s", year);
- return StringSave (buf);
- }
-
- title = (CharPtr) ttl->data.ptrvalue;
- if (StringLen (title) < 3) return StringSave (".");
-
- ValNodeCopyStr (&head, 0, "(in) ");
-
- alp = cbp->authors;
- if (alp != NULL) {
- str = GetAuthorsString (format, alp, NULL, NULL, NULL);
- if (str != NULL) {
- ValNodeCopyStr (&head, 0, str);
- names = alp->names;
- if (names != NULL) {
- if (names->next != NULL) {
- ValNodeCopyStr (&head, 0, " (Eds.);");
- } else {
- ValNodeCopyStr (&head, 0, " (Ed.);");
- }
- }
- ValNodeCopyStr (&head, 0, "\n");
- }
- MemFree (str);
- }
-
- book_title = StringSaveNoNull (title);
- vnp = ValNodeAddStr (&head, 0, book_title);
- if (book_title != NULL) {
-
- /* make book title all caps */
-
- title = book_title;
- ch = *title;
- while (ch != '\0') {
- *title = TO_UPPER (ch);
- title++;
- ch = *title;
- }
- }
-
- volume = imp->volume;
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- issue = imp->issue;
- part_sup = imp->part_sup;
- part_supi = imp->part_supi;
- }
- pages [0] = '\0';
- FixPages (pages, imp->pages);
-
- if ((! StringHasNoText (volume)) && (StringCmp (volume, "0") != 0)) {
- AddValNodeString (&head, ", Vol. ", volume, NULL);
- DoSup (&head, issue, part_sup, part_supi);
- }
-
- if (! StringHasNoText (pages)) {
- AddValNodeString (&head, ": ", pages, NULL);
- }
-
- if (book_title != NULL) {
- ValNodeCopyStr (&head, 0, ";\n");
- }
-
- afp = imp->pub;
- if (afp != NULL) {
- str = MakeAffilStr (afp);
- if (str != NULL) {
- ValNodeCopyStr (&head, 0, str);
- ValNodeCopyStr (&head, 0, " ");
- MemFree (str);
- }
- }
-
- AddValNodeString (&head, NULL, year, NULL);
-
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- if (imp->prepub == 2) {
- ValNodeCopyStr (&head, 0, " In press");
- }
- }
-
- rsult = MergeValNodeStrings (head);
- ValNodeFreeData (head);
-
- return rsult;
-}
-
-static CharPtr FormatCitBook (
- FmtType format,
- CitBookPtr cbp
-)
-
-{
- AffilPtr afp;
- char year[5];
- CharPtr bookTitle=NULL;
- CharPtr retval = NULL;
- CharPtr temp;
- DatePtr dp;
- ImprintPtr ip;
- int aflen = 0;
- CharPtr p;
- CharPtr affilStr = NULL;
-
- /* Check parameters */
-
- if (cbp == NULL)
- return NULL;
-
- if ( cbp -> othertype != 0)
- return NULL;
-
- ip = cbp -> imp;
-
- /* Format the year */
-
- dp = ip -> date;
- year[0] = '\0';
-
- if ( dp -> data[0] == 1)
- sprintf(year,"%ld",(long) ( 1900+dp -> data[1]));
- else
- {
- StringNCpy( (CharPtr) year, (CharPtr) dp -> str, (size_t) 4);
- year[4] = '\0';
- }
-
- /* Get the book title */
-
- if (cbp->title)
- bookTitle = StringSave(cbp -> title -> data.ptrvalue);
-
- /* Get the affiliation length */
-
- if ( ip -> pub){
- afp = ip -> pub;
- aflen = StringLen(afp -> affil)+ 5;
- if ( afp -> choice == 2){
- aflen += 3 + StringLen(afp -> div);
- aflen += 3 + StringLen(afp -> street);
- aflen += 3 + StringLen(afp -> city);
- aflen += 3 + StringLen(afp -> sub);
- aflen += 3 + StringLen(afp -> country);
- }
- } else{
- aflen = 22;
- }
- if (ip->prepub == 2)
- aflen += 10;
-
- /* Create a Char String big enough to hold */
- /* the title, year, and affiliation. */
-
- temp = retval = MemNew( (size_t) (30+StringLen( bookTitle)+StringLen( year) + aflen) );
-
- /* Convert the title to upper case and */
- /* add it to the string. */
-
- for ( p = bookTitle; *p; p++)
- *p = TO_UPPER(*p);
-
- /* temp = StringMove(temp, "Book: "); */
- temp = StringMove(temp, "(in) ");
- temp = StringMove(temp, bookTitle);
- temp = StringMove(temp, ".");
-
- /* Add the affiliation to the string */
-
- if ( ip -> pub)
- {
- afp = ip -> pub;
- *temp = ' ';
- temp++;
- affilStr = MakeAffilStr(afp);
- temp = StringMove(temp,affilStr);
- }
-
- /* Add the year to the string */
-
- if (year[0] != '\0')
- {
- if (affilStr != NULL)
- temp = StringMove(temp," (");
- else
- temp = StringMove(temp, "(");
- temp = StringMove(temp, year);
- temp = StringMove(temp, ")");
- }
-
- /* If in press, add note */
-
- if (ip->prepub == 2)
- temp = StringMove(temp, ", In press");
-
- /* Clean up and return */
-
- if (bookTitle)
- MemFree(bookTitle);
-
- return retval;
-
-}
-
-static CharPtr FormatThesis (
- FmtType format,
- CitBookPtr cbp
-)
-
-{
- AffilPtr afp;
- Char ch;
- DatePtr dp;
- ValNodePtr head = NULL;
- ImprintPtr imp;
- CharPtr ptr;
- CharPtr rsult = NULL;
- CharPtr str;
- CharPtr suffix = NULL;
- Char year [8];
-
- if (cbp == NULL) return NULL;
- if (cbp->othertype != 2 || cbp->let_type != 3) return NULL;
-
- imp = cbp->imp;
- if (imp == NULL) return NULL;
-
- dp = imp->date;
- year [0] = '\0';
- if (dp != NULL) {
- if (dp->data [0] == 1) {
- if (dp->data [1] != 0) {
- sprintf (year, "%ld", (long) (1900 + dp->data [1]));
- }
- } else {
- StringNCpy (year, dp->str, (size_t) 4);
- year [4] = '\0';
- }
- }
-
- AddValNodeString (&head, "Thesis (", year, ")");
-
- if (imp->prepub == 2) {
- suffix = ", In press";
- }
-
- str = NULL;
- afp = imp->pub;
- if (afp != NULL) {
- if (afp->choice == 1) {
- if (StringLen (afp->affil) > 7) {
- str = StringSave (afp->affil);
- }
- } else if (afp->choice == 2) {
- str = MakeAffilStr (afp);
- }
- }
-
- if (str != NULL) {
-
- /* convert double quotes to single quotes */
-
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- if (ch == '\"') {
- *ptr = '\'';
- }
- ptr++;
- ch = *ptr;
- }
- AddValNodeString (&head, " ", str, suffix);
- MemFree (str);
- }
-
- rsult = MergeValNodeStrings (head);
- ValNodeFreeData (head);
-
- return rsult;
-}
-
-static CharPtr FormatCitArt (
- FmtType format,
- Boolean citArtIsoJta,
- CitArtPtr cap
-)
-
-{
- CitBookPtr cbp;
- CitJourPtr cjp;
- CharPtr rsult = NULL;
-
- if (cap == NULL) return NULL;
-
- switch (cap->from) {
- case 1 :
- cjp = (CitJourPtr) cap->fromptr;
- if (cjp != NULL) {
- rsult = FormatCitJour (format, citArtIsoJta, cjp);
- }
- break;
- case 2 :
- cbp = (CitBookPtr) cap->fromptr;
- if (cbp != NULL) {
- rsult = FormatCitBookArt (format, cbp);
- }
- break;
- case 3 :
- cbp = (CitBookPtr) cap->fromptr;
- if (cbp != NULL) {
- rsult = FormatCitBookArt (format, cbp);
- }
- break;
- default :
- break;
- }
-
- return rsult;
-}
-
-static CharPtr FormatCitPat (
- FmtType format,
- CitPatPtr cpp,
- SeqIdPtr seqidp
-)
-
-{
- AffilPtr afp;
- AuthListPtr alp;
- Char date [40];
- ValNodePtr head = NULL;
- CharPtr prefix = NULL;
- CharPtr rsult = NULL;
- SeqIdPtr sip;
- CharPtr suffix = NULL;
- PatentSeqIdPtr psip;
- Int4 pat_seqid = 0;
- Char buf[10];
-
- if (cpp == NULL) return NULL;
-
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- ValNodeCopyStr (&head, 0, "Patent: ");
- suffix = " ";
- } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
- ValNodeCopyStr (&head, 0, "Patent number ");
- }
-
- if (! StringHasNoText (cpp->country)) {
- AddValNodeString (&head, NULL, cpp->country, suffix);
- }
-
- if (! StringHasNoText (cpp->number)) {
- ValNodeCopyStr (&head, 0, cpp->number);
- } else if (! StringHasNoText (cpp->app_number)) {
- AddValNodeString (&head, "(", cpp->app_number, ")");
- }
-
- if (! StringHasNoText (cpp->doc_type)) {
- AddValNodeString (&head, "-", cpp->doc_type, NULL);
- }
-
- /* pat_seqid test */
-
- for (sip = seqidp; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_PATENT) {
- psip = (PatentSeqIdPtr) sip -> data.ptrvalue;
- if (psip != NULL) {
- pat_seqid = psip->seqid;
- }
- }
- }
- if (pat_seqid > 0) {
- if (format == EMBL_FMT) {
- sprintf(buf,"%s%ld%s", "/", (long) pat_seqid, ", ");
- ValNodeCopyStr (&head, 0, buf);
- } else {
- sprintf(buf,"%s%ld ", " ", (long) pat_seqid);
- ValNodeCopyStr (&head, 0, buf);
- }
- } else {
- ValNodeCopyStr (&head, 0, " ");
- }
-
- /* Date */
-
- date [0] = '\0';
- if (cpp->date_issue != NULL) {
- DateToGB (date, cpp->date_issue, FALSE);
- } else if (cpp->app_date != NULL) {
- DateToGB (date, cpp->app_date, FALSE);
- }
- if (! StringHasNoText (date)) {
- ValNodeCopyStr (&head, 0, date);
- }
-
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
- ValNodeCopyStr (&head, 0, ";");
- } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
- ValNodeCopyStr (&head, 0, ".");
- }
-
- alp = cpp->authors;
- if (alp != NULL) {
- afp = alp->affil;
- if (afp != NULL) {
- suffix = NULL;
- if (afp->choice == 2) {
- suffix = ";";
- }
-
- /* If and of the affiliation fields are */
- /* non-blank, put them on a new line. */
-
- if ((! StringHasNoText (afp->affil)) ||
- (! StringHasNoText (afp->street)) ||
- (! StringHasNoText (afp->div)) ||
- (! StringHasNoText (afp->city)) ||
- (! StringHasNoText (afp->sub)) ||
- (! StringHasNoText (afp->country)))
- ValNodeCopyStr (&head, 0, "\n");
-
- /* Write out the affiliation fields */
-
- if (! StringHasNoText (afp->affil)) {
- AddValNodeString (&head, NULL, afp->affil, suffix);
- prefix = " ";
- }
- if (! StringHasNoText (afp->street)) {
- AddValNodeString (&head, prefix, afp->street, ";");
- prefix = " ";
- }
- if (! StringHasNoText (afp->div)) {
- AddValNodeString (&head, prefix, afp->div, ";");
- prefix = " ";
- }
- if (! StringHasNoText (afp->city)) {
- AddValNodeString (&head, prefix, afp->city, NULL);
- prefix = ", ";
- }
- if (! StringHasNoText (afp->sub)) {
- AddValNodeString (&head, prefix, afp->sub, NULL);
- }
- if (! StringHasNoText (afp->country)) {
- AddValNodeString (&head, ";\n", afp->country, ";");
- }
- }
- }
-
- rsult = MergeValNodeStrings (head);
- ValNodeFreeData (head);
-
- /*
- s_StringCleanup(rsult);
- */
-
- return rsult;
-}
-
-static CharPtr FormatCitGen (
- FmtType format,
- Boolean dropBadCitGens,
- Boolean noAffilOnUnpub,
- CitGenPtr cgp
-)
-
-{
- CharPtr affil = NULL;
- AuthListPtr alp = NULL;
- Char ch;
- DatePtr dp;
- ValNodePtr head = NULL;
- CharPtr inpress = NULL;
- CharPtr journal = NULL;
- Char pages [128];
- CharPtr prefix = NULL;
- CharPtr ptr;
- CharPtr rsult = NULL;
- Char year [8];
-
- if (cgp == NULL) return NULL;
-
- if (cgp->journal == NULL && StringNICmp (cgp->cit, "unpublished", 11) == 0) {
- if (noAffilOnUnpub) {
-
- /* !!! temporarily put date in unpublished citation for QA !!! */
-
- if (dropBadCitGens) {
- year [0] = '\0';
- dp = cgp->date;
- if (dp != NULL) {
- if (dp->data [0] == 1) {
- if (dp->data [1] != 0) {
- sprintf (year, " (%ld)", (long) (1900 + dp->data [1]));
- }
- } else {
- StringCpy (year, " (");
- StringNCat (year, dp->str, 4);
- StringCat (year, ")");
- }
- }
- AddValNodeString (&head, NULL, "Unpublished", NULL);
- AddValNodeString (&head, NULL, year, NULL);
- rsult = MergeValNodeStrings (head);
- ValNodeFreeData (head);
- return rsult;
- }
-
- /* !!! remove above section once QA against asn2ff is done !!! */
-
- return StringSave ("Unpublished");
- }
-
- alp = cgp->authors;
- if (alp != NULL) {
- affil = GetAffil (alp->affil);
- if (! StringHasNoText (affil)) {
- rsult = MemNew ((size_t) StringLen (affil) + (size_t) StringLen (cgp->cit) + 15);
- StringCpy (rsult, "Unpublished ");
- StringCat (rsult, affil);
- TrimSpacesAroundString (rsult);
- return rsult;
- }
- }
-
- rsult = StringSave (cgp->cit);
- TrimSpacesAroundString (rsult);
- return rsult;
- }
-
- year [0] = '\0';
- dp = cgp->date;
- if (dp != NULL) {
- if (dp->data [0] == 1) {
- if (dp->data [1] != 0) {
- sprintf (year, " (%ld)", (long) (1900 + dp->data [1]));
- }
- } else {
- StringCpy (year, " (");
- StringNCat (year, dp->str, 4);
- StringCat (year, ")");
- }
- }
-
- pages [0] = '\0';
- if (cgp->pages != NULL) {
- FixPages (pages, cgp->pages);
- }
-
- if (cgp->journal != NULL) {
- journal = (CharPtr) cgp->journal->data.ptrvalue;
- }
- if (cgp->cit != NULL) {
- ptr = StringStr (cgp->cit, "Journal=\"");
- if (ptr != NULL) {
- journal = ptr + 9;
- } else if (StringNICmp (cgp->cit, "submitted", 8) == 0 ||
- StringNICmp (cgp->cit, "unpublished", 11) == 0) {
-
- if ((! dropBadCitGens) || journal != NULL) {
- inpress = cgp->cit;
- } else {
- inpress = "Unpublished";
- }
- } else if (StringNICmp (cgp->cit, "Online Publication", 18) == 0 ||
- StringNICmp (cgp->cit, "Published Only in DataBase", 26) == 0) {
-
- inpress = cgp->cit;
- } else if ((! dropBadCitGens) && journal == NULL) {
- journal = cgp->cit;
- }
- }
- if (journal != NULL) {
- journal = StringSave (journal);
- for (ptr = journal, ch = *ptr; ch != '\0'; ptr++, ch = *ptr) {
- if (ch == '=' || ch == '\"') {
- *ptr = '\0';
- }
- }
- ValNodeAddStr (&head, 0, journal);
- prefix = " ";
- }
-
- if (! StringHasNoText (inpress)) {
- AddValNodeString (&head, prefix, inpress, NULL);
- prefix = " ";
- }
-
- if (! StringHasNoText (cgp->volume)) {
- AddValNodeString (&head, prefix, cgp->volume, NULL);
- }
-
- if (! StringHasNoText (pages)) {
- if (format == GENBANK_FMT) {
- AddValNodeString (&head, ", ", pages, NULL);
- } else if (format == EMBL_FMT) {
- AddValNodeString (&head, ":", pages, NULL);
- }
- }
-
- if (! StringHasNoText (year)) {
- AddValNodeString (&head, NULL, year, NULL);
- }
-
- rsult = MergeValNodeStrings (head);
- ValNodeFreeData (head);
-
- return rsult;
-}
-
-static CharPtr FormatCitSub (
- FmtType format,
- CitSubPtr csp
-)
-
-{
- CharPtr affil;
- AffilPtr afp;
- AuthListPtr alp;
- Char buf [256];
- Char date [40];
- ValNodePtr head = NULL;
- CharPtr rsult = NULL;
-
- if (csp == NULL) return NULL;
-
- date [0] = '\0';
- if (csp->date != NULL) {
- DateToGB (date, csp->date, TRUE);
- }
- if (StringHasNoText (date)) {
- StringCpy (date, "??-???-????");
- }
-
- sprintf (buf, "Submitted (%s)", date);
- ValNodeCopyStr (&head, 0, buf);
-
- alp = csp->authors;
- if (alp != NULL) {
- afp = alp->affil;
- if (afp != NULL) {
- affil = GetAffil (afp);
- if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
- if (StringNCmp(affil, " to the EMBL/GenBank/DDBJ databases.", 36) != 0) {
- ValNodeCopyStr (&head, 0, " to the EMBL/GenBank/DDBJ databases.\n");
- } else {
- ValNodeCopyStr (&head, 0, " ");
- }
- } else {
- ValNodeCopyStr (&head, 0, " ");
- }
- ValNodeCopyStr (&head, 0, affil);
- MemFree (affil);
- } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
- ValNodeCopyStr (&head, 0, " to the EMBL/GenBank/DDBJ databases.\n");
- }
- }
-
- rsult = MergeValNodeStrings (head);
- ValNodeFreeData (head);
-
- return rsult;
-}
-
-static CharPtr GetPubJournal (
- FmtType format,
- Boolean dropBadCitGens,
- Boolean noAffilOnUnpub,
- Boolean citArtIsoJta,
- PubdescPtr pdp,
- CitSubPtr csp,
- SeqIdPtr seqidp,
- IndxPtr index
-)
-
-{
- CitArtPtr cap;
- CitBookPtr cbp;
- CitGenPtr cgp;
- CitPatPtr cpp;
- CharPtr journal = NULL;
- MedlineEntryPtr mep;
- ValNodePtr vnp;
-
- if (csp != NULL) {
- return FormatCitSub (format, csp);
- }
- if (pdp == NULL) return NULL;
-
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- switch (vnp->choice) {
- case PUB_Gen :
- cgp = (CitGenPtr) vnp->data.ptrvalue;
- if (cgp != NULL) {
- if (StringNICmp ("BackBone id_pub", cgp->cit, 15) != 0) {
- if (cgp->cit == NULL && cgp->journal == NULL && cgp->date == NULL && cgp->serial_number) {
- break; /* skip just serial number */
- }
- }
- journal = FormatCitGen (format, dropBadCitGens, noAffilOnUnpub, cgp);
- }
- break;
- case PUB_Sub :
- csp = (CitSubPtr) vnp->data.ptrvalue;
- if (csp != NULL) {
- journal = FormatCitSub (format, csp);
- }
- break;
- case PUB_Medline :
- mep = (MedlineEntryPtr) vnp->data.ptrvalue;
- if (mep != NULL) {
- cap = mep->cit;
- if (cap != NULL) {
- journal = FormatCitArt (format, citArtIsoJta, cap);
- }
- }
- break;
- case PUB_Article :
- cap = (CitArtPtr) vnp->data.ptrvalue;
- if (cap != NULL) {
- journal = FormatCitArt (format, citArtIsoJta, cap);
- }
- break;
- case PUB_Book :
- case PUB_Proc :
- cbp = (CitBookPtr) vnp->data.ptrvalue;
- if (cbp != NULL) {
- journal = FormatCitBook (format, cbp);
- }
- break;
- case PUB_Man :
- cbp = (CitBookPtr) vnp->data.ptrvalue;
- if (cbp != NULL) {
- journal = FormatThesis (format, cbp);
- }
- break;
- case PUB_Patent :
- cpp = (CitPatPtr) vnp->data.ptrvalue;
- if (cpp != NULL) {
- journal = FormatCitPat (format, cpp, seqidp);
- }
- break;
- default :
- break;
- }
-
- /* optionally populate indexes for NCBI internal database */
-
- if (index != NULL && journal != NULL) {
-
- /* skip non-informative cit-gens */
-
- if (StringNICmp (journal, "submitted", 8) == 0 ||
- StringNICmp (journal, "unpublished", 11) == 0 ||
- StringNICmp (journal, "Online Publication", 18) == 0 ||
- StringNICmp (journal, "Published Only in DataBase", 26) == 0) {
- } else {
- ValNodeCopyStrToHead (&(index->journals), 0, journal);
- }
- }
-
- if (journal != NULL) return journal;
- }
-
- return NULL;
-}
-
-static Int4 GetMuid (
- PubdescPtr pdp
-)
-
-{
- MedlineEntryPtr mep;
- ValNodePtr vnp;
-
- if (pdp == NULL) return 0;
-
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- switch (vnp->choice) {
- case PUB_Medline :
- mep = (MedlineEntryPtr) vnp->data.ptrvalue;
- if (mep != NULL) {
- return mep->uid;
- }
- break;
- case PUB_Muid :
- return vnp->data.intvalue;
- default :
- break;
- }
- }
-
- return 0;
-}
-
-static Int4 GetPmid (
- PubdescPtr pdp
-)
-
-{
- MedlineEntryPtr mep;
- ValNodePtr vnp;
-
- if (pdp == NULL) return 0;
-
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- switch (vnp->choice) {
- case PUB_Medline :
- mep = (MedlineEntryPtr) vnp->data.ptrvalue;
- if (mep != NULL) {
- return mep->pmid;
- }
- break;
- case PUB_PMid :
- return vnp->data.intvalue;
- default :
- break;
- }
- }
-
- return 0;
-}
-
-static CharPtr CleanQualValue (
- CharPtr str
-)
-
-{
- Char ch;
- CharPtr dst;
- CharPtr ptr;
-
- if (str == NULL || str [0] == '\0') return NULL;
-
- dst = str;
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- if (ch == '\n' || ch == '\r' || ch == '\t' || ch == '"') {
- *dst = ' ';
- dst++;
- } else {
- *dst = ch;
- dst++;
- }
- ptr++;
- ch = *ptr;
- }
- *dst = '\0';
-
- return str;
-}
-
-static CharPtr Asn2gnbkCompressSpaces (CharPtr str)
-
-{
- Char ch;
- CharPtr dst;
- Char last;
- CharPtr ptr;
-
- if (str != NULL && str [0] != '\0') {
- dst = str;
- ptr = str;
- ch = *ptr;
- while (ch != '\0' && ch <= ' ') {
- ptr++;
- ch = *ptr;
- }
- while (ch != '\0') {
- *dst = ch;
- dst++;
- ptr++;
- last = ch;
- ch = *ptr;
- if (ch != '\0' && ch < ' ') {
- *ptr = ' ';
- ch = *ptr;
- }
- while (ch != '\0' && last <= ' ' && ch <= ' ') {
- ptr++;
- ch = *ptr;
- }
- }
- *dst = '\0';
- dst = NULL;
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- if (ch != ' ') {
- dst = NULL;
- } else if (dst == NULL) {
- dst = ptr;
- }
- ptr++;
- ch = *ptr;
- }
- if (dst != NULL) {
- *dst = '\0';
- }
- }
- return str;
-}
-
-static CharPtr StripAllSpaces (
- CharPtr str
-)
-
-{
- Char ch;
- CharPtr dst;
- CharPtr ptr;
-
- if (str == NULL || str [0] == '\0') return NULL;
-
- dst = str;
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- if (ch == ' ' || ch == '\t') {
- } else {
- *dst = ch;
- dst++;
- }
- ptr++;
- ch = *ptr;
- }
- *dst = '\0';
-
- return str;
-}
-
-static CharPtr remarksText [] = {
- "full automatic", "full staff_review", "full staff_entry",
- "simple staff_review", "simple staff_entry", "simple automatic",
- "unannotated automatic", "unannotated staff_review", "unannotated staff_entry",
- NULL
-};
-
-static void AddReferenceToGbseq (
- GBSeqPtr gbseq,
- GBReferencePtr gbref,
- CharPtr str
-)
-
-{
- CharPtr copy;
- CharPtr ptr;
- CharPtr ref;
-
- if (gbseq == NULL || gbref == NULL || StringHasNoText (str)) return;
-
- copy = StringSave (str);
-
- /* link in reverse order, to be reversed in slash block */
-
- gbref->next = gbseq->references;
- gbseq->references = gbref;
-
- /* now parse or make ASN required default values for remaining fields */
-
- if (StringNCmp (copy, "REFERENCE ", 12) == 0) {
- ref = copy + 12;
- ptr = StringStr (ref, "\n AUTHORS");
- if (ptr == NULL) {
- ptr = StringStr (ref, ")\n");
- }
- if (ptr != NULL) {
- *ptr = '\0';
- gbref->reference = StringSave (ref);
- }
- }
-
- if (gbref->reference == NULL) {
- gbref->reference = StringSave ("?");
- }
-
- CleanQualValue (gbref->reference);
- Asn2gnbkCompressSpaces (gbref->reference);
-
- if (gbref->journal == NULL) {
- gbref->journal = StringSave ("?");
- }
-
- CleanQualValue (gbref->journal);
- Asn2gnbkCompressSpaces (gbref->journal);
-
- MemFree (copy);
-}
-
-static Boolean IsCitSub (
- PubdescPtr pdp,
- CitSubPtr csp
-)
-
-{
- ValNodePtr vnp;
-
- if (csp != NULL) return TRUE;
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- if (vnp->choice == PUB_Sub) return TRUE;
- }
- return FALSE;
-}
-
-static CharPtr FormatReferenceBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- AuthListPtr alp;
- Asn2gbSectPtr asp;
- BioseqPtr bsp;
- Char buf [150];
- CitArtPtr cap;
- Char ch;
- CitJourPtr cjp;
- Boolean citArtIsoJta;
- CharPtr consortium;
- CitRetractPtr crp;
- CitSubPtr csp = NULL;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- Int4 gibbsq;
- GBReferencePtr gbref = NULL;
- GBSeqPtr gbseq;
- Int2 i;
- ImprintPtr imp;
- IndxPtr index;
- IntRefBlockPtr irp;
- size_t len;
- SeqLocPtr loc = NULL;
- MedlineEntryPtr mep;
- Int4 muid = 0;
- Boolean needsPeriod = FALSE;
- SeqLocPtr nextslp;
- Boolean notFound;
- ObjMgrDataPtr omdp;
- PubdescPtr pdp = NULL;
- PubdescPtr pdpcopy = NULL;
- PubmedEntryPtr pep = NULL;
- Int4 pmid = 0;
- CharPtr prefix = NULL;
- RefBlockPtr rbp;
- SubmitBlockPtr sbp;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp = NULL;
- SeqIdPtr sip;
- SeqLocPtr slp;
- SeqSubmitPtr ssp;
- Int4 start;
- Int4 stop;
- CharPtr str;
- Boolean strict_isojta;
- CharPtr suffix = NULL;
- CharPtr tmp;
- Boolean trailingPeriod = TRUE;
- ValNodePtr vnp;
- StringItemPtr ffstring, temp;
-
- if (afp == NULL || bbp == NULL) return NULL;
- rbp = (RefBlockPtr) bbp;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
- bsp = asp->bsp;
- if (bsp == NULL) return NULL;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return NULL;
-
- if (ajp->index) {
- index = &asp->index;
- } else {
- index = NULL;
- }
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (! StringHasNoText (rbp->string)) return StringSave (rbp->string);
-
- /* could be descriptor, feature, or submit block citation */
-
- if (rbp->itemtype == OBJ_SEQDESC) {
-
- sdp = SeqMgrGetDesiredDescriptor (rbp->entityID, NULL, rbp->itemID, 0, NULL, &dcontext);
- if (sdp != NULL && dcontext.seqdesctype == Seq_descr_pub) {
- pdp = (PubdescPtr) sdp->data.ptrvalue;
- }
-
- } else if (rbp->itemtype == OBJ_SEQFEAT) {
-
- sfp = SeqMgrGetDesiredFeature (rbp->entityID, NULL, rbp->itemID, 0, NULL, &fcontext);
- if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_PUB) {
- pdp = (PubdescPtr) sfp->data.value.ptrvalue;
- }
-
- } else if (rbp->itemtype == OBJ_SEQSUB_CIT) {
-
- omdp = ObjMgrGetData (rbp->entityID);
- if (omdp != NULL && omdp->datatype == OBJ_SEQSUB) {
- ssp = (SeqSubmitPtr) omdp->dataptr;
- if (ssp != NULL && ssp->datatype == 1) {
- sbp = ssp->sub;
- if (sbp != NULL) {
- csp = sbp->cit;
- }
- }
- }
- }
-
- if (pdp == NULL && csp == NULL) return NULL;
-
- temp = FFGetString(ajp);
- if ( temp == NULL ) {
- FFRecycleString(ajp, ffstring);
- return NULL;
- }
-
- /* any justuids left at this point is RefSeq protein, and should be fetched */
-
- irp = (IntRefBlockPtr) rbp;
- if (irp->justuids) {
- if (rbp->pmid != 0) {
- pep = GetPubMedForUid (rbp->pmid);
- } else if (rbp->muid != 0) {
- pep = GetPubMedForUid (rbp->muid);
- }
- if (pep != NULL) {
- mep = (MedlineEntryPtr) pep->medent;
- if (mep != NULL && mep->cit != NULL) {
- pdpcopy = AsnIoMemCopy ((Pointer) pdp,
- (AsnReadFunc) PubdescAsnRead,
- (AsnWriteFunc) PubdescAsnWrite);
- cap = AsnIoMemCopy ((Pointer) mep->cit,
- (AsnReadFunc) CitArtAsnRead,
- (AsnWriteFunc) CitArtAsnWrite);
- vnp = ValNodeAddPointer (&(pdpcopy->pub), PUB_Article, (Pointer) cap);
- pdp = pdpcopy;
- }
- }
- }
-
- /* print serial number */
- FFStartPrint(temp, afp->format, 0, 12, "REFERENCE", 12, 5, 5, "RN", TRUE);
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- if (rbp->serial > 99) {
- sprintf (buf, "%d ", (int) rbp->serial);
- } else {
- sprintf (buf, "%d", (int) rbp->serial);
- }
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- sprintf (buf, "[%d]", (int) rbp->serial);
- }
-
- FFAddOneString(temp, buf, FALSE, FALSE, TILDE_TO_SPACES);
-
- /* print base range */
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
-
- if (rbp->sites != 3) {
- FFAddNChar(temp, ' ', 15 - temp->pos, FALSE);
- }
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
-
- if (rbp->sites == 0) {
- FFLineWrap(ffstring, temp, 0, 5, ASN2FF_EMBL_MAX, "RN");
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
- FFStartPrint(temp, afp->format, 0, 0, NULL, 0, 5, 5, "RP", FALSE);
- }
- }
-
- if (rbp->sites == 1 || rbp->sites == 2) {
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFAddOneString(temp, "(sites)", FALSE, FALSE, TILDE_TO_SPACES);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- } else {
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RP");
- }
- } else if (rbp->sites == 3) {
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- } else {
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RP");
- }
- } else {
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFAddNChar(temp, ' ', 15 - temp->pos, FALSE);
- if (afp->format == GENBANK_FMT) {
- FFAddOneString(temp, "(bases ", FALSE, FALSE, TILDE_TO_SPACES);
- } else {
- FFAddOneString(temp, "(residues ", FALSE, FALSE, TILDE_TO_SPACES);
- }
- }
-
- irp = (IntRefBlockPtr) rbp;
- loc = irp->loc;
-
- if (loc != NULL) {
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- suffix = "; ";
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- suffix = ", ";
- }
-
- slp = SeqLocFindNext (loc, NULL);
- while (slp != NULL) {
- nextslp = SeqLocFindNext (loc, slp);
- start = SeqLocStart (slp) + 1;
- stop = SeqLocStop (slp) + 1;
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- sprintf (buf, "%ld to %ld", (long) start, (long) stop);
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- sprintf (buf, "%ld-%ld", (long) start, (long) stop);
- }
- if (nextslp == NULL) {
- suffix = NULL;
- }
- FFAddTextToString(temp, NULL, buf, suffix, FALSE, FALSE, TILDE_TO_SPACES);
- slp = nextslp;
- }
-
- } else {
-
- /* code still used for ssp->cit */
-
- start = 1;
- stop = bsp->length;
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- sprintf (buf, "%ld to %ld", (long) start, (long) stop);
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- sprintf (buf, "%ld-%ld", (long) start, (long) stop);
- }
- FFAddOneString(temp, buf, FALSE, FALSE, TILDE_TO_SPACES);
- }
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFAddOneString(temp, ")", FALSE, FALSE, TILDE_TO_SPACES);
- }
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- } else {
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RP");
- }
- }
-
- if (gbseq != NULL) {
- gbref = GBReferenceNew ();
- }
-
- /* print author list */
-
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
- FFStartPrint(temp, afp->format, 2, 12, "AUTHORS", 12, 5, 5, "RA", FALSE);
-
- str = NULL;
- consortium = NULL;
-
- alp = GetAuthListPtr (pdp, csp);
- if (alp != NULL) {
- str = GetAuthorsString (afp->format, alp, &consortium, index, gbref);
- TrimSpacesAroundString (str);
- }
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- suffix = NULL;
- trailingPeriod = TRUE;
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- trailingPeriod = FALSE;
- len = StringLen (str);
- if (len > 0 && str [len - 1] != '.') {
- suffix = ".;";
- } else {
- suffix = ";";
- }
- }
-
- /* if no authors were found, period will still be added by this call */
- if (str != NULL) {
- FFAddTextToString(temp, NULL, str, suffix, trailingPeriod, FALSE, TILDE_TO_SPACES);
- } else {
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFAddOneChar(temp, '.', FALSE);
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- FFAddOneChar(temp, ';', FALSE);
- }
- }
-
- MemFree (str);
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- } else {
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RA");
- }
-
- /* print consortium */
-
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
- if (! StringHasNoText (consortium)) {
- FFStartPrint (temp, afp->format, 2, 12, "CONSRTM", 12, 5, 5, "CM", FALSE);
- FFAddTextToString (temp, NULL, consortium, suffix, FALSE, FALSE, TILDE_TO_SPACES);
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- } else {
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "CM");
- }
- }
- MemFree (consortium);
-
- /* print title */
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- str = GetPubTitle (afp->format, pdp, csp);
- CleanPubTitle (str);
- StrStripSpaces (str);
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- prefix = NULL;
- suffix = NULL;
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- if (str != NULL) {
- prefix = "\"";
- suffix = "\";";
- } else {
- prefix = NULL;
- suffix = ";";
- }
- }
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- if (! StringHasNoText (str)) {
- FFStartPrint (temp, afp->format, 2, 12, "TITLE", 12, 5, 5, "RT", FALSE);
-
- FFAddTextToString (temp, prefix, str, suffix, FALSE, FALSE, TILDE_TO_SPACES);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- }
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- FFStartPrint (temp, afp->format, 2, 12, "TITLE", 12, 5, 5, "RT", FALSE);
- if (! StringHasNoText (str)) {
-
- FFAddTextToString (temp, prefix, str, suffix, FALSE, FALSE, TILDE_TO_SPACES);
-
- } else {
- FFAddOneChar (temp, ';', FALSE);
- }
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RT");
- }
-
- if (gbseq != NULL) {
- if (gbref != NULL) {
- gbref->title = StringSaveNoNull (str);
- }
- }
-
- MemFree (str);
-
- /* print journal */
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- FFStartPrint (temp, afp->format, 2, 12, "JOURNAL", 12, 5, 5, "RL", FALSE);
-
- /* Only GenBank/EMBL/DDBJ require ISO JTA in ENTREZ/RELEASE modes (RefSeq should later) */
-
- citArtIsoJta = ajp->flags.citArtIsoJta;
- strict_isojta = FALSE;
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GENBANK ||
- sip->choice == SEQID_EMBL ||
- sip->choice == SEQID_DDBJ ||
- /* sip->choice == SEQID_OTHER || */
- sip->choice == SEQID_TPG ||
- sip->choice == SEQID_TPE ||
- sip->choice == SEQID_TPD) {
- strict_isojta = TRUE;
- }
- }
- if (! strict_isojta) {
- citArtIsoJta = FALSE;
- }
-
- str = GetPubJournal (afp->format, ajp->flags.dropBadCitGens,
- ajp->flags.noAffilOnUnpub, citArtIsoJta,
- pdp, csp, bsp->id, index);
- if (str == NULL) {
- str = StringSave ("Unpublished");
- }
- StrStripSpaces (str);
- TrimSpacesAroundString (str);
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- needsPeriod = FALSE;
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- if (! IsCitSub (pdp, csp)) {
- needsPeriod = TRUE;
- }
- }
-
- FFAddOneString (temp, str, FALSE, FALSE, TILDE_IGNORE);
- if (needsPeriod) {
- FFAddOneChar(temp, '.', FALSE);
- }
-
- if (gbseq != NULL) {
- if (gbref != NULL) {
- gbref->journal = StringSaveNoNull (str);
- tmp = gbref->journal;
- if (tmp != NULL) {
- ch = *tmp;
- while (ch != '\0') {
- if (ch == '\n' || ch == '\r' || ch == '\t') {
- *tmp = ' ';
- }
- tmp++;
- ch = *tmp;
- }
- TrimSpacesAroundString (gbref->journal);
- }
- }
- }
-
- MemFree (str);
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- } else {
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RL");
- }
-
- /* print muid */
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- muid = GetMuid (pdp);
- if (muid > 0) {
- FFStartPrint (temp, afp->format, 2, 12, "MEDLINE", 12, 5, 5, "RX", FALSE);
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- FF_www_muid (ajp, temp, muid);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- sprintf (buf, "MEDLINE; %ld.", (long) muid);
- FFAddOneString (temp, buf, FALSE, FALSE, TILDE_TO_SPACES);
- FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RX");
- }
- }
-
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
- pmid = GetPmid (pdp);
- if (pmid > 0) {
- FFStartPrint (temp, afp->format, 3, 12, "PUBMED", 12, 5, 5, "RX", FALSE);
-
- FF_www_muid (ajp, temp, pmid);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- }
- }
-
- if (gbseq != NULL) {
- if (gbref != NULL) {
- gbref->medline = muid;
- gbref->pubmed = pmid;
- }
- }
-
- if (pdp == NULL) {
- str = FFToCharPtr(ffstring);
-
- if (gbseq != NULL) {
- if (gbref != NULL) {
- AddReferenceToGbseq (gbseq, gbref, str);
- }
- }
-
- FFRecycleString(ajp, ffstring);
- FFRecycleString(ajp, temp);
- if (pep != NULL) {
- PubmedEntryFree (pep);
- }
- if (pdpcopy != NULL) {
- PubdescFree (pdpcopy);
- }
-
- return str;
- }
-
-
- /* !!! remainder of fields are only for GenBank !!! */
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
-
- prefix = "REMARK";
-
- if (pdp->comment != NULL) {
- for (i = 0, notFound = TRUE; notFound && remarksText [i] != NULL; i++) {
- if (StringCmp (pdp->comment, remarksText [i]) == 0) {
- notFound = FALSE;
- }
- }
- if (notFound) {
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
- FFAddOneString (temp, pdp->comment, FALSE, TRUE, TILDE_EXPAND);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- prefix = NULL;
-
- if (gbseq != NULL) {
- if (gbref != NULL) {
- gbref->remark = StringSave (pdp->comment);
- }
- }
-
- }
- }
-
- gibbsq = 0;
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GIBBSQ) {
- gibbsq = sip->data.intvalue;
- }
- }
- csp = NULL;
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- if (vnp->choice == PUB_Sub) {
- csp = (CitSubPtr) vnp->data.ptrvalue;
- }
- }
- if (gibbsq > 0 /* && csp == NULL */) {
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- sprintf (buf, "GenBank staff at the National Library of Medicine created this entry [NCBI gibbsq %ld] from the original journal article.", (long) gibbsq);
- FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
- FFAddOneString (temp, buf, FALSE, FALSE, TILDE_EXPAND);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- prefix = NULL;
-
- /* gibbsq comment section (fields may be copied from degenerate pubdesc) */
-
- str = pdp->fig;
- if (StringHasNoText (str)) {
- str = irp->fig;
- }
- if (! StringHasNoText (str)) {
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- sprintf (buf, "This sequence comes from %s", str);
- FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
- FFAddOneString (temp, buf, TRUE, TRUE, TILDE_EXPAND);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- prefix = NULL;
- }
-
- if (pdp->poly_a || irp->poly_a) {
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- FFStartPrint (temp ,afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
- FFAddOneString (temp, "Polyadenylate residues occurring in the figure were omitted from the sequence.", TRUE, TRUE, TILDE_EXPAND);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- prefix = NULL;
- }
-
- str = pdp->maploc;
- if (StringHasNoText (str)) {
- str = irp->maploc;
- }
- if (! StringHasNoText (str)) {
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- sprintf (buf, "Map location: %s", str);
- FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
- FFAddOneString (temp, buf, TRUE, TRUE, TILDE_EXPAND);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- prefix = NULL;
- }
-
- }
-
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- if (vnp->choice == PUB_Article) {
- cap = (CitArtPtr) vnp->data.ptrvalue;
- if (cap != NULL && cap->from == 1) {
- cjp = (CitJourPtr) cap->fromptr;
- if (cjp != NULL) {
- imp = cjp->imp;
- if (imp != NULL) {
- crp = imp->retract;
- if (crp != NULL && crp->type == 3) {
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
- FFAddOneString (temp, "Erratum:", FALSE, FALSE, TILDE_TO_SPACES);
- FFAddTextToString (temp, "[", crp->exp, "]", FALSE, TRUE, TILDE_EXPAND);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- prefix = NULL;
- }
- }
- }
- }
- } else if (vnp->choice == PUB_Sub) {
- csp = (CitSubPtr) vnp->data.ptrvalue;
- if (csp != NULL) {
- if (! StringHasNoText (csp->descr)) {
- FFRecycleString(ajp, temp);
- temp = FFGetString(ajp);
-
- FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
- FFAddOneString (temp, csp->descr, FALSE, TRUE, TILDE_EXPAND);
- FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
- prefix = NULL;
- }
- }
- }
- }
-
- }
-
- str = FFToCharPtr(ffstring);
-
- if (gbseq != NULL) {
- if (gbref != NULL) {
- AddReferenceToGbseq (gbseq, gbref, str);
- }
- }
-
- FFRecycleString(ajp, ffstring);
- FFRecycleString(ajp, temp);
- if (pep != NULL) {
- PubmedEntryFree (pep);
- }
- if (pdpcopy != NULL) {
- PubdescFree (pdpcopy);
- }
-
- return str;
-}
-
-/* A tilde is not an EOL if it is found in a sring of the form: */
-/* /~alpahnumdot/ where alphanumdot is either alpha numeric or '.' */
-/* */
-/* str points to the tilde in question. */
-static Boolean IsTildeEOL(CharPtr str) {
- CharPtr ptr;
-
- if ( *(str - 1) != '/' ) return TRUE;
-
- ++str;
-
-
- for ( ptr = str;
- IS_ALPHANUM(*ptr) || *ptr == '_' || *ptr == '-' || *ptr == '.';
- ++ptr) continue;
-
- return *ptr == '/' ? FALSE : TRUE;
-}
-
-
-/* returns a pointer to the first character past the url */
-static CharPtr FindUrlEnding(CharPtr str) {
- CharPtr ptr;
-
- for ( ptr = str;
- !IS_WHITESP(*ptr) && *ptr != '\0' && *ptr != '(' && *ptr != '\"';
- ++ptr ) {
- if ( *ptr == '~' ) {
- if ( IsTildeEOL(ptr) ) break;
- }
- }
-
- --ptr;
-
- /* back up over any trailing periods, commas, or parentheses */
- while ( (*ptr == '.') || (*ptr == ',') || (*ptr == ')') ) {
- --ptr;
- }
-
- ++ptr;
-
- return ptr;
-}
-
-static void AddCommentWithURLlinks (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr prefix,
- CharPtr str,
- CharPtr suffix
-)
-
-{
- Char ch;
- CharPtr ptr;
-
- while (! StringHasNoText (str)) {
- ptr = StringStr (str, "http://");
- if (ptr == NULL) {
- if (prefix != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- }
- AddStringWithTildes (ffstring, str);
- if (suffix != NULL) {
- FFAddOneString(ffstring, suffix, FALSE, FALSE, TILDE_IGNORE);
- }
- return;
- }
-
- *ptr = '\0';
- AddStringWithTildes (ffstring, str);
- *ptr = 'h';
-
- str = ptr;
- ptr = FindUrlEnding(str);
-
-
- ch = *ptr;
- *ptr = '\0';
- if ( GetWWW(ajp) ) {
- FFAddTextToString(ffstring, "<a href=", str, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, NULL, str, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- }
-
- *ptr = ch;
- str = ptr;
- }
-}
-
-static void CatenateCommentInGbseq (
- GBSeqPtr gbseq,
- CharPtr str
-)
-
-{
- Char ch;
- CharPtr tmp;
-
- if (gbseq == NULL || StringHasNoText (str)) return;
-
- if (StringNCmp (str, "COMMENT ", 12) == 0) {
- str += 12;
- }
- if (gbseq->comment == NULL) {
- gbseq->comment = StringSave (str);
- } else {
- tmp = (CharPtr) MemNew (StringLen (gbseq->comment) + StringLen (str) + 4);
- StringCpy (tmp, gbseq->comment);
- StringCat (tmp, "; ");
- StringCat (tmp, str);
- gbseq->comment = MemFree (gbseq->comment);
- gbseq->comment = tmp;
- }
-
- tmp = gbseq->comment;
- if (tmp == NULL) return;
- ch = *tmp;
- while (ch != '\0') {
- if (ch == '\n' || ch == '\r' || ch == '\t') {
- *tmp = ' ';
- }
- tmp++;
- ch = *tmp;
- }
- TrimSpacesAroundString (gbseq->comment);
- Asn2gnbkCompressSpaces (gbseq->comment);
-}
-
-
-static CharPtr FormatCommentBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- Boolean add_period;
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- CommentBlockPtr cbp;
- CharPtr db;
- DbtagPtr dbt;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- GBSeqPtr gbseq;
- size_t len;
- ObjectIdPtr oip;
- CharPtr prefix;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp;
- Char sfx [32];
- CharPtr str;
- CharPtr suffix;
- CharPtr title;
- StringItemPtr ffstring;
-
- if (afp == NULL || bbp == NULL) return NULL;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
-
- cbp = (CommentBlockPtr) bbp;
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- /* some comments are allocated (along with possible first COMMENT label) */
-
- if (! StringHasNoText (bbp->string)) {
- str = StringSave (bbp->string);
- CatenateCommentInGbseq (gbseq, str);
- return str;
- }
-
- title = NULL;
- prefix = NULL;
- suffix = NULL;
- add_period = FALSE;
- sfx [0] = '\0';
-
- if (bbp->itemtype == OBJ_SEQDESC) {
-
- /* usually should reference comment, maploc, or region descriptor IDs */
-
- sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID, 0, NULL, &dcontext);
- if (sdp != NULL) {
-
- if (dcontext.seqdesctype == Seq_descr_comment) {
-
- title = (CharPtr) sdp->data.ptrvalue;
-
- } else if (dcontext.seqdesctype == Seq_descr_maploc) {
-
- dbt = (DbtagPtr) sdp->data.ptrvalue;
- if (dbt != NULL) {
- db = dbt->db;
- oip = dbt->tag;
- if (oip != NULL) {
- if (oip->str != NULL) {
-
- title = oip->str;
- prefix = ("Map location: ");
-
- } else if (db != NULL && oip->id != 0) {
-
- title = db;
- prefix = ("Map location: (Database ");
- sprintf (sfx, "; id # %ld).", (long) oip->id);
- suffix = sfx;
-
- }
- }
- }
-
- } else if (dcontext.seqdesctype == Seq_descr_region) {
-
- title = (CharPtr) sdp->data.ptrvalue;
- prefix = "Region: ";
-
- }
- }
-
- } else if (bbp->itemtype == OBJ_SEQFEAT) {
-
- /* also have to deal with comment feature across entire sequence */
-
- sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
- if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_COMMENT) {
-
- title = sfp->comment;
- }
- }
-
- if (title == NULL) return NULL;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return NULL;
-
- if (cbp->first) {
- FFStartPrint (ffstring, afp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, afp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- str = StringSave (title);
- TrimSpacesAndJunkFromEnds (str, TRUE);
- if (! IsEllipsis (str)) {
- s_RemovePeriodFromEnd (str);
- len = StringLen (str);
- if (len > 0 && str [len - 1] != '.') {
- add_period = TRUE;
- }
- }
- AddCommentWithURLlinks(ajp, ffstring, prefix, str, suffix);
- /*
- if ( GetWWW(ajp) && prefix == NULL && suffix == NULL) {
-
- AddCommentWithURLlinks (ffstring, str);
- } else {
- FFAddTextToString (ffstring, prefix, str, suffix, FALSE, TRUE, TILDE_OLD_EXPAND);
- }
- */
- if (add_period) {
- FFAddOneChar (ffstring, '.',FALSE);
- }
- MemFree (str);
-
- str = FFEndPrint(ajp, ffstring, afp->format, 12, 12, 5, 5, "CC");
-
- CatenateCommentInGbseq (gbseq, str);
-
- FFRecycleString(ajp, ffstring);
- return str;
-}
-
-/* format features section */
-
-static Boolean is_real_id (
- SeqIdPtr sip,
- SeqIdPtr this_sip
-)
-
-{
- BioseqPtr bsp;
-
- if (sip == NULL || this_sip == NULL) return FALSE;
-
- if (! SeqIdIn (sip, this_sip)) {
- bsp = BioseqFind (sip);
- if (bsp == NULL) return TRUE; /* ??? */
- if (bsp->repr == Seq_repr_virtual) return FALSE;
- }
-
- return TRUE;
-}
-
-static Boolean FlatVirtLoc (
- BioseqPtr bsp,
- SeqLocPtr location
-)
-
-{
- SeqIntPtr sintp;
- SeqIdPtr sip;
- SeqPntPtr spp;
-
- if (bsp == NULL || location == NULL) return FALSE;
-
- switch (location->choice) {
- case SEQLOC_WHOLE :
- sip = (SeqIdPtr) location->data.ptrvalue;
- if (sip == NULL) return TRUE;
- if (! is_real_id (sip, bsp->id)) return TRUE;
- break;
- case SEQLOC_INT :
- sintp = (SeqIntPtr) location->data.ptrvalue;
- if (sintp == NULL) return TRUE;
- sip = sintp->id;
- if (sip == NULL) return TRUE;
- if (! is_real_id (sip, bsp->id)) return TRUE;
- break;
- case SEQLOC_PNT :
- spp = (SeqPntPtr) location->data.ptrvalue;
- if (spp == NULL) return TRUE;
- sip = spp->id;
- if (sip == NULL) return TRUE;
- if (! is_real_id (sip, bsp->id)) return TRUE;
- break;
- default :
- break;
- }
-
- return FALSE;
-}
-
-static Uint1 order [NUM_SEQID];
-static Boolean order_initialized = FALSE;
-
-static CharPtr lim_str [5] = { "", ">","<", ">", "<" };
-
-static Boolean GetAccnVerFromServer (Int4 gi, CharPtr buf)
-
-{
- AccnVerLookupFunc func;
- SeqMgrPtr smp;
- CharPtr str;
-
- if (buf == NULL) return FALSE;
- *buf = '\0';
- smp = SeqMgrWriteLock ();
- if (smp == NULL) return FALSE;
- func = smp->accn_ver_lookup_func;
- SeqMgrUnlock ();
- if (func == NULL) return FALSE;
- str = (*func) (gi);
- if (str == NULL) return FALSE;
- if (StringLen (str) < 40) {
- StringCpy (buf, str);
- }
- MemFree (str);
- return TRUE;
-}
-
-
-/******************************************************************************/
-/* FlatLoc functions . */
-/******************************************************************************/
-
-static Boolean FF_FlatNullAhead (
- BioseqPtr bsp,
- ValNodePtr location
-)
-
-{
- SeqLocPtr next;
-
- if (bsp == NULL || location == NULL) return FALSE;
-
- next = location->next;
- if (next == NULL) return TRUE;
- if (next->choice == SEQLOC_NULL) return TRUE;
- if (FlatVirtLoc (bsp, next)) return TRUE;
-
- return FALSE;
-}
-
-
-
-static void FlatLocSeqId (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- SeqIdPtr sip
-)
-
-{
- BioseqPtr bsp;
- Char buf [40];
- ObjectIdPtr oip;
- SeqIdPtr use_id = NULL;
- Boolean was_lock = FALSE;
-
- if (ffstring == NULL || sip == NULL) return;
-
- buf [0] = '\0';
- bsp = BioseqFind (sip);
- if (bsp != NULL) {
- use_id = SeqIdSelect (bsp->id, order, NUM_SEQID);
- } else if (sip->choice == SEQID_GI) {
- if (GetAccnVerFromServer (sip->data.intvalue, buf)) {
- FFAddTextToString(ffstring, NULL, buf, ":", FALSE, FALSE, TILDE_IGNORE);
- /*AddValNodeString (head, NULL, buf, ":");*/
- return;
- }
- use_id = GetSeqIdForGI (sip->data.intvalue);
- }
- if (use_id == NULL && bsp == NULL) {
- bsp = BioseqLockById (sip);
- was_lock = TRUE;
- if (bsp != NULL) {
- use_id = SeqIdSelect (bsp->id, order, NUM_SEQID);
- }
- }
- if (use_id != NULL) {
- SeqIdWrite (use_id, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
- if (use_id->choice == SEQID_GI) {
- ajp->relModeError = TRUE;
- }
- } else if (sip->choice == SEQID_GI) {
- SeqIdWrite (sip, buf, PRINTID_FASTA_LONG, sizeof (buf) - 1);
- ajp->relModeError = TRUE;
- } else {
- SeqIdWrite (sip, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
- if (sip->choice == SEQID_GI) {
- ajp->relModeError = TRUE;
- }
- }
- if (was_lock) {
- BioseqUnlock (bsp);
- }
- if (StringHasNoText (buf)) {
- StringCpy (buf, "?00000");
- ajp->relModeError = TRUE;
- if (use_id != NULL && use_id->choice == SEQID_LOCAL) {
- oip = (ObjectIdPtr) use_id->data.ptrvalue;
- if (oip != NULL && (! StringHasNoText (oip->str))) {
- StringNCpy_0 (buf, oip->str, 13);
- }
- }
- }
- FFAddTextToString(ffstring, NULL, buf, ":", FALSE, FALSE, TILDE_IGNORE);
-}
-
-
-
-static void FlatLocCaret (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- SeqIdPtr sip,
- SeqIdPtr this_sip,
- Int4 point,
- IntFuzzPtr fuzz
-)
-
-{
- Char buf [128];
- Uint1 index;
-
- if (ffstring == NULL) return;
-
- if (sip != NULL && (! SeqIdIn (sip, this_sip))) {
- FlatLocSeqId (ajp, ffstring, sip);
- }
-
- buf [0] = '\0';
- point++; /* orginal FlatLocHalfCaret was called with point + 1 */
-
- if (fuzz != NULL) {
- switch (fuzz->choice) {
- case 1 :
- sprintf (buf, "(%ld.%ld)..(%ld.%ld)",
- (long) (point - fuzz->a),
- (long) point,
- (long) point,
- (long) (point + fuzz->a));
- break;
- case 2 :
- sprintf (buf, "%ld^%ld",
- (long) (1 + fuzz->b),
- (long) (1 + fuzz->a));
- break;
- case 3 :
- sprintf (buf, "%ld^%ld",
- (long) (point - point * ((double) fuzz->a / 1000.0)),
- (long) (point + point * ((double) fuzz->a / 1000.0)));
- break;
- case 4 :
- if (fuzz->a == 3) { /* space to right */
- sprintf (buf, "%ld^%ld", (long) (point), (long) (point + 1));
- } else if (fuzz->a == 4 && point > 1) { /* space to left */
- sprintf (buf, "%ld^%ld", (long) (point - 1), (long) point);
- } else {
- index = (Uint1) fuzz->a;
- if (index > 4) {
- index = 0;
- }
- sprintf (buf, "%s%ld", lim_str [index], (long) point);
- }
- break;
- default :
- sprintf (buf, "%ld", (long) point);
- break;
- }
- } else {
- sprintf (buf, "%ld", (long) point);
- }
-
- FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
-}
-
-
-static void FlatLocPoint (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- SeqIdPtr sip,
- SeqIdPtr this_sip,
- Int4 point,
- IntFuzzPtr fuzz
-)
-
-{
- Char buf [128];
- Uint1 index;
-
- if (ffstring == NULL) return;
-
- if (sip != NULL && (! SeqIdIn (sip, this_sip))) {
- FlatLocSeqId (ajp, ffstring, sip);
- }
-
- buf [0] = '\0';
- point++;
-
- if (fuzz != NULL) {
- switch (fuzz->choice) {
- case 1 :
- sprintf (buf, "(%ld.%ld)",
- (long) (point - fuzz->a),
- (long) (point + fuzz->a));
- break;
- case 2 :
- sprintf (buf, "(%ld.%ld)",
- (long) (1 + fuzz->b),
- (long) (1 + fuzz->a));
- break;
- case 3 :
- sprintf (buf, "(%ld.%ld)",
- (long) (point - point * ((double) fuzz->a / 1000.0)),
- (long) (point + point * ((double) fuzz->a / 1000.0)));
- break;
- case 4 :
- index = (Uint1) fuzz->a;
- if (index > 4) {
- index = 0;
- }
- sprintf (buf, "%s%ld", lim_str [index], (long) point);
- break;
- default :
- sprintf (buf, "%ld", (long) point);
- break;
- }
- } else {
- sprintf (buf, "%ld", (long) point);
- }
-
- FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
-}
-
-
-static void FlatLocElement (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- BioseqPtr bsp,
- SeqLocPtr location
-)
-
-{
- Boolean minus_strand = FALSE;
- SeqBondPtr sbp;
- SeqIntPtr sintp;
- SeqIdPtr sip;
- SeqPntPtr spp;
- BioseqPtr wholebsp;
-
- if (ffstring == NULL || bsp == NULL || location == NULL) return;
-
- switch (location->choice) {
- case SEQLOC_WHOLE :
- sip = (SeqIdPtr) location->data.ptrvalue;
- if (sip == NULL) return;
- wholebsp = BioseqFind (sip);
- if (wholebsp == NULL) return;
- if (is_real_id (sip, bsp->id)) {
- FlatLocPoint (ajp, ffstring, sip, bsp->id, 0, NULL);
- if (bsp->length > 0) {
- FFAddOneString(ffstring, "..", FALSE, FALSE, TILDE_IGNORE);
- FlatLocPoint (ajp, ffstring, NULL, bsp->id, bsp->length - 1, NULL);
- }
- }
- break;
- case SEQLOC_INT :
- sintp = (SeqIntPtr) location->data.ptrvalue;
- if (sintp == NULL) return;
- sip = sintp->id;
- if (sip == NULL) return;
- if (is_real_id (sip, bsp->id)) {
- minus_strand = (Boolean) (sintp->strand == Seq_strand_minus);
- if (minus_strand) {
- FFAddOneString(ffstring, "complement(", FALSE, FALSE, TILDE_IGNORE);
- }
- FlatLocPoint (ajp, ffstring, sip, bsp->id, sintp->from, sintp->if_from);
- if (sintp->to > 0 &&
- (sintp->to != sintp->from ||
- sintp->if_from != NULL ||
- sintp->if_to != NULL)) {
- FFAddOneString(ffstring, "..", FALSE, FALSE, TILDE_IGNORE);
- FlatLocPoint (ajp, ffstring, NULL, bsp->id, sintp->to, sintp->if_to);
- }
- if (minus_strand) {
- FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
- }
- }
- break;
- case SEQLOC_PNT :
- spp = (SeqPntPtr) location->data.ptrvalue;
- if (spp == NULL) return;
- sip = spp->id;
- if (sip == NULL) return;
- if (is_real_id (sip, bsp->id)) {
- minus_strand = (Boolean) (spp->strand == Seq_strand_minus);
- if (minus_strand) {
- FFAddOneString(ffstring, "complement(", FALSE, FALSE, TILDE_IGNORE);
- }
- if (spp->fuzz != NULL) {
- FlatLocCaret (ajp, ffstring, sip, bsp->id, spp->point, spp->fuzz);
- } else {
- FlatLocPoint (ajp, ffstring, sip, bsp->id, spp->point, NULL);
- }
- if (minus_strand) {
- FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
- }
- }
- break;
- case SEQLOC_BOND :
- sbp = (SeqBondPtr) location->data.ptrvalue;
- if (sbp == NULL) return;
- spp = sbp->a;
- if (spp == NULL) return;
- sip = spp->id;
- if (sip == NULL) return;
- FFAddOneString(ffstring, "bond(", FALSE, FALSE, TILDE_IGNORE);
- FlatLocPoint (ajp, ffstring, sip, bsp->id, spp->point, spp->fuzz);
- spp = sbp->b;
- if (spp != NULL) {
- FFAddOneString(ffstring, ",", FALSE, FALSE, TILDE_IGNORE);
- FlatLocPoint (ajp, ffstring, NULL, bsp->id, spp->point, spp->fuzz);
- }
- FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
- break;
- default :
- /* unexpected internal complex type or unimplemented SEQLOC_FEAT */
- return;
- }
-}
-
-
-
-static void FF_FlatPackedPoint (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- PackSeqPntPtr pspp,
- BioseqPtr bsp
-)
-
-{
- Uint1 dex;
-
- if (ffstring == NULL || pspp == NULL || bsp == NULL) return;
-
- for (dex = 0; dex < pspp->used; dex++) {
- FlatLocPoint (ajp, ffstring, pspp->id, bsp->id, pspp->pnts [dex], pspp->fuzz);
- }
-}
-
-
-static void FF_DoFlatLoc (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- BioseqPtr bsp,
- SeqLocPtr location,
- Boolean ok_to_complement
-);
-
-static void FF_GroupFlatLoc (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- BioseqPtr bsp,
- SeqLocPtr location,
- CharPtr prefix,
- Boolean is_flat_order
-)
-
-{
- Boolean found_non_virt = FALSE;
- SeqIdPtr hold_next;
- Int2 parens = 1;
- PackSeqPntPtr pspp;
- SeqLocPtr slp;
- Boolean special_mode = FALSE; /* join in order */
-
- if (ffstring == NULL || bsp == NULL || location == NULL) return;
-
- /* prefix will have the first parenthesis */
-
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
-
- for (slp = (SeqLocPtr) location->data.ptrvalue; slp != NULL; slp = slp->next) {
-
- if (slp->choice == SEQLOC_NULL || FlatVirtLoc (bsp, slp)) {
- if (slp != location && slp->next != NULL) {
- if (special_mode) {
- special_mode = FALSE;
- FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
- parens--;
- }
- }
- continue;
- }
-
- if (found_non_virt && slp->choice != SEQLOC_EMPTY && slp->choice != SEQLOC_NULL) {
- FFAddOneString(ffstring, ",", FALSE, FALSE, TILDE_IGNORE);
- }
-
- switch (slp->choice) {
- case SEQLOC_WHOLE :
- case SEQLOC_PNT :
- case SEQLOC_BOND :
- case SEQLOC_FEAT :
- found_non_virt = TRUE;
- if (FlatVirtLoc (bsp, slp)) {
- if (slp != location && slp->next != NULL) {
- if (special_mode) {
- special_mode = FALSE;
- FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
- parens--;
- }
- }
- } else {
- FlatLocElement (ajp, ffstring, bsp, slp);
- }
- break;
- case SEQLOC_INT :
- found_non_virt = TRUE;
- if (is_flat_order && (! FF_FlatNullAhead (bsp, slp))) {
- special_mode = TRUE;
- FFAddOneString(ffstring, "join(", FALSE, FALSE, TILDE_IGNORE);
- parens++;
- }
- FlatLocElement (ajp, ffstring, bsp, slp);
- break;
- case SEQLOC_PACKED_PNT :
- found_non_virt = TRUE;
- pspp = (PackSeqPntPtr) slp->data.ptrvalue;
- if (pspp != NULL) {
- FF_FlatPackedPoint (ajp, ffstring, pspp, bsp);
- }
- break;
- case SEQLOC_PACKED_INT :
- case SEQLOC_MIX :
- case SEQLOC_EQUIV :
- found_non_virt = TRUE;
- hold_next = slp->next;
- slp->next = NULL;
- FF_DoFlatLoc (ajp, ffstring, bsp, slp, FALSE);
- slp->next = hold_next;
- break;
- default :
- break;
- }
-
- }
-
- while (parens > 0) {
- FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
- parens--;
- }
-}
-
-
-
-
-static void FF_DoFlatLoc (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- BioseqPtr bsp,
- SeqLocPtr location,
- Boolean ok_to_complement
-)
-
-{
- Boolean found_null;
- SeqLocPtr next_loc;
- PackSeqPntPtr pspp;
- SeqLocPtr slp;
-
- if (ffstring == NULL || bsp == NULL || location == NULL) return;
-
- /* deal with complement of entire location */
-
- if (ok_to_complement && SeqLocStrand (location) == Seq_strand_minus) {
- slp = AsnIoMemCopy ((Pointer) location,
- (AsnReadFunc) SeqLocAsnRead,
- (AsnWriteFunc) SeqLocAsnWrite);
- if (slp != NULL) {
- SeqLocRevCmp (slp);
- FFAddOneString(ffstring, "complement(", FALSE, FALSE, TILDE_IGNORE);
- FF_DoFlatLoc (ajp, ffstring, bsp, slp, FALSE);
- FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
- }
- SeqLocFree (slp);
- return;
- }
-
- /* handle each location component */
-
- for (slp = location; slp != NULL; slp = slp->next) {
-
- if (slp->choice == SEQLOC_NULL || FlatVirtLoc (bsp, slp)) continue;
-
- /* print comma between components */
-
- if (slp != location) {
- FFAddOneString(ffstring, ",", FALSE, FALSE, TILDE_IGNORE);
- }
-
- switch (slp->choice) {
- case SEQLOC_MIX :
- case SEQLOC_PACKED_INT :
- found_null = FALSE;
- for (next_loc = (SeqLocPtr) slp->data.ptrvalue;
- next_loc != NULL;
- next_loc = next_loc->next) {
- if (next_loc->choice == SEQLOC_NULL ||
- FlatVirtLoc (bsp, next_loc) /* ||
- LocationHasNullsBetween (slp) */ )
- found_null = TRUE;
- }
- if (found_null) {
- FF_GroupFlatLoc (ajp, ffstring, bsp, slp, "order(", TRUE);
- } else {
- FF_GroupFlatLoc (ajp, ffstring, bsp, slp, "join(", FALSE);
- }
- break;
- case SEQLOC_EQUIV :
- FF_GroupFlatLoc (ajp, ffstring, bsp, slp, "one-of(", FALSE);
- break;
- case SEQLOC_PACKED_PNT :
- pspp = (PackSeqPntPtr) slp->data.ptrvalue;
- if (pspp != NULL) {
- FF_FlatPackedPoint (ajp, ffstring, pspp, bsp);
- }
- break;
- default :
- FlatLocElement (ajp, ffstring, bsp, slp);
- break;
- }
-
- }
-}
-
-
-
-
-static CharPtr FlatLoc (
- IntAsn2gbJobPtr ajp,
- BioseqPtr bsp,
- SeqLocPtr location,
- Boolean masterStyle
-)
-
-{
- Boolean hasNulls;
- IntFuzzPtr fuzz = NULL;
- SeqLocPtr loc;
- Boolean noLeft;
- Boolean noRight;
- Uint1 num = 1;
- SeqPntPtr spp;
- CharPtr str;
- SeqLocPtr tmp;
- StringItemPtr ffstring = NULL;
-
- if (bsp == NULL || location == NULL) return NULL;
-
- ffstring = FFGetString(ajp);
-
- if (! order_initialized) {
- order [SEQID_GENBANK] = num++;
- order [SEQID_EMBL] = num++;
- order [SEQID_DDBJ] = num++;
- order [SEQID_OTHER] = num++;
- order [SEQID_TPG] = num++;
- order [SEQID_TPE] = num++;
- order [SEQID_TPD] = num++;
- order [SEQID_GIBBSQ] = num++;
- order [SEQID_GIBBMT] = num++;
- order [SEQID_PRF] = num++;
- order [SEQID_PDB] = num++;
- order [SEQID_PIR] = num++;
- order [SEQID_SWISSPROT] = num++;
- order [SEQID_PATENT] = num++;
- order [SEQID_GI] = num++;;
- order [SEQID_GENERAL] = num++;
- order [SEQID_LOCAL] = num++;
- order [SEQID_GIIM] = num++;
- order_initialized = TRUE;
- }
-
- if (masterStyle) {
-
- /* map location from parts to segmented bioseq */
-
- if (location->choice == SEQLOC_PNT) {
- spp = (SeqPntPtr) location->data.ptrvalue;
- if (spp != NULL) {
- fuzz = spp->fuzz;
- }
- }
-
- CheckSeqLocForPartial (location, &noLeft, &noRight);
- hasNulls = LocationHasNullsBetween (location);
- loc = SeqLocMerge (bsp, location, NULL, FALSE, TRUE, hasNulls);
- if (loc == NULL) {
- tmp = TrimLocInSegment (bsp, location, &noLeft, &noRight);
- loc = SeqLocMerge (bsp, tmp, NULL, FALSE, TRUE, hasNulls);
- SeqLocFree (tmp);
- }
- if (loc == NULL) {
- return StringSave ("?");
- }
- FreeAllFuzz (loc);
- SetSeqLocPartial (loc, noLeft, noRight);
-
- if (loc->choice == SEQLOC_PNT && fuzz != NULL) {
- spp = (SeqPntPtr) loc->data.ptrvalue;
- if (spp != NULL && spp->fuzz == NULL) {
- spp->fuzz = AsnIoMemCopy ((Pointer) fuzz,
- (AsnReadFunc) IntFuzzAsnRead,
- (AsnWriteFunc) IntFuzzAsnWrite);
- }
- }
-
- FF_DoFlatLoc (ajp, ffstring, bsp, loc, TRUE);
-
- SeqLocFree (loc);
-
- } else {
- FF_DoFlatLoc (ajp, ffstring, bsp, location, TRUE);
- }
-
- str = FFToCharPtr(ffstring);
- FFRecycleString(ajp, ffstring);
- return str;
-}
-
-
-
-
-static void PromoteSeqId (SeqIdPtr sip, Pointer userdata)
-
-{
- SeqIdPtr bestid, newid, oldid;
-
- bestid = (SeqIdPtr) userdata;
-
- newid = SeqIdDup (bestid);
- if (newid == NULL) return;
-
- oldid = ValNodeNew (NULL);
- if (oldid == NULL) return;
-
- MemCopy (oldid, sip, sizeof (ValNode));
- oldid->next = NULL;
-
- sip->choice = newid->choice;
- sip->data.ptrvalue = newid->data.ptrvalue;
-
- SeqIdFree (oldid);
- ValNodeFree (newid);
-
- SeqIdStripLocus (sip);
-}
-
-static SeqLocPtr SeqLocReMapEx (SeqIdPtr newid, SeqLocPtr seq_loc, SeqLocPtr location, Int4 offset, Boolean rev, Boolean masterStyle)
-
-{
- BioseqPtr bsp;
- Boolean hasNulls;
- IntFuzzPtr fuzz = NULL;
- SeqLocPtr loc;
- Boolean noLeft;
- Boolean noRight;
- Uint1 num = 1;
- SeqEntryPtr scope;
- SeqIdPtr sip;
- SeqLocPtr slp = NULL;
- SeqPntPtr spp;
- SeqLocPtr tmp;
-
- if (newid == NULL || seq_loc == NULL || location == NULL) return NULL;
-
- if (masterStyle) {
-
- sip = SeqLocId (seq_loc);
- if (sip == NULL) return NULL;
- bsp = BioseqFind (sip);
- if (bsp == NULL) {
- scope = SeqEntrySetScope (NULL);
- bsp = BioseqFind (sip);
- SeqEntrySetScope (scope);
- }
- if (bsp == NULL) return NULL;
- sip = SeqIdFindBest (bsp->id, 0);
-
- /* map location from parts to segmented bioseq */
-
- if (location->choice == SEQLOC_PNT) {
- spp = (SeqPntPtr) location->data.ptrvalue;
- if (spp != NULL) {
- fuzz = spp->fuzz;
- }
- }
-
- CheckSeqLocForPartial (location, &noLeft, &noRight);
- hasNulls = LocationHasNullsBetween (location);
- loc = SeqLocMerge (bsp, location, NULL, FALSE, TRUE, hasNulls);
- if (loc == NULL) {
- tmp = TrimLocInSegment (bsp, location, &noLeft, &noRight);
- loc = SeqLocMerge (bsp, tmp, NULL, FALSE, TRUE, hasNulls);
- SeqLocFree (tmp);
- }
- if (loc == NULL) {
- return NULL;
- }
- FreeAllFuzz (loc);
- SetSeqLocPartial (loc, noLeft, noRight);
-
- if (loc->choice == SEQLOC_PNT && fuzz != NULL) {
- spp = (SeqPntPtr) loc->data.ptrvalue;
- if (spp != NULL && spp->fuzz == NULL) {
- spp->fuzz = AsnIoMemCopy ((Pointer) fuzz,
- (AsnReadFunc) IntFuzzAsnRead,
- (AsnWriteFunc) IntFuzzAsnWrite);
- }
- }
-
- scope = SeqEntrySetScope (NULL);
- slp = SeqLocReMap (newid, seq_loc, loc, offset, rev);
- SeqEntrySetScope (scope);
-
- SeqLocFree (loc);
-
- VisitSeqIdsInSeqLoc (slp, (Pointer) sip, PromoteSeqId);
- } else {
-
- scope = SeqEntrySetScope (NULL);
- slp = SeqLocReMap (newid, seq_loc, location, offset, rev);
- SeqEntrySetScope (scope);
- }
-
- return slp;
-}
-
-
-/******************************************************************************/
-/* End FlatLoc functions. */
-/******************************************************************************/
-
-
-
-static void SubSourceToQualArray (
- SubSourcePtr ssp,
- QualValPtr qvp
-)
-
-{
- Int2 idx;
- Uint1 subtype;
-
- if (ssp == NULL || qvp == NULL) return;
-
- while (ssp != NULL) {
- subtype = ssp->subtype;
- if (subtype == 255) {
- subtype = 29;
- }
- if (subtype < 30) {
- idx = subSourceToSourceIdx [subtype];
- if (idx > 0 && idx < ASN2GNBK_TOTAL_SOURCE) {
- if (qvp [idx].ssp == NULL) {
- qvp [idx].ssp = ssp;
- }
- }
- }
- ssp = ssp->next;
- }
-}
-
-static Int2 orgModToSourceIdx [38] = {
- SCQUAL_zero_orgmod,
- SCQUAL_one_orgmod,
- SCQUAL_strain,
- SCQUAL_sub_strain,
- SCQUAL_type,
- SCQUAL_sub_type,
- SCQUAL_variety,
- SCQUAL_serotype,
- SCQUAL_serogroup,
- SCQUAL_serovar,
- SCQUAL_cultivar,
- SCQUAL_pathovar,
- SCQUAL_chemovar,
- SCQUAL_biovar,
- SCQUAL_biotype,
- SCQUAL_group,
- SCQUAL_sub_group,
- SCQUAL_isolate,
- SCQUAL_common,
- SCQUAL_acronym,
- SCQUAL_dosage,
- SCQUAL_spec_or_nat_host,
- SCQUAL_sub_species,
- SCQUAL_specimen_voucher,
- SCQUAL_authority,
- SCQUAL_forma,
- SCQUAL_forma_specialis,
- SCQUAL_ecotype,
- SCQUAL_synonym,
- SCQUAL_anamorph,
- SCQUAL_teleomorph,
- SCQUAL_breed,
- SCQUAL_gb_acronym,
- SCQUAL_gb_anamorph,
- SCQUAL_gb_synonym,
- SCQUAL_old_lineage,
- SCQUAL_old_name,
- SCQUAL_orgmod_note
-};
-
-static void OrgModToQualArray (
- OrgModPtr omp,
- QualValPtr qvp
-)
-
-{
- Int2 idx;
- Uint1 subtype;
-
- if (omp == NULL || qvp == NULL) return;
-
- while (omp != NULL) {
- subtype = omp->subtype;
- if (subtype == 253) {
- subtype = 35;
- } else if (subtype == 254) {
- subtype = 36;
- } else if (subtype == 255) {
- subtype = 37;
- }
- if (subtype < 38) {
- idx = orgModToSourceIdx [subtype];
- if (idx > 0 && idx < ASN2GNBK_TOTAL_SOURCE) {
- if (qvp [idx].omp == NULL) {
- qvp [idx].omp = omp;
- }
- }
- }
- omp = omp->next;
- }
-}
-
-static CharPtr organelleQual [] = {
- NULL,
- NULL,
- "/organelle=\"plastid:chloroplast\"",
- "/organelle=\"plastid:chromoplast\"",
- "/organelle=\"mitochondrion:kinetoplast\"",
- "/organelle=\"mitochondrion\"",
- "/organelle=\"plastid\"",
- "/macronuclear",
- NULL,
- "/plasmid=\"\"",
- "/transposon=\"\"",
- "/insertion_seq=\"\"",
- "/organelle=\"plastid:cyanelle\"",
- "/proviral",
- "/virion",
- "/organelle=\"nucleomorph\"",
- "/organelle=\"plastid:apicoplast\"",
- "/organelle=\"plastid:leucoplast\"",
- "/organelle=\"plastid:proplastid\"",
- NULL
-};
-
-static Boolean StringIsJustQuotes (
- CharPtr str
-)
-
-{
- Nlm_Uchar ch; /* to use 8bit characters in multibyte languages */
-
- if (str != NULL) {
- ch = *str;
- while (ch != '\0') {
- if (ch > ' ' && ch != '"' && ch != '\'') {
- return FALSE;
- }
- str++;
- ch = *str;
- }
- }
- return TRUE;
-}
-
-static CharPtr RemoveAllSpaces (
- CharPtr str
-)
-
-{
- Char ch;
- CharPtr dst;
- CharPtr ptr;
-
- if (str == NULL || str [0] == '\0') return NULL;
-
- dst = str;
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- if (ch != ' ') {
- *dst = ch;
- dst++;
- }
- ptr++;
- ch = *ptr;
- }
- *dst = '\0';
-
- return str;
-}
-
-static void AddFeatureToGbseq (
- GBSeqPtr gbseq,
- GBFeaturePtr gbfeat,
- CharPtr str,
- SeqFeatPtr sfp
-)
-
-{
- Char ch;
- CharPtr copy;
- GBQualifierPtr gbqual;
- GBQualifierPtr last = NULL;
- CharPtr ptr;
- CharPtr qual;
- CharPtr val;
-
- if (gbseq == NULL || gbfeat == NULL || StringHasNoText (str)) return;
-
- copy = StringSave (str);
-
- /* link in reverse order, to be reversed in slash block */
-
- gbfeat->next = gbseq->feature_table;
- gbseq->feature_table = gbfeat;
-
- /* now parse qualifiers */
-
- ptr = StringStr (copy, " /");
- while (ptr != NULL) {
- qual = ptr + 22;
- val = qual;
- ch = *val;
- while (ch != '=' && ch != '\n' && ch != '\0') {
- val++;
- ch = *val;
- }
- /*
- val = StringChr (qual, '=');
- if (val == NULL) {
- val = StringChr (qual, '\n');
- }
- */
- if (ch != '\0' /* val != NULL */) {
- *val = '\0';
- val++;
- if (ch == '=') {
- if (*val == '"') {
- val++;
- }
- ptr = StringStr (val, "\n /");
- if (ptr != NULL) {
- *ptr = '\0';
- ptr++;
- }
- } else {
- ptr = StringStr (val, " /");
- val = NULL;
- }
- gbqual = GBQualifierNew ();
- if (gbqual != NULL) {
- gbqual->name = StringSave (qual);
- if (! StringHasNoText (val)) {
- gbqual->value = StringSave (val);
- CleanQualValue (gbqual->value);
- Asn2gnbkCompressSpaces (gbqual->value);
- if (sfp != NULL) {
- if (sfp->data.choice == SEQFEAT_CDREGION &&
- StringICmp (qual, "translation") == 0) {
- RemoveAllSpaces (gbqual->value);
- } else if (sfp->data.choice == SEQFEAT_RNA &&
- StringICmp (qual, "transcription") == 0) {
- RemoveAllSpaces (gbqual->value);
- } else if (sfp->data.choice == SEQFEAT_PROT &&
- StringICmp (qual, "peptide") == 0) {
- RemoveAllSpaces (gbqual->value);
- }
- }
- }
- }
- } else {
- gbqual = GBQualifierNew ();
- if (gbqual != NULL) {
- gbqual->name = StringSave (qual);
- }
- }
- if (gbfeat->quals == NULL) {
- gbfeat->quals = gbqual;
- } else if (last != NULL) {
- last->next = gbqual;
- }
- last = gbqual;
- }
-
- MemFree (copy);
-}
-
-static CharPtr GetMolTypeQual (
- BioseqPtr bsp
-)
-
-{
- SeqMgrDescContext dcontext;
- MolInfoPtr mip;
- SeqDescrPtr sdp;
-
- if (bsp == NULL) return NULL;
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp == NULL) return NULL;
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip == NULL) return NULL;
-
- switch (mip->biomol) {
- case 0 :
- switch (bsp->mol) {
- case Seq_mol_dna :
- return "unassigned DNA";
- case Seq_mol_rna :
- return "unassigned RNA";
- case Seq_mol_na :
- break;
- default :
- break;
- }
- break;
- case MOLECULE_TYPE_GENOMIC :
- switch (bsp->mol) {
- case Seq_mol_dna :
- return "genomic DNA";
- case Seq_mol_rna :
- return "genomic RNA";
- case Seq_mol_na :
- break;
- default :
- break;
- }
- break;
- case MOLECULE_TYPE_PRE_MRNA :
- return "pre-RNA";
- case MOLECULE_TYPE_MRNA :
- return "mRNA";
- case MOLECULE_TYPE_RRNA :
- return "rRNA";
- case MOLECULE_TYPE_TRNA :
- return "tRNA";
- case MOLECULE_TYPE_SNRNA :
- return "snRNA";
- case MOLECULE_TYPE_SCRNA :
- return "scRNA";
- case MOLECULE_TYPE_PEPTIDE :
- break;
- case MOLECULE_TYPE_OTHER_GENETIC_MATERIAL :
- switch (bsp->mol) {
- case Seq_mol_dna :
- return "other DNA";
- case Seq_mol_rna :
- return "other RNA";
- case Seq_mol_na :
- break;
- default :
- break;
- }
- break;
- case MOLECULE_TYPE_GENOMIC_MRNA_MIX :
- break;
- case MOLECULE_TYPE_CRNA :
- return "other RNA";
- break;
- case MOLECULE_TYPE_SNORNA :
- return "snoRNA";
- break;
- case MOLECULE_TYPE_TRANSCRIBED_RNA :
- return "other RNA";
- break;
- case 255 :
- switch (bsp->mol) {
- case Seq_mol_dna :
- return "other DNA";
- case Seq_mol_rna :
- return "other RNA";
- case Seq_mol_na :
- break;
- default :
- break;
- }
- break;
- default :
- break;
- }
-
- return NULL;
-}
-
-static CharPtr FormatSourceFeatBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- Boolean add_period;
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BioSourcePtr biop = NULL;
- BioseqPtr bsp;
- Char buf [80];
- CharPtr common = NULL;
- DbtagPtr dbt;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- GBFeaturePtr gbfeat = NULL;
- GBSeqPtr gbseq;
- Int2 i;
- Uint1 idx;
- IntSrcBlockPtr isp;
- Boolean is_desc = TRUE;
- Int2 j;
- Uint1 jdx;
- Uint1 lastomptype;
- Uint1 lastssptype;
- SeqLocPtr location = NULL;
- CharPtr notestr;
- Uint1Ptr notetbl = NULL;
- Boolean okay;
- ObjectIdPtr oip;
- OrgModPtr omp;
- OrgNamePtr onp = NULL;
- OrgRefPtr orp = NULL;
- CharPtr prefix;
- Uint1Ptr qualtbl = NULL;
- QualValPtr qvp;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp = NULL;
- SubSourcePtr ssp;
- CharPtr str;
- CharPtr taxname = NULL;
- ValNodePtr vnp;
- StringItemPtr ffstring, unique;
-
- if (afp == NULL || bbp == NULL) return NULL;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
- bsp = asp->bsp;
- if (bsp == NULL) return NULL;
- qvp = afp->qvp;
- if (qvp == NULL) return NULL;
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (! StringHasNoText (bbp->string)) return StringSave (bbp->string);
-
- isp = (IntSrcBlockPtr) bbp;
-
- /* could be descriptor or feature */
-
- if (bbp->itemtype == OBJ_SEQDESC) {
- sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID, 0, NULL, &dcontext);
- if (sdp != NULL && dcontext.seqdesctype == Seq_descr_source) {
- biop = (BioSourcePtr) sdp->data.ptrvalue;
- }
- } else if (bbp->itemtype == OBJ_SEQFEAT) {
- sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
- if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_BIOSRC) {
- biop = (BioSourcePtr) sfp->data.value.ptrvalue;
- }
- is_desc = FALSE;
- }
-
- if (biop == NULL) return NULL;
-
- unique = FFGetString(ajp);
- if ( unique == NULL ) return NULL;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return NULL;
-
- FFStartPrint (ffstring, afp->format, 5, 21, NULL, 0, 5, 21, "FT", FALSE);
- FFAddOneString (ffstring, "source", FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 21 - 5 - StringLen("source"), FALSE);
-
- if (gbseq != NULL) {
- gbfeat = GBFeatureNew ();
- if (gbfeat != NULL) {
- gbfeat->key = StringSave ("source");
- }
- }
-
- location = isp->loc;
-
- str = FlatLoc (ajp, bsp, location, ajp->masterStyle);
- if ( GetWWW(ajp) ) {
- FF_www_featloc (ffstring, str);
- } else {
- FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneChar(ffstring, '\n', FALSE);
-
- if (gbseq != NULL) {
- if (gbfeat != NULL) {
- if (! StringHasNoText (str)) {
- gbfeat->location = StringSave (str);
- } else {
- gbfeat->location = StringSave ("");
- }
- }
- }
-
- MemFree (str);
-
- orp = biop->org;
- if (orp != NULL) {
- taxname = orp->taxname;
- /* common = orp->common; */
- }
- if (StringHasNoText (taxname)) {
- if (ajp->flags.needOrganismQual) {
- taxname = "unknown";
- common = orp->common;
-#ifdef ASN2GNBK_PRINT_UNKNOWN_ORG
- } else {
- taxname = "unknown";
- common = orp->common;
-#endif
- }
- }
-
- /* populate qualifier table from biosource fields */
-
- qvp [SCQUAL_organism].str = taxname;
- qvp [SCQUAL_common_name].str = common;
-
- if (biop->is_focus) {
- qvp [SCQUAL_focus].ble = TRUE;
- }
-
- str = GetMolTypeQual (bsp);
- if (str == NULL) {
- switch (bsp->mol) {
- case Seq_mol_dna :
- str = "unassigned DNA";
- break;
- case Seq_mol_rna :
- str = "unassigned RNA";
- break;
- case Seq_mol_aa :
- break;
- default :
- str = "unassigned DNA";
- break;
- }
- }
- qvp [SCQUAL_mol_type].str = str;
-
- SubSourceToQualArray (biop->subtype, qvp);
-
- if (orp != NULL) {
- onp = orp->orgname;
- if (onp != NULL) {
- OrgModToQualArray (onp->mod, qvp);
- }
-
- if (! is_desc) {
- qvp [SCQUAL_unstructured].vnp = orp->mod;
- }
- qvp [SCQUAL_db_xref].vnp = orp->db;
- }
-
- if (sfp != NULL) {
- qvp [SCQUAL_org_xref].vnp = sfp->dbxref;
- }
-
- /* organelle currently prints /mitochondrion, /virion, etc. */
-
- qvp [SCQUAL_organelle].num = biop->genome;
-
- /* some qualifiers are flags in genome and names in subsource, print once with name */
-
- if (qvp [SCQUAL_ins_seq_name].ssp != NULL &&
- qvp [SCQUAL_organelle].num == GENOME_insertion_seq) {
- qvp [SCQUAL_organelle].num = 0;
- }
- if (qvp [SCQUAL_plasmid_name].ssp != NULL &&
- qvp [SCQUAL_organelle].num == GENOME_plasmid) {
- qvp [SCQUAL_organelle].num = 0;
- }
- /* AF095904.1
- if (qvp [SCQUAL_plastid_name].ssp != NULL &&
- qvp [SCQUAL_organelle].num == GENOME_plastid) {
- qvp [SCQUAL_organelle].num = 0;
- }
- */
- if (qvp [SCQUAL_transposon_name].ssp != NULL &&
- qvp [SCQUAL_organelle].num == GENOME_transposon) {
- qvp [SCQUAL_organelle].num = 0;
- }
-
- if (sfp != NULL) {
- qvp [SCQUAL_seqfeat_note].str = sfp->comment;
- }
-
- /* now print qualifiers from table */
-
- qualtbl = source_qual_order;
- if (is_desc) {
- notetbl = source_desc_note_order;
- } else {
- notetbl = source_feat_note_order;
- }
-
- for (i = 0, idx = qualtbl [i]; idx != 0; i++, idx = qualtbl [i]) {
-
- lastomptype = 0;
- lastssptype = 0;
- switch (asn2gnbk_source_quals [idx].qualclass) {
-
- case Qual_class_ignore :
- break;
-
- case Qual_class_string :
- if (! StringHasNoText (qvp [idx].str)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=",
- FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
- FALSE, FALSE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_boolean :
- if (qvp [idx].ble) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "\n",
- FALSE, TRUE, TILDE_IGNORE);
- }
- break;
-
- case Qual_class_organelle :
- j = (Int2) qvp [idx].num;
- if (organelleQual [j] != NULL) {
- FFAddTextToString(ffstring, NULL, organelleQual[j], "\n",
- FALSE, FALSE, TILDE_IGNORE);
- }
- break;
-
- case Qual_class_orgmod :
- omp = qvp [idx].omp;
- if (lastomptype == 0 && omp != NULL) {
- lastomptype = omp->subtype;
- }
- while (omp != NULL && omp->subtype == lastomptype) {
- if (StringIsJustQuotes (omp->subname)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=\"\"\n",
- FALSE, TRUE, TILDE_IGNORE);
- } else if (! StringHasNoText (omp->subname)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", omp->subname, "\"\n",
- FALSE, TRUE, TILDE_TO_SPACES);
- }
- omp = omp->next;
- }
- break;
-
- case Qual_class_subsource :
- ssp = qvp [idx].ssp;
- if (lastssptype == 0 && ssp != NULL) {
- lastssptype = ssp->subtype;
- }
- while (ssp != NULL && ssp->subtype == lastssptype) {
- if (ssp->subtype == SUBSRC_germline ||
- ssp->subtype == SUBSRC_rearranged ||
- ssp->subtype == SUBSRC_transgenic ||
- ssp->subtype == SUBSRC_environmental_sample) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "\n",
- FALSE, TRUE, TILDE_TO_SPACES);
- } else if (StringIsJustQuotes (ssp->name)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=\"\"\n",
- FALSE, TRUE, TILDE_IGNORE);
- } else if (! StringHasNoText (ssp->name)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", ssp->name, "\"\n",
- FALSE, TRUE, TILDE_TO_SPACES);
- }
- ssp = ssp->next;
- }
- break;
-
- case Qual_class_pubset :
- break;
-
- case Qual_class_quote :
- break;
-
- case Qual_class_noquote :
- break;
-
- case Qual_class_label :
- break;
-
- case Qual_class_db_xref :
- for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
- buf [0] = '\0';
- dbt = (DbtagPtr) vnp->data.ptrvalue;
- if (dbt != NULL && (! StringHasNoText (dbt->db))) {
- oip = dbt->tag;
- if (oip != NULL) {
-
- okay = TRUE;
- if (ajp->flags.dropBadDbxref) {
- /* if RELEASE_MODE, drop unknown dbtag */
- okay = FALSE;
- for (j = 0; legalDbXrefs [j] != NULL; j++) {
- if (StringCmp (dbt->db, legalDbXrefs [j]) == 0) {
- okay = TRUE;
- }
- }
- }
-
- if (okay) {
- if (! StringHasNoText (oip->str)) {
- if (StringLen (dbt->db) + StringLen (oip->str) < 80) {
- sprintf (buf, "%s", oip->str);
- }
- } else {
- sprintf (buf, "%ld", (long) oip->id);
- }
- }
- }
- }
- if (! StringHasNoText (buf)) {
- FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
- FF_www_db_xref(ajp, ffstring, dbt->db, buf);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- }
- }
- break;
-
- case Qual_class_illegal :
- break;
-
- case Qual_class_note :
- if (! ajp->flags.srcQualsToNote) {
-
- /* in sequin_mode and dump_mode, all orgmods and subsources show up as separate /qualifiers */
-
- for (j = 0, jdx = notetbl [j]; jdx != 0; j++, jdx = notetbl [j]) {
-
- lastomptype = 0;
- lastssptype = 0;
- switch (asn2gnbk_source_quals [jdx].qualclass) {
-
- case Qual_class_orgmod :
- if (jdx == SCQUAL_orgmod_note) break;
- omp = qvp [jdx].omp;
- if (lastomptype == 0 && omp != NULL) {
- lastomptype = omp->subtype;
- }
- while (omp != NULL && omp->subtype == lastomptype) {
- if (StringIsJustQuotes (omp->subname)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [jdx].name, "=\"\"\n",
- FALSE, TRUE, TILDE_IGNORE);
- } else if (! StringHasNoText (omp->subname)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [jdx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", omp->subname, "\"\n",
- FALSE, TRUE, TILDE_TO_SPACES);
- }
- omp = omp->next;
- }
- break;
-
- case Qual_class_subsource :
- if (jdx == SCQUAL_subsource_note) break;
- ssp = qvp [jdx].ssp;
- if (lastssptype == 0 && ssp != NULL) {
- lastssptype = ssp->subtype;
- }
- while (ssp != NULL && ssp->subtype == lastssptype) {
- if (StringIsJustQuotes (ssp->name)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [jdx].name, "=\"\"\n",
- FALSE, TRUE, TILDE_IGNORE);
-
- } else if (! StringHasNoText (ssp->name)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [jdx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", ssp->name, "\"\n",
- FALSE, TRUE, TILDE_TO_SPACES);
- }
- ssp = ssp->next;
- }
- break;
-
- default :
- break;
- }
- }
- }
-
- notestr = NULL;
- prefix = "";
- add_period = FALSE;
-
- if (biop->genome == 8) {
- FFAddTextToString(unique, "", "extrachromosomal", NULL, FALSE, FALSE, TILDE_IGNORE);
- prefix = "\n";
- }
-
- for (j = 0, jdx = notetbl [j]; jdx != 0; j++, jdx = notetbl [j]) {
-
- lastomptype = 0;
- lastssptype = 0;
- switch (asn2gnbk_source_quals [jdx].qualclass) {
-
- case Qual_class_string :
- if (! StringHasNoText (qvp [jdx].str)) {
- FFAddString_NoRedund (unique, prefix, qvp [jdx].str, NULL);
- add_period = FALSE;
- prefix = "\n";
- }
- break;
-
- case Qual_class_orgmod :
- if ((! ajp->flags.srcQualsToNote) && jdx != SCQUAL_orgmod_note) break;
- omp = qvp [jdx].omp;
- if (lastomptype == 0 && omp != NULL) {
- lastomptype = omp->subtype;
- }
- while (omp != NULL && omp->subtype == lastomptype) {
- if (! StringHasNoText (omp->subname)) {
- if (jdx == SCQUAL_orgmod_note) {
- sprintf (buf, "%s", prefix);
- } else {
- sprintf (buf, "%s%s: ", prefix, asn2gnbk_source_quals [jdx].name);
- }
-
- str = StringSave (omp->subname);
- add_period = s_RemovePeriodFromEnd (str);
- if (jdx == SCQUAL_orgmod_note) {
- FFAddString_NoRedund (unique, buf, str, NULL);
- } else {
- FFAddTextToString(unique, buf, str, NULL, FALSE, FALSE, TILDE_IGNORE);
- }
- MemFree (str);
-
- if (jdx == SCQUAL_orgmod_note) {
- if (add_period) {
- prefix = ".\n";
- } else {
- prefix = "\n";
- }
- } else {
- prefix = "; ";
- }
- }
- omp = omp->next;
- }
- break;
-
- case Qual_class_subsource :
- if ((! ajp->flags.srcQualsToNote) && jdx != SCQUAL_subsource_note) break;
- ssp = qvp [jdx].ssp;
- if (lastssptype == 0 && ssp != NULL) {
- lastssptype = ssp->subtype;
- }
- while (ssp != NULL && ssp->subtype == lastssptype) {
- if (! StringHasNoText (ssp->name)) {
- if (jdx == SCQUAL_subsource_note) {
- sprintf (buf, "%s", prefix);
- } else {
- sprintf (buf, "%s%s: ", prefix, asn2gnbk_source_quals [jdx].name);
- }
-
- str = StringSave (ssp->name);
- add_period = s_RemovePeriodFromEnd (str);
- if (jdx == SCQUAL_subsource_note) {
- FFAddString_NoRedund (unique, buf, str, NULL);
- } else {
- FFAddTextToString(unique, buf, str, NULL, FALSE, FALSE, TILDE_IGNORE);
- }
- MemFree (str);
-
- if (jdx == SCQUAL_subsource_note) {
- if (add_period) {
- prefix = ".\n";
- } else {
- prefix = "\n";
- }
- } else {
- prefix = "; ";
- }
- }
- ssp = ssp->next;
- }
- break;
-
- case Qual_class_valnode :
- for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (! StringHasNoText (str)) {
- FFAddString_NoRedund (unique, prefix, str, NULL);
- add_period = FALSE;
- prefix = "; ";
- }
- }
- break;
-
- default :
- break;
- }
- }
- if ( !FFEmpty(unique) ) {
- notestr = FFToCharPtr(unique);
-
- if (add_period) {
- s_AddPeriodToEnd (notestr);
- }
-
-#ifdef ASN2GNBK_STRIP_NOTE_PERIODS
- if (! IsEllipsis (notestr))
- s_RemovePeriodFromEnd (notestr);
-#endif
-
- FFAddOneString (ffstring, "/note=\"", FALSE, FALSE, TILDE_IGNORE);
- if (is_desc) {
- /* AB055064.1 says TILDE_IGNORE on descriptors */
- FFAddOneString (ffstring, notestr, FALSE, TRUE, TILDE_IGNORE);
- } else {
- /* ASZ93724.1 says TILDE_EXPAND on features */
- FFAddOneString (ffstring, notestr, FALSE, TRUE, TILDE_EXPAND);
- }
- FFAddOneString (ffstring, "\"", FALSE, FALSE, TILDE_IGNORE);
-
- MemFree (notestr);
- }
- break;
- default :
- break;
- }
- }
-
- /* and then deal with the various note types separately (not in order table) */
-
- str = FFEndPrint(ajp, ffstring, afp->format, 21, 21, 5, 21, "FT");
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (gbseq != NULL) {
- if (gbfeat != NULL) {
- AddFeatureToGbseq (gbseq, gbfeat, str, NULL);
- }
- }
-
- FFRecycleString(ajp, unique);
- FFRecycleString(ajp, ffstring);
- return str;
-}
-
-
-typedef struct qualfeatur {
- CharPtr name;
- Uint1 featurclass;
-} QualFeatur, PNTR QualFeaturPtr;
-
-#define NUM_GB_QUALS 26
-
-static QualFeatur qualToFeature [NUM_GB_QUALS] = {
- { "allele", FTQUAL_allele },
- { "bound_moiety", FTQUAL_bound_moiety },
- { "clone", FTQUAL_clone },
- { "codon", FTQUAL_codon },
- { "cons_splice", FTQUAL_cons_splice },
- { "direction", FTQUAL_direction },
- { "EC_number", FTQUAL_EC_number },
- { "frequency", FTQUAL_frequency },
- { "function", FTQUAL_function },
- { "insertion_seq", FTQUAL_insertion_seq },
- { "label", FTQUAL_label },
- { "map", FTQUAL_map },
- { "mod_base", FTQUAL_mod_base },
- { "number", FTQUAL_number },
- { "operon", FTQUAL_operon },
- { "organism", FTQUAL_organism },
- { "PCR_conditions", FTQUAL_PCR_conditions },
- { "phenotype", FTQUAL_phenotype },
- { "product", FTQUAL_product_quals },
- { "replace", FTQUAL_replace },
- { "rpt_family", FTQUAL_rpt_family },
- { "rpt_type", FTQUAL_rpt_type },
- { "rpt_unit", FTQUAL_rpt_unit },
- { "standard_name", FTQUAL_standard_name },
- { "transposon", FTQUAL_transposon },
- { "usedin", FTQUAL_usedin }
-};
-
-static Int2 GbqualToFeaturIndex (
- CharPtr qualname
-)
-
-{
- Int2 L, R, mid;
-
- if (qualname == NULL || *qualname == '\0') return 0;
-
- L = 0;
- R = NUM_GB_QUALS - 1;
-
- while (L < R) {
- mid = (L + R) / 2;
- if (StringICmp (qualToFeature [mid].name, qualname) < 0) {
- L = mid + 1;
- } else {
- R = mid;
- }
- }
-
- if (StringICmp (qualToFeature [R].name, qualname) == 0) {
- return qualToFeature [R].featurclass;
- }
-
- return 0;
-}
-
-#define NUM_ILLEGAL_QUALS 14
-
-static FeaturQual illegalGbqualList [NUM_ILLEGAL_QUALS] = {
- { "anticodon", Qual_class_noquote },
- { "citation", Qual_class_noquote },
- { "codon_start", Qual_class_noquote },
- { "db_xref", Qual_class_quote },
- { "evidence", Qual_class_noquote },
- { "exception", Qual_class_quote },
- { "gene", Qual_class_quote },
- { "note", Qual_class_quote },
- { "protein_id", Qual_class_quote },
- { "pseudo", Qual_class_noquote },
- { "transcript_id", Qual_class_quote },
- { "transl_except", Qual_class_noquote },
- { "transl_table", Qual_class_noquote },
- { "translation", Qual_class_quote },
-};
-
-static Int2 IllegalGbqualToClass (
- CharPtr qualname
-)
-
-{
- Int2 L, R, mid;
-
- if (qualname == NULL || *qualname == '\0') return 0;
-
- L = 0;
- R = NUM_ILLEGAL_QUALS - 1;
-
- while (L < R) {
- mid = (L + R) / 2;
- if (StringICmp (illegalGbqualList [mid].name, qualname) < 0) {
- L = mid + 1;
- } else {
- R = mid;
- }
- }
-
- if (StringICmp (illegalGbqualList [R].name, qualname) == 0) {
- return illegalGbqualList [R].qualclass;
- }
-
- return 0;
-}
-
-static CharPtr trnaList [] = {
- "tRNA-Gap",
- "tRNA-Ala",
- "tRNA-Asx",
- "tRNA-Cys",
- "tRNA-Asp",
- "tRNA-Glu",
- "tRNA-Phe",
- "tRNA-Gly",
- "tRNA-His",
- "tRNA-Ile",
- "tRNA-Lys",
- "tRNA-Leu",
- "tRNA-Met",
- "tRNA-Asn",
- "tRNA-Pro",
- "tRNA-Gln",
- "tRNA-Arg",
- "tRNA-Ser",
- "tRNA-Thr",
- "tRNA-Sec",
- "tRNA-Val",
- "tRNA-Trp",
- "tRNA-OTHER",
- "tRNA-Tyr",
- "tRNA-Glx",
- "tRNA-TERM",
- NULL
-};
-
-static CharPtr evidenceText [] = {
- NULL, "experimental", "not_experimental"
-};
-
-static CharPtr secStrText [] = {
- NULL, "helix", "sheet", "turn"
-};
-
-static CharPtr oops = "?";
-
-static CharPtr SeqCodeNameGet (
- SeqCodeTablePtr table,
- Uint1 residue
-)
-
-{
- Uint1 index;
-
- if (table != NULL) {
- index = residue - table->start_at;
- if ( /*index >= 0 && */ index < table->num) {
- return (table->names) [index];
- }
- }
-
- return oops;
-}
-
-static CharPtr Get3LetterSymbol (
- IntAsn2gbJobPtr ajp,
- Uint1 seq_code,
- SeqCodeTablePtr table,
- Uint1 residue
-)
-
-{
- Uint1 code = Seq_code_ncbieaa;
- Int2 index;
- Uint1 new_residue;
- CharPtr ptr;
- CharPtr retval = NULL;
- SeqMapTablePtr smtp;
- SeqCodeTablePtr table_3aa;
-
- if (residue == 42) { /* stop codon in NCBIeaa */
- retval = "TERM";
- return retval;
- }
-
- if (ajp->flags.iupacaaOnly) {
- code = Seq_code_iupacaa;
- } else {
- code = Seq_code_ncbieaa;
- }
-
- if (seq_code != code) {
- /* if code and seq_code are identical, then smtp is NULL?? */
- smtp = SeqMapTableFind (code, seq_code);
- new_residue = SeqMapTableConvert (smtp, residue);
- } else {
- new_residue = residue;
- }
-
- /* The following looks for non-symbols (255) and "Undetermined" (88) */
- if ((int) new_residue == 255 || (int) new_residue == 88) {
- retval = "OTHER";
- return retval;
- } else {
- ptr = SeqCodeNameGet (table, residue);
- table_3aa=SeqCodeTableFind (Seq_code_iupacaa3);
- if (ptr != NULL && table_3aa != NULL) {
- for (index=0; index < (int) table_3aa->num; index++) {
- if (StringCmp(ptr, (table_3aa->names) [index]) == 0) {
- retval = (table_3aa->symbols) [index];
- return retval;
- }
- }
- }
- }
-
- retval = "OTHER";
- return retval;
-}
-
-static Boolean MatchCit (
- ValNodePtr ppr,
- RefBlockPtr rbp
-)
-
-{
- Char buf [121];
- size_t len;
- Int4 uid;
- ValNodePtr vnp;
-
- if (ppr == NULL || rbp == NULL) return FALSE;
- switch (ppr->choice) {
- case PUB_Muid :
- uid = ppr->data.intvalue;
- if (rbp->muid == uid) return TRUE;
- break;
- case PUB_PMid :
- uid = ppr->data.intvalue;
- if (rbp->pmid == uid) return TRUE;
- break;
- case PUB_Equiv :
- for (vnp = (ValNodePtr) ppr->data.ptrvalue; vnp != NULL; vnp = vnp->next) {
- if (MatchCit (vnp, rbp)) return TRUE;
- }
- break;
- default :
- PubLabelUnique (ppr, buf, sizeof (buf) - 1, OM_LABEL_CONTENT, TRUE);
- len = StringLen (buf);
- if (len > 0 && buf [len - 1] == '>') {
- buf [len - 1] = '\0';
- len--;
- }
- len = MIN (len, StringLen (rbp->uniquestr));
- if (StringNICmp (rbp->uniquestr, buf, len) == 0) return TRUE;
- break;
- }
- return FALSE;
-}
-
-static Int2 MatchRef (
- ValNodePtr ppr,
- RefBlockPtr PNTR rbpp,
- Int2 numReferences
-)
-
-{
- Int2 j;
- RefBlockPtr rbp;
-
- if (ppr == NULL || rbpp == NULL) return 0;
-
- for (j = 0; j < numReferences; j++) {
- rbp = rbpp [j];
- if (rbp == NULL) continue;
- if (MatchCit (ppr, rbp)) return j + 1;
- }
- return 0;
-}
-
-/* taken from asn2ff4.c */
-
-static Boolean LookForFuzz (SeqLocPtr head)
-{
- Boolean retval=FALSE;
- IntFuzzPtr ifp;
- PackSeqPntPtr pspp;
- SeqIntPtr sip;
- SeqLocPtr slp;
- SeqPntPtr spp;
-
- if (head == NULL)
- return retval;
-
- slp=NULL;
- while ((slp = SeqLocFindNext(head, slp)) != NULL)
- {
- switch (slp->choice)
- {
- case SEQLOC_INT:
- sip = (SeqIntPtr)(slp->data.ptrvalue);
- ifp = sip->if_from;
- if (ifp != NULL)
- {
- if (ifp->choice == 4)
- {
- if (ifp->a != 0)
- retval=TRUE;
- }
- else
- retval = TRUE;
- }
- ifp = sip->if_to;
- if (ifp != NULL)
- {
- if (ifp->choice == 4)
- {
- if (ifp->a != 0)
- retval=TRUE;
- }
- else
- retval = TRUE;
- }
- break;
- case SEQLOC_PNT:
- spp = (SeqPntPtr)(slp->data.ptrvalue);
- ifp = spp->fuzz;
- if (ifp != NULL)
- {
- if (ifp->choice == 4)
- {
- if (ifp->a != 0)
- retval=TRUE;
- }
- else
- retval = TRUE;
- }
- break;
- case SEQLOC_PACKED_PNT:
- pspp = (PackSeqPntPtr)(slp->data.ptrvalue);
- ifp = pspp->fuzz;
- if (ifp != NULL)
- {
- if (ifp->choice == 4)
- {
- if (ifp->a != 0)
- retval=TRUE;
- }
- else
- retval = TRUE;
- }
- break;
- default:
- break;
- }
- if (retval == TRUE)
- break;
- }
- return retval;
-}
-
-static CharPtr bondList [] = {
- NULL,
- "disulfide",
- "thiolester",
- "xlink",
- "thioether",
- "unclassified"
-};
-
-static CharPtr siteList [] = {
- NULL,
- "active",
- "binding",
- "cleavage",
- "inhibit",
- "modified",
- "glycosylation",
- "myristoylation",
- "mutagenized",
- "metal-binding",
- "phosphorylation",
- "acetylation",
- "amidation",
- "methylation",
- "hydroxylation",
- "sulfatation",
- "oxidative-deamination",
- "pyrrolidone-carboxylic-acid",
- "gamma-carboxyglutamic-acid",
- "blocked",
- "lipid-binding",
- "np-binding",
- "DNA binding",
- "signal-peptide",
- "transit-peptide",
- "transmembrane-region",
- "unclassified"
-};
-
-static CharPtr conflict_msg =
-"Protein sequence is in conflict with the conceptual translation";
-
-static CharPtr no_protein_msg =
-"Coding region translates with internal stops";
-
-/**/
-/* s_DisplayQVP () -- Displays the strings in a QVP structure. */
-/* This is a debugging function only. */
-/**/
-
-static void s_DisplayQVP(QualValPtr qvp, Uint1Ptr notetbl)
-{
- Int2 j;
- Int2 jdx;
-
- fprintf(stderr,"\n");
- for (j = 0, jdx = notetbl [j]; jdx != 0; j++, jdx = notetbl [j])
- {
- if (((int) qvp[jdx].str != 0x1000000) &&
- ((int) qvp[jdx].str != 0x1) &&
- ((int) qvp[jdx].str != 0xb) &&
- (qvp[jdx].str != NULL))
- fprintf(stderr, "%d\t%-25s %s\n", j, asn2gnbk_featur_quals[jdx].name,
- qvp[jdx].str);
- else
- fprintf(stderr, "%d\t%-25s %s\n", j, asn2gnbk_featur_quals[jdx].name,
- "NULL");
- }
-}
-
-static Boolean NotInGeneSyn (
- CharPtr str,
- ValNodePtr gene_syn)
-
-{
- CharPtr syn;
- ValNodePtr vnp;
-
- for (vnp = gene_syn; vnp != NULL; vnp = vnp->next) {
- syn = (CharPtr) vnp->data.ptrvalue;
- if (! StringHasNoText (syn)) {
- if (StringICmp (str, syn) == 0) return FALSE;
- }
- }
- return TRUE;
-}
-
-typedef struct valqualstruc {
- Uint2 featdef;
- FtQualType ftqual;
-} ValQual, PNTR ValQualPtr;
-
-/*
- WARNING - This list MUST be kept sorted in FEATDEF order as the primary
- key, and within a FEATDEF group sorted by FTQUAL as the secondary key
-*/
-
-static ValQual legalGbqualList [] = {
-
- { FEATDEF_GENE , FTQUAL_allele },
- { FEATDEF_GENE , FTQUAL_function },
- { FEATDEF_GENE , FTQUAL_label },
- { FEATDEF_GENE , FTQUAL_map },
- { FEATDEF_GENE , FTQUAL_operon },
- { FEATDEF_GENE , FTQUAL_phenotype },
- { FEATDEF_GENE , FTQUAL_product },
- { FEATDEF_GENE , FTQUAL_standard_name },
- { FEATDEF_GENE , FTQUAL_usedin },
-
- { FEATDEF_CDS , FTQUAL_allele },
- { FEATDEF_CDS , FTQUAL_codon },
- { FEATDEF_CDS , FTQUAL_label },
- { FEATDEF_CDS , FTQUAL_map },
- { FEATDEF_CDS , FTQUAL_number },
- { FEATDEF_CDS , FTQUAL_operon },
- { FEATDEF_CDS , FTQUAL_standard_name },
- { FEATDEF_CDS , FTQUAL_usedin },
-
- { FEATDEF_PROT , FTQUAL_product },
-
- { FEATDEF_preRNA , FTQUAL_allele },
- { FEATDEF_preRNA , FTQUAL_function },
- { FEATDEF_preRNA , FTQUAL_label },
- { FEATDEF_preRNA , FTQUAL_map },
- { FEATDEF_preRNA , FTQUAL_operon },
- { FEATDEF_preRNA , FTQUAL_product },
- { FEATDEF_preRNA , FTQUAL_standard_name },
- { FEATDEF_preRNA , FTQUAL_usedin },
-
- { FEATDEF_mRNA , FTQUAL_allele },
- { FEATDEF_mRNA , FTQUAL_function },
- { FEATDEF_mRNA , FTQUAL_label },
- { FEATDEF_mRNA , FTQUAL_map },
- { FEATDEF_mRNA , FTQUAL_operon },
- { FEATDEF_mRNA , FTQUAL_product },
- { FEATDEF_mRNA , FTQUAL_standard_name },
- { FEATDEF_mRNA , FTQUAL_usedin },
-
- { FEATDEF_tRNA , FTQUAL_allele },
- { FEATDEF_tRNA , FTQUAL_function },
- { FEATDEF_tRNA , FTQUAL_label },
- { FEATDEF_tRNA , FTQUAL_map },
- { FEATDEF_tRNA , FTQUAL_product },
- { FEATDEF_tRNA , FTQUAL_standard_name },
- { FEATDEF_tRNA , FTQUAL_usedin },
-
- { FEATDEF_rRNA , FTQUAL_allele },
- { FEATDEF_rRNA , FTQUAL_function },
- { FEATDEF_rRNA , FTQUAL_label },
- { FEATDEF_rRNA , FTQUAL_map },
- { FEATDEF_rRNA , FTQUAL_product },
- { FEATDEF_rRNA , FTQUAL_standard_name },
- { FEATDEF_rRNA , FTQUAL_usedin },
-
- { FEATDEF_snRNA , FTQUAL_allele },
- { FEATDEF_snRNA , FTQUAL_function },
- { FEATDEF_snRNA , FTQUAL_label },
- { FEATDEF_snRNA , FTQUAL_map },
- { FEATDEF_snRNA , FTQUAL_product },
- { FEATDEF_snRNA , FTQUAL_standard_name },
- { FEATDEF_snRNA , FTQUAL_usedin },
-
- { FEATDEF_scRNA , FTQUAL_allele },
- { FEATDEF_scRNA , FTQUAL_function },
- { FEATDEF_scRNA , FTQUAL_label },
- { FEATDEF_scRNA , FTQUAL_map },
- { FEATDEF_scRNA , FTQUAL_product },
- { FEATDEF_scRNA , FTQUAL_standard_name },
- { FEATDEF_scRNA , FTQUAL_usedin },
-
- { FEATDEF_otherRNA , FTQUAL_allele },
- { FEATDEF_otherRNA , FTQUAL_function },
- { FEATDEF_otherRNA , FTQUAL_label },
- { FEATDEF_otherRNA , FTQUAL_map },
- { FEATDEF_otherRNA , FTQUAL_operon },
- { FEATDEF_otherRNA , FTQUAL_product },
- { FEATDEF_otherRNA , FTQUAL_standard_name },
- { FEATDEF_otherRNA , FTQUAL_usedin },
-
- { FEATDEF_attenuator , FTQUAL_allele },
- { FEATDEF_attenuator , FTQUAL_label },
- { FEATDEF_attenuator , FTQUAL_map },
- { FEATDEF_attenuator , FTQUAL_operon },
- { FEATDEF_attenuator , FTQUAL_phenotype },
- { FEATDEF_attenuator , FTQUAL_usedin },
-
- { FEATDEF_C_region , FTQUAL_allele },
- { FEATDEF_C_region , FTQUAL_label },
- { FEATDEF_C_region , FTQUAL_map },
- { FEATDEF_C_region , FTQUAL_product },
- { FEATDEF_C_region , FTQUAL_standard_name },
- { FEATDEF_C_region , FTQUAL_usedin },
-
- { FEATDEF_CAAT_signal , FTQUAL_allele },
- { FEATDEF_CAAT_signal , FTQUAL_label },
- { FEATDEF_CAAT_signal , FTQUAL_map },
- { FEATDEF_CAAT_signal , FTQUAL_usedin },
-
- { FEATDEF_Imp_CDS , FTQUAL_codon },
- { FEATDEF_Imp_CDS , FTQUAL_EC_number },
- { FEATDEF_Imp_CDS , FTQUAL_function },
- { FEATDEF_Imp_CDS , FTQUAL_label },
- { FEATDEF_Imp_CDS , FTQUAL_map },
- { FEATDEF_Imp_CDS , FTQUAL_number },
- { FEATDEF_Imp_CDS , FTQUAL_operon },
- { FEATDEF_Imp_CDS , FTQUAL_product },
- { FEATDEF_Imp_CDS , FTQUAL_standard_name },
- { FEATDEF_Imp_CDS , FTQUAL_usedin },
-
- { FEATDEF_conflict , FTQUAL_allele },
- { FEATDEF_conflict , FTQUAL_label },
- { FEATDEF_conflict , FTQUAL_map },
- { FEATDEF_conflict , FTQUAL_replace },
- { FEATDEF_conflict , FTQUAL_usedin },
-
- { FEATDEF_D_loop , FTQUAL_allele },
- { FEATDEF_D_loop , FTQUAL_label },
- { FEATDEF_D_loop , FTQUAL_map },
- { FEATDEF_D_loop , FTQUAL_usedin },
-
- { FEATDEF_D_segment , FTQUAL_allele },
- { FEATDEF_D_segment , FTQUAL_label },
- { FEATDEF_D_segment , FTQUAL_map },
- { FEATDEF_D_segment , FTQUAL_product },
- { FEATDEF_D_segment , FTQUAL_standard_name },
- { FEATDEF_D_segment , FTQUAL_usedin },
-
- { FEATDEF_enhancer , FTQUAL_allele },
- { FEATDEF_enhancer , FTQUAL_label },
- { FEATDEF_enhancer , FTQUAL_map },
- { FEATDEF_enhancer , FTQUAL_standard_name },
- { FEATDEF_enhancer , FTQUAL_usedin },
-
- { FEATDEF_exon , FTQUAL_allele },
- { FEATDEF_exon , FTQUAL_EC_number },
- { FEATDEF_exon , FTQUAL_function },
- { FEATDEF_exon , FTQUAL_label },
- { FEATDEF_exon , FTQUAL_map },
- { FEATDEF_exon , FTQUAL_number },
- { FEATDEF_exon , FTQUAL_product },
- { FEATDEF_exon , FTQUAL_standard_name },
- { FEATDEF_exon , FTQUAL_usedin },
-
- { FEATDEF_GC_signal , FTQUAL_allele },
- { FEATDEF_GC_signal , FTQUAL_label },
- { FEATDEF_GC_signal , FTQUAL_map },
- { FEATDEF_GC_signal , FTQUAL_usedin },
-
- { FEATDEF_iDNA , FTQUAL_allele },
- { FEATDEF_iDNA , FTQUAL_function },
- { FEATDEF_iDNA , FTQUAL_label },
- { FEATDEF_iDNA , FTQUAL_map },
- { FEATDEF_iDNA , FTQUAL_number },
- { FEATDEF_iDNA , FTQUAL_standard_name },
- { FEATDEF_iDNA , FTQUAL_usedin },
-
- { FEATDEF_intron , FTQUAL_allele },
- { FEATDEF_intron , FTQUAL_cons_splice },
- { FEATDEF_intron , FTQUAL_function },
- { FEATDEF_intron , FTQUAL_label },
- { FEATDEF_intron , FTQUAL_map },
- { FEATDEF_intron , FTQUAL_number },
- { FEATDEF_intron , FTQUAL_standard_name },
- { FEATDEF_intron , FTQUAL_usedin },
-
- { FEATDEF_J_segment , FTQUAL_allele },
- { FEATDEF_J_segment , FTQUAL_label },
- { FEATDEF_J_segment , FTQUAL_map },
- { FEATDEF_J_segment , FTQUAL_product },
- { FEATDEF_J_segment , FTQUAL_standard_name },
- { FEATDEF_J_segment , FTQUAL_usedin },
-
- { FEATDEF_LTR , FTQUAL_allele },
- { FEATDEF_LTR , FTQUAL_function },
- { FEATDEF_LTR , FTQUAL_label },
- { FEATDEF_LTR , FTQUAL_map },
- { FEATDEF_LTR , FTQUAL_standard_name },
- { FEATDEF_LTR , FTQUAL_usedin },
-
- { FEATDEF_mat_peptide , FTQUAL_allele },
- { FEATDEF_mat_peptide , FTQUAL_EC_number },
- { FEATDEF_mat_peptide , FTQUAL_function },
- { FEATDEF_mat_peptide , FTQUAL_label },
- { FEATDEF_mat_peptide , FTQUAL_map },
- { FEATDEF_mat_peptide , FTQUAL_product },
- { FEATDEF_mat_peptide , FTQUAL_standard_name },
- { FEATDEF_mat_peptide , FTQUAL_usedin },
-
- { FEATDEF_misc_binding , FTQUAL_allele },
- { FEATDEF_misc_binding , FTQUAL_bound_moiety },
- { FEATDEF_misc_binding , FTQUAL_function },
- { FEATDEF_misc_binding , FTQUAL_label },
- { FEATDEF_misc_binding , FTQUAL_map },
- { FEATDEF_misc_binding , FTQUAL_usedin },
-
- { FEATDEF_misc_difference , FTQUAL_allele },
- { FEATDEF_misc_difference , FTQUAL_clone },
- { FEATDEF_misc_difference , FTQUAL_label },
- { FEATDEF_misc_difference , FTQUAL_map },
- { FEATDEF_misc_difference , FTQUAL_phenotype },
- { FEATDEF_misc_difference , FTQUAL_replace },
- { FEATDEF_misc_difference , FTQUAL_standard_name },
- { FEATDEF_misc_difference , FTQUAL_usedin },
-
- { FEATDEF_misc_feature , FTQUAL_allele },
- { FEATDEF_misc_feature , FTQUAL_function },
- { FEATDEF_misc_feature , FTQUAL_label },
- { FEATDEF_misc_feature , FTQUAL_map },
- { FEATDEF_misc_feature , FTQUAL_number },
- { FEATDEF_misc_feature , FTQUAL_phenotype },
- { FEATDEF_misc_feature , FTQUAL_product },
- { FEATDEF_misc_feature , FTQUAL_standard_name },
- { FEATDEF_misc_feature , FTQUAL_usedin },
-
- { FEATDEF_misc_recomb , FTQUAL_allele },
- { FEATDEF_misc_recomb , FTQUAL_label },
- { FEATDEF_misc_recomb , FTQUAL_map },
- { FEATDEF_misc_recomb , FTQUAL_organism },
- { FEATDEF_misc_recomb , FTQUAL_standard_name },
- { FEATDEF_misc_recomb , FTQUAL_usedin },
-
- { FEATDEF_misc_signal , FTQUAL_allele },
- { FEATDEF_misc_signal , FTQUAL_function },
- { FEATDEF_misc_signal , FTQUAL_label },
- { FEATDEF_misc_signal , FTQUAL_map },
- { FEATDEF_misc_signal , FTQUAL_operon },
- { FEATDEF_misc_signal , FTQUAL_phenotype },
- { FEATDEF_misc_signal , FTQUAL_standard_name },
- { FEATDEF_misc_signal , FTQUAL_usedin },
-
- { FEATDEF_misc_structure , FTQUAL_allele },
- { FEATDEF_misc_structure , FTQUAL_function },
- { FEATDEF_misc_structure , FTQUAL_label },
- { FEATDEF_misc_structure , FTQUAL_map },
- { FEATDEF_misc_structure , FTQUAL_standard_name },
- { FEATDEF_misc_structure , FTQUAL_usedin },
-
- { FEATDEF_modified_base , FTQUAL_allele },
- { FEATDEF_modified_base , FTQUAL_frequency },
- { FEATDEF_modified_base , FTQUAL_label },
- { FEATDEF_modified_base , FTQUAL_map },
- { FEATDEF_modified_base , FTQUAL_mod_base },
- { FEATDEF_modified_base , FTQUAL_usedin },
-
- { FEATDEF_N_region , FTQUAL_allele },
- { FEATDEF_N_region , FTQUAL_label },
- { FEATDEF_N_region , FTQUAL_map },
- { FEATDEF_N_region , FTQUAL_product },
- { FEATDEF_N_region , FTQUAL_standard_name },
- { FEATDEF_N_region , FTQUAL_usedin },
-
- { FEATDEF_old_sequence , FTQUAL_allele },
- { FEATDEF_old_sequence , FTQUAL_label },
- { FEATDEF_old_sequence , FTQUAL_map },
- { FEATDEF_old_sequence , FTQUAL_replace },
- { FEATDEF_old_sequence , FTQUAL_usedin },
-
- { FEATDEF_polyA_signal , FTQUAL_allele },
- { FEATDEF_polyA_signal , FTQUAL_label },
- { FEATDEF_polyA_signal , FTQUAL_map },
- { FEATDEF_polyA_signal , FTQUAL_usedin },
-
- { FEATDEF_polyA_site , FTQUAL_allele },
- { FEATDEF_polyA_site , FTQUAL_label },
- { FEATDEF_polyA_site , FTQUAL_map },
- { FEATDEF_polyA_site , FTQUAL_usedin },
-
- { FEATDEF_prim_transcript , FTQUAL_allele },
- { FEATDEF_prim_transcript , FTQUAL_function },
- { FEATDEF_prim_transcript , FTQUAL_label },
- { FEATDEF_prim_transcript , FTQUAL_map },
- { FEATDEF_prim_transcript , FTQUAL_operon },
- { FEATDEF_prim_transcript , FTQUAL_standard_name },
- { FEATDEF_prim_transcript , FTQUAL_usedin },
-
- { FEATDEF_primer_bind , FTQUAL_allele },
- { FEATDEF_primer_bind , FTQUAL_label },
- { FEATDEF_primer_bind , FTQUAL_map },
- { FEATDEF_primer_bind , FTQUAL_PCR_conditions },
- { FEATDEF_primer_bind , FTQUAL_standard_name },
- { FEATDEF_primer_bind , FTQUAL_usedin },
-
- { FEATDEF_promoter , FTQUAL_allele },
- { FEATDEF_promoter , FTQUAL_function },
- { FEATDEF_promoter , FTQUAL_label },
- { FEATDEF_promoter , FTQUAL_map },
- { FEATDEF_promoter , FTQUAL_operon },
- { FEATDEF_promoter , FTQUAL_phenotype },
- { FEATDEF_promoter , FTQUAL_standard_name },
- { FEATDEF_promoter , FTQUAL_usedin },
-
- { FEATDEF_protein_bind , FTQUAL_allele },
- { FEATDEF_protein_bind , FTQUAL_bound_moiety },
- { FEATDEF_protein_bind , FTQUAL_function },
- { FEATDEF_protein_bind , FTQUAL_label },
- { FEATDEF_protein_bind , FTQUAL_map },
- { FEATDEF_protein_bind , FTQUAL_standard_name },
- { FEATDEF_protein_bind , FTQUAL_usedin },
-
- { FEATDEF_RBS , FTQUAL_allele },
- { FEATDEF_RBS , FTQUAL_label },
- { FEATDEF_RBS , FTQUAL_map },
- { FEATDEF_RBS , FTQUAL_standard_name },
- { FEATDEF_RBS , FTQUAL_usedin },
-
- { FEATDEF_repeat_region , FTQUAL_allele },
- { FEATDEF_repeat_region , FTQUAL_function },
- { FEATDEF_repeat_region , FTQUAL_insertion_seq },
- { FEATDEF_repeat_region , FTQUAL_label },
- { FEATDEF_repeat_region , FTQUAL_map },
- { FEATDEF_repeat_region , FTQUAL_rpt_family },
- { FEATDEF_repeat_region , FTQUAL_rpt_type },
- { FEATDEF_repeat_region , FTQUAL_rpt_unit },
- { FEATDEF_repeat_region , FTQUAL_standard_name },
- { FEATDEF_repeat_region , FTQUAL_transposon },
- { FEATDEF_repeat_region , FTQUAL_usedin },
-
- { FEATDEF_repeat_unit , FTQUAL_allele },
- { FEATDEF_repeat_unit , FTQUAL_function },
- { FEATDEF_repeat_unit , FTQUAL_label },
- { FEATDEF_repeat_unit , FTQUAL_map },
- { FEATDEF_repeat_unit , FTQUAL_rpt_family },
- { FEATDEF_repeat_unit , FTQUAL_rpt_type },
- { FEATDEF_repeat_unit , FTQUAL_usedin },
-
- { FEATDEF_rep_origin , FTQUAL_allele },
- { FEATDEF_rep_origin , FTQUAL_direction },
- { FEATDEF_rep_origin , FTQUAL_label },
- { FEATDEF_rep_origin , FTQUAL_map },
- { FEATDEF_rep_origin , FTQUAL_standard_name },
- { FEATDEF_rep_origin , FTQUAL_usedin },
-
- { FEATDEF_S_region , FTQUAL_allele },
- { FEATDEF_S_region , FTQUAL_label },
- { FEATDEF_S_region , FTQUAL_map },
- { FEATDEF_S_region , FTQUAL_product },
- { FEATDEF_S_region , FTQUAL_standard_name },
- { FEATDEF_S_region , FTQUAL_usedin },
-
- { FEATDEF_satellite , FTQUAL_allele },
- { FEATDEF_satellite , FTQUAL_label },
- { FEATDEF_satellite , FTQUAL_map },
- { FEATDEF_satellite , FTQUAL_rpt_family },
- { FEATDEF_satellite , FTQUAL_rpt_type },
- { FEATDEF_satellite , FTQUAL_rpt_unit },
- { FEATDEF_satellite , FTQUAL_standard_name },
- { FEATDEF_satellite , FTQUAL_usedin },
-
- { FEATDEF_sig_peptide , FTQUAL_allele },
- { FEATDEF_sig_peptide , FTQUAL_function },
- { FEATDEF_sig_peptide , FTQUAL_label },
- { FEATDEF_sig_peptide , FTQUAL_map },
- { FEATDEF_sig_peptide , FTQUAL_product },
- { FEATDEF_sig_peptide , FTQUAL_standard_name },
- { FEATDEF_sig_peptide , FTQUAL_usedin },
-
- { FEATDEF_stem_loop , FTQUAL_allele },
- { FEATDEF_stem_loop , FTQUAL_function },
- { FEATDEF_stem_loop , FTQUAL_label },
- { FEATDEF_stem_loop , FTQUAL_map },
- { FEATDEF_stem_loop , FTQUAL_operon },
- { FEATDEF_stem_loop , FTQUAL_standard_name },
- { FEATDEF_stem_loop , FTQUAL_usedin },
-
- { FEATDEF_STS , FTQUAL_allele },
- { FEATDEF_STS , FTQUAL_label },
- { FEATDEF_STS , FTQUAL_map },
- { FEATDEF_STS , FTQUAL_standard_name },
- { FEATDEF_STS , FTQUAL_usedin },
-
- { FEATDEF_TATA_signal , FTQUAL_allele },
- { FEATDEF_TATA_signal , FTQUAL_label },
- { FEATDEF_TATA_signal , FTQUAL_map },
- { FEATDEF_TATA_signal , FTQUAL_usedin },
-
- { FEATDEF_terminator , FTQUAL_allele },
- { FEATDEF_terminator , FTQUAL_label },
- { FEATDEF_terminator , FTQUAL_map },
- { FEATDEF_terminator , FTQUAL_operon },
- { FEATDEF_terminator , FTQUAL_standard_name },
- { FEATDEF_terminator , FTQUAL_usedin },
-
- { FEATDEF_transit_peptide , FTQUAL_allele },
- { FEATDEF_transit_peptide , FTQUAL_function },
- { FEATDEF_transit_peptide , FTQUAL_label },
- { FEATDEF_transit_peptide , FTQUAL_map },
- { FEATDEF_transit_peptide , FTQUAL_product },
- { FEATDEF_transit_peptide , FTQUAL_standard_name },
- { FEATDEF_transit_peptide , FTQUAL_usedin },
-
- { FEATDEF_unsure , FTQUAL_allele },
- { FEATDEF_unsure , FTQUAL_label },
- { FEATDEF_unsure , FTQUAL_map },
- { FEATDEF_unsure , FTQUAL_replace },
- { FEATDEF_unsure , FTQUAL_usedin },
-
- { FEATDEF_V_region , FTQUAL_allele },
- { FEATDEF_V_region , FTQUAL_label },
- { FEATDEF_V_region , FTQUAL_map },
- { FEATDEF_V_region , FTQUAL_product },
- { FEATDEF_V_region , FTQUAL_standard_name },
- { FEATDEF_V_region , FTQUAL_usedin },
-
- { FEATDEF_V_segment , FTQUAL_allele },
- { FEATDEF_V_segment , FTQUAL_label },
- { FEATDEF_V_segment , FTQUAL_map },
- { FEATDEF_V_segment , FTQUAL_product },
- { FEATDEF_V_segment , FTQUAL_standard_name },
- { FEATDEF_V_segment , FTQUAL_usedin },
-
- { FEATDEF_variation , FTQUAL_allele },
- { FEATDEF_variation , FTQUAL_frequency },
- { FEATDEF_variation , FTQUAL_label },
- { FEATDEF_variation , FTQUAL_map },
- { FEATDEF_variation , FTQUAL_phenotype },
- { FEATDEF_variation , FTQUAL_product },
- { FEATDEF_variation , FTQUAL_replace },
- { FEATDEF_variation , FTQUAL_standard_name },
- { FEATDEF_variation , FTQUAL_usedin },
-
- { FEATDEF_3clip , FTQUAL_allele },
- { FEATDEF_3clip , FTQUAL_function },
- { FEATDEF_3clip , FTQUAL_label },
- { FEATDEF_3clip , FTQUAL_map },
- { FEATDEF_3clip , FTQUAL_standard_name },
- { FEATDEF_3clip , FTQUAL_usedin },
-
- { FEATDEF_3UTR , FTQUAL_allele },
- { FEATDEF_3UTR , FTQUAL_function },
- { FEATDEF_3UTR , FTQUAL_label },
- { FEATDEF_3UTR , FTQUAL_map },
- { FEATDEF_3UTR , FTQUAL_standard_name },
- { FEATDEF_3UTR , FTQUAL_usedin },
-
- { FEATDEF_5clip , FTQUAL_allele },
- { FEATDEF_5clip , FTQUAL_function },
- { FEATDEF_5clip , FTQUAL_label },
- { FEATDEF_5clip , FTQUAL_map },
- { FEATDEF_5clip , FTQUAL_standard_name },
- { FEATDEF_5clip , FTQUAL_usedin },
-
- { FEATDEF_5UTR , FTQUAL_allele },
- { FEATDEF_5UTR , FTQUAL_function },
- { FEATDEF_5UTR , FTQUAL_label },
- { FEATDEF_5UTR , FTQUAL_map },
- { FEATDEF_5UTR , FTQUAL_standard_name },
- { FEATDEF_5UTR , FTQUAL_usedin },
-
- { FEATDEF_10_signal , FTQUAL_allele },
- { FEATDEF_10_signal , FTQUAL_label },
- { FEATDEF_10_signal , FTQUAL_map },
- { FEATDEF_10_signal , FTQUAL_operon },
- { FEATDEF_10_signal , FTQUAL_standard_name },
- { FEATDEF_10_signal , FTQUAL_usedin },
-
- { FEATDEF_35_signal , FTQUAL_allele },
- { FEATDEF_35_signal , FTQUAL_label },
- { FEATDEF_35_signal , FTQUAL_map },
- { FEATDEF_35_signal , FTQUAL_operon },
- { FEATDEF_35_signal , FTQUAL_standard_name },
- { FEATDEF_35_signal , FTQUAL_usedin },
-
- { FEATDEF_REGION , FTQUAL_function },
- { FEATDEF_REGION , FTQUAL_label },
- { FEATDEF_REGION , FTQUAL_map },
- { FEATDEF_REGION , FTQUAL_number },
- { FEATDEF_REGION , FTQUAL_phenotype },
- { FEATDEF_REGION , FTQUAL_product },
- { FEATDEF_REGION , FTQUAL_standard_name },
- { FEATDEF_REGION , FTQUAL_usedin },
-
- { FEATDEF_mat_peptide_aa , FTQUAL_allele },
- { FEATDEF_mat_peptide_aa , FTQUAL_label },
- { FEATDEF_mat_peptide_aa , FTQUAL_map },
- { FEATDEF_mat_peptide_aa , FTQUAL_product },
- { FEATDEF_mat_peptide_aa , FTQUAL_standard_name },
- { FEATDEF_mat_peptide_aa , FTQUAL_usedin },
-
- { FEATDEF_sig_peptide_aa , FTQUAL_allele },
- { FEATDEF_sig_peptide_aa , FTQUAL_label },
- { FEATDEF_sig_peptide_aa , FTQUAL_map },
- { FEATDEF_sig_peptide_aa , FTQUAL_product },
- { FEATDEF_sig_peptide_aa , FTQUAL_standard_name },
- { FEATDEF_sig_peptide_aa , FTQUAL_usedin },
-
- { FEATDEF_transit_peptide_aa , FTQUAL_allele },
- { FEATDEF_transit_peptide_aa , FTQUAL_label },
- { FEATDEF_transit_peptide_aa , FTQUAL_map },
- { FEATDEF_transit_peptide_aa , FTQUAL_product },
- { FEATDEF_transit_peptide_aa , FTQUAL_standard_name },
- { FEATDEF_transit_peptide_aa , FTQUAL_usedin },
-
- { FEATDEF_snoRNA , FTQUAL_allele },
- { FEATDEF_snoRNA , FTQUAL_function },
- { FEATDEF_snoRNA , FTQUAL_label },
- { FEATDEF_snoRNA , FTQUAL_map },
- { FEATDEF_snoRNA , FTQUAL_product },
- { FEATDEF_snoRNA , FTQUAL_standard_name },
- { FEATDEF_snoRNA , FTQUAL_usedin },
-
- { FEATDEF_operon , FTQUAL_allele },
- { FEATDEF_operon , FTQUAL_function },
- { FEATDEF_operon , FTQUAL_label },
- { FEATDEF_operon , FTQUAL_map },
- { FEATDEF_operon , FTQUAL_operon },
- { FEATDEF_operon , FTQUAL_phenotype },
- { FEATDEF_operon , FTQUAL_standard_name },
- { FEATDEF_operon , FTQUAL_usedin },
-
- { FEATDEF_oriT , FTQUAL_allele },
- { FEATDEF_oriT , FTQUAL_direction },
- { FEATDEF_oriT , FTQUAL_label },
- { FEATDEF_oriT , FTQUAL_map },
- { FEATDEF_oriT , FTQUAL_rpt_type },
- { FEATDEF_oriT , FTQUAL_rpt_type },
- { FEATDEF_oriT , FTQUAL_rpt_unit },
- { FEATDEF_oriT , FTQUAL_standard_name },
- { FEATDEF_oriT , FTQUAL_usedin }
-};
-
-/* comparison of ValQual's -- first compare featdef then ftqual */
-
-/* macro did not work properly on linux machine, so using function instead */
-/* #define COMPARE_VALQUAL(av,aq,bv,bq) ( ((av)-(bv)) ? ((av)-(bv)) : ((aq)-(bq)) ) */
-
-static Int2 CompareValQual (Uint2 av, FtQualType aq, Uint2 bv, FtQualType bq)
-
-{
- if (av == bv) return (aq - bq);
- return (av - bv);
-}
-
-/* Returns TRUE if {featureKey, qualKey} exists in legalGbqualList */
-
-static Boolean AllowedValQual (Uint2 featureKey, FtQualType qualKey)
-
-{
- Int2 L, R, mid;
-
- L = 0;
- R = sizeof (legalGbqualList) / sizeof (ValQual) - 1;
- while (L < R) {
- mid = (L + R) / 2;
- if (CompareValQual (legalGbqualList [mid].featdef,
- legalGbqualList [mid].ftqual,
- featureKey, qualKey) < 0)
- L = mid + 1;
- else
- R = mid;
- }
- if (CompareValQual (legalGbqualList [R].featdef,
- legalGbqualList [R].ftqual,
- featureKey, qualKey)) {
- return 0;
- }
- return 1;
-}
-
-
-static CharPtr validRptString [] = {
- "tandem", "inverted", "flanking", "terminal", "direct", "dispersed", "other", NULL
-};
-
-static CharPtr validLRBString [] = {
- "LEFT", "RIGHT", "BOTH", NULL
-};
-
-static CharPtr validConsSpliceString [] = {
- "(5'site:YES, 3'site:YES)",
- "(5'site:YES, 3'site:NO)",
- "(5'site:YES, 3'site:ABSENT)",
- "(5'site:NO, 3'site:YES)",
- "(5'site:NO, 3'site:NO)",
- "(5'site:NO, 3'site:ABSENT)",
- "(5'site:ABSENT, 3'site:YES)",
- "(5'site:ABSENT, 3'site:NO)",
- "(5'site:ABSENT, 3'site:ABSENT)",
- NULL
-};
-
-static CharPtr validExceptionString [] = {
- "RNA editing",
- "reasons given in citation",
- NULL
-};
-
-static CharPtr validRefSeqExceptionString [] = {
- "RNA editing",
- "reasons given in citation",
- "ribosomal slippage",
- "ribosome slippage",
- "trans splicing",
- "trans-splicing",
- "alternative processing",
- "alternate processing",
- "artificial frameshift",
- "non-consensus splice site",
- "nonconsensus splice site",
- "rearrangement required for product",
- "unclassified transcription discrepancy",
- "unclassified translation discrepancy",
- NULL
-};
-
-static Boolean StringInStringList (CharPtr testString, CharPtr PNTR stringList) {
- Int2 i;
- i = 0;
- while (stringList [i] != NULL) {
- if (StringICmp (testString, stringList [i]) == 0)
- return 1;
- i++;
- }
- return 0;
-}
-
-/*
-Functions now public and prototyped in sequtil.h
-Return values are:
- 0: no problem - Accession is in proper format
--1: Accession did not start with a letter (or two letters)
--2: Accession did not contain five numbers (or six numbers after 2 letters)
--3: the original Accession number to be validated was NULL
--4: the original Accession number is too long (>16)
-*/
-
-NLM_EXTERN Int2 ValidateAccn (
- CharPtr accession
-)
-
-{
- Char ch;
- Int2 numAlpha = 0;
- Int2 numDigits = 0;
- Int2 numUndersc = 0;
- CharPtr str;
-
- if (accession == NULL || accession [0] == '\0') return -3;
-
- if (StringLen (accession) >= 16) return -4;
-
- if (accession [0] < 'A' || accession [0] > 'Z') return -1;
-
- str = accession;
- if (StringNCmp (str, "NZ_", 3) == 0) {
- str += 3;
- }
- ch = *str;
- while (IS_ALPHA (ch)) {
- numAlpha++;
- str++;
- ch = *str;
- }
- while (ch == '_') {
- numUndersc++;
- str++;
- ch = *str;
- }
- while (IS_DIGIT (ch)) {
- numDigits++;
- str++;
- ch = *str;
- }
- if (ch != '\0' && ch != ' ' && ch != '.') return -2;
-
- if (numUndersc > 1) return -2;
-
- if (numUndersc == 0) {
- if (numAlpha == 1 && numDigits == 5) return 0;
- if (numAlpha == 2 && numDigits == 6) return 0;
- if (numAlpha == 3 && numDigits == 5) return 0;
- if (numAlpha == 4 && numDigits == 8) return 0;
- } else if (numUndersc == 1) {
- if (numAlpha != 2 || (numDigits != 6 && numDigits != 8)) return -2;
- if (accession [0] == 'N' || accession [0] == 'X' || accession [0] == 'Z') {
- if (accession [1] == 'M' ||
- accession [1] == 'C' ||
- accession [1] == 'T' ||
- accession [1] == 'P' ||
- accession [1] == 'G' ||
- accession [1] == 'R' ||
- accession [1] == 'S' ||
- accession [1] == 'Z') {
- return 0;
- }
- }
- }
-
- return -2;
-}
-
-NLM_EXTERN Int2 ValidateSeqID (
- SeqIdPtr sip
-)
-
-{
- Char buf [41];
-
- if (sip == NULL) return -3;
- SeqIdWrite (sip, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
- return ValidateAccn (buf);
-}
-
-static CharPtr mrnaevtext1 = "Derived by automated computational analysis";
-static CharPtr mrnaevtext2 = "using gene prediction method:";
-static CharPtr mrnaevtext3 = "Supporting evidence includes similarity to:";
-
-static void GetStrFormRNAEvidence (
- UserObjectPtr uop,
- Pointer userdata
-)
-
-{
- size_t len;
- CharPtr method = NULL;
- Int2 nm = 0;
- ObjectIdPtr oip;
- CharPtr str = NULL;
- CharPtr PNTR strp;
- Char tmp [20];
- UserFieldPtr u, ufp, uu;
-
- if (uop == NULL) return;
- oip = uop->type;
- if (oip == NULL) return;
- if (StringCmp (oip->str, "ModelEvidence") != 0) return;
- strp = (CharPtr PNTR) userdata;
-
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (oip == NULL || ufp->data.ptrvalue == NULL) continue;
- if (StringCmp (oip->str, "Method") == 0) {
- method = StringSaveNoNull ((CharPtr) ufp->data.ptrvalue);
- }
- if (StringCmp (oip->str, "mRNA") == 0) {
- for (u = (UserFieldPtr) ufp->data.ptrvalue; u != NULL; u = u->next) {
- if (u->data.ptrvalue == NULL) continue;
- for (uu = (UserFieldPtr) u->data.ptrvalue; uu != NULL; uu = uu->next) {
- oip = uu->label;
- if (oip == NULL) continue;
- if (StringCmp (oip->str, "accession") == 0) {
- nm++;
- }
- }
- }
- }
- }
-
- len = StringLen (mrnaevtext1) + StringLen (mrnaevtext2) + StringLen (mrnaevtext3) + StringLen (method) + 30;
- str = (CharPtr) MemNew (len);
- if (str == NULL) return;
-
- if (method != NULL) {
- sprintf (str, "%s %s %s.", mrnaevtext1, mrnaevtext2, method);
- } else {
- sprintf (str, "%s.", mrnaevtext1);
- }
- if (nm > 0) {
- StringCat (str, " ");
- StringCat (str, mrnaevtext3);
- if (nm > 1) {
- sprintf (tmp, " %d mRNAs", (int) nm);
- } else {
- sprintf (tmp, " %d mRNA", (int) nm);
- }
- StringCat (str, tmp);
- }
-
- *strp = str;
-}
-
-static Boolean ValidateRptUnit (
- CharPtr buf
-)
-
-{
-#if 0
- CharPtr str;
- Char tmp [255];
-
- StringNCpy_0 (tmp, buf, sizeof (tmp));
- TrimSpacesAroundString (tmp);
-
- str = tmp;
- /* first check for sequence letters with optional semicolons */
- while (IS_ALPHA (*str) || *str == ';') str++;
- if (*str == '\0') return TRUE;
- /* next check for letters, digits, commas, parentheses, dashes, and underscores */
- str = tmp;
- while (IS_ALPHANUM (*str) || *str == '(' || *str == ')' || *str == ',' || *str == ';' || *str == '-' || *str == '_') str++;
- if (*str == '\0') return TRUE;
- /* now check for officially legal styles */
- str = tmp;
- while (IS_ALPHANUM (*str)) str++;
- if (*str != '\0') { /* wasn't pure alphanumeric; now check for xxx..yyy */
- str = buf;
- while (IS_DIGIT (*str)) str++; /* xxx */
- if (*str == '\0' /* must be something after the xxx */
- || StringLen (str) < 3 /* need at least 2 '.'s and a digit*/
- || str[0] != '.' || str[1] != '.') return FALSE;
- str+=2;
- while (IS_DIGIT (*str)) str++;
- if (*str != '\0') return FALSE; /* mustn't be anything after the yyy */
- }
-#endif
- return TRUE;
-}
-
-
-static CharPtr goQualType [] = {
- "", "Process", "Component", "Function", NULL
-};
-
-static void RecordGoFieldsInQVP (
- UserFieldPtr ufp,
- Pointer userdata
-)
-
-{
- UserFieldPtr entry;
- Int2 i;
- ObjectIdPtr oip;
- QualValPtr qvp;
-
- qvp = (QualValPtr) userdata;
-
- if (ufp == NULL || ufp->choice != 11) return;
- oip = ufp->label;
- if (oip == NULL) return;
- for (i = 0; goQualType [i] != NULL; i++) {
- if (StringICmp (oip->str, goQualType [i]) == 0) break;
- }
- if (goQualType [i] == NULL) return;
-
- entry = ufp->data.ptrvalue;
- if (entry == NULL || entry->choice != 11) return;
-
- /* ufp = (UserFieldPtr) entry->data.ptrvalue; */
- switch (i) {
- case 1 :
- qvp [FTQUAL_go_process].ufp = entry;
- break;
- case 2 :
- qvp [FTQUAL_go_component].ufp = entry;
- break;
- case 3 :
- qvp [FTQUAL_go_function].ufp = entry;
- break;
- default :
- break;
- }
-}
-
-static void RecordUserObjectsInQVP (
- UserObjectPtr uop,
- Pointer userdata
-)
-
-{
- ObjectIdPtr oip;
- QualValPtr qvp;
-
- if (uop == NULL || userdata == NULL) return;
- qvp = (QualValPtr) userdata;
- oip = uop->type;
- if (oip == NULL) return;
- if (StringCmp (oip->str, "ModelEvidence") == 0) {
- qvp [FTQUAL_modelev].uop = uop;
- } else if (StringCmp (oip->str, "GeneOntology") == 0) {
- VisitUserFieldsInUop (uop, (Pointer) qvp, RecordGoFieldsInQVP);
- }
-}
-
-static SeqIdPtr SeqLocIdForProduct (
- SeqLocPtr product
-)
-
-{
- SeqIdPtr sip;
- SeqLocPtr slp;
-
- /* in case product is a SEQLOC_EQUIV */
-
- if (product == NULL) return NULL;
- sip = SeqLocId (product);
- if (sip != NULL) return sip;
- slp = SeqLocFindNext (product, NULL);
- while (slp != NULL) {
- sip = SeqLocId (slp);
- if (sip != NULL) return sip;
- slp = SeqLocFindNext (product, slp);
- }
- return NULL;
-}
-
-static void AddIntervalsToGbfeat (
- GBFeaturePtr gbfeat,
- SeqLocPtr location,
- BioseqPtr target
-)
-
-{
- Char accn [41];
- SeqLocPtr copy = NULL;
- Int4 from;
- GBIntervalPtr gbint;
- Int4 gi;
- GBIntervalPtr last = NULL;
- Int4 point;
- SeqIntPtr sint;
- SeqIdPtr sip;
- SeqLocPtr slp;
- SeqPntPtr spp;
- Int4 to;
- Int4 swap;
-
- if (gbfeat == NULL || location == NULL) return;
- if (target != NULL) {
- copy = SeqLocMerge (target, location, NULL, FALSE, TRUE, FALSE);
- location = copy;
- }
-
- slp = SeqLocFindNext (location, NULL);
- while (slp != NULL) {
- from = 0;
- to = 0;
- point = 0;
- sip = NULL;
- switch (slp->choice) {
- case SEQLOC_WHOLE :
- sip = (SeqIdPtr) slp->data.ptrvalue;
- if (sip != NULL) {
- from = 1;
- to = SeqLocLen (slp);
- if (to < 0) {
- sip = NULL;
- }
- }
- break;
- case SEQLOC_INT :
- sint = (SeqIntPtr) slp->data.ptrvalue;
- if (sint != NULL) {
- from = sint->from + 1;
- to = sint->to + 1;
- sip = sint->id;
- if (sint->strand == Seq_strand_minus && from < to) {
- swap = from;
- from = to;
- to = swap;
- }
- }
- break;
- case SEQLOC_PNT :
- spp = (SeqPntPtr) slp->data.ptrvalue;
- if (spp != NULL) {
- point = spp->point + 1;
- sip = spp->id;
- }
- break;
- default :
- break;
- }
- if (sip != NULL) {
- accn [0] = '\0';
- if (sip->choice == SEQID_GI) {
- gi = sip->data.intvalue;
- if (! GetAccnVerFromServer (gi, accn)) {
- accn [0] = '\0';
- }
- if (StringHasNoText (accn)) {
- sip = GetSeqIdForGI (gi);
- SeqIdWrite (sip, accn, PRINTID_TEXTID_ACC_VER, sizeof (accn));
- SeqIdFree (sip);
- }
- } else {
- SeqIdWrite (sip, accn, PRINTID_TEXTID_ACC_VER, sizeof (accn));
- }
- if (! StringHasNoText (accn)) {
- gbint = GBIntervalNew ();
- if (gbint != NULL) {
- gbint->from = from;
- gbint->to = to;
- gbint->point = point;
- gbint->accession = StringSave (accn);
- if (gbfeat->intervals == NULL) {
- gbfeat->intervals = gbint;
- } else {
- last->next = gbint;
- }
- last = gbint;
- }
- }
- }
- slp = SeqLocFindNext (location, slp);
- }
-
- SeqLocFree (copy);
-}
-
-static Boolean CountBasesByRead (
- IntAsn2gbJobPtr ajp,
- BioseqPtr bsp,
- Int4Ptr base_count
-)
-
-{
- Byte bases [400];
- Uint1 code = Seq_code_iupacna;
- Int2 ctr;
- Int2 i;
- Int4 len;
- Uint1 residue;
- SeqPortPtr spp = NULL;
- Int4 total = 0;
-
- if (ISA_aa (bsp->mol)) {
- code = Seq_code_ncbieaa;
- }
-
- if (ajp->ajp.slp != NULL) {
- spp = SeqPortNewByLoc (ajp->ajp.slp, code);
- len = SeqLocLen (ajp->ajp.slp);
- } else {
- spp = SeqPortNew (bsp, 0, -1, 0, code);
- len = bsp->length;
- }
- if (spp == NULL) return FALSE;
- if (bsp->repr == Seq_repr_delta || bsp->repr == Seq_repr_virtual) {
- SeqPortSet_do_virtual (spp, TRUE);
- }
-
- /* use SeqPortRead rather than SeqPortGetResidue for faster performance */
-
- ctr = SeqPortRead (spp, bases, sizeof (bases));
- i = 0;
- residue = (Uint1) bases [i];
- while (residue != SEQPORT_EOF) {
- if (IS_residue (residue)) {
- total++;
- switch (residue) {
- case 'A' :
- (base_count [0])++;
- break;
- case 'C' :
- (base_count [1])++;
- break;
- case 'G' :
- (base_count [2])++;
- break;
- case 'T' :
- (base_count [3])++;
- break;
- default :
- (base_count [4])++;
- break;
- }
- }
- i++;
- if (i >= ctr) {
- i = 0;
- ctr = SeqPortRead (spp, bases, sizeof (bases));
- if (ctr < 0) {
- bases [0] = -ctr;
- } else if (ctr < 1) {
- bases [0] = SEQPORT_EOF;
- }
- }
- residue = (Uint1) bases [i];
- }
-
- SeqPortFree (spp);
-
- return TRUE;
-}
-
-static void LIBCALLBACK CountBasesByStream (
- CharPtr sequence,
- Pointer userdata
-)
-
-{
- Int4Ptr base_count;
- Char ch;
- CharPtr ptr;
-
- base_count = (Int4Ptr) userdata;
-
- ptr = sequence;
- ch = *ptr;
- while (ch != '\0') {
- ch = TO_UPPER (ch);
- switch (ch) {
- case 'A' :
- (base_count [0])++;
- break;
- case 'C' :
- (base_count [1])++;
- break;
- case 'G' :
- (base_count [2])++;
- break;
- case 'T' :
- (base_count [3])++;
- break;
- default :
- (base_count [4])++;
- break;
- }
- ptr++;
- ch = *ptr;
- }
-}
-
-static CharPtr FormatBasecountBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- Int4 base_count [5];
- BioseqPtr bsp;
- Char buf [80];
- Int2 i;
- Int4 len;
- StringItemPtr ffstring;
- CharPtr str;
-
- if (afp == NULL || bbp == NULL) return NULL;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
-
- asp = afp->asp;
- if (asp == NULL) return NULL;
- bsp = (asp->bsp);
- if (bsp == NULL) return NULL;
-
- /* after first formatting, result is cached into bbp->string */
-
- if (! StringHasNoText (bbp->string)) return StringSave (bbp->string);
-
- for (i = 0; i < 5; i++) {
- base_count [i] = 0;
- }
-
- if (ajp->ajp.slp != NULL) {
- len = SeqLocLen (ajp->ajp.slp);
- if (! CountBasesByRead (ajp, bsp, base_count)) return NULL;
- } else {
- len = bsp->length;
- SeqPortStream (bsp, TRUE, (Pointer) base_count, CountBasesByStream);
- }
-
- if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
-
- if (base_count [4] == 0) {
- sprintf (buf, "%7ld a%7ld c%7ld g%7ld t",
- (long) base_count [0], (long) base_count [1],
- (long) base_count [2], (long) base_count [3]);
- } else {
- sprintf (buf, "%7ld a%7ld c%7ld g%7ld t%7ld others",
- (long) base_count [0], (long) base_count [1],
- (long) base_count [2], (long) base_count [3],
- (long) base_count [4]);
- }
-
- } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
-
- sprintf (buf, "Sequence %ld BP; %ld A; %ld C; %ld G; %ld T; %ld other;",
- (long) len,
- (long) base_count [0], (long) base_count [1],
- (long) base_count [2], (long) base_count [3],
- (long) base_count [4]);
- }
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return NULL;
-
- if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
- FFAddOneString(ffstring, "XX\n", FALSE, FALSE, TILDE_IGNORE);
- }
- FFStartPrint (ffstring, afp->format, 0, 0, "BASE COUNT", 12, 5, 5, "SQ", FALSE);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- str = FFEndPrint(ajp, ffstring, afp->format, 12, 0, 5, 5, "SQ");
- FFRecycleString(ajp, ffstring);
-
- return str;
-}
-
-static void PrintSeqLine (
- StringItemPtr ffstring,
- FmtType format,
- CharPtr buf,
- Int4 start,
- Int4 stop
-)
-
-{
- size_t len;
- Char pos [16];
- Int4 pad;
-
- len = StringLen (buf);
- if (len > 0 && buf [len - 1] == ' ') {
- buf [len - 1] = '\0';
- }
-
- if (format == GENBANK_FMT || format == GENPEPT_FMT) {
-
- sprintf (pos, "%9ld", (long) (start + 1));
- FFAddOneString(ffstring, pos, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, ' ', FALSE);
- FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
-
- sprintf (pos, "%8ld", (long) (stop));
- FFAddNChar(ffstring, ' ', 5, FALSE);
- FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- pad = 72 - 5 - StringLen(buf);
- FFAddNChar(ffstring, ' ', pad, FALSE);
- FFAddOneString(ffstring, pos, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
-}
-
-static CharPtr CompressNonBases (CharPtr str)
-
-{
- Char ch;
- CharPtr dst;
- CharPtr ptr;
-
- if (str == NULL || str [0] == '\0') return NULL;
-
- dst = str;
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- if (IS_ALPHA (ch)) {
- *dst = ch;
- dst++;
- }
- ptr++;
- ch = *ptr;
- }
- *dst = '\0';
-
- return str;
-}
-
-/*
-static void CatenateSequenceInGbseq (
- GBSeqPtr gbseq,
- CharPtr str
-)
-
-{
- Char ch;
- CharPtr tmp;
-
- if (gbseq == NULL || StringHasNoText (str)) return;
-
- if (gbseq->sequence == NULL) {
- gbseq->sequence = StringSave (str);
- } else {
- tmp = (CharPtr) MemNew (StringLen (gbseq->sequence) + StringLen (str) + 2);
- StringCpy (tmp, gbseq->sequence);
- StringCat (tmp, str);
- gbseq->sequence = MemFree (gbseq->sequence);
- gbseq->sequence = tmp;
- }
-
- tmp = gbseq->sequence;
- if (tmp == NULL) return;
- ch = *tmp;
- while (ch != '\0') {
- if (ch == '\n' || ch == '\r' || ch == '\t') {
- *tmp = ' ';
- }
- tmp++;
- ch = *tmp;
- }
- TrimSpacesAroundString (gbseq->sequence);
- CompressNonBases (gbseq->sequence);
-}
-*/
-
- static Uint1 fasta_order [NUM_SEQID] = {
- 33, /* 0 = not set */
- 20, /* 1 = local Object-id */
- 15, /* 2 = gibbsq */
- 16, /* 3 = gibbmt */
- 30, /* 4 = giim Giimport-id */
- 10, /* 5 = genbank */
- 10, /* 6 = embl */
- 10, /* 7 = pir */
- 10, /* 8 = swissprot */
- 15, /* 9 = patent */
- 20, /* 10 = other TextSeqId */
- 20, /* 11 = general Dbtag */
- 255, /* 12 = gi */
- 10, /* 13 = ddbj */
- 10, /* 14 = prf */
- 12, /* 15 = pdb */
- 10, /* 16 = tpg */
- 10, /* 17 = tpe */
- 10 /* 18 = tpd */
- };
-
-static void PrintGenome (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- SeqLocPtr slp_head,
- CharPtr prefix,
- Boolean segWithParts
-)
-{
- Char buf[40], val[166];
- Boolean first = TRUE;
- SeqLocPtr slp;
- Int4 from, to, start, stop;
- SeqIdPtr sid, newid;
- BioseqPtr bsp = NULL;
- Int2 p1=0, p2=0;
-
- for (slp = slp_head; slp; slp = slp->next) {
- from = to = 0;
- sid = SeqLocId(slp);
- if (slp->choice == SEQLOC_INT || slp->choice == SEQLOC_WHOLE) {
- start = from = SeqLocStart(slp);
- stop = to = SeqLocStop(slp);
- } else if (slp->choice == SEQLOC_NULL){
- sprintf(val, ",%s", "gap()");
- FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
- continue;
- } else {
- continue;
- }
- if (sid == NULL) {
- continue;
- }
- newid = NULL;
- buf [0] = '\0';
- if (sid->choice == SEQID_GI) {
- if (GetAccnVerFromServer (sid->data.intvalue, buf)) {
- /* no need to call GetSeqIdForGI */
- } else {
- newid = GetSeqIdForGI (sid->data.intvalue);
- if (newid != NULL && segWithParts) {
- if (newid->choice == SEQID_GIBBSQ ||
- newid->choice == SEQID_GIBBMT ||
- newid->choice == SEQID_GIIM) {
- bsp = BioseqFind (newid);
- if (bsp != NULL && bsp->repr == Seq_repr_virtual) {
- if (bsp->length > 0) {
- sprintf (val, ",gap(%ld)", (long) bsp->length);
- } else {
- sprintf(val, ",%s", "gap()");
- }
- FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
- continue;
- }
- }
- }
- }
- } else if (sid->choice == SEQID_GENERAL) {
- newid = sid;
- } else {
- newid = sid;
- }
- if (prefix != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- }
- if (first) {
- first = FALSE;
- } else {
- FFAddOneChar(ffstring, ',', FALSE);
- /*ff_AddChar(',');*/
- }
- if (! StringHasNoText (buf)) {
- /* filled in by GetAccnVerFromServer */
- } else if (newid != NULL) {
- SeqIdWrite (SeqIdSelect (newid, fasta_order, NUM_SEQID),
- buf, PRINTID_TEXTID_ACC_VER, sizeof(buf) -1 );
- } else if (sid->choice == SEQID_GI) {
- SeqIdWrite (sid, buf, PRINTID_FASTA_LONG, sizeof (buf) - 1);
- }
-
- if (SeqLocStrand (slp) == Seq_strand_minus) {
- FFAddOneString(ffstring, "complement(", FALSE, FALSE, TILDE_IGNORE);
- }
- if ( GetWWW(ajp) ) {
- if (newid == NULL) {
- newid = sid;
- }
- if (newid->choice != SEQID_GENERAL) {
- FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "val=", buf, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, NULL, buf, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
- } else {
- FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
- }
-
- if (SeqLocStrand(slp) == Seq_strand_minus) {
- sprintf (val,":%ld..%ld)", (long) start+1, (long) stop+1);
- } else {
- sprintf (val,":%ld..%ld", (long) start+1, (long) stop+1);
- }
- FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
- p1 += StringLen (val);
- p2 += StringLen (val);
- }
-}
-
-static Boolean SegHasParts (
- BioseqPtr bsp
-)
-
-{
- BioseqSetPtr bssp;
- SeqEntryPtr sep;
-
- if (bsp == NULL || bsp->repr != Seq_repr_seg) return FALSE;
- sep = bsp->seqentry;
- if (sep == NULL) return FALSE;
- sep = sep->next;
- if (sep == NULL || (! IS_Bioseq_set (sep))) return FALSE;
- bssp = (BioseqSetPtr) sep->data.ptrvalue;
- if (bssp != NULL && bssp->_class == BioseqseqSet_class_parts) return TRUE;
- return FALSE;
-}
-
-static Boolean DeltaLitOnly (
- BioseqPtr bsp
-)
-
-{
- ValNodePtr vnp;
-
- if (bsp == NULL || bsp->repr != Seq_repr_delta) return FALSE;
- for (vnp = (ValNodePtr)(bsp->seq_ext); vnp != NULL; vnp = vnp->next) {
- if (vnp->choice == 1) return FALSE;
- }
- return TRUE;
-}
-
-static CharPtr FormatContigBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BioseqPtr bsp;
- DeltaSeqPtr dsp;
- GBSeqPtr gbseq;
- SeqLitPtr litp;
- CharPtr prefix = NULL;
- Boolean segWithParts = FALSE;
- SeqLocPtr slp_head = NULL;
- CharPtr str;
- Char val [20];
- StringItemPtr ffstring;
- CharPtr label;
-
- if (afp == NULL || bbp == NULL) return NULL;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
- bsp = (asp->bsp);
- if (bsp == NULL) return NULL;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return NULL;
-
- if ( GetWWW(ajp) ) {
- label = "CONTIG ";
- } else {
- label = "CONTIG";
- }
- FFAddOneString(ffstring, label, FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 12 - StringLen(label), FALSE);
-
- FFAddOneString(ffstring, "join(", FALSE, FALSE, TILDE_IGNORE);
-
- if (bsp->seq_ext_type == 1) {
-
- if (bsp->repr == Seq_repr_seg && SegHasParts (bsp)) {
- segWithParts = TRUE;
- }
-
- slp_head = (SeqLocPtr) bsp->seq_ext;
- PrintGenome (ajp, ffstring, slp_head, prefix, segWithParts);
-
- } else if (bsp->seq_ext_type == 4) {
-
- for (dsp = (DeltaSeqPtr) bsp->seq_ext; dsp != NULL; dsp=dsp->next) {
- if (dsp->choice == 1) {
-
- slp_head = (SeqLocPtr) dsp->data.ptrvalue;
- PrintGenome (ajp, ffstring, slp_head, prefix, FALSE);
-
- } else {
-
- litp = (SeqLitPtr) dsp->data.ptrvalue;
- if (litp != NULL) {
- if (litp->seq_data != NULL) {
- if (litp->length == 0) {
- sprintf (val, "gap(%ld)", (long) litp->length);
- FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
- } else {
- /* don't know what to do here */
- }
- } else {
- sprintf (val, ",gap(%ld)", (long) litp->length);
- FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
-
- prefix = ",";
- }
- }
-
- FFAddOneChar(ffstring, ')', FALSE);
-
- str = FFEndPrint(ajp, ffstring, afp->format, 12, 12, 12, 12, NULL);
- FFRecycleString(ajp, ffstring);
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- if (StringLen (str) > 12) {
- gbseq->contig = StringSave (str + 12);
- } else {
- gbseq->contig = StringSave (str);
- }
-
- CleanQualValue (gbseq->contig);
- Asn2gnbkCompressSpaces (gbseq->contig);
- StripAllSpaces (gbseq->contig);
- }
-
- return str;
-}
-
-static CharPtr FormatSlashBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- GBFeaturePtr currf, headf, nextf;
- GBReferencePtr currr, headr, nextr;
- GBSeqPtr gbseq;
- IndxPtr index;
-
- if (afp == NULL || bbp == NULL) return NULL;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
-
- /* sort and unique indexes */
-
- index = ajp->index;
-
- if (index != NULL) {
-
- MemCopy (index, &asp->index, sizeof (IndxBlock));
- MemSet (&asp->index, 0, sizeof (IndxBlock));
-
- index->authors = ValNodeSort (index->authors, SortVnpByString);
- index->authors = UniqueValNode (index->authors);
-
- index->genes = ValNodeSort (index->genes, SortVnpByString);
- index->genes = UniqueValNode (index->genes);
-
- index->journals = ValNodeSort (index->journals, SortVnpByString);
- index->journals = UniqueValNode (index->journals);
-
- index->keywords = ValNodeSort (index->keywords, SortVnpByString);
- index->keywords = UniqueValNode (index->keywords);
-
- index->secondaries = ValNodeSort (index->secondaries, SortVnpByString);
- index->secondaries = UniqueValNode (index->secondaries);
- }
-
- /* adjust XML-ized GenBank format */
-
- gbseq = ajp->gbseq;
-
- if (gbseq != NULL) {
-
- MemCopy (gbseq, &asp->gbseq, sizeof (GBSeq));
- MemSet (&asp->gbseq, 0, sizeof (GBSeq));
-
- /* reverse order of references */
-
- headr = NULL;
- for (currr = gbseq->references; currr != NULL; currr = nextr) {
- nextr = currr->next;
- currr->next = headr;
- headr = currr;
- }
- gbseq->references = headr;
-
- /* reverse order of features */
-
- headf = NULL;
- for (currf = gbseq->feature_table; currf != NULL; currf = nextf) {
- nextf = currf->next;
- currf->next = headf;
- headf = currf;
- }
- gbseq->feature_table = headf;
- }
-
- /* slash always has string pre-allocated by add slash block function */
-
- return StringSaveNoNull (bbp->string);
-}
-
-/* ********************************************************************** */
-
/* functions to record sections or blocks in linked lists */
-static Asn2gbSectPtr Asn2gbAddSection (
- Asn2gbWorkPtr awp
-)
-
-{
- Asn2gbSectPtr asp;
- ValNodePtr vnp;
-
- if (awp == NULL) return NULL;
-
- asp = (Asn2gbSectPtr) MemNew (sizeof (IntAsn2gbSect));
- if (asp == NULL) return NULL;
-
- vnp = ValNodeAddPointer (&(awp->lastsection), 0, asp);
- if (vnp == NULL) return asp;
-
- awp->lastsection = vnp;
- if (awp->sectionList == NULL) {
- awp->sectionList = vnp;
- }
-
- return asp;
-}
-
-static BaseBlockPtr Asn2gbAddBlock (
+NLM_EXTERN BaseBlockPtr Asn2gbAddBlock (
Asn2gbWorkPtr awp,
BlockType blocktype,
size_t size
@@ -10856,8384 +1465,6 @@ static BaseBlockPtr Asn2gbAddBlock (
}
-/* ********************************************************************** */
-
-/* add functions allocate specific blocks, populate with paragraph print info */
-
-static CharPtr strd [4] = {
- " ", "ss-", "ds-", "ms-"
-};
-
-static CharPtr gnbk_mol [14] = {
- " ", "DNA ", "RNA ", "mRNA", "rRNA", "tRNA", "snRNA", "scRNA", " AA ", "DNA ", "DNA ", "RNA ", "snoRNA", "RNA "
-};
-
-/* EMBL_FMT in RELEASE_MODE or ENTREZ_MODE, otherwise use gnbk_mol */
-
-static CharPtr embl_mol [14] = {
- "xxx", "DNA", "RNA", "RNA", "RNA", "RNA", "RNA", "RNA", "AA ", "DNA", "DNA", "RNA", "RNA", "RNA"
-};
-
-static CharPtr embl_divs [18] = {
- "FUN", "INV", "MAM", "ORG", "PHG", "PLN", "PRI", "PRO", "ROD"
- "SYN", "UNA", "VRL", "VRT", "PAT", "EST", "STS", "HUM", "HTC"
-};
-
-static Uint1 imolToMoltype [14] = {
- 0, 1, 2, 5, 4, 3, 6, 7, 9, 1, 1, 2, 8, 2
-};
-
-static DatePtr GetBestDate (
- DatePtr a,
- DatePtr b
-)
-
-{
- Int2 status;
-
- if (a == NULL) return b;
- if (b == NULL) return a;
-
- status = DateMatch (a, b, FALSE);
- if (status == 1) return a;
-
- return b;
-}
-
-/*--------------------------------------------------------*/
-/* */
-/* s_IsSeperatorNeeded() */
-/* */
-/*--------------------------------------------------------*/
-
-static Boolean s_IsSeperatorNeeded(CharPtr baseString, Int4 baseLength, Int2 suffixLength)
-{
- Char lastChar;
- Char nextToLastChar;
-
- lastChar = baseString[baseLength - 1];
- nextToLastChar = baseString[baseLength - 2];
-
- /* This first check put here to emulate what may be a */
- /* bug in the original code (in CheckLocusLength() ) */
- /* which adds an 'S' segment seperator only if it */
- /* DOES make the string longer than the max. */
-
- if (baseLength + suffixLength < 16)
- return FALSE;
-
- /* If the last character is not a digit */
- /* then don't use a seperator. */
-
- if (!IS_DIGIT(lastChar))
- return FALSE;
-
- /* If the last two characters are a non-digit */
- /* followed by a '0', then don't use seperator. */
-
- if ((lastChar == '0') && (!IS_DIGIT(nextToLastChar)))
- return FALSE;
-
- /* If we made it to here, use a seperator */
-
- return TRUE;
-}
-
-/*--------------------------------------------------------*/
-/* */
-/* s_LocusAddSuffix() - */
-/* */
-/*--------------------------------------------------------*/
-
-static Boolean s_LocusAddSuffix (CharPtr locus, Asn2gbWorkPtr awp)
-{
- size_t buflen;
- Char ch;
- Char segCountStr[6];
- Int2 segCountStrLen;
- Char segSuffix[5];
-
- buflen = StringLen (locus);
-
- /* If there's one or less segments, */
- /* no suffix is needed. */
-
- if (awp->numsegs <= 1)
- return FALSE;
-
- /* If the basestring has one or less */
- /* characters, no suffix is needed. */
-
- if (buflen <=1)
- return FALSE;
-
- /* Add the suffix */
-
- ch = locus[buflen-1];
- sprintf(segCountStr,"%d",awp->numsegs);
- segCountStrLen = StringLen(segCountStr);
- segSuffix[0] = '\0';
-
- if (s_IsSeperatorNeeded(locus,buflen,segCountStrLen) == TRUE)
- sprintf(segSuffix,"S%0*d",segCountStrLen,awp->seg);
- else
- sprintf(segSuffix,"%0*d",segCountStrLen,awp->seg);
- StringCat(locus,segSuffix);
-
- /* Return successfully */
-
- return TRUE;
-}
-
-/*--------------------------------------------------------*/
-/* */
-/* s_LocusAdjustLength() - */
-/* */
-/*--------------------------------------------------------*/
-
-static Boolean s_LocusAdjustLength(CharPtr locus, Int2 maxLength)
-{
- Int2 trimCount;
- Int2 buflen;
- CharPtr buftmp;
-
- buflen = StringLen (locus);
- if (buflen <= maxLength) return FALSE;
-
- buftmp = MemNew(maxLength + 1);
-
- /* If the sequence id is an NCBI locus of the */
- /* form HSU00001, then make sure that if */
- /* there is trimming the HS gets trimmed off */
- /* as a unit, never just the 'H'. */
-
- trimCount = buflen - maxLength;
- if (trimCount == 1)
- if (IS_ALPHA(locus[0]) != 0 &&
- IS_ALPHA(locus[1]) != 0 &&
- IS_ALPHA(locus[2]) != 0 &&
- IS_DIGIT(locus[3]) != 0 &&
- IS_DIGIT(locus[4]) != 0 &&
- IS_DIGIT(locus[5]) != 0 &&
- IS_DIGIT(locus[6]) != 0 &&
- IS_DIGIT(locus[7]) != 0 &&
- locus[8] == 'S' &&
- locus[9] == '\0')
- trimCount++;
-
- /* Left truncate the sequence id */
-
- StringCpy(buftmp, &locus[trimCount]);
- StringCpy(locus, buftmp);
-
- MemFree(buftmp);
- return TRUE;
-}
-
-/*--------------------------------------------------------*/
-/* */
-/* AddLocusBlock() - */
-/* */
-/*--------------------------------------------------------*/
-
-static DatePtr GetBestDateForBsp (
- BioseqPtr bsp
-)
-
-{
- DatePtr best_date = NULL;
- SeqMgrDescContext dcontext;
- DatePtr dp;
- EMBLBlockPtr ebp;
- GBBlockPtr gbp;
- PdbBlockPtr pdp;
- PdbRepPtr prp;
- SeqDescrPtr sdp;
- SPBlockPtr spp;
-
- if (bsp == NULL) return NULL;
-
- dp = NULL;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_update_date, &dcontext);
- if (sdp != NULL) {
- dp = (DatePtr) sdp->data.ptrvalue;
- best_date = GetBestDate (dp, best_date);
- }
-
- /* !!! temporarily also look at genbank block entry date !!! */
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
- if (sdp != NULL) {
- gbp = (GBBlockPtr) sdp->data.ptrvalue;
- if (gbp != NULL) {
- dp = gbp->entry_date;
- best_date = GetBestDate (dp, best_date);
- }
- }
-
- /* more complicated code for dates from various objects goes here */
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_embl, &dcontext);
- if (sdp != NULL) {
- ebp = (EMBLBlockPtr) sdp->data.ptrvalue;
- if (ebp != NULL) {
- dp = ebp->creation_date;
- best_date = GetBestDate (dp, best_date);
- dp = ebp->update_date;
- best_date = GetBestDate (dp, best_date);
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_sp, &dcontext);
- if (sdp != NULL) {
- spp = (SPBlockPtr) sdp->data.ptrvalue;
- if (spp != NULL) {
- dp = spp->created;
- if (dp != NULL && dp->data [0] == 1) {
- best_date = GetBestDate (dp, best_date);
- }
- dp = spp->sequpd;
- if (dp != NULL && dp->data [0] == 1) {
- best_date = GetBestDate (dp, best_date);
- }
- dp = spp->annotupd;
- if (dp != NULL && dp->data [0] == 1) {
- best_date = GetBestDate (dp, best_date);
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_pdb, &dcontext);
- if (sdp != NULL) {
- pdp = (PdbBlockPtr) sdp->data.ptrvalue;
- if (pdp != NULL) {
- dp = pdp->deposition;
- if (dp != NULL && dp->data [0] == 1) {
- best_date = GetBestDate (dp, best_date);
- }
- prp = pdp->replace;
- if (prp != NULL) {
- dp = prp->date;
- if (dp != NULL && dp->data[0] == 1) {
- best_date = GetBestDate (dp, best_date);
- }
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_create_date, &dcontext);
- if (sdp != NULL) {
- dp = (DatePtr) sdp->data.ptrvalue;
- if (dp != NULL) {
- best_date = GetBestDate (dp, best_date);
- }
- }
-
- return best_date;
-}
-
-static Boolean LocusHasBadChars (
- CharPtr locus
-)
-
-{
- Char ch;
- CharPtr ptr;
-
- ptr = locus;
- ch = *ptr;
- while (ch != '\0') {
- if (! IS_ALPHANUM (ch)) {
- return TRUE;
- }
- ptr++;
- ch = *ptr;
- }
- return FALSE;
-}
-
-static void AddLocusBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- size_t acclen;
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BaseBlockPtr bbp;
- DatePtr best_date = NULL;
- BioSourcePtr biop;
- Int2 bmol = 0;
- BioseqPtr bsp;
- SeqFeatPtr cds;
- Char date [40];
- SeqMgrDescContext dcontext;
- Char div [10];
- BioseqPtr dna;
- DatePtr dp;
- CharPtr ebmol;
- EMBLBlockPtr ebp;
- SeqMgrFeatContext fcontext;
- GBBlockPtr gbp;
- Char gene [32];
- Boolean genome_view;
- GBSeqPtr gbseq;
- Char id [41];
- Int2 imol = 0;
- IndxPtr index;
- Int2 istrand;
- Boolean is_nm = FALSE;
- Boolean is_np = FALSE;
- Boolean is_nz = FALSE;
- Boolean is_transgenic = FALSE;
- Char len [32];
- Int4 length;
- size_t loclen;
- Char locus [41];
- MolInfoPtr mip;
- Char mol [30];
- BioseqPtr nm = NULL;
- OrgNamePtr onp;
- Uint1 origin;
- OrgRefPtr orp;
- BioseqPtr parent;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp;
- SeqIdPtr sip;
- SubSourcePtr ssp;
- Uint1 tech;
- Uint1 topology;
- TextSeqIdPtr tsip;
- Boolean wgsmaster = FALSE;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
- asp = awp->asp;
- if (asp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, LOCUS_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- mol [0] = '\0';
- len [0] = '\0';
- div [0] = '\0';
- date [0] = '\0';
- gene [0] = '\0';
-
- genome_view = FALSE;
- if (bsp->repr == Seq_repr_seg && (! SegHasParts (bsp))) {
- genome_view = TRUE;
- }
- if (bsp->repr == Seq_repr_delta && (! DeltaLitOnly (bsp))) {
- genome_view = TRUE;
- }
-
- /* locus id */
-
- sip = NULL;
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_OTHER) {
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL) {
- if (StringNCmp (tsip->accession, "NM_", 3) == 0 ||
- StringNCmp (tsip->accession, "NR_", 3) == 0 ||
- StringNCmp (tsip->accession, "XM_", 3) == 0 ||
- StringNCmp (tsip->accession, "XR_", 3) == 0) {
- is_nm = TRUE;
- nm = bsp;
- } else if (StringNCmp (tsip->accession, "NP_", 3) == 0 ||
- StringNCmp (tsip->accession, "XP_", 3) == 0) {
- is_np = TRUE;
- } else if (StringNCmp (tsip->accession, "NZ_", 3) == 0) {
- is_nz = TRUE;
- }
- }
- break;
- }
- if (sip->choice == SEQID_GENBANK ||
- sip->choice == SEQID_EMBL ||
- sip->choice == SEQID_DDBJ) break;
- if (sip->choice == SEQID_PIR ||
- sip->choice == SEQID_SWISSPROT ||
- sip->choice == SEQID_PRF ||
- sip->choice == SEQID_PDB) break;
- if (sip->choice == SEQID_TPG ||
- sip->choice == SEQID_TPE ||
- sip->choice == SEQID_TPD) break;
- }
- if (sip == NULL) {
- sip = SeqIdFindBest (bsp->id, SEQID_GENBANK);
- }
-
- if (genome_view) {
- SeqIdWrite (sip, locus, PRINTID_TEXTID_ACCESSION, sizeof (locus) - 1);
- } else {
- SeqIdWrite (sip, locus, PRINTID_TEXTID_LOCUS, sizeof (locus) - 1);
- if (LocusHasBadChars (locus)) {
- SeqIdWrite (sip, locus, PRINTID_TEXTID_ACCESSION, sizeof (locus) - 1);
- }
- }
-
- if (is_np) {
- sfp = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
- if (sfp != NULL && fcontext.bsp != NULL) {
- nm = fcontext.bsp;
- for (sip = nm->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_OTHER) {
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL) {
- if (StringNCmp (tsip->accession, "NM_", 3) == 0 ||
- StringNCmp (tsip->accession, "XM_", 3) == 0) {
- is_nm = TRUE;
- }
- }
- }
- }
- if (! is_nm) {
- nm = NULL;
- }
- }
- }
- if (nm != NULL) {
- /*
- sfp = SeqMgrGetNextFeature (nm, NULL, SEQFEAT_GENE, 0, &fcontext);
- if (sfp != NULL) {
- StringNCpy_0 (gene, fcontext.label, sizeof (gene));
- if (SeqMgrGetNextFeature (nm, sfp, SEQFEAT_GENE, 0, &fcontext) != NULL) {
- gene [0] = '\0';
- }
- if (StringLen (gene) > 15) {
- gene [0] = '\0';
- }
- }
- */
- }
-
- /* more complicated code to get parent locus, if segmented, goes here */
-
- if (awp->slp != NULL) {
- length = SeqLocLen (awp->slp);
- } else {
- length = bsp->length;
- }
-
- mip = NULL;
- tech = MI_TECH_standard;
- origin = 0;
- bmol = bsp->mol;
- if (bmol > Seq_mol_aa) {
- bmol = 0;
- }
- istrand = bsp->strand;
- if (istrand > 3) {
- istrand = 0;
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp != NULL) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
-
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip != NULL) {
- if (mip->biomol <= MOLECULE_TYPE_TRANSCRIBED_RNA) {
- imol = (Int2) mip->biomol;
- }
- tech = mip->tech;
-
- if (tech == MI_TECH_wgs && bsp->repr == Seq_repr_virtual) {
-
- /* check for WGS master record */
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- switch (sip->choice) {
- case SEQID_GENBANK :
- case SEQID_EMBL :
- case SEQID_DDBJ :
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL && tsip->accession != NULL) {
- acclen = StringLen (tsip->accession);
- if (acclen == 12) {
- if (StringCmp (tsip->accession + 6, "000000") == 0) {
- wgsmaster = TRUE;
- }
- } else if (acclen == 13) {
- if (StringCmp (tsip->accession + 6, "0000000") == 0) {
- wgsmaster = TRUE;
- }
- }
- }
- break;
- case SEQID_OTHER :
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL && tsip->accession != NULL) {
- if (StringLen (tsip->accession) == 15) {
- if (StringCmp (tsip->accession + 9, "000000") == 0) {
- wgsmaster = TRUE;
- }
- }
- }
- break;
- default :
- break;
- }
- }
- }
- }
- }
-
- /* check inst.mol if mol-type is not-set or genomic */
-
- if (imol <= MOLECULE_TYPE_GENOMIC) {
- if (bmol == Seq_mol_aa) {
- imol = MOLECULE_TYPE_PEPTIDE;
- } else if (bmol == Seq_mol_na) {
- imol = 0;
- } else if (bmol == Seq_mol_rna) {
- imol = 2;
- } else {
- imol = 1;
- }
- } else if (imol == MOLECULE_TYPE_OTHER_GENETIC_MATERIAL) {
- if (bmol == Seq_mol_rna) {
- imol = 2;
- }
- }
-
- /* if ds-DNA don't show ds */
-
- if (bmol == Seq_mol_dna && istrand == 2) {
- istrand = 0;
- }
-
- /* ss=any RNA don't show ss */
-
- if ((bmol > Seq_mol_rna ||
- (imol >= MOLECULE_TYPE_MRNA && imol <= MOLECULE_TYPE_PEPTIDE)) &&
- istrand == 1) {
- istrand = 0;
- }
-
- topology = bsp->topology;
- if (awp->slp != NULL) {
- topology = TOPOLOGY_LINEAR;
- }
-
- /* length, topology, and molecule type */
-
- if (awp->format == GENBANK_FMT) {
-
- if (awp->newLocusLine) {
-
- if (wgsmaster && (! is_nz)) {
- sprintf (len, "%ld rc", (long) length);
- } else {
- sprintf (len, "%ld bp", (long) length);
- }
- sprintf (mol, "%s%-4s", strd [istrand], gnbk_mol [imol]);
-
- } else {
-
- if (topology == TOPOLOGY_CIRCULAR) {
- sprintf (len, "%7ld bp", (long) length);
- sprintf (mol, "%s%-4s circular", strd [istrand], gnbk_mol [imol]);
- } else {
- sprintf (len, "%7ld bp", (long) length);
- sprintf (mol, "%s%-4s ", strd [istrand], gnbk_mol [imol]);
- }
- }
-
- } else if (awp->format == GENPEPT_FMT) {
-
- if (awp->newLocusLine) {
- sprintf (len, "%ld aa", (long) length);
- } else {
- sprintf (len, "%7ld aa", (long) length);
- }
-
- } else if (awp->format == EMBL_FMT) {
-
- if (imol < MOLECULE_TYPE_PEPTIDE) {
- if (ajp->flags.useEmblMolType) {
- ebmol = embl_mol [imol];
- } else {
- ebmol = gnbk_mol [imol];
- }
-
- if (topology == TOPOLOGY_CIRCULAR) {
- sprintf (mol, "circular %s", ebmol);
- sprintf (len, "%ld BP.", (long) length);
- } else {
- sprintf (mol, "%s", ebmol);
- sprintf (len, "%ld BP.", (long) length);
- }
- }
- }
-
- /* division */
-
- biop = NULL;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
- if (sdp != NULL) {
- biop = (BioSourcePtr) sdp->data.ptrvalue;
- } else {
- sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_BIOSRC, 0, &fcontext);
- if (sfp != NULL) {
- biop = (BioSourcePtr) sfp->data.value.ptrvalue;
- } else if (ISA_aa (bsp->mol)) {
-
- /* if protein with no sources, get sources applicable to DNA location of CDS */
-
- cds = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
- if (cds != NULL) {
- sfp = SeqMgrGetOverlappingSource (cds->location, &fcontext);
- if (sfp != NULL) {
- biop = (BioSourcePtr) sfp->data.value.ptrvalue;
- } else {
- dna = BioseqFindFromSeqLoc (cds->location);
- if (dna != NULL) {
- sdp = SeqMgrGetNextDescriptor (dna, NULL, Seq_descr_source, &dcontext);
- if (sdp != NULL) {
- biop = (BioSourcePtr) sdp->data.ptrvalue;
- }
- }
- }
- }
- }
- }
- if (biop != NULL) {
- origin = biop->origin;
- orp = biop->org;
- if (orp != NULL) {
- onp = orp->orgname;
- if (onp != NULL) {
- StringNCpy_0 (div, onp->div, sizeof (div));
- }
- }
- for (ssp = biop->subtype; ssp != NULL; ssp = ssp->next) {
- if (ssp->subtype == SUBSRC_transgenic) {
- is_transgenic = TRUE;
- }
- }
- }
-
- switch (tech) {
- case MI_TECH_est :
- StringCpy (div, "EST");
- break;
- case MI_TECH_sts :
- StringCpy (div, "STS");
- break;
- case MI_TECH_survey :
- StringCpy (div, "GSS");
- break;
- case MI_TECH_htgs_0 :
- case MI_TECH_htgs_1 :
- case MI_TECH_htgs_2 :
- StringCpy (div, "HTG");
- break;
- case MI_TECH_htc :
- StringCpy (div, "HTC");
- break;
- default :
- break;
- }
-
- if (origin == 5 || is_transgenic) {
- StringCpy (div, "SYN");
- }
-
- sip = SeqIdFindBest (bsp->id, SEQID_PATENT);
- if (sip != NULL && sip->choice == SEQID_PATENT) {
- StringCpy (div, "PAT");
- }
-
- /* more complicated code for division, if necessary, goes here */
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
- while (sdp != NULL) {
- gbp = (GBBlockPtr) sdp->data.ptrvalue;
- if (gbp != NULL) {
- if (StringHasNoText (div) && gbp->div != NULL) {
- StringCpy (div, gbp->div);
- }
- else if (StringCmp(gbp->div, "PAT") == 0 ||
- StringCmp(gbp->div, "SYN") == 0 ) {
- StringCpy (div, gbp->div);
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_genbank, &dcontext);
- }
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_embl, &dcontext);
- if (sdp != NULL) {
- ebp = (EMBLBlockPtr) sdp->data.ptrvalue;
- if (ebp != NULL) {
- if (ebp->div == 255) {
- if (mip == NULL) {
- StringCpy (div, "HUM");
- }
- } else if (ebp->div < 18) {
- StringCpy (div, embl_divs [ebp->div]);
- }
- }
- }
-
- if (StringHasNoText (div)) {
- StringCpy (div, "UNA");
- }
- }
-
- /* empty division field if unable to find anything */
-
- if (StringHasNoText (div)) {
- StringCpy (div, " ");
- }
-
- /* contig style (old genome_view flag) forces CON division */
-
- if (awp->contig) {
- StringCpy (div, "CON");
- }
-
- if (genome_view) {
- StringCpy (div, "CON");
- }
-
- /* date */
-
- best_date = GetBestDateForBsp (bsp);
-
- if (best_date == NULL) {
-
- /* if bsp is product of CDS or mRNA feature, get date from sfp->location bsp */
-
- sfp = NULL;
- if (ISA_na (bsp->mol)) {
- sfp = SeqMgrGetRNAgivenProduct (bsp, NULL);
- } else if (ISA_aa (bsp->mol)) {
- sfp = SeqMgrGetCDSgivenProduct (bsp, NULL);
- }
- if (sfp != NULL) {
- parent = BioseqFindFromSeqLoc (sfp->location);
- if (parent != NULL) {
- best_date = GetBestDateForBsp (parent);
- }
- }
- }
-
- /* convert best date */
-
- if (best_date != NULL) {
- DateToGB (date, best_date, FALSE);
- }
- if (StringHasNoText (date)) {
- StringCpy (date, "01-JAN-1900");
- }
-
- if (awp->format == GENBANK_FMT || awp->format == GENPEPT_FMT) {
-
- /* Create the proper locus name */
-
- parent = awp->parent;
- if (parent->repr == Seq_repr_seg) {
-
- if (! StringHasNoText (awp->basename)) {
- StringCpy (locus, awp->basename);
- s_LocusAddSuffix (locus, awp);
- }
- }
-
- /* Print the "LOCUS_NEW" line, if requested */
-
- if (awp->newLocusLine) {
- FFStartPrint (ffstring, awp->format, 0, 0, "LOCUS", 12, 0, 0, NULL, FALSE);
- parent = awp->parent;
-
- if (parent->repr == Seq_repr_seg)
- s_LocusAdjustLength (locus,16);
-
- if (is_nm && (! StringHasNoText (gene))) {
- FFAddOneString (ffstring, gene, FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString (ffstring, locus, FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddNChar(ffstring, ' ', 43 - StringLen(len)- ffstring->curr->pos, FALSE);
- FFAddOneString (ffstring, len, FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 44 - ffstring->curr->pos, FALSE);
- FFAddOneString (ffstring, mol, FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 55 - ffstring->curr->pos, FALSE);
- if (topology == TOPOLOGY_CIRCULAR) {
- FFAddOneString (ffstring, "circular", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString (ffstring, "linear ", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddNChar(ffstring, ' ', 64 - ffstring->curr->pos, FALSE);
- FFAddOneString (ffstring, div, FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 68 - ffstring->curr->pos, FALSE);
- FFAddOneString (ffstring, date, FALSE, FALSE, TILDE_IGNORE);
- }
-
- /* Else print the "LOCUS" line */
-
- else {
- FFStartPrint (ffstring, awp->format, 0, 0, "LOCUS", 12, 0, 0, NULL, FALSE);
-
- if (parent->repr == Seq_repr_seg)
- s_LocusAdjustLength (locus,16);
-
- FFAddOneString (ffstring, locus, FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 32 - StringLen(len) - ffstring->curr->pos, FALSE);
- FFAddOneString (ffstring, len, FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 33 - ffstring->curr->pos, FALSE);
- FFAddOneString (ffstring, mol, FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 52 - ffstring->curr->pos, FALSE);
- FFAddOneString (ffstring, div, FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 62 - ffstring->curr->pos, FALSE);
- FFAddOneString (ffstring, date, FALSE, FALSE, TILDE_IGNORE);
- }
-
- } else if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
- FFStartPrint (ffstring, awp->format, 0, 0, NULL, 0, 5, 0, "ID", FALSE);
- FFAddOneString (ffstring, locus, FALSE, FALSE, TILDE_IGNORE);
- loclen = StringLen(locus);
- if (14 - 5 - loclen > 0) {
- FFAddNChar(ffstring, ' ', 14 - 5 - loclen, FALSE);
- }
- if (awp->hup) {
- FFAddOneString (ffstring, " confidential; ", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString (ffstring, " standard; ", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, mol, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, "; ", FALSE, FALSE, TILDE_IGNORE);
-
- /* conditional code to make div "UNA" goes here */
-
- FFAddOneString (ffstring, div, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, "; ", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, len, FALSE, FALSE, TILDE_IGNORE);
- }
-
- /* optionally populate indexes for NCBI internal database */
-
- if (ajp->index) {
- index = &asp->index;
- } else {
- index = NULL;
- }
-
- if (index != NULL) {
- Char tmp [20];
- index->locus = StringSave (locus);
- index->div = StringSave (div);
- sprintf (tmp, "%ld", (long) length);
- index->base_cnt = StringSave (tmp);
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- gbseq->locus = StringSave (locus);
- gbseq->length = length;
- gbseq->division = StringSave (div);
- gbseq->strandedness = bsp->strand;
- gbseq->moltype = imolToMoltype [imol];
- gbseq->topology = topology;
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- SeqIdWrite (sip, id, PRINTID_FASTA_SHORT, sizeof (id));
- ValNodeCopyStr (&gbseq->other_seqids, 0, id);
- }
-
- date [0] = '\0';
- dp = NULL;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_create_date, &dcontext);
- if (sdp != NULL) {
- dp = (DatePtr) sdp->data.ptrvalue;
- }
- if (dp != NULL) {
- DateToGB (date, dp, FALSE);
- }
- if (StringHasNoText (date)) {
- StringCpy (date, "01-JAN-1900");
- }
- gbseq->create_date = StringSave (date);
-
- date [0] = '\0';
- dp = NULL;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_update_date, &dcontext);
- if (sdp != NULL) {
- dp = (DatePtr) sdp->data.ptrvalue;
- }
- if (dp != NULL) {
- DateToGB (date, dp, FALSE);
- }
- if (StringHasNoText (date)) {
- StringCpy (date, "01-JAN-1900");
- }
- gbseq->update_date = StringSave (date);
- }
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 0, 5, 0, "ID");
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddDeflineBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Char buf[4096];
- /*CharPtr buf;
- size_t buflen = 4096;*/
- SeqMgrDescContext dcontext;
- GBSeqPtr gbseq;
- ItemInfo ii;
- MolInfoPtr mip;
- SeqDescrPtr sdp;
- Uint1 tech;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
- asp = awp->asp;
- if (asp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, DEFLINE_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- tech = 0;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp != NULL) {
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip != NULL) {
- tech = mip->tech;
- }
- }
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- /*buf = MemNew (sizeof (Char) * (buflen + 1));*/
- MemSet ((Pointer) (&ii), 0, sizeof (ItemInfo));
- MemSet ((Pointer) buf, 0, sizeof (buf));
-
- /* create default defline */
-
- if ( CreateDefLine (&ii, bsp, buf, sizeof(buf), tech, NULL, NULL)) {
- bbp->entityID = ii.entityID;
- bbp->itemID = ii.itemID;
- bbp->itemtype = ii.itemtype;
-
- FFStartPrint (ffstring, awp->format, 0, 12, "DEFINITION", 12, 5, 5, "DE", TRUE);
-
- if (StringHasNoText (buf)) {
- FFAddOneChar (ffstring, '.', FALSE);
- } else {
- FFAddOneString (ffstring, buf, TRUE, TRUE, TILDE_IGNORE);
- }
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "DE");
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- gbseq->definition = StringSave (buf);
- }
-
- FFRecycleString(ajp, ffstring);
-}
-
-/* !!! this definitely needs more work to support all classes, use proper SeqId !!! */
-
-static void AddAccessionBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- size_t acclen;
- SeqIdPtr accn = NULL;
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Char buf [41];
- SeqMgrDescContext dcontext;
- EMBLBlockPtr ebp;
- ValNodePtr extra_access;
- CharPtr flatloc;
- GBBlockPtr gbp;
- SeqIdPtr gi = NULL;
- GBSeqPtr gbseq;
- IndxPtr index;
- SeqIdPtr lcl = NULL;
- size_t len = 0;
- MolInfoPtr mip;
- SeqDescrPtr sdp;
- CharPtr separator = " ";
- SeqIdPtr sip;
- TextSeqIdPtr tsip;
- ValNodePtr vnp;
- CharPtr wgsaccn = NULL;
- CharPtr xtra;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
- asp = awp->asp;
- if (asp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- switch (sip->choice) {
- case SEQID_GI :
- gi = sip;
- break;
- case SEQID_GENBANK :
- case SEQID_EMBL :
- case SEQID_DDBJ :
- accn = sip;
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL) {
- acclen = StringLen (tsip->accession);
- if (acclen == 12) {
- wgsaccn = tsip->accession;
- len = 12;
- } else if (acclen == 13) {
- wgsaccn = tsip->accession;
- len = 13;
- }
- }
- break;
- case SEQID_OTHER :
- accn = sip;
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL) {
- if (StringLen (tsip->accession) == 15) {
- wgsaccn = tsip->accession;
- len = 15;
- }
- }
- break;
- case SEQID_PIR :
- case SEQID_SWISSPROT :
- case SEQID_PRF :
- case SEQID_PDB :
- accn = sip;
- break;
- case SEQID_TPG :
- case SEQID_TPE :
- case SEQID_TPD :
- accn = sip;
- break;
- case SEQID_GENERAL :
- /* should not override better accession */
- if (accn == NULL) {
- accn = sip;
- }
- break;
- case SEQID_LOCAL :
- lcl = sip;
- break;
- default :
- break;
- }
- }
-
- sip = NULL;
- if (accn != NULL) {
- sip = accn;
- } else if (lcl != NULL) {
- sip = lcl;
- } else if (gi != NULL) {
- sip = gi;
- }
-
- if (sip == NULL) return;
-
- SeqIdWrite (sip, buf, PRINTID_TEXTID_ACC_ONLY, sizeof (buf));
-
- bbp = Asn2gbAddBlock (awp, ACCESSION_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- FFStartPrint (ffstring, awp->format, 0, 12, "ACCESSION", 12, 5, 5, "AC", TRUE);
-
- if (awp->hup && accn != NULL) {
- FFAddOneString (ffstring, ";", FALSE, FALSE, TILDE_TO_SPACES);
-
- } else if (ajp->ajp.slp != NULL) {
- FF_www_accession (ajp, ffstring, buf);
- flatloc = FlatLoc (ajp, bsp, ajp->ajp.slp, ajp->masterStyle);
- FFAddTextToString (ffstring, " REGION: ", flatloc, NULL, FALSE, FALSE, TILDE_TO_SPACES);
- MemFree (flatloc);
- } else {
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- }
-
- /* optionally populate indexes for NCBI internal database */
-
- if (ajp->index) {
- index = &asp->index;
- } else {
- index = NULL;
- }
-
- if (index != NULL) {
- index->accession = StringSave (buf);
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- gbseq->primary_accession = StringSave (buf);
- }
-
- if (awp->format == GENBANK_FMT || awp->format == GENPEPT_FMT) {
- separator = " ";
- } else if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
- separator = ";";
- }
-
- if (ajp->ajp.slp == NULL) {
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp != NULL && wgsaccn != NULL) {
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip != NULL && mip->tech == MI_TECH_wgs) {
- StringNCpy_0 (buf, wgsaccn, sizeof (buf));
- acclen = StringLen (buf);
- if (acclen == 12 && StringCmp (buf + len - 6, "000000") != 0) {
- StringCpy (buf + len - 6, "000000");
- } else if (acclen == 13 && StringCmp (buf + len - 7, "0000000") != 0) {
- StringCpy (buf + len - 7, "0000000");
- } else if (acclen == 15 && StringCmp (buf + len - 8, "00000000") != 0) {
- StringCpy (buf + len - 8, "00000000");
- } else {
- buf [0] = '\0';
- }
- if (! StringHasNoText (buf)) {
- if ( GetWWW(ajp) ) {
- FFAddTextToString(ffstring, separator, "<a href=", link_wgs, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "db=Nucleotide&cmd=Search&term=", buf, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_TO_SPACES);
- } else {
- FFAddTextToString(ffstring, separator, buf, NULL, FALSE, FALSE, TILDE_TO_SPACES);
- }
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, 0, &dcontext);
- while (sdp != NULL) {
-
- extra_access = NULL;
-
- switch (dcontext.seqdesctype) {
- case Seq_descr_genbank :
- gbp = (GBBlockPtr) sdp->data.ptrvalue;
- if (gbp != NULL) {
- extra_access = gbp->extra_accessions;
- }
- break;
- case Seq_descr_embl :
- ebp = (EMBLBlockPtr) sdp->data.ptrvalue;
- if (ebp != NULL) {
- extra_access = ebp->extra_acc;
- }
- break;
- default :
- break;
- }
-
- if (extra_access != NULL) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- }
-
- for (vnp = extra_access; vnp != NULL; vnp = vnp->next) {
- xtra = (CharPtr) vnp->data.ptrvalue;
- if (ValidateAccn (xtra) == 0) {
- FFAddTextToString(ffstring, separator, xtra, NULL, FALSE, FALSE, TILDE_TO_SPACES);
-
- /* optionally populate indexes for NCBI internal database */
-
- if (index != NULL) {
- ValNodeCopyStrToHead (&(index->secondaries), 0, xtra);
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (gbseq != NULL) {
- ValNodeCopyStr (&(gbseq->secondary_accessions), 0, xtra);
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, 0, &dcontext);
- }
- }
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "AC");
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddVersionBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- SeqIdPtr accn = NULL;
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Char buf [41];
- GBSeqPtr gbseq;
- Int4 gi = -1;
- IndxPtr index;
- CharPtr ptr;
- SeqIdPtr sip;
- Char tmp [41];
- Char version [64];
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
- asp = awp->asp;
- if (asp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- switch (sip->choice) {
- case SEQID_GI :
- gi = sip->data.intvalue;
- break;
- case SEQID_GENBANK :
- case SEQID_EMBL :
- case SEQID_DDBJ :
- case SEQID_OTHER :
- accn = sip;
- break;
- case SEQID_PIR :
- case SEQID_SWISSPROT :
- case SEQID_PRF :
- case SEQID_PDB :
- accn = sip;
- break;
- case SEQID_TPG :
- case SEQID_TPE :
- case SEQID_TPD :
- accn = sip;
- break;
- default :
- break;
- }
- }
-
- /* if (gi < 1 && accn == NULL) return; */
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
- if (gi < 1) return;
- }
-
- bbp = Asn2gbAddBlock (awp, VERSION_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- /* no longer displaying NID */
-
- /*
- if (gi > 0) {
- sprintf (version, "g%ld", (long) gi);
-
- gb_StartPrint (awp->format, needInitBuff, 0, 12, "NID", 13, 5, 5, "NI", TRUE);
- needInitBuff = FALSE;
-
- gb_AddString (NULL, version, NULL, FALSE, FALSE, TILDE_TO_SPACES);
-
- ff_EndPrint();
- needEndPrint = FALSE;
- }
- */
-
- version [0] = '\0';
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
- sprintf (version, "g%ld", (long) gi);
-
- FFStartPrint (ffstring, awp->format, 0, 12, "VERSION", 12, 5, 5, "NI", TRUE);
-
- FFAddOneString (ffstring, version, FALSE, FALSE, TILDE_TO_SPACES);
-
- FFAddOneChar(ffstring, '\n', FALSE);
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "NI");
- FFRecycleString(ajp, ffstring);
- return;
- }
-
- if (accn != NULL) {
-
- buf [0] = '\0';
- SeqIdWrite (accn, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
-
- if (gi > 0) {
- sprintf (version, "%s GI:%ld", buf, (long) gi);
- } else {
- sprintf (version, "%s", buf);
- }
-
- FFStartPrint (ffstring, awp->format, 0, 12, "VERSION", 12, 5, 5, "SV", TRUE);
-
- FFAddTextToString (ffstring, NULL, version, "\n", FALSE, FALSE, TILDE_TO_SPACES);
- /* optionally populate indexes for NCBI internal database */
-
- if (ajp->index) {
- index = &asp->index;
- } else {
- index = NULL;
- }
-
- if (index != NULL) {
- ptr = StringChr (buf, '.');
- if (ptr != NULL) {
- ptr++;
- index->version = StringSave (ptr);
- }
- if (gi > 0) {
- sprintf (tmp, "%ld", (long) gi);
- index->gi = StringSave (tmp);
- }
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- ptr = StringChr (buf, '.');
- if (ptr != NULL) {
- gbseq->accession_version = StringSave (buf);
- }
- }
-
- } else if (gi > 0) {
-
- FFStartPrint (ffstring, awp->format, 0, 0, "VERSION", 12, 5, 5, "SV", TRUE);
-
- sprintf (version, " GI:%ld", (long) gi);
-
- FFAddTextToString (ffstring, NULL, version, "\n", FALSE, FALSE, TILDE_TO_SPACES);
-
- } else {
-
- FFStartPrint (ffstring, awp->format, 0, 0, "VERSION", 0, 5, 5, "SV", TRUE);
- FFAddOneChar(ffstring, '\n', FALSE);
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "SV");
- }
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "SV");
- FFRecycleString(ajp, ffstring);
-}
-
-/* only displaying PID in GenPept format */
-
-static void AddPidBlock (Asn2gbWorkPtr awp)
-
-{
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Int4 gi = -1;
- SeqIdPtr sip;
- Char version [64];
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- switch (sip->choice) {
- case SEQID_GI :
- gi = sip->data.intvalue;
- break;
- default :
- break;
- }
- }
-
- if (gi < 1) return;
-
- bbp = Asn2gbAddBlock (awp, PID_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- FFStartPrint (ffstring, awp->format, 0, 12, "PID", 12, 5, 5, NULL, TRUE);
-
- sprintf (version, "g%ld", (long) gi);
- FFAddOneString (ffstring, version, FALSE, FALSE, TILDE_TO_SPACES);
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, NULL);
- FFRecycleString(ajp, ffstring);
-}
-
-static Uint1 dbsource_fasta_order [NUM_SEQID] = {
- 33, /* 0 = not set */
- 20, /* 1 = local Object-id */
- 15, /* 2 = gibbsq */
- 16, /* 3 = gibbmt */
- 30, /* 4 = giim Giimport-id */
- 10, /* 5 = genbank */
- 10, /* 6 = embl */
- 10, /* 7 = pir */
- 10, /* 8 = swissprot */
- 15, /* 9 = patent */
- 18, /* 10 = other TextSeqId */
- 20, /* 11 = general Dbtag */
- 31, /* 12 = gi */
- 10, /* 13 = ddbj */
- 10, /* 14 = prf */
- 12, /* 15 = pdb */
- 10, /* 16 = tpg */
- 10, /* 17 = tpe */
- 10 /* 18 = tpd */
-};
-
-static void AddToUniqueSipList (
- ValNodePtr PNTR list,
- SeqIdPtr sip
-)
-
-{
- ValNodePtr vnp;
-
- if (list == NULL || sip == NULL) return;
- for (vnp = *list; vnp != NULL; vnp = vnp->next) {
- if (SeqIdMatch (sip, (SeqIdPtr) vnp->data.ptrvalue)) return;
- }
- ValNodeAddPointer (list, 0, (Pointer) sip);
-}
-
-static Boolean WriteDbsourceID (
- SeqIdPtr sip,
- CharPtr str
-)
-
-{
- DbtagPtr db;
- CharPtr dt;
- Int4 gi;
- ObjectIdPtr oip;
- CharPtr pfx;
- PDBSeqIdPtr psip = NULL;
- CharPtr prefix;
- Boolean rsult = FALSE;
- CharPtr sfx;
- CharPtr suffix;
- Char tmp [32];
- TextSeqIdPtr tsip = NULL;
-
- if (sip == NULL || str == NULL) return FALSE;
- *str = '\0';
- switch (sip->choice) {
- case SEQID_LOCAL :
- oip = (ObjectIdPtr) sip->data.ptrvalue;
- if (oip == NULL) return FALSE;
- if (! StringHasNoText (oip->str)) {
- StringCat (str, oip->str);
- return TRUE;
- } else if (oip->id > 0) {
- sprintf (tmp, "%ld", (long) oip->id);
- StringCat (str, tmp);
- return TRUE;
- }
- return FALSE;
- case SEQID_GI :
- gi = (Int4) sip->data.intvalue;
- if (gi == 0) return FALSE;
- sprintf (tmp, "gi: %ld", (long) gi);
- StringCat (str, tmp);
- return TRUE;
- case SEQID_GENERAL :
- db = (DbtagPtr) sip->data.ptrvalue;
- if (db == NULL) return FALSE;
- /* !!! still need to implement this !!! */
- return FALSE;
- case SEQID_GENBANK :
- case SEQID_EMBL :
- case SEQID_DDBJ :
- case SEQID_OTHER :
- case SEQID_PIR :
- case SEQID_SWISSPROT :
- case SEQID_PRF :
- case SEQID_TPG :
- case SEQID_TPE :
- case SEQID_TPD :
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip == NULL) return FALSE;
- break;
- case SEQID_PDB :
- psip = (PDBSeqIdPtr) sip->data.ptrvalue;
- if (psip == NULL) return FALSE;
- break;
- default :
- break;
- }
- prefix = " ";
- suffix = NULL;
- switch (sip->choice) {
- case SEQID_EMBL :
- StringCat (str, "embl ");
- suffix = ",";
- break;
- case SEQID_OTHER :
- StringCat (str, "REFSEQ: ");
- break;
- case SEQID_SWISSPROT :
- StringCat (str, "swissprot: ");
- suffix = ",";
- break;
- case SEQID_PIR :
- StringCat (str, "pir: ");
- break;
- case SEQID_PRF :
- StringCat (str, "prf: ");
- break;
- case SEQID_PDB :
- StringCat (str, "pdb: ");
- suffix = ",";
- break;
- default :
- break;
- }
- pfx = NULL;
- sfx = NULL;
- if (tsip != NULL) {
- if (! StringHasNoText (tsip->name)) {
- StringCat (str, sfx);
- StringCat (str, pfx);
- StringCat (str, "locus ");
- StringCat (str, tsip->name);
- sfx = suffix;
- pfx = prefix;
- rsult = TRUE;
- }
- if (! StringHasNoText (tsip->accession)) {
- StringCat (str, sfx);
- StringCat (str, pfx);
- StringCat (str, "accession ");
- StringCat (str, tsip->accession);
- sfx = suffix;
- pfx = prefix;
- rsult = TRUE;
- }
- if (tsip->version > 0) {
- sprintf (tmp, ".%d", (int) tsip->version);
- StringCat (str, tmp);
- sfx = suffix;
- pfx = prefix;
- }
- if (! StringHasNoText (tsip->release)) {
- StringCat (str, pfx);
- StringCat (str, "release ");
- StringCat (str, tsip->release);
- sfx = suffix;
- pfx = prefix;
- }
- if (sip->choice == SEQID_SWISSPROT || sip->choice == SEQID_PIR || sip->choice == SEQID_PRF) {
- StringCat (str, ";");
- }
- return rsult;
- }
- if (psip != NULL) {
- if (! StringHasNoText (psip->mol)) {
- StringCat (str, "molecule ");
- StringCat (str, psip->mol);
- sfx = suffix;
- pfx = prefix;
- rsult = TRUE;
- }
- if (psip->chain > 0) {
- StringCat (str, sfx);
- StringCat (str, pfx);
- sprintf (tmp, "chain %d", (int) psip->chain);
- StringCat (str, tmp);
- sfx = suffix;
- pfx = prefix;
- rsult = TRUE;
- }
- if (psip->rel != NULL) {
- StringCat (str, sfx);
- StringCat (str, pfx);
- StringCat (str, "release ");
- dt = asn2gb_PrintDate (psip->rel);
- StringCat (str, dt);
- MemFree (dt);
- sfx = suffix;
- pfx = prefix;
- rsult = TRUE;
- }
- StringCat (str, ";");
- return rsult;
- }
- return rsult;
-}
-
-
-static void AddSPBlock (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- BioseqPtr bsp
-)
-
-{
- CharPtr acc;
- DbtagPtr db;
- SeqMgrDescContext dcontext;
- Boolean first;
- Boolean has_link;
- Char id [41];
- ObjectIdPtr oip;
- SeqDescrPtr sdp;
- SeqIdPtr sid;
- SPBlockPtr spb;
- CharPtr string;
- ValNodePtr vnp;
- CharPtr str;
- Char numbuf[40];
-
- if (bsp == NULL) return;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_sp, &dcontext);
- if (sdp == NULL) return;
- spb = (SPBlockPtr) sdp->data.ptrvalue;
- if (spb == NULL) return;
-
- if (spb->_class == 1) {
- FFAddOneString (ffstring, "class: standard.", FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- } else if (spb->_class == 2) {
- FFAddOneString (ffstring, "class: preliminary.", FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- }
-
- if (spb->extra_acc) {
- FFAddOneString (ffstring, "extra accessions:", FALSE, FALSE, TILDE_IGNORE);
- for (vnp = spb->extra_acc; vnp != NULL; vnp = vnp->next) {
- FFAddOneString (ffstring, (CharPtr) vnp->data.ptrvalue, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar (ffstring, ',', FALSE );
- }
- }
-
- if (spb->imeth) {
- FFAddOneString (ffstring, "seq starts with Met", FALSE, FALSE, TILDE_IGNORE);
- }
-
- if (spb->plasnm != NULL) {
- FFAddOneString (ffstring, "plasmid:", FALSE, FALSE, TILDE_IGNORE);
- for (vnp = spb->plasnm; vnp != NULL; vnp = vnp->next) {
- FFAddOneString (ffstring, (CharPtr) vnp->data.ptrvalue, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar (ffstring, ',', FALSE );
- }
- }
-
- if (spb->created) {
- string = PrintDate (spb->created);
- FFAddOneString (ffstring, "created: ", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, string, FALSE, FALSE, TILDE_IGNORE);
-
- MemFree (string);
- }
-
- if (spb->sequpd) {
- string = PrintDate (spb->sequpd);
- FFAddOneString (ffstring, "sequence updated: ", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, string, FALSE, FALSE, TILDE_IGNORE);
- MemFree (string);
- }
-
- if (spb->annotupd) {
- string = PrintDate (spb->annotupd);
- FFAddOneString (ffstring, "annotation updated: ", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, string, FALSE, FALSE, TILDE_IGNORE);
- MemFree (string);
- }
-
- if (spb->seqref) {
- FFAddOneString (ffstring, "xrefs: ", FALSE, FALSE, TILDE_IGNORE);
- first = TRUE;
- for (sid = spb->seqref; sid != NULL; sid = sid->next) {
- acc = NULL;
- has_link = FALSE;
- if (first == FALSE) {
- FFAddOneString (ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
- }
- first = FALSE;
- SeqIdWrite (sid, id, PRINTID_TEXTID_ACC_VER, sizeof (id) - 1);
- if (sid->choice == SEQID_GI) {
- has_link = TRUE;
- }
- acc = id;
- if (acc != NULL) {
- switch (sid->choice) {
- case SEQID_GENBANK:
- FFAddOneString (ffstring, "genbank accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_EMBL:
- FFAddOneString (ffstring, "embl accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_PIR:
- FFAddOneString (ffstring, "pir locus ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_SWISSPROT:
- FFAddOneString (ffstring, "swissprot accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_DDBJ:
- FFAddOneString (ffstring, "ddbj accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_PRF:
- FFAddOneString (ffstring, "prf accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_PDB:
- FFAddOneString (ffstring, "pdb accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_GI:
- FFAddOneString (ffstring, "gi: ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_TPG:
- FFAddOneString (ffstring, "genbank third party accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_TPE:
- FFAddOneString (ffstring, "embl third party accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_TPD:
- FFAddOneString (ffstring, "ddbj third party accession ", FALSE, FALSE, TILDE_IGNORE);
- break;
- default:
- acc = NULL;
- break;
- }
- }
- if (acc != NULL) {
- if ( GetWWW(ajp) && has_link ) {
- sprintf(numbuf, "%ld", (long) sid->data.intvalue);
- FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "val=", numbuf, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, acc, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, acc, FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
- }
-
- first = TRUE;
- for (vnp = spb->dbref; vnp != NULL; vnp = vnp->next) {
- db = (DbtagPtr) vnp->data.ptrvalue;
- if (db == NULL) continue;
- oip = db->tag;
- if (oip == NULL) continue;
- has_link = FALSE;
- if (first) {
- FFAddNewLine(ffstring);
- FFAddOneString (ffstring, "xrefs (non-sequence databases): ", FALSE, FALSE, TILDE_IGNORE);
- first = FALSE;
- } else {
- FFAddOneString (ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, db->db, FALSE, FALSE, TILDE_IGNORE);
- if (StringCmp (db->db, "MIM") == 0) {
- has_link = TRUE;
- }
-
- if ( oip->str != NULL ) {
- str = oip->str;
- } else if ( oip->id > 0 ) {
- sprintf(numbuf, "%d", oip->id);
- str = numbuf;
- }
-
- if ( !StringHasNoText(str) ) {
- if ( GetWWW(ajp) && has_link) {
- FFAddOneChar (ffstring, ' ', FALSE);
- FFAddTextToString(ffstring, "<a href=", link_omim, str, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, ">", str, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
-}
-
-static void AddPIRBlock (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- BioseqPtr bsp
-)
-
-{
- CharPtr acc;
- SeqMgrDescContext dcontext;
- Boolean first;
- Char id [41];
- CharPtr prefix = NULL;
- SeqDescrPtr sdp;
- SeqIdPtr sid;
- PirBlockPtr pbp;
-
- if (bsp == NULL) return;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_pir, &dcontext);
- if (sdp == NULL) return;
- pbp = (PirBlockPtr) sdp->data.ptrvalue;
- if (pbp == NULL) return;
-
- if (pbp->host != NULL) {
- FFAddTextToString (ffstring, "host:", pbp->host, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->source != NULL) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "source: ", pbp->source, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->summary != NULL) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "summary: ", pbp->summary, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->genetic != NULL) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "genetic: ", pbp->genetic, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->includes != NULL) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "includes: ", pbp->includes, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->placement != NULL) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "placement: ", pbp->placement, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->superfamily != NULL) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "superfamily: ", pbp->superfamily, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->cross_reference != NULL) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "xref: ", pbp->cross_reference, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->date != NULL) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString (ffstring, "PIR dates: ", pbp->date, "\n", FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->had_punct) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddOneString (ffstring, "punctuation in sequence", FALSE, FALSE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (pbp->seqref) {
- FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddOneString (ffstring, "xrefs: ", FALSE, FALSE, TILDE_IGNORE);
- first = TRUE;
- for (sid = pbp->seqref; sid != NULL; sid = sid->next) {
- acc = NULL;
- if (first == FALSE) {
- FFAddOneString (ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
- }
- first = FALSE;
- SeqIdWrite (sid, id, PRINTID_TEXTID_ACC_VER, sizeof (id) - 1);
- acc = id;
- if (acc != NULL) {
- switch (sid->choice) {
- case SEQID_GENBANK:
- FFAddOneString (ffstring, "genbank ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_EMBL:
- FFAddOneString (ffstring, "embl ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_PIR:
- FFAddOneString (ffstring, "pir ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_SWISSPROT:
- FFAddOneString (ffstring, "swissprot ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_DDBJ:
- FFAddOneString (ffstring, "ddbj ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_PRF:
- FFAddOneString (ffstring, "prf ", FALSE, FALSE, TILDE_IGNORE);
- break;
- case SEQID_GI:
- FFAddOneString (ffstring, "gi: ", FALSE, FALSE, TILDE_IGNORE);
- break;
- default:
- acc = NULL;
- break;
- }
- }
- if (acc != NULL) {
- FFAddOneString (ffstring, acc, FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
- FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_IGNORE);
-}
-
-static void AddPRFBlock (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- BioseqPtr bsp
-)
-
-{
- SeqMgrDescContext dcontext;
- PrfExtSrcPtr extra;
- CharPtr prefix = NULL;
- SeqDescrPtr sdp;
- PrfBlockPtr prf;
-
- if (bsp == NULL) return;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_prf, &dcontext);
- if (sdp == NULL) return;
- prf = (PrfBlockPtr) sdp->data.ptrvalue;
- if (prf == NULL) return;
- if ( ffstring == NULL ) return;
-
- extra = prf->extra_src;
- if (extra != NULL) {
-
- if (extra->host != NULL) {
- FFAddTextToString(ffstring, "host:", extra->host, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- if (extra->part != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "part: ", extra->part, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
- if (extra->state != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "state: ", extra->state, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
- if (extra->strain != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "strain: ", extra->strain, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
- if (extra->taxon != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "taxonomy: ", extra->taxon, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
-
- FFAddOneChar(ffstring, '.', FALSE);
- }
-}
-
-static void AddPDBBlock (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- BioseqPtr bsp
-)
-
-{
- SeqMgrDescContext dcontext;
- CharPtr dt;
- CharPtr prefix = NULL;
- SeqDescrPtr sdp;
- PdbBlockPtr pdb;
- PdbRepPtr replace;
- CharPtr str;
- ValNodePtr vnp;
-
- if (bsp == NULL) return;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_pdb, &dcontext);
- if (sdp == NULL) return;
- pdb = (PdbBlockPtr) sdp->data.ptrvalue;
- if (pdb == NULL) return;
-
- if (pdb->deposition != NULL) {
- dt = asn2gb_PrintDate (pdb->deposition);
- FFAddTextToString (ffstring, "deposition: ", dt, NULL, FALSE, TRUE, TILDE_IGNORE);
- MemFree (dt);
- prefix = ";";
- }
- if (pdb->pdbclass != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "class: ", pdb->pdbclass, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
- if (pdb->source != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddOneString(ffstring, "source: ", FALSE, TRUE, TILDE_IGNORE);
- prefix = NULL;
- for (vnp = pdb->source; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (StringHasNoText (str)) continue;
- FFAddTextToString (ffstring, prefix, str, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ", ";
- }
- prefix = ";";
- }
- if (pdb->exp_method != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddTextToString(ffstring, "Exp. method: ", pdb->exp_method, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ";";
- }
- replace = pdb->replace;
- if (replace != NULL) {
- if (replace->ids != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
- FFAddOneString(ffstring, "ids replaced: ", FALSE, TRUE, TILDE_IGNORE);
-
- prefix = NULL;
- for (vnp = replace->ids; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (StringHasNoText (str)) continue;
- FFAddTextToString (ffstring, prefix, str, NULL, FALSE, TRUE, TILDE_IGNORE);
- prefix = ", ";
- }
- prefix = ";";
- }
- if (replace->date != NULL) {
- FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
- FFAddNewLine(ffstring);
-
- dt = asn2gb_PrintDate (replace->date);
- FFAddTextToString(ffstring, "replacement date: ", dt, NULL, FALSE, TRUE, TILDE_IGNORE);
- MemFree (dt);
- prefix = ";";
- }
- }
-
- FFAddOneChar(ffstring, '.', FALSE);
-}
-
-static void AddDbsourceBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Char buf [256];
- SeqFeatPtr cds;
- DbtagPtr db;
- GBSeqPtr gbseq;
- SeqIdPtr id;
- ValNodePtr list = NULL;
- BioseqPtr nuc;
- SeqIdPtr sip;
- SeqLocPtr slp;
- CharPtr str;
- Boolean unknown = TRUE;
- ValNodePtr vnp;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- asp = awp->asp;
- if (asp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, DBSOURCE_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- FFStartPrint (ffstring, awp->format, 0, 12, "DBSOURCE", 12, 5, 5, NULL, TRUE);
-
- sip = SeqIdSelect (bsp->id, dbsource_fasta_order, NUM_SEQID);
-
- if (sip != NULL) {
-
- switch (sip->choice) {
- case SEQID_PIR :
- case SEQID_SWISSPROT :
- case SEQID_PRF :
- case SEQID_PDB :
- if (WriteDbsourceID (sip, buf)) {
- FF_www_dbsource (ajp, ffstring, buf, TRUE, sip->choice);
- FFAddNewLine(ffstring);
- unknown = FALSE;
- }
- break;
- case SEQID_GENERAL :
- db = sip->data.ptrvalue;
- if (db == NULL) {
- break;
- }
- if (StringNCmp (db->db, "PIDe", 4) != 0 &&
- StringNCmp (db->db, "PIDd", 4) != 0 &&
- StringNCmp (db->db, "PID", 3) != 0) {
- break;
- }
- /* if (ChoicePID) found, continue on to next set of cases */
- case SEQID_EMBL :
- case SEQID_GENBANK :
- case SEQID_DDBJ :
- case SEQID_GIBBSQ :
- case SEQID_GIBBMT :
- case SEQID_OTHER :
- case SEQID_TPG :
- case SEQID_TPE :
- case SEQID_TPD :
- case SEQID_GI :
- case SEQID_GIIM :
- cds = SeqMgrGetCDSgivenProduct (bsp, NULL);
- if (cds == NULL) {
- /* now may also be protein product of mature peptide feature */
- cds = SeqMgrGetPROTgivenProduct (bsp, NULL);
- }
- if (cds != NULL) {
- nuc = BioseqFindFromSeqLoc (cds->location);
- if (nuc != NULL) {
- slp = SeqLocFindNext (cds->location, NULL);
- while (slp != NULL) {
- sip = SeqLocId (slp);
- AddToUniqueSipList (&list, sip);
- slp = SeqLocFindNext (cds->location, slp);
- }
- for (vnp = list; vnp != NULL; vnp = vnp->next) {
- id = (SeqIdPtr) vnp->data.ptrvalue;
- nuc = BioseqFindCore (id);
- sip = NULL;
- if (nuc != NULL) {
- sip = SeqIdSelect (nuc->id, dbsource_fasta_order, NUM_SEQID);
- } else if (id != NULL && id->choice == SEQID_GI) {
- sip = GetSeqIdForGI (id->data.intvalue);
- }
- if (sip == NULL) {
- sip = id;
- }
- if (sip != NULL) {
- if (WriteDbsourceID (sip, buf)) {
- FF_www_dbsource (ajp, ffstring, buf, TRUE, sip->choice);
- FFAddNewLine(ffstring);
- unknown = FALSE;
- }
- }
- }
- ValNodeFree (list);
- }
- } else {
- if (WriteDbsourceID (sip, buf)) {
- FF_www_dbsource (ajp, ffstring, buf, TRUE, sip->choice);
- FFAddNewLine(ffstring);
- unknown = FALSE;
- }
- }
- break;
- default :
- break;
- }
-
- switch (sip->choice) {
- case SEQID_PIR :
- AddPIRBlock (ajp, ffstring, bsp);
- break;
- case SEQID_SWISSPROT :
- AddSPBlock (ajp, ffstring, bsp);
- break;
- case SEQID_PRF :
- AddPRFBlock (ajp, ffstring, bsp);
- break;
- case SEQID_PDB :
- AddPDBBlock (ajp, ffstring, bsp);
- break;
- default :
- break;
- }
- }
-
- if (unknown) {
- FFAddOneString (ffstring, "UNKNOWN", FALSE, FALSE, TILDE_TO_SPACES);
- }
-
- str = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, NULL);
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- if (StringNCmp (str, "DBSOURCE ", 12) == 0) {
- gbseq->source_db = StringSave (str + 12);
- } else {
- gbseq->source_db = StringSave (str);
- }
- CleanQualValue (gbseq->source_db);
- Asn2gnbkCompressSpaces (gbseq->source_db);
- }
-
- bbp->string = str;
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddDateBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Char date [40];
- SeqMgrDescContext dcontext;
- DatePtr dp;
- SeqDescrPtr sdp;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- bbp = Asn2gbAddBlock (awp, DATE_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- date [0] = '\0';
-
- dp = NULL;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_create_date, &dcontext);
- if (sdp != NULL) {
- dp = (DatePtr) sdp->data.ptrvalue;
- }
- if (dp != NULL) {
- DateToGB (date, dp, FALSE);
- }
- if (StringHasNoText (date)) {
- StringCpy (date, "01-JAN-1900");
- }
-
- FFStartPrint (ffstring, awp->format, 0, 0, NULL, 0, 5, 5, "DT", TRUE);
- FFAddOneString (ffstring, date, FALSE, FALSE, TILDE_IGNORE);
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 0, 0, 5, 5, "DT");
- FFRecycleString(ajp, ffstring);
-
- bbp = Asn2gbAddBlock (awp, DATE_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- ffstring = FFGetString(ajp);
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_update_date, &dcontext);
- if (sdp != NULL) {
- dp = (DatePtr) sdp->data.ptrvalue;
- }
- if (dp != NULL) {
- DateToGB (date, dp, FALSE);
- }
-
- FFStartPrint (ffstring, awp->format, 0, 0, NULL, 0, 5, 5, "DT", FALSE);
- FFAddOneString (ffstring, date, FALSE, FALSE, TILDE_IGNORE);
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 0, 0, 5, 5, "DT");
- FFRecycleString(ajp, ffstring);
-}
-
-
-#define TOTAL_ESTKW 11
-#define TOTAL_STSKW 5
-#define TOTAL_GSSKW 2
-
-static CharPtr EST_kw_array[ TOTAL_ESTKW] = {
- "EST", "EST PROTO((expressed sequence tag)", "expressed sequence tag",
- "EST (expressed sequence tag)", "EST(expressed sequence tag)",
- "partial cDNA sequence", "transcribed sequence fragment", "TSR",
- "putatively transcribed partial sequence", "UK putts"
-};
-
-static CharPtr GSS_kw_array [TOTAL_GSSKW] = {
- "GSS", "trapped exon"
-};
-static CharPtr STS_kw_array[TOTAL_STSKW] = {
- "STS", "STS(sequence tagged site)", "STS (sequence tagged site)",
- "STS sequence", "sequence tagged site"
-};
-
-static Int2 MatchArrayString (
- CharPtr array_string [],
- Int2 totalstr,
- CharPtr text
-)
-
-{
- Int2 i;
-
- for (i = 0; i < totalstr && text != NULL; i++) {
- if (StringCmp (array_string [i], text) == 0) {
- return (i);
- }
- }
-
- return (-1);
-}
-
-static Boolean CheckSpecialKeyword (
- Boolean is_est,
- Boolean is_sts,
- Boolean is_gss,
- CharPtr kwd
-)
-
-{
- if (kwd == NULL) return FALSE;
-
- if (is_est) {
- if (MatchArrayString (STS_kw_array, TOTAL_STSKW, kwd) != -1) return FALSE;
- if (MatchArrayString (GSS_kw_array, TOTAL_GSSKW, kwd) != -1) return FALSE;
- }
-
- if (is_sts) {
- if (MatchArrayString (EST_kw_array, TOTAL_ESTKW, kwd) != -1) return FALSE;
- if (MatchArrayString (GSS_kw_array, TOTAL_GSSKW, kwd) != -1) return FALSE;
- }
-
- if (is_gss) {
- if (MatchArrayString (STS_kw_array, TOTAL_STSKW, kwd) != -1) return FALSE;
- if (MatchArrayString (EST_kw_array, TOTAL_ESTKW, kwd) != -1) return FALSE;
- }
-
- return TRUE;
-}
-
-static Boolean KeywordAlreadyInList (
- ValNodePtr head,
- CharPtr kwd
-)
-
-{
- ValNodePtr vnp;
-
- for (vnp = head; vnp != NULL; vnp = vnp->next) {
- if (StringICmp ((CharPtr) vnp->data.ptrvalue, kwd) == 0) return TRUE;
- }
-
- return FALSE;
-}
-
-
-static void AddKeywordsBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- SeqMgrDescContext dcontext;
- EMBLBlockPtr ebp;
- GBBlockPtr gbp;
- GBSeqPtr gbseq;
- ValNodePtr head = NULL;
- IndxPtr index;
- Boolean is_est = FALSE;
- Boolean is_gss = FALSE;
- Boolean is_sts = FALSE;
- ValNodePtr keywords;
- CharPtr kwd;
- MolInfoPtr mip;
- PirBlockPtr pir;
- PrfBlockPtr prf;
- SeqDescrPtr sdp;
- SeqIdPtr sip;
- SPBlockPtr sp;
- CharPtr str;
- ValNodePtr vnp;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
- asp = awp->asp;
- if (asp == NULL) return;
-
- bbp = (BaseBlockPtr) Asn2gbAddBlock (awp, KEYWORDS_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_TPG || sip->choice == SEQID_TPE || sip->choice == SEQID_TPD) {
- ValNodeCopyStr (&head, 0, "Third Party Annotation");
- ValNodeCopyStr (&head, 0, "; ");
- ValNodeCopyStr (&head, 0, "TPA");
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp != NULL) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
-
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip != NULL) {
- switch (mip->tech) {
- case MI_TECH_htgs_1 :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- ValNodeCopyStr (&head, 0, "HTG");
- ValNodeCopyStr (&head, 0, "; ");
- ValNodeCopyStr (&head, 0, "HTGS_PHASE1");
- break;
- case MI_TECH_htgs_2 :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- ValNodeCopyStr (&head, 0, "HTG");
- ValNodeCopyStr (&head, 0, "; ");
- ValNodeCopyStr (&head, 0, "HTGS_PHASE2");
- break;
- case MI_TECH_htgs_3 :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- ValNodeCopyStr (&head, 0, "HTG");
- break;
- case MI_TECH_est :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- is_est = TRUE;
- ValNodeCopyStr (&head, 0, "EST");
- break;
- case MI_TECH_sts :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- is_sts = TRUE;
- ValNodeCopyStr (&head, 0, "STS");
- break;
- case MI_TECH_survey :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- is_gss = TRUE;
- ValNodeCopyStr (&head, 0, "GSS");
- break;
- case MI_TECH_fli_cdna :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- ValNodeCopyStr (&head, 0, "FLI_CDNA");
- break;
- case MI_TECH_htgs_0 :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- ValNodeCopyStr (&head, 0, "HTG");
- ValNodeCopyStr (&head, 0, "; ");
- ValNodeCopyStr (&head, 0, "HTGS_PHASE0");
- break;
- case MI_TECH_htc :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- ValNodeCopyStr (&head, 0, "HTC");
- break;
- case MI_TECH_wgs :
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- ValNodeCopyStr (&head, 0, "WGS");
- break;
- default :
- break;
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, 0, &dcontext);
- while (sdp != NULL) {
-
- keywords = NULL;
-
- switch (dcontext.seqdesctype) {
- case Seq_descr_genbank :
- gbp = (GBBlockPtr) sdp->data.ptrvalue;
- if (gbp != NULL) {
- keywords = gbp->keywords;
- }
- break;
- case Seq_descr_embl :
- ebp = (EMBLBlockPtr) sdp->data.ptrvalue;
- if (ebp != NULL) {
- keywords = ebp->keywords;
- }
- break;
- case Seq_descr_pir :
- pir = (PirBlockPtr) sdp->data.ptrvalue;
- if (pir != NULL) {
- keywords = pir->keywords;
- }
- break;
- case Seq_descr_prf :
- prf = (PrfBlockPtr) sdp->data.ptrvalue;
- if (prf != NULL) {
- keywords = prf->keywords;
- }
- break;
- case Seq_descr_sp :
- sp = (SPBlockPtr) sdp->data.ptrvalue;
- if (sp != NULL) {
- keywords = sp->keywords;
- }
- break;
- default :
- break;
- }
-
- if (keywords != NULL) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- }
-
- for (vnp = keywords; vnp != NULL; vnp = vnp->next) {
- kwd = (CharPtr) vnp->data.ptrvalue;
- if (CheckSpecialKeyword (is_est, is_sts, is_gss, kwd)) {
- if (! KeywordAlreadyInList (head, kwd)) {
- if (head != NULL) {
- ValNodeCopyStr (&head, 0, "; ");
- }
- ValNodeCopyStr (&head, 0, kwd);
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, 0, &dcontext);
- }
-
- FFStartPrint( ffstring, awp->format, 0, 12, "KEYWORDS", 12, 5, 5, "KW", TRUE);
- str = MergeValNodeStrings (head);
-
- /* if no keywords were found, period will still be added by this call */
- if ( str != NULL ) {
- FFAddOneString (ffstring, str, TRUE, FALSE, TILDE_TO_SPACES);
- } else {
- FFAddOneChar(ffstring, '.', FALSE);
- }
-
- MemFree (str);
-
- /* optionally populate indexes for NCBI internal database */
-
- if (ajp->index) {
- index = &asp->index;
- } else {
- index = NULL;
- }
-
- if (index != NULL) {
- for (vnp = head; vnp != NULL; vnp = vnp->next) {
- kwd = (CharPtr) vnp->data.ptrvalue;
- if (StringCmp (kwd, "; ") == 0) continue;
- ValNodeCopyStrToHead (&(index->keywords), 0, kwd);
- }
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- for (vnp = head; vnp != NULL; vnp = vnp->next) {
- kwd = (CharPtr) vnp->data.ptrvalue;
- if (StringCmp (kwd, "; ") == 0) continue;
- ValNodeCopyStr (&(gbseq->keywords), 0, kwd);
- }
- }
-
- ValNodeFreeData (head);
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "KW");
-
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddSegmentBlock (
- Asn2gbWorkPtr awp,
- Boolean onePartOfSeg
-)
-
-{
- Char acc [41];
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BaseBlockPtr bbp;
- Char buf [32];
- GBSeqPtr gbseq;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- asp = awp->asp;
- if (asp == NULL) return;
-
- if (awp->seg < 1 || awp->numsegs < 1) return;
-
- bbp = Asn2gbAddBlock (awp, SEGMENT_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
-
- FFStartPrint (ffstring, awp->format, 0, 12, "SEGMENT", 12, 5, 5, "XX", FALSE);
-
- if ( GetWWW(ajp) && awp->parent != NULL && onePartOfSeg) {
- sprintf (buf, "%d of ", (int) awp->seg);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
- SeqIdWrite (awp->parent->id, acc, PRINTID_TEXTID_ACC_VER, sizeof (acc) - 1);
-
- FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "val=", acc, ">", FALSE, FALSE, TILDE_IGNORE);
-
- sprintf (buf, "%ld", (long) awp->numsegs);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- sprintf (buf, "%d of %ld", (int) awp->seg, (long) awp->numsegs);
- FFAddOneString (ffstring, buf, FALSE, TRUE, TILDE_TO_SPACES);
- }
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- sprintf (buf, "%d of %ld", (int) awp->seg, (long) awp->numsegs);
- gbseq->segment = StringSave (buf);
- }
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "XX");
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddSourceBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- SeqFeatPtr cds;
- SeqMgrDescContext dcontext;
- BioseqPtr dna;
- SeqMgrFeatContext fcontext;
- GBBlockPtr gbp;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, SOURCE_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
- if (sdp != NULL && (! ajp->newSourceOrg)) {
- gbp = (GBBlockPtr) sdp->data.ptrvalue;
- if (gbp != NULL && (! StringHasNoText (gbp->source))) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- return;
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
- if (sdp != NULL) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- } else {
- sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_BIOSRC, 0, &fcontext);
- if (sfp != NULL) {
- bbp->entityID = fcontext.entityID;
- bbp->itemID = fcontext.itemID;
- bbp->itemtype = OBJ_SEQFEAT;
- } else if (ISA_aa (bsp->mol)) {
-
- /* if protein with no sources, get sources applicable to DNA location of CDS */
-
- cds = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
- if (cds != NULL) {
- sfp = SeqMgrGetOverlappingSource (cds->location, &fcontext);
- if (sfp != NULL) {
- bbp->entityID = fcontext.entityID;
- bbp->itemID = fcontext.itemID;
- bbp->itemtype = OBJ_SEQFEAT;
- } else {
- dna = BioseqFindFromSeqLoc (cds->location);
- if (dna != NULL) {
- sdp = SeqMgrGetNextDescriptor (dna, NULL, Seq_descr_source, &dcontext);
- if (sdp != NULL) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- }
- }
- }
- }
- }
- }
-}
-
-static void AddOrganismBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- SeqFeatPtr cds;
- SeqMgrDescContext dcontext;
- BioseqPtr dna;
- SeqMgrFeatContext fcontext;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp;
-
- if (awp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, ORGANISM_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
- if (sdp != NULL) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- } else {
- sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_BIOSRC, 0, &fcontext);
- if (sfp != NULL) {
- bbp->entityID = fcontext.entityID;
- bbp->itemID = fcontext.itemID;
- bbp->itemtype = OBJ_SEQFEAT;
- } else if (ISA_aa (bsp->mol)) {
-
- /* if protein with no sources, get sources applicable to DNA location of CDS */
-
- cds = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
- if (cds != NULL) {
- sfp = SeqMgrGetOverlappingSource (cds->location, &fcontext);
- if (sfp != NULL) {
- bbp->entityID = fcontext.entityID;
- bbp->itemID = fcontext.itemID;
- bbp->itemtype = OBJ_SEQFEAT;
- } else {
- dna = BioseqFindFromSeqLoc (cds->location);
- if (dna != NULL) {
- sdp = SeqMgrGetNextDescriptor (dna, NULL, Seq_descr_source, &dcontext);
- if (sdp != NULL) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- }
- }
- }
- }
- }
- }
-}
-
-static RefBlockPtr AddPub (
- Asn2gbWorkPtr awp,
- ValNodePtr PNTR head,
- PubdescPtr pdp
-)
-
-{
- Char buf [521]; /* increased for consortium in citsub */
- CitArtPtr cap;
- CitBookPtr cbp;
- CitGenPtr cgp;
- CitJourPtr cjp;
- CitPatPtr cpp;
- CitSubPtr csp;
- DatePtr dp = NULL;
- Boolean justuids = TRUE;
- ImprintPtr imp = NULL;
- IntRefBlockPtr irp;
- RefBlockPtr rbp;
- ValNodePtr vnp;
-
- if (awp == NULL || head == NULL || pdp == NULL) return NULL;
-
- if (awp->hideGeneRIFs) {
- if (StringNICmp (pdp->comment, "GeneRIF", 7) == 0) return NULL;
- } else if (awp->onlyGeneRIFs || awp->latestGeneRIFs) {
- if (StringNICmp (pdp->comment, "GeneRIF", 7) != 0) return NULL;
- }
-
- rbp = (RefBlockPtr) MemNew (sizeof (IntRefBlock));
- if (rbp == NULL) return NULL;
- rbp->blocktype = REFERENCE_BLOCK;
- rbp->section = awp->currsection;
-
- rbp->serial = INT2_MAX;
-
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- switch (vnp->choice) {
- case PUB_Gen :
- /* may be unpublished, or may be serial number of swiss-prot reference */
- cgp = (CitGenPtr) vnp->data.ptrvalue;
- if (cgp != NULL) {
- if (StringNICmp ("BackBone id_pub", cgp->cit, 15) != 0) {
- rbp->category = REF_CAT_UNP;
- dp = cgp->date;
- if (cgp->serial_number > 0) {
- rbp->serial = cgp->serial_number;
- }
- if (cgp->cit != NULL) {
- if (StringNICmp ("unpublished", cgp->cit, 11) != 0 &&
- StringNICmp ("submitted", cgp->cit, 8) != 0 &&
- StringNICmp ("to be published", cgp->cit, 15) != 0 &&
- StringNICmp ("in press", cgp->cit, 8) != 0 &&
- StringStr (cgp->cit, "Journal") == NULL) {
- if (cgp->serial_number == 0) {
- MemFree (rbp);
- return NULL;
- }
- }
- } else if (cgp->journal == NULL || cgp->date == NULL) {
- if (cgp->serial_number == 0) {
- MemFree (rbp);
- return NULL;
- }
- }
- }
- }
- break;
- case PUB_Sub :
- rbp->category = REF_CAT_SUB;
- csp = (CitSubPtr) vnp->data.ptrvalue;
- if (csp != NULL) {
- imp = csp->imp;
- if (imp != NULL) {
- dp = imp->date;
- }
- if (csp->date != NULL) {
- dp = csp->date;
- }
- }
- break;
- case PUB_Article:
- cap = (CitArtPtr) vnp->data.ptrvalue;
- if (cap != NULL) {
- switch (cap->from) {
- case 1:
- cjp = (CitJourPtr) cap->fromptr;
- if (cjp != NULL) {
- imp = (ImprintPtr) cjp->imp;
- if (imp != NULL) {
- dp = imp->date;
- }
- }
- break;
- case 2:
- cbp = (CitBookPtr) cap->fromptr;
- if (cbp != NULL) {
- imp = (ImprintPtr) cbp->imp;
- if (imp != NULL) {
- dp = imp->date;
- }
- }
- break;
- case 3:
- cbp = (CitBookPtr) cap->fromptr;
- if (cbp != NULL) {
- imp = (ImprintPtr) cbp->imp;
- if (imp != NULL) {
- dp = imp->date;
- }
- }
- break;
- default:
- break;
- }
- }
- break;
- case PUB_Book:
- cbp = (CitBookPtr) vnp->data.ptrvalue;
- if (cbp != NULL) {
- imp = (ImprintPtr) cbp->imp;
- if (imp != NULL) {
- dp = imp->date;
- }
- }
- break;
- case PUB_Proc:
- cbp = (CitBookPtr) vnp->data.ptrvalue;
- if (cbp != NULL) {
- imp = (ImprintPtr) cbp->imp;
- if (imp != NULL) {
- dp = imp->date;
- }
- }
- break;
- case PUB_Patent :
- rbp->category = REF_CAT_PUB;
- cpp = (CitPatPtr) vnp->data.ptrvalue;
- if (cpp != NULL) {
- if (cpp->date_issue != NULL) {
- dp = (DatePtr) cpp->date_issue;
- } else if (cpp->app_date != NULL) {
- dp = (DatePtr) cpp->app_date;
- }
- }
- break;
- case PUB_Man:
- cbp = (CitBookPtr) vnp->data.ptrvalue;
- if (cbp != NULL) {
- imp = (ImprintPtr) cbp->imp;
- if (imp != NULL) {
- dp = imp->date;
- }
- }
- break;
- case PUB_Muid :
- rbp->muid = vnp->data.intvalue;
- rbp->category = REF_CAT_PUB;
- break;
- case PUB_PMid :
- rbp->pmid = vnp->data.intvalue;
- rbp->category = REF_CAT_PUB;
- break;
- default :
- break;
- }
- if (vnp->choice != PUB_Muid && vnp->choice != PUB_PMid) {
- justuids = FALSE;
- }
- }
-
- /* check for submitted vs. in-press */
-
- if (imp != NULL) {
- rbp->category = REF_CAT_PUB;
- switch (imp->prepub) {
- case 1 :
- rbp->category = REF_CAT_UNP;
- break;
- case 2 :
- rbp->category = REF_CAT_PUB;
- break;
- default :
- break;
- }
- }
-
- /* check for sites reftype */
-
- if (pdp->reftype != 0) {
- rbp->sites = pdp->reftype;
- }
-
- if (rbp->muid == 0 && rbp->pmid == 0) {
- vnp = pdp->pub;
-
- /* skip over just serial number */
-
- if (vnp != NULL && vnp->choice == PUB_Gen && vnp->next != NULL) {
- cgp = (CitGenPtr) vnp->data.ptrvalue;
- if (cgp != NULL) {
- if (StringNICmp ("BackBone id_pub", cgp->cit, 15) != 0) {
- if (cgp->cit == NULL && cgp->journal == NULL && cgp->date == NULL && cgp->serial_number) {
- vnp = vnp->next;
- }
- }
- }
- }
-
- if (PubLabelUnique (vnp, buf, sizeof (buf) - 1, OM_LABEL_CONTENT, TRUE) > 0) {
- rbp->uniquestr = StringSaveNoNull (buf);
- }
- }
-
- irp = (IntRefBlockPtr) rbp;
- irp->date = DateDup (dp);
- irp->justuids = justuids;
- /* if (justuids) { */
- irp->fig = StringSaveNoNull (pdp->fig);
- irp->maploc = StringSaveNoNull (pdp->maploc);
- irp->poly_a = pdp->poly_a;
- /* } */
-
- /* if not rejected by now, link in */
-
- ValNodeAddPointer (head, 0, rbp);
-
- return rbp;
-}
-
-static int LIBCALLBACK SortReferences (
- VoidPtr ptr1,
- VoidPtr ptr2,
- Boolean serialFirst,
- Boolean isRefSeq
-)
-
-{
- int compare;
- IntRefBlockPtr irp1;
- IntRefBlockPtr irp2;
- RefBlockPtr rbp1;
- RefBlockPtr rbp2;
- Int2 status;
- RefBlockPtr temp;
- ValNodePtr vnp1;
- ValNodePtr vnp2;
-
- if (ptr1 == NULL || ptr2 == NULL) return 0;
- vnp1 = *((ValNodePtr PNTR) ptr1);
- vnp2 = *((ValNodePtr PNTR) ptr2);
- if (vnp1 == NULL || vnp2 == NULL) return 0;
- rbp1 = (RefBlockPtr) vnp1->data.ptrvalue;
- rbp2 = (RefBlockPtr) vnp2->data.ptrvalue;
- if (rbp1 == NULL || rbp2 == NULL) return 0;
-
- if (serialFirst) {
- if (rbp1->serial > rbp2->serial) {
- return 1;
- } else if (rbp1->serial < rbp2->serial) {
- return -1;
- }
- }
-
- /* usual first sort by published, unpublished, and cit-subs */
-
- if (rbp1->category > rbp2->category) {
- return 1;
- } else if (rbp1->category < rbp2->category) {
- return -1;
- }
-
- /* for RefSeq, newer publications first, so temporarily swap pointers */
-
- if (isRefSeq) {
- temp = rbp1;
- rbp1 = rbp2;
- rbp2 = temp;
- }
-
- /* within class, sort by date, older publications first (except RefSeq) */
-
- irp1 = (IntRefBlockPtr) rbp1;
- irp2 = (IntRefBlockPtr) rbp2;
- status = DateMatch (irp1->date, irp2->date, FALSE);
- if (status == 1 || status == -1) return status;
-
- /* if dates (e.g., years) match, try to distinguish by uids */
-
- if (rbp1->pmid != 0 && rbp2->pmid != 0) {
- if (rbp1->pmid > rbp2->pmid) {
- return 1;
- } else if (rbp1->pmid < rbp2->pmid) {
- return -1;
- }
- }
-
- if (rbp1->muid != 0 && rbp2->muid != 0) {
- if (rbp1->muid > rbp2->muid) {
- return 1;
- } else if (rbp1->muid < rbp2->muid) {
- return -1;
- }
- }
-
- /* restore sort order after date and pmid/muid matching */
-
- if (isRefSeq) {
- temp = rbp1;
- rbp1 = rbp2;
- rbp2 = temp;
- }
-
- /* if same uid, one with just uids goes last to be excised but remembered */
-
- if ((rbp1->pmid != 0 && rbp2->pmid != 0) || (rbp1->muid != 0 && rbp2->muid != 0)) {
- if (irp1->justuids && (! irp2->justuids)) {
- return 1;
- } else if ((! irp1->justuids) && irp2->justuids) {
- return -1;
- }
- }
-
- /* put sites after pubs that refer to all or a range of bases */
-
- if (rbp1->sites > 0) {
- return 1;
- } else if (rbp2->sites > 0) {
- return -1;
- }
-
- /* for publication features, sort in explore index order */
-
- if (irp1->index > irp2->index) {
- return 1;
- } else if (irp1->index < irp2->index) {
- return -1;
- }
-
- /* next use author string */
-
- if (irp1->authstr != NULL && irp2->authstr != NULL) {
- compare = StringICmp (irp1->authstr, irp2->authstr);
- if (compare > 0) {
- return 1;
- } else if (compare < 0) {
- return -1;
- }
- }
-
- /* use unique label string to determine sort order */
-
- if (rbp1->uniquestr != NULL && rbp2->uniquestr != NULL) {
- compare = StringICmp (rbp1->uniquestr, rbp2->uniquestr);
- if (compare > 0) {
- return 1;
- } else if (compare < 0) {
- return -1;
- }
- }
-
- /* last resort for equivalent publication descriptors, sort in itemID order */
-
- if (rbp1->itemtype == OBJ_SEQDESC && rbp2->itemtype == OBJ_SEQDESC) {
- if (rbp1->itemID > rbp2->itemID) {
- return 1;
- } else if (rbp1->itemID < rbp2->itemID) {
- return -1;
- }
- }
-
- if (! serialFirst) {
- if (rbp1->serial > rbp2->serial) {
- return 1;
- } else if (rbp1->serial < rbp2->serial) {
- return -1;
- }
- }
-
- return 0;
-}
-
-static int LIBCALLBACK SortReferencesA (
- VoidPtr ptr1,
- VoidPtr ptr2
-)
-
-{
- return SortReferences (ptr1, ptr2, FALSE, FALSE);
-}
-
-static int LIBCALLBACK SortReferencesB (
- VoidPtr ptr1,
- VoidPtr ptr2
-)
-
-{
- return SortReferences (ptr1, ptr2, TRUE, FALSE);
-}
-
-static int LIBCALLBACK SortReferencesAR (
- VoidPtr ptr1,
- VoidPtr ptr2
-)
-
-{
- return SortReferences (ptr1, ptr2, FALSE, TRUE);
-}
-
-static int LIBCALLBACK SortReferencesBR (
- VoidPtr ptr1,
- VoidPtr ptr2
-)
-
-{
- return SortReferences (ptr1, ptr2, TRUE, TRUE);
-}
-
-static CharPtr GetAuthorsPlusConsortium (
- FmtType format,
- AuthListPtr alp
-)
-
-{
- CharPtr consortium;
- CharPtr str;
- CharPtr tmp;
-
- consortium = NULL;
- str = GetAuthorsString (format, alp, &consortium, NULL, NULL);
- if (str == NULL) return consortium;
- if (consortium == NULL) return str;
- tmp = MemNew (StringLen (str) + StringLen (consortium) + 5);
- if (tmp == NULL) return NULL;
- StringCpy (tmp, str);
- StringCat (tmp, "; ");
- StringCat (tmp, consortium);
- MemFree (str);
- MemFree (consortium);
- return tmp;
-}
-
-static Boolean HasNoPmidOrMuid (
- PubdescPtr pdp
-)
-
-{
- ValNodePtr vnp;
-
- if (pdp == NULL) return TRUE;
- for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
- if (vnp->choice == PUB_PMid || vnp->choice == PUB_Muid) return FALSE;
- }
- return TRUE;
-}
-
-typedef struct cdspubs {
- Asn2gbWorkPtr awp;
- BioseqPtr target;
- ValNodePtr vnp;
-} CdsPubs, PNTR CdsPubsPtr;
-
-static Boolean LIBCALLBACK GetRefsOnCDS (
- SeqFeatPtr sfp,
- SeqMgrFeatContextPtr context
-)
-
-{
- AuthListPtr alp;
- Asn2gbWorkPtr awp;
- CdsPubsPtr cpp;
- IntRefBlockPtr irp;
- Boolean okay;
- PubdescPtr pdp;
- RefBlockPtr rbp;
-
- if (sfp == NULL || context == NULL) return TRUE;
- cpp = (CdsPubsPtr) context->userdata;
- awp = cpp->awp;
- if (awp == NULL) return TRUE;
-
- okay = TRUE;
- pdp = (PubdescPtr) sfp->data.value.ptrvalue;
- if (awp->format == FTABLE_FMT) {
- if (HasNoPmidOrMuid (pdp)) {
- okay = FALSE;
- }
- }
-
- if (okay) {
- rbp = AddPub (awp, &(awp->pubhead), pdp);
- if (rbp != NULL) {
-
- rbp->entityID = context->entityID;
- rbp->itemID = context->itemID;
- rbp->itemtype = OBJ_SEQFEAT;
-
- irp = (IntRefBlockPtr) rbp;
- irp->loc = SeqLocMerge (cpp->target, cpp->vnp, NULL, FALSE, TRUE, FALSE);
- alp = GetAuthListPtr (pdp, NULL);
- if (alp != NULL) {
- irp->authstr = GetAuthorsPlusConsortium (awp->format, alp);
- }
- irp->index = 0;
- }
- }
-
- return TRUE;
-}
-
-static void GetRefsOnBioseq (
- Asn2gbWorkPtr awp,
- BioseqPtr target,
- BioseqPtr bsp,
- Int4 from,
- Int4 to,
- SeqLocPtr cdsloc
-)
-
-{
- IntAsn2gbJobPtr ajp;
- AuthListPtr alp;
- CdsPubs cp;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- Int2 i;
- Int2 idx;
- IntRefBlockPtr irp;
- Int4Ptr ivals;
- Int4 left;
- SeqLocPtr newloc;
- Int2 numivals;
- Boolean okay;
- PubdescPtr pdp;
- RefBlockPtr rbp;
- Int4 right;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp;
- SeqInt sint;
- SeqIdPtr sip;
- Boolean split;
- Int4 start;
- Int4 stop;
- Uint1 strand;
- Boolean takeIt;
- ValNode vn;
- ValNodePtr vnp;
-
- if (awp == NULL || target == NULL || bsp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
-
- /* full length loc for descriptors */
-
- sint.from = 0;
- if (ajp->ajp.slp != NULL) {
- from = SeqLocStart (ajp->ajp.slp); /* other features use awp->slp for from and to */
- }
- if (ajp->ajp.slp != NULL) {
- sint.to = SeqLocLen (ajp->ajp.slp) - 1;
- to = SeqLocStop (ajp->ajp.slp); /* other features use awp->slp for from and to */
- } else {
- sint.to = bsp->length - 1;
- }
- sint.strand = Seq_strand_plus;
- sint.id = SeqIdStripLocus (SeqIdDup (SeqIdFindBest (bsp->id, 0)));
- sint.if_from = NULL;
- sint.if_to = NULL;
-
- vn.choice = SEQLOC_INT;
- vn.data.ptrvalue = (Pointer) &sint;
- vn.next = NULL;
-
- sdp = SeqMgrGetNextDescriptor (target, NULL, Seq_descr_pub, &dcontext);
- while (sdp != NULL) {
-
- /* check if descriptor on part already added on segmented bioseq */
-
- okay = TRUE;
- for (vnp = awp->pubhead; vnp != NULL && okay; vnp = vnp->next) {
- rbp = (RefBlockPtr) vnp->data.ptrvalue;
- if (rbp != NULL) {
- if (rbp->entityID == dcontext.entityID &&
- rbp->itemID == dcontext.itemID &&
- rbp->itemtype == OBJ_SEQDESC) {
- okay = FALSE;
- }
- }
- }
- if (awp->format == FTABLE_FMT) {
- pdp = (PubdescPtr) sdp->data.ptrvalue;
- if (HasNoPmidOrMuid (pdp)) {
- okay = FALSE;
- }
- }
-
- if (okay) {
- pdp = (PubdescPtr) sdp->data.ptrvalue;
- rbp = AddPub (awp, &(awp->pubhead), pdp);
- if (rbp != NULL) {
-
- rbp->entityID = dcontext.entityID;
- rbp->itemID = dcontext.itemID;
- rbp->itemtype = OBJ_SEQDESC;
-
- irp = (IntRefBlockPtr) rbp;
- irp->loc = SeqLocMerge (target, &vn, NULL, FALSE, TRUE, FALSE);
- alp = GetAuthListPtr (pdp, NULL);
- if (alp != NULL) {
- irp->authstr = GetAuthorsPlusConsortium (awp->format, alp);
- }
- irp->index = 0;
- }
- }
- sdp = SeqMgrGetNextDescriptor (target, sdp, Seq_descr_pub, &dcontext);
- }
-
- /* if protein with no pubs, get pubs applicable to DNA location of CDS */
-
- if (cdsloc != NULL) {
- cp.awp = awp;
- cp.target = target;
- cp.vnp = &vn;
- SeqMgrGetAllOverlappingFeatures (cdsloc, FEATDEF_PUB, NULL, 0, LOCATION_SUBSET, (Pointer) &cp, GetRefsOnCDS);
- }
-
- SeqIdFree (sint.id);
-
- /* features are indexed on parent if segmented */
-
- bsp = awp->parent;
-
- sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_PUB, 0, &fcontext);
- while (sfp != NULL) {
- ivals = fcontext.ivals;
- numivals = fcontext.numivals;
- if (ivals != NULL && numivals > 0) {
-
- /*
- idx = (numivals - 1) * 2;
- start = ivals [idx];
- stop = ivals [idx + 1];
- */
-
- takeIt = FALSE;
- for (i = 0, idx = 0; i < numivals; i++, idx += 2) {
- start = ivals [idx];
- stop = ivals [idx + 1];
- if ((start <= from && stop > from) ||
- (start < to && stop >= to) ||
- (start >= from && stop <= to)) {
- takeIt = TRUE;
- }
- }
- if (awp->format == FTABLE_FMT) {
- pdp = (PubdescPtr) sdp->data.ptrvalue;
- if (HasNoPmidOrMuid (pdp)) {
- takeIt = FALSE;
- }
- }
-
- if (takeIt /* stop >= from && stop <= to */) {
-
- /*
- start = ivals [0] + 1;
- stop = ivals [idx + 1] + 1;
- */
- pdp = (PubdescPtr) sfp->data.value.ptrvalue;
- rbp = AddPub (awp, &(awp->pubhead), pdp);
- if (rbp != NULL) {
-
- rbp->entityID = fcontext.entityID;
- rbp->itemID = fcontext.itemID;
- rbp->itemtype = OBJ_SEQFEAT;
-
- irp = (IntRefBlockPtr) rbp;
- irp->loc = SeqLocMerge (target, sfp->location, NULL, FALSE, TRUE, FALSE);
- if (ajp->ajp.slp != NULL) {
- sip = SeqIdParse ("lcl|dummy");
- left = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_LEFT_END);
- right = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_RIGHT_END);
- strand = SeqLocStrand (ajp->ajp.slp);
- split = FALSE;
- newloc = SeqLocReMapEx (sip, ajp->ajp.slp, irp->loc, 0, FALSE, ajp->masterStyle);
- /*
- newloc = SeqLocCopyRegion (sip, irp->loc, bsp, left, right, strand, &split);
- */
- SeqIdFree (sip);
- if (newloc != NULL) {
- A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
- irp->loc = SeqLocFree (irp->loc);
- irp->loc = newloc;
- }
- }
- alp = GetAuthListPtr (pdp, NULL);
- if (alp != NULL) {
- irp->authstr = GetAuthorsPlusConsortium (awp->format, alp);
- }
- irp->index = fcontext.index;
- }
- }
- }
-
- sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_PUB, 0, &fcontext);
- }
-}
-
-static Boolean LIBCALLBACK GetRefsOnSeg (
- SeqLocPtr slp,
- SeqMgrSegmentContextPtr context
-)
-
-{
- Asn2gbWorkPtr awp;
- BioseqPtr bsp;
- Int4 from;
- SeqLocPtr loc;
- SeqEntryPtr oldscope;
- SeqEntryPtr sep;
- SeqIdPtr sip;
- Int4 to;
-
- if (slp == NULL || context == NULL) return FALSE;
- awp = (Asn2gbWorkPtr) context->userdata;
-
- from = context->cumOffset;
- to = from + context->to - context->from;
-
- sip = SeqLocId (slp);
- if (sip == NULL) {
- loc = SeqLocFindNext (slp, NULL);
- if (loc != NULL) {
- sip = SeqLocId (loc);
- }
- }
- if (sip == NULL) return TRUE;
-
- /* reference descriptors only on parts within entity */
-
- sep = GetTopSeqEntryForEntityID (awp->entityID);
- oldscope = SeqEntrySetScope (sep);
- bsp = BioseqFind (sip);
- SeqEntrySetScope (oldscope);
-
- if (bsp != NULL) {
- GetRefsOnBioseq (awp, awp->refs, bsp, from, to, NULL);
- return TRUE;
- }
-
- /* if we ever want to fetch remote references, code goes here */
-
- return TRUE;
-}
-
-static Boolean AddReferenceBlock (
- Asn2gbWorkPtr awp,
- Boolean isRefSeq
-)
-
-{
- IntAsn2gbJobPtr ajp;
- AuthListPtr alp;
- Asn2gbSectPtr asp;
- BioseqPtr bsp;
- SeqFeatPtr cds;
- Boolean combine;
- SeqMgrFeatContext context;
- CitSubPtr csp;
- BioseqPtr dna;
- Boolean excise;
- ValNodePtr head = NULL;
- Int2 i;
- IntRefBlockPtr irp;
- Boolean is_aa;
- Boolean is_embl = FALSE;
- Boolean is_patent = FALSE;
- IntRefBlockPtr lastirp;
- RefBlockPtr lastrbp;
- ValNodePtr next;
- Int2 numReferences;
- ValNodePtr PNTR prev;
- RefBlockPtr rbp;
- RefBlockPtr PNTR referenceArray;
- BioseqPtr refs;
- SubmitBlockPtr sbp;
- SeqIdPtr sip;
- SeqLocPtr slp;
- BioseqPtr target;
- ValNodePtr vnp;
-
- if (awp == NULL) return FALSE;
- ajp = awp->ajp;
- if (ajp == NULL) return FALSE;
- asp = awp->asp;
- if (asp == NULL) return FALSE;
- bsp = awp->bsp;
- refs = awp->refs;
- if (bsp == NULL || refs == NULL) return FALSE;
-
- /* collect publications on bioseq */
-
- awp->pubhead = NULL;
- GetRefsOnBioseq (awp, bsp, refs, awp->from, awp->to, NULL);
- target = bsp;
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_EMBL) {
- is_embl = TRUE;
- } else if (sip->choice == SEQID_PATENT) {
- is_patent = TRUE;
- }
- }
-
- is_aa = (Boolean) ISA_aa (bsp->mol);
-
- if (bsp->repr == Seq_repr_seg) {
-
- /* collect publication descriptors on local parts */
-
- SeqMgrExploreSegments (bsp, (Pointer) awp, GetRefsOnSeg);
- target = awp->refs;
- }
-
- if (awp->pubhead == NULL && ISA_aa (bsp->mol)) {
-
- /* if protein with no pubs, get pubs applicable to DNA location of CDS */
-
- cds = SeqMgrGetCDSgivenProduct (bsp, &context);
- if (cds != NULL) {
- dna = BioseqFindFromSeqLoc (cds->location);
- if (dna != NULL) {
- GetRefsOnBioseq (awp, dna, dna, context.left, context.right, cds->location);
- target = dna;
- }
- }
- }
-
- head = awp->pubhead;
- awp->pubhead = NULL;
-
- if (head == NULL && awp->ssp == NULL) return FALSE;
-
- /* sort by pub/unpub/sites/sub, then date, finally existing serial */
-
- if (isRefSeq) {
- head = SortValNode (head, SortReferencesAR);
- } else {
- head = SortValNode (head, SortReferencesA);
- }
-
- if (awp->ssp != NULL) {
-
- /* add seq-submit citation */
-
- rbp = (RefBlockPtr) MemNew (sizeof (IntRefBlock));
- if (rbp != NULL) {
- irp = (IntRefBlockPtr) rbp;
-
- rbp->blocktype = REFERENCE_BLOCK;
- rbp->section = awp->currsection;
- rbp->serial = INT2_MAX;
- rbp->category = REF_CAT_SUB;
-
- rbp->entityID = ajp->ajp.entityID;
- rbp->itemID = 1;
- rbp->itemtype = OBJ_SEQSUB_CIT;
-
- sbp = awp->ssp->sub;
- if (sbp != NULL) {
- csp = sbp->cit;
- if (csp != NULL) {
- alp = GetAuthListPtr (NULL, csp);
- if (alp != NULL) {
- irp->authstr = GetAuthorsPlusConsortium (awp->format, alp);
- }
- }
- }
-
- if (awp->citSubsFirst) {
-
- /* for DDBJ, add seq-submit citation to beginning of list */
-
- vnp = ValNodeNew (NULL);
- if (vnp != NULL) {
- vnp->choice = 0;
- vnp->data.ptrvalue = (VoidPtr) rbp;
- vnp->next = head;
- head = vnp;
- }
-
- } else {
-
- /* for GENBANK and EMBL add seq-submit citation to end of list */
-
- ValNodeAddPointer (&head, 0, rbp);
- }
- }
- }
-
- /* unique references, excise duplicates from list */
-
- prev = &(head);
- vnp = head;
- lastrbp = NULL;
- while (vnp != NULL) {
- excise = FALSE;
- combine = TRUE;
- next = vnp->next;
- rbp = (RefBlockPtr) vnp->data.ptrvalue;
- if (lastrbp != NULL) {
- lastirp = (IntRefBlockPtr) lastrbp;
- if (rbp != NULL) {
- irp = (IntRefBlockPtr) rbp;
- if (lastrbp->pmid != 0 && rbp->pmid != 0) {
- if (lastrbp->pmid == rbp->pmid) {
- excise = TRUE;
- }
- } else if (lastrbp->muid != 0 && rbp->muid != 0) {
- if (lastrbp->muid == rbp->muid) {
- excise = TRUE;
- }
- } else if (lastrbp->uniquestr != NULL && rbp->uniquestr != NULL) {
- if (StringICmp (lastrbp->uniquestr, rbp->uniquestr) == 0) {
- if (SeqLocCompare (irp->loc, lastirp->loc) == SLC_A_EQ_B) {
- if (StringICmp (irp->authstr, lastirp->authstr) == 0) {
-
- /* L76496.1 - removing duplicate submission pubs */
- excise = TRUE;
- }
- }
- }
- }
- if (excise && lastrbp->sites == 0 && rbp->sites > 0) {
- /* real range trumps sites */
- combine = FALSE;
- }
- }
- }
- if (rbp != NULL) {
- irp = (IntRefBlockPtr) rbp;
- if (irp->justuids) {
- if (isRefSeq && is_aa) {
- /* if allowing justuid in protein RefSeq, try to look up dynamically */
- excise = TRUE; /* Back to old behavior, do not fetch */
- } else {
- /* do not allow justuids reference to appear by itself - S79174.1 */
- excise = TRUE;
- /* justuids should still combine, even if no authors - S67070.1 */
- }
- } else if (is_embl && is_patent) {
- /* EMBL patent records do not need author or title - A29528.1 */
- } else if (StringHasNoText (irp->authstr)) {
- /* do not allow no author reference to appear by itself - U07000.1 */
- excise = TRUE;
- combine = FALSE;
- }
- }
- if (excise) {
- *prev = vnp->next;
- vnp->next = NULL;
-
- /* combine locations of duplicate references */
-
- irp = (IntRefBlockPtr) rbp;
- lastirp = (IntRefBlockPtr) lastrbp;
- if (combine) {
- if (lastirp != NULL) {
- slp = SeqLocMerge (target, lastirp->loc, irp->loc, FALSE, TRUE, FALSE);
- lastirp->loc = SeqLocFree (lastirp->loc);
- lastirp->loc = slp;
- }
- if (irp != NULL && lastirp != NULL) {
- if ((rbp->muid == lastrbp->muid && rbp->muid != 0) ||
- (rbp->pmid == lastrbp->pmid && rbp->pmid != 0)) {
- if (lastirp->fig == NULL) {
- lastirp->fig = StringSaveNoNull (irp->fig);
- }
- if (lastirp->maploc == NULL) {
- lastirp->maploc = StringSaveNoNull (irp->maploc);
- }
- lastirp->poly_a = irp->poly_a;
- }
- }
- }
-
- /* and remove duplicate reference */
-
- MemFree (rbp->uniquestr);
- DateFree (irp->date);
- SeqLocFree (irp->loc);
- MemFree (irp->authstr);
- MemFree (irp->fig);
- MemFree (irp->maploc);
- MemFree (rbp);
- ValNodeFree (vnp);
-
- } else {
-
- prev = &(vnp->next);
- lastrbp = rbp;
- }
- vnp = next;
- }
-
- /* resort by existing serial, then pub/unpub/sites/sub, then date */
-
- if (isRefSeq) {
- head = SortValNode (head, SortReferencesBR);
- } else {
- head = SortValNode (head, SortReferencesB);
- }
-
- if (head == NULL) return FALSE;
-
- /* if taking best GeneRIFs, free remainder */
-
- if (awp->latestGeneRIFs) {
- for (vnp = head, i = 0; vnp != NULL && i < 10; vnp = vnp->next, i++) continue;
- if (vnp != NULL) {
- next = vnp->next;
- vnp->next = NULL;
- for (vnp = next; vnp != NULL; vnp = vnp->next) {
- rbp = (RefBlockPtr) vnp->data.ptrvalue;
- MemFree (rbp->uniquestr);
- irp = (IntRefBlockPtr) rbp;
- DateFree (irp->date);
- SeqLocFree (irp->loc);
- MemFree (irp->authstr);
- MemFree (irp->fig);
- MemFree (irp->maploc);
- MemFree (rbp);
- }
- }
- }
-
- /* assign serial numbers */
-
- for (vnp = head, i = 1; vnp != NULL; vnp = vnp->next, i++) {
- rbp = (RefBlockPtr) vnp->data.ptrvalue;
- if (rbp != NULL) {
- rbp->serial = i;
- }
- }
-
- /* allocate reference array for this section */
-
- numReferences = i - 1;
- asp->numReferences = numReferences;
-
- if (numReferences > 0) {
- referenceArray = (RefBlockPtr PNTR) MemNew (sizeof (RefBlockPtr) * (numReferences + 1));
- asp->referenceArray = referenceArray;
-
- if (referenceArray != NULL) {
-
- /* fill in reference array */
-
- for (vnp = head, i = 0; vnp != NULL && i < numReferences; vnp = vnp->next, i++) {
- referenceArray [i] = (RefBlockPtr) vnp->data.ptrvalue;
- }
- }
- }
-
- /* finally link into blocks for current section */
-
- ValNodeLink (&(awp->lastblock), head);
- vnp = awp->lastblock;
- if (vnp == NULL) return FALSE;
- while (vnp->next != NULL) {
- vnp = vnp->next;
- }
-
- awp->lastblock = vnp;
- if (awp->blockList == NULL) {
- awp->blockList = vnp;
- }
-
- return TRUE;
-}
-
-static void AddHistCommentString (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- CharPtr prefix,
- CharPtr suffix,
- DatePtr dp,
- SeqIdPtr ids
-)
-
-{
- Int2 count = 0;
- Char buf [256];
- Boolean first;
- Int4 gi = 0;
- SeqIdPtr sip;
- CharPtr strd;
-
- if (dp == NULL || ids == NULL || prefix == NULL || suffix == NULL || ffstring == NULL) return;
-
- strd = asn2gb_PrintDate (dp);
- if (strd == NULL) {
- strd = StringSave ("?");
- }
-
- for (sip = ids; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GI) {
- gi = (long) sip->data.intvalue;
- count++;
- }
- }
-
- if (count > 1) {
- sprintf (buf, "%s or before %s %s", prefix, strd, suffix);
- } else {
- sprintf (buf, "%s %s %s", prefix, strd, suffix);
- }
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
-
- MemFree (strd);
-
- if (gi == 0) {
- FFAddOneString (ffstring, " gi:?", FALSE, FALSE, TILDE_EXPAND);
- return;
- }
-
- first = TRUE;
- for (sip = ids; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GI) {
- gi = (long) sip->data.intvalue;
- if (! first) {
- FFAddOneString (ffstring, ",", FALSE, FALSE, TILDE_IGNORE);
- }
- first = FALSE;
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, " gi:", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString (ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
- sprintf (buf, "%ld", (long) gi);
- FFAddTextToString (ffstring, "val=", buf, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- sprintf (buf, " gi:%ld", (long) gi);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
- }
- }
- }
-
- FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_EXPAND);
-}
-
-static void AddHTGSCommentString (
- StringItemPtr ffstring,
- BioseqPtr bsp,
- MolInfoPtr mip
-)
-
-{
- CharPtr buf = NULL;
- Char buffer [256];
- Int4 buflen = 0;
- DeltaSeqPtr dsp;
- ValNodePtr head = NULL;
- Int4 num_s = 0;
- Int4 num_g = 0;
- CharPtr str = NULL;
-
- if (bsp == NULL || mip == NULL || mip->tech < 2) return;
-
- if (bsp->repr == Seq_repr_delta) {
- for (dsp = (DeltaSeqPtr) bsp->seq_ext, buflen = 0; dsp != NULL; dsp = dsp->next) {
- buflen += 80;
- }
- if (buflen > 0) {
- buf = MemNew ((size_t) (buflen + 1));
- if (buf == NULL) return;
- CountGapsInDeltaSeq (bsp, &num_s, &num_g, NULL, NULL, buf, buflen);
- }
- }
-
- if (mip->tech == MI_TECH_htgs_0) {
-
- if (num_s > 0) {
- sprintf (buffer, "* NOTE: This record contains %ld individual~", (long) (num_g + 1));
- ValNodeCopyStr (&head, 0, buffer);
- ValNodeCopyStr (&head, 0, "* sequencing reads that have not been assembled into~");
- ValNodeCopyStr (&head, 0, "* contigs. Runs of N are used to separate the reads~");
- ValNodeCopyStr (&head, 0, "* and the order in which they appear is completely~");
- ValNodeCopyStr (&head, 0, "* arbitrary. Low-pass sequence sampling is useful for~");
- ValNodeCopyStr (&head, 0, "* identifying clones that may be gene-rich and allows~");
- ValNodeCopyStr (&head, 0, "* overlap relationships among clones to be deduced.~");
- ValNodeCopyStr (&head, 0, "* However, it should not be assumed that this clone~");
- ValNodeCopyStr (&head, 0, "* will be sequenced to completion. In the event that~");
- ValNodeCopyStr (&head, 0, "* the record is updated, the accession number will~");
- ValNodeCopyStr (&head, 0, "* be preserved.");
- }
- ValNodeCopyStr (&head, 0, "~");
- ValNodeCopyStr (&head, 0, buf);
-
- } else if (mip->tech == MI_TECH_htgs_1) {
-
- ValNodeCopyStr (&head, 0, "* NOTE: This is a \"working draft\" sequence.");
- if (num_s > 0) {
- sprintf (buffer, " It currently~* consists of %ld contigs. The true order of the pieces~", (long) (num_g + 1));
- ValNodeCopyStr (&head, 0, buffer);
- ValNodeCopyStr (&head, 0, "* is not known and their order in this sequence record is~");
- ValNodeCopyStr (&head, 0, "* arbitrary. Gaps between the contigs are represented as~");
- ValNodeCopyStr (&head, 0, "* runs of N, but the exact sizes of the gaps are unknown.");
- }
- ValNodeCopyStr (&head, 0, "~* This record will be updated with the finished sequence~");
- ValNodeCopyStr (&head, 0, "* as soon as it is available and the accession number will~");
- ValNodeCopyStr (&head, 0, "* be preserved.");
- ValNodeCopyStr (&head, 0, "~");
- ValNodeCopyStr (&head, 0, buf);
-
- } else if (mip->tech == MI_TECH_htgs_2) {
-
- ValNodeCopyStr (&head, 0, "* NOTE: This is a \"working draft\" sequence.");
- if (num_s > 0) {
- sprintf (buffer, " It currently~* consists of %ld contigs. Gaps between the contigs~", (long) (num_g + 1));
- ValNodeCopyStr (&head, 0, buffer);
- ValNodeCopyStr (&head, 0, "* are represented as runs of N. The order of the pieces~");
- ValNodeCopyStr (&head, 0, "* is believed to be correct as given, however the sizes~");
- ValNodeCopyStr (&head, 0, "* of the gaps between them are based on estimates that have~");
- ValNodeCopyStr (&head, 0, "* provided by the submittor.");
- }
- ValNodeCopyStr (&head, 0, "~* This sequence will be replaced~");
- ValNodeCopyStr (&head, 0, "* by the finished sequence as soon as it is available and~");
- ValNodeCopyStr (&head, 0, "* the accession number will be preserved.");
- ValNodeCopyStr (&head, 0, "~");
- ValNodeCopyStr (&head, 0, buf);
-
- } else if ((str = StringForSeqTech (mip->tech)) != NULL) {
-
- sprintf (buffer, "Method: %s.", str);
- ValNodeCopyStr (&head, 0, buffer);
- }
-
- MemFree (buf);
-
- str = MergeValNodeStrings (head);
-
- FFAddOneString (ffstring, str, TRUE, TRUE, TILDE_EXPAND);
-
- MemFree (str);
- ValNodeFreeData (head);
-}
-
-static void AddWGSMasterCommentString (
- StringItemPtr ffstring,
- BioseqPtr bsp,
- CharPtr wgsaccn,
- CharPtr wgsname
-)
-
-{
- size_t acclen;
- BioSourcePtr biop;
- Char buf [256];
- SeqMgrDescContext dcontext;
- CharPtr first = NULL;
- ValNodePtr head = NULL;
- CharPtr last = NULL;
- ObjectIdPtr oip;
- OrgRefPtr orp;
- SeqDescrPtr sdp;
- CharPtr taxname = NULL;
- UserFieldPtr ufp;
- UserObjectPtr uop;
- Char ver [16];
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
- if (sdp != NULL) {
- biop = (BioSourcePtr) sdp->data.ptrvalue;
- if (biop != NULL) {
- orp = biop->org;
- if (orp != NULL) {
- taxname = orp->taxname;
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
- while (sdp != NULL) {
- uop = (UserObjectPtr) sdp->data.ptrvalue;
- if (uop != NULL) {
- oip = uop->type;
- if (oip != NULL && StringICmp (oip->str, "WGSProjects") == 0) {
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (oip == NULL || oip->str == NULL || ufp->choice != 1) continue;
- if (StringICmp (oip->str, "WGS_accession_first") == 0) {
- first = (CharPtr) ufp->data.ptrvalue;
- } else if (StringICmp (oip->str, "WGS_accession_last") == 0) {
- last = (CharPtr) ufp->data.ptrvalue;
- }
- }
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
- }
-
- if (StringHasNoText (taxname)) {
- taxname = "?";
- }
- if (StringHasNoText (first)) {
- first = "?";
- }
- if (StringHasNoText (last)) {
- last = "?";
- }
- ver [0] = '\0';
- acclen = StringLen (wgsname);
- if (acclen == 12) {
- StringCpy (ver, wgsname + 4);
- ver [2] = '\0';
- } else if (acclen == 13) {
- StringCpy (ver, wgsname + 4);
- ver [2] = '\0';
- } else if (acclen == 15) {
- StringCpy (ver, wgsname + 7);
- ver [2] = '\0';
- }
-
- sprintf (buf, "The %s whole genome shotgun (WGS) project has the project accession %s.", taxname, wgsaccn);
- FFAddOneString(ffstring, buf, TRUE, FALSE, TILDE_EXPAND);
-
- sprintf (buf, " This version of the project (%s) has the accession number %s,", ver, wgsname);
- FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
-
- if (StringCmp (first, last) != 0) {
- sprintf (buf, " and consists of sequences %s-%s.", first, last);
- FFAddOneString(ffstring, buf, TRUE, FALSE, TILDE_EXPAND);
- } else {
- sprintf (buf, " and consists of sequence %s.", first);
- FFAddOneString(ffstring, buf, TRUE, FALSE, TILDE_EXPAND);
- }
-}
-
-
-static CharPtr GetMolInfoCommentString (
- BioseqPtr bsp,
- MolInfoPtr mip
-)
-
-{
- Boolean is_aa;
- CharPtr str = NULL;
-
- if (bsp == NULL || mip == NULL) return NULL;
-
- is_aa = ISA_aa (bsp->mol);
- switch (mip->completeness) {
- case 1 :
- str = "COMPLETENESS: full length";
- break;
- case 2 :
- str = "COMPLETENESS: not full length";
- break;
- case 3 :
- if (is_aa) {
- str = "COMPLETENESS: incomplete on the amino end";
- } else {
- str = "COMPLETENESS: incomplete on the 5' end";
- }
- break;
- case 4 :
- if (is_aa) {
- str = "COMPLETENESS: incomplete on the carboxy end";
- } else {
- str = "COMPLETENESS: incomplete on the 3' end";
- }
- break;
- case 5 :
- str = "COMPLETENESS: incomplete on both ends";
- break;
- case 6 :
- if (is_aa) {
- str = "COMPLETENESS: complete on the amino end";
- } else {
- str = "COMPLETENESS: complete on the 5' end";
- }
- break;
- case 7 :
- if (is_aa) {
- str = "COMPLETENESS: complete on the carboxy end";
- } else {
- str = "COMPLETENESS: complete on the 3' end";
- }
- break;
- default :
- str = "COMPLETENESS: unknown";
- break;
- }
-
- return str;
-}
-
-static CharPtr GetStrForBankit (
- UserObjectPtr uop
-)
-
-{
- CharPtr bic = NULL, uvc = NULL, ptr;
- ObjectIdPtr oip;
- UserFieldPtr ufp;
-
- if (uop == NULL) return NULL;
- if ((oip = uop->type) == NULL) return NULL;
- if (StringCmp (oip->str, "Submission") != 0) return NULL;
-
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (StringCmp(oip->str, "UniVecComment") == 0) {
- uvc = ufp->data.ptrvalue;
- } else if (StringCmp(oip->str, "AdditionalComment") == 0) {
- bic = ufp->data.ptrvalue;
- }
- }
-
- if (uvc == NULL && bic == NULL) return NULL;
-
- ptr = (CharPtr) MemNew (StringLen (uvc) + StringLen (bic) + 45);
- if (uvc != NULL && bic != NULL) {
- sprintf (ptr, "Vector Explanation: %s~Bankit Comment: %s", uvc, bic);
- } else if (uvc != NULL) {
- sprintf (ptr, "Vector Explanation: %s", uvc);
- } else if (bic != NULL) {
- sprintf (ptr, "Bankit Comment: %s", bic);
- }
-
- return ptr;
-}
-
-static CharPtr reftxt0 = " The reference sequence was derived from ";
-static CharPtr reftxt1 = " This record is predicted by genome sequence analysis and is not yet supported by experimental evidence.";
-static CharPtr reftxt2 = " This record has not yet been subject to final NCBI review.";
-static CharPtr reftxt3 = " The mRNA record is supported by experimental evidence; however, the coding sequence is predicted.";
-static CharPtr reftxt4 = " This record has undergone preliminary review of the sequence, but has not yet been subject to final review.";
-static CharPtr reftxt5 = " This record has been curated by ";
-static CharPtr reftxt6 = " This record is predicted by automated computational analysis.";
-static CharPtr reftxt7 = " This record is provided to represent a collection of whole genome shotgun sequences.";
-static CharPtr reftxt8 = " This record is derived from an annotated genomic sequence (";
-
-static CharPtr GetStatusForRefTrack (
- UserObjectPtr uop
-)
-
-{
- CharPtr st;
- ObjectIdPtr oip;
- UserFieldPtr ufp, urf = NULL;
-
- if (uop == NULL) return NULL;
- if ((oip = uop->type) == NULL) return NULL;
- if (StringCmp (oip->str, "RefGeneTracking") != 0) return NULL;
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (StringCmp(oip->str, "Assembly") == 0) {
- urf = ufp;
- }
- }
- /* if (urf == NULL || urf->choice != 11) return NULL; */
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (StringCmp (oip->str, "Status") == 0) {
- st = (CharPtr) ufp->data.ptrvalue;
- if (StringICmp (st, "Inferred") == 0) {
- return "INFERRED ";
- } else if (StringICmp (st, "Provisional") == 0) {
- return "PROVISIONAL ";
- } else if (StringICmp (st, "Predicted") == 0) {
- return "PREDICTED ";
- } else if (StringICmp (st, "Validated") == 0) {
- return "VALIDATED ";
- } else if (StringICmp (st, "Reviewed") == 0) {
- return "REVIEWED ";
- } else if (StringICmp (st, "Model") == 0) {
- return "MODEL ";
- } else if (StringICmp (st, "WGS") == 0) {
- return "WGS ";
- }
- }
- }
- return NULL;
-}
-
-
-static void AddStrForRefTrack (
- IntAsn2gbJobPtr ajp,
- StringItemPtr ffstring,
- UserObjectPtr uop
-)
-
-{
- CharPtr accn, curator = NULL, source = NULL, st;
- ObjectIdPtr oip;
- UserFieldPtr ufp, tmp, u, urf = NULL;
- Int2 i = 0;
- Int2 review = 0,len;
- Boolean is_accn;
-
- if ( uop == NULL || ffstring == NULL ) return;
- if ((oip = uop->type) == NULL) return;
- if (StringCmp (oip->str, "RefGeneTracking") != 0) return;
-
- len = StringLen (reftxt0);
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (StringCmp(oip->str, "Assembly") == 0) {
- urf = ufp;
- }
- if (StringCmp (oip->str, "Status") == 0) {
- st = (CharPtr) ufp->data.ptrvalue;
- if (StringICmp (st, "Inferred") == 0) {
- review = 1;
- } else if (StringICmp (st, "Provisional") == 0) {
- review = 2;
- } else if (StringICmp (st, "Predicted") == 0) {
- review = 3;
- } else if (StringICmp (st, "Validated") == 0) {
- review = 4;
- } else if (StringICmp (st, "Reviewed") == 0) {
- review = 5;
- } else if (StringICmp (st, "Model") == 0) {
- review = 6;
- } else if (StringICmp (st, "WGS") == 0) {
- review = 7;
- }
- } else if (StringCmp (oip->str, "Collaborator") == 0) {
- st = (CharPtr) ufp->data.ptrvalue;
- if (! StringHasNoText (st)) {
- curator = st;
- }
- } else if (StringCmp (oip->str, "GenomicSource") == 0) {
- st = (CharPtr) ufp->data.ptrvalue;
- if (! StringHasNoText (st)) {
- source = st;
- }
- }
- }
- if (urf != NULL && urf->choice == 11) {
- for (tmp = urf->data.ptrvalue; tmp != NULL; tmp = tmp->next) {
- for (u = tmp->data.ptrvalue; u != NULL; u = u->next) {
- oip = u->label;
- if (StringCmp (oip->str, "accession") == 0 ||
- StringCmp (oip->str, "name") == 0) {
- i++;
- }
- }
- }
- }
- if ( GetWWW(ajp) ) {
- FFAddTextToString(ffstring, "<a href=", ref_link, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, ":", FALSE, FALSE, TILDE_IGNORE);
- if (review == 1) {
- FFAddOneString (ffstring, reftxt1, FALSE, FALSE, TILDE_IGNORE);
- } else if (review == 2) {
- FFAddOneString (ffstring, reftxt2, FALSE, FALSE, TILDE_IGNORE);
- } else if (review == 3) {
- FFAddOneString (ffstring, reftxt3, FALSE, FALSE, TILDE_IGNORE);
- } else if (review == 4) {
- FFAddOneString (ffstring, reftxt4, FALSE, FALSE, TILDE_IGNORE);
- } else if (review == 5) {
- if (curator == NULL) {
- curator = "NCBI staff";
- }
- FFAddOneString (ffstring, reftxt5, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, curator, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_IGNORE);
- } else if (review == 6) {
- FFAddOneString (ffstring, reftxt6, FALSE, FALSE, TILDE_IGNORE);
- } else if (review == 7) {
- FFAddOneString (ffstring, reftxt7, FALSE, FALSE, TILDE_IGNORE);
- }
- if (review != 5 && curator != NULL) {
- FFAddOneString (ffstring, reftxt5, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, curator, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_IGNORE);
- }
- if (source != NULL) {
- FFAddOneString (ffstring, reftxt8, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, source, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, ").", FALSE, FALSE, TILDE_IGNORE);
- }
- if (i > 0) {
- FFAddOneString (ffstring, reftxt0, FALSE, FALSE, TILDE_IGNORE);
-
- for (tmp = urf->data.ptrvalue; tmp != NULL; tmp = tmp->next) {
- is_accn = TRUE;
- for (u = tmp->data.ptrvalue; u != NULL; u = u->next) {
- oip = u->label;
- if (StringCmp (oip->str, "accession") == 0) break;
- if (StringCmp (oip->str, "name") == 0) {
- is_accn = FALSE;
- break;
- }
- }
- if (u == NULL) continue;
- accn = (CharPtr) u->data.ptrvalue;
- if (StringHasNoText (accn)) continue;
- if (is_accn && GetWWW(ajp) ) {
- FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "val=", accn, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, accn, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString (ffstring, accn, FALSE, FALSE, TILDE_IGNORE);
- }
- if (tmp->next != NULL) {
- ufp = tmp->next;
- if (ufp->next != NULL) {
- FFAddOneString (ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString (ffstring, " and ", FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
- FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_EXPAND);
- }
-}
-
-static CharPtr GetGenomeBuildNumber (
- UserObjectPtr uop
-)
-
-{
- ObjectIdPtr oip;
- CharPtr str;
- UserFieldPtr ufp;
-
- if (uop == NULL) return NULL;
- if ((oip = uop->type) == NULL) return NULL;
- if (StringCmp (oip->str, "GenomeBuild") != 0) return NULL;
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (StringCmp(oip->str, "NcbiAnnotation") == 0) {
- if (ufp->choice == 1) { /* string */
- str = ufp->data.ptrvalue;
- if (! StringHasNoText (str)) return str;
- }
- } else if (StringCmp (oip->str, "Annotation") == 0) {
- if (ufp->choice == 1) { /* string */
- str = ufp->data.ptrvalue;
- if (! StringHasNoText (str)) {
- if (StringNICmp (str, "NCBI build ", 11) == 0) {
- if (! StringHasNoText (str + 11)) {
- return (str + 11);
- }
- }
- }
- }
- }
- }
- return NULL;
-}
-
-
-static CharPtr reftxt11 = "This record is predicted by automated computational analysis. This record is derived from an annotated genomic sequence";
-static CharPtr reftxt12 = "using gene prediction method:";
-
-static void FindModelEvidenceUop (
- UserObjectPtr uop,
- Pointer userdata
-)
-
-{
- ObjectIdPtr oip;
- UserObjectPtr PNTR uopp;
-
- if (uop == NULL || userdata == NULL) return;
- uopp = (UserObjectPtr PNTR) userdata;
- oip = uop->type;
- if (oip == NULL) return;
- if (StringCmp (oip->str, "ModelEvidence") == 0) {
- *uopp = uop;
- }
-}
-
-static Boolean DoGetAnnotationComment (
- BioseqPtr bsp,
- CharPtr PNTR namep,
- CharPtr PNTR methodp,
- BoolPtr mrnaEv,
- BoolPtr estEv
-)
-
-{
- SeqMgrDescContext dcontext;
- CharPtr method = NULL;
- UserObjectPtr moduop;
- CharPtr name = NULL;
- ObjectIdPtr oip;
- SeqDescrPtr sdp;
- UserFieldPtr ufp;
- UserObjectPtr uop;
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
- while (sdp != NULL) {
- uop = (UserObjectPtr) sdp->data.ptrvalue;
- if (uop != NULL) {
- moduop = NULL;
- VisitUserObjectsInUop (uop, (Pointer) &moduop, FindModelEvidenceUop);
- if (moduop != NULL) {
- oip = moduop->type;
- if (oip != NULL && StringCmp(oip->str, "ModelEvidence") == 0) {
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (oip == NULL) continue;
- if (StringCmp(oip->str, "Contig Name") == 0) {
- name = (CharPtr) ufp->data.ptrvalue;
- } else if (StringCmp(oip->str, "Method") == 0) {
- method = (CharPtr) ufp->data.ptrvalue;
- } else if (StringCmp(oip->str, "mRNA") == 0) {
- *mrnaEv = TRUE;
- } else if (StringCmp(oip->str, "EST") == 0) {
- *estEv = TRUE;
- }
- }
- }
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
- }
- if (StringHasNoText (name)) return FALSE;
- *namep = name;
- if (! StringHasNoText (method)) {
- *methodp = method;
- }
- return TRUE;
-}
-
-static Boolean GetAnnotationComment (
- BioseqPtr bsp,
- CharPtr PNTR namep,
- CharPtr PNTR methodp,
- BoolPtr mrnaEv,
- BoolPtr estEv
-)
-
-{
- SeqFeatPtr cds;
-
- if (DoGetAnnotationComment (bsp, namep, methodp, mrnaEv, estEv)) return TRUE;
- if (ISA_aa (bsp->mol)) {
- cds = SeqMgrGetCDSgivenProduct (bsp, NULL);
- if (cds != NULL) {
- bsp = BioseqFindFromSeqLoc (cds->location);
- if (bsp != NULL) {
- return DoGetAnnotationComment (bsp, namep, methodp, mrnaEv, estEv);
- }
- }
- }
- return FALSE;
-}
-
-static void FindGeneFeat (
- SeqFeatPtr sfp,
- Pointer userdata
-)
-
-{
- SeqFeatPtr PNTR sfpp;
-
- if (sfp->data.choice != SEQFEAT_GENE) return;
- sfpp = (SeqFeatPtr PNTR) userdata;
- *sfpp = sfp;
-}
-
-static void FindLocusId (
- ValNodePtr dbxref,
- CharPtr locusIDp
-)
-
-{
- DbtagPtr dbt;
- ObjectIdPtr oip;
- ValNodePtr vnp;
-
- for (vnp = dbxref; vnp != NULL; vnp = vnp->next) {
- dbt = (DbtagPtr) vnp->data.ptrvalue;
- if (dbt == NULL) continue;
- if (StringICmp (dbt->db, "LocusID") != 0 && StringICmp (dbt->db, "InterimID") != 0) continue;
- oip = dbt->tag;
- if (oip == NULL) continue;
- if (oip->str != NULL) {
- StringCpy (locusIDp, oip->str);
- } else if (oip->id > 0) {
- sprintf (locusIDp, "%ld", (long) oip->id);
- }
- }
-}
-
-static Boolean GetGeneAndLocus (
- BioseqPtr bsp,
- CharPtr PNTR genep,
- CharPtr locusIDp,
- CharPtr taxIDp
-)
-
-{
- BioSourcePtr biop;
- DbtagPtr dbt;
- SeqMgrDescContext dcontext;
- SeqFeatPtr gene = NULL;
- GeneRefPtr grp;
- ObjectIdPtr oip;
- OrgRefPtr orp;
- SeqDescrPtr sdp;
- SeqEntryPtr sep;
- CharPtr str;
- ValNodePtr syn;
- ValNodePtr vnp;
-
- sep = GetTopSeqEntryForEntityID (bsp->idx.entityID);
- if (sep == NULL) return FALSE;
- VisitFeaturesInSep (sep, (Pointer) &gene, FindGeneFeat);
- if (gene == NULL) return FALSE;
-
- grp = (GeneRefPtr) gene->data.value.ptrvalue;
- if (grp == NULL) return FALSE;
- if (! StringHasNoText (grp->locus)) {
- *genep = grp->locus;
- } else {
- syn = grp->syn;
- if (syn != NULL) {
- str = (CharPtr) syn->data.ptrvalue;
- if (! StringHasNoText (str)) {
- *genep = str;
- }
- }
- }
- FindLocusId (gene->dbxref, locusIDp);
- FindLocusId (grp->db, locusIDp);
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
- if (sdp != NULL) {
- biop = (BioSourcePtr) sdp->data.ptrvalue;
- if (biop != NULL) {
- orp = biop->org;
- if (orp != NULL) {
- for (vnp = orp->db; vnp != NULL; vnp = vnp->next) {
- dbt = (DbtagPtr) vnp->data.ptrvalue;
- if (dbt == NULL) continue;
- if (StringCmp (dbt->db, "taxon") == 0) {
- oip = dbt->tag;
- if (oip == NULL) continue;
- if (oip->str != NULL) {
- StringCpy (taxIDp, oip->str);
- } else if (oip->id > 0) {
- sprintf (taxIDp, "%ld", (long) oip->id);
- }
- }
- }
- }
- }
- }
-
- if (genep == NULL || StringHasNoText (locusIDp)) return FALSE;
-
- return TRUE;
-}
-
-static CharPtr reftxt21 = "NCBI contigs are derived from assembled genomic sequence data.";
-
-static CharPtr reftxt22 = "Features on this sequence have been produced for build ";
-static CharPtr reftxt23 = " of the NCBI's genome annotation";
-
-static CharPtr nsAreGapsString = "The strings of n's in this record represent gaps between contigs, and the length of each string corresponds to the length of the gap.";
-
-static Boolean IsTpa (
- BioseqPtr bsp,
- Boolean has_tpa_assembly,
- BoolPtr isRefSeqP
-)
-
-{
- DbtagPtr dbt;
- Boolean has_bankit = FALSE;
- Boolean has_genbank = FALSE;
- Boolean has_gi = FALSE;
- Boolean has_local = FALSE;
- Boolean has_refseq = FALSE;
- Boolean has_smart = FALSE;
- Boolean has_tpa = FALSE;
- SeqIdPtr sip;
-
- if (bsp == NULL || bsp->id == NULL) return FALSE;
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- switch (sip->choice) {
- case SEQID_LOCAL :
- has_local = TRUE;
- break;
- case SEQID_GENBANK :
- case SEQID_EMBL :
- case SEQID_DDBJ :
- has_genbank = TRUE;
- break;
- case SEQID_OTHER :
- has_refseq = TRUE;
- if (isRefSeqP != NULL) {
- *isRefSeqP = TRUE;
- }
- break;
- case SEQID_GI :
- has_gi = TRUE;
- break;
- case SEQID_TPG :
- case SEQID_TPE :
- case SEQID_TPD :
- has_tpa = TRUE;
- break;
- case SEQID_GENERAL :
- dbt = (DbtagPtr) sip->data.ptrvalue;
- if (dbt != NULL) {
- if (StringICmp (dbt->db, "BankIt") == 0) {
- has_bankit = TRUE;
- }
- if (StringICmp (dbt->db, "TMSMART") == 0) {
- has_smart = TRUE;
- }
- }
- break;
- default :
- break;
- }
- }
-
- if (has_genbank) return FALSE;
- if (has_tpa) return TRUE;
- if (has_refseq) return FALSE;
- if (has_bankit && has_tpa_assembly) return TRUE;
- if (has_smart && has_tpa_assembly) return TRUE;
- if (has_gi) return FALSE;
- if (has_local && has_tpa_assembly) return TRUE;
-
- return FALSE;
-}
-
-static CharPtr GetStrForTpaOrRefSeqHist (
- BioseqPtr bsp
-)
-
-{
- Boolean accn;
- Char buf [64];
- DbtagPtr dbt;
- Int4 gi;
- ValNodePtr head = NULL;
- SeqHistPtr hist;
- SeqIdPtr id;
- Boolean isRefSeq = FALSE;
- Boolean minus1;
- Boolean minus2;
- SeqAlignPtr salp;
- SeqAlignPtr salptmp;
- SeqIdPtr sip;
- Int4 start;
- Int4 stop;
- CharPtr str;
- Char tmp [80];
-
- hist = bsp->hist;
- if (hist != NULL && hist->assembly != NULL) {
- salp = SeqAlignListDup (hist->assembly);
- AlnMgr2IndexLite (salp);
- AlnMgr2SortAlnSetByNthRowPos (salp, 1);
- salptmp = (SeqAlignPtr) (salp->segs);
- while (salptmp != NULL) {
- AlnMgr2GetNthSeqRangeInSA (salptmp, 1, &start, &stop);
- sip = AlnMgr2GetNthSeqIdPtr (salptmp, 2);
- if (sip != NULL) {
- id = NULL;
- accn = FALSE;
- if (sip->choice == SEQID_GI) {
- gi = (Int4) sip->data.intvalue;
- if (GetAccnVerFromServer (gi, buf)) {
- accn = TRUE;
- } else {
- id = GetSeqIdForGI (gi);
- }
- } else {
- id = SeqIdDup (sip);
- }
- if (id != NULL || accn) {
- if (head == NULL) {
- if (isRefSeq) {
- ValNodeCopyStr (&head, 0, "REFSEQ_SPAN PRIMARY_IDENTIFIER PRIMARY_SPAN COMP");
- } else {
- ValNodeCopyStr (&head, 0, "TPA_SPAN PRIMARY_IDENTIFIER PRIMARY_SPAN COMP");
- }
- }
- if (id != NULL) {
- SeqIdWrite (id, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
- if (id->choice == SEQID_GENERAL) {
- dbt = (DbtagPtr) id->data.ptrvalue;
- if (dbt != NULL && StringICmp (dbt->db, "ti") == 0) {
- StringCpy (buf, "TI");
- SeqIdWrite (id, buf + 2, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 3);
- }
- }
- }
- sprintf (tmp, "~%ld-%ld ",
- (long) (start + 1), (long) (stop + 1));
- /*
- i = 39 - StringLen (buf);
- if (i > 0) {
- tmp [i] = '\0';
- } else {
- tmp [21] = '\0';
- }
- */
- tmp [21] = '\0';
- StringCat (buf, " ");
- buf [18] = '\0';
- StringCat (tmp, buf);
- AlnMgr2GetNthSeqRangeInSA (salptmp, 2, &start, &stop);
- sprintf (buf, " %ld-%ld ",
- (long) (start + 1), (long) (stop + 1));
- buf [21] = '\0';
- StringCat (tmp, buf);
- minus1 = (Boolean) (AlnMgr2GetNthStrand (salptmp, 1) == Seq_strand_minus);
- minus2 = (Boolean) (AlnMgr2GetNthStrand (salptmp, 2) == Seq_strand_minus);
- if (minus1 || minus2) {
- if (! (minus1 && minus2)) {
- StringCat (tmp, "c");
- }
- }
- ValNodeCopyStr (&head, 0, tmp);
- }
- SeqIdFree (id);
- }
- SeqIdFree (sip);
- salptmp = salptmp->next;
- }
- SeqAlignFree (salp);
- }
-
- if (head == NULL) return NULL;
-
- str = MergeValNodeStrings (head);
- ValNodeFreeData (head);
-
- return str;
-}
-
-static CharPtr tpaString = "THIRD PARTY ANNOTATION DATABASE: This TPA record uses data from DDBJ/EMBL/GenBank ";
-
-static CharPtr GetStrForTPA (
- UserObjectPtr uop,
- BioseqPtr bsp
-)
-
-{
- Char ch;
- UserFieldPtr curr;
- SeqHistPtr hist;
- Int2 i;
- Char id [41];
- Boolean isRefSeq = FALSE;
- Int2 j;
- size_t len;
- ObjectIdPtr oip;
- CharPtr ptr;
- CharPtr str;
- CharPtr tmp;
- UserFieldPtr ufp;
-
- if (uop == NULL) return NULL;
- if ((oip = uop->type) == NULL) return NULL;
- if (StringCmp (oip->str, "TpaAssembly") != 0) return NULL;
- if (bsp == NULL) return NULL;
- hist = bsp->hist;
- if (hist != NULL && hist->assembly != NULL) return NULL;
- if (! IsTpa (bsp, TRUE, &isRefSeq)) return NULL;
- if (isRefSeq) return NULL;
-
- len = StringLen (tpaString) + StringLen ("entries ") + StringLen ("and ") + 5;
- i = 0;
- for (curr = uop->data; curr != NULL; curr = curr->next) {
- if (curr->choice != 11) continue;
- for (ufp = curr->data.ptrvalue; ufp != NULL; ufp = ufp->next) {
- if (ufp->choice != 1) continue;
- oip = ufp->label;
- if (oip == NULL || StringICmp (oip->str, "accession") != 0) continue;
- str = (CharPtr) ufp->data.ptrvalue;
- if (StringHasNoText (str)) continue;
- len += StringLen (str) + 2;
- i++;
- }
- }
- if (i == 0) return NULL;
-
- ptr = (CharPtr) MemNew (len);
- if (ptr == NULL) return NULL;
- StringCpy (ptr, tpaString);
- if (i > 1) {
- StringCat (ptr, "entries ");
- } else {
- StringCat (ptr, "entry ");
- }
-
- j = 0;
- for (curr = uop->data; curr != NULL; curr = curr->next) {
- if (curr->choice != 11) continue;
- for (ufp = curr->data.ptrvalue; ufp != NULL; ufp = ufp->next) {
- if (ufp->choice != 1) continue;
- oip = ufp->label;
- if (oip == NULL || StringICmp (oip->str, "accession") != 0) continue;
- str = (CharPtr) ufp->data.ptrvalue;
- if (StringHasNoText (str)) continue;
- StringNCpy_0 (id, str, sizeof (id));
- tmp = id;
- ch = *tmp;
- while (ch != '\0') {
- if (IS_LOWER (ch)) {
- *tmp = TO_UPPER (ch);
- }
- tmp++;
- ch = *tmp;
- }
- if (j == i - 1 && i > 1) {
- StringCat (ptr, " and ");
- } else if (j > 0) {
- StringCat (ptr, ", ");
- }
- StringCat (ptr, id);
- j++;
- }
- }
-
- return ptr;
-}
-
-static CharPtr GetStrForGenome (
- UserObjectPtr uop,
- BioseqPtr bsp
-)
-
-{
- ObjectIdPtr oip;
-
- if (uop == NULL) return NULL;
- if ((oip = uop->type) == NULL) return NULL;
- if (StringCmp (oip->str, "GenomeInfo") != 0) return NULL;
-
- /* !!! need to implement !!! */
-
- return NULL;
-}
-
-static void AddPrimaryBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- BaseBlockPtr bbp = NULL;
- BioseqPtr bsp;
- SeqMgrDescContext dcontext;
- GBSeqPtr gbseq;
- Boolean has_tpa_assembly = FALSE;
- SeqHistPtr hist;
- Boolean isRefSeq = FALSE;
- ObjectIdPtr oip;
- SeqDescrPtr sdp;
- CharPtr str;
- UserObjectPtr uop;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
- asp = awp->asp;
- if (asp == NULL) return;
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
- while (sdp != NULL) {
- uop = (UserObjectPtr) sdp->data.ptrvalue;
- if (uop != NULL) {
- oip = uop->type;
- if (oip != NULL) {
- if (StringCmp (oip->str, "TpaAssembly") == 0) {
- has_tpa_assembly = TRUE;
- }
- }
- }
- if (has_tpa_assembly) {
- sdp = NULL;
- } else {
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
- }
- }
-
- if (! IsTpa (bsp, has_tpa_assembly, &isRefSeq)) return;
- hist = bsp->hist;
- if (hist == NULL || hist->assembly == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- str = GetStrForTpaOrRefSeqHist (bsp);
- if (str != NULL) {
-
- bbp = (BaseBlockPtr) Asn2gbAddBlock (awp, PRIMARY_BLOCK, sizeof (BaseBlock));
- if (bbp != NULL) {
-
- if (has_tpa_assembly) {
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- }
-
- FFStartPrint (ffstring, awp->format, 0, 12, "PRIMARY", 12, 5, 5, "PR", TRUE);
-
- FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "PR");
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- gbseq->primary = StringSave (str);
- }
- }
- MemFree (str);
- }
-
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddCommentBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- size_t acclen;
- IntAsn2gbJobPtr ajp;
- BioseqPtr bsp;
- Char buf [128];
- CommentBlockPtr cbp = NULL;
- Char ch;
- Boolean didGenome = FALSE;
- Boolean didRefTrack = FALSE;
- Boolean didTPA = FALSE;
- DbtagPtr dbt;
- SeqMgrDescContext dcontext;
- DeltaSeqPtr dsp;
- Boolean estEv = FALSE;
- SeqMgrFeatContext fcontext;
- Boolean first = TRUE;
- GBBlockPtr gbp;
- CharPtr geneName = NULL;
- CharPtr genomeBuildNumber = NULL;
- Int4 gi = 0;
- CommentBlockPtr gsdbcbp = NULL;
- Int4 gsdbid = 0;
- Boolean has_gaps = FALSE;
- Boolean hasRefTrackStatus = FALSE;
- SeqHistPtr hist;
- Boolean is_collab = FALSE;
- Boolean is_other = FALSE;
- Boolean is_tpa = FALSE;
- Boolean is_wgs = FALSE;
- SeqLitPtr litp;
- ObjectIdPtr localID = NULL;
- Char locusID [32];
- CharPtr method = NULL;
- MolInfoPtr mip;
- Boolean mrnaEv = FALSE;
- CharPtr name = NULL;
- Boolean okay;
- BioseqPtr parent;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp;
- Boolean showGBBSource = FALSE;
- SeqIdPtr sip;
- CharPtr str;
- Char taxID [32];
- TextSeqIdPtr tsip;
- UserObjectPtr uop;
- CharPtr wgsaccn = NULL;
- CharPtr wgsname = NULL;
- StringItemPtr ffstring = NULL;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
- while (sdp != NULL) {
- uop = (UserObjectPtr) sdp->data.ptrvalue;
- if (uop != NULL) {
- str = GetStatusForRefTrack (uop);
- if (str != NULL) {
- hasRefTrackStatus = TRUE;
- }
- if (genomeBuildNumber == NULL) {
- genomeBuildNumber = GetGenomeBuildNumber (uop);
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
- }
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_OTHER) {
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
-
- if (tsip != NULL) {
- is_other = TRUE;
- if (StringNCmp (tsip->accession, "NC_", 3) == 0) {
- if (! StringHasNoText (genomeBuildNumber)) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, "GENOME ANNOTATION ", FALSE, FALSE, TILDE_IGNORE);
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString (ffstring, "<a href=", ref_link, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, ": ", FALSE, FALSE, TILDE_IGNORE);
-
- FFAddOneString (ffstring, reftxt22, FALSE, FALSE, TILDE_EXPAND);
- FFAddOneString (ffstring, genomeBuildNumber, FALSE, FALSE, TILDE_EXPAND);
- FFAddOneString (ffstring, reftxt23, FALSE, FALSE, TILDE_EXPAND);
-
- FFAddOneString (ffstring, " [see ", FALSE, FALSE, TILDE_EXPAND);
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString (ffstring, "<a href=", doc_link, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, "documentation", FALSE, FALSE, TILDE_IGNORE);
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
-
- FFAddOneString (ffstring, "].", FALSE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
-
- } else if (StringNCmp(tsip->accession, "NT_", 3) == 0 || StringNCmp(tsip->accession, "NW_", 3) == 0) {
-
- if (! hasRefTrackStatus) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, "GENOME ANNOTATION ", FALSE, FALSE, TILDE_IGNORE);
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString (ffstring, "<a href=", ref_link, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, ": ", FALSE, FALSE, TILDE_IGNORE);
-
- if (! StringHasNoText (genomeBuildNumber)) {
- FFAddOneString (ffstring, reftxt22, FALSE, FALSE, TILDE_EXPAND);
- FFAddOneString (ffstring, genomeBuildNumber, FALSE, FALSE, TILDE_EXPAND);
- FFAddOneString (ffstring, reftxt23, FALSE, FALSE, TILDE_EXPAND);
-
- FFAddOneString (ffstring, " [see ", FALSE, FALSE, TILDE_EXPAND);
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString (ffstring, "<a href=", doc_link, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, "documentation", FALSE, FALSE, TILDE_IGNORE);
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
-
- FFAddOneString (ffstring, "].", FALSE, FALSE, TILDE_EXPAND);
- } else {
-
- FFAddOneString (ffstring, reftxt21, TRUE, FALSE, TILDE_EXPAND);
-
- FFAddOneString (ffstring, "~Also see:~ ", FALSE, FALSE, TILDE_EXPAND);
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString (ffstring, "<a href=", doc_link, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, "Documentation", FALSE, FALSE, TILDE_IGNORE);
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
-
- FFAddOneString (ffstring, " of NCBI's Annotation Process~ ", FALSE, FALSE, TILDE_EXPAND);
- }
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
-
- } else if (StringNCmp(tsip->accession, "XP_", 3) == 0 ||
- StringNCmp(tsip->accession, "XM_", 3) == 0 ||
- StringNCmp(tsip->accession, "XR_", 3) == 0 ||
- StringNCmp(tsip->accession, "ZP_", 3) == 0) {
-
- name = NULL;
- method = NULL;
- mrnaEv = FALSE;
- estEv = FALSE;
- if (GetAnnotationComment (bsp, &name, &method, &mrnaEv, &estEv)) {
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, "MODEL ", FALSE, FALSE, TILDE_IGNORE);
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString (ffstring, "<a href=", ref_link, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, ": ", FALSE, FALSE, TILDE_IGNORE);
-
- FFAddTextToString (ffstring, NULL, reftxt11, " (", FALSE, FALSE, TILDE_IGNORE);
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString (ffstring, "<a href=", nt_link, name, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, name, FALSE, FALSE, TILDE_IGNORE);
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
-
- FFAddOneString (ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
-
- if (method != NULL) {
- FFAddOneString (ffstring, " ", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, reftxt12, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, " ", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, method, FALSE, FALSE, TILDE_IGNORE);
- }
-
- if (mrnaEv || estEv) {
- FFAddOneString (ffstring, ", supported by ", FALSE, FALSE, TILDE_IGNORE);
- if (mrnaEv && estEv) {
- FFAddOneString (ffstring, "mRNA and EST ", FALSE, FALSE, TILDE_IGNORE);
- } else if (mrnaEv) {
- FFAddOneString (ffstring, "mRNA ", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString (ffstring, "EST ", FALSE, FALSE, TILDE_IGNORE);
- }
- geneName = NULL;
- locusID [0] = '\0';
- taxID [0] = '\0';
- if ( GetWWW(ajp) && GetGeneAndLocus (bsp, &geneName, locusID, taxID)) {
- FFAddTextToString (ffstring, "<a href=", ev_link, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString (ffstring, "contig=", name, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString (ffstring, "&gene=", geneName, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString (ffstring, "&lid=", locusID, NULL, FALSE, FALSE, TILDE_IGNORE);
- if (! StringHasNoText (taxID)) {
- FFAddTextToString (ffstring, "&taxid=", taxID, NULL, FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, ">", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, "evidence", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString (ffstring, "evidence", FALSE, FALSE, TILDE_IGNORE);
- }
- }
-
- FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_IGNORE);
-
- FFAddOneString (ffstring, "~Also see:~ ", FALSE, FALSE, TILDE_EXPAND);
-
- if ( GetWWW(ajp) ) {
- FFAddTextToString (ffstring, "<a href=", doc_link, ">", FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddOneString (ffstring, "Documentation", FALSE, FALSE, TILDE_IGNORE);
- if ( GetWWW(ajp) ) {
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
- }
-
- FFAddOneString (ffstring, " of NCBI's Annotation Process~ ", FALSE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
- } else {
- if (StringLen (tsip->accession) == 15) {
- is_wgs = TRUE;
- if (StringCmp (tsip->accession + 9, "000000") == 0) {
- wgsaccn = tsip->accession;
- wgsname = tsip->name; /* master accession has 8 zeroes, name has project version plus 6 zeroes */
- }
- }
- }
- }
-
- } else if (sip->choice == SEQID_TPG || sip->choice == SEQID_TPE || sip->choice == SEQID_TPD) {
-
- is_tpa = TRUE;
-
- } else if (sip->choice == SEQID_GENBANK || sip->choice == SEQID_EMBL || sip->choice == SEQID_DDBJ) {
-
- is_collab = TRUE;
-
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL && tsip->accession != NULL) {
- acclen = StringLen (tsip->accession);
- if (acclen == 12) {
- is_wgs = TRUE;
- if (StringCmp (tsip->accession + 6, "000000") == 0) {
- wgsaccn = tsip->accession;
- wgsname = tsip->name; /* master accession has 8 zeroes, name has project version plus 6 zeroes */
- }
- } else if (acclen == 13) {
- is_wgs = TRUE;
- if (StringCmp (tsip->accession + 6, "0000000") == 0) {
- wgsaccn = tsip->accession;
- wgsname = tsip->name; /* master accession has 9 zeroes, name has project version plus 7 zeroes */
- }
- } else if (ajp->newSourceOrg && StringLen (tsip->accession) == 6) {
- ch = tsip->accession [0];
- if (ch == 'J' || ch == 'K' || ch == 'L' || ch == 'M') {
- showGBBSource = TRUE;
- }
- }
- }
-
- } else if (sip->choice == SEQID_GENERAL) {
- dbt = (DbtagPtr) sip->data.ptrvalue;
-
- /* show GSDB sequence identifier */
-
- if (dbt != NULL && StringCmp (dbt->db, "GSDB") == 0 && dbt->tag != NULL) {
- gsdbcbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (gsdbcbp != NULL) {
- gsdbcbp->first = first;
-
- /* string will be created after we know if there are additional comments */
-
- gsdbid = dbt->tag->id;
- first = FALSE;
- }
- }
-
- } else if (sip->choice == SEQID_GI) {
- gi = (Int4) sip->data.intvalue;
-
- } else if (sip->choice == SEQID_LOCAL) {
- localID = (ObjectIdPtr) sip->data.ptrvalue;
- }
- }
-
- if (localID != NULL) {
- if (is_tpa || is_collab) {
- if (awp->mode == SEQUIN_MODE || awp->mode == DUMP_MODE) {
- buf [0] = '\0';
- if (! StringHasNoText (localID->str)) {
- if (StringLen (localID->str) < 100) {
- sprintf (buf, "LocalID: %s", localID->str);
- } else {
- sprintf (buf, "LocalID string too large");
- }
- } else {
- sprintf (buf, "LocalID: %ld", (long) localID->id);
- }
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12,5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
- }
- }
-
- /* RefSeq results in allocated comment string */
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
- while (sdp != NULL) {
-
- uop = (UserObjectPtr) sdp->data.ptrvalue;
- if (uop != NULL) {
-
- if (! didTPA) {
- str = GetStrForTPA (uop, bsp);
- if (str != NULL) {
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12,5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- MemFree (str);
- didTPA = TRUE;
- }
- }
-
- if (! ajp->flags.hideBankItComment) {
- str = GetStrForBankit (uop);
- if (str != NULL) {
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, str, TRUE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12,5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- MemFree (str);
- }
- }
-
- if (! didRefTrack) {
- str = GetStatusForRefTrack (uop);
- if (str != NULL) {
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
-
- AddStrForRefTrack (ajp, ffstring, uop);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12,5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- /* do not free static str from GetStatusForRefTrack */
- didRefTrack = TRUE;
- }
- }
-
- if (! didGenome) {
- str = GetStrForGenome (uop, bsp);
- if (str != NULL) {
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- MemFree (str);
- didGenome = TRUE;
- }
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
- }
-
- if (bsp->repr == Seq_repr_delta && bsp->seq_ext_type == 4 && is_wgs) {
- has_gaps = FALSE;
- for (dsp = (DeltaSeqPtr) bsp->seq_ext; dsp; dsp=dsp->next) {
- if (dsp->choice == 2) {
- litp = (SeqLitPtr) dsp->data.ptrvalue;
- if (litp != NULL) {
- if (litp->seq_data == NULL && litp->length > 0) {
- has_gaps = TRUE;
- }
- }
- }
- }
- if (has_gaps) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, nsAreGapsString, TRUE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
- }
-
- /* Seq-hist results in allocated comment string */
-
- hist = bsp->hist;
- if (hist != NULL) {
-
- if (hist->replaced_by_ids != NULL && hist->replaced_by_date != NULL) {
-
- okay = TRUE;
- for (sip = hist->replaced_by_ids; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GI) {
- if (gi == (Int4) sip->data.intvalue) {
- okay = FALSE;
- }
- }
- }
-
- if (okay) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- AddHistCommentString (ajp, ffstring, "[WARNING] On", "this sequence was replaced by a newer version",
- hist->replaced_by_date, hist->replaced_by_ids);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
- }
-
- if (hist->replace_ids != NULL && hist->replace_date != NULL && awp->mode != SEQUIN_MODE) {
-
- okay = TRUE;
- for (sip = hist->replace_ids; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GI) {
- if (gi == (Int4) sip->data.intvalue) {
- okay = FALSE;
- }
- }
- }
-
- if (okay) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- AddHistCommentString (ajp, ffstring, "On", "this sequence version replaced",
- hist->replace_date, hist->replace_ids);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
- }
-
- }
-
- /* just save IDs for comment, maploc, and region descriptors */
-
- /*
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_comment, &dcontext);
- while (sdp != NULL) {
- if (sdp->data.ptrvalue != NULL) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_comment, &dcontext);
- }
- */
-
- /* WGS master comment goes before comment descriptors */
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp != NULL) {
-
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip != NULL) {
- if (mip->tech == MI_TECH_wgs) {
-
- if (wgsname != NULL) {
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- /*
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- */
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- AddWGSMasterCommentString (ffstring,bsp, wgsaccn, wgsname);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
- }
- }
- }
-
- if (showGBBSource) {
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
- if (sdp != NULL) {
- gbp = (GBBlockPtr) sdp->data.ptrvalue;
- if (gbp != NULL && (! StringHasNoText (gbp->source))) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, "Original source text: ", FALSE, FALSE, TILDE_EXPAND);
- FFAddOneString (ffstring, gbp->source, TRUE, TRUE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_comment, &dcontext);
- while (sdp != NULL) {
- if (sdp->data.ptrvalue != NULL) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_comment, &dcontext);
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_maploc, &dcontext);
- while (sdp != NULL) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_maploc, &dcontext);
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_region, &dcontext);
- while (sdp != NULL) {
- if (sdp->data.ptrvalue != NULL) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_region, &dcontext);
- }
-
- /* HTGS results in allocated comment string */
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp != NULL) {
-
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip != NULL) {
- if (mip->completeness != 0 && is_other) {
-
- str = GetMolInfoCommentString (bsp, mip);
-
- if (str != NULL) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddOneString (ffstring, str, TRUE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
-
- }
- if (mip->tech == MI_TECH_htgs_0 ||
- mip->tech == MI_TECH_htgs_1 ||
- mip->tech == MI_TECH_htgs_2) {
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- /*
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- */
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- AddHTGSCommentString (ffstring, bsp, mip);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
-
- } else {
- str = StringForSeqTech (mip->tech);
- if (! StringHasNoText (str)) {
-
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
-
- /*
- cbp->entityID = dcontext.entityID;
- cbp->itemID = dcontext.itemID;
- cbp->itemtype = OBJ_SEQDESC;
- */
- cbp->first = first;
- first = FALSE;
-
- if (cbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- FFAddTextToString (ffstring, "Method: ", str, NULL, TRUE, FALSE, TILDE_EXPAND);
-
- cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
- }
- }
- }
- }
-
- /* add comment features that are full length on appropriate segment */
-
- parent = awp->parent;
- if (parent == NULL) return;
-
- sfp = SeqMgrGetNextFeature (parent, NULL, SEQFEAT_COMMENT, 0, &fcontext);
- while (sfp != NULL) {
- if (fcontext.left == awp->from && fcontext.right == awp->to) {
- cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
- if (cbp != NULL) {
- cbp->entityID = fcontext.entityID;
- cbp->itemID = fcontext.itemID;
- cbp->itemtype = OBJ_SEQFEAT;
- cbp->first = first;
- first = FALSE;
- }
- }
- sfp = SeqMgrGetNextFeature (parent, sfp, SEQFEAT_COMMENT, 0, &fcontext);
- }
-
- if (gsdbcbp != NULL) {
-
- /* if there were no subsequent comments, do not add period after GSDB id */
-
- if (cbp == NULL) {
- sprintf (buf, "GSDB:S:%ld", (long) gsdbid);
- } else {
- sprintf (buf, "GSDB:S:%ld.", (long) gsdbid);
- }
-
- if (gsdbcbp->first) {
- FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
- } else {
- FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
- }
-
- /* CheckEndPunctuation, ConvertDoubleQuotes, and ExpandTildes already taken into account */
-
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
-
- gsdbcbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
- FFRecycleString(ajp, ffstring);
- ffstring = FFGetString(ajp);
- }
-
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddFeatHeaderBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, FEATHEADER_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- if (awp->format == FTABLE_FMT) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- FFStartPrint (ffstring, awp->format, 0, 12, "FEATURES", 21, 5, 0, "FH", TRUE);
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
- FFAddOneString (ffstring, "Key", FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 13 , FALSE);
- }
-
- FFAddOneString (ffstring, "Location/Qualifiers", FALSE, FALSE, TILDE_TO_SPACES);
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
- FFAddNewLine(ffstring);
- FFAddNewLine(ffstring);
- }
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 21, 5, 0, "FH");
- FFRecycleString(ajp, ffstring);
-}
-
-static Uint2 ComputeSourceHash (
- CharPtr key,
- Uint2 start
-)
-
-{
- Uint4 h;
- Uint2 M;
- Uint2 S;
-
- if (key == NULL) return start;
-
- M = 101; /* prime key */
- S = 256; /* size of alphabet */
-
- for (h = start; *key != '\0'; key++) {
- h = (S * h + *key) % M;
- }
-
- return (Uint2) h;
-}
-
-static BaseBlockPtr AddSource (
- Asn2gbWorkPtr awp,
- ValNodePtr PNTR head,
- BioSourcePtr biop,
- CharPtr comment
-)
-
-{
- BaseBlockPtr bbp;
- DbtagPtr dbt;
- Uint2 hash;
- Int2 idx;
- IntSrcBlockPtr isp;
- ObjectIdPtr oip;
- OrgModPtr omp;
- OrgNamePtr onp;
- OrgRefPtr orp;
- SubSourcePtr ssp;
- CharPtr str;
- Uint1 subtype;
- Char tmp [16];
- ValNodePtr vnp;
-
- if (awp == NULL || head == NULL || biop == NULL) return NULL;
-
- bbp = (BaseBlockPtr) MemNew (sizeof (IntSrcBlock));
- if (bbp == NULL) return NULL;
- bbp->blocktype = SOURCEFEAT_BLOCK;
- bbp->section = awp->currsection;
-
- ValNodeAddPointer (head, 0, bbp);
-
- isp = (IntSrcBlockPtr) bbp;
- isp->biop = biop;
- isp->is_focus = biop->is_focus;
- if (biop->origin == 5) {
- isp->is_synthetic = TRUE;
- }
-
- orp = biop->org;
- if (orp == NULL) return bbp;
-
- isp->orghash = ComputeSourceHash (orp->taxname, 0);
- isp->taxname = orp->taxname;
-
- hash = 0;
- onp = orp->orgname;
- if (onp != NULL) {
- if (StringICmp (onp->div, "SYN") == 0) {
- isp->is_synthetic = TRUE;
- }
- isp->omp = onp->mod;
- for (omp = onp->mod; omp != NULL; omp = omp->next) {
- subtype = omp->subtype;
- if (subtype == 253) {
- subtype = 35;
- } else if (subtype == 254) {
- subtype = 36;
- } else if (subtype == 255) {
- subtype = 37;
- }
- if (subtype < 38) {
- idx = orgModToSourceIdx [subtype];
- if (idx > 0 && idx < ASN2GNBK_TOTAL_SOURCE) {
- str = asn2gnbk_source_quals [idx].name;
- hash = ComputeSourceHash (str, hash);
- hash = ComputeSourceHash (omp->subname, hash);
- }
- }
- }
- }
- if (comment != NULL) {
- hash = ComputeSourceHash ("note", hash);
- hash = ComputeSourceHash (comment, hash);
- }
- isp->modhash = hash;
-
- hash = 0;
- for (ssp = biop->subtype; ssp != NULL; ssp = ssp->next) {
- subtype = ssp->subtype;
- if (subtype == 255) {
- subtype = 29;
- }
- if (subtype < 30) {
- idx = subSourceToSourceIdx [subtype];
- if (idx > 0 && idx < ASN2GNBK_TOTAL_SOURCE) {
- str = asn2gnbk_source_quals [idx].name;
- hash = ComputeSourceHash (str, hash);
- hash = ComputeSourceHash (ssp->name, hash);
- }
- }
- }
- isp->subhash = hash;
- isp->ssp = biop->subtype;
-
- hash = 0;
- for (vnp = orp->db; vnp != NULL; vnp = vnp->next) {
- dbt = (DbtagPtr) vnp->data.ptrvalue;
- if (dbt != NULL) {
- hash = ComputeSourceHash (dbt->db, hash);
- oip = dbt->tag;
- if (oip != NULL) {
- if (oip->str != NULL) {
- hash = ComputeSourceHash (oip->str, hash);
- } else {
- sprintf (tmp, "%ld", (long) oip->id);
- hash = ComputeSourceHash (tmp, hash);
- }
- }
- }
- }
- isp->xrfhash = hash;
- isp->vnp = orp->db;
-
- return bbp;
-}
-
-static int LIBCALLBACK SortSourcesByHash (
- VoidPtr ptr1,
- VoidPtr ptr2
-)
-
-{
- Int4 diff;
- IntSrcBlockPtr isp1;
- IntSrcBlockPtr isp2;
- ValNodePtr vnp1;
- ValNodePtr vnp2;
-
- if (ptr1 == NULL || ptr2 == NULL) return 0;
- vnp1 = *((ValNodePtr PNTR) ptr1);
- vnp2 = *((ValNodePtr PNTR) ptr2);
- if (vnp1 == NULL || vnp2 == NULL) return 0;
- isp1 = (IntSrcBlockPtr) vnp1->data.ptrvalue;
- isp2 = (IntSrcBlockPtr) vnp2->data.ptrvalue;
- if (isp1 == NULL || isp2 == NULL) return 0;
-
- if (isp1->is_focus && (! isp2->is_focus)) return -1;
- if (isp2->is_focus && (! isp1->is_focus)) return 1;
-
- diff = isp1->orghash - isp2->orghash;
- if (diff > 0) return -1;
- if (diff < 0) return 1;
-
- diff = isp1->xrfhash - isp2->xrfhash;
- if (diff > 0) return -1;
- if (diff < 0) return 1;
-
- /* sort so that sources with modifiers come first */
-
- diff = isp1->modhash - isp2->modhash;
- if (diff > 0) return -1;
- if (diff < 0) return 1;
-
- diff = isp1->subhash - isp2->subhash;
- if (diff > 0) return -1;
- if (diff < 0) return 1;
-
- /* if all hashes are equal, descriptor comes first */
-
- if (isp1->is_descriptor && (! isp2->is_descriptor)) {
- return -1;
- } else if (isp2->is_descriptor && (! isp1->is_descriptor)) {
- return 1;
- }
-
- return 0;
-}
-
-static int LIBCALLBACK SortSourcesByPos (
- VoidPtr ptr1,
- VoidPtr ptr2
-)
-
-{
- IntSrcBlockPtr isp1;
- IntSrcBlockPtr isp2;
- ValNodePtr vnp1;
- ValNodePtr vnp2;
-
- if (ptr1 == NULL || ptr2 == NULL) return 0;
- vnp1 = *((ValNodePtr PNTR) ptr1);
- vnp2 = *((ValNodePtr PNTR) ptr2);
- if (vnp1 == NULL || vnp2 == NULL) return 0;
- isp1 = (IntSrcBlockPtr) vnp1->data.ptrvalue;
- isp2 = (IntSrcBlockPtr) vnp2->data.ptrvalue;
- if (isp1 == NULL || isp2 == NULL) return 0;
-
- /* descriptor always goes first */
-
- if (isp1->is_descriptor && (! isp2->is_descriptor)) {
- return -1;
- } else if (isp2->is_descriptor && (! isp1->is_descriptor)) {
- return 1;
- }
-
- /* feature with smallest left extreme is first */
-
- if (isp1->left > isp2->left) {
- return 1;
- } else if (isp1->left < isp2->left) {
- return -1;
- }
-
- /* if same left extreme, shortest source feature is first just for flatfile */
-
- if (isp1->right > isp2->right) {
- return 1;
- } else if (isp1->right < isp2->right) {
- return -1;
- }
-
- return 0;
-}
-
-/* */
-/* s_isFuzzyLoc () -- Determines is a location has fuzzy coordinates */
-/* */
-
-static Boolean s_isFuzzyLoc ( SeqLocPtr pLocation )
-{
- SeqIntPtr pIntLocation;
-
- if (pLocation == NULL)
- return FALSE;
-
- if (pLocation->choice != SEQLOC_INT)
- return FALSE;
-
- if (pLocation->data.ptrvalue == NULL)
- return FALSE;
-
- pIntLocation = (SeqIntPtr) pLocation->data.ptrvalue;
-
- if ((pIntLocation->if_from != NULL) && (pIntLocation->if_from->choice == 2))
- return TRUE;
-
- if ((pIntLocation->if_to != NULL) && (pIntLocation->if_to->choice == 2))
- return TRUE;
-
- return FALSE;
-}
-
-static void GetSourcesOnBioseq (
- Asn2gbWorkPtr awp,
- BioseqPtr target,
- BioseqPtr bsp,
- Int4 from,
- Int4 to
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- BioSourcePtr biop;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- Boolean hasNulls;
- Int4 left;
- Boolean loop = FALSE;
- Int2 idx;
- IntSrcBlockPtr isp;
- Int4Ptr ivals;
- SeqLocPtr newloc;
- Boolean noLeft;
- Boolean noRight;
- Int2 numivals;
- Boolean okay;
- Int4 right;
- SeqDescrPtr sdp;
- SeqFeatPtr sfp;
- SeqInt sint;
- SeqIdPtr sip;
- Boolean split;
- Int4 start;
- Int4 stop;
- Uint1 strand;
- ValNode vn;
- ValNodePtr vnp;
-
- if (awp == NULL || target == NULL || bsp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
-
- /* full length loc for descriptors */
-
- sint.from = 0;
- if (ajp->ajp.slp != NULL) {
- sint.to = SeqLocLen (ajp->ajp.slp) - 1;
- } else {
- sint.to = bsp->length - 1;
- }
- sint.strand = Seq_strand_plus;
- sint.id = SeqIdStripLocus (SeqIdDup (SeqIdFindBest (bsp->id, 0)));
- sint.if_from = NULL;
- sint.if_to = NULL;
-
- vn.choice = SEQLOC_INT;
- vn.data.ptrvalue = (Pointer) &sint;
- vn.next = NULL;
-
- /* if SWISS-PROT, may have multiple source descriptors */
-
- if (ISA_aa (bsp->mol)) {
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_SWISSPROT) {
- loop = TRUE;
- }
- }
- }
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
- while (sdp != NULL) {
-
- /* check if descriptor on part already added on segmented bioseq */
-
- okay = TRUE;
- for (vnp = awp->srchead; vnp != NULL && okay; vnp = vnp->next) {
- bbp = (BaseBlockPtr) vnp->data.ptrvalue;
- if (bbp != NULL) {
- if (bbp->entityID == dcontext.entityID &&
- bbp->itemID == dcontext.itemID &&
- bbp->itemtype == OBJ_SEQDESC) {
- okay = FALSE;
- }
- }
- }
-
- if (okay) {
- biop = (BioSourcePtr) sdp->data.ptrvalue;
- bbp = AddSource (awp, &(awp->srchead), biop, NULL);
- if (bbp != NULL) {
-
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
-
- isp = (IntSrcBlockPtr) bbp;
- isp->loc = SeqLocMerge (target, &vn, NULL, FALSE, TRUE, FALSE);
- isp->left = 0;
- isp->right = bsp->length - 1;
- isp->is_descriptor = TRUE;
- }
- }
-
- /* if SWISS-PROT, loop through multiple source descriptors */
-
- if (loop) {
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_source, &dcontext);
- } else {
- sdp = NULL;
- }
- }
-
- SeqIdFree (sint.id);
-
- if ((! awp->contig) || awp->showconsource) {
-
- /* features are indexed on parent if segmented */
-
- bsp = awp->parent;
-
- sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_BIOSRC, 0, &fcontext);
- while (sfp != NULL) {
- ivals = fcontext.ivals;
- numivals = fcontext.numivals;
- if (ivals != NULL && numivals > 0) {
-
- idx = (numivals - 1) * 2;
- start = ivals [idx];
- stop = ivals [idx + 1];
- if (stop >= from && stop <= to && (ajp->ajp.slp == NULL || SeqLocCompare (sfp->location, ajp->ajp.slp) > 0)) {
-
- biop = (BioSourcePtr) sfp->data.value.ptrvalue;
- bbp = AddSource (awp, &(awp->srchead), biop, sfp->comment);
- if (bbp != NULL) {
-
- bbp->entityID = fcontext.entityID;
- bbp->itemID = fcontext.itemID;
- bbp->itemtype = OBJ_SEQFEAT;
-
- isp = (IntSrcBlockPtr) bbp;
- if (sfp->location != NULL && sfp->location->choice == SEQLOC_PNT) {
- isp->loc = AsnIoMemCopy ((Pointer) sfp->location,
- (AsnReadFunc) SeqLocAsnRead,
- (AsnWriteFunc) SeqLocAsnWrite);
- } else if (s_isFuzzyLoc (sfp->location)) {
- isp->loc = AsnIoMemCopy ((Pointer) sfp->location,
- (AsnReadFunc) SeqLocAsnRead,
- (AsnWriteFunc) SeqLocAsnWrite);
- } else if (SeqLocId(sfp->location) == NULL) {
- isp->loc = AsnIoMemCopy ((Pointer) sfp->location,
- (AsnReadFunc) SeqLocAsnRead,
- (AsnWriteFunc) SeqLocAsnWrite);
- } else {
- CheckSeqLocForPartial (sfp->location, &noLeft, &noRight);
- hasNulls = LocationHasNullsBetween (sfp->location);
- isp->loc = SeqLocMerge (target, sfp->location, NULL, FALSE, TRUE, hasNulls);
- SetSeqLocPartial (isp->loc, noLeft, noRight);
- }
- isp->left = fcontext.left;
- isp->right = fcontext.right;
- isp->comment = sfp->comment;
- if (ajp->ajp.slp != NULL) {
- sip = SeqIdParse ("lcl|dummy");
- left = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_LEFT_END);
- right = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_RIGHT_END);
- strand = SeqLocStrand (ajp->ajp.slp);
- split = FALSE;
- newloc = SeqLocReMapEx (sip, ajp->ajp.slp, isp->loc, 0, FALSE, ajp->masterStyle);
- /*
- newloc = SeqLocCopyRegion (sip, isp->loc, bsp, left, right, strand, &split);
- */
- SeqIdFree (sip);
- if (newloc != NULL) {
- A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
- isp->loc = SeqLocFree (isp->loc);
- isp->loc = newloc;
- isp->left = left;
- isp->right = right;
- }
- }
- }
- }
- }
-
- sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_BIOSRC, 0, &fcontext);
- }
- }
-}
-
-static Boolean LIBCALLBACK GetSourcesOnSeg (
- SeqLocPtr slp,
- SeqMgrSegmentContextPtr context
-)
-
-{
- Asn2gbWorkPtr awp;
- BioseqPtr bsp;
- Int4 from;
- SeqLocPtr loc;
- SeqEntryPtr oldscope;
- SeqEntryPtr sep;
- SeqIdPtr sip;
- Int4 to;
-
- if (slp == NULL || context == NULL) return FALSE;
- awp = (Asn2gbWorkPtr) context->userdata;
-
- from = context->cumOffset;
- to = from + context->to - context->from;
-
- sip = SeqLocId (slp);
- if (sip == NULL) {
- loc = SeqLocFindNext (slp, NULL);
- if (loc != NULL) {
- sip = SeqLocId (loc);
- }
- }
- if (sip == NULL) return TRUE;
-
- /* biosource descriptors only on parts within entity */
-
- sep = GetTopSeqEntryForEntityID (awp->entityID);
- oldscope = SeqEntrySetScope (sep);
- bsp = BioseqFind (sip);
- SeqEntrySetScope (oldscope);
-
- if (bsp != NULL) {
- GetSourcesOnBioseq (awp, awp->target, bsp, from, to);
- return TRUE;
- }
-
- /* if we ever want to fetch remote sources, code goes here */
-
-#if 0
- Uint2 entityID;
-
- /* may remote fetch genome component if not already in memory */
-
- bsp = BioseqLockById (sip);
-
- if (bsp == NULL) return TRUE;
-
- entityID = ObjMgrGetEntityIDForPointer (bsp);
-
- if (entityID != awp->entityID) {
-
- /* if segment not packaged in record, may need to feature index it */
-
- if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
- SeqMgrIndexFeatures (entityID, NULL);
- }
-
- /* collect features indexed on the remote bioseq */
-
- from = 0;
- to = bsp->length - 1;
- }
-
- GetSourcesOnBioseq (awp, awp->target, bsp, from, to);
-
- BioseqUnlock (bsp);
-#endif
-
- return TRUE;
-}
-
-/* isIdenticalSource() -- Checks to see if two sources are identical */
-/* by comparing the actual values in the */
-/* fields. This only gets called if the two */
-/* sources hashed the same -- it's a double- */
-/* check since two non-identical things will */
-/* occassionally hash to the same value. */
-
-static Boolean isIdenticalSource (IntSrcBlockPtr isp1, IntSrcBlockPtr isp2)
-{
- OrgModPtr omp1;
- OrgModPtr omp2;
- SubSourcePtr ssp1;
- SubSourcePtr ssp2;
- ValNodePtr vnp1;
- ValNodePtr vnp2;
- ObjectIdPtr oip1;
- ObjectIdPtr oip2;
- DbtagPtr dbt1;
- DbtagPtr dbt2;
-
- if (isp1->is_focus != isp2->is_focus)
- return FALSE;
-
- /* Compare the taxonomy names */
-
- if (StringICmp(isp1->taxname,isp2->taxname) != 0)
- return FALSE;
-
- /* Compare the comment */
-
- if (StringICmp(isp1->comment,isp2->comment) != 0)
- return FALSE;
-
- /* Compare the org mods */
-
- omp1 = isp1->omp;
- omp2 = isp2->omp;
- while (omp1 != NULL && omp2 != NULL)
- {
- if (omp1->subtype != omp2->subtype)
- return FALSE;
- if (StringICmp (omp1->subname, omp2->subname) != 0)
- return FALSE;
- omp1 = omp1->next;
- omp2 = omp2->next;
- }
-
- if (omp1 != NULL || omp2 != NULL)
- return FALSE;
-
- /* Compare the subtypes */
-
- ssp1 = isp1->ssp;
- ssp2 = isp2->ssp;
-
- while (ssp1 != NULL && ssp2 != NULL)
- {
- if (ssp1->subtype != ssp2->subtype)
- return FALSE;
- if (StringICmp(ssp1->name,ssp2->name) != 0)
- return FALSE;
- ssp1 = ssp1->next;
- ssp2 = ssp2->next;
- }
-
- if (ssp1 != NULL || ssp2 != NULL)
- return FALSE;
-
- /* Compare the DB tags */
-
- vnp1 = isp1->vnp;
- vnp2 = isp2->vnp;
-
- while (vnp1 != NULL && vnp2 != NULL)
- {
- dbt1 = (DbtagPtr) vnp1->data.ptrvalue;
- dbt2 = (DbtagPtr) vnp2->data.ptrvalue;
-
- if ((dbt1 != NULL) && (dbt2 != NULL)) {
- if (dbt1->db != dbt2->db)
- return FALSE;
-
- oip1 = dbt1->tag;
- oip2 = dbt2->tag;
- if ((oip1 != NULL) && (oip2 != NULL)) {
- if (oip1->str != NULL) {
- if (StringICmp(oip1->str, oip2->str) != 0)
- return FALSE;
- } else {
- if (oip1->id != oip2->id)
- return FALSE;
- }
- }
- else if (oip1 != NULL)
- return FALSE;
- else if (oip2 != NULL)
- return FALSE;
- }
- else if (dbt1 != NULL)
- return FALSE;
- else if (dbt2 != NULL)
- return FALSE;
-
- vnp1 = vnp1->next;
- vnp2 = vnp2->next;
- }
-
- if (vnp1 != NULL || vnp2 != NULL)
- return FALSE;
-
- /* If it passed all checks, then they */
- /* are the same, so return true. */
-
- return TRUE;
-}
-
-static void CleanupPackedSeqInt (SeqLocPtr location)
-
-{
- SeqLocPtr head = NULL;
- SeqIntPtr loc;
- SeqIntPtr sintp;
- SeqLocPtr slp;
-
- if (location == NULL || location->choice != SEQLOC_PACKED_INT || location->data.ptrvalue == NULL) return;
-
- slp = SeqLocFindNext (location, NULL);
- while (slp != NULL) {
- if (slp->choice == SEQLOC_INT) {
- sintp = (SeqIntPtr) slp->data.ptrvalue;
- if (sintp != NULL) {
- loc = AsnIoMemCopy (sintp, (AsnReadFunc) SeqIntAsnRead,
- (AsnWriteFunc) SeqIntAsnWrite);
- ValNodeAddPointer (&head, SEQLOC_INT, loc);
- }
- }
- slp = SeqLocFindNext (location, slp);
- }
- if (head == NULL) return;
-
- location->data.ptrvalue = SeqLocFree (location->data.ptrvalue);
- location->data.ptrvalue = head;
-
- slp = location->data.ptrvalue;
- if (slp == NULL || slp->next != NULL) return;
- /* here seqloc_packed_int points to a single location element, so no need for seqloc_packed_int parent */
- location->choice = slp->choice;
- location->data.ptrvalue = (Pointer) slp->data.ptrvalue;
- MemFree (slp);
-}
-
-
-static void AddSourceFeatBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- SeqFeatPtr cds;
- SeqMgrFeatContext context;
- BioseqPtr dna;
- SeqLocPtr duploc;
- Boolean excise;
- ValNodePtr head = NULL;
- IntSrcBlockPtr isp;
- IntSrcBlockPtr lastisp;
- IntSrcBlockPtr descrIsp;
- ValNodePtr next;
- ValNodePtr PNTR prev;
- SeqInt sint;
- SeqLocPtr slp;
- CharPtr str;
- BioseqPtr target;
- ValNode vn;
- ValNodePtr vnp;
- Boolean descHasFocus = FALSE;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- /* collect biosources on bioseq */
-
- awp->srchead = NULL;
- GetSourcesOnBioseq (awp, bsp, bsp, awp->from, awp->to);
- target = bsp;
-
- if (bsp->repr == Seq_repr_seg) {
-
- /* collect biosource descriptors on local parts */
-
- SeqMgrExploreSegments (bsp, (Pointer) awp, GetSourcesOnSeg);
- target = awp->target;
- }
-
- if (awp->srchead == NULL && ISA_aa (bsp->mol)) {
-
- /* if protein with no sources, get sources applicable to DNA location of CDS */
-
- cds = SeqMgrGetCDSgivenProduct (bsp, &context);
- if (cds != NULL) {
- dna = BioseqFindFromSeqLoc (cds->location);
- if (dna != NULL) {
- GetSourcesOnBioseq (awp, dna, dna, context.left, context.right);
- target = dna;
- }
- }
- }
-
- head = awp->srchead;
- awp->srchead = NULL;
-
- if (head == NULL) {
- sint.from = 0;
- sint.to = bsp->length - 1;
- sint.strand = Seq_strand_plus;
- sint.id = SeqIdStripLocus (SeqIdDup (SeqIdFindBest (bsp->id, 0)));
- sint.if_from = NULL;
- sint.if_to = NULL;
-
- vn.choice = SEQLOC_INT;
- vn.data.ptrvalue = (Pointer) &sint;
- vn.next = NULL;
-
- FFStartPrint (ffstring, awp->format, 5, 21, NULL, 0, 5, 21, "FT", FALSE);
- FFAddOneString(ffstring, "source", FALSE, FALSE, TILDE_IGNORE);
- FFAddNChar(ffstring, ' ', 21 - 5 - StringLen("source"), FALSE);
-
- str = FlatLoc (ajp, bsp, &vn, (Boolean) (awp->style == MASTER_STYLE));
- if ( GetWWW(ajp) ) {
- FF_www_featloc (ffstring, str);
- } else {
- FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- }
- MemFree (str);
-
- if (ajp->flags.needOrganismQual) {
- FFAddNewLine(ffstring);
- FFAddTextToString (ffstring, "/organism=\"", "unknown", "\"", FALSE, TRUE, TILDE_TO_SPACES);
-#ifdef ASN2GNBK_PRINT_UNKNOWN_ORG
- } else {
- FFAddNewLine(ffstring);
- FFAddTextToString (ffstring, "/organism=\"", "unknown", "\"", FALSE, TRUE, TILDE_TO_SPACES);
-#endif
- }
-
- str = GetMolTypeQual (bsp);
- if (str == NULL) {
- switch (bsp->mol) {
- case Seq_mol_dna :
- str = "unassigned DNA";
- break;
- case Seq_mol_rna :
- str = "unassigned RNA";
- break;
- case Seq_mol_aa :
- break;
- default :
- str = "unassigned DNA";
- break;
- }
- }
- if (str != NULL) {
- FFAddNewLine(ffstring);
- FFAddTextToString (ffstring, "/mol_type=\"", str, "\"", FALSE, TRUE, TILDE_TO_SPACES);
- }
-
- str = FFEndPrint(ajp, ffstring, awp->format, 5, 21, 5, 21, "FT");
-
- bbp = (BaseBlockPtr) Asn2gbAddBlock (awp, SOURCEFEAT_BLOCK, sizeof (IntSrcBlock));
- if (bbp != NULL) {
- bbp->section = awp->currsection;
- bbp->string = str;
- } else {
- MemFree(str);
- }
- FFRecycleString(ajp, ffstring);
- return;
- }
-
- /* sort by hash values */
-
- head = SortValNode (head, SortSourcesByHash);
-
- /* unique sources, excise duplicates from list */
-
- prev = &(head);
- vnp = head;
- lastisp = NULL;
- while (vnp != NULL) {
- excise = FALSE;
- next = vnp->next;
- isp = (IntSrcBlockPtr) vnp->data.ptrvalue;
- if (isp->is_descriptor && isp->is_focus)
- descHasFocus = TRUE;
- if (lastisp != NULL) {
- if (isp != NULL) {
- if (lastisp->is_focus == isp->is_focus &&
- lastisp->orghash == isp->orghash &&
- lastisp->xrfhash == isp->xrfhash) {
-
- /* check for identical modifiers */
-
- if (lastisp->modhash == isp->modhash &&
- lastisp->subhash == isp->subhash) {
-
- excise = isIdenticalSource (isp, lastisp);
-
- /* or modifiers only in lastisp (e.g., on part bioseq) */
-
- } else if (isp->modhash == 0 && isp->subhash == 0) {
- excise = isIdenticalSource (isp, lastisp);
- }
- }
- }
- }
- if (excise) {
- *prev = vnp->next;
- vnp->next = NULL;
-
- /* combine locations of duplicate sources */
-
- if (lastisp != NULL) {
- slp = SeqLocMerge (target, lastisp->loc, isp->loc, FALSE, TRUE, FALSE);
- lastisp->loc = SeqLocFree (lastisp->loc);
- lastisp->loc = slp;
- lastisp->left = MIN (lastisp->left,isp->left);
- lastisp->right = MAX (lastisp->right, isp->right);
- }
-
- /* and remove duplicate source */
-
- SeqLocFree (isp->loc);
- MemFree (isp);
- ValNodeFree (vnp);
-
- } else {
-
- prev = &(vnp->next);
- lastisp = isp;
- }
- vnp = next;
- }
-
- /* Sort again, by location this time */
-
- head = SortValNode (head, SortSourcesByPos);
-
- /* If the descriptor has a focus, then subtract */
- /* out all the other source locations. */
-
- descrIsp = (IntSrcBlockPtr) head->data.ptrvalue; /* Sorted 1st by now */
-
- if ((descHasFocus) && (! descrIsp->is_synthetic)) {
-
- vnp = head;
- duploc = AsnIoMemCopy ((Pointer) descrIsp->loc,
- (AsnReadFunc) SeqLocAsnRead,
- (AsnWriteFunc) SeqLocAsnWrite);
- vnp = vnp->next;
- while (vnp != NULL) {
- isp = (IntSrcBlockPtr) vnp->data.ptrvalue;
- if (SeqLocAinB (descrIsp->loc, isp->loc) >= 0) {
- vnp = NULL; /* break the chain */
- descrIsp->loc = SeqLocFree (descrIsp->loc);
- descrIsp->loc = duploc;
- duploc = NULL;
- } else {
- descrIsp->loc = SeqLocSubtract (descrIsp->loc, isp->loc);
- vnp = vnp->next;
- }
- }
- CleanupPackedSeqInt (descrIsp->loc);
- descrIsp->left = SeqLocStart (descrIsp->loc);
- descrIsp->right = SeqLocStop (descrIsp->loc);
- SeqLocFree (duploc);
- }
-
- /* if features completely subtracted descriptor
- intervals, suppress in release, entrez modes */
-
- if (descrIsp->loc == NULL && ajp->flags.hideEmptySource && head->next != NULL) {
- vnp = head->next;
- head->next = NULL;
- ValNodeFreeData (head);
- head = vnp;
- }
-
- /* finally link into blocks for current section */
-
- ValNodeLink (&(awp->lastblock), head);
- vnp = awp->lastblock;
- if (vnp == NULL) return;
- while (vnp->next != NULL) {
- vnp = vnp->next;
- }
-
- awp->lastblock = vnp;
- if (awp->blockList == NULL) {
- awp->blockList = vnp;
- }
- FFRecycleString(ajp, ffstring);
-}
-
-static Boolean IsCDD (
- SeqFeatPtr sfp
-)
-
-{
- DbtagPtr dbt;
- ValNodePtr vnp;
-
- for (vnp = sfp->dbxref; vnp != NULL; vnp = vnp->next) {
- dbt = (DbtagPtr) vnp->data.ptrvalue;
- if (dbt != NULL && StringCmp (dbt->db, "CDD") == 0) return TRUE;
- }
-
- return FALSE;
-}
-
-static void GetFeatsOnCdsProduct (
- SeqFeatPtr cds,
- BioseqPtr nbsp,
- BioseqPtr pbsp,
- IntAsn2gbJobPtr ajp,
- Asn2gbWorkPtr awp
-)
-
-{
- FeatBlockPtr fbp;
- IntFeatBlockPtr ifp;
- Boolean isRefSeq;
- Int4 lastleft;
- Int4 lastright;
- SeqAnnotPtr lastsap;
- SeqFeatPtr lastsfp;
- SeqLocPtr location;
- SeqLocPtr newloc;
- SeqMgrFeatContext pcontext;
- SeqFeatPtr prt;
- SeqIdPtr sip;
- SeqLocPtr slp;
- Boolean suppress;
-
- if (cds == NULL || ajp == NULL || awp == NULL) return;
- if (nbsp == NULL || pbsp == NULL || (! ISA_aa (pbsp->mol))) return;
-
- if (awp->hideCdsProdFeats) return;
-
- isRefSeq = FALSE;
- for (sip = nbsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_OTHER) {
- isRefSeq = TRUE;
- }
- }
-
- /* explore mat_peptides, sites, etc. */
-
- lastsfp = NULL;
- lastsap = NULL;
- lastleft = 0;
- lastright = 0;
-
- prt = SeqMgrGetNextFeature (pbsp, NULL, 0, 0, &pcontext);
- while (prt != NULL) {
-
- if (pcontext.featdeftype == FEATDEF_REGION ||
- pcontext.featdeftype == FEATDEF_SITE ||
- pcontext.featdeftype == FEATDEF_BOND ||
- pcontext.featdeftype == FEATDEF_mat_peptide_aa ||
- pcontext.featdeftype == FEATDEF_sig_peptide_aa ||
- pcontext.featdeftype == FEATDEF_transit_peptide_aa ||
- (pcontext.featdeftype == FEATDEF_preprotein && isRefSeq)) {
-
- if (awp->hideCddFeats && pcontext.featdeftype == FEATDEF_REGION && IsCDD (prt)) {
-
- /* passing this test prevents mapping of COG CDD region features */
-
- } else if (pcontext.dnaStop >= awp->from && pcontext.dnaStop <= awp->to) {
-
- /* suppress duplicate features (on protein) */
-
- suppress = FALSE;
- if (lastsfp != NULL && lastsap != NULL) {
- if (lastsfp->idx.subtype == prt->idx.subtype &&
- lastleft == pcontext.left &&
- lastright == pcontext.right) {
- if (lastsap == pcontext.sap ||
- (lastsap->desc == NULL && pcontext.sap->desc == NULL)) {
- if (AsnIoMemComp (lastsfp, prt, (AsnWriteFunc) SeqFeatAsnWrite)) {
- suppress = TRUE;
- }
- }
- }
- }
-
- /* make sure feature maps within nucleotide sublocation */
-
- if (! suppress) {
- if (ajp->ajp.slp != NULL) {
- location = aaFeatLoc_to_dnaFeatLoc (cds, prt->location);
- slp = SeqLocMerge (nbsp, location, NULL, FALSE, TRUE, FALSE);
- if (slp != NULL) {
- sip = SeqIdParse ("lcl|dummy");
- newloc = SeqLocReMapEx (sip, ajp->ajp.slp, slp, 0, FALSE, ajp->masterStyle);
- SeqIdFree (sip);
- SeqLocFree (slp);
- if (newloc == NULL) {
- suppress = TRUE;
- }
- SeqLocFree (newloc);
- } else {
- suppress = TRUE;
- }
- SeqLocFree (location);
- }
- }
-
- if (! suppress) {
-
- fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntFeatBlock));
- if (fbp != NULL) {
-
- fbp->entityID = pcontext.entityID;
- fbp->itemID = pcontext.itemID;
- fbp->itemtype = OBJ_SEQFEAT;
- fbp->featdeftype = pcontext.featdeftype;
- ifp = (IntFeatBlockPtr) fbp;
- ifp->mapToNuc = TRUE;
- ifp->mapToProt = FALSE;
- ifp->mapToGen = FALSE;
- ifp->mapToMrna = FALSE;
- ifp->mapToPep = FALSE;
- ifp->firstfeat = awp->firstfeat;
- awp->firstfeat = FALSE;
- }
- }
-
- lastsfp = prt;
- lastsap = pcontext.sap;
- lastleft = pcontext.left;
- lastright = pcontext.right;
-
- }
- }
- prt = SeqMgrGetNextFeature (pbsp, prt, 0, 0, &pcontext);
- }
-}
-
-static Boolean NotEMBLorDDBJ (
- BioseqPtr bsp
-)
-
-{
- SeqIdPtr sip;
-
- if (bsp == NULL) return TRUE;
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_EMBL) return FALSE;
- if (sip->choice == SEQID_DDBJ) return FALSE;
- }
- return TRUE;
-}
-
-static Boolean LIBCALLBACK GetFeatsOnBioseq (
- SeqFeatPtr sfp,
- SeqMgrFeatContextPtr fcontext
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- Asn2gbWorkPtr awp;
- BioseqPtr bsp;
- Char buf [41];
- SeqFeatPtr cds;
- SeqMgrFeatContext cdscontext;
- SeqMgrDescContext dcontext;
- FeatBlockPtr fbp;
- SeqLocPtr firstslp;
- GBQualPtr gbq;
- SeqFeatPtr gene;
- Int4 gi;
- GeneRefPtr grp;
- Boolean juststop = FALSE;
- IntCdsBlockPtr icp;
- Int2 idx;
- IntFeatBlockPtr ifp;
- Int4Ptr ivals;
- Int2 j;
- SeqAnnotPtr lastsap;
- SeqFeatPtr lastsfp;
- SeqLocPtr lastslp;
- SeqLocPtr newloc;
- Int2 numivals;
- Boolean okay;
- SeqEntryPtr oldscope;
- BioseqPtr parent;
- Boolean partial5;
- Boolean partial3;
- ValNodePtr ppr;
- PubdescPtr pdp;
- BioseqPtr prod;
- Boolean pseudo = FALSE;
- SeqDescrPtr sdp;
- SeqEntryPtr sep;
- SeqIdPtr sip;
- SeqLocPtr slp;
- Int4 start;
- Int4 stop;
- TextSeqIdPtr tsip;
- ValNodePtr vnp;
-
- if (sfp == NULL || fcontext == NULL) return FALSE;
- awp = (Asn2gbWorkPtr) fcontext->userdata;
- if (awp == NULL) return FALSE;
- ajp = awp->ajp;
- if (ajp == NULL) return FALSE;
- asp = awp->asp;
- if (asp == NULL) return FALSE;
- bsp = asp->bsp;
- if (bsp == NULL) return FALSE;
-
- if (fcontext->featdeftype == FEATDEF_PUB ||
- fcontext->featdeftype == FEATDEF_NON_STD_RESIDUE ||
- fcontext->featdeftype == FEATDEF_BIOSRC ||
- fcontext->featdeftype == FEATDEF_RSITE ||
- fcontext->featdeftype == FEATDEF_SEQ) return TRUE;
-
- if (ajp->flags.validateFeats &&
- (fcontext->featdeftype == FEATDEF_BAD ||
- fcontext->featdeftype == FEATDEF_virion)) {
- return TRUE;
- }
-
- if (ISA_na (bsp->mol) && fcontext->featdeftype == FEATDEF_HET) return TRUE;
-
- /* check feature customization flags */
-
- if (awp->hideImpFeats && sfp->data.choice == SEQFEAT_IMP) return TRUE;
- if (awp->hideSnpFeats && fcontext->featdeftype == FEATDEF_variation) return TRUE;
- if (awp->hideExonFeats && fcontext->featdeftype == FEATDEF_exon) return TRUE;
- if (awp->hideIntronFeats && fcontext->featdeftype == FEATDEF_intron) return TRUE;
- if (awp->hideMiscFeats && fcontext->featdeftype == FEATDEF_misc_feature) return TRUE;
- if (awp->hideRemImpFeats && sfp->data.choice == SEQFEAT_IMP) {
- if (fcontext->featdeftype != FEATDEF_variation &&
- fcontext->featdeftype != FEATDEF_exon &&
- fcontext->featdeftype != FEATDEF_intron &&
- fcontext->featdeftype != FEATDEF_misc_feature) return TRUE;
- }
- if (ISA_aa (bsp->mol) && fcontext->featdeftype == FEATDEF_REGION &&
- awp->hideCddFeats && IsCDD (sfp)) return TRUE;
-
- /* DDBJ does not want to show gene features */
-
- if (fcontext->seqfeattype == SEQFEAT_GENE && awp->hideGeneFeats) return TRUE;
-
- /* suppress comment features that are full length */
-
- if (fcontext->seqfeattype == SEQFEAT_COMMENT &&
- fcontext->left == awp->from && fcontext->right == awp->to) return TRUE;
-
- ivals = fcontext->ivals;
- numivals = fcontext->numivals;
-
- /* check to see if last interval is on this awp->from - awp->to range */
-
- if (ivals != NULL && numivals > 0) {
- idx = (numivals - 1) * 2;
- start = ivals [idx];
- stop = ivals [idx + 1];
- if (stop < awp->from || stop > awp->to) {
-
- /* may need to map sig_peptide on a different segment */
-
- if (fcontext->seqfeattype == SEQFEAT_CDREGION) {
- sip = SeqLocIdForProduct (sfp->product);
- bsp = BioseqFind (sip);
- GetFeatsOnCdsProduct (sfp, asp->bsp, bsp, ajp, awp);
- }
-
- if (! awp->showAllFeats) return TRUE;
-
- /* if showing one segment, only show features covering this segment */
-
- if (fcontext->right < awp->from || fcontext->left > awp->to) return TRUE;
-
- } else if (fcontext->farloc && NotEMBLorDDBJ (awp->bsp)) {
-
- /* last interval may not have been mapped to bioseq if far */
-
- firstslp = NULL;
- lastslp = NULL;
-
- slp = SeqLocFindNext (sfp->location, NULL);
- while (slp != NULL) {
- if (slp->choice != SEQLOC_NULL) {
- lastslp = slp;
- if (firstslp == NULL) {
- firstslp = slp;
- }
- }
- slp = SeqLocFindNext (sfp->location, slp);
- }
-
- /* !!! EMBL may have different desired behavior on where to map !!! */
-
- if (firstslp != NULL && SeqLocStrand (firstslp) == Seq_strand_minus) {
- slp = firstslp;
- } else {
- slp = lastslp;
- }
-
- if (slp != NULL) {
- sip = SeqLocId (slp);
- if (sip != NULL) {
- bsp = BioseqFindCore (sip);
- if (bsp == NULL || (bsp != awp->parent && bsp != awp->bsp)) {
-
- return TRUE;
- }
- }
- }
- }
- }
-
- /* make sure feature is within sublocation */
-
- if (ajp->ajp.slp != NULL) {
- if (SeqLocCompare (sfp->location, ajp->ajp.slp) == SLC_NO_MATCH) {
- slp = SeqLocMerge (bsp, sfp->location, NULL, FALSE, TRUE, FALSE);
- if (slp == NULL) return TRUE;
- sip = SeqIdParse ("lcl|dummy");
- newloc = SeqLocReMapEx (sip, ajp->ajp.slp, slp, 0, FALSE, ajp->masterStyle);
- SeqIdFree (sip);
- SeqLocFree (slp);
- if (newloc == NULL) return TRUE;
- SeqLocFree (newloc);
- }
- }
-
- /* suppress duplicate features (on nucleotide) */
-
- lastsfp = awp->lastsfp;
- lastsap = awp->lastsap;
- if (lastsfp != NULL && lastsap != NULL) {
- if (lastsfp->idx.subtype == sfp->idx.subtype &&
- awp->lastleft == fcontext->left &&
- awp->lastright == fcontext->right) {
- if (lastsap == fcontext->sap ||
- (lastsap->desc == NULL && fcontext->sap->desc == NULL)) {
- if (AsnIoMemComp (lastsfp, sfp, (AsnWriteFunc) SeqFeatAsnWrite)) {
- return TRUE;
- }
- }
- }
- }
-
- /* if RELEASE_MODE, verify that features have all mandatory qualifiers */
-
- if (ajp->flags.needRequiredQuals) {
- okay = FALSE;
-
- switch (fcontext->featdeftype) {
-
- case FEATDEF_CDS:
- if (ajp->flags.checkCDSproductID) {
- /* non-pseudo CDS must have /product */
- if (sfp->pseudo) {
- pseudo = TRUE;
- }
- grp = SeqMgrGetGeneXref (sfp);
- if (grp == NULL) {
- sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
- oldscope = SeqEntrySetScope (sep);
- gene = SeqMgrGetOverlappingGene (sfp->location, NULL);
- SeqEntrySetScope (oldscope);
- if (gene != NULL) {
- grp = (GeneRefPtr) gene->data.value.ptrvalue;
- if (gene->pseudo) {
- pseudo = TRUE;
- }
- }
- }
- if (grp != NULL && grp->pseudo) {
- pseudo = TRUE;
- }
- if (sfp->location != NULL) {
- if (CheckSeqLocForPartial (sfp->location, &partial5, &partial3)) {
- if (partial5 && (! partial3)) {
- if (SeqLocLen (sfp->location) <= 5) {
- juststop = TRUE;
- }
- }
- }
- }
- if (pseudo || juststop) {
- okay = TRUE;
- } else if (sfp->product != NULL) {
- sip = SeqLocIdForProduct (sfp->product);
- if (sip != NULL) {
- if ((sip->choice == SEQID_GI && sip->data.intvalue > 0) ||
- sip->choice == SEQID_LOCAL) {
- sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
- oldscope = SeqEntrySetScope (sep);
- prod = BioseqFind (sip);
- SeqEntrySetScope (oldscope);
- if (prod != NULL) {
- for (sip = prod->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GENBANK ||
- sip->choice == SEQID_EMBL ||
- sip->choice == SEQID_DDBJ ||
- sip->choice == SEQID_OTHER ||
- sip->choice == SEQID_PATENT ||
- sip->choice == SEQID_TPG ||
- sip->choice == SEQID_TPE ||
- sip->choice == SEQID_TPD) {
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL && (! StringHasNoText (tsip->accession))) {
- if (ValidateAccn (tsip->accession) == 0)
- okay = TRUE;
- }
- }
- }
- } else if (sip->choice == SEQID_GI && sip->data.intvalue > 0) {
- /* RELEASE_MODE requires that /protein_id is an accession */
- gi = sip->data.intvalue;
- if (GetAccnVerFromServer (gi, buf)) {
- okay = TRUE;
- } else {
- sip = GetSeqIdForGI (gi);
- if (sip != NULL) {
- okay = TRUE;
- }
- }
- }
- } else if (sip->choice == SEQID_GENBANK ||
- sip->choice == SEQID_EMBL ||
- sip->choice == SEQID_DDBJ ||
- sip->choice == SEQID_OTHER ||
- sip->choice == SEQID_PATENT ||
- sip->choice == SEQID_TPG ||
- sip->choice == SEQID_TPE ||
- sip->choice == SEQID_TPD) {
- tsip = (TextSeqIdPtr) sip->data.ptrvalue;
- if (tsip != NULL && (! StringHasNoText (tsip->accession))) {
- if (ValidateAccn (tsip->accession) == 0)
- okay = TRUE;
- }
- }
- }
- } else {
- if (sfp->excpt && (! StringHasNoText (sfp->except_text))) {
- if (StringStr (sfp->except_text, "rearrangement required for product") != NULL) {
- okay = TRUE;
- }
- }
- }
- } else {
- okay = TRUE;
- }
- if (! okay) {
- ajp->relModeError = TRUE;
- }
- break;
-
- case FEATDEF_conflict:
- if (sfp->cit == NULL) {
- /* RefSeq allows conflict with accession in comment instead of sfp->cit */
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_OTHER) {
- if (! StringHasNoText (sfp->comment)) {
- okay = TRUE;
- }
- }
- }
- }
- /* continue on to old_sequence */
- case FEATDEF_old_sequence:
- /* conflict and old_sequence require a publication printable on the segment */
- vnp = sfp->cit;
-
- if (vnp != NULL && asp->referenceArray != NULL) {
- for (ppr = vnp->data.ptrvalue; ppr != NULL; ppr = ppr->next) {
- j = MatchRef (ppr, asp->referenceArray, asp->numReferences);
- if (j > 0) {
- okay = TRUE;
- break;
- }
- }
- }
- break;
-
- case FEATDEF_GENE:
- /* gene requires /gene or /locus_tag, but desc or syn can be mapped to /gene */
- grp = (GeneRefPtr) sfp->data.value.ptrvalue;
- if (grp != NULL) {
- if (! StringHasNoText (grp->locus)) {
- okay = TRUE;
- } else if (! StringHasNoText (grp->locus_tag)) {
- okay = TRUE;
- } else if (! StringHasNoText (grp->desc)) {
- okay = TRUE;
- } else {
- vnp = grp->syn;
- if (vnp != NULL) {
- if (! StringHasNoText (vnp->data.ptrvalue)) {
- okay = TRUE;
- }
- }
- }
- }
- break;
-
- case FEATDEF_protein_bind:
- case FEATDEF_misc_binding:
- /* protein_bind or misc_binding require FTQUAL_bound_moiety */
- gbq = sfp->qual;
- while (gbq != NULL) {
- if (StringICmp (gbq->qual, "bound_moiety") == 0 && (! StringHasNoText (gbq->val))) {
- okay = TRUE;
- break;
- }
- gbq = gbq->next;
- }
- break;
-
- case FEATDEF_modified_base:
- /* modified_base requires FTQUAL_mod_base */
- gbq = sfp->qual;
- while (gbq != NULL) {
- if (StringICmp (gbq->qual, "mod_base") == 0 && (! StringHasNoText (gbq->val))) {
- okay = TRUE;
- break;
- }
- gbq = gbq->next;
- }
- break;
-
- default:
- if (fcontext->featdeftype >= FEATDEF_GENE && fcontext->featdeftype < FEATDEF_MAX) {
- okay = TRUE;
- }
- break;
- }
-
- if (okay == FALSE) return TRUE;
- }
-
- /* if RELEASE_MODE, suppress features with location on segmented Bioseq */
-
- if (ajp->flags.suppressSegLoc) {
- bsp = awp->parent;
- if (bsp != NULL && bsp->repr == Seq_repr_seg) {
- slp = SeqLocFindNext (sfp->location, NULL);
- while (slp != NULL) {
- sip = SeqLocId (slp);
- if (sip != NULL) {
- if (SeqIdIn (sip, bsp->id)) return TRUE;
- }
- slp = SeqLocFindNext (sfp->location, slp);
- }
- }
- }
-
- awp->lastsfp = sfp;
- awp->lastsap = fcontext->sap;
- awp->lastleft = fcontext->left;
- awp->lastright = fcontext->right;
-
- if (fcontext->seqfeattype == SEQFEAT_CDREGION) {
- fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
- } else {
- fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntFeatBlock));
- }
- if (fbp == NULL) return TRUE;
-
- fbp->entityID = fcontext->entityID;
- fbp->itemID = fcontext->itemID;
- fbp->itemtype = OBJ_SEQFEAT;
- fbp->featdeftype = fcontext->featdeftype;
- ifp = (IntFeatBlockPtr) fbp;
- ifp->mapToNuc = FALSE;
- ifp->mapToProt = FALSE;
- ifp->mapToGen = FALSE;
- ifp->mapToMrna = FALSE;
- ifp->mapToPep = FALSE;
- ifp->firstfeat = awp->firstfeat;
- awp->firstfeat = FALSE;
- awp->featseen = TRUE;
-
- /* optionally map CDS from cDNA onto genomic */
-
- if (awp->isGPS && ISA_na (bsp->mol) && awp->copyGpsCdsUp &&
- fcontext->featdeftype == FEATDEF_mRNA) {
- sip = SeqLocIdForProduct (sfp->product);
- bsp = BioseqFind (sip);
- if (bsp != NULL && ISA_na (bsp->mol)) {
- cds = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &cdscontext);
- if (cds != NULL) {
- fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
- if (fbp != NULL) {
-
- fbp->entityID = cdscontext.entityID;
- fbp->itemID = cdscontext.itemID;
- fbp->itemtype = OBJ_SEQFEAT;
- fbp->featdeftype = cdscontext.featdeftype;
- ifp = (IntFeatBlockPtr) fbp;
- ifp->mapToNuc = FALSE;
- ifp->mapToProt = FALSE;
- ifp->mapToGen = TRUE;
- ifp->mapToMrna = FALSE;
- ifp->mapToPep = FALSE;
- ifp->firstfeat = awp->firstfeat;
- awp->firstfeat = FALSE;
- }
- }
- }
- }
-
- if (fcontext->seqfeattype != SEQFEAT_CDREGION) return TRUE;
-
- /* if feature table format, do not get features from protein product */
-
- if (awp->format == FTABLE_FMT) return TRUE;
-
- /* if CDS, collect more information from product protein bioseq - may be part */
-
- sip = SeqLocIdForProduct (sfp->product);
- bsp = BioseqFind (sip);
- if (bsp == NULL || (! ISA_aa (bsp->mol))) return TRUE;
-
- ifp->isCDS = TRUE;
- icp = (IntCdsBlockPtr) ifp;
-
- /* first explore pubs to pick up figure and maploc */
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_pub, &dcontext);
- while (sdp != NULL) {
- pdp = (PubdescPtr) sdp->data.ptrvalue;
- if (pdp != NULL) {
- if (icp->fig == NULL) {
- icp->fig = StringSaveNoNull (pdp->fig);
- }
- if (icp->maploc == NULL) {
- icp->maploc = StringSaveNoNull (pdp->maploc);
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_pub, &dcontext);
- }
-
- /* product may be segmented part, and remaining features are indexed on parent */
-
- parent = SeqMgrGetParentOfPart (bsp, NULL);
- if (parent != NULL) {
- bsp = parent;
- }
-
- /* then explore mat_peptides, sites, etc. */
-
- GetFeatsOnCdsProduct (sfp, asp->bsp, bsp, ajp, awp);
-
- return TRUE;
-}
-
-static Boolean LIBCALLBACK GetFeatsOnSeg (
- SeqLocPtr slp,
- SeqMgrSegmentContextPtr context
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbWorkPtr awp;
- BioseqPtr bsp;
- Uint2 entityID;
- Int4 from;
- Int4 left;
- SeqLocPtr loc;
- Int4 right;
- SeqIdPtr sip;
- Int4 to;
-
- if (slp == NULL || context == NULL) return FALSE;
- awp = (Asn2gbWorkPtr) context->userdata;
- if (awp == NULL) return FALSE;
- ajp = awp->ajp;
- if (ajp == NULL) return FALSE;
-
- /* do not fetch outside of desired component */
-
- if (ajp->ajp.slp != NULL) {
- left = GetOffsetInBioseq (ajp->ajp.slp, awp->parent, SEQLOC_LEFT_END);
- right = GetOffsetInBioseq (ajp->ajp.slp, awp->parent, SEQLOC_RIGHT_END);
-
- from = context->cumOffset;
- to = from + context->to - context->from;
-
- if (left > to) return TRUE;
- if (right < from) return TRUE;
- }
-
- from = awp->from;
- to = awp->to;
-
- sip = SeqLocId (slp);
- if (sip == NULL) {
- loc = SeqLocFindNext (slp, NULL);
- if (loc != NULL) {
- sip = SeqLocId (loc);
- }
- }
- if (sip == NULL) return TRUE;
-
- /* may want to remote fetch genome component if not already in memory */
-
- bsp = BioseqLockById (sip);
-
- if (bsp == NULL) return TRUE;
-
- entityID = ObjMgrGetEntityIDForPointer (bsp);
-
- if (entityID != awp->entityID) {
-
- /* if segment not packaged in record, may need to feature index it */
-
- if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
- SeqMgrIndexFeatures (entityID, NULL);
- }
-
- /* collect features indexed on the remote bioseq */
-
- awp->from = 0;
- awp->to = bsp->length - 1;
- }
-
- awp->lastsfp = NULL;
- awp->lastsap = NULL;
- awp->lastleft = 0;
- awp->lastright = 0;
-
- if (context->strand == Seq_strand_minus) {
- SeqMgrExploreFeaturesRev (bsp, (Pointer) awp, GetFeatsOnBioseq, /* awp->slp */ slp, NULL, NULL);
- } else {
- SeqMgrExploreFeatures (bsp, (Pointer) awp, GetFeatsOnBioseq, /* awp->slp */ slp, NULL, NULL);
- }
-
- /* restore original from and to */
-
- awp->from = from;
- awp->to = to;
-
- BioseqUnlock (bsp);
-
- return TRUE;
-}
-
-static void AddFeatureBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BioseqPtr bsp;
- SeqFeatPtr cds;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- FeatBlockPtr fbp;
- SeqFeatPtr gene;
- IntFeatBlockPtr ifp;
- Boolean is_other;
- MolInfoPtr mip;
- SeqFeatPtr mrna;
- SeqFeatPtr prot;
- SeqDescrPtr sdp;
- SeqIdPtr sip;
- SeqLocPtr slp;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->parent;
- if (bsp == NULL) return;
-
- awp->lastsfp = NULL;
- awp->lastsap = NULL;
- awp->lastleft = 0;
- awp->lastright = 0;
-
- /* optionally map gene from genomic onto cDNA */
-
- if (awp->isGPS && ISA_na (bsp->mol) && awp->copyGpsGeneDown) {
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp != NULL && sdp->choice == Seq_descr_molinfo) {
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip != NULL) {
- if (mip->biomol == MOLECULE_TYPE_MRNA) {
- mrna = SeqMgrGetRNAgivenProduct (bsp, NULL);
- if (mrna != NULL) {
- gene = SeqMgrGetOverlappingGene (mrna->location, &fcontext);
- if (gene != NULL && gene->data.choice == SEQFEAT_GENE) {
-
- fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
- if (fbp != NULL) {
-
- fbp->entityID = fcontext.entityID;
- fbp->itemID = fcontext.itemID;
- fbp->itemtype = OBJ_SEQFEAT;
- fbp->featdeftype = fcontext.featdeftype;
- ifp = (IntFeatBlockPtr) fbp;
- ifp->mapToNuc = FALSE;
- ifp->mapToProt = FALSE;
- ifp->mapToGen = FALSE;
- ifp->mapToMrna = TRUE;
- ifp->mapToPep = FALSE;
- ifp->isCDS = TRUE;
- ifp->firstfeat = awp->firstfeat;
- awp->firstfeat = FALSE;
- }
- }
- }
- }
- }
- }
- }
-
- if (awp->farFeatsSuppress) {
-
- if (bsp->repr == Seq_repr_seg || bsp->repr == Seq_repr_delta) {
-
- /* if farFeatsSuppress first collect features on remote segments in MASTER_STYLE */
-
- SeqMgrExploreSegments (bsp, (Pointer) awp, GetFeatsOnSeg);
- }
- }
-
- if ((! awp->farFeatsSuppress) || (! awp->featseen)) {
-
- /* reminder - features on near parts are indexed on segmented Bioseq */
-
- slp = ajp->ajp.slp;
- if (slp != NULL && SeqLocStrand (slp) == Seq_strand_minus) {
- SeqMgrExploreFeaturesRev (bsp, (Pointer) awp, GetFeatsOnBioseq, awp->slp, NULL, NULL);
- } else {
- SeqMgrExploreFeatures (bsp, (Pointer) awp, GetFeatsOnBioseq, awp->slp, NULL, NULL);
- }
- }
-
- if (awp->format == GENPEPT_FMT && ISA_aa (bsp->mol)) {
- cds = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
- if (cds != NULL && cds->data.choice == SEQFEAT_CDREGION) {
-
- fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
- if (fbp != NULL) {
-
- fbp->entityID = fcontext.entityID;
- fbp->itemID = fcontext.itemID;
- fbp->itemtype = OBJ_SEQFEAT;
- fbp->featdeftype = fcontext.featdeftype;
- ifp = (IntFeatBlockPtr) fbp;
- ifp->mapToNuc = FALSE;
- ifp->mapToProt = TRUE;
- ifp->mapToGen = FALSE;
- ifp->mapToMrna = FALSE;
- ifp->mapToPep = FALSE;
- ifp->isCDS = TRUE;
- ifp->firstfeat = awp->firstfeat;
- awp->firstfeat = FALSE;
- }
- }
- prot = SeqMgrGetPROTgivenProduct (bsp, &fcontext);
- if (prot != NULL && prot->data.choice == SEQFEAT_PROT) {
-
- is_other = FALSE;
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_OTHER) {
- is_other = TRUE;
- }
- }
-
- /* for RefSeq records or GenBank not release_mode */
- if (is_other || (! ajp->flags.forGbRelease)) {
-
- fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
- if (fbp != NULL) {
-
- fbp->entityID = fcontext.entityID;
- fbp->itemID = fcontext.itemID;
- fbp->itemtype = OBJ_SEQFEAT;
- fbp->featdeftype = fcontext.featdeftype;
- ifp = (IntFeatBlockPtr) fbp;
- ifp->mapToNuc = FALSE;
- ifp->mapToProt = FALSE;
- ifp->mapToGen = FALSE;
- ifp->mapToMrna = FALSE;
- ifp->mapToPep = TRUE;
- ifp->firstfeat = awp->firstfeat;
- awp->firstfeat = FALSE;
- }
- }
- }
- }
-
- if (awp->onlyNearFeats) return;
- if (awp->nearFeatsSuppress && awp->featseen) return;
-
- if (! awp->farFeatsSuppress) {
-
- if (bsp->repr == Seq_repr_seg || bsp->repr == Seq_repr_delta) {
-
- /* if not farFeatsSuppress now collect features on remote segments in MASTER_STYLE */
-
- SeqMgrExploreSegments (bsp, (Pointer) awp, GetFeatsOnSeg);
- }
- }
-}
-
-static void AddWGSBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Char buf [80];
- SeqMgrDescContext dcontext;
- CharPtr first = NULL;
- CharPtr last = NULL;
- ObjectIdPtr oip;
- SeqDescrPtr sdp;
- UserFieldPtr ufp;
- UserObjectPtr uop;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if ( ajp == NULL ) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) return;
-
- bbp = Asn2gbAddBlock (awp, WGS_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
- while (sdp != NULL) {
- uop = (UserObjectPtr) sdp->data.ptrvalue;
- if (uop != NULL) {
- oip = uop->type;
- if (oip != NULL && StringICmp (oip->str, "WGSProjects") == 0) {
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (oip == NULL || oip->str == NULL || ufp->choice != 1) continue;
- if (StringICmp (oip->str, "WGS_accession_first") == 0) {
- first = (CharPtr) ufp->data.ptrvalue;
- } else if (StringICmp (oip->str, "WGS_accession_last") == 0) {
- last = (CharPtr) ufp->data.ptrvalue;
- }
- }
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
- }
-
- FFStartPrint (ffstring, awp->format, 0, 12, "WGS", 12, 0, 0, NULL, FALSE);
-
- if (first != NULL && last != NULL) {
-
- if ( GetWWW(ajp) ) {
- if (StringCmp (first, last) != 0) {
- FFAddTextToString(ffstring, "<a href=", link_wgs, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "db=Nucleotide&cmd=Search&term=", first, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, ":", last, "[ACCN]>", FALSE, FALSE, TILDE_IGNORE);
- sprintf (buf, "%s-%s", first, last);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_TO_SPACES);
- } else {
- FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "val=", first, ">", FALSE, FALSE, TILDE_IGNORE);
- sprintf (buf, "%s", first);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_TO_SPACES);
- }
- } else {
- if (StringCmp (first, last) != 0) {
- sprintf (buf, "%s-%s", first, last);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- } else {
- sprintf (buf, "%s", first);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- }
- }
- }
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 0, 0, NULL);
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddGenomeBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- CharPtr accn;
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- SeqMgrDescContext dcontext;
- Boolean first = TRUE;
- CharPtr moltype;
- ObjectIdPtr oip;
- SeqDescrPtr sdp;
- UserFieldPtr ufp;
- UserObjectPtr uop;
- UserFieldPtr urf;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if ( ajp == NULL ) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) return;
-
- bbp = Asn2gbAddBlock (awp, GENOME_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- FFStartPrint (ffstring, awp->format, 0, 12, "GENOME", 12, 0, 0, NULL, FALSE);
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
- while (sdp != NULL) {
- uop = (UserObjectPtr) sdp->data.ptrvalue;
- if (uop != NULL) {
- oip = uop->type;
- if (oip != NULL && StringICmp (oip->str, "GenomeProject") == 0) {
- for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (oip == NULL || oip->str == NULL || ufp->choice != 11) continue;
- if (StringICmp (oip->str, "Chromosome") != 0) continue;
- accn = NULL;
- moltype = NULL;
- for (urf = (UserFieldPtr) ufp->data.ptrvalue; urf != NULL; urf = urf->next) {
- oip = urf->label;
- if (oip == NULL || oip->str == NULL || urf->choice != 1) continue;
- if (StringICmp (oip->str, "accession") == 0) {
- accn = (CharPtr) urf->data.ptrvalue;
- } else if (StringICmp (oip->str, "Moltype") == 0) {
- moltype = (CharPtr) urf->data.ptrvalue;
- }
- }
- if (! StringHasNoText (accn)) {
- if (! first) {
- FFAddNewLine(ffstring);
- }
- first = FALSE;
- FFAddOneString (ffstring, accn, FALSE, FALSE, TILDE_IGNORE);
- if (! StringHasNoText (moltype)) {
- FFAddTextToString (ffstring, " (", moltype, ")", FALSE, FALSE, TILDE_TO_SPACES);
- }
- }
- }
- }
- }
- sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
- }
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 0, 0, NULL);
- FFRecycleString(ajp, ffstring);
-}
-
-static void AddBasecountBlock (
- Asn2gbWorkPtr awp,
- CharPtr bases
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Int4 base_count [5];
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Char buf [80];
- Char ch;
- Int2 i;
- Int4 len;
- StringItemPtr ffstring;
- CharPtr ptr;
- CharPtr str;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, BASECOUNT_BLOCK, sizeof (BaseBlock));
-
- if (bases == NULL || ajp->ajp.slp != NULL) return;
- len = bsp->length;
- for (i = 0; i < 5; i++) {
- base_count [i] = 0;
- }
-
- ptr = bases;
- ch = *ptr;
- while (ch != '\0') {
- ch = TO_UPPER (ch);
- switch (ch) {
- case 'A' :
- (base_count [0])++;
- break;
- case 'C' :
- (base_count [1])++;
- break;
- case 'G' :
- (base_count [2])++;
- break;
- case 'T' :
- (base_count [3])++;
- break;
- default :
- (base_count [4])++;
- break;
- }
- ptr++;
- ch = *ptr;
- }
-
- if (awp->format == GENBANK_FMT || awp->format == GENPEPT_FMT) {
-
- if (base_count [4] == 0) {
- sprintf (buf, "%7ld a%7ld c%7ld g%7ld t",
- (long) base_count [0], (long) base_count [1],
- (long) base_count [2], (long) base_count [3]);
- } else {
- sprintf (buf, "%7ld a%7ld c%7ld g%7ld t%7ld others",
- (long) base_count [0], (long) base_count [1],
- (long) base_count [2], (long) base_count [3],
- (long) base_count [4]);
- }
-
- } else if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
-
- sprintf (buf, "Sequence %ld BP; %ld A; %ld C; %ld G; %ld T; %ld other;",
- (long) len,
- (long) base_count [0], (long) base_count [1],
- (long) base_count [2], (long) base_count [3],
- (long) base_count [4]);
- }
-
- ffstring = FFGetString (ajp);
- if ( ffstring == NULL ) return;
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
- FFAddOneString(ffstring, "XX\n", FALSE, FALSE, TILDE_IGNORE);
- }
- FFStartPrint (ffstring, awp->format, 0, 0, "BASE COUNT", 12, 5, 5, "SQ", FALSE);
- FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
- str = FFEndPrint(ajp, ffstring, awp->format, 12, 0, 5, 5, "SQ");
- FFRecycleString(ajp, ffstring);
-
- bbp->string = StringSave (str);
-}
-
-static void AddOriginBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BaseBlockPtr bbp;
- BioseqPtr bsp;
- Char buf [67];
- SeqMgrDescContext dcontext;
- GBBlockPtr gbp;
- SeqDescrPtr sdp;
- StringItemPtr ffstring;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) return;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return;
-
- bbp = Asn2gbAddBlock (awp, ORIGIN_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- if (awp->format == GENBANK_FMT || awp->format == GENPEPT_FMT) {
-
- buf [0] = '\0';
-
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
- if (sdp != NULL) {
- gbp = (GBBlockPtr) sdp->data.ptrvalue;
- if (gbp != NULL && (! StringHasNoText (gbp->origin))) {
- StringNCpy_0 (buf, gbp->origin, sizeof (buf));
- bbp->entityID = dcontext.entityID;
- bbp->itemID = dcontext.itemID;
- bbp->itemtype = OBJ_SEQDESC;
- }
- }
-
- FFStartPrint (ffstring, awp->format, 0, 12, "ORIGIN", 12, 0, 0, NULL, FALSE);
-
- if (! StringHasNoText (buf)) {
- FFAddOneString (ffstring, buf, TRUE, FALSE, TILDE_TO_SPACES);
- }
- }
-
- bbp->string = FFEndPrint(ajp, ffstring, awp->format, 0, 12, 0, 0, NULL);
- FFRecycleString(ajp, ffstring);
-}
-
-#define BASES_PER_BLOCK 1200
-
-static void AddSequenceBlock (
- Asn2gbWorkPtr awp,
- CharPtr bases
-)
-
-{
- IntAsn2gbJobPtr ajp;
- BioseqPtr bsp;
- Int4 i;
- Int4 j;
- Int4 len;
- CharPtr ptr;
- SeqBlockPtr sbp;
- Int4 start;
- Int4 stop;
- CharPtr str;
-
- if (awp == NULL) return;
- ajp = awp->ajp;
- if (ajp == NULL) return;
- bsp = awp->bsp;
- if (bsp == NULL) return;
-
- if (awp->slp != NULL) {
- len = SeqLocLen (awp->slp);
- } else {
- len = bsp->length;
- }
-
- /* if generating GBSeq XML, populate single sequence block */
-
- if (ajp->gbseq) {
- sbp = (SeqBlockPtr) Asn2gbAddBlock (awp, SEQUENCE_BLOCK, sizeof (SeqBlock));
- if (sbp == NULL) return;
-
- sbp->entityID = bsp->idx.entityID;
- sbp->itemID = bsp->idx.itemID;
- sbp->itemtype = OBJ_BIOSEQ;
-
- sbp->start = 0;
- sbp->stop = len;
- return;
- }
-
- /* otherwise populate individual sequence blocks for given range */
-
- ptr = bases;
-
- for (start = 0; start < len; start += BASES_PER_BLOCK) {
- sbp = (SeqBlockPtr) Asn2gbAddBlock (awp, SEQUENCE_BLOCK, sizeof (SeqBlock));
- if (sbp == NULL) continue;
-
- sbp->entityID = bsp->idx.entityID;
- sbp->itemID = bsp->idx.itemID;
- sbp->itemtype = OBJ_BIOSEQ;
-
- stop = start + BASES_PER_BLOCK;
- if (stop >= len) {
- stop = len;
- }
-
- sbp->start = start;
- sbp->stop = stop;
-
- if (ptr != NULL) {
- str = MemNew (sizeof (Char) * (BASES_PER_BLOCK + 2));
- if (str != NULL) {
- sbp->bases = str;
- j = stop - start;
- for (i = 0; i < j; i++) {
- *str = *ptr;
- ptr++;
- str++;
- }
- }
- }
- }
-}
-
-static void AddContigBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- BaseBlockPtr bbp;
-
- if (awp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, CONTIG_BLOCK, sizeof (BaseBlock));
-}
-
-static void AddSlashBlock (
- Asn2gbWorkPtr awp
-)
-
-{
- BaseBlockPtr bbp;
- CharPtr str;
-
- if (awp == NULL) return;
-
- bbp = Asn2gbAddBlock (awp, SLASH_BLOCK, sizeof (BaseBlock));
- if (bbp == NULL) return;
-
- str = MemNew(sizeof(Char) * 4);
- StringNCpy(str, "//\n", 4);
-
- bbp->string = str;
-}
-
/*--------------------------------------------------------*/
/* */
/* s_LocusGetBaseName() - */
@@ -19341,6 +1572,54 @@ static Boolean s_LocusGetBaseName (BioseqPtr parent, BioseqPtr segment, CharPtr
/* ********************************************************************** */
+ static Uint1 fasta_order [NUM_SEQID] = {
+ 33, /* 0 = not set */
+ 20, /* 1 = local Object-id */
+ 15, /* 2 = gibbsq */
+ 16, /* 3 = gibbmt */
+ 30, /* 4 = giim Giimport-id */
+ 10, /* 5 = genbank */
+ 10, /* 6 = embl */
+ 10, /* 7 = pir */
+ 10, /* 8 = swissprot */
+ 15, /* 9 = patent */
+ 20, /* 10 = other TextSeqId */
+ 20, /* 11 = general Dbtag */
+ 255, /* 12 = gi */
+ 10, /* 13 = ddbj */
+ 10, /* 14 = prf */
+ 12, /* 15 = pdb */
+ 10, /* 16 = tpg */
+ 10, /* 17 = tpe */
+ 10 /* 18 = tpd */
+ };
+
+/* DoOneSection builds a single report for one bioseq or segment */
+
+static Asn2gbSectPtr Asn2gbAddSection (
+ Asn2gbWorkPtr awp
+)
+
+{
+ Asn2gbSectPtr asp;
+ ValNodePtr vnp;
+
+ if (awp == NULL) return NULL;
+
+ asp = (Asn2gbSectPtr) MemNew (sizeof (IntAsn2gbSect));
+ if (asp == NULL) return NULL;
+
+ vnp = ValNodeAddPointer (&(awp->lastsection), 0, asp);
+ if (vnp == NULL) return asp;
+
+ awp->lastsection = vnp;
+ if (awp->sectionList == NULL) {
+ awp->sectionList = vnp;
+ }
+
+ return asp;
+}
+
static void LIBCALLBACK SaveGBSeqSequence (
CharPtr sequence,
Pointer userdata
@@ -19358,6 +1637,31 @@ static void LIBCALLBACK SaveGBSeqSequence (
*tmpp = tmp;
}
+static CharPtr CompressNonBases (CharPtr str)
+
+{
+ Char ch;
+ CharPtr dst;
+ CharPtr ptr;
+
+ if (str == NULL || str [0] == '\0') return NULL;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (IS_ALPHA (ch)) {
+ *dst = ch;
+ dst++;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = '\0';
+
+ return str;
+}
+
static CharPtr DoSeqPortStream (
BioseqPtr bsp
)
@@ -19391,9 +1695,39 @@ static CharPtr DoSeqPortStream (
return str;
}
-/* DoOneSection builds a single report for one bioseq or segment */
+static Boolean DeltaLitOnly (
+ BioseqPtr bsp
+)
+
+{
+ ValNodePtr vnp;
+
+ if (bsp == NULL || bsp->repr != Seq_repr_delta) return FALSE;
+ for (vnp = (ValNodePtr)(bsp->seq_ext); vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == 1) return FALSE;
+ }
+ return TRUE;
+}
+
+static Boolean SegHasParts (
+ BioseqPtr bsp
+)
+
+{
+ BioseqSetPtr bssp;
+ SeqEntryPtr sep;
+
+ if (bsp == NULL || bsp->repr != Seq_repr_seg) return FALSE;
+ sep = bsp->seqentry;
+ if (sep == NULL) return FALSE;
+ sep = sep->next;
+ if (sep == NULL || (! IS_Bioseq_set (sep))) return FALSE;
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL && bssp->_class == BioseqseqSet_class_parts) return TRUE;
+ return FALSE;
+}
-static void DoOneSection (
+NLM_EXTERN void DoOneSection (
BioseqPtr target,
BioseqPtr parent,
BioseqPtr bsp,
@@ -19557,11 +1891,11 @@ static void DoOneSection (
/* start exploring and populating paragraphs */
if (awp->format == FTABLE_FMT) {
-
AddFeatHeaderBlock (awp);
if (awp->showRefs) {
AddReferenceBlock (awp, isRefSeq);
}
+ AddSourceFeatBlock (awp);
AddFeatureBlock (awp);
} else {
@@ -19714,6 +2048,7 @@ static void DoOneSection (
(awp->currsection)++;
}
+/* ********************************************************************** */
/*
the following functions handle various kinds of input, all calling
@@ -19855,7 +2190,7 @@ static Boolean LIBCALLBACK FindSegForPart (
return FALSE;
}
-static void DoOneBioseq (
+NLM_EXTERN void DoOneBioseq (
BioseqPtr bsp,
Pointer userdata
)
@@ -20081,3261 +2416,6 @@ static void DoOneBioseqSet (
-static CharPtr goFieldType [] = {
- "", "text string", "go id", "pubmed id", "evidence", NULL
-};
-
-static CharPtr GetGOtext (
- UserFieldPtr topufp
-)
-
-{
- CharPtr evidence = NULL;
- Char gid [32];
- CharPtr goid = NULL;
- Int2 j;
- ObjectIdPtr oip;
- Int4 pmid = 0;
- CharPtr str;
- CharPtr textstr = NULL;
- Char tmp [32];
- UserFieldPtr ufp;
-
- for (ufp = topufp; ufp != NULL; ufp = ufp->next) {
- oip = ufp->label;
- if (oip == NULL) continue;
- for (j = 0; goFieldType [j] != NULL; j++) {
- if (StringICmp (oip->str, goFieldType [j]) == 0) break;
- }
- if (goFieldType [j] == NULL) continue;
- switch (j) {
- case 1 :
- if (ufp->choice == 1) {
- textstr = (CharPtr) ufp->data.ptrvalue;
- }
- break;
- case 2 :
- if (ufp->choice == 1) {
- goid = (CharPtr) ufp->data.ptrvalue;
- } else if (ufp->choice == 2) {
- sprintf (gid, "%ld", (long) (Int4) ufp->data.intvalue);
- goid = (CharPtr) gid;
- }
- break;
- case 3 :
- if (ufp->choice == 2) {
- pmid = (Int4) ufp->data.intvalue;
- }
- break;
- case 4 :
- if (ufp->choice == 1) {
- evidence = (CharPtr) ufp->data.ptrvalue;
- }
- break;
- default :
- break;
- }
- }
- /* if (StringHasNoText (textstr)) return NULL; */
-
- str = (CharPtr) MemNew (StringLen (textstr) + StringLen (goid) + StringLen (evidence) + 50);
- if (str == NULL) return NULL;
-
- StringCpy (str, textstr);
- if (! StringHasNoText (goid)) {
- StringCat (str, " [goid ");
- StringCat (str, goid);
- StringCat (str, "]");
- }
- if (! StringHasNoText (evidence)) {
- StringCat (str, " [evidence ");
- StringCat (str, evidence);
- StringCat (str, "]");
- }
- if (pmid != 0) {
- sprintf (tmp, " [pmid %ld", (long) pmid);
- StringCat (str, tmp);
- StringCat (str, "]");
- }
- TrimSpacesAroundString (str);
-
- return str;
-}
-
-static Boolean DbxrefAlreadyInGeneXref (
- DbtagPtr dbt,
- ValNodePtr dbxref
-)
-
-{
- DbtagPtr gdbt;
- ValNodePtr vnp;
-
- if (dbt == NULL) return FALSE;
-
- for (vnp = dbxref; vnp != NULL; vnp = vnp->next) {
- gdbt = (DbtagPtr) vnp->data.ptrvalue;
- if (gdbt == NULL) continue;
- if (DbtagMatch (dbt, gdbt)) return TRUE;
- }
-
- return FALSE;
-}
-
-/* FormatFeatureblockQuals should not be called directly,
- except from FormatFeatureBlock. It performs no input
- validation. (perhaps it should?) */
-
-static void FormatFeatureBlockQuals (
- StringItemPtr ffstring,
- IntAsn2gbJobPtr ajp,
- Asn2gbFormatPtr afp,
- Asn2gbSectPtr asp,
- BioseqPtr bsp,
- Uint1 featdeftype,
- ValNodePtr gene_syn,
- CharPtr lasttype,
- SeqLocPtr location,
- BioseqPtr prod,
- CharPtr protein_pid_g,
- QualValPtr qvp,
- Int4 left,
- Int4 right,
- Uint1 strand,
- SeqFeatPtr sfp,
- BioseqPtr target,
- Boolean is_other,
- Boolean is_journalscan,
- Boolean is_gps
-)
-
-{
- Boolean add_period;
- CharPtr ascii;
- Int2 ascii_len;
- Boolean at_end = FALSE;
- ByteStorePtr bs;
- Char buf[80];
- Choice cbaa;
- CodeBreakPtr cbp;
- Char ch;
- Uint1 choice;
- Uint1 code = Seq_code_ncbieaa;
- Int4 gi;
- Boolean hadProtDesc = FALSE;
- DbtagPtr dbt;
- UserFieldPtr entry;
- Int4 exp_ev;
- GBQualPtr gbq;
- Int2 i;
- Uint1 idx;
- Boolean isTRNA;
- Int2 j;
- Uint1 jdx;
- Int4 len;
- SeqLocPtr newloc;
- CharPtr notestr;
- Char numbuf [32];
- Int2 numcodons;
- Int2 numsyns;
- ObjectIdPtr oip;
- Boolean okay;
- Boolean only_digits;
- BioseqPtr pbsp;
- ValNodePtr ppr;
- CharPtr prefix;
- CharPtr protein_seq = NULL;
- size_t prtlen;
- CharPtr ptr;
- Uint1 residue;
- SeqCodeTablePtr sctp;
- Int4 sec_str;
- Uint1 seqcode;
- Char seqid [50];
- SeqIntPtr sintp;
- SeqIdPtr sip;
- SeqLocPtr slp;
- Boolean split;
- SeqPortPtr spp;
- CharPtr start;
- CharPtr str;
- Boolean suppress_period;
- CharPtr tmp;
- tRNAPtr trna;
- UserFieldPtr ufp;
- UserObjectPtr uop;
- ValNodePtr vnp;
- StringItemPtr unique;
-
- unique = FFGetString(ajp);
- if ( unique == NULL ) return;
-
- for (i = 0, idx = feat_qual_order [i]; idx != 0; i++, idx = feat_qual_order [i]) {
-
- lasttype = NULL;
- switch (asn2gnbk_featur_quals [idx].qualclass) {
-
- case Qual_class_ignore :
- break;
-
- case Qual_class_string :
- if (! StringHasNoText (qvp [idx].str)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_locus_tag :
- if (! StringHasNoText (qvp [idx].str)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_tilde :
- if (! StringHasNoText (qvp [idx].str)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_EXPAND);
- FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
- FALSE, TRUE, TILDE_EXPAND);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_product :
- if (StringHasNoText (qvp [idx].str) ||
- (ajp->flags.dropIllegalQuals &&
- (! AllowedValQual (featdeftype, FTQUAL_product)))) break;
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- break;
-
- case Qual_class_sgml :
- if (! StringHasNoText (qvp [idx].str)) {
- if (is_journalscan) {
- ascii_len = Sgml2AsciiLen (qvp [idx].str);
- start = ascii = MemNew ((size_t) (10 + ascii_len));
- if (start != NULL) {
- ascii = Sgml2Ascii (qvp [idx].str, ascii, ascii_len + 1);
-
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddTextToString(ffstring, "\"", start, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
-
- MemFree (start);
- }
- } else {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddTextToString(ffstring, "\"", qvp[idx].str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- }
- break;
-
- case Qual_class_boolean :
- if (qvp [idx].ble) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "\n",
- FALSE, TRUE, TILDE_IGNORE);
- }
- break;
-
- case Qual_class_int :
- if (qvp [idx].num > 0) {
- if (idx == FTQUAL_transl_table) {
- sprintf (numbuf, "%ld", (long) qvp [idx].num);
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FF_www_gcode (ajp, ffstring, numbuf);
- } else {
- sprintf (numbuf, "%ld", (long) qvp [idx].num);
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, NULL, numbuf, NULL,
- FALSE, TRUE, TILDE_IGNORE);
- }
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_evidence :
- exp_ev = qvp [idx].num;
- if (exp_ev > 0 && exp_ev <= 2) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, evidenceText [exp_ev], FALSE, TRUE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_valnode :
- for (vnp = qvp[idx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (str != NULL) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddTextToString(ffstring, "\"", str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- }
- break;
-
- case Qual_class_gene_syn :
- /*
- for (vnp = qvp[idx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (str != NULL) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddTextToString(ffstring, "\"", str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- }
- */
- numsyns = 0;
- for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (! StringHasNoText (str)) {
- numsyns++;
- }
- }
- if (numsyns > 0) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- prefix = NULL;
- for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (! StringHasNoText (str)) {
- FFAddTextToString (ffstring, prefix, str, NULL, FALSE, FALSE, TILDE_IGNORE);
- prefix = ", ";
- }
- }
- FFAddOneChar(ffstring, '\"', FALSE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_EC_valnode :
- for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- okay = TRUE;
-
- if (str == NULL) continue;
-
- if (ajp->flags.dropIllegalQuals) {
- tmp = str;
- while (*tmp != '\0' && *tmp == '\"')
- tmp++;
- for (; *tmp != '\0' && *tmp != '\"'; tmp++) {
- if (!IS_DIGIT(*tmp) && *tmp != '.' && *tmp != '-') {
- okay = FALSE;
- }
- }
- }
- if (!okay) continue;
-
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\"', FALSE);
- FF_AddECnumber(ajp, ffstring, str);
- FFAddOneChar(ffstring, '\"', FALSE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_EC_quote :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- okay = TRUE;
- if (gbq->val == NULL) {
- okay = FALSE;
- }
-
- if (ajp->flags.dropIllegalQuals && okay) {
- tmp = gbq->val;
- while (*tmp != '\0' && *tmp == '\"')
- tmp++;
- for (; *tmp != '\0' && *tmp != '\"'; tmp++) {
- if (!IS_DIGIT(*tmp) && *tmp != '.' && *tmp != '-') {
- okay = FALSE;
- }
- }
- }
-
- if (StringHasNoText (gbq->val)) {
- okay = FALSE;
- }
-
- if (okay) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\"', FALSE);
- if (!StringIsJustQuotes (gbq->val)) {
- FF_AddECnumber (ajp, ffstring, gbq->val);
- }
- FFAddOneChar(ffstring, '\"', FALSE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_quote :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, TRUE, TILDE_IGNORE);
- if (!StringIsJustQuotes (gbq->val)) {
- FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_IGNORE);
- }
- FFAddOneChar(ffstring, '\"', FALSE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_noquote :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_label :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- if (ajp->flags.checkQualSyntax) { /* single token, not just numeric */
- str = gbq->val;
- ch = *str;
- only_digits = TRUE;
- while (ch != '\0') {
- if (IS_WHITESP (ch)) break; /* only single token allowed */
- if (! IS_DIGIT (ch)) {
- only_digits = FALSE;
- }
- str++;
- ch = *str;
- }
- if (only_digits) break; /* must not be just numeric */
- }
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_number :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
-
- if (ajp->flags.checkQualSyntax) {
- str = gbq->val;
-
- if ( StringHasNoText (str) )
- break;
- while (!IS_WHITESP (*str) && *str != '\0')
- str++;
- if (! StringHasNoText (str) )
- break;
- }
-
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_paren :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- tmp = StringSave (gbq->val);
- str = tmp;
- len = StringLen (str);
- if (len > 1 && *str == '(' && str [len - 1] == ')' &&
- StringChr (str, ',') != NULL) {
- str++;
- while (! StringHasNoText (str)) {
- ptr = StringChr (str, ',');
- if (ptr == NULL) {
- ptr = StringChr (str, ')');
- }
- if (ptr != NULL) {
- *ptr = '\0';
- ptr++;
- }
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- str = ptr;
- }
- } else {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- MemFree (tmp);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_rpt :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
-
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- tmp = StringSave (gbq->val);
- str = tmp;
- len = StringLen (str);
- if (len > 1 && *str == '(' && str [len - 1] == ')' &&
- StringChr (str, ',') != NULL) {
- str++;
- while (! StringHasNoText (str)) {
- ptr = StringChr (str, ',');
- if (ptr == NULL) {
- ptr = StringChr (str, ')');
- }
- if (ptr != NULL) {
- *ptr = '\0';
- ptr++;
- }
- if ((! ajp->flags.checkQualSyntax) || (StringInStringList (str, validRptString))) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- str = ptr;
- }
- } else {
- if ((! ajp->flags.checkQualSyntax) || (StringInStringList (str, validRptString))) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- }
- MemFree (tmp);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_rpt_unit :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
-
- /* in release_mode, must be of the form 123..4567 or a single-token label,
- or (technically illegal but common) letters and semicolons - NO LONGER CHECKED */
-
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- tmp = StringSave (gbq->val);
- str = tmp;
- len = StringLen (str);
- if (len > 1 && *str == '(' && str [len - 1] == ')' /* && StringChr (str, ',') != NULL */) {
- str++;
- while (! StringHasNoText (str)) {
- ptr = StringChr (str, ',');
- if (ptr == NULL) {
- ptr = StringChr (str, ')');
- }
- if (ptr != NULL) {
- *ptr = '\0';
- ptr++;
- }
- if ((! ajp->flags.checkQualSyntax) || (ValidateRptUnit (str))) {
- TrimSpacesAroundString (str);
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=\"",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\"', FALSE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- str = ptr;
- }
- } else {
- if ((! ajp->flags.checkQualSyntax) || (ValidateRptUnit (str))) {
- TrimSpacesAroundString (str);
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=\"",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\"', FALSE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- }
- MemFree (tmp);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_replace :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '\"', FALSE);
- if (!StringHasNoText (gbq->val)) {
- FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
- }
- FFAddOneChar(ffstring, '\"', FALSE);
- FFAddOneChar(ffstring, '\n', FALSE);
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_consplice :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
-
- if (ajp->flags.checkQualSyntax && (! StringInStringList (gbq->val, validConsSpliceString)) ) {
- break;
- }
-
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_site :
- if (! StringHasNoText (qvp [idx].str)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", qvp[idx].str, "\"", FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_bond :
- if (! StringHasNoText (qvp [idx].str)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", qvp[idx].str, "\"", FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_L_R_B :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
-
- if (ajp->flags.checkQualSyntax && (! StringInStringList (gbq->val, validLRBString)) ) {
- break;
- }
-
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_sec_str :
- sec_str = qvp [idx].num;
- if (sec_str > 0 && sec_str <= 3) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", secStrText[sec_str], "\"",
- FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- break;
-
- case Qual_class_seq_loc :
- slp = qvp [idx].slp;
- if (slp != NULL) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- str = FlatLoc (ajp, target, slp, /* ajp->masterStyle */ FALSE);
- FFAddTextToString(ffstring, "\"", str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- MemFree (str);
- }
- break;
-
- case Qual_class_code_break :
- cbp = qvp [idx].cbp;
- seqcode = 0;
- sctp = NULL;
- while (cbp != NULL) {
- cbaa = cbp->aa;
- switch (cbaa.choice) {
- case 1 :
- seqcode = Seq_code_ncbieaa;
- break;
- case 2 :
- seqcode = Seq_code_ncbi8aa;
- break;
- case 3 :
- seqcode = Seq_code_ncbistdaa;
- break;
- default :
- break;
- }
- if (seqcode != 0) {
- sctp = SeqCodeTableFind (seqcode);
- if (sctp != NULL) {
- slp = NULL;
- while ((slp = SeqLocFindNext (cbp->loc, slp)) != NULL) {
- str = NULL;
- if (ajp->ajp.slp != NULL) {
- sip = SeqIdParse ("lcl|dummy");
- split = FALSE;
- newloc = SeqLocReMapEx (sip, ajp->ajp.slp, slp, 0, FALSE, ajp->masterStyle);
-
- SeqIdFree (sip);
- if (newloc != NULL) {
- A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
- str = FlatLoc (ajp, target, newloc, ajp->masterStyle);
- SeqLocFree (newloc);
- }
- } else {
- str = FlatLoc (ajp, target, slp, ajp->masterStyle);
- }
- if (str != NULL) {
- residue = cbaa.value.intvalue;
- ptr = Get3LetterSymbol (ajp, seqcode, sctp, residue);
- if (ptr == NULL) {
- ptr = "OTHER";
- }
- FFAddOneString(ffstring, "/transl_except=", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "(pos:", str, ",", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "aa:", ptr, ")", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- MemFree (str);
- }
- }
- }
- cbp = cbp->next;
- }
- break;
-
- case Qual_class_anti_codon :
- slp = qvp [FTQUAL_anticodon].slp;
- newloc = NULL;
- if (slp != NULL && ajp->ajp.slp != NULL) {
- sip = SeqIdParse ("lcl|dummy");
- split = FALSE;
- newloc = SeqLocReMapEx (sip, ajp->ajp.slp, slp, 0, FALSE, ajp->masterStyle);
- /*
- newloc = SeqLocCopyRegion (sip, slp, bsp, left, right, strand, &split);
- */
- SeqIdFree (sip);
- slp = newloc;
- if (newloc != NULL) {
- A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
- }
- }
- if (slp != NULL && slp->choice == SEQLOC_INT) {
- sintp = (SeqIntPtr) slp->data.ptrvalue;
- if (sintp != NULL) {
- str = qvp [FTQUAL_trna_aa].str;
- if (! StringHasNoText (str)) {
- sprintf(numbuf, "%ld", (long) sintp->from + 1);
- FFAddTextToString(ffstring, "/anticodon=(pos:", numbuf, "..",
- FALSE, FALSE, TILDE_IGNORE);
- sprintf(numbuf, "%ld", (long) sintp->to + 1);
- FFAddTextToString(ffstring, NULL, numbuf, ",",
- FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "aa:", str, ")",
- FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- }
- }
- if (newloc != NULL) {
- SeqLocFree (newloc);
- }
- break;
-
- case Qual_class_codon :
- gbq = qvp [idx].gbq;
- if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
- if (lasttype == NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
- FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, gbq->val, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_pubset :
- vnp = qvp [idx].vnp;
- if (vnp != NULL && asp->referenceArray != NULL) {
- for (ppr = vnp->data.ptrvalue; ppr != NULL; ppr = ppr->next) {
- j = MatchRef (ppr, asp->referenceArray, asp->numReferences);
- if (j > 0) {
- sprintf (numbuf, "%d", (int) j);
- FFAddTextToString(ffstring, "/citation=[", numbuf, "]",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- }
- }
- break;
-
- case Qual_class_db_xref :
- for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
- buf [0] = '\0';
- dbt = (DbtagPtr) vnp->data.ptrvalue;
- if (dbt != NULL && (! StringHasNoText (dbt->db))) {
- oip = dbt->tag;
- if (oip != NULL) {
-
- okay = TRUE;
- if (StringCmp (dbt->db, "PID") == 0 || StringCmp (dbt->db, "GI") == 0) {
- okay = FALSE;
- }
- if (ajp->flags.dropBadDbxref) {
- /* if RELEASE_MODE, drop unknown dbtag */
- okay = FALSE;
- for (j = 0; legalDbXrefs [j] != NULL; j++) {
- if (StringCmp (dbt->db, legalDbXrefs [j]) == 0) {
- okay = TRUE;
- }
- }
- if (! okay) {
- if (is_gps || is_other) {
- for (j = 0; legalRefSeqDbXrefs [j] != NULL; j++) {
- if (StringCmp (dbt->db, legalRefSeqDbXrefs [j]) == 0) {
- okay = TRUE;
- }
- }
- }
- }
- }
- if (okay && idx == FTQUAL_db_xref && qvp [FTQUAL_gene_xref].vnp != NULL) {
- if (DbxrefAlreadyInGeneXref (dbt, qvp [FTQUAL_gene_xref].vnp)) {
- okay = FALSE;
- }
- }
-
- if (okay) {
- if (! StringHasNoText (oip->str)) {
- if (StringLen (oip->str) < 80) {
- sprintf (buf, "%s", oip->str);
- }
- } else {
- sprintf (buf, "%ld", (long) oip->id);
- }
- }
- }
- }
- if (! StringHasNoText (buf)) {
- if (StringICmp (buf, protein_pid_g) != 0) {
- /* already sorted and uniqued by BasicSeqEntryCleanup, per feature */
- if (StringICmp (dbt->db, "LocusID") == 0 || StringICmp (dbt->db, "InterimID") == 0) {
- if (FFStringSearch (ffstring, dbt->db, 0) >= 0) {
- okay = FALSE;
- }
- }
- if (okay) {
- FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
- FF_www_db_xref(ajp, ffstring, dbt->db, buf);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
- }
- break;
-
-
- case Qual_class_seq_id :
- sip = qvp [idx].sip;
- if (sip != NULL) {
- /* should always be found above for protein_id or transcript_id
- prod = BioseqFind (sip);
- */
- if (prod != NULL) {
- choice = 0;
- for (sip = prod->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GENBANK ||
- sip->choice == SEQID_EMBL ||
- sip->choice == SEQID_DDBJ ||
- sip->choice == SEQID_OTHER ||
- sip->choice == SEQID_TPG ||
- sip->choice == SEQID_TPE ||
- sip->choice == SEQID_TPD) {
- choice = sip->choice;
- if (SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, FALSE, TILDE_IGNORE);
- FF_www_protein_id(ajp, ffstring, seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- }
- } else if (sip->choice == SEQID_GI) {
- if (choice == 0) {
- sprintf (seqid, "%ld", (long) sip->data.intvalue);
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, FALSE, TILDE_IGNORE);
- FF_www_protein_id(ajp, ffstring, seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- }
- sprintf (seqid, "%ld", (long) sip->data.intvalue);
- FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
- FF_www_db_xref(ajp, ffstring, "GI", seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- } else if (sip->choice == SEQID_GENERAL) {
- dbt = (DbtagPtr) sip->data.ptrvalue;
- if (dbt != NULL && StringCmp (dbt->db, "PID") == 0) {
- /*
- oip = dbt->tag;
- if (oip != NULL) {
- if (! StringHasNoText (oip->str)) {
- sprintf (seqid, "PID:%s", oip->str);
- NewContLine ();
- gb_AddString ("/db_xref=\"", seqid, "\"", FALSE, TRUE, TILDE_TO_SPACES);
- }
- }
- */
- } else if (dbt != NULL) {
- pbsp = BioseqFind (sip);
- if (pbsp != NULL && pbsp->id != NULL && pbsp->id->next == NULL) {
- if (SeqIdWrite (sip, seqid, PRINTID_REPORT, sizeof (seqid)) != NULL) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, FALSE, TILDE_IGNORE);
- FF_www_protein_id(ajp, ffstring, seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
- }
- }
- } else {
- if (sip->choice == SEQID_GI) {
- gi = sip->data.intvalue;
- if (GetAccnVerFromServer (gi, seqid)) {
- if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, FALSE, TILDE_IGNORE);
- FF_www_protein_id(ajp, ffstring, seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- } else {
- ajp->relModeError = TRUE;
- }
- } else {
- sip = GetSeqIdForGI(gi);
- if (sip != NULL && SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
- if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, FALSE, TILDE_IGNORE);
- FF_www_protein_id(ajp, ffstring, seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- } else {
- ajp->relModeError = TRUE;
- }
- } else if (! ajp->flags.dropIllegalQuals) {
- sprintf (seqid, "%ld", (long) gi);
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, FALSE, TILDE_IGNORE);
- FF_www_protein_id(ajp, ffstring, seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- } else {
- ajp->relModeError = TRUE;
- }
- }
-
- sprintf (seqid, "%ld", (long) gi);
- FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
- FF_www_db_xref(ajp, ffstring, "GI", seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- } else if (SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
- if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
- FALSE, FALSE, TILDE_IGNORE);
- FF_www_protein_id(ajp, ffstring, seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- } else {
- ajp->relModeError = TRUE;
- }
-
- gi = GetGIForSeqId (sip);
- if (gi > 0) {
- sprintf (seqid, "%ld", (long) gi);
- FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
- FF_www_db_xref(ajp, ffstring, "GI", seqid);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
- }
- break;
-
- case Qual_class_translation :
- if (qvp [idx].ble) {
- if ((prod == NULL && ajp->transIfNoProd) || ajp->alwaysTranslCds) {
- bs = ProteinFromCdRegionEx (sfp, TRUE, FALSE);
- if (bs != NULL) {
- str = BSMerge (bs, NULL);
- bs = BSFree (bs);
- if (str != NULL) {
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- *ptr = TO_UPPER (ch);
- ptr++;
- ch = *ptr;
- }
- prtlen = StringLen (str);
- if (prtlen > 1) {
- if (str [prtlen - 1] == '*') {
- str [prtlen - 1] = '\0';
- }
- }
- if (! StringHasNoText (str)) {
- FFAddTextToString(ffstring, "/translation=\"", str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- MemFree (str);
- }
- } else {
- ajp->relModeError = TRUE;
- }
- } else if (prod != NULL) {
- len = SeqLocLen (sfp->product);
- if (len > 0) {
- if (SeqLocStart (location) == 0 || SeqLocStop (location) == bsp->length - 1) {
- at_end = TRUE;
- }
- str = (CharPtr) MemNew ((size_t) (len + 1) * sizeof (Char));
- protein_seq = str;
- if (ajp->flags.iupacaaOnly) {
- code = Seq_code_iupacaa;
- } else {
- code = Seq_code_ncbieaa;
- }
- spp = SeqPortNewByLoc (sfp->product, code);
- if (spp != NULL) {
- SeqPortSet_do_virtual (spp, TRUE);
- while ((residue = SeqPortGetResidue (spp)) != SEQPORT_EOF) {
- if (! (IS_residue (residue))) continue;
- if (residue == INVALID_RESIDUE) {
- residue = (Uint1) 'X';
- }
- *protein_seq = residue;
- protein_seq++;
- }
- /*
- if (at_end && StringLen (str) < GENPEPT_MIN) {
- str = MemFree (str);
- }
- */
- if (! StringHasNoText (str)) {
- FFAddTextToString(ffstring, "/translation=\"", str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- MemFree (str);
- } else {
- ajp->relModeError = TRUE;
- }
- SeqPortFree (spp);
- } else {
- ajp->relModeError = TRUE;
- }
- }
- }
- break;
-
- case Qual_class_transcription :
- if (qvp [idx].ble) {
- if (ajp->showTranscript) {
- str = GetSequenceByFeature (sfp);
- if (str != NULL) {
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- *ptr = TO_UPPER (ch);
- ptr++;
- ch = *ptr;
- }
- if (! StringHasNoText (str)) {
- FFAddTextToString(ffstring, "/transcription=\"", str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- MemFree (str);
- }
- }
- }
- break;
-
- case Qual_class_peptide :
- if (qvp [idx].ble) {
- if (ajp->showPeptide) {
- str = GetSequenceByFeature (sfp);
- if (str != NULL) {
- ptr = str;
- ch = *ptr;
- while (ch != '\0') {
- *ptr = TO_UPPER (ch);
- ptr++;
- ch = *ptr;
- }
- if (! StringHasNoText (str)) {
- FFAddTextToString(ffstring, "/peptide=\"", str, "\"",
- FALSE, TRUE, TILDE_TO_SPACES);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- MemFree (str);
- }
- }
- }
- break;
-
- case Qual_class_illegal :
- for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (str != NULL) {
- FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_TO_SPACES);
- FFAddNewLine(ffstring);
- }
- }
- break;
-
- case Qual_class_note :
- if (! ajp->flags.goQualsToNote) {
-
- /* in sequin_mode and dump_mode in RefSeq, GO terms show up as separate /qualifiers */
-
- for (j = 0, jdx = feat_note_order [j]; jdx != 0; j++, jdx = feat_note_order [j]) {
- switch (asn2gnbk_featur_quals [jdx].qualclass) {
-
- case Qual_class_go :
- if (qvp [jdx].ufp != NULL) {
- for (entry = qvp [jdx].ufp; entry != NULL; entry = entry->next) {
- if (entry == NULL || entry->choice != 11) break;
- ufp = (UserFieldPtr) entry->data.ptrvalue;
- str = GetGOtext (ufp);
- if (! StringHasNoText (str)) {
- FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[jdx].name, "=",
- FALSE, TRUE, TILDE_IGNORE);
- FFAddTextToString(ffstring, "\"", str, "\"",
- FALSE, FALSE, TILDE_IGNORE);
- FFAddOneChar(ffstring, '\n', FALSE);
- }
- MemFree (str);
- }
- }
- break;
-
- default :
- break;
- }
- }
- }
-
- /*head = NULL;*/
- notestr = NULL;
- prefix = NULL;
- add_period = FALSE;
- suppress_period = FALSE;
- lasttype = NULL;
- isTRNA = TRUE;
-
-
-#ifdef DISPLAY_STRINGS
- s_DisplayQVP (qvp, feat_note_order);
-#endif
- for (j = 0, jdx = feat_note_order [j]; jdx != 0; j++, jdx = feat_note_order [j]) {
- switch (asn2gnbk_featur_quals [jdx].qualclass) {
-
- case Qual_class_string :
- if (! StringHasNoText (qvp [jdx].str)) {
- if (jdx == FTQUAL_figure) {
- if (!IsEllipsis (qvp [jdx].str))
- s_RemovePeriodFromEnd (qvp [jdx].str);
- sprintf (buf, "This sequence comes from %s", qvp [jdx].str);
- FFAddString_NoRedund (unique, prefix, buf, NULL);
- add_period = FALSE;
- } else if (jdx == FTQUAL_maploc) {
- if (!IsEllipsis (qvp [jdx].str))
- s_RemovePeriodFromEnd (qvp [jdx].str);
- sprintf (buf, "Map location %s", qvp [jdx].str);
- FFAddString_NoRedund (unique, prefix, buf, NULL);
- add_period = FALSE;
- } else if (jdx == FTQUAL_seqfeat_note) {
- str = StringSave (qvp [jdx].str);
- TrimSpacesAndJunkFromEnds (str, TRUE);
- if (! IsEllipsis (str))
- add_period = s_RemovePeriodFromEnd (str);
- /* NOTE -- The following function call cleans up some strings
- (i.e., U34661 & U31565) but should be commented back
- in only if the problem can't be fixed upstream of here
-
- s_StringCleanup(str);
-
- */
- FFAddString_NoRedund (unique, prefix, str, NULL);
- MemFree (str);
- if (hadProtDesc) {
- suppress_period = TRUE;
- }
- } else if (jdx == FTQUAL_prot_note) {
- str = StringSave (qvp [jdx].str);
- TrimSpacesAndJunkFromEnds (str, TRUE);
- if (! IsEllipsis (str))
- s_RemovePeriodFromEnd (str);
- FFAddString_NoRedund (unique, prefix, str, NULL);
- MemFree (str);
- add_period = FALSE;
- } else if (jdx == FTQUAL_prot_desc) {
- str = StringSave (qvp [jdx].str);
- TrimSpacesAndJunkFromEnds (str, TRUE);
- if (! IsEllipsis (str))
- add_period = s_RemovePeriodFromEnd (str);
- FFAddString_NoRedund (unique, prefix, str, NULL);
- MemFree (str);
- hadProtDesc = TRUE; /* gi|347886|gb|M96268.1|ECOUBIA */
- } else {
- if (! IsEllipsis (qvp [jdx].str)) {
- s_RemovePeriodFromEnd (qvp [jdx].str);
- }
- FFAddString_NoRedund (unique, prefix, qvp [jdx].str, NULL);
- add_period = FALSE;
- }
- prefix = "; ";
- }
- break;
-
- case Qual_class_locus_tag :
- if (! StringHasNoText (qvp [jdx].str)) {
- if (! IsEllipsis (qvp [jdx].str)) {
- s_RemovePeriodFromEnd (qvp [jdx].str);
- }
- FFAddTextToString (unique, prefix, "locus_tag: ", NULL, FALSE, FALSE, TILDE_IGNORE);
- FFAddString_NoRedund (unique, NULL, qvp [jdx].str, NULL);
- prefix = "; ";
- add_period = FALSE;
- }
- break;
-
- case Qual_class_go :
- if (ajp->flags.goQualsToNote && qvp [jdx].ufp != NULL) {
- for (entry = qvp [jdx].ufp; entry != NULL; entry = entry->next) {
- if (entry == NULL || entry->choice != 11) break;
- ufp = (UserFieldPtr) entry->data.ptrvalue;
- str = GetGOtext (ufp);
- if (! StringHasNoText (str)) {
- if (StringCmp (prefix, "; ") == 0) {
- prefix = ";\n";
- }
- FFAddTextToString (unique, prefix, asn2gnbk_featur_quals[jdx].name, ": ", FALSE, FALSE, TILDE_IGNORE);
- FFAddTextToString(unique, NULL, str, NULL, FALSE, FALSE, TILDE_IGNORE);
- }
- MemFree (str);
- prefix = "; ";
- add_period = FALSE;
- }
- }
- break;
-
- case Qual_class_method :
- if (! StringHasNoText (qvp [jdx].str)) {
- if ( FFEmpty(unique) ) {
- prefix = "Method: ";
- } else {
- prefix = "; Method: ";
- }
- FFAddString_NoRedund (unique, prefix, qvp [jdx].str, NULL);
- prefix = "; ";
- add_period = FALSE;
- }
- break;
-
- case Qual_class_valnode :
- for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (! StringHasNoText (str)) {
- FFAddString_NoRedund (unique, prefix, str, NULL);
- prefix = "; ";
- add_period = FALSE;
- }
- }
- break;
-
- case Qual_class_gene_syn :
- numsyns = 0;
- for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (! StringHasNoText (str)) {
- numsyns++;
- }
- }
- if (numsyns > 0) {
- if (numsyns > 1) {
- FFAddTextToString (unique, prefix, "synonyms: ", NULL, FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddTextToString (unique, prefix, "synonym: ", NULL, FALSE, FALSE, TILDE_IGNORE);
- }
- prefix = NULL;
- for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (! StringHasNoText (str)) {
- FFAddTextToString (unique, prefix, str, NULL, FALSE, FALSE, TILDE_IGNORE);
- prefix = ", ";
- }
- }
- prefix = "; ";
- add_period = FALSE;
- }
- break;
-
- case Qual_class_region :
- if (! StringHasNoText (qvp [jdx].str)) {
- if ( FFEmpty(unique) ) {
- prefix = "Region: ";
- } else {
- prefix = "; Region: ";
- }
-#ifdef ASN2GNBK_STRIP_NOTE_PERIODS
- FFAddTextToString(unique, prefix, qvp [jdx].str, NULL, FALSE, FALSE, TILDE_IGNORE);
-#else
- FFAddString_NoRedund (unique, prefix, qvp [jdx].str, NULL);
-#endif
- prefix = "; ";
- add_period = FALSE;
- }
- break;
-
- case Qual_class_site :
- if (! StringHasNoText (qvp [jdx].str)) {
- FFAddString_NoRedund (unique, prefix, qvp [jdx].str, " site");
- add_period = FALSE;
- prefix = "\n";
- }
- break;
-
- case Qual_class_bond :
- if (! StringHasNoText (qvp [jdx].str)) {
- FFAddString_NoRedund (unique, prefix, qvp [jdx].str, " bond");
- add_period = FALSE;
- prefix = "\n";
- }
- break;
-
- case Qual_class_protnames :
- /* process gene sgml for check against subsequent protein names */
- start = NULL;
- if (! StringHasNoText (qvp [FTQUAL_gene].str)) {
- if (is_journalscan) {
- ascii_len = Sgml2AsciiLen (qvp [FTQUAL_gene].str);
- start = ascii = MemNew ((size_t) (10 + ascii_len));
- if (start != NULL) {
- ascii = Sgml2Ascii (qvp [FTQUAL_gene].str, ascii, ascii_len + 1);
- }
- } else {
- start = StringSaveNoNull (qvp [FTQUAL_gene].str);
- }
- }
- for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if (! StringHasNoText (str)) {
- /* case sensitive - gi|4973426|gb|AF148501.1|AF148501 */
- /* check with and without sgml conversion */
- if (StringCmp (start, str) != 0 &&
- StringCmp (qvp [FTQUAL_gene].str, str) != 0) {
- if (! StringStr (qvp [FTQUAL_prot_desc].str, str)) {
- /* if (NotInGeneSyn (str, gene_syn)) { */
- FFAddString_NoRedund (unique, prefix, str, NULL);
- prefix = "; ";
- add_period = FALSE;
- /* } */
- }
- }
- }
- }
- MemFree (start);
- break;
-
- case Qual_class_xtraprds :
- gbq = qvp [jdx].gbq;
- if (lasttype == NULL && gbq != NULL) {
- lasttype = gbq->qual;
- }
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (! StringHasNoText (gbq->val)) {
- if (StringCmp(gbq->val,qvp[FTQUAL_gene].str) != 0 &&
- StringCmp(gbq->val,qvp[FTQUAL_product].str) != 0) {
- if (!isTRNA || !StringStr (gbq->val, "RNA")) {
- FFAddString_NoRedund (unique, prefix, gbq->val, NULL);
- prefix = "; ";
- add_period = FALSE;
- }
- }
- }
- gbq = gbq->next;
- }
- break;
-
- case Qual_class_its :
- str = qvp [jdx].str;
- if (! StringHasNoText (str)) {
- if (sfp->comment == NULL || StringStr (sfp->comment, str) == NULL) {
- FFAddString_NoRedund (unique, prefix, str, NULL);
- prefix = "; ";
- add_period = FALSE;
- }
- }
- break;
-
- case Qual_class_trna_codons :
- trna = qvp [jdx].trp;
- if (trna) {
- numcodons = ComposeCodonsRecognizedString (trna, numbuf, sizeof (numbuf));
- if (numcodons < 1 || StringHasNoText (numbuf)) {
- } else if (numcodons == 1) {
- isTRNA = TRUE;
- sprintf (buf, "codon recognized: %s", numbuf);
- if (StringStr (qvp [FTQUAL_seqfeat_note].str, buf) == NULL) {
- FFAddString_NoRedund (unique, prefix, "codon recognized: ", numbuf);
- prefix = "; ";
- }
- } else {
- isTRNA = TRUE;
- FFAddString_NoRedund (unique, prefix, "codons recognized: ", numbuf);
- prefix = "; ";
- add_period = FALSE;
- }
- }
- break;
-
- case Qual_class_model_ev :
- uop = qvp [jdx].uop;
- if (uop != NULL) {
- str = NULL;
- VisitUserObjectsInUop (sfp->ext, (Pointer) &str, GetStrFormRNAEvidence);
- if (! StringHasNoText (str)) {
- FFAddString_NoRedund (unique, prefix, str, NULL);
- prefix = "; ";
- add_period = FALSE;
- }
- }
- break;
-
- case Qual_class_seq_id :
- sip = qvp [jdx].sip;
- if (sip != NULL) {
- /* should always be found above for protein_id or transcript_id
- prod = BioseqFind (sip);
- */
- if (prod != NULL) {
- choice = 0;
- for (sip = prod->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GENBANK ||
- sip->choice == SEQID_EMBL ||
- sip->choice == SEQID_DDBJ ||
- sip->choice == SEQID_OTHER ||
- sip->choice == SEQID_TPG ||
- sip->choice == SEQID_TPE ||
- sip->choice == SEQID_TPD) {
- choice = sip->choice;
- if (SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
- FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
- FALSE, FALSE, TILDE_IGNORE);
- }
- } else if (sip->choice == SEQID_GI) {
- if (choice == 0) {
- sprintf (seqid, "%ld", (long) sip->data.intvalue);
- FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
- FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
- } else {
- if (sip->choice == SEQID_GI) {
- gi = sip->data.intvalue;
- if (GetAccnVerFromServer (gi, seqid)) {
- if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
- FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
- FALSE, FALSE, TILDE_IGNORE);
- }
- } else {
- sip = GetSeqIdForGI(gi);
- if (sip != NULL && SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
- if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
- FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
- FALSE, FALSE, TILDE_IGNORE);
- }
- } else if (! ajp->flags.dropIllegalQuals) {
- sprintf (seqid, "%ld", (long) gi);
- FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
- FALSE, FALSE, TILDE_IGNORE);
- }
- }
- } else if (SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
- if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
- FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
- FALSE, FALSE, TILDE_IGNORE);
- }
- }
- }
- prefix = "; ";
- add_period = FALSE;
- }
- break;
-
- default :
- break;
- }
- }
-
- if ( !FFEmpty(unique) ) {
- notestr = FFToCharPtr(unique);
- TrimSpacesAroundString (notestr);
- if (add_period) {
- if (! suppress_period) {
- s_AddPeriodToEnd (notestr);
- }
- }
-
-#ifdef ASN2GNBK_STRIP_NOTE_PERIODS
- if (! IsEllipsis (notestr))
- s_RemovePeriodFromEnd (notestr);
-#endif
-
- FFAddOneString(ffstring, "/note=\"", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, notestr, FALSE, TRUE, TILDE_EXPAND);
- FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
-
- MemFree (notestr);
- /*ValNodeFreeData (head);*/
- }
- break;
-
- default:
- break;
-
- }
- }
- FFRecycleString(ajp, unique);
-}
-
-
-
-static void FF_asn2gb_www_featkey (
- StringItemPtr ffstring,
- CharPtr key,
- SeqLocPtr slp,
- Int4 from,
- Int4 to,
- Uint1 strand,
- Uint4 itemID
-)
-
-{
- BioseqPtr bsp;
- Int4 gi = 0;
- SeqIdPtr sip;
- Boolean is_aa = FALSE;
- Char gi_buf[16];
- Char itemID_buf[16];
-
- bsp = BioseqFindFromSeqLoc (slp);
- if (bsp != NULL) {
- is_aa = ISA_aa (bsp->mol);
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GI) {
- gi = (Int4) sip->data.intvalue;
- }
- }
- }
-
- sprintf(gi_buf, "%ld", (long)gi);
- sprintf(itemID_buf, "%ld", (long)itemID);
-
-
- FFAddOneString(ffstring, "<a href=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, link_feat, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "val=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, gi_buf, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "&itemID=", FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, itemID_buf, FALSE, FALSE, TILDE_IGNORE);
-
-
- if ( is_aa ) {
- FFAddOneString(ffstring, "&view=gpwithparts>", FALSE, FALSE, TILDE_IGNORE);
- } else {
- FFAddOneString(ffstring, "&view=gbwithparts>", FALSE, FALSE, TILDE_IGNORE);
- }
-
- FFAddOneString(ffstring, key, FALSE, FALSE, TILDE_IGNORE);
- FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
-}
-
-
-
-static CharPtr FormatFeatureBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- Uint1 aa;
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- Int2 bondidx;
- BioseqPtr bsp;
- BioseqSetPtr bssp;
- Choice cbaa;
- CodeBreakPtr cbp;
- BioseqPtr cdna;
- SeqFeatPtr cds;
- Char ch;
- Uint1 code = Seq_code_ncbieaa;
- CdRegionPtr crp;
- SeqMgrDescContext dcontext;
- SeqMgrFeatContext fcontext;
- Uint1 featdeftype;
- Uint1 from;
- GBQualPtr gbq;
- GBFeaturePtr gbfeat = NULL;
- GBSeqPtr gbseq;
- SeqMgrFeatContext gcontext;
- ValNodePtr gcp;
- SeqFeatPtr gene = NULL;
- ValNodePtr gene_syn = NULL;
- GeneRefPtr grp;
- IntCdsBlockPtr icp;
- Uint2 idx;
- IntFeatBlockPtr ifp;
- ValNodePtr illegal = NULL;
- ImpFeatPtr imp = NULL;
- IndxPtr index;
- Boolean is_gps = FALSE;
- Boolean is_journalscan = FALSE;
- Boolean is_other = FALSE;
- CharPtr key;
- CharPtr lasttype = NULL;
- Int4 left = -1;
- SeqLocPtr loc = NULL;
- SeqLocPtr location = NULL;
- SeqLocPtr locforgene = NULL;
- SeqMgrFeatContext mcontext;
- MolInfoPtr mip;
- SeqFeatPtr mrna;
- SeqLocPtr newloc;
- Boolean noLeft;
- Boolean noRight;
- SeqMgrFeatContext ocontext;
- SeqEntryPtr oldscope;
- SeqFeatPtr operon = NULL;
- Uint2 partial;
- SeqMgrFeatContext pcontext;
- BioseqPtr prd;
- CharPtr precursor_comment = NULL;
- BioseqPtr prod = NULL;
- SeqFeatPtr prot;
- Boolean protein = FALSE;
- Char protein_pid_g [32];
- ProtRefPtr prp;
- ProtRefPtr prpxref;
- Boolean pseudo = FALSE;
- CharPtr ptr;
- Int2 qualclass;
- QualValPtr qvp;
- Uint1 residue;
- Int4 right = -1;
- RnaRefPtr rrp;
- SeqCodeTablePtr sctp;
- SeqDescrPtr sdp;
- SeqEntryPtr sep;
- Uint1 seqcode;
- SeqFeatPtr sfp;
- Uint1 shift;
- SeqIdPtr sip;
- Int2 siteidx;
- SeqMapTablePtr smtp;
- Boolean split;
- CharPtr str;
- Uint1 strand = Seq_strand_unknown;
- BioseqPtr target;
- CharPtr tmp;
- tRNAPtr trna;
- BioseqPtr unlockme = NULL;
- ValNodePtr vnp;
- StringItemPtr ffstring;
-
-
- if (afp == NULL || bbp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
- target = asp->target;
- bsp = asp->bsp;
- if (target == NULL || bsp == NULL) return NULL;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- qvp = afp->qvp;
- if (qvp == NULL) return NULL;
-
- ffstring = FFGetString(ajp);
- if ( ffstring == NULL ) return NULL;
-
- if (ajp->index) {
- index = &asp->index;
- } else {
- index = NULL;
- }
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- protein_pid_g [0] = '\0';
-
- /* all features in this list are known to be valid for the designated mode */
-
- sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
- if (sfp == NULL) return NULL;
-
- /* may need to map location between aa and dna */
-
- ifp = (IntFeatBlockPtr) bbp;
- if (ifp->mapToNuc) {
-
- /* map mat_peptide, etc., to nucleotide coordinates */
-
- sip = SeqLocId (sfp->location);
- prd = BioseqFind (sip);
- cds = SeqMgrGetCDSgivenProduct (prd, NULL);
- CheckSeqLocForPartial (sfp->location, &noLeft, &noRight);
- location = aaFeatLoc_to_dnaFeatLoc (cds, sfp->location);
- SetSeqLocPartial (location, noLeft, noRight);
- locforgene = location;
- loc = location;
-
- } else if (ifp->mapToProt) {
-
- /* map CDS to protein product coordinates */
-
- sip = SeqLocIdForProduct (sfp->product);
- prd = BioseqFind (sip);
- cds = SeqMgrGetCDSgivenProduct (prd, NULL);
- location = dnaLoc_to_aaLoc (cds, sfp->location, TRUE, NULL, FALSE);
- SetSeqLocPartial (location, FALSE, FALSE);
- locforgene = sfp->location;
- loc = location;
-
- } else if (ifp->mapToGen) {
-
- /* map CDS from cDNA to genomic Bioseq */
-
- cdna = BioseqFindFromSeqLoc (sfp->location);
- mrna = SeqMgrGetRNAgivenProduct (cdna, &mcontext);
- CheckSeqLocForPartial (sfp->location, &noLeft, &noRight);
- location = productLoc_to_locationLoc (mrna, sfp->location);
- SetSeqLocPartial (location, noLeft, noRight);
- locforgene = location;
- loc = location;
-
- } else if (ifp->mapToMrna) {
-
- /* map gene from genomic to cDNA Bioseq */
-
- sep = SeqMgrGetSeqEntryForData (bsp);
- location = CreateWholeInterval (sep);
- SetSeqLocPartial (location, FALSE, FALSE);
- locforgene = location;
- loc = location;
-
- } else if (ifp->mapToPep) {
-
- /* map protein processing from precursor to subpeptide Bioseq */
-
- sep = SeqMgrGetSeqEntryForData (bsp);
- location = CreateWholeInterval (sep);
- SetSeqLocPartial (location, FALSE, FALSE);
- locforgene = location;
- loc = location;
-
- } else {
-
- /* no aa-dna or dna-aa mapping, just use location */
-
- location = sfp->location;
- locforgene = sfp->location;
- }
- if (location == NULL) return NULL;
-
- sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
- if (sep == NULL && IS_Bioseq_set (sep)) {
- bssp = (BioseqSetPtr) sep->data.ptrvalue;
- if (bssp != NULL && bssp->_class == BioseqseqSet_class_gen_prod_set) {
- is_gps = TRUE;
- }
- }
-
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_OTHER) {
- is_other = TRUE;
- } else if (sip->choice == SEQID_GIBBSQ ||
- sip->choice == SEQID_GIBBMT ||
- sip->choice == SEQID_GIIM) {
- is_journalscan = TRUE;
- }
- }
-
- featdeftype = fcontext.featdeftype;
- if (featdeftype < FEATDEF_GENE || featdeftype >= FEATDEF_MAX) {
- featdeftype = FEATDEF_BAD;
- }
- key = FindKeyFromFeatDefType (featdeftype, TRUE);
-
- if (afp->format == GENPEPT_FMT && ISA_aa (bsp->mol)) {
- if (featdeftype == FEATDEF_REGION) {
- key = "Region";
- } else if (featdeftype == FEATDEF_BOND) {
- key = "Bond";
- } else if (featdeftype == FEATDEF_SITE) {
- key = "Site";
- }
- if (ifp->mapToPep) {
- if (featdeftype >= FEATDEF_preprotein && featdeftype <= FEATDEF_transit_peptide_aa) {
- key = "Precursor";
- }
- }
- }
-
- /* deal with unmappable impfeats */
-
- if (featdeftype == FEATDEF_BAD && fcontext.seqfeattype == SEQFEAT_IMP) {
- imp = (ImpFeatPtr) sfp->data.value.ptrvalue;
- if (imp != NULL) {
- key = imp->key;
- }
- }
-
- FFStartPrint(ffstring, afp->format, 5, 21, NULL, 0, 5, 21, "FT", /* ifp->firstfeat */ FALSE);
- if (ajp->ajp.slp != NULL) {
- FFAddOneString(ffstring, key, FALSE, FALSE, TILDE_IGNORE);
- } else if ( GetWWW(ajp) /* && SeqMgrGetParentOfPart (bsp, NULL) == NULL */ ) {
- FF_asn2gb_www_featkey (ffstring, key, sfp->location, fcontext.left + 1, fcontext.right + 1, fcontext.strand, fcontext.itemID);
- } else {
- FFAddOneString(ffstring, key, FALSE, FALSE, TILDE_IGNORE);
- }
- FFAddNChar(ffstring, ' ', 21 - 5 - StringLen(key), FALSE);
-
- if (gbseq != NULL) {
- gbfeat = GBFeatureNew ();
- if (gbfeat != NULL) {
- gbfeat->key = StringSave (key);
- }
- }
-
- if (imp == NULL || StringHasNoText (imp->loc)) {
-
-
- if (ajp->ajp.slp != NULL) {
- sip = SeqIdParse ("lcl|dummy");
- left = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_LEFT_END);
- right = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_RIGHT_END);
- strand = SeqLocStrand (ajp->ajp.slp);
- split = FALSE;
- newloc = SeqLocReMapEx (sip, ajp->ajp.slp, location, 0, FALSE, ajp->masterStyle);
- /*
- newloc = SeqLocCopyRegion (sip, location, bsp, left, right, strand, &split);
- */
- SeqIdFree (sip);
- if (newloc == NULL) return NULL;
- A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
- str = FlatLoc (ajp, target, newloc, ajp->masterStyle);
- SeqLocFree (newloc);
- } else {
- str = FlatLoc (ajp, target, location, ajp->masterStyle);
- }
- } else {
- str = StringSave (imp->loc);
- }
- if ( GetWWW(ajp) ) {
- FF_www_featloc (ffstring, str);
- } else {
- FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
- }
-
- if (gbseq != NULL) {
- if (gbfeat != NULL) {
- gbfeat->location = StringSave (str);
- if (ajp->masterStyle) {
- AddIntervalsToGbfeat (gbfeat, location, target);
- } else {
- AddIntervalsToGbfeat (gbfeat, location, NULL);
- }
- }
- }
-
- MemFree (str);
-
- /* populate qualifier table from feature fields */
-
- /*
- if (sfp->partial == TRUE)
- sfp->partial = FlatAnnotPartial(sfp, use_product);
- */
-
- if (sfp->partial) {
- partial = SeqLocPartialCheck (location);
- if (partial == SLP_COMPLETE /* || partial > SLP_OTHER */ ) {
- qvp [FTQUAL_partial].ble = TRUE;
- }
- if (LookForFuzz (location)) {
- qvp [FTQUAL_partial].ble = FALSE;
- }
- if (imp != NULL) {
- if (StringChr (imp->loc, '<') != NULL || StringChr (imp->loc, '>') != NULL) {
- qvp [FTQUAL_partial].ble = FALSE;
- }
- }
-
- /* hide unclassified /partial in RELEASE_MODE and ENTREZ_MODE */
-
- if (ajp->mode == RELEASE_MODE || ajp->mode == ENTREZ_MODE) {
- qvp [FTQUAL_partial].ble = FALSE;
- }
- /*
- if (ajp->flags.checkQualSyntax) {
- switch (featdeftype) {
- case FEATDEF_conflict:
- case FEATDEF_mutation:
- case FEATDEF_N_region:
- case FEATDEF_polyA_site:
- qvp [FTQUAL_partial].ble = FALSE;
- break;
- default:
- break;
- }
- }
- */
- }
- if (ifp->mapToProt) {
- qvp [FTQUAL_partial].ble = FALSE;
- }
-
- if (sfp->pseudo) {
- pseudo = TRUE;
- }
-
- if (fcontext.seqfeattype == SEQFEAT_GENE) {
- grp = (GeneRefPtr) sfp->data.value.ptrvalue;
- if (grp != NULL) {
- if (! StringHasNoText (grp->locus)) {
- qvp [FTQUAL_gene].str = grp->locus;
- qvp [FTQUAL_locus_tag].str = grp->locus_tag;
- qvp [FTQUAL_gene_desc].str = grp->desc;
- qvp [FTQUAL_gene_syn].vnp = grp->syn;
- } else if (grp->locus_tag != NULL) {
- qvp [FTQUAL_locus_tag].str = grp->locus_tag;
- qvp [FTQUAL_gene_desc].str = grp->desc;
- qvp [FTQUAL_gene_syn].vnp = grp->syn;
- } else if (! StringHasNoText (grp->desc)) {
- qvp [FTQUAL_gene].str = grp->desc;
- qvp [FTQUAL_gene_syn].vnp = grp->syn;
- } else if (grp->syn != NULL) {
- vnp = grp->syn;
- qvp [FTQUAL_gene].str = (CharPtr) vnp->data.ptrvalue;
- vnp = vnp->next;
- qvp [FTQUAL_gene_syn].vnp = vnp;
- }
- qvp [FTQUAL_gene_map].str = grp->maploc;
- qvp [FTQUAL_gene_allele].str = grp->allele;
- qvp [FTQUAL_gene_xref].vnp = grp->db;
- if (grp->pseudo) {
- pseudo = TRUE;
- }
- }
- if (! ajp->flags.geneSynsToNote) {
- qvp [FTQUAL_gene_syn_refseq].vnp = qvp [FTQUAL_gene_syn].vnp;
- qvp [FTQUAL_gene_syn].vnp = NULL;
- }
- operon = SeqMgrGetOverlappingOperon (locforgene, &ocontext);
- if (operon != NULL) {
- for (gbq = operon->qual; gbq != NULL; gbq = gbq->next) {
- if (StringCmp (gbq->qual, "operon") == 0) {
- qvp [FTQUAL_operon].gbq = gbq;
- }
- }
- }
-
- } else {
-
- grp = SeqMgrGetGeneXref (sfp);
- if (grp != NULL) {
- qvp [FTQUAL_gene_xref].vnp = grp->db;
- }
- if (grp == NULL) {
- sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
- oldscope = SeqEntrySetScope (sep);
- gene = SeqMgrGetOverlappingGene (locforgene, &gcontext);
- SeqEntrySetScope (oldscope);
- if (gene != NULL) {
- qvp [FTQUAL_gene_note].str = gene->comment;
- grp = (GeneRefPtr) gene->data.value.ptrvalue;
- if (gene->pseudo) {
- pseudo = TRUE;
- }
- if (grp != NULL && grp->db != NULL) {
- qvp [FTQUAL_gene_xref].vnp = grp->db;
- } else {
- qvp [FTQUAL_gene_xref].vnp = gene->dbxref;
- }
- }
- }
- if (grp != NULL && grp->pseudo) {
- pseudo = TRUE;
- }
- if (grp != NULL && (! SeqMgrGeneIsSuppressed (grp)) &&
- (fcontext.featdeftype != FEATDEF_repeat_region || gene == NULL)) {
- if (! StringHasNoText (grp->locus)) {
- qvp [FTQUAL_gene].str = grp->locus;
- qvp [FTQUAL_locus_tag].str = grp->locus_tag;
- gene_syn = grp->syn;
- } else if (! StringHasNoText (grp->locus_tag)) {
- qvp [FTQUAL_locus_tag].str = grp->locus_tag;
- gene_syn = grp->syn;
- } else if (! StringHasNoText (grp->desc)) {
- qvp [FTQUAL_gene].str = grp->desc;
- gene_syn = grp->syn;
- } else if (grp->syn != NULL) {
- vnp = grp->syn;
- qvp [FTQUAL_gene].str = (CharPtr) vnp->data.ptrvalue;
- vnp = vnp->next;
- gene_syn = vnp;
- }
- }
- if (grp != NULL && fcontext.featdeftype != FEATDEF_variation) {
- qvp [FTQUAL_gene_allele].str = grp->allele; /* now propagating /allele */
- }
- if (fcontext.seqfeattype != SEQFEAT_CDREGION &&
- fcontext.seqfeattype != SEQFEAT_RNA) {
- qvp [FTQUAL_gene_xref].vnp = NULL;
- }
- if (fcontext.featdeftype != FEATDEF_operon) {
- grp = SeqMgrGetGeneXref (sfp);
- if (grp == NULL || (! SeqMgrGeneIsSuppressed (grp))) {
- operon = SeqMgrGetOverlappingOperon (locforgene, &ocontext);
- if (operon != NULL) {
- for (gbq = operon->qual; gbq != NULL; gbq = gbq->next) {
- if (StringCmp (gbq->qual, "operon") == 0) {
- qvp [FTQUAL_operon].gbq = gbq;
- }
- }
- }
- }
- }
-
- /* specific fields set here */
-
- switch (fcontext.seqfeattype) {
- case SEQFEAT_CDREGION :
- if (! ifp->mapToProt) {
- crp = (CdRegionPtr) sfp->data.value.ptrvalue;
- if (crp != NULL) {
-
- qvp [FTQUAL_codon_start].num = crp->frame;
- if (qvp [FTQUAL_codon_start].num == 0) {
- qvp [FTQUAL_codon_start].num = 1;
- }
- qvp [FTQUAL_transl_except].cbp = crp->code_break;
- for (cbp = crp->code_break; cbp != NULL; cbp = cbp->next) {
- seqcode = 0;
- sctp = NULL;
- cbaa = cbp->aa;
- switch (cbaa.choice) {
- case 1 :
- seqcode = Seq_code_ncbieaa;
- break;
- case 2 :
- seqcode = Seq_code_ncbi8aa;
- break;
- case 3 :
- seqcode = Seq_code_ncbistdaa;
- break;
- default :
- break;
- }
- if (seqcode != 0) {
- sctp = SeqCodeTableFind (seqcode);
- if (sctp != NULL) {
- residue = cbaa.value.intvalue;
- if (residue != 42) {
- if (seqcode != Seq_code_ncbieaa) {
- smtp = SeqMapTableFind (seqcode, Seq_code_ncbieaa);
- residue = SeqMapTableConvert (smtp, residue);
- }
- if (residue == 'U') {
- if (ajp->flags.selenocysteineToNote) {
- qvp [FTQUAL_selenocysteine_note].str = "selenocysteine";
- } else {
- qvp [FTQUAL_selenocysteine].ble = TRUE;
- }
- }
- }
- }
- }
- }
-
- gcp = crp->genetic_code;
- if (gcp != NULL) {
- for (vnp = gcp->data.ptrvalue; vnp != NULL; vnp = vnp->next) {
- if (vnp->choice == 2 && vnp->data.intvalue != 0) {
- qvp [FTQUAL_transl_table].num = vnp->data.intvalue;
- }
- }
-
- /* suppress table 1, but always show it in GBSeqXML */
-
- if (qvp [FTQUAL_transl_table].num == 1 && ajp->gbseq == NULL) {
- qvp [FTQUAL_transl_table].num = 0;
- }
- }
-
- if (sfp->product != NULL && SeqLocLen (sfp->product) != 0) {
- protein = TRUE;
- }
- if (crp->conflict && (protein || (! sfp->excpt))) {
- if (protein) {
- qvp [FTQUAL_prot_conflict].str = conflict_msg;
- } else {
- /*
- qvp [FTQUAL_prot_missing].str = no_protein_msg;
- */
- }
- }
- }
-
- sip = SeqLocIdForProduct (sfp->product);
- qvp [FTQUAL_protein_id].sip = sip;
-
- sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
-
- if (! ajp->alwaysTranslCds) {
-
- /* by default only show /translation if product bioseq is within entity */
-
- oldscope = SeqEntrySetScope (sep);
- prod = BioseqFind (sip);
- SeqEntrySetScope (oldscope);
-
- if (prod == NULL && ajp->showFarTransl) {
-
- /* but flag can override and force far /translation */
-
- prod = BioseqLockById (sip);
- unlockme = prod;
- }
- }
-
- prp = NULL;
-
- if (prod != NULL) {
- for (sip = prod->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_GI) {
- sprintf (protein_pid_g, "PID:g%ld", (long) sip->data.intvalue);
- }
- }
- sdp = SeqMgrGetNextDescriptor (prod, NULL, Seq_descr_comment, &dcontext);
- if (sdp != NULL && dcontext.level == 0) {
- if (! StringHasNoText ((CharPtr) sdp->data.ptrvalue)) {
- qvp [FTQUAL_prot_comment].str = (CharPtr) sdp->data.ptrvalue;
- }
- }
- sdp = SeqMgrGetNextDescriptor (prod, NULL, Seq_descr_molinfo, &dcontext);
- if (sdp != NULL && dcontext.level == 0) {
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip != NULL && mip->tech > 1 &&
- mip->tech != MI_TECH_concept_trans &&
- mip->tech != MI_TECH_concept_trans_a) {
- str = StringForSeqTech (mip->tech);
- if (! StringHasNoText (str)) {
- qvp [FTQUAL_prot_method].str = str;
- }
- }
- }
- prot = SeqMgrGetBestProteinFeature (prod, &pcontext);
- if (prot != NULL) {
- prp = (ProtRefPtr) prot->data.value.ptrvalue;
- if (prp != NULL && prp->processed < 2) {
- qvp [FTQUAL_prot_note].str = prot->comment;
- }
- }
- }
-
- /* protein xref overrides names, but should not prevent /protein_id, etc. */
-
- prpxref = SeqMgrGetProtXref (sfp);
- if (prpxref != NULL) {
- prp = prpxref;
- }
- if (prp != NULL) {
- vnp = prp->name;
- if (vnp != NULL && (! StringHasNoText ((CharPtr) vnp->data.ptrvalue))) {
- qvp [FTQUAL_cds_product].str = (CharPtr) vnp->data.ptrvalue;
- vnp = vnp->next;
- qvp [FTQUAL_prot_names].vnp = vnp;
- }
- qvp [FTQUAL_prot_desc].str = prp->desc;
- qvp [FTQUAL_prot_activity].vnp = prp->activity;
- qvp [FTQUAL_prot_EC_number].vnp = prp->ec;
- }
-
- if (! pseudo) {
- if (prod != NULL || ajp->transIfNoProd || ajp->alwaysTranslCds) {
- qvp [FTQUAL_translation].ble = TRUE;
- }
- }
-
- if (ifp->isCDS) {
- icp = (IntCdsBlockPtr) ifp;
- qvp [FTQUAL_figure].str = icp->fig;
- qvp [FTQUAL_maploc].str = icp->maploc;
- }
- } else {
- qvp [FTQUAL_coded_by].slp = sfp->location;
-
- crp = (CdRegionPtr) sfp->data.value.ptrvalue;
- if (crp != NULL) {
- gcp = crp->genetic_code;
- if (gcp != NULL) {
- for (vnp = gcp->data.ptrvalue; vnp != NULL; vnp = vnp->next) {
- if (vnp->choice == 2 && vnp->data.intvalue != 0) {
- qvp [FTQUAL_transl_table].num = vnp->data.intvalue;
- }
- }
-
- /* suppress table 1 */
-
- if (qvp [FTQUAL_transl_table].num == 1) {
- qvp [FTQUAL_transl_table].num = 0;
- }
- }
- for (cbp = crp->code_break; cbp != NULL; cbp = cbp->next) {
- seqcode = 0;
- sctp = NULL;
- cbaa = cbp->aa;
- switch (cbaa.choice) {
- case 1 :
- seqcode = Seq_code_ncbieaa;
- break;
- case 2 :
- seqcode = Seq_code_ncbi8aa;
- break;
- case 3 :
- seqcode = Seq_code_ncbistdaa;
- break;
- default :
- break;
- }
- if (seqcode != 0) {
- sctp = SeqCodeTableFind (seqcode);
- if (sctp != NULL) {
- residue = cbaa.value.intvalue;
- if (residue != 42) {
- if (seqcode != Seq_code_ncbieaa) {
- smtp = SeqMapTableFind (seqcode, Seq_code_ncbieaa);
- residue = SeqMapTableConvert (smtp, residue);
- }
- if (residue == 'U') {
- if (ajp->flags.selenocysteineToNote) {
- qvp [FTQUAL_selenocysteine_note].str = "selenocysteine";
- } else {
- qvp [FTQUAL_selenocysteine].ble = TRUE;
- }
- }
- }
- }
- }
- }
- }
- }
- break;
- case SEQFEAT_PROT :
- if (! ifp->mapToPep) {
- prp = (ProtRefPtr) sfp->data.value.ptrvalue;
- if (prp != NULL) {
- vnp = prp->name;
- if (vnp != NULL && (! StringHasNoText ((CharPtr) vnp->data.ptrvalue))) {
- qvp [FTQUAL_product].str = (CharPtr) vnp->data.ptrvalue;
- vnp = vnp->next;
- qvp [FTQUAL_prot_names].vnp = vnp;
- }
- if (afp->format != GENPEPT_FMT) {
- qvp [FTQUAL_prot_desc].str = prp->desc;
- } else {
- qvp [FTQUAL_prot_name].str = prp->desc;
- }
- if (afp->format != GENPEPT_FMT || prp->processed != 2) {
- qvp [FTQUAL_prot_activity].vnp = prp->activity;
- }
- qvp [FTQUAL_prot_EC_number].vnp = prp->ec;
- }
- sip = SeqLocIdForProduct (sfp->product);
- if (sip != NULL) {
- /* for RefSeq records or GenBank not release_mode */
- if (is_other || (! ajp->flags.forGbRelease)) {
- qvp [FTQUAL_protein_id].sip = sip;
- }
- prod = BioseqFind (sip);
- }
- } else {
- qvp [FTQUAL_derived_from].slp = sfp->location;
- sip = SeqLocIdForProduct (sfp->product);
- if (sip != NULL) {
- prod = BioseqFind (sip);
- if (prod != NULL) {
- prot = SeqMgrGetBestProteinFeature (prod, NULL);
- if (prot != NULL) {
- precursor_comment = prot->comment;
- }
- }
- }
- }
- prp = (ProtRefPtr) sfp->data.value.ptrvalue;
- if (prp != NULL) {
- if (! pseudo) {
- if (ajp->showPeptide) {
- if (prp->processed == 2 || prp->processed == 3 || prp->processed == 4) {
- qvp [FTQUAL_peptide].ble = TRUE;
- }
- }
- }
- if (prp->processed == 3 || prp->processed == 4) {
- if (! is_other) {
- /* Only RefSeq allows product on signal or transit peptide */
- qvp [FTQUAL_product].str = NULL;
- }
- }
- }
- break;
- case SEQFEAT_RNA :
- rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
- if (rrp != NULL) {
- if (rrp->pseudo) {
- pseudo = TRUE;
- }
- if (rrp->type == 2) {
- sip = SeqLocIdForProduct (sfp->product);
- if (sip != NULL) {
- /* for RefSeq records or GenBank not release_mode or entrez_mode */
- if (is_other || (ajp->mode == SEQUIN_MODE || ajp->mode == DUMP_MODE)) {
- qvp [FTQUAL_transcript_id].sip = sip;
- } else {
- /* otherwise now goes in note */
- qvp [FTQUAL_transcript_id_note].sip = sip; /* !!! remove October 15, 2003 !!! */
- }
- prod = BioseqFind (sip);
- }
- if (! pseudo) {
- if (ajp->showTranscript) {
- qvp [FTQUAL_transcription].ble = TRUE;
- }
- }
- }
- if (rrp->type == 3) {
- if (rrp->ext.choice == 1) {
- /* amino acid could not be parsed into structured form */
- if (! ajp->flags.dropIllegalQuals) {
- str = (CharPtr) rrp->ext.value.ptrvalue;
- qvp [FTQUAL_product].str = str;
- } else {
- qvp [FTQUAL_product].str = "tRNA-OTHER";
- }
- } else if (rrp->ext.choice == 2) {
- trna = (tRNAPtr) rrp->ext.value.ptrvalue;
- if (trna != NULL) {
- aa = 0;
- if (trna->aatype == 2) {
- aa = trna->aa;
- } else {
- from = 0;
- switch (trna->aatype) {
- case 0 :
- from = 0;
- break;
- case 1 :
- from = Seq_code_iupacaa;
- break;
- case 2 :
- from = Seq_code_ncbieaa;
- break;
- case 3 :
- from = Seq_code_ncbi8aa;
- break;
- case 4 :
- from = Seq_code_ncbistdaa;
- break;
- default:
- break;
- }
- if (ajp->flags.iupacaaOnly) {
- code = Seq_code_iupacaa;
- } else {
- code = Seq_code_ncbieaa;
- }
- smtp = SeqMapTableFind (code, from);
- if (smtp != NULL) {
- aa = SeqMapTableConvert (smtp, trna->aa);
- if (aa == 255 && from == Seq_code_iupacaa && trna->aa == 'U') {
- aa = 'U';
- }
- }
- }
- if (ajp->flags.iupacaaOnly) {
- smtp = SeqMapTableFind (Seq_code_iupacaa, Seq_code_ncbieaa);
- if (smtp != NULL) {
- aa = SeqMapTableConvert (smtp, trna->aa);
- } else {
- aa = 'X';
- }
- }
- if (aa > 0 && aa != 255) {
- if (aa <= 74) {
- shift = 0;
- } else if (aa > 79) {
- shift = 2;
- } else {
- shift = 1;
- }
- if (aa != '*') {
- idx = aa - (64 + shift);
- } else {
- idx = 25;
- }
- if (idx > 0 && idx < 26) {
- str = trnaList [idx];
- qvp [FTQUAL_product].str = str;
- if (StringNICmp (str, "tRNA-", 5) == 0) {
- qvp [FTQUAL_trna_aa].str = str + 5;
- }
- }
- }
- qvp [FTQUAL_anticodon].slp = trna->anticodon;
- qvp [FTQUAL_trna_codons].trp = trna;
- }
- }
- } else {
- if (rrp->ext.choice == 1) {
- str = (CharPtr) rrp->ext.value.ptrvalue;
- qvp [FTQUAL_product].str = str;
-
- /*
- if (rrp->type == 255 && (! StringHasNoText (str))) {
- if (StringICmp (str, "internal transcribed spacer 1") == 0 ||
- StringICmp (str, "internal transcribed spacer ITS1") == 0 ||
- StringICmp (str, "ITS1") == 0) {
- qvp [FTQUAL_rrna_its].str = "ITS1";
- } else if (StringICmp (str, "internal transcribed spacer 2") == 0 ||
- StringICmp (str, "internal transcribed spacer ITS2") == 0 ||
- StringICmp (str, "ITS2") == 0) {
- qvp [FTQUAL_rrna_its].str = "ITS2";
- } else if (StringICmp (str, "internal transcribed spacer 3") == 0 ||
- StringICmp (str, "internal transcribed spacer ITS3") == 0 ||
- StringICmp (str, "ITS3") == 0) {
- qvp [FTQUAL_rrna_its].str = "ITS3";
- }
- }
- */
- }
- }
- }
- break;
- case SEQFEAT_REGION :
- if (afp->format == GENPEPT_FMT && featdeftype == FEATDEF_REGION && ISA_aa (bsp->mol)) {
- qvp [FTQUAL_region_name].str = (CharPtr) sfp->data.value.ptrvalue;
- } else {
- qvp [FTQUAL_region].str = (CharPtr) sfp->data.value.ptrvalue;
- }
- break;
- case SEQFEAT_COMMENT :
- break;
- case SEQFEAT_BOND :
- bondidx = (Int2) sfp->data.value.intvalue;
- if (bondidx == 255) {
- bondidx = 5;
- }
- if (bondidx > 0 && bondidx < 6) {
- if (afp->format == GENPEPT_FMT && ISA_aa (bsp->mol)) {
- qvp [FTQUAL_bond_type].str = bondList [bondidx];
- } else {
- qvp [FTQUAL_bond].str = bondList [bondidx];
- }
- }
- break;
- case SEQFEAT_SITE :
- siteidx = (Int2) sfp->data.value.intvalue;
- if (siteidx == 255) {
- siteidx = 26;
- }
- if (siteidx > 0 && siteidx < 27) {
- if (afp->format == GENPEPT_FMT && ISA_aa (bsp->mol)) {
- qvp [FTQUAL_site_type].str = siteList [siteidx];
- } else {
- qvp [FTQUAL_site].str = siteList [siteidx];
- }
- }
- break;
- case SEQFEAT_PSEC_STR :
- qvp [FTQUAL_sec_str_type].num = sfp->data.value.intvalue;
- break;
- case SEQFEAT_HET :
- qvp [FTQUAL_heterogen].str = (CharPtr) sfp->data.value.ptrvalue;
- break;
- default :
- break;
- }
- }
-
- /* common fields set here */
-
- VisitUserObjectsInUop (sfp->ext, (Pointer) qvp, RecordUserObjectsInQVP);
-
- if (fcontext.featdeftype == FEATDEF_repeat_region) {
- pseudo = FALSE;
- }
-
- qvp [FTQUAL_pseudo].ble = pseudo;
-
- qvp [FTQUAL_seqfeat_note].str = sfp->comment;
-
- /* if RELEASE_MODE, check list of features that can have /pseudo */
-
- if (ajp->flags.dropIllegalQuals && pseudo &&
- (fcontext.seqfeattype == SEQFEAT_RNA || fcontext.seqfeattype == SEQFEAT_IMP) ) {
- switch (featdeftype) {
-
- case FEATDEF_allele:
- case FEATDEF_attenuator:
- case FEATDEF_CAAT_signal:
- case FEATDEF_conflict:
- case FEATDEF_D_loop:
- case FEATDEF_enhancer:
- case FEATDEF_GC_signal:
- case FEATDEF_iDNA:
- case FEATDEF_intron:
- case FEATDEF_LTR:
- case FEATDEF_misc_binding:
- case FEATDEF_misc_difference:
- case FEATDEF_misc_recomb:
- case FEATDEF_misc_RNA:
- case FEATDEF_misc_signal:
- case FEATDEF_misc_structure:
- case FEATDEF_modified_base:
- case FEATDEF_mutation:
- case FEATDEF_old_sequence:
- case FEATDEF_polyA_signal:
- case FEATDEF_polyA_site:
- case FEATDEF_precursor_RNA:
- case FEATDEF_prim_transcript:
- case FEATDEF_primer_bind:
- case FEATDEF_protein_bind:
- case FEATDEF_RBS:
- case FEATDEF_repeat_region:
- case FEATDEF_repeat_unit:
- case FEATDEF_rep_origin:
- case FEATDEF_satellite:
- case FEATDEF_stem_loop:
- case FEATDEF_STS:
- case FEATDEF_TATA_signal:
- case FEATDEF_terminator:
- case FEATDEF_unsure:
- case FEATDEF_variation:
- case FEATDEF_3clip:
- case FEATDEF_3UTR:
- case FEATDEF_5clip:
- case FEATDEF_5UTR:
- case FEATDEF_10_signal:
- case FEATDEF_35_signal:
- qvp [FTQUAL_pseudo].ble = FALSE;
- break;
- default:
- break;
- }
- }
-
- if (afp->format != GENPEPT_FMT) {
- qvp [FTQUAL_evidence].num = sfp->exp_ev;
- }
-
- /* exception currently legal only on CDS */
-
- if ((! ajp->flags.dropIllegalQuals) || fcontext.seqfeattype == SEQFEAT_CDREGION) {
- qvp [FTQUAL_exception].str = sfp->except_text;
-
- if (sfp->excpt && qvp [FTQUAL_exception].str == NULL) {
- if (qvp [FTQUAL_seqfeat_note].str != NULL) {
- if (ajp->flags.dropIllegalQuals &&
- (! StringInStringList (qvp [FTQUAL_seqfeat_note].str, validExceptionString))) {
- /* !!! if ajp->flags.dropIllegalQuals, check CDS list to avoid losing note !!! */
- qvp [FTQUAL_exception].str = NULL;
- } else {
- /* if no /exception text, use text in comment, remove from /note */
-
- qvp [FTQUAL_exception].str = qvp [FTQUAL_seqfeat_note].str;
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
- } else {
- qvp [FTQUAL_exception].str = "No explanation supplied";
- }
-
- /* !!! if ajp->flags.dropIllegalQuals, check CDS list here as well !!! */
- if (ajp->flags.dropIllegalQuals &&
- (! StringInStringList (qvp [FTQUAL_seqfeat_note].str, validExceptionString))) {
- qvp [FTQUAL_exception].str = NULL;
- }
- }
- if (ajp->flags.dropIllegalQuals) {
- if (is_other) {
- if (! StringInStringList (qvp [FTQUAL_exception].str, validRefSeqExceptionString)) {
- qvp [FTQUAL_exception_note].str = qvp [FTQUAL_exception].str;
- qvp [FTQUAL_exception].str = NULL;
- }
- } else {
- if (! StringInStringList (qvp [FTQUAL_exception].str, validExceptionString)) {
- qvp [FTQUAL_exception_note].str = qvp [FTQUAL_exception].str;
- qvp [FTQUAL_exception].str = NULL;
- }
- }
- }
- } else {
- qvp [FTQUAL_exception_note].str = sfp->except_text;
- }
- if (StringHasNoText (qvp [FTQUAL_exception].str)) {
- qvp [FTQUAL_exception].str = NULL;
- }
- if (StringHasNoText (qvp [FTQUAL_exception_note].str)) {
- qvp [FTQUAL_exception_note].str = NULL;
- }
-
- qvp [FTQUAL_db_xref].vnp = sfp->dbxref;
- qvp [FTQUAL_citation].vnp = sfp->cit;
-
- /* /product same as sfp->comment will suppress /note */
-
- if (! StringHasNoText (qvp [FTQUAL_product].str) &&
- StringICmp (sfp->comment, qvp [FTQUAL_product].str) == 0) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
- /* case sensitive AJ011317.1 */
- if (! StringHasNoText (qvp [FTQUAL_cds_product].str) &&
- StringCmp (sfp->comment, qvp [FTQUAL_cds_product].str) == 0) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
-
- /* /gene same as sfp->comment will suppress /note */
- /* case sensitive -gi|6572973|gb|AF195052.1|AF195052 */
-
- if (! StringHasNoText (qvp [FTQUAL_gene].str) &&
- StringCmp (sfp->comment, qvp [FTQUAL_gene].str) == 0) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
-
- /* gene /note same as sfp->comment will suppress /note - U92435.1 says do not do this */
-
- /*
- if (! StringHasNoText (qvp [FTQUAL_gene_note].str) &&
- StringICmp (sfp->comment, qvp [FTQUAL_gene_note].str) == 0) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
- */
-
- /* if site sfp->comment contains site name, suppress site in /note */
-
- if (! StringHasNoText (qvp [FTQUAL_site].str) &&
- StringStr (sfp->comment, qvp [FTQUAL_site].str) != NULL) {
- qvp [FTQUAL_site].str = NULL;
- }
-
- /* /EC_number same as sfp->comment will suppress /note */
-
- for (vnp = qvp [FTQUAL_prot_EC_number].vnp; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if ((! StringHasNoText (str)) &&
- StringICmp (sfp->comment, str) == 0) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
- }
-
- /* mat_peptide precursor same as sfp->comment will suppress /note in GenPept */
-
- if (precursor_comment != NULL && StringCmp (precursor_comment, sfp->comment) == 0) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
-
-
- /* now go through gbqual list */
-
- for (gbq = sfp->qual; gbq != NULL; gbq = gbq->next) {
- idx = GbqualToFeaturIndex (gbq->qual);
- if (idx > 0 && idx < ASN2GNBK_TOTAL_FEATUR) {
- if (qvp [idx].gbq == NULL) {
- if (idx == FTQUAL_product_quals) {
- if (qvp [FTQUAL_product].str == NULL) {
- qvp [FTQUAL_product].str = gbq->val;
- } else if (qvp [FTQUAL_xtra_prod_quals].gbq == NULL) {
- /* chain will include remaining product gbquals */
- qvp [FTQUAL_xtra_prod_quals].gbq = gbq;
- }
- } else {
- qvp [idx].gbq = gbq;
- }
- }
-
- } else if (idx == 0) {
-
- qualclass = IllegalGbqualToClass (gbq->qual);
- if (qualclass == 0) {
- qualclass = Qual_class_quote;
- }
- tmp = StringSave (gbq->val);
- if (tmp != NULL) {
- str = MemNew (sizeof (Char) * (StringLen (gbq->qual) + StringLen (tmp) + 10));
- if (str != NULL) {
- if (qualclass == Qual_class_quote) {
- if (StringIsJustQuotes (tmp)) {
- sprintf (str, "/%s", gbq->qual);
- } else {
- ptr = tmp;
- ch = *ptr;
- while (ch != '\0') {
- if (ch == '"') {
- *ptr = '\'';
- }
- ptr++;
- ch = *ptr;
- }
- sprintf (str, "/%s=\"%s\"", gbq->qual, tmp);
- }
- ValNodeCopyStr (&illegal, 0, str);
- } else if (qualclass == Qual_class_noquote || qualclass == Qual_class_label) {
- if (StringIsJustQuotes (tmp)) {
- sprintf (str, "/%s", gbq->qual);
- } else {
- sprintf (str, "/%s=%s", gbq->qual, tmp);
- }
- ValNodeCopyStr (&illegal, 0, str);
- }
- MemFree (str);
- }
- MemFree (tmp);
- }
- }
- }
-
- /* illegal qualifiers are copied and formatted in valnode chain */
-
- if (! ajp->flags.dropIllegalQuals) {
- qvp [FTQUAL_illegal_qual].vnp = illegal;
- }
-
- /* remove protein description that equals the gene name, case sensitive */
-
- if (StringCmp (qvp [FTQUAL_gene].str, qvp [FTQUAL_prot_desc].str) == 0) {
- qvp [FTQUAL_prot_desc].str = NULL;
- }
-
- /* remove protein description that equals the cds product, case sensitive */
-
- if (StringCmp (qvp [FTQUAL_cds_product].str, qvp [FTQUAL_prot_desc].str) == 0) {
- qvp [FTQUAL_prot_desc].str = NULL;
- }
-
- /* remove comment contained in prot_desc - gi|4530123|gb|AF071539.1|AF071539 */
-
- if (StringStr (qvp [FTQUAL_prot_desc].str, qvp [FTQUAL_seqfeat_note].str) != NULL) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
-
- /* remove protein description that equals the standard name */
-
- if (qvp [FTQUAL_standard_name].gbq != NULL && qvp [FTQUAL_prot_desc].str != NULL) {
- gbq = qvp [FTQUAL_standard_name].gbq;
- lasttype = gbq->qual;
- while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
- if (StringICmp (gbq->val, qvp [FTQUAL_prot_desc].str) == 0) {
- qvp [FTQUAL_prot_desc].str = NULL;
- }
- gbq = gbq->next;
- }
- }
-
- /* remove protein description that equals a gene synonym - case insensitive AF109216.1 */
-
- for (vnp = gene_syn; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if ((! StringHasNoText (str)) &&
- StringCmp (str, qvp [FTQUAL_prot_desc].str) == 0) {
- /* NC_001823 leave in prot_desc if no cds_product */
- if (qvp [FTQUAL_cds_product].str != NULL) {
- qvp [FTQUAL_prot_desc].str = NULL;
- }
- }
- }
-
- /* remove comment that equals a gene synonym */
-
- if (afp->format != GENPEPT_FMT && (! ifp->mapToProt)) {
- for (vnp = gene_syn; vnp != NULL; vnp = vnp->next) {
- str = (CharPtr) vnp->data.ptrvalue;
- if ((! StringHasNoText (str)) &&
- StringICmp (str, qvp [FTQUAL_seqfeat_note].str) == 0) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
- }
- }
-
- /* remove protein comment descriptor that equals the protein note */
-
- if (StringCmp (qvp [FTQUAL_prot_note].str, qvp [FTQUAL_prot_comment].str) == 0) {
- qvp [FTQUAL_prot_comment].str = NULL;
- }
-
- /* suppress cds comment if a subset of protein note - AF002218.1 */
-
- if (StringStr (qvp [FTQUAL_prot_note].str, qvp [FTQUAL_seqfeat_note].str) != NULL) {
- qvp [FTQUAL_seqfeat_note].str = NULL;
- }
-
- /* suppress selenocysteine note if already in comment */
-
- if (StringStr (sfp->comment, "selenocysteine") != NULL) {
- qvp [FTQUAL_selenocysteine_note].str = NULL;
- }
-
- /* if /allele inherited from gene, suppress allele gbqual on feature */
-
- if (qvp [FTQUAL_gene_allele].str != NULL) {
- qvp [FTQUAL_allele].gbq = NULL;
- }
-
- /* now print qualifiers from table */
-
-#ifdef DISPLAY_STRINGS
- s_DisplayQVP(qvp, feat_note_order);
-#endif
-
- /* Strip duplicate notes */
-
- if ((StringCmp(qvp[FTQUAL_product].str,
- qvp[FTQUAL_seqfeat_note].str) == 0)) {
- qvp[FTQUAL_seqfeat_note].str = NULL;
- }
-
- if ((qvp[FTQUAL_standard_name].gbq != NULL) &&
- (qvp[FTQUAL_standard_name].gbq->val != NULL)) {
- if ((StringCmp(qvp[FTQUAL_seqfeat_note].str,
- qvp[FTQUAL_standard_name].gbq->val) == 0)) {
- qvp[FTQUAL_seqfeat_note].str = NULL;
- }
- }
-
- /* Display strings for debugging purposes */
-
-#ifdef DISPLAY_STRINGS
- s_DisplayQVP(qvp, feat_qual_order);
-#endif
-
- /* optionally populate indexes for NCBI internal database */
-
- if (index != NULL) {
- if (! StringHasNoText (qvp [FTQUAL_gene].str)) {
- ValNodeCopyStrToHead (&(index->genes), 0, qvp [FTQUAL_gene].str);
- }
- }
-
- FFAddOneChar(ffstring, '\n', FALSE);
-
- /* Build the flat file */
- FormatFeatureBlockQuals (ffstring, ajp, afp, asp, bsp, featdeftype, gene_syn,
- lasttype, location, prod,
- protein_pid_g, qvp,
- left, right, strand,
- sfp, target, is_other,
- is_journalscan, is_gps);
-
- /* ??? and then deal with the various note types separately (not in order table) ??? */
-
- /* free aa-dna or dna-aa mapped location */
-
- SeqLocFree (loc);
-
- ValNodeFreeData (illegal);
-
- BioseqUnlock (unlockme);
-
- str = FFEndPrint (ajp, ffstring, afp->format, 21, 21, 21, 21, "FT");
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- if (gbseq != NULL) {
- if (gbfeat != NULL) {
- AddFeatureToGbseq (gbseq, gbfeat, str, sfp);
- }
- }
-
- FFRecycleString(ajp, ffstring);
- return str;
-}
-
-
-static CharPtr FormatSequenceBlock (
- Asn2gbFormatPtr afp,
- BaseBlockPtr bbp
-)
-
-{
- IntAsn2gbJobPtr ajp;
- Asn2gbSectPtr asp;
- Byte bases [400];
- Int2 blk;
- BioseqPtr bsp;
- Char buf [80];
- Char ch;
- Int2 cnt;
- Uint1 code = Seq_code_iupacna;
- Int2 count;
- Int2 ctr;
- GBSeqPtr gbseq;
- Int2 i;
- IntAsn2gbSectPtr iasp;
- Boolean is_na;
- Int2 lin;
- Int4 pos;
- CharPtr ptr;
- Uint1 residue;
- SeqBlockPtr sbp;
- SeqPortPtr spp;
- Int4 start;
- Int4 stop;
- CharPtr str;
- CharPtr tmp;
- StringItemPtr ffstring;
-
- if (afp == NULL || bbp == NULL) return NULL;
- sbp = (SeqBlockPtr) bbp;
- ajp = afp->ajp;
- if (ajp == NULL) return NULL;
- asp = afp->asp;
- if (asp == NULL) return NULL;
- iasp = (IntAsn2gbSectPtr) asp;
- bsp = (asp->bsp);
- if (bsp == NULL) return NULL;
-
- /* if GBSeq XML, use SeqPortStream on single block */
-
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
-
- str = MemNew (sizeof (Char) * (bsp->length + 10));
- if (str == NULL) return NULL;
-
- tmp = str;
- SeqPortStream (bsp, TRUE, (Pointer) &tmp, SaveGBSeqSequence);
- gbseq->sequence = StringSave (str);
-
- tmp = gbseq->sequence;
- if (tmp == NULL) return NULL;
- ch = *tmp;
- while (ch != '\0') {
- if (ch == '\n' || ch == '\r' || ch == '\t') {
- *tmp = ' ';
- }
- tmp++;
- ch = *tmp;
- }
- TrimSpacesAroundString (gbseq->sequence);
- CompressNonBases (gbseq->sequence);
-
- return str;
- }
-
- /* if subsequence cached with SeqPortStream, use it */
-
- if (sbp->bases != NULL) {
- ffstring = FFGetString (ajp);
-
- start = sbp->start;
- stop = sbp->stop;
-
- count = 0;
- blk = 0;
- lin = 0;
-
- ptr = sbp->bases;
- ch = *ptr;
-
- while (ch != '\0') {
- buf [count] = (Char) (TO_LOWER (ch));
- count++;
- ptr++;
- ch = *ptr;
-
- blk++;
- lin++;
- if (lin >= 60) {
-
- buf [count] = '\0';
- PrintSeqLine (ffstring, afp->format, buf, start, start + cnt);
- count = 0;
- cnt = 0;
- blk = 0;
- lin = 0;
- start += 60;
-
- } else if (blk >= 10) {
-
- buf [count] = ' ';
- count++;
- blk = 0;
-
- }
- }
-
- buf [count] = '\0';
- if (count > 0) {
- PrintSeqLine (ffstring, afp->format, buf, start, start + cnt);
- }
-
- str = FFToCharPtr(ffstring);
-
- FFRecycleString (ajp, ffstring);
- return str;
- }
-
- /* otherwise split into smaller blocks */
-
- spp = iasp->spp;
- if (spp == NULL) {
-
- /* if first time, create SeqPort for this section */
-
- if (ISA_aa (bsp->mol)) {
- if (ajp->flags.iupacaaOnly) {
- code = Seq_code_iupacaa;
- } else {
- code = Seq_code_ncbieaa;
- }
- }
-
- if (ajp->ajp.slp != NULL) {
- spp = SeqPortNewByLoc (ajp->ajp.slp, code);
- } else {
- spp = SeqPortNew (bsp, 0, -1, 0, code);
- }
- if (spp == NULL) return NULL;
- if (bsp->repr == Seq_repr_delta || bsp->repr == Seq_repr_virtual) {
- SeqPortSet_do_virtual (spp, TRUE);
- }
-
- iasp->spp = spp;
- }
-
- start = sbp->start;
- stop = sbp->stop;
-
- if (start != spp->curpos) {
- SeqPortSeek (spp, start, SEEK_SET);
- }
-
- pos = start;
-
- count = 0;
- cnt = 0;
- blk = 0;
- lin = 0;
-
- is_na = ISA_na (bsp->mol);
-
- ctr = (Int2) MIN ((Int4) (stop - pos), (Int4) sizeof (bases));
- ctr = SeqPortRead (spp, bases, ctr);
-
- i = 0;
-
- if (ctr < 0) {
- residue = -ctr;
- } else if (ctr < 1) {
- residue = SEQPORT_EOF;
- } else {
- residue = (Uint1) bases [i];
- }
-
-
- ffstring = FFGetString(ajp);
- while (pos < stop && residue != SEQPORT_EOF) {
-
- if (residue == INVALID_RESIDUE) {
- if (is_na) {
- residue = 'N';
- } else {
- residue = 'X';
- }
- }
-
- if (IS_residue (residue)) {
-
- buf [count] = (Char) (TO_LOWER (residue));
- count++;
- cnt++;
- pos++;
-
- blk++;
- lin++;
- if (lin >= 60) {
-
- buf [count] = '\0';
- PrintSeqLine (ffstring, afp->format, buf, start, start + cnt);
- count = 0;
- cnt = 0;
- blk = 0;
- lin = 0;
- start += 60;
-
- } else if (blk >= 10) {
-
- buf [count] = ' ';
- count++;
- blk = 0;
-
- }
- }
-
- i++;
- if (i >= ctr) {
- i = 0;
- ctr = (Int2) MIN ((Int4) (stop - pos), (Int4) sizeof (bases));
- ctr = SeqPortRead (spp, bases, ctr);
- if (ctr < 0) {
- bases [0] = -ctr;
- } else if (ctr < 1) {
- bases [0] = SEQPORT_EOF;
- }
- }
- residue = (Uint1) bases [i];
- }
-
- buf [count] = '\0';
- if (count > 0) {
- PrintSeqLine (ffstring, afp->format, buf, start, start + cnt);
- }
-
- if (ajp->transientSeqPort) {
- iasp->spp = SeqPortFree (iasp->spp);
- }
-
- str = FFToCharPtr(ffstring);
-
- /* optionally populate gbseq for XML-ized GenBank format */
-
- /*
- if (ajp->gbseq) {
- gbseq = &asp->gbseq;
- } else {
- gbseq = NULL;
- }
-
- if (gbseq != NULL) {
- CatenateSequenceInGbseq (gbseq, str);
- }
- */
-
- FFRecycleString(ajp, ffstring);
- return str;
-}
-
-
/* ********************************************************************** */
@@ -23552,6 +2632,7 @@ typedef struct lookforids {
Boolean isNTorNW;
Boolean isNC;
Boolean isTPA;
+ Boolean isAEorCH;
Boolean isNuc;
Boolean isProt;
} LookForIDs, PNTR LookForIDsPtr;
@@ -23576,6 +2657,14 @@ static void LookForSeqIDs (BioseqPtr bsp, Pointer userdata)
case SEQID_EMBL :
case SEQID_DDBJ :
lfip->isGED = TRUE;
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL) {
+ if (StringNCmp (tsip->accession, "AE", 2) == 0) {
+ lfip->isAEorCH = TRUE;
+ } else if (StringNCmp (tsip->accession, "CH", 2) == 0) {
+ lfip->isAEorCH = TRUE;
+ }
+ }
break;
case SEQID_TPG :
case SEQID_TPE :
@@ -23606,6 +2695,7 @@ static void LookForGEDetc (
BoolPtr isNTorNW,
BoolPtr isNC,
BoolPtr isTPA,
+ BoolPtr isAEorCH,
BoolPtr isNuc,
BoolPtr isProt
)
@@ -23619,6 +2709,7 @@ static void LookForGEDetc (
*isNTorNW = lfi.isNTorNW;
*isNC = lfi.isNC;
*isTPA = lfi.isTPA;
+ *isAEorCH = lfi.isAEorCH;
*isNuc = lfi.isNuc;
*isProt = lfi.isProt;
}
@@ -23650,6 +2741,7 @@ NLM_EXTERN Asn2gbJobPtr asn2gnbk_setup (
GBSeqPtr gbseq = NULL;
Int4 i;
IndxPtr index = NULL;
+ Boolean isAEorCH;
Boolean isGED;
Boolean isNTorNW;
Boolean isNC;
@@ -23684,6 +2776,16 @@ NLM_EXTERN Asn2gbJobPtr asn2gnbk_setup (
ValNodePtr vnp;
Boolean is_html = FALSE;
+ if (format == 0) {
+ format = GENBANK_FMT;
+ }
+ if (mode == 0) {
+ mode = SEQUIN_MODE;
+ }
+ if (style == 0) {
+ style = NORMAL_STYLE;
+ }
+
if (extra != NULL) {
index = extra->index;
gbseq = extra->gbseq;
@@ -23840,7 +2942,7 @@ NLM_EXTERN Asn2gbJobPtr asn2gnbk_setup (
aw.onlyNearFeats = FALSE;
aw.farFeatsSuppress = FALSE;
aw.nearFeatsSuppress = FALSE;
- LookForGEDetc (sep, &isGED, &isNTorNW, &isNC, &isTPA, &isNuc, &isProt);
+ LookForGEDetc (sep, &isGED, &isNTorNW, &isNC, &isTPA, &isAEorCH, &isNuc, &isProt);
if (ajp->ajp.slp != NULL) {
/* specified location obeys fetching parameters, for now */
aw.onlyNearFeats = (Boolean) ((flags & FEAT_FETCH_MASK) == ONLY_NEAR_FEATURES);
@@ -23852,6 +2954,13 @@ NLM_EXTERN Asn2gbJobPtr asn2gnbk_setup (
aw.showconfeats = TRUE;
} else if (isNTorNW || isTPA) {
aw.onlyNearFeats = TRUE;
+ } else if (isAEorCH) {
+ /* AE or CH are special cases in CON division */
+ if ((Boolean) ((flags & FEAT_FETCH_MASK) == ONLY_NEAR_FEATURES)) {
+ aw.onlyNearFeats = TRUE;
+ } else {
+ aw.nearFeatsSuppress = TRUE;
+ }
} else if (isNC) {
if ((Boolean) ((flags & FEAT_FETCH_MASK) == ONLY_NEAR_FEATURES)) {
aw.onlyNearFeats = TRUE;
@@ -24024,6 +3133,23 @@ NLM_EXTERN Asn2gbJobPtr asn2gnbk_setup (
return (Asn2gbJobPtr) ajp;
}
+/* ********************************************************************** */
+
+/* format functions allocate printable string for given paragraph */
+
+NLM_EXTERN CharPtr DefaultFormatBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ if (afp == NULL || bbp == NULL) return NULL;
+
+ /* default format function assumes string pre-allocated by add block function */
+
+ return StringSaveNoNull (bbp->string);
+}
+
typedef CharPtr (*FormatProc) (Asn2gbFormatPtr afp, BaseBlockPtr bbp);
static FormatProc asn2gnbk_fmt_functions [27] = {
@@ -24277,7 +3403,7 @@ static void PrintFTCodeBreak (
slp = SeqLocFindNext (cbp->loc, NULL);
while (slp != NULL) {
- str = FlatLoc (&iaj, target, slp, FALSE);
+ str = FFFlatLoc (&iaj, target, slp, FALSE);
if (str != NULL) {
residue = cbaa.value.intvalue;
ptr = Get3LetterSymbol (&iaj, seqcode, sctp, residue);
@@ -24321,6 +3447,253 @@ static SeqIdPtr SeqIdFindForTable (SeqIdPtr sip)
/* #define MAKE_MRNA_GPS_FEAT */
+static void PrintBioSourceFtableEntry (
+ ValNodePtr PNTR head,
+ BioSourcePtr biop
+)
+{
+ OrgModPtr mod;
+ SubSourcePtr ssp;
+ Char str [256];
+
+ if (head == NULL || biop == NULL) return;
+
+ if (biop->org != NULL && ! StringHasNoText (biop->org->taxname))
+ {
+ sprintf (str, "\t\t\torganism\t%s\n", biop->org->taxname);
+ ValNodeCopyStr (head, 0, str);
+ }
+
+ /* add OrgMods */
+ if (biop->org != NULL && biop->org->orgname != NULL)
+ {
+ for (mod = biop->org->orgname->mod;
+ mod != NULL;
+ mod = mod->next)
+ {
+ switch (mod->subtype)
+ {
+ case ORGMOD_strain :
+ sprintf (str, "\t\t\tstrain\t");
+ break;
+ case ORGMOD_substrain :
+ sprintf (str, "\t\t\tsubstrain\t");
+ break;
+ case ORGMOD_type :
+ sprintf (str, "\t\t\ttype\t");
+ break;
+ case ORGMOD_subtype :
+ sprintf (str, "\t\t\tsubtype\t");
+ break;
+ case ORGMOD_variety :
+ sprintf (str, "\t\t\tvariety\t");
+ break;
+ case ORGMOD_serotype :
+ sprintf (str, "\t\t\tserotype\t");
+ break;
+ case ORGMOD_serogroup :
+ sprintf (str, "\t\t\tserogroup\t");
+ break;
+ case ORGMOD_serovar :
+ sprintf (str, "\t\t\tserovar\t");
+ break;
+ case ORGMOD_cultivar :
+ sprintf (str, "\t\t\tcultivar\t");
+ break;
+ case ORGMOD_pathovar :
+ sprintf (str, "\t\t\tpathovar\t");
+ break;
+ case ORGMOD_chemovar :
+ sprintf (str, "\t\t\tchemovar\t");
+ break;
+ case ORGMOD_biovar :
+ sprintf (str, "\t\t\tbiovar\t");
+ break;
+ case ORGMOD_biotype :
+ sprintf (str, "\t\t\tbiotype\t");
+ break;
+ case ORGMOD_group :
+ sprintf (str, "\t\t\tgroup\t");
+ break;
+ case ORGMOD_subgroup :
+ sprintf (str, "\t\t\tsubgroup\t");
+ break;
+ case ORGMOD_isolate :
+ sprintf (str, "\t\t\tisolate\t");
+ break;
+ case ORGMOD_common :
+ sprintf (str, "\t\t\tcommon\t");
+ break;
+ case ORGMOD_acronym :
+ sprintf (str, "\t\t\tacronym\t");
+ break;
+ case ORGMOD_dosage :
+ sprintf (str, "\t\t\tdosage\t");
+ break;
+ case ORGMOD_nat_host :
+ sprintf (str, "\t\t\tnat_host\t");
+ break;
+ case ORGMOD_sub_species :
+ sprintf (str, "\t\t\tsub_species\t");
+ break;
+ case ORGMOD_specimen_voucher :
+ sprintf (str, "\t\t\tspecimen_voucher\t");
+ break;
+ case ORGMOD_authority :
+ sprintf (str, "\t\t\tauthority\t");
+ break;
+ case ORGMOD_forma :
+ sprintf (str, "\t\t\tforma\t");
+ break;
+ case ORGMOD_forma_specialis :
+ sprintf (str, "\t\t\tforma_specialis\t");
+ break;
+ case ORGMOD_ecotype :
+ sprintf (str, "\t\t\tecotype\t");
+ break;
+ case ORGMOD_synonym :
+ sprintf (str, "\t\t\tsynonym\t");
+ break;
+ case ORGMOD_anamorph :
+ sprintf (str, "\t\t\tanamorph\t");
+ break;
+ case ORGMOD_teleomorph :
+ sprintf (str, "\t\t\tteleomorph\t");
+ break;
+ case ORGMOD_breed :
+ sprintf (str, "\t\t\tbreed\t");
+ break;
+ case ORGMOD_gb_acronym :
+ sprintf (str, "\t\t\tgb_acronym\t");
+ break;
+ case ORGMOD_gb_anamorph :
+ sprintf (str, "\t\t\tgb_anamorph\t");
+ break;
+ case ORGMOD_old_lineage :
+ sprintf (str, "\t\t\told_lineage\t");
+ break;
+ case ORGMOD_old_name :
+ sprintf (str, "\t\t\told_name\t");
+ break;
+ case ORGMOD_other :
+ sprintf (str, "\t\t\tnote\t");
+ break;
+ default :
+ str [0] = 0;
+ }
+ if ( str [0] == 0) continue;
+ if (! StringHasNoText (mod->subname))
+ {
+ StringNCat (str, mod->subname, sizeof (str) - StringLen (str) - 2);
+ str [sizeof (str) - 2] = 0;
+ }
+ StringCat (str, "\n");
+ ValNodeCopyStr (head, 0, str);
+ }
+ }
+
+ for (ssp = biop->subtype; ssp != NULL; ssp = ssp->next)
+ {
+ switch (ssp->subtype)
+ {
+ case SUBSRC_chromosome :
+ sprintf (str, "\t\t\tchromosome\t");
+ break;
+ case SUBSRC_map :
+ sprintf (str, "\t\t\tmap\t");
+ break;
+ case SUBSRC_clone :
+ sprintf (str, "\t\t\tclone\t");
+ break;
+ case SUBSRC_haplotype :
+ sprintf (str, "\t\t\thaplotype\t");
+ break;
+ case SUBSRC_genotype :
+ sprintf (str, "\t\t\tgenotype\t");
+ break;
+ case SUBSRC_sex :
+ sprintf (str, "\t\t\tsex\t");
+ break;
+ case SUBSRC_cell_line :
+ sprintf (str, "\t\t\tcell_line\t");
+ break;
+ case SUBSRC_cell_type :
+ sprintf (str, "\t\t\tcell_type\t");
+ break;
+ case SUBSRC_tissue_type :
+ sprintf (str, "\t\t\ttissue_type\t");
+ break;
+ case SUBSRC_clone_lib :
+ sprintf (str, "\t\t\tclone_lib\t");
+ break;
+ case SUBSRC_dev_stage :
+ sprintf (str, "\t\t\tdev_stage\t");
+ break;
+ case SUBSRC_frequency :
+ sprintf (str, "\t\t\tfrequency\t");
+ break;
+ case SUBSRC_germline :
+ sprintf (str, "\t\t\tgermline\t");
+ break;
+ case SUBSRC_rearranged :
+ sprintf (str, "\t\t\trearranged\t");
+ break;
+ case SUBSRC_lab_host :
+ sprintf (str, "\t\t\tlab_host\t");
+ break;
+ case SUBSRC_pop_variant :
+ sprintf (str, "\t\t\tpop_variant\t");
+ break;
+ case SUBSRC_tissue_lib :
+ sprintf (str, "\t\t\ttissue_lib\t");
+ break;
+ case SUBSRC_plasmid_name :
+ sprintf (str, "\t\t\tplasmid_name\t");
+ break;
+ case SUBSRC_transposon_name :
+ sprintf (str, "\t\t\ttransposon_name\t");
+ break;
+ case SUBSRC_insertion_seq_name :
+ sprintf (str, "\t\t\tinsertion_seq_name\t");
+ break;
+ case SUBSRC_plastid_name :
+ sprintf (str, "\t\t\tplastid_name\t");
+ break;
+ case SUBSRC_country :
+ sprintf (str, "\t\t\tcountry\t");
+ break;
+ case SUBSRC_segment :
+ sprintf (str, "\t\t\tsegment\t");
+ break;
+ case SUBSRC_endogenous_virus_name :
+ sprintf (str, "\t\t\tendogenous_virus_name\t");
+ break;
+ case SUBSRC_transgenic :
+ sprintf (str, "\t\t\ttransgenic\t");
+ break;
+ case SUBSRC_environmental_sample :
+ sprintf (str, "\t\t\tenvironmental_sample\t");
+ break;
+ case SUBSRC_isolation_source :
+ sprintf (str, "\t\t\tisolation_source\t");
+ break;
+ case SUBSRC_other :
+ sprintf (str, "\t\t\tnote\t");
+ break;
+ default :
+ str [0] = 0;
+ }
+ if ( str [0] == 0) continue;
+ if (! StringHasNoText (ssp->name))
+ {
+ StringNCat (str, ssp->name, sizeof (str) - StringLen (str) - 2);
+ str [sizeof (str) - 2] = 0;
+ }
+ StringCat (str, "\n");
+ ValNodeCopyStr (head, 0, str);
+ }
+}
+
static void PrintFtableLocAndQuals (
IntAsn2gbJobPtr ajp,
ValNodePtr PNTR head,
@@ -24371,6 +3744,9 @@ static void PrintFtableLocAndQuals (
if (StringCmp (label, "Gene") == 0) {
label = "gene";
}
+ else if (StringCmp (label, "Src") == 0) {
+ label = "source";
+ }
if (StringHasNoText (label)) {
label = "???";
}
@@ -24813,6 +4189,9 @@ static void PrintFtableLocAndQuals (
ValNodeCopyStr (head, 0, tmp);
}
break;
+ case SEQFEAT_BIOSRC :
+ PrintBioSourceFtableEntry (head, sfp->data.value.ptrvalue);
+ break;
default :
break;
}
@@ -24953,6 +4332,46 @@ static BioseqPtr BioseqLockAndIndexByEntity (Uint2 entityID)
return bsp;
}
+static CharPtr FormatFtableSourceFeatBlock (
+ BaseBlockPtr bbp,
+ BioseqPtr target
+)
+{
+ SeqFeatPtr sfp;
+ SeqDescPtr sdp;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ BioSourcePtr biop;
+ ValNodePtr head;
+ IntSrcBlockPtr isp;
+ CharPtr str;
+
+ if (bbp == NULL) return NULL;
+
+ isp = (IntSrcBlockPtr) bbp;
+ head = NULL;
+ biop = NULL;
+
+ if (bbp->itemtype == OBJ_SEQDESC) {
+ sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID,
+ 0, NULL, &dcontext);
+ if (sdp == NULL) return NULL;
+ biop = sdp->data.ptrvalue;
+ } else if (bbp->itemtype == OBJ_SEQFEAT) {
+ sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
+ if (sfp == NULL) return NULL;
+ biop = sfp->data.value.ptrvalue;
+ }
+ if (biop == NULL) return NULL;
+ PrintFtableIntervals (&head, target, isp->loc, "source");
+ PrintBioSourceFtableEntry (&head, biop);
+
+ str = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ return str;
+}
+
NLM_EXTERN CharPtr asn2gnbk_format (
Asn2gbJobPtr ajp,
Int4 paragraph
@@ -25059,7 +4478,7 @@ NLM_EXTERN CharPtr asn2gnbk_format (
sprintf (tmp, "\t\t\tmuid\t%ld\n", (long) irp->rb.muid);
ValNodeCopyStr (&head, 0, tmp);
}
- str = MergeValNodeStrings (head);
+ str = MergeFFValNodeStrs (head);
ValNodeFreeData (head);
}
}
@@ -25070,9 +4489,11 @@ NLM_EXTERN CharPtr asn2gnbk_format (
if (sfp != NULL) {
head = NULL;
PrintFtableLocAndQuals (af.ajp, &head, target, sfp, &fcontext);
- str = MergeValNodeStrings (head);
+ str = MergeFFValNodeStrs (head);
ValNodeFreeData (head);
}
+ } else if (blocktype == SOURCEFEAT_BLOCK) {
+ str = FormatFtableSourceFeatBlock (bbp, target);
}
SeqEntrySetScope (oldscope);
@@ -25380,7 +4801,7 @@ NLM_EXTERN Boolean SeqEntryToGnbk (
for (i = 0; i < numParagraphs; i++) {
str = asn2gnbk_format (ajp, i);
- block = 0;
+ block = (BlockType) 0;
if (paragraphArray != NULL) {
bbp = paragraphArray [i];
if (bbp != NULL) {
diff --git a/api/asn2gnb2.c b/api/asn2gnb2.c
new file mode 100644
index 00000000..3310cbbb
--- /dev/null
+++ b/api/asn2gnb2.c
@@ -0,0 +1,4778 @@
+/* asn2gnb2.c
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: asn2gnb2.c
+*
+* Author: Karl Sirotkin, Tom Madden, Tatiana Tatusov, Jonathan Kans,
+* Mati Shomrat
+*
+* Version Creation Date: 10/21/98
+*
+* $Revision: 1.1 $
+*
+* File Description: New GenBank flatfile generator - work in progress
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <objall.h>
+#include <objsset.h>
+#include <objsub.h>
+#include <objfdef.h>
+#include <objpubme.h>
+#include <seqport.h>
+#include <sequtil.h>
+#include <sqnutils.h>
+#include <subutil.h>
+#include <tofasta.h>
+#include <explore.h>
+#include <gbfeat.h>
+#include <gbftdef.h>
+#include <edutil.h>
+#include <alignmgr2.h>
+#include <asn2gnbi.h>
+
+#ifdef WIN_MAC
+#if __profile__
+#include <Profiler.h>
+#endif
+#endif
+
+/* ********************************************************************** */
+
+static Boolean DeltaLitOnly (
+ BioseqPtr bsp
+)
+
+{
+ ValNodePtr vnp;
+
+ if (bsp == NULL || bsp->repr != Seq_repr_delta) return FALSE;
+ for (vnp = (ValNodePtr)(bsp->seq_ext); vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == 1) return FALSE;
+ }
+ return TRUE;
+}
+
+static Boolean SegHasParts (
+ BioseqPtr bsp
+)
+
+{
+ BioseqSetPtr bssp;
+ SeqEntryPtr sep;
+
+ if (bsp == NULL || bsp->repr != Seq_repr_seg) return FALSE;
+ sep = bsp->seqentry;
+ if (sep == NULL) return FALSE;
+ sep = sep->next;
+ if (sep == NULL || (! IS_Bioseq_set (sep))) return FALSE;
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL && bssp->_class == BioseqseqSet_class_parts) return TRUE;
+ return FALSE;
+}
+
+/* add functions allocate specific blocks, populate with paragraph print info */
+
+static CharPtr strd [4] = {
+ " ", "ss-", "ds-", "ms-"
+};
+
+static CharPtr gnbk_mol [14] = {
+ " ", "DNA ", "RNA ", "mRNA", "rRNA", "tRNA", "snRNA", "scRNA", " AA ", "DNA ", "DNA ", "RNA ", "snoRNA", "RNA "
+};
+
+/* EMBL_FMT in RELEASE_MODE or ENTREZ_MODE, otherwise use gnbk_mol */
+
+static CharPtr embl_mol [14] = {
+ "xxx", "DNA", "RNA", "RNA", "RNA", "RNA", "RNA", "RNA", "AA ", "DNA", "DNA", "RNA", "RNA", "RNA"
+};
+
+static CharPtr embl_divs [18] = {
+ "FUN", "INV", "MAM", "ORG", "PHG", "PLN", "PRI", "PRO", "ROD"
+ "SYN", "UNA", "VRL", "VRT", "PAT", "EST", "STS", "HUM", "HTC"
+};
+
+static Uint1 imolToMoltype [14] = {
+ 0, 1, 2, 5, 4, 3, 6, 7, 9, 1, 1, 2, 8, 2
+};
+
+static DatePtr GetBestDate (
+ DatePtr a,
+ DatePtr b
+)
+
+{
+ Int2 status;
+
+ if (a == NULL) return b;
+ if (b == NULL) return a;
+
+ status = DateMatch (a, b, FALSE);
+ if (status == 1) return a;
+
+ return b;
+}
+
+/*--------------------------------------------------------*/
+/* */
+/* s_IsSeperatorNeeded() */
+/* */
+/*--------------------------------------------------------*/
+
+static Boolean s_IsSeperatorNeeded(CharPtr baseString, Int4 baseLength, Int2 suffixLength)
+{
+ Char lastChar;
+ Char nextToLastChar;
+
+ lastChar = baseString[baseLength - 1];
+ nextToLastChar = baseString[baseLength - 2];
+
+ /* This first check put here to emulate what may be a */
+ /* bug in the original code (in CheckLocusLength() ) */
+ /* which adds an 'S' segment seperator only if it */
+ /* DOES make the string longer than the max. */
+
+ if (baseLength + suffixLength < 16)
+ return FALSE;
+
+ /* If the last character is not a digit */
+ /* then don't use a seperator. */
+
+ if (!IS_DIGIT(lastChar))
+ return FALSE;
+
+ /* If the last two characters are a non-digit */
+ /* followed by a '0', then don't use seperator. */
+
+ if ((lastChar == '0') && (!IS_DIGIT(nextToLastChar)))
+ return FALSE;
+
+ /* If we made it to here, use a seperator */
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------*/
+/* */
+/* s_LocusAddSuffix() - */
+/* */
+/*--------------------------------------------------------*/
+
+static Boolean s_LocusAddSuffix (CharPtr locus, Asn2gbWorkPtr awp)
+{
+ size_t buflen;
+ Char ch;
+ Char segCountStr[6];
+ Int2 segCountStrLen;
+ Char segSuffix[5];
+
+ buflen = StringLen (locus);
+
+ /* If there's one or less segments, */
+ /* no suffix is needed. */
+
+ if (awp->numsegs <= 1)
+ return FALSE;
+
+ /* If the basestring has one or less */
+ /* characters, no suffix is needed. */
+
+ if (buflen <=1)
+ return FALSE;
+
+ /* Add the suffix */
+
+ ch = locus[buflen-1];
+ sprintf(segCountStr,"%d",awp->numsegs);
+ segCountStrLen = StringLen(segCountStr);
+ segSuffix[0] = '\0';
+
+ if (s_IsSeperatorNeeded(locus,buflen,segCountStrLen) == TRUE)
+ sprintf(segSuffix,"S%0*d",segCountStrLen,awp->seg);
+ else
+ sprintf(segSuffix,"%0*d",segCountStrLen,awp->seg);
+ StringCat(locus,segSuffix);
+
+ /* Return successfully */
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------*/
+/* */
+/* s_LocusAdjustLength() - */
+/* */
+/*--------------------------------------------------------*/
+
+static Boolean s_LocusAdjustLength(CharPtr locus, Int2 maxLength)
+{
+ Int2 trimCount;
+ Int2 buflen;
+ CharPtr buftmp;
+
+ buflen = StringLen (locus);
+ if (buflen <= maxLength) return FALSE;
+
+ buftmp = MemNew(maxLength + 1);
+
+ /* If the sequence id is an NCBI locus of the */
+ /* form HSU00001, then make sure that if */
+ /* there is trimming the HS gets trimmed off */
+ /* as a unit, never just the 'H'. */
+
+ trimCount = buflen - maxLength;
+ if (trimCount == 1)
+ if (IS_ALPHA(locus[0]) != 0 &&
+ IS_ALPHA(locus[1]) != 0 &&
+ IS_ALPHA(locus[2]) != 0 &&
+ IS_DIGIT(locus[3]) != 0 &&
+ IS_DIGIT(locus[4]) != 0 &&
+ IS_DIGIT(locus[5]) != 0 &&
+ IS_DIGIT(locus[6]) != 0 &&
+ IS_DIGIT(locus[7]) != 0 &&
+ locus[8] == 'S' &&
+ locus[9] == '\0')
+ trimCount++;
+
+ /* Left truncate the sequence id */
+
+ StringCpy(buftmp, &locus[trimCount]);
+ StringCpy(locus, buftmp);
+
+ MemFree(buftmp);
+ return TRUE;
+}
+
+/*--------------------------------------------------------*/
+/* */
+/* AddLocusBlock() - */
+/* */
+/*--------------------------------------------------------*/
+
+static DatePtr GetBestDateForBsp (
+ BioseqPtr bsp
+)
+
+{
+ DatePtr best_date = NULL;
+ SeqMgrDescContext dcontext;
+ DatePtr dp;
+ EMBLBlockPtr ebp;
+ GBBlockPtr gbp;
+ PdbBlockPtr pdp;
+ PdbRepPtr prp;
+ SeqDescrPtr sdp;
+ SPBlockPtr spp;
+
+ if (bsp == NULL) return NULL;
+
+ dp = NULL;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_update_date, &dcontext);
+ if (sdp != NULL) {
+ dp = (DatePtr) sdp->data.ptrvalue;
+ best_date = GetBestDate (dp, best_date);
+ }
+
+ /* !!! temporarily also look at genbank block entry date !!! */
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
+ if (sdp != NULL) {
+ gbp = (GBBlockPtr) sdp->data.ptrvalue;
+ if (gbp != NULL) {
+ dp = gbp->entry_date;
+ best_date = GetBestDate (dp, best_date);
+ }
+ }
+
+ /* more complicated code for dates from various objects goes here */
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_embl, &dcontext);
+ if (sdp != NULL) {
+ ebp = (EMBLBlockPtr) sdp->data.ptrvalue;
+ if (ebp != NULL) {
+ dp = ebp->creation_date;
+ best_date = GetBestDate (dp, best_date);
+ dp = ebp->update_date;
+ best_date = GetBestDate (dp, best_date);
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_sp, &dcontext);
+ if (sdp != NULL) {
+ spp = (SPBlockPtr) sdp->data.ptrvalue;
+ if (spp != NULL) {
+ dp = spp->created;
+ if (dp != NULL && dp->data [0] == 1) {
+ best_date = GetBestDate (dp, best_date);
+ }
+ dp = spp->sequpd;
+ if (dp != NULL && dp->data [0] == 1) {
+ best_date = GetBestDate (dp, best_date);
+ }
+ dp = spp->annotupd;
+ if (dp != NULL && dp->data [0] == 1) {
+ best_date = GetBestDate (dp, best_date);
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_pdb, &dcontext);
+ if (sdp != NULL) {
+ pdp = (PdbBlockPtr) sdp->data.ptrvalue;
+ if (pdp != NULL) {
+ dp = pdp->deposition;
+ if (dp != NULL && dp->data [0] == 1) {
+ best_date = GetBestDate (dp, best_date);
+ }
+ prp = pdp->replace;
+ if (prp != NULL) {
+ dp = prp->date;
+ if (dp != NULL && dp->data[0] == 1) {
+ best_date = GetBestDate (dp, best_date);
+ }
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_create_date, &dcontext);
+ if (sdp != NULL) {
+ dp = (DatePtr) sdp->data.ptrvalue;
+ if (dp != NULL) {
+ best_date = GetBestDate (dp, best_date);
+ }
+ }
+
+ return best_date;
+}
+
+static Boolean LocusHasBadChars (
+ CharPtr locus
+)
+
+{
+ Char ch;
+ CharPtr ptr;
+
+ ptr = locus;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (! IS_ALPHANUM (ch)) {
+ return TRUE;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ return FALSE;
+}
+
+NLM_EXTERN void AddLocusBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ size_t acclen;
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp;
+ DatePtr best_date = NULL;
+ BioSourcePtr biop;
+ Int2 bmol = 0;
+ BioseqPtr bsp;
+ SeqFeatPtr cds;
+ Char date [40];
+ SeqMgrDescContext dcontext;
+ Char div [10];
+ BioseqPtr dna;
+ DatePtr dp;
+ CharPtr ebmol;
+ EMBLBlockPtr ebp;
+ SeqMgrFeatContext fcontext;
+ GBBlockPtr gbp;
+ Char gene [32];
+ Boolean genome_view;
+ GBSeqPtr gbseq;
+ Char id [41];
+ Int2 imol = 0;
+ IndxPtr index;
+ Int2 istrand;
+ Boolean is_nm = FALSE;
+ Boolean is_np = FALSE;
+ Boolean is_nz = FALSE;
+ Boolean is_transgenic = FALSE;
+ Char len [32];
+ Int4 length;
+ size_t loclen;
+ Char locus [41];
+ MolInfoPtr mip;
+ Char mol [30];
+ BioseqPtr nm = NULL;
+ OrgNamePtr onp;
+ Uint1 origin;
+ OrgRefPtr orp;
+ BioseqPtr parent;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+ SeqIdPtr sip;
+ SubSourcePtr ssp;
+ Uint1 tech;
+ Uint1 topology;
+ TextSeqIdPtr tsip;
+ Boolean wgsmaster = FALSE;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, LOCUS_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ mol [0] = '\0';
+ len [0] = '\0';
+ div [0] = '\0';
+ date [0] = '\0';
+ gene [0] = '\0';
+
+ genome_view = FALSE;
+ if (bsp->repr == Seq_repr_seg && (! SegHasParts (bsp))) {
+ genome_view = TRUE;
+ }
+ if (bsp->repr == Seq_repr_delta && (! DeltaLitOnly (bsp))) {
+ genome_view = TRUE;
+ }
+
+ /* locus id */
+
+ sip = NULL;
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_OTHER) {
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL) {
+ if (StringNCmp (tsip->accession, "NM_", 3) == 0 ||
+ StringNCmp (tsip->accession, "NR_", 3) == 0 ||
+ StringNCmp (tsip->accession, "XM_", 3) == 0 ||
+ StringNCmp (tsip->accession, "XR_", 3) == 0) {
+ is_nm = TRUE;
+ nm = bsp;
+ } else if (StringNCmp (tsip->accession, "NP_", 3) == 0 ||
+ StringNCmp (tsip->accession, "XP_", 3) == 0) {
+ is_np = TRUE;
+ } else if (StringNCmp (tsip->accession, "NZ_", 3) == 0) {
+ is_nz = TRUE;
+ }
+ }
+ break;
+ }
+ if (sip->choice == SEQID_GENBANK ||
+ sip->choice == SEQID_EMBL ||
+ sip->choice == SEQID_DDBJ) break;
+ if (sip->choice == SEQID_PIR ||
+ sip->choice == SEQID_SWISSPROT ||
+ sip->choice == SEQID_PRF ||
+ sip->choice == SEQID_PDB) break;
+ if (sip->choice == SEQID_TPG ||
+ sip->choice == SEQID_TPE ||
+ sip->choice == SEQID_TPD) break;
+ }
+ if (sip == NULL) {
+ sip = SeqIdFindBest (bsp->id, SEQID_GENBANK);
+ }
+
+ if (genome_view) {
+ SeqIdWrite (sip, locus, PRINTID_TEXTID_ACCESSION, sizeof (locus) - 1);
+ } else {
+ SeqIdWrite (sip, locus, PRINTID_TEXTID_LOCUS, sizeof (locus) - 1);
+ if (LocusHasBadChars (locus)) {
+ SeqIdWrite (sip, locus, PRINTID_TEXTID_ACCESSION, sizeof (locus) - 1);
+ }
+ }
+
+ if (is_np) {
+ sfp = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
+ if (sfp != NULL && fcontext.bsp != NULL) {
+ nm = fcontext.bsp;
+ for (sip = nm->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_OTHER) {
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL) {
+ if (StringNCmp (tsip->accession, "NM_", 3) == 0 ||
+ StringNCmp (tsip->accession, "XM_", 3) == 0) {
+ is_nm = TRUE;
+ }
+ }
+ }
+ }
+ if (! is_nm) {
+ nm = NULL;
+ }
+ }
+ }
+ if (nm != NULL) {
+ /*
+ sfp = SeqMgrGetNextFeature (nm, NULL, SEQFEAT_GENE, 0, &fcontext);
+ if (sfp != NULL) {
+ StringNCpy_0 (gene, fcontext.label, sizeof (gene));
+ if (SeqMgrGetNextFeature (nm, sfp, SEQFEAT_GENE, 0, &fcontext) != NULL) {
+ gene [0] = '\0';
+ }
+ if (StringLen (gene) > 15) {
+ gene [0] = '\0';
+ }
+ }
+ */
+ }
+
+ /* more complicated code to get parent locus, if segmented, goes here */
+
+ if (awp->slp != NULL) {
+ length = SeqLocLen (awp->slp);
+ } else {
+ length = bsp->length;
+ }
+
+ mip = NULL;
+ tech = MI_TECH_standard;
+ origin = 0;
+ bmol = bsp->mol;
+ if (bmol > Seq_mol_aa) {
+ bmol = 0;
+ }
+ istrand = bsp->strand;
+ if (istrand > 3) {
+ istrand = 0;
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp != NULL) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip != NULL) {
+ if (mip->biomol <= MOLECULE_TYPE_TRANSCRIBED_RNA) {
+ imol = (Int2) mip->biomol;
+ }
+ tech = mip->tech;
+
+ if (tech == MI_TECH_wgs && bsp->repr == Seq_repr_virtual) {
+
+ /* check for WGS master record */
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ switch (sip->choice) {
+ case SEQID_GENBANK :
+ case SEQID_EMBL :
+ case SEQID_DDBJ :
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL && tsip->accession != NULL) {
+ acclen = StringLen (tsip->accession);
+ if (acclen == 12) {
+ if (StringCmp (tsip->accession + 6, "000000") == 0) {
+ wgsmaster = TRUE;
+ }
+ } else if (acclen == 13) {
+ if (StringCmp (tsip->accession + 6, "0000000") == 0) {
+ wgsmaster = TRUE;
+ }
+ }
+ }
+ break;
+ case SEQID_OTHER :
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL && tsip->accession != NULL) {
+ if (StringLen (tsip->accession) == 15) {
+ if (StringCmp (tsip->accession + 9, "000000") == 0) {
+ wgsmaster = TRUE;
+ }
+ }
+ }
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /* check inst.mol if mol-type is not-set or genomic */
+
+ if (imol <= MOLECULE_TYPE_GENOMIC) {
+ if (bmol == Seq_mol_aa) {
+ imol = MOLECULE_TYPE_PEPTIDE;
+ } else if (bmol == Seq_mol_na) {
+ imol = 0;
+ } else if (bmol == Seq_mol_rna) {
+ imol = 2;
+ } else {
+ imol = 1;
+ }
+ } else if (imol == MOLECULE_TYPE_OTHER_GENETIC_MATERIAL) {
+ if (bmol == Seq_mol_rna) {
+ imol = 2;
+ }
+ }
+
+ /* if ds-DNA don't show ds */
+
+ if (bmol == Seq_mol_dna && istrand == 2) {
+ istrand = 0;
+ }
+
+ /* ss=any RNA don't show ss */
+
+ if ((bmol > Seq_mol_rna ||
+ (imol >= MOLECULE_TYPE_MRNA && imol <= MOLECULE_TYPE_PEPTIDE)) &&
+ istrand == 1) {
+ istrand = 0;
+ }
+
+ topology = bsp->topology;
+ if (awp->slp != NULL) {
+ topology = TOPOLOGY_LINEAR;
+ }
+
+ /* length, topology, and molecule type */
+
+ if (awp->format == GENBANK_FMT) {
+
+ if (awp->newLocusLine) {
+
+ if (wgsmaster && (! is_nz)) {
+ sprintf (len, "%ld rc", (long) length);
+ } else {
+ sprintf (len, "%ld bp", (long) length);
+ }
+ sprintf (mol, "%s%-4s", strd [istrand], gnbk_mol [imol]);
+
+ } else {
+
+ if (topology == TOPOLOGY_CIRCULAR) {
+ sprintf (len, "%7ld bp", (long) length);
+ sprintf (mol, "%s%-4s circular", strd [istrand], gnbk_mol [imol]);
+ } else {
+ sprintf (len, "%7ld bp", (long) length);
+ sprintf (mol, "%s%-4s ", strd [istrand], gnbk_mol [imol]);
+ }
+ }
+
+ } else if (awp->format == GENPEPT_FMT) {
+
+ if (awp->newLocusLine) {
+ sprintf (len, "%ld aa", (long) length);
+ } else {
+ sprintf (len, "%7ld aa", (long) length);
+ }
+
+ } else if (awp->format == EMBL_FMT) {
+
+ if (imol < MOLECULE_TYPE_PEPTIDE) {
+ if (ajp->flags.useEmblMolType) {
+ ebmol = embl_mol [imol];
+ } else {
+ ebmol = gnbk_mol [imol];
+ }
+
+ if (topology == TOPOLOGY_CIRCULAR) {
+ sprintf (mol, "circular %s", ebmol);
+ sprintf (len, "%ld BP.", (long) length);
+ } else {
+ sprintf (mol, "%s", ebmol);
+ sprintf (len, "%ld BP.", (long) length);
+ }
+ }
+ }
+
+ /* division */
+
+ biop = NULL;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ } else {
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_BIOSRC, 0, &fcontext);
+ if (sfp != NULL) {
+ biop = (BioSourcePtr) sfp->data.value.ptrvalue;
+ } else if (ISA_aa (bsp->mol)) {
+
+ /* if protein with no sources, get sources applicable to DNA location of CDS */
+
+ cds = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
+ if (cds != NULL) {
+ sfp = SeqMgrGetOverlappingSource (cds->location, &fcontext);
+ if (sfp != NULL) {
+ biop = (BioSourcePtr) sfp->data.value.ptrvalue;
+ } else {
+ dna = BioseqFindFromSeqLoc (cds->location);
+ if (dna != NULL) {
+ sdp = SeqMgrGetNextDescriptor (dna, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (biop != NULL) {
+ origin = biop->origin;
+ orp = biop->org;
+ if (orp != NULL) {
+ onp = orp->orgname;
+ if (onp != NULL) {
+ StringNCpy_0 (div, onp->div, sizeof (div));
+ }
+ }
+ for (ssp = biop->subtype; ssp != NULL; ssp = ssp->next) {
+ if (ssp->subtype == SUBSRC_transgenic) {
+ is_transgenic = TRUE;
+ }
+ }
+ }
+
+ switch (tech) {
+ case MI_TECH_est :
+ StringCpy (div, "EST");
+ break;
+ case MI_TECH_sts :
+ StringCpy (div, "STS");
+ break;
+ case MI_TECH_survey :
+ StringCpy (div, "GSS");
+ break;
+ case MI_TECH_htgs_0 :
+ case MI_TECH_htgs_1 :
+ case MI_TECH_htgs_2 :
+ StringCpy (div, "HTG");
+ break;
+ case MI_TECH_htc :
+ StringCpy (div, "HTC");
+ break;
+ default :
+ break;
+ }
+
+ if (origin == ORG_MUT || origin == ORG_ARTIFICIAL || origin == ORG_SYNTHETIC || is_transgenic) {
+ StringCpy (div, "SYN");
+ }
+
+ sip = SeqIdFindBest (bsp->id, SEQID_PATENT);
+ if (sip != NULL && sip->choice == SEQID_PATENT) {
+ StringCpy (div, "PAT");
+ }
+
+ /* more complicated code for division, if necessary, goes here */
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
+ while (sdp != NULL) {
+ gbp = (GBBlockPtr) sdp->data.ptrvalue;
+ if (gbp != NULL) {
+ if (StringHasNoText (div) && gbp->div != NULL) {
+ StringCpy (div, gbp->div);
+ }
+ else if (StringCmp(gbp->div, "PAT") == 0 ||
+ StringCmp(gbp->div, "SYN") == 0 ) {
+ StringCpy (div, gbp->div);
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_genbank, &dcontext);
+ }
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_embl, &dcontext);
+ if (sdp != NULL) {
+ ebp = (EMBLBlockPtr) sdp->data.ptrvalue;
+ if (ebp != NULL) {
+ if (ebp->div == 255) {
+ if (mip == NULL) {
+ StringCpy (div, "HUM");
+ }
+ } else if (ebp->div < 18) {
+ StringCpy (div, embl_divs [ebp->div]);
+ }
+ }
+ }
+
+ if (StringHasNoText (div)) {
+ StringCpy (div, "UNA");
+ }
+ }
+
+ /* empty division field if unable to find anything */
+
+ if (StringHasNoText (div)) {
+ StringCpy (div, " ");
+ }
+
+ /* contig style (old genome_view flag) forces CON division */
+
+ if (awp->contig) {
+ StringCpy (div, "CON");
+ }
+
+ if (genome_view) {
+ StringCpy (div, "CON");
+ }
+
+ /* date */
+
+ best_date = GetBestDateForBsp (bsp);
+
+ if (best_date == NULL) {
+
+ /* if bsp is product of CDS or mRNA feature, get date from sfp->location bsp */
+
+ sfp = NULL;
+ if (ISA_na (bsp->mol)) {
+ sfp = SeqMgrGetRNAgivenProduct (bsp, NULL);
+ } else if (ISA_aa (bsp->mol)) {
+ sfp = SeqMgrGetCDSgivenProduct (bsp, NULL);
+ }
+ if (sfp != NULL) {
+ parent = BioseqFindFromSeqLoc (sfp->location);
+ if (parent != NULL) {
+ best_date = GetBestDateForBsp (parent);
+ }
+ }
+ }
+
+ /* convert best date */
+
+ if (best_date != NULL) {
+ DateToFF (date, best_date, FALSE);
+ }
+ if (StringHasNoText (date)) {
+ StringCpy (date, "01-JAN-1900");
+ }
+
+ if (awp->format == GENBANK_FMT || awp->format == GENPEPT_FMT) {
+
+ /* Create the proper locus name */
+
+ parent = awp->parent;
+ if (parent->repr == Seq_repr_seg) {
+
+ if (! StringHasNoText (awp->basename)) {
+ StringCpy (locus, awp->basename);
+ s_LocusAddSuffix (locus, awp);
+ }
+ }
+
+ /* Print the "LOCUS_NEW" line, if requested */
+
+ if (awp->newLocusLine) {
+ FFStartPrint (ffstring, awp->format, 0, 0, "LOCUS", 12, 0, 0, NULL, FALSE);
+ parent = awp->parent;
+
+ if (parent->repr == Seq_repr_seg)
+ s_LocusAdjustLength (locus,16);
+
+ if (is_nm && (! StringHasNoText (gene))) {
+ FFAddOneString (ffstring, gene, FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, locus, FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddNChar(ffstring, ' ', 43 - StringLen(len)- ffstring->curr->pos, FALSE);
+ FFAddOneString (ffstring, len, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 44 - ffstring->curr->pos, FALSE);
+ FFAddOneString (ffstring, mol, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 55 - ffstring->curr->pos, FALSE);
+ if (topology == TOPOLOGY_CIRCULAR) {
+ FFAddOneString (ffstring, "circular", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, "linear ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddNChar(ffstring, ' ', 64 - ffstring->curr->pos, FALSE);
+ FFAddOneString (ffstring, div, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 68 - ffstring->curr->pos, FALSE);
+ FFAddOneString (ffstring, date, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ /* Else print the "LOCUS" line */
+
+ else {
+ FFStartPrint (ffstring, awp->format, 0, 0, "LOCUS", 12, 0, 0, NULL, FALSE);
+
+ if (parent->repr == Seq_repr_seg)
+ s_LocusAdjustLength (locus,16);
+
+ FFAddOneString (ffstring, locus, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 32 - StringLen(len) - ffstring->curr->pos, FALSE);
+ FFAddOneString (ffstring, len, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 33 - ffstring->curr->pos, FALSE);
+ FFAddOneString (ffstring, mol, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 52 - ffstring->curr->pos, FALSE);
+ FFAddOneString (ffstring, div, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 62 - ffstring->curr->pos, FALSE);
+ FFAddOneString (ffstring, date, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ } else if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ FFStartPrint (ffstring, awp->format, 0, 0, NULL, 0, 5, 0, "ID", FALSE);
+ FFAddOneString (ffstring, locus, FALSE, FALSE, TILDE_IGNORE);
+ loclen = StringLen(locus);
+ if (14 - 5 - loclen > 0) {
+ FFAddNChar(ffstring, ' ', 14 - 5 - loclen, FALSE);
+ }
+ if (awp->hup) {
+ FFAddOneString (ffstring, " confidential; ", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, " standard; ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, mol, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, "; ", FALSE, FALSE, TILDE_IGNORE);
+
+ /* conditional code to make div "UNA" goes here */
+
+ FFAddOneString (ffstring, div, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, "; ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, len, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ /* optionally populate indexes for NCBI internal database */
+
+ if (ajp->index) {
+ index = &asp->index;
+ } else {
+ index = NULL;
+ }
+
+ if (index != NULL) {
+ Char tmp [20];
+ index->locus = StringSave (locus);
+ index->div = StringSave (div);
+ sprintf (tmp, "%ld", (long) length);
+ index->base_cnt = StringSave (tmp);
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ gbseq->locus = StringSave (locus);
+ gbseq->length = length;
+ gbseq->division = StringSave (div);
+ gbseq->strandedness = bsp->strand;
+ gbseq->moltype = imolToMoltype [imol];
+ gbseq->topology = topology;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ SeqIdWrite (sip, id, PRINTID_FASTA_SHORT, sizeof (id));
+ ValNodeCopyStr (&gbseq->other_seqids, 0, id);
+ }
+
+ date [0] = '\0';
+ dp = NULL;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_create_date, &dcontext);
+ if (sdp != NULL) {
+ dp = (DatePtr) sdp->data.ptrvalue;
+ }
+ if (dp != NULL) {
+ DateToFF (date, dp, FALSE);
+ }
+ if (StringHasNoText (date)) {
+ StringCpy (date, "01-JAN-1900");
+ }
+ gbseq->create_date = StringSave (date);
+
+ date [0] = '\0';
+ dp = NULL;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_update_date, &dcontext);
+ if (sdp != NULL) {
+ dp = (DatePtr) sdp->data.ptrvalue;
+ }
+ if (dp != NULL) {
+ DateToFF (date, dp, FALSE);
+ }
+ if (StringHasNoText (date)) {
+ StringCpy (date, "01-JAN-1900");
+ }
+ gbseq->update_date = StringSave (date);
+ }
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 0, 5, 0, "ID");
+ FFRecycleString(ajp, ffstring);
+}
+
+NLM_EXTERN void AddDeflineBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Char buf[4096];
+ /*CharPtr buf;
+ size_t buflen = 4096;*/
+ SeqMgrDescContext dcontext;
+ GBSeqPtr gbseq;
+ ItemInfo ii;
+ MolInfoPtr mip;
+ SeqDescrPtr sdp;
+ Uint1 tech;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, DEFLINE_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ tech = 0;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp != NULL) {
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip != NULL) {
+ tech = mip->tech;
+ }
+ }
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ /*buf = MemNew (sizeof (Char) * (buflen + 1));*/
+ MemSet ((Pointer) (&ii), 0, sizeof (ItemInfo));
+ MemSet ((Pointer) buf, 0, sizeof (buf));
+
+ /* create default defline */
+
+ if ( CreateDefLine (&ii, bsp, buf, sizeof(buf), tech, NULL, NULL)) {
+ bbp->entityID = ii.entityID;
+ bbp->itemID = ii.itemID;
+ bbp->itemtype = ii.itemtype;
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "DEFINITION", 12, 5, 5, "DE", TRUE);
+
+ if (StringHasNoText (buf)) {
+ FFAddOneChar (ffstring, '.', FALSE);
+ } else {
+ FFAddOneString (ffstring, buf, TRUE, TRUE, TILDE_IGNORE);
+ }
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "DE");
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ gbseq->definition = StringSave (buf);
+ }
+
+ FFRecycleString(ajp, ffstring);
+}
+
+static void FF_www_accession (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr cstring
+)
+{
+ if (cstring == NULL || ffstring == NULL) return;
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "val=", cstring, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, cstring, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, cstring, FALSE, FALSE, TILDE_IGNORE);
+ }
+ return;
+}
+
+/* !!! this definitely needs more work to support all classes, use proper SeqId !!! */
+
+NLM_EXTERN void AddAccessionBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ size_t acclen;
+ SeqIdPtr accn = NULL;
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Char buf [41];
+ SeqMgrDescContext dcontext;
+ EMBLBlockPtr ebp;
+ ValNodePtr extra_access;
+ CharPtr flatloc;
+ GBBlockPtr gbp;
+ SeqIdPtr gi = NULL;
+ GBSeqPtr gbseq;
+ IndxPtr index;
+ SeqIdPtr lcl = NULL;
+ size_t len = 0;
+ MolInfoPtr mip;
+ SeqDescrPtr sdp;
+ CharPtr separator = " ";
+ SeqIdPtr sip;
+ TextSeqIdPtr tsip;
+ ValNodePtr vnp;
+ CharPtr wgsaccn = NULL;
+ CharPtr xtra;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ switch (sip->choice) {
+ case SEQID_GI :
+ gi = sip;
+ break;
+ case SEQID_GENBANK :
+ case SEQID_EMBL :
+ case SEQID_DDBJ :
+ accn = sip;
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL) {
+ acclen = StringLen (tsip->accession);
+ if (acclen == 12) {
+ wgsaccn = tsip->accession;
+ len = 12;
+ } else if (acclen == 13) {
+ wgsaccn = tsip->accession;
+ len = 13;
+ }
+ }
+ break;
+ case SEQID_OTHER :
+ accn = sip;
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL) {
+ if (StringLen (tsip->accession) == 15) {
+ wgsaccn = tsip->accession;
+ len = 15;
+ }
+ }
+ break;
+ case SEQID_PIR :
+ case SEQID_SWISSPROT :
+ case SEQID_PRF :
+ case SEQID_PDB :
+ accn = sip;
+ break;
+ case SEQID_TPG :
+ case SEQID_TPE :
+ case SEQID_TPD :
+ accn = sip;
+ break;
+ case SEQID_GENERAL :
+ /* should not override better accession */
+ if (accn == NULL) {
+ accn = sip;
+ }
+ break;
+ case SEQID_LOCAL :
+ lcl = sip;
+ break;
+ default :
+ break;
+ }
+ }
+
+ sip = NULL;
+ if (accn != NULL) {
+ sip = accn;
+ } else if (lcl != NULL) {
+ sip = lcl;
+ } else if (gi != NULL) {
+ sip = gi;
+ }
+
+ if (sip == NULL) return;
+
+ SeqIdWrite (sip, buf, PRINTID_TEXTID_ACC_ONLY, sizeof (buf));
+
+ bbp = Asn2gbAddBlock (awp, ACCESSION_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "ACCESSION", 12, 5, 5, "AC", TRUE);
+
+ if (awp->hup && accn != NULL) {
+ FFAddOneString (ffstring, ";", FALSE, FALSE, TILDE_TO_SPACES);
+
+ } else if (ajp->ajp.slp != NULL) {
+ FF_www_accession (ajp, ffstring, buf);
+ flatloc = FFFlatLoc (ajp, bsp, ajp->ajp.slp, ajp->masterStyle);
+ FFAddTextToString (ffstring, " REGION: ", flatloc, NULL, FALSE, FALSE, TILDE_TO_SPACES);
+ MemFree (flatloc);
+ } else {
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ FFAddOneChar(ffstring, ';', FALSE);
+ }
+ }
+
+ /* optionally populate indexes for NCBI internal database */
+
+ if (ajp->index) {
+ index = &asp->index;
+ } else {
+ index = NULL;
+ }
+
+ if (index != NULL) {
+ index->accession = StringSave (buf);
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ gbseq->primary_accession = StringSave (buf);
+ }
+
+ if (awp->format == GENBANK_FMT || awp->format == GENPEPT_FMT) {
+ separator = " ";
+ } else if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ separator = " ";
+ }
+
+ if (ajp->ajp.slp == NULL) {
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp != NULL && wgsaccn != NULL) {
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip != NULL && mip->tech == MI_TECH_wgs) {
+ StringNCpy_0 (buf, wgsaccn, sizeof (buf));
+ acclen = StringLen (buf);
+ if (acclen == 12 && StringCmp (buf + len - 6, "000000") != 0) {
+ StringCpy (buf + len - 6, "000000");
+ } else if (acclen == 13 && StringCmp (buf + len - 7, "0000000") != 0) {
+ StringCpy (buf + len - 7, "0000000");
+ } else if (acclen == 15 && StringCmp (buf + len - 8, "00000000") != 0) {
+ StringCpy (buf + len - 8, "00000000");
+ } else {
+ buf [0] = '\0';
+ }
+ if (! StringHasNoText (buf)) {
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString(ffstring, separator, "<a href=", link_wgs, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "db=Nucleotide&cmd=Search&term=", buf, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_TO_SPACES);
+ } else {
+ FFAddTextToString(ffstring, separator, buf, NULL, FALSE, FALSE, TILDE_TO_SPACES);
+ }
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ FFAddOneChar(ffstring, ';', FALSE);
+ }
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, 0, &dcontext);
+ while (sdp != NULL) {
+
+ extra_access = NULL;
+
+ switch (dcontext.seqdesctype) {
+ case Seq_descr_genbank :
+ gbp = (GBBlockPtr) sdp->data.ptrvalue;
+ if (gbp != NULL) {
+ extra_access = gbp->extra_accessions;
+ }
+ break;
+ case Seq_descr_embl :
+ ebp = (EMBLBlockPtr) sdp->data.ptrvalue;
+ if (ebp != NULL) {
+ extra_access = ebp->extra_acc;
+ }
+ break;
+ default :
+ break;
+ }
+
+ if (extra_access != NULL) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ }
+
+ for (vnp = extra_access; vnp != NULL; vnp = vnp->next) {
+ xtra = (CharPtr) vnp->data.ptrvalue;
+ if (ValidateAccn (xtra) == 0) {
+ FFAddTextToString(ffstring, separator, xtra, NULL, FALSE, FALSE, TILDE_TO_SPACES);
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ FFAddOneChar(ffstring, ';', FALSE);
+ }
+
+ /* optionally populate indexes for NCBI internal database */
+
+ if (index != NULL) {
+ ValNodeCopyStrToHead (&(index->secondaries), 0, xtra);
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (gbseq != NULL) {
+ ValNodeCopyStr (&(gbseq->secondary_accessions), 0, xtra);
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, 0, &dcontext);
+ }
+ }
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "AC");
+ FFRecycleString(ajp, ffstring);
+}
+
+NLM_EXTERN void AddVersionBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ SeqIdPtr accn = NULL;
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Char buf [41];
+ GBSeqPtr gbseq;
+ Int4 gi = -1;
+ IndxPtr index;
+ CharPtr ptr;
+ SeqIdPtr sip;
+ Char tmp [41];
+ Char version [64];
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ switch (sip->choice) {
+ case SEQID_GI :
+ gi = sip->data.intvalue;
+ break;
+ case SEQID_GENBANK :
+ case SEQID_EMBL :
+ case SEQID_DDBJ :
+ case SEQID_OTHER :
+ accn = sip;
+ break;
+ case SEQID_PIR :
+ case SEQID_SWISSPROT :
+ case SEQID_PRF :
+ case SEQID_PDB :
+ accn = sip;
+ break;
+ case SEQID_TPG :
+ case SEQID_TPE :
+ case SEQID_TPD :
+ accn = sip;
+ break;
+ default :
+ break;
+ }
+ }
+
+ /* if (gi < 1 && accn == NULL) return; */
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ if ( accn == NULL ) return;
+ }
+
+ bbp = Asn2gbAddBlock (awp, VERSION_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ /* no longer displaying NID */
+
+ /*
+ if (gi > 0) {
+ sprintf (version, "g%ld", (long) gi);
+
+ gb_StartPrint (awp->format, needInitBuff, 0, 12, "NID", 13, 5, 5, "NI", TRUE);
+ needInitBuff = FALSE;
+
+ gb_AddString (NULL, version, NULL, FALSE, FALSE, TILDE_TO_SPACES);
+
+ ff_EndPrint();
+ needEndPrint = FALSE;
+ }
+ */
+
+ version [0] = '\0';
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ SeqIdWrite (accn, version, PRINTID_TEXTID_ACC_VER, sizeof (version) - 1);
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "VERSION", 12, 5, 5, "SV", TRUE);
+
+ FFAddOneString (ffstring, version, FALSE, FALSE, TILDE_TO_SPACES);
+
+ FFAddOneChar(ffstring, '\n', FALSE);
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "SV");
+ FFRecycleString(ajp, ffstring);
+ return;
+ }
+
+ if (accn != NULL) {
+
+ buf [0] = '\0';
+ SeqIdWrite (accn, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
+
+ if (gi > 0) {
+ sprintf (version, "%s GI:%ld", buf, (long) gi);
+ } else {
+ sprintf (version, "%s", buf);
+ }
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "VERSION", 12, 5, 5, "SV", TRUE);
+
+ FFAddTextToString (ffstring, NULL, version, "\n", FALSE, FALSE, TILDE_TO_SPACES);
+ /* optionally populate indexes for NCBI internal database */
+
+ if (ajp->index) {
+ index = &asp->index;
+ } else {
+ index = NULL;
+ }
+
+ if (index != NULL) {
+ ptr = StringChr (buf, '.');
+ if (ptr != NULL) {
+ ptr++;
+ index->version = StringSave (ptr);
+ }
+ if (gi > 0) {
+ sprintf (tmp, "%ld", (long) gi);
+ index->gi = StringSave (tmp);
+ }
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ ptr = StringChr (buf, '.');
+ if (ptr != NULL) {
+ gbseq->accession_version = StringSave (buf);
+ }
+ }
+
+ } else if (gi > 0) {
+
+ FFStartPrint (ffstring, awp->format, 0, 0, "VERSION", 12, 5, 5, "SV", TRUE);
+
+ sprintf (version, " GI:%ld", (long) gi);
+
+ FFAddTextToString (ffstring, NULL, version, "\n", FALSE, FALSE, TILDE_TO_SPACES);
+
+ } else {
+
+ FFStartPrint (ffstring, awp->format, 0, 0, "VERSION", 0, 5, 5, "SV", TRUE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "SV");
+ }
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "SV");
+ FFRecycleString(ajp, ffstring);
+}
+
+/* only displaying PID in GenPept format */
+
+static void AddPidBlock (Asn2gbWorkPtr awp)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Int4 gi = -1;
+ SeqIdPtr sip;
+ Char version [64];
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ switch (sip->choice) {
+ case SEQID_GI :
+ gi = sip->data.intvalue;
+ break;
+ default :
+ break;
+ }
+ }
+
+ if (gi < 1) return;
+
+ bbp = Asn2gbAddBlock (awp, PID_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "PID", 12, 5, 5, NULL, TRUE);
+
+ sprintf (version, "g%ld", (long) gi);
+ FFAddOneString (ffstring, version, FALSE, FALSE, TILDE_TO_SPACES);
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, NULL);
+ FFRecycleString(ajp, ffstring);
+}
+
+static Uint1 dbsource_fasta_order [NUM_SEQID] = {
+ 33, /* 0 = not set */
+ 20, /* 1 = local Object-id */
+ 15, /* 2 = gibbsq */
+ 16, /* 3 = gibbmt */
+ 30, /* 4 = giim Giimport-id */
+ 10, /* 5 = genbank */
+ 10, /* 6 = embl */
+ 10, /* 7 = pir */
+ 10, /* 8 = swissprot */
+ 15, /* 9 = patent */
+ 18, /* 10 = other TextSeqId */
+ 20, /* 11 = general Dbtag */
+ 31, /* 12 = gi */
+ 10, /* 13 = ddbj */
+ 10, /* 14 = prf */
+ 12, /* 15 = pdb */
+ 10, /* 16 = tpg */
+ 10, /* 17 = tpe */
+ 10 /* 18 = tpd */
+};
+
+static void AddToUniqueSipList (
+ ValNodePtr PNTR list,
+ SeqIdPtr sip
+)
+
+{
+ ValNodePtr vnp;
+
+ if (list == NULL || sip == NULL) return;
+ for (vnp = *list; vnp != NULL; vnp = vnp->next) {
+ if (SeqIdMatch (sip, (SeqIdPtr) vnp->data.ptrvalue)) return;
+ }
+ ValNodeAddPointer (list, 0, (Pointer) sip);
+}
+
+static Boolean WriteDbsourceID (
+ SeqIdPtr sip,
+ CharPtr str
+)
+
+{
+ DbtagPtr db;
+ CharPtr dt;
+ Int4 gi;
+ ObjectIdPtr oip;
+ CharPtr pfx;
+ PDBSeqIdPtr psip = NULL;
+ CharPtr prefix;
+ Boolean rsult = FALSE;
+ CharPtr sfx;
+ CharPtr suffix;
+ Char tmp [32];
+ TextSeqIdPtr tsip = NULL;
+
+ if (sip == NULL || str == NULL) return FALSE;
+ *str = '\0';
+ switch (sip->choice) {
+ case SEQID_LOCAL :
+ oip = (ObjectIdPtr) sip->data.ptrvalue;
+ if (oip == NULL) return FALSE;
+ if (! StringHasNoText (oip->str)) {
+ StringCat (str, oip->str);
+ return TRUE;
+ } else if (oip->id > 0) {
+ sprintf (tmp, "%ld", (long) oip->id);
+ StringCat (str, tmp);
+ return TRUE;
+ }
+ return FALSE;
+ case SEQID_GI :
+ gi = (Int4) sip->data.intvalue;
+ if (gi == 0) return FALSE;
+ sprintf (tmp, "gi: %ld", (long) gi);
+ StringCat (str, tmp);
+ return TRUE;
+ case SEQID_GENERAL :
+ db = (DbtagPtr) sip->data.ptrvalue;
+ if (db == NULL) return FALSE;
+ /* !!! still need to implement this !!! */
+ return FALSE;
+ case SEQID_GENBANK :
+ case SEQID_EMBL :
+ case SEQID_DDBJ :
+ case SEQID_OTHER :
+ case SEQID_PIR :
+ case SEQID_SWISSPROT :
+ case SEQID_PRF :
+ case SEQID_TPG :
+ case SEQID_TPE :
+ case SEQID_TPD :
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip == NULL) return FALSE;
+ break;
+ case SEQID_PDB :
+ psip = (PDBSeqIdPtr) sip->data.ptrvalue;
+ if (psip == NULL) return FALSE;
+ break;
+ default :
+ break;
+ }
+ prefix = " ";
+ suffix = NULL;
+ switch (sip->choice) {
+ case SEQID_EMBL :
+ StringCat (str, "embl ");
+ suffix = ",";
+ break;
+ case SEQID_OTHER :
+ StringCat (str, "REFSEQ: ");
+ break;
+ case SEQID_SWISSPROT :
+ StringCat (str, "swissprot: ");
+ suffix = ",";
+ break;
+ case SEQID_PIR :
+ StringCat (str, "pir: ");
+ break;
+ case SEQID_PRF :
+ StringCat (str, "prf: ");
+ break;
+ case SEQID_PDB :
+ StringCat (str, "pdb: ");
+ suffix = ",";
+ break;
+ default :
+ break;
+ }
+ pfx = NULL;
+ sfx = NULL;
+ if (tsip != NULL) {
+ if (! StringHasNoText (tsip->name)) {
+ StringCat (str, sfx);
+ StringCat (str, pfx);
+ StringCat (str, "locus ");
+ StringCat (str, tsip->name);
+ sfx = suffix;
+ pfx = prefix;
+ rsult = TRUE;
+ }
+ if (! StringHasNoText (tsip->accession)) {
+ StringCat (str, sfx);
+ StringCat (str, pfx);
+ StringCat (str, "accession ");
+ StringCat (str, tsip->accession);
+ sfx = suffix;
+ pfx = prefix;
+ rsult = TRUE;
+ }
+ if (tsip->version > 0) {
+ sprintf (tmp, ".%d", (int) tsip->version);
+ StringCat (str, tmp);
+ sfx = suffix;
+ pfx = prefix;
+ }
+ if (! StringHasNoText (tsip->release)) {
+ StringCat (str, pfx);
+ StringCat (str, "release ");
+ StringCat (str, tsip->release);
+ sfx = suffix;
+ pfx = prefix;
+ }
+ if (sip->choice == SEQID_SWISSPROT || sip->choice == SEQID_PIR || sip->choice == SEQID_PRF) {
+ StringCat (str, ";");
+ }
+ return rsult;
+ }
+ if (psip != NULL) {
+ if (! StringHasNoText (psip->mol)) {
+ StringCat (str, "molecule ");
+ StringCat (str, psip->mol);
+ sfx = suffix;
+ pfx = prefix;
+ rsult = TRUE;
+ }
+ if (psip->chain > 0) {
+ StringCat (str, sfx);
+ StringCat (str, pfx);
+ sprintf (tmp, "chain %d", (int) psip->chain);
+ StringCat (str, tmp);
+ sfx = suffix;
+ pfx = prefix;
+ rsult = TRUE;
+ }
+ if (psip->rel != NULL) {
+ StringCat (str, sfx);
+ StringCat (str, pfx);
+ StringCat (str, "release ");
+ dt = asn2gb_PrintDate (psip->rel);
+ StringCat (str, dt);
+ MemFree (dt);
+ sfx = suffix;
+ pfx = prefix;
+ rsult = TRUE;
+ }
+ StringCat (str, ";");
+ return rsult;
+ }
+ return rsult;
+}
+
+
+static void AddSPBlock (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ BioseqPtr bsp
+)
+
+{
+ CharPtr acc;
+ DbtagPtr db;
+ SeqMgrDescContext dcontext;
+ Boolean first;
+ Boolean has_link;
+ Char id [41];
+ ObjectIdPtr oip;
+ SeqDescrPtr sdp;
+ SeqIdPtr sid;
+ SPBlockPtr spb;
+ CharPtr string;
+ ValNodePtr vnp;
+ CharPtr str;
+ Char numbuf[40];
+
+ if (bsp == NULL) return;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_sp, &dcontext);
+ if (sdp == NULL) return;
+ spb = (SPBlockPtr) sdp->data.ptrvalue;
+ if (spb == NULL) return;
+
+ if (spb->_class == 1) {
+ FFAddOneString (ffstring, "class: standard.", FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ } else if (spb->_class == 2) {
+ FFAddOneString (ffstring, "class: preliminary.", FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ }
+
+ if (spb->extra_acc) {
+ FFAddOneString (ffstring, "extra accessions:", FALSE, FALSE, TILDE_IGNORE);
+ for (vnp = spb->extra_acc; vnp != NULL; vnp = vnp->next) {
+ FFAddOneString (ffstring, (CharPtr) vnp->data.ptrvalue, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar (ffstring, ',', FALSE );
+ }
+ }
+
+ if (spb->imeth) {
+ FFAddOneString (ffstring, "seq starts with Met", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ if (spb->plasnm != NULL) {
+ FFAddOneString (ffstring, "plasmid:", FALSE, FALSE, TILDE_IGNORE);
+ for (vnp = spb->plasnm; vnp != NULL; vnp = vnp->next) {
+ FFAddOneString (ffstring, (CharPtr) vnp->data.ptrvalue, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar (ffstring, ',', FALSE );
+ }
+ }
+
+ if (spb->created) {
+ string = PrintDate (spb->created);
+ FFAddOneString (ffstring, "created: ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, string, FALSE, FALSE, TILDE_IGNORE);
+
+ MemFree (string);
+ }
+
+ if (spb->sequpd) {
+ string = PrintDate (spb->sequpd);
+ FFAddOneString (ffstring, "sequence updated: ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, string, FALSE, FALSE, TILDE_IGNORE);
+ MemFree (string);
+ }
+
+ if (spb->annotupd) {
+ string = PrintDate (spb->annotupd);
+ FFAddOneString (ffstring, "annotation updated: ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, string, FALSE, FALSE, TILDE_IGNORE);
+ MemFree (string);
+ }
+
+ if (spb->seqref) {
+ FFAddOneString (ffstring, "xrefs: ", FALSE, FALSE, TILDE_IGNORE);
+ first = TRUE;
+ for (sid = spb->seqref; sid != NULL; sid = sid->next) {
+ acc = NULL;
+ has_link = FALSE;
+ if (first == FALSE) {
+ FFAddOneString (ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ first = FALSE;
+ SeqIdWrite (sid, id, PRINTID_TEXTID_ACC_VER, sizeof (id) - 1);
+ if (sid->choice == SEQID_GI) {
+ has_link = TRUE;
+ }
+ acc = id;
+ if (acc != NULL) {
+ switch (sid->choice) {
+ case SEQID_GENBANK:
+ FFAddOneString (ffstring, "genbank accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_EMBL:
+ FFAddOneString (ffstring, "embl accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_PIR:
+ FFAddOneString (ffstring, "pir locus ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_SWISSPROT:
+ FFAddOneString (ffstring, "swissprot accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_DDBJ:
+ FFAddOneString (ffstring, "ddbj accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_PRF:
+ FFAddOneString (ffstring, "prf accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_PDB:
+ FFAddOneString (ffstring, "pdb accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_GI:
+ FFAddOneString (ffstring, "gi: ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_TPG:
+ FFAddOneString (ffstring, "genbank third party accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_TPE:
+ FFAddOneString (ffstring, "embl third party accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_TPD:
+ FFAddOneString (ffstring, "ddbj third party accession ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ default:
+ acc = NULL;
+ break;
+ }
+ }
+ if (acc != NULL) {
+ if ( GetWWW(ajp) && has_link ) {
+ sprintf(numbuf, "%ld", (long) sid->data.intvalue);
+ FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "val=", numbuf, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, acc, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, acc, FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+ }
+
+ first = TRUE;
+ for (vnp = spb->dbref; vnp != NULL; vnp = vnp->next) {
+ db = (DbtagPtr) vnp->data.ptrvalue;
+ if (db == NULL) continue;
+ oip = db->tag;
+ if (oip == NULL) continue;
+ has_link = FALSE;
+ if (first) {
+ FFAddNewLine(ffstring);
+ FFAddOneString (ffstring, "xrefs (non-sequence databases): ", FALSE, FALSE, TILDE_IGNORE);
+ first = FALSE;
+ } else {
+ FFAddOneString (ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (StringCmp (db->db, "MGD") == 0 || StringCmp (db->db, "MGI") == 0) {
+ FFAddOneString (ffstring, "MGI", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, db->db, FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (StringCmp (db->db, "MIM") == 0) {
+ has_link = TRUE;
+ }
+
+ str = NULL;
+ if ( oip->str != NULL ) {
+ str = oip->str;
+ if (StringNCmp (str, "GO:", 3) == 0) {
+ str += 3;
+ } else if (StringNCmp (str, "MGI:", 4) == 0) {
+ str += 4;
+ }
+ } else if ( oip->id > 0 ) {
+ sprintf(numbuf, "%d", oip->id);
+ str = numbuf;
+ }
+
+ if ( !StringHasNoText(str) ) {
+ if ( GetWWW(ajp) && has_link) {
+ FFAddOneChar (ffstring, ' ', FALSE);
+ FFAddTextToString(ffstring, "<a href=", link_omim, str, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, ">", str, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+}
+
+static void AddPIRBlock (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ BioseqPtr bsp
+)
+
+{
+ CharPtr acc;
+ SeqMgrDescContext dcontext;
+ Boolean first;
+ Char id [41];
+ CharPtr prefix = NULL;
+ SeqDescrPtr sdp;
+ SeqIdPtr sid;
+ PirBlockPtr pbp;
+
+ if (bsp == NULL) return;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_pir, &dcontext);
+ if (sdp == NULL) return;
+ pbp = (PirBlockPtr) sdp->data.ptrvalue;
+ if (pbp == NULL) return;
+
+ if (pbp->host != NULL) {
+ FFAddTextToString (ffstring, "host:", pbp->host, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->source != NULL) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "source: ", pbp->source, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->summary != NULL) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "summary: ", pbp->summary, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->genetic != NULL) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "genetic: ", pbp->genetic, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->includes != NULL) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "includes: ", pbp->includes, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->placement != NULL) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "placement: ", pbp->placement, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->superfamily != NULL) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "superfamily: ", pbp->superfamily, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->cross_reference != NULL) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "xref: ", pbp->cross_reference, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->date != NULL) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString (ffstring, "PIR dates: ", pbp->date, "\n", FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->had_punct) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddOneString (ffstring, "punctuation in sequence", FALSE, FALSE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (pbp->seqref) {
+ FFAddOneString (ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddOneString (ffstring, "xrefs: ", FALSE, FALSE, TILDE_IGNORE);
+ first = TRUE;
+ for (sid = pbp->seqref; sid != NULL; sid = sid->next) {
+ acc = NULL;
+ if (first == FALSE) {
+ FFAddOneString (ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ first = FALSE;
+ SeqIdWrite (sid, id, PRINTID_TEXTID_ACC_VER, sizeof (id) - 1);
+ acc = id;
+ if (acc != NULL) {
+ switch (sid->choice) {
+ case SEQID_GENBANK:
+ FFAddOneString (ffstring, "genbank ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_EMBL:
+ FFAddOneString (ffstring, "embl ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_PIR:
+ FFAddOneString (ffstring, "pir ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_SWISSPROT:
+ FFAddOneString (ffstring, "swissprot ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_DDBJ:
+ FFAddOneString (ffstring, "ddbj ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_PRF:
+ FFAddOneString (ffstring, "prf ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case SEQID_GI:
+ FFAddOneString (ffstring, "gi: ", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ default:
+ acc = NULL;
+ break;
+ }
+ }
+ if (acc != NULL) {
+ FFAddOneString (ffstring, acc, FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+ FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_IGNORE);
+}
+
+static void AddPRFBlock (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ BioseqPtr bsp
+)
+
+{
+ SeqMgrDescContext dcontext;
+ PrfExtSrcPtr extra;
+ CharPtr prefix = NULL;
+ SeqDescrPtr sdp;
+ PrfBlockPtr prf;
+
+ if (bsp == NULL) return;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_prf, &dcontext);
+ if (sdp == NULL) return;
+ prf = (PrfBlockPtr) sdp->data.ptrvalue;
+ if (prf == NULL) return;
+ if ( ffstring == NULL ) return;
+
+ extra = prf->extra_src;
+ if (extra != NULL) {
+
+ if (extra->host != NULL) {
+ FFAddTextToString(ffstring, "host:", extra->host, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ if (extra->part != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "part: ", extra->part, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+ if (extra->state != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "state: ", extra->state, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+ if (extra->strain != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "strain: ", extra->strain, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+ if (extra->taxon != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "taxonomy: ", extra->taxon, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+
+ FFAddOneChar(ffstring, '.', FALSE);
+ }
+}
+
+static void AddPDBBlock (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ BioseqPtr bsp
+)
+
+{
+ SeqMgrDescContext dcontext;
+ CharPtr dt;
+ CharPtr prefix = NULL;
+ SeqDescrPtr sdp;
+ PdbBlockPtr pdb;
+ PdbRepPtr replace;
+ CharPtr str;
+ ValNodePtr vnp;
+
+ if (bsp == NULL) return;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_pdb, &dcontext);
+ if (sdp == NULL) return;
+ pdb = (PdbBlockPtr) sdp->data.ptrvalue;
+ if (pdb == NULL) return;
+
+ if (pdb->deposition != NULL) {
+ dt = asn2gb_PrintDate (pdb->deposition);
+ FFAddTextToString (ffstring, "deposition: ", dt, NULL, FALSE, TRUE, TILDE_IGNORE);
+ MemFree (dt);
+ prefix = ";";
+ }
+ if (pdb->pdbclass != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "class: ", pdb->pdbclass, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+ if (pdb->source != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddOneString(ffstring, "source: ", FALSE, TRUE, TILDE_IGNORE);
+ prefix = NULL;
+ for (vnp = pdb->source; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (StringHasNoText (str)) continue;
+ FFAddTextToString (ffstring, prefix, str, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ", ";
+ }
+ prefix = ";";
+ }
+ if (pdb->exp_method != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddTextToString(ffstring, "Exp. method: ", pdb->exp_method, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ";";
+ }
+ replace = pdb->replace;
+ if (replace != NULL) {
+ if (replace->ids != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+ FFAddOneString(ffstring, "ids replaced: ", FALSE, TRUE, TILDE_IGNORE);
+
+ prefix = NULL;
+ for (vnp = replace->ids; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (StringHasNoText (str)) continue;
+ FFAddTextToString (ffstring, prefix, str, NULL, FALSE, TRUE, TILDE_IGNORE);
+ prefix = ", ";
+ }
+ prefix = ";";
+ }
+ if (replace->date != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNewLine(ffstring);
+
+ dt = asn2gb_PrintDate (replace->date);
+ FFAddTextToString(ffstring, "replacement date: ", dt, NULL, FALSE, TRUE, TILDE_IGNORE);
+ MemFree (dt);
+ prefix = ";";
+ }
+ }
+
+ FFAddOneChar(ffstring, '.', FALSE);
+}
+
+static CharPtr TxtSave (CharPtr text, size_t len)
+
+{
+ CharPtr str = NULL;
+
+ if ((text == NULL) || (len == 0))
+ return str;
+
+ str = MemNew((size_t)(len + 1));
+ MemCopy(str, text, (size_t)len);
+
+ return (str);
+}
+
+static Boolean FF_www_dbsource(
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr str,
+ Boolean first,
+ Uint1 choice
+)
+{
+ CharPtr temp, end, text, loc, link=NULL;
+ Int2 j;
+
+ if( GetWWW(ajp) ) {
+ if (choice == SEQID_PIR /*|| choice == SEQID_SWISSPROT */) {
+ link = link_seq;
+ } else if (choice == SEQID_PDB || choice == SEQID_PRF) {
+ link = link_seq;
+ } else if (choice == SEQID_EMBL || choice == SEQID_GENBANK ||
+ choice == SEQID_DDBJ || choice == SEQID_GIBBSQ ||
+ choice == SEQID_GIBBMT || choice == SEQID_GI ||
+ choice == SEQID_GIIM || choice == SEQID_OTHER ||
+ choice == SEQID_TPG || choice == SEQID_TPE || choice == SEQID_TPD) {
+ link = link_seq;
+ } else {
+ AddStringWithTildes(ffstring, str);
+ return TRUE;
+ }
+
+ if ((text = StringStr(str, "accession")) != NULL) {
+ end = text + 9;
+ j = 9;
+ while (*end == ' ') {
+ ++end;
+ j++;
+ }
+ if (first == FALSE) {
+ FFAddOneString(ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ loc = TxtSave (str, end-str - j);
+ FFAddOneString(ffstring, loc, FALSE, FALSE, TILDE_IGNORE);
+ MemFree (loc);
+ for (; text != end; ++text ) {
+ FFAddOneChar(ffstring, *text, FALSE);
+ }
+
+ temp = text;
+ end += StringLen(text) - 1;
+ if ( *end != ';' ) {
+ ++end;
+ }
+
+ FFAddTextToString(ffstring, "<a href=", link, "val=", FALSE, FALSE, TILDE_IGNORE);
+ for (text = temp; text != end; ++text ) {
+ FFAddOneChar(ffstring, *text, FALSE);
+ }
+ FFAddOneString(ffstring, ">", FALSE, FALSE, TILDE_IGNORE);
+
+ text = temp;
+ FFAddOneString(ffstring, text, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ if (first == FALSE) {
+ FFAddOneString(ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ }
+ } else {
+ AddStringWithTildes(ffstring, str);
+ }
+ return TRUE;
+}
+
+static CharPtr CleanQualValue (
+ CharPtr str
+)
+
+{
+ Char ch;
+ CharPtr dst;
+ CharPtr ptr;
+
+ if (str == NULL || str [0] == '\0') return NULL;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch == '\n' || ch == '\r' || ch == '\t' || ch == '"') {
+ *dst = ' ';
+ dst++;
+ } else {
+ *dst = ch;
+ dst++;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = '\0';
+
+ return str;
+}
+
+static CharPtr Asn2gnbkCompressSpaces (CharPtr str)
+
+{
+ Char ch;
+ CharPtr dst;
+ Char last;
+ CharPtr ptr;
+
+ if (str != NULL && str [0] != '\0') {
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0' && ch <= ' ') {
+ ptr++;
+ ch = *ptr;
+ }
+ while (ch != '\0') {
+ *dst = ch;
+ dst++;
+ ptr++;
+ last = ch;
+ ch = *ptr;
+ if (ch != '\0' && ch < ' ') {
+ *ptr = ' ';
+ ch = *ptr;
+ }
+ while (ch != '\0' && last <= ' ' && ch <= ' ') {
+ ptr++;
+ ch = *ptr;
+ }
+ }
+ *dst = '\0';
+ dst = NULL;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch != ' ') {
+ dst = NULL;
+ } else if (dst == NULL) {
+ dst = ptr;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ if (dst != NULL) {
+ *dst = '\0';
+ }
+ }
+ return str;
+}
+
+static CharPtr StripAllSpaces (
+ CharPtr str
+)
+
+{
+ Char ch;
+ CharPtr dst;
+ CharPtr ptr;
+
+ if (str == NULL || str [0] == '\0') return NULL;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch == ' ' || ch == '\t') {
+ } else {
+ *dst = ch;
+ dst++;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = '\0';
+
+ return str;
+}
+
+NLM_EXTERN void AddDbsourceBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Char buf [256];
+ SeqFeatPtr cds;
+ DbtagPtr db;
+ GBSeqPtr gbseq;
+ SeqIdPtr id;
+ ValNodePtr list = NULL;
+ BioseqPtr nuc;
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+ CharPtr str;
+ Boolean unknown = TRUE;
+ ValNodePtr vnp;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, DBSOURCE_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "DBSOURCE", 12, 5, 5, NULL, TRUE);
+
+ sip = SeqIdSelect (bsp->id, dbsource_fasta_order, NUM_SEQID);
+
+ if (sip != NULL) {
+
+ switch (sip->choice) {
+ case SEQID_PIR :
+ case SEQID_SWISSPROT :
+ case SEQID_PRF :
+ case SEQID_PDB :
+ if (WriteDbsourceID (sip, buf)) {
+ FF_www_dbsource (ajp, ffstring, buf, TRUE, sip->choice);
+ FFAddNewLine(ffstring);
+ unknown = FALSE;
+ }
+ break;
+ case SEQID_GENERAL :
+ db = sip->data.ptrvalue;
+ if (db == NULL) {
+ break;
+ }
+ if (StringNCmp (db->db, "PIDe", 4) != 0 &&
+ StringNCmp (db->db, "PIDd", 4) != 0 &&
+ StringNCmp (db->db, "PID", 3) != 0) {
+ break;
+ }
+ /* if (ChoicePID) found, continue on to next set of cases */
+ case SEQID_EMBL :
+ case SEQID_GENBANK :
+ case SEQID_DDBJ :
+ case SEQID_GIBBSQ :
+ case SEQID_GIBBMT :
+ case SEQID_OTHER :
+ case SEQID_TPG :
+ case SEQID_TPE :
+ case SEQID_TPD :
+ case SEQID_GI :
+ case SEQID_GIIM :
+ cds = SeqMgrGetCDSgivenProduct (bsp, NULL);
+ if (cds == NULL) {
+ /* now may also be protein product of mature peptide feature */
+ cds = SeqMgrGetPROTgivenProduct (bsp, NULL);
+ }
+ if (cds != NULL) {
+ nuc = BioseqFindFromSeqLoc (cds->location);
+ if (nuc != NULL) {
+ slp = SeqLocFindNext (cds->location, NULL);
+ while (slp != NULL) {
+ sip = SeqLocId (slp);
+ AddToUniqueSipList (&list, sip);
+ slp = SeqLocFindNext (cds->location, slp);
+ }
+ for (vnp = list; vnp != NULL; vnp = vnp->next) {
+ id = (SeqIdPtr) vnp->data.ptrvalue;
+ nuc = BioseqFindCore (id);
+ sip = NULL;
+ if (nuc != NULL) {
+ sip = SeqIdSelect (nuc->id, dbsource_fasta_order, NUM_SEQID);
+ } else if (id != NULL && id->choice == SEQID_GI) {
+ sip = GetSeqIdForGI (id->data.intvalue);
+ }
+ if (sip == NULL) {
+ sip = id;
+ }
+ if (sip != NULL) {
+ if (WriteDbsourceID (sip, buf)) {
+ FF_www_dbsource (ajp, ffstring, buf, TRUE, sip->choice);
+ FFAddNewLine(ffstring);
+ unknown = FALSE;
+ }
+ }
+ }
+ ValNodeFree (list);
+ }
+ } else {
+ if (WriteDbsourceID (sip, buf)) {
+ FF_www_dbsource (ajp, ffstring, buf, TRUE, sip->choice);
+ FFAddNewLine(ffstring);
+ unknown = FALSE;
+ }
+ }
+ break;
+ default :
+ break;
+ }
+
+ switch (sip->choice) {
+ case SEQID_PIR :
+ AddPIRBlock (ajp, ffstring, bsp);
+ break;
+ case SEQID_SWISSPROT :
+ AddSPBlock (ajp, ffstring, bsp);
+ break;
+ case SEQID_PRF :
+ AddPRFBlock (ajp, ffstring, bsp);
+ break;
+ case SEQID_PDB :
+ AddPDBBlock (ajp, ffstring, bsp);
+ break;
+ default :
+ break;
+ }
+ }
+
+ if (unknown) {
+ FFAddOneString (ffstring, "UNKNOWN", FALSE, FALSE, TILDE_TO_SPACES);
+ }
+
+ str = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, NULL);
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ if (StringNCmp (str, "DBSOURCE ", 12) == 0) {
+ gbseq->source_db = StringSave (str + 12);
+ } else {
+ gbseq->source_db = StringSave (str);
+ }
+ CleanQualValue (gbseq->source_db);
+ Asn2gnbkCompressSpaces (gbseq->source_db);
+ }
+
+ bbp->string = str;
+ FFRecycleString(ajp, ffstring);
+}
+
+NLM_EXTERN void AddDateBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Char date [40];
+ SeqMgrDescContext dcontext;
+ DatePtr dp;
+ SeqDescrPtr sdp;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ bbp = Asn2gbAddBlock (awp, DATE_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ date [0] = '\0';
+
+ dp = NULL;
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_create_date, &dcontext);
+ if (sdp != NULL) {
+ dp = (DatePtr) sdp->data.ptrvalue;
+ }
+ if (dp != NULL) {
+ DateToFF (date, dp, FALSE);
+ }
+ if (StringHasNoText (date)) {
+ StringCpy (date, "01-JAN-1900");
+ }
+
+ FFStartPrint (ffstring, awp->format, 0, 0, NULL, 0, 5, 5, "DT", TRUE);
+ FFAddOneString (ffstring, date, FALSE, FALSE, TILDE_IGNORE);
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 0, 0, 5, 5, "DT");
+ FFRecycleString(ajp, ffstring);
+
+ bbp = Asn2gbAddBlock (awp, DATE_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_update_date, &dcontext);
+ if (sdp != NULL) {
+ dp = (DatePtr) sdp->data.ptrvalue;
+ }
+ if (dp != NULL) {
+ DateToFF (date, dp, FALSE);
+ }
+
+ FFStartPrint (ffstring, awp->format, 0, 0, NULL, 0, 5, 5, "DT", FALSE);
+ FFAddOneString (ffstring, date, FALSE, FALSE, TILDE_IGNORE);
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 0, 0, 5, 5, "DT");
+ FFRecycleString(ajp, ffstring);
+}
+
+
+#define TOTAL_ESTKW 11
+#define TOTAL_STSKW 5
+#define TOTAL_GSSKW 2
+
+static CharPtr EST_kw_array[ TOTAL_ESTKW] = {
+ "EST", "EST PROTO((expressed sequence tag)", "expressed sequence tag",
+ "EST (expressed sequence tag)", "EST(expressed sequence tag)",
+ "partial cDNA sequence", "transcribed sequence fragment", "TSR",
+ "putatively transcribed partial sequence", "UK putts"
+};
+
+static CharPtr GSS_kw_array [TOTAL_GSSKW] = {
+ "GSS", "trapped exon"
+};
+static CharPtr STS_kw_array[TOTAL_STSKW] = {
+ "STS", "STS(sequence tagged site)", "STS (sequence tagged site)",
+ "STS sequence", "sequence tagged site"
+};
+
+static Int2 MatchArrayString (
+ CharPtr array_string [],
+ Int2 totalstr,
+ CharPtr text
+)
+
+{
+ Int2 i;
+
+ for (i = 0; i < totalstr && text != NULL; i++) {
+ if (StringCmp (array_string [i], text) == 0) {
+ return (i);
+ }
+ }
+
+ return (-1);
+}
+
+static Boolean CheckSpecialKeyword (
+ Boolean is_est,
+ Boolean is_sts,
+ Boolean is_gss,
+ CharPtr kwd
+)
+
+{
+ if (kwd == NULL) return FALSE;
+
+ if (is_est) {
+ if (MatchArrayString (STS_kw_array, TOTAL_STSKW, kwd) != -1) return FALSE;
+ if (MatchArrayString (GSS_kw_array, TOTAL_GSSKW, kwd) != -1) return FALSE;
+ }
+
+ if (is_sts) {
+ if (MatchArrayString (EST_kw_array, TOTAL_ESTKW, kwd) != -1) return FALSE;
+ if (MatchArrayString (GSS_kw_array, TOTAL_GSSKW, kwd) != -1) return FALSE;
+ }
+
+ if (is_gss) {
+ if (MatchArrayString (STS_kw_array, TOTAL_STSKW, kwd) != -1) return FALSE;
+ if (MatchArrayString (EST_kw_array, TOTAL_ESTKW, kwd) != -1) return FALSE;
+ }
+
+ return TRUE;
+}
+
+static Boolean KeywordAlreadyInList (
+ ValNodePtr head,
+ CharPtr kwd
+)
+
+{
+ ValNodePtr vnp;
+
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ if (StringICmp ((CharPtr) vnp->data.ptrvalue, kwd) == 0) return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+NLM_EXTERN void AddKeywordsBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ Boolean add_encode = FALSE;
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ SeqMgrDescContext dcontext;
+ EMBLBlockPtr ebp;
+ GBBlockPtr gbp;
+ GBSeqPtr gbseq;
+ ValNodePtr head = NULL;
+ IndxPtr index;
+ Boolean is_est = FALSE;
+ Boolean is_gss = FALSE;
+ Boolean is_sts = FALSE;
+ ValNodePtr keywords;
+ CharPtr kwd;
+ MolInfoPtr mip;
+ ObjectIdPtr oip;
+ PirBlockPtr pir;
+ PrfBlockPtr prf;
+ SeqDescrPtr sdp;
+ SeqIdPtr sip;
+ SPBlockPtr sp;
+ CharPtr str;
+ UserObjectPtr uop;
+ ValNodePtr vnp;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+
+ bbp = (BaseBlockPtr) Asn2gbAddBlock (awp, KEYWORDS_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_TPG || sip->choice == SEQID_TPE || sip->choice == SEQID_TPD) {
+ ValNodeCopyStr (&head, 0, "Third Party Annotation");
+ ValNodeCopyStr (&head, 0, "; ");
+ ValNodeCopyStr (&head, 0, "TPA");
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp != NULL) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip != NULL) {
+ switch (mip->tech) {
+ case MI_TECH_htgs_1 :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, "HTG");
+ ValNodeCopyStr (&head, 0, "; ");
+ ValNodeCopyStr (&head, 0, "HTGS_PHASE1");
+ break;
+ case MI_TECH_htgs_2 :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, "HTG");
+ ValNodeCopyStr (&head, 0, "; ");
+ ValNodeCopyStr (&head, 0, "HTGS_PHASE2");
+ break;
+ case MI_TECH_htgs_3 :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, "HTG");
+ break;
+ case MI_TECH_est :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ is_est = TRUE;
+ ValNodeCopyStr (&head, 0, "EST");
+ break;
+ case MI_TECH_sts :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ is_sts = TRUE;
+ ValNodeCopyStr (&head, 0, "STS");
+ break;
+ case MI_TECH_survey :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ is_gss = TRUE;
+ ValNodeCopyStr (&head, 0, "GSS");
+ break;
+ case MI_TECH_fli_cdna :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, "FLI_CDNA");
+ break;
+ case MI_TECH_htgs_0 :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, "HTG");
+ ValNodeCopyStr (&head, 0, "; ");
+ ValNodeCopyStr (&head, 0, "HTGS_PHASE0");
+ break;
+ case MI_TECH_htc :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, "HTC");
+ break;
+ case MI_TECH_wgs :
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, "WGS");
+ break;
+ default :
+ break;
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL) {
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop != NULL) {
+ oip = uop->type;
+ if (oip != NULL && StringICmp (oip->str, "ENCODE") == 0) {
+ add_encode = TRUE;
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
+ }
+ if (add_encode) {
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, "ENCODE");
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, 0, &dcontext);
+ while (sdp != NULL) {
+
+ keywords = NULL;
+
+ switch (dcontext.seqdesctype) {
+ case Seq_descr_genbank :
+ gbp = (GBBlockPtr) sdp->data.ptrvalue;
+ if (gbp != NULL) {
+ keywords = gbp->keywords;
+ }
+ break;
+ case Seq_descr_embl :
+ ebp = (EMBLBlockPtr) sdp->data.ptrvalue;
+ if (ebp != NULL) {
+ keywords = ebp->keywords;
+ }
+ break;
+ case Seq_descr_pir :
+ pir = (PirBlockPtr) sdp->data.ptrvalue;
+ if (pir != NULL) {
+ keywords = pir->keywords;
+ }
+ break;
+ case Seq_descr_prf :
+ prf = (PrfBlockPtr) sdp->data.ptrvalue;
+ if (prf != NULL) {
+ keywords = prf->keywords;
+ }
+ break;
+ case Seq_descr_sp :
+ sp = (SPBlockPtr) sdp->data.ptrvalue;
+ if (sp != NULL) {
+ keywords = sp->keywords;
+ }
+ break;
+ default :
+ break;
+ }
+
+ if (keywords != NULL) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ }
+
+ for (vnp = keywords; vnp != NULL; vnp = vnp->next) {
+ kwd = (CharPtr) vnp->data.ptrvalue;
+ if (CheckSpecialKeyword (is_est, is_sts, is_gss, kwd)) {
+ if (! KeywordAlreadyInList (head, kwd)) {
+ if (head != NULL) {
+ ValNodeCopyStr (&head, 0, "; ");
+ }
+ ValNodeCopyStr (&head, 0, kwd);
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, 0, &dcontext);
+ }
+
+ FFStartPrint( ffstring, awp->format, 0, 12, "KEYWORDS", 12, 5, 5, "KW", TRUE);
+ str = MergeFFValNodeStrs (head);
+
+ /* if no keywords were found, period will still be added by this call */
+ if ( str != NULL ) {
+ FFAddOneString (ffstring, str, TRUE, FALSE, TILDE_TO_SPACES);
+ } else {
+ FFAddOneChar(ffstring, '.', FALSE);
+ }
+
+ MemFree (str);
+
+ /* optionally populate indexes for NCBI internal database */
+
+ if (ajp->index) {
+ index = &asp->index;
+ } else {
+ index = NULL;
+ }
+
+ if (index != NULL) {
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ kwd = (CharPtr) vnp->data.ptrvalue;
+ if (StringCmp (kwd, "; ") == 0) continue;
+ ValNodeCopyStrToHead (&(index->keywords), 0, kwd);
+ }
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ kwd = (CharPtr) vnp->data.ptrvalue;
+ if (StringCmp (kwd, "; ") == 0) continue;
+ ValNodeCopyStr (&(gbseq->keywords), 0, kwd);
+ }
+ }
+
+ ValNodeFreeData (head);
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "KW");
+
+ FFRecycleString(ajp, ffstring);
+}
+
+NLM_EXTERN void AddSegmentBlock (
+ Asn2gbWorkPtr awp,
+ Boolean onePartOfSeg
+)
+
+{
+ Char acc [41];
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp;
+ Char buf [32];
+ GBSeqPtr gbseq;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+
+ if (awp->seg < 1 || awp->numsegs < 1) return;
+
+ bbp = Asn2gbAddBlock (awp, SEGMENT_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "SEGMENT", 12, 5, 5, "XX", FALSE);
+
+ if ( GetWWW(ajp) && awp->parent != NULL && onePartOfSeg) {
+ sprintf (buf, "%d of ", (int) awp->seg);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
+ SeqIdWrite (awp->parent->id, acc, PRINTID_TEXTID_ACC_VER, sizeof (acc) - 1);
+
+ FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "val=", acc, ">", FALSE, FALSE, TILDE_IGNORE);
+
+ sprintf (buf, "%ld", (long) awp->numsegs);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ sprintf (buf, "%d of %ld", (int) awp->seg, (long) awp->numsegs);
+ FFAddOneString (ffstring, buf, FALSE, TRUE, TILDE_TO_SPACES);
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ sprintf (buf, "%d of %ld", (int) awp->seg, (long) awp->numsegs);
+ gbseq->segment = StringSave (buf);
+ }
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "XX");
+ FFRecycleString(ajp, ffstring);
+}
+
+NLM_EXTERN void AddSourceBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ SeqFeatPtr cds;
+ SeqMgrDescContext dcontext;
+ BioseqPtr dna;
+ SeqMgrFeatContext fcontext;
+ GBBlockPtr gbp;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, SOURCE_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
+ if (sdp != NULL && (! ajp->newSourceOrg)) {
+ gbp = (GBBlockPtr) sdp->data.ptrvalue;
+ if (gbp != NULL && (! StringHasNoText (gbp->source))) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ return;
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ } else {
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_BIOSRC, 0, &fcontext);
+ if (sfp != NULL) {
+ bbp->entityID = fcontext.entityID;
+ bbp->itemID = fcontext.itemID;
+ bbp->itemtype = OBJ_SEQFEAT;
+ } else if (ISA_aa (bsp->mol)) {
+
+ /* if protein with no sources, get sources applicable to DNA location of CDS */
+
+ cds = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
+ if (cds != NULL) {
+ sfp = SeqMgrGetOverlappingSource (cds->location, &fcontext);
+ if (sfp != NULL) {
+ bbp->entityID = fcontext.entityID;
+ bbp->itemID = fcontext.itemID;
+ bbp->itemtype = OBJ_SEQFEAT;
+ } else {
+ dna = BioseqFindFromSeqLoc (cds->location);
+ if (dna != NULL) {
+ sdp = SeqMgrGetNextDescriptor (dna, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+NLM_EXTERN void AddOrganismBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ SeqFeatPtr cds;
+ SeqMgrDescContext dcontext;
+ BioseqPtr dna;
+ SeqMgrFeatContext fcontext;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+
+ if (awp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, ORGANISM_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ } else {
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_BIOSRC, 0, &fcontext);
+ if (sfp != NULL) {
+ bbp->entityID = fcontext.entityID;
+ bbp->itemID = fcontext.itemID;
+ bbp->itemtype = OBJ_SEQFEAT;
+ } else if (ISA_aa (bsp->mol)) {
+
+ /* if protein with no sources, get sources applicable to DNA location of CDS */
+
+ cds = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
+ if (cds != NULL) {
+ sfp = SeqMgrGetOverlappingSource (cds->location, &fcontext);
+ if (sfp != NULL) {
+ bbp->entityID = fcontext.entityID;
+ bbp->itemID = fcontext.itemID;
+ bbp->itemtype = OBJ_SEQFEAT;
+ } else {
+ dna = BioseqFindFromSeqLoc (cds->location);
+ if (dna != NULL) {
+ sdp = SeqMgrGetNextDescriptor (dna, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+static RefBlockPtr AddPub (
+ Asn2gbWorkPtr awp,
+ ValNodePtr PNTR head,
+ PubdescPtr pdp
+)
+
+{
+ Char buf [521]; /* increased for consortium in citsub */
+ CitArtPtr cap;
+ CitBookPtr cbp;
+ CitGenPtr cgp;
+ CitJourPtr cjp;
+ CitPatPtr cpp;
+ CitSubPtr csp;
+ DatePtr dp = NULL;
+ Boolean justuids = TRUE;
+ ImprintPtr imp = NULL;
+ IntRefBlockPtr irp;
+ RefBlockPtr rbp;
+ ValNodePtr vnp;
+
+ if (awp == NULL || head == NULL || pdp == NULL) return NULL;
+
+ if (awp->hideGeneRIFs) {
+ if (StringNICmp (pdp->comment, "GeneRIF", 7) == 0) return NULL;
+ } else if (awp->onlyGeneRIFs || awp->latestGeneRIFs) {
+ if (StringNICmp (pdp->comment, "GeneRIF", 7) != 0) return NULL;
+ }
+
+ rbp = (RefBlockPtr) MemNew (sizeof (IntRefBlock));
+ if (rbp == NULL) return NULL;
+ rbp->blocktype = REFERENCE_BLOCK;
+ rbp->section = awp->currsection;
+
+ rbp->serial = INT2_MAX;
+
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ switch (vnp->choice) {
+ case PUB_Gen :
+ /* may be unpublished, or may be serial number of swiss-prot reference */
+ cgp = (CitGenPtr) vnp->data.ptrvalue;
+ if (cgp != NULL) {
+ if (StringNICmp ("BackBone id_pub", cgp->cit, 15) != 0) {
+ rbp->category = REF_CAT_UNP;
+ dp = cgp->date;
+ if (cgp->serial_number > 0) {
+ rbp->serial = cgp->serial_number;
+ }
+ if (cgp->cit != NULL) {
+ if (StringNICmp ("unpublished", cgp->cit, 11) != 0 &&
+ StringNICmp ("submitted", cgp->cit, 8) != 0 &&
+ StringNICmp ("to be published", cgp->cit, 15) != 0 &&
+ StringNICmp ("in press", cgp->cit, 8) != 0 &&
+ StringStr (cgp->cit, "Journal") == NULL) {
+ if (cgp->serial_number == 0) {
+ MemFree (rbp);
+ return NULL;
+ }
+ }
+ } else if (cgp->journal == NULL || cgp->date == NULL) {
+ if (cgp->serial_number == 0) {
+ MemFree (rbp);
+ return NULL;
+ }
+ }
+ }
+ }
+ break;
+ case PUB_Sub :
+ rbp->category = REF_CAT_SUB;
+ csp = (CitSubPtr) vnp->data.ptrvalue;
+ if (csp != NULL) {
+ imp = csp->imp;
+ if (imp != NULL) {
+ dp = imp->date;
+ }
+ if (csp->date != NULL) {
+ dp = csp->date;
+ }
+ }
+ break;
+ case PUB_Article:
+ cap = (CitArtPtr) vnp->data.ptrvalue;
+ if (cap != NULL) {
+ switch (cap->from) {
+ case 1:
+ cjp = (CitJourPtr) cap->fromptr;
+ if (cjp != NULL) {
+ imp = (ImprintPtr) cjp->imp;
+ if (imp != NULL) {
+ dp = imp->date;
+ }
+ }
+ break;
+ case 2:
+ cbp = (CitBookPtr) cap->fromptr;
+ if (cbp != NULL) {
+ imp = (ImprintPtr) cbp->imp;
+ if (imp != NULL) {
+ dp = imp->date;
+ }
+ }
+ break;
+ case 3:
+ cbp = (CitBookPtr) cap->fromptr;
+ if (cbp != NULL) {
+ imp = (ImprintPtr) cbp->imp;
+ if (imp != NULL) {
+ dp = imp->date;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case PUB_Book:
+ cbp = (CitBookPtr) vnp->data.ptrvalue;
+ if (cbp != NULL) {
+ imp = (ImprintPtr) cbp->imp;
+ if (imp != NULL) {
+ dp = imp->date;
+ }
+ }
+ break;
+ case PUB_Proc:
+ cbp = (CitBookPtr) vnp->data.ptrvalue;
+ if (cbp != NULL) {
+ imp = (ImprintPtr) cbp->imp;
+ if (imp != NULL) {
+ dp = imp->date;
+ }
+ }
+ break;
+ case PUB_Patent :
+ rbp->category = REF_CAT_PUB;
+ cpp = (CitPatPtr) vnp->data.ptrvalue;
+ if (cpp != NULL) {
+ if (cpp->date_issue != NULL) {
+ dp = (DatePtr) cpp->date_issue;
+ } else if (cpp->app_date != NULL) {
+ dp = (DatePtr) cpp->app_date;
+ }
+ }
+ break;
+ case PUB_Man:
+ cbp = (CitBookPtr) vnp->data.ptrvalue;
+ if (cbp != NULL) {
+ imp = (ImprintPtr) cbp->imp;
+ if (imp != NULL) {
+ dp = imp->date;
+ }
+ }
+ break;
+ case PUB_Muid :
+ rbp->muid = vnp->data.intvalue;
+ rbp->category = REF_CAT_PUB;
+ break;
+ case PUB_PMid :
+ rbp->pmid = vnp->data.intvalue;
+ rbp->category = REF_CAT_PUB;
+ break;
+ default :
+ break;
+ }
+ if (vnp->choice != PUB_Muid && vnp->choice != PUB_PMid) {
+ justuids = FALSE;
+ }
+ }
+
+ /* check for submitted vs. in-press */
+
+ if (imp != NULL) {
+ rbp->category = REF_CAT_PUB;
+ switch (imp->prepub) {
+ case 1 :
+ rbp->category = REF_CAT_UNP;
+ break;
+ case 2 :
+ rbp->category = REF_CAT_PUB;
+ break;
+ default :
+ break;
+ }
+ }
+
+ /* check for sites reftype */
+
+ if (pdp->reftype != 0) {
+ rbp->sites = pdp->reftype;
+ }
+
+ if (rbp->muid == 0 && rbp->pmid == 0) {
+ vnp = pdp->pub;
+
+ /* skip over just serial number */
+
+ if (vnp != NULL && vnp->choice == PUB_Gen && vnp->next != NULL) {
+ cgp = (CitGenPtr) vnp->data.ptrvalue;
+ if (cgp != NULL) {
+ if (StringNICmp ("BackBone id_pub", cgp->cit, 15) != 0) {
+ if (cgp->cit == NULL && cgp->journal == NULL && cgp->date == NULL && cgp->serial_number) {
+ vnp = vnp->next;
+ }
+ }
+ }
+ }
+
+ if (PubLabelUnique (vnp, buf, sizeof (buf) - 1, OM_LABEL_CONTENT, TRUE) > 0) {
+ rbp->uniquestr = StringSaveNoNull (buf);
+ }
+ }
+
+ irp = (IntRefBlockPtr) rbp;
+ irp->date = DateDup (dp);
+ irp->justuids = justuids;
+ /* if (justuids) { */
+ irp->fig = StringSaveNoNull (pdp->fig);
+ irp->maploc = StringSaveNoNull (pdp->maploc);
+ irp->poly_a = pdp->poly_a;
+ /* } */
+
+ /* if not rejected by now, link in */
+
+ ValNodeAddPointer (head, 0, rbp);
+
+ return rbp;
+}
+
+static int LIBCALLBACK SortReferences (
+ VoidPtr ptr1,
+ VoidPtr ptr2,
+ Boolean serialFirst,
+ Boolean isRefSeq
+)
+
+{
+ int compare;
+ IntRefBlockPtr irp1;
+ IntRefBlockPtr irp2;
+ RefBlockPtr rbp1;
+ RefBlockPtr rbp2;
+ Int2 status;
+ RefBlockPtr temp;
+ ValNodePtr vnp1;
+ ValNodePtr vnp2;
+
+ if (ptr1 == NULL || ptr2 == NULL) return 0;
+ vnp1 = *((ValNodePtr PNTR) ptr1);
+ vnp2 = *((ValNodePtr PNTR) ptr2);
+ if (vnp1 == NULL || vnp2 == NULL) return 0;
+ rbp1 = (RefBlockPtr) vnp1->data.ptrvalue;
+ rbp2 = (RefBlockPtr) vnp2->data.ptrvalue;
+ if (rbp1 == NULL || rbp2 == NULL) return 0;
+
+ if (serialFirst) {
+ if (rbp1->serial > rbp2->serial) {
+ return 1;
+ } else if (rbp1->serial < rbp2->serial) {
+ return -1;
+ }
+ }
+
+ /* usual first sort by published, unpublished, and cit-subs */
+
+ if (rbp1->category > rbp2->category) {
+ return 1;
+ } else if (rbp1->category < rbp2->category) {
+ return -1;
+ }
+
+ /* for RefSeq, newer publications first, so temporarily swap pointers */
+
+ if (isRefSeq) {
+ temp = rbp1;
+ rbp1 = rbp2;
+ rbp2 = temp;
+ }
+
+ /* within class, sort by date, older publications first (except RefSeq) */
+
+ irp1 = (IntRefBlockPtr) rbp1;
+ irp2 = (IntRefBlockPtr) rbp2;
+ status = DateMatch (irp1->date, irp2->date, FALSE);
+ if (status == 1 || status == -1) return status;
+
+ /* if dates (e.g., years) match, try to distinguish by uids */
+
+ if (rbp1->pmid != 0 && rbp2->pmid != 0) {
+ if (rbp1->pmid > rbp2->pmid) {
+ return 1;
+ } else if (rbp1->pmid < rbp2->pmid) {
+ return -1;
+ }
+ }
+
+ if (rbp1->muid != 0 && rbp2->muid != 0) {
+ if (rbp1->muid > rbp2->muid) {
+ return 1;
+ } else if (rbp1->muid < rbp2->muid) {
+ return -1;
+ }
+ }
+
+ /* restore sort order after date and pmid/muid matching */
+
+ if (isRefSeq) {
+ temp = rbp1;
+ rbp1 = rbp2;
+ rbp2 = temp;
+ }
+
+ /* if same uid, one with just uids goes last to be excised but remembered */
+
+ if ((rbp1->pmid != 0 && rbp2->pmid != 0) || (rbp1->muid != 0 && rbp2->muid != 0)) {
+ if (irp1->justuids && (! irp2->justuids)) {
+ return 1;
+ } else if ((! irp1->justuids) && irp2->justuids) {
+ return -1;
+ }
+ }
+
+ /* put sites after pubs that refer to all or a range of bases */
+
+ if (rbp1->sites > 0) {
+ return 1;
+ } else if (rbp2->sites > 0) {
+ return -1;
+ }
+
+ /* for publication features, sort in explore index order */
+
+ if (irp1->index > irp2->index) {
+ return 1;
+ } else if (irp1->index < irp2->index) {
+ return -1;
+ }
+
+ /* next use author string */
+
+ if (irp1->authstr != NULL && irp2->authstr != NULL) {
+ compare = StringICmp (irp1->authstr, irp2->authstr);
+ if (compare > 0) {
+ return 1;
+ } else if (compare < 0) {
+ return -1;
+ }
+ }
+
+ /* use unique label string to determine sort order */
+
+ if (rbp1->uniquestr != NULL && rbp2->uniquestr != NULL) {
+ compare = StringICmp (rbp1->uniquestr, rbp2->uniquestr);
+ if (compare > 0) {
+ return 1;
+ } else if (compare < 0) {
+ return -1;
+ }
+ }
+
+ /* last resort for equivalent publication descriptors, sort in itemID order */
+
+ if (rbp1->itemtype == OBJ_SEQDESC && rbp2->itemtype == OBJ_SEQDESC) {
+ if (rbp1->itemID > rbp2->itemID) {
+ return 1;
+ } else if (rbp1->itemID < rbp2->itemID) {
+ return -1;
+ }
+ }
+
+ if (! serialFirst) {
+ if (rbp1->serial > rbp2->serial) {
+ return 1;
+ } else if (rbp1->serial < rbp2->serial) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int LIBCALLBACK SortReferencesA (
+ VoidPtr ptr1,
+ VoidPtr ptr2
+)
+
+{
+ return SortReferences (ptr1, ptr2, FALSE, FALSE);
+}
+
+static int LIBCALLBACK SortReferencesB (
+ VoidPtr ptr1,
+ VoidPtr ptr2
+)
+
+{
+ return SortReferences (ptr1, ptr2, TRUE, FALSE);
+}
+
+static int LIBCALLBACK SortReferencesAR (
+ VoidPtr ptr1,
+ VoidPtr ptr2
+)
+
+{
+ return SortReferences (ptr1, ptr2, FALSE, TRUE);
+}
+
+static int LIBCALLBACK SortReferencesBR (
+ VoidPtr ptr1,
+ VoidPtr ptr2
+)
+
+{
+ return SortReferences (ptr1, ptr2, TRUE, TRUE);
+}
+
+static CharPtr GetAuthorsPlusConsortium (
+ FmtType format,
+ AuthListPtr alp
+)
+
+{
+ CharPtr consortium;
+ CharPtr str;
+ CharPtr tmp;
+
+ consortium = NULL;
+ str = GetAuthorsString (format, alp, &consortium, NULL, NULL);
+ if (str == NULL) return consortium;
+ if (consortium == NULL) return str;
+ tmp = MemNew (StringLen (str) + StringLen (consortium) + 5);
+ if (tmp == NULL) return NULL;
+ StringCpy (tmp, str);
+ StringCat (tmp, "; ");
+ StringCat (tmp, consortium);
+ MemFree (str);
+ MemFree (consortium);
+ return tmp;
+}
+
+static Boolean HasNoPmidOrMuid (
+ PubdescPtr pdp
+)
+
+{
+ ValNodePtr vnp;
+
+ if (pdp == NULL) return TRUE;
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == PUB_PMid || vnp->choice == PUB_Muid) return FALSE;
+ }
+ return TRUE;
+}
+
+typedef struct cdspubs {
+ Asn2gbWorkPtr awp;
+ BioseqPtr target;
+ ValNodePtr vnp;
+} CdsPubs, PNTR CdsPubsPtr;
+
+static Boolean LIBCALLBACK GetRefsOnCDS (
+ SeqFeatPtr sfp,
+ SeqMgrFeatContextPtr context
+)
+
+{
+ AuthListPtr alp;
+ Asn2gbWorkPtr awp;
+ CdsPubsPtr cpp;
+ IntRefBlockPtr irp;
+ Boolean okay;
+ PubdescPtr pdp;
+ RefBlockPtr rbp;
+
+ if (sfp == NULL || context == NULL) return TRUE;
+ cpp = (CdsPubsPtr) context->userdata;
+ awp = cpp->awp;
+ if (awp == NULL) return TRUE;
+
+ okay = TRUE;
+ pdp = (PubdescPtr) sfp->data.value.ptrvalue;
+ if (awp->format == FTABLE_FMT) {
+ if (HasNoPmidOrMuid (pdp)) {
+ okay = FALSE;
+ }
+ }
+
+ if (okay) {
+ rbp = AddPub (awp, &(awp->pubhead), pdp);
+ if (rbp != NULL) {
+
+ rbp->entityID = context->entityID;
+ rbp->itemID = context->itemID;
+ rbp->itemtype = OBJ_SEQFEAT;
+
+ irp = (IntRefBlockPtr) rbp;
+ irp->loc = SeqLocMerge (cpp->target, cpp->vnp, NULL, FALSE, TRUE, FALSE);
+ alp = GetAuthListPtr (pdp, NULL);
+ if (alp != NULL) {
+ irp->authstr = GetAuthorsPlusConsortium (awp->format, alp);
+ }
+ irp->index = 0;
+ }
+ }
+
+ return TRUE;
+}
+
+static void GetRefsOnBioseq (
+ Asn2gbWorkPtr awp,
+ BioseqPtr target,
+ BioseqPtr bsp,
+ Int4 from,
+ Int4 to,
+ SeqLocPtr cdsloc
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ AuthListPtr alp;
+ CdsPubs cp;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ Int2 i;
+ Int2 idx;
+ IntRefBlockPtr irp;
+ Int4Ptr ivals;
+ Int4 left;
+ SeqLocPtr newloc;
+ Int2 numivals;
+ Boolean okay;
+ PubdescPtr pdp;
+ RefBlockPtr rbp;
+ Int4 right;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+ SeqInt sint;
+ SeqIdPtr sip;
+ Boolean split;
+ Int4 start;
+ Int4 stop;
+ Uint1 strand;
+ Boolean takeIt;
+ ValNode vn;
+ ValNodePtr vnp;
+
+ if (awp == NULL || target == NULL || bsp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+
+ /* full length loc for descriptors */
+
+ sint.from = 0;
+ if (ajp->ajp.slp != NULL) {
+ from = SeqLocStart (ajp->ajp.slp); /* other features use awp->slp for from and to */
+ }
+ if (ajp->ajp.slp != NULL) {
+ sint.to = SeqLocLen (ajp->ajp.slp) - 1;
+ to = SeqLocStop (ajp->ajp.slp); /* other features use awp->slp for from and to */
+ } else {
+ sint.to = bsp->length - 1;
+ }
+ sint.strand = Seq_strand_plus;
+ sint.id = SeqIdStripLocus (SeqIdDup (SeqIdFindBest (bsp->id, 0)));
+ sint.if_from = NULL;
+ sint.if_to = NULL;
+
+ vn.choice = SEQLOC_INT;
+ vn.data.ptrvalue = (Pointer) &sint;
+ vn.next = NULL;
+
+ sdp = SeqMgrGetNextDescriptor (target, NULL, Seq_descr_pub, &dcontext);
+ while (sdp != NULL) {
+
+ /* check if descriptor on part already added on segmented bioseq */
+
+ okay = TRUE;
+ for (vnp = awp->pubhead; vnp != NULL && okay; vnp = vnp->next) {
+ rbp = (RefBlockPtr) vnp->data.ptrvalue;
+ if (rbp != NULL) {
+ if (rbp->entityID == dcontext.entityID &&
+ rbp->itemID == dcontext.itemID &&
+ rbp->itemtype == OBJ_SEQDESC) {
+ okay = FALSE;
+ }
+ }
+ }
+ if (awp->format == FTABLE_FMT) {
+ pdp = (PubdescPtr) sdp->data.ptrvalue;
+ if (HasNoPmidOrMuid (pdp)) {
+ okay = FALSE;
+ }
+ }
+
+ if (okay) {
+ pdp = (PubdescPtr) sdp->data.ptrvalue;
+ rbp = AddPub (awp, &(awp->pubhead), pdp);
+ if (rbp != NULL) {
+
+ rbp->entityID = dcontext.entityID;
+ rbp->itemID = dcontext.itemID;
+ rbp->itemtype = OBJ_SEQDESC;
+
+ irp = (IntRefBlockPtr) rbp;
+ irp->loc = SeqLocMerge (target, &vn, NULL, FALSE, TRUE, FALSE);
+ alp = GetAuthListPtr (pdp, NULL);
+ if (alp != NULL) {
+ irp->authstr = GetAuthorsPlusConsortium (awp->format, alp);
+ }
+ irp->index = 0;
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (target, sdp, Seq_descr_pub, &dcontext);
+ }
+
+ /* if protein with no pubs, get pubs applicable to DNA location of CDS */
+
+ if (cdsloc != NULL) {
+ cp.awp = awp;
+ cp.target = target;
+ cp.vnp = &vn;
+ SeqMgrGetAllOverlappingFeatures (cdsloc, FEATDEF_PUB, NULL, 0, LOCATION_SUBSET, (Pointer) &cp, GetRefsOnCDS);
+ }
+
+ SeqIdFree (sint.id);
+
+ /* features are indexed on parent if segmented */
+
+ bsp = awp->parent;
+
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_PUB, 0, &fcontext);
+ while (sfp != NULL) {
+ ivals = fcontext.ivals;
+ numivals = fcontext.numivals;
+ if (ivals != NULL && numivals > 0) {
+
+ /*
+ idx = (numivals - 1) * 2;
+ start = ivals [idx];
+ stop = ivals [idx + 1];
+ */
+
+ takeIt = FALSE;
+ for (i = 0, idx = 0; i < numivals; i++, idx += 2) {
+ start = ivals [idx];
+ stop = ivals [idx + 1];
+ if ((start <= from && stop > from) ||
+ (start < to && stop >= to) ||
+ (start >= from && stop <= to)) {
+ takeIt = TRUE;
+ }
+ }
+ if (awp->format == FTABLE_FMT) {
+ pdp = (PubdescPtr) sdp->data.ptrvalue;
+ if (HasNoPmidOrMuid (pdp)) {
+ takeIt = FALSE;
+ }
+ }
+
+ if (takeIt /* stop >= from && stop <= to */) {
+
+ /*
+ start = ivals [0] + 1;
+ stop = ivals [idx + 1] + 1;
+ */
+ pdp = (PubdescPtr) sfp->data.value.ptrvalue;
+ rbp = AddPub (awp, &(awp->pubhead), pdp);
+ if (rbp != NULL) {
+
+ rbp->entityID = fcontext.entityID;
+ rbp->itemID = fcontext.itemID;
+ rbp->itemtype = OBJ_SEQFEAT;
+
+ irp = (IntRefBlockPtr) rbp;
+ irp->loc = SeqLocMerge (target, sfp->location, NULL, FALSE, TRUE, FALSE);
+ if (ajp->ajp.slp != NULL) {
+ sip = SeqIdParse ("lcl|dummy");
+ left = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_LEFT_END);
+ right = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_RIGHT_END);
+ strand = SeqLocStrand (ajp->ajp.slp);
+ split = FALSE;
+ newloc = SeqLocReMapEx (sip, ajp->ajp.slp, irp->loc, 0, FALSE, ajp->masterStyle);
+ /*
+ newloc = SeqLocCopyRegion (sip, irp->loc, bsp, left, right, strand, &split);
+ */
+ SeqIdFree (sip);
+ if (newloc != NULL) {
+ A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
+ irp->loc = SeqLocFree (irp->loc);
+ irp->loc = newloc;
+ }
+ }
+ alp = GetAuthListPtr (pdp, NULL);
+ if (alp != NULL) {
+ irp->authstr = GetAuthorsPlusConsortium (awp->format, alp);
+ }
+ irp->index = fcontext.index;
+ }
+ }
+ }
+
+ sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_PUB, 0, &fcontext);
+ }
+}
+
+static Boolean LIBCALLBACK GetRefsOnSeg (
+ SeqLocPtr slp,
+ SeqMgrSegmentContextPtr context
+)
+
+{
+ Asn2gbWorkPtr awp;
+ BioseqPtr bsp;
+ Int4 from;
+ SeqLocPtr loc;
+ SeqEntryPtr oldscope;
+ SeqEntryPtr sep;
+ SeqIdPtr sip;
+ Int4 to;
+
+ if (slp == NULL || context == NULL) return FALSE;
+ awp = (Asn2gbWorkPtr) context->userdata;
+
+ from = context->cumOffset;
+ to = from + context->to - context->from;
+
+ sip = SeqLocId (slp);
+ if (sip == NULL) {
+ loc = SeqLocFindNext (slp, NULL);
+ if (loc != NULL) {
+ sip = SeqLocId (loc);
+ }
+ }
+ if (sip == NULL) return TRUE;
+
+ /* reference descriptors only on parts within entity */
+
+ sep = GetTopSeqEntryForEntityID (awp->entityID);
+ oldscope = SeqEntrySetScope (sep);
+ bsp = BioseqFind (sip);
+ SeqEntrySetScope (oldscope);
+
+ if (bsp != NULL) {
+ GetRefsOnBioseq (awp, awp->refs, bsp, from, to, NULL);
+ return TRUE;
+ }
+
+ /* if we ever want to fetch remote references, code goes here */
+
+ return TRUE;
+}
+
+NLM_EXTERN Boolean AddReferenceBlock (
+ Asn2gbWorkPtr awp,
+ Boolean isRefSeq
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ AuthListPtr alp;
+ Asn2gbSectPtr asp;
+ BioseqPtr bsp;
+ SeqFeatPtr cds;
+ Boolean combine;
+ SeqMgrFeatContext context;
+ CitSubPtr csp;
+ BioseqPtr dna;
+ Boolean excise;
+ ValNodePtr head = NULL;
+ Int2 i;
+ IntRefBlockPtr irp;
+ Boolean is_aa;
+ Boolean is_embl = FALSE;
+ Boolean is_patent = FALSE;
+ IntRefBlockPtr lastirp;
+ RefBlockPtr lastrbp;
+ ValNodePtr next;
+ Int2 numReferences;
+ ValNodePtr PNTR prev;
+ RefBlockPtr rbp;
+ RefBlockPtr PNTR referenceArray;
+ BioseqPtr refs;
+ SubmitBlockPtr sbp;
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+ BioseqPtr target;
+ ValNodePtr vnp;
+
+ if (awp == NULL) return FALSE;
+ ajp = awp->ajp;
+ if (ajp == NULL) return FALSE;
+ asp = awp->asp;
+ if (asp == NULL) return FALSE;
+ bsp = awp->bsp;
+ refs = awp->refs;
+ if (bsp == NULL || refs == NULL) return FALSE;
+
+ /* collect publications on bioseq */
+
+ awp->pubhead = NULL;
+ GetRefsOnBioseq (awp, bsp, refs, awp->from, awp->to, NULL);
+ target = bsp;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_EMBL) {
+ is_embl = TRUE;
+ } else if (sip->choice == SEQID_PATENT) {
+ is_patent = TRUE;
+ }
+ }
+
+ is_aa = (Boolean) ISA_aa (bsp->mol);
+
+ if (bsp->repr == Seq_repr_seg) {
+
+ /* collect publication descriptors on local parts */
+
+ SeqMgrExploreSegments (bsp, (Pointer) awp, GetRefsOnSeg);
+ target = awp->refs;
+ }
+
+ if (awp->pubhead == NULL && ISA_aa (bsp->mol)) {
+
+ /* if protein with no pubs, get pubs applicable to DNA location of CDS */
+
+ cds = SeqMgrGetCDSgivenProduct (bsp, &context);
+ if (cds != NULL) {
+ dna = BioseqFindFromSeqLoc (cds->location);
+ if (dna != NULL) {
+ GetRefsOnBioseq (awp, dna, dna, context.left, context.right, cds->location);
+ target = dna;
+ }
+ }
+ }
+
+ head = awp->pubhead;
+ awp->pubhead = NULL;
+
+ if (head == NULL && awp->ssp == NULL) return FALSE;
+
+ /* sort by pub/unpub/sites/sub, then date, finally existing serial */
+
+ if (isRefSeq) {
+ head = SortValNode (head, SortReferencesAR);
+ } else {
+ head = SortValNode (head, SortReferencesA);
+ }
+
+ if (awp->ssp != NULL) {
+
+ /* add seq-submit citation */
+
+ rbp = (RefBlockPtr) MemNew (sizeof (IntRefBlock));
+ if (rbp != NULL) {
+ irp = (IntRefBlockPtr) rbp;
+
+ rbp->blocktype = REFERENCE_BLOCK;
+ rbp->section = awp->currsection;
+ rbp->serial = INT2_MAX;
+ rbp->category = REF_CAT_SUB;
+
+ rbp->entityID = ajp->ajp.entityID;
+ rbp->itemID = 1;
+ rbp->itemtype = OBJ_SEQSUB_CIT;
+
+ sbp = awp->ssp->sub;
+ if (sbp != NULL) {
+ csp = sbp->cit;
+ if (csp != NULL) {
+ alp = GetAuthListPtr (NULL, csp);
+ if (alp != NULL) {
+ irp->authstr = GetAuthorsPlusConsortium (awp->format, alp);
+ }
+ }
+ }
+
+ if (awp->citSubsFirst) {
+
+ /* for DDBJ, add seq-submit citation to beginning of list */
+
+ vnp = ValNodeNew (NULL);
+ if (vnp != NULL) {
+ vnp->choice = 0;
+ vnp->data.ptrvalue = (VoidPtr) rbp;
+ vnp->next = head;
+ head = vnp;
+ }
+
+ } else {
+
+ /* for GENBANK and EMBL add seq-submit citation to end of list */
+
+ ValNodeAddPointer (&head, 0, rbp);
+ }
+ }
+ }
+
+ /* unique references, excise duplicates from list */
+
+ prev = &(head);
+ vnp = head;
+ lastrbp = NULL;
+ while (vnp != NULL) {
+ excise = FALSE;
+ combine = TRUE;
+ next = vnp->next;
+ rbp = (RefBlockPtr) vnp->data.ptrvalue;
+ if (lastrbp != NULL) {
+ lastirp = (IntRefBlockPtr) lastrbp;
+ if (rbp != NULL) {
+ irp = (IntRefBlockPtr) rbp;
+ if (lastrbp->pmid != 0 && rbp->pmid != 0) {
+ if (lastrbp->pmid == rbp->pmid) {
+ excise = TRUE;
+ }
+ } else if (lastrbp->muid != 0 && rbp->muid != 0) {
+ if (lastrbp->muid == rbp->muid) {
+ excise = TRUE;
+ }
+ } else if (lastrbp->uniquestr != NULL && rbp->uniquestr != NULL) {
+ if (StringICmp (lastrbp->uniquestr, rbp->uniquestr) == 0) {
+ if (SeqLocCompare (irp->loc, lastirp->loc) == SLC_A_EQ_B) {
+ if (StringICmp (irp->authstr, lastirp->authstr) == 0) {
+
+ /* L76496.1 - removing duplicate submission pubs */
+ excise = TRUE;
+ }
+ }
+ }
+ }
+ if (excise && lastrbp->sites == 0 && rbp->sites > 0) {
+ /* real range trumps sites */
+ combine = FALSE;
+ }
+ }
+ }
+ if (rbp != NULL) {
+ irp = (IntRefBlockPtr) rbp;
+ if (irp->justuids) {
+ if (isRefSeq && is_aa) {
+ /* if allowing justuid in protein RefSeq, try to look up dynamically */
+ excise = TRUE; /* Back to old behavior, do not fetch */
+ } else {
+ /* do not allow justuids reference to appear by itself - S79174.1 */
+ excise = TRUE;
+ /* justuids should still combine, even if no authors - S67070.1 */
+ }
+ } else if (is_embl && is_patent) {
+ /* EMBL patent records do not need author or title - A29528.1 */
+ } else if (StringHasNoText (irp->authstr)) {
+ /* do not allow no author reference to appear by itself - U07000.1 */
+ excise = TRUE;
+ combine = FALSE;
+ }
+ }
+ if (excise) {
+ *prev = vnp->next;
+ vnp->next = NULL;
+
+ /* combine locations of duplicate references */
+
+ irp = (IntRefBlockPtr) rbp;
+ lastirp = (IntRefBlockPtr) lastrbp;
+ if (combine) {
+ if (lastirp != NULL) {
+ slp = SeqLocMerge (target, lastirp->loc, irp->loc, FALSE, TRUE, FALSE);
+ lastirp->loc = SeqLocFree (lastirp->loc);
+ lastirp->loc = slp;
+ }
+ if (irp != NULL && lastirp != NULL) {
+ if ((rbp->muid == lastrbp->muid && rbp->muid != 0) ||
+ (rbp->pmid == lastrbp->pmid && rbp->pmid != 0)) {
+ if (lastirp->fig == NULL) {
+ lastirp->fig = StringSaveNoNull (irp->fig);
+ }
+ if (lastirp->maploc == NULL) {
+ lastirp->maploc = StringSaveNoNull (irp->maploc);
+ }
+ lastirp->poly_a = irp->poly_a;
+ }
+ }
+ }
+
+ /* and remove duplicate reference */
+
+ MemFree (rbp->uniquestr);
+ DateFree (irp->date);
+ SeqLocFree (irp->loc);
+ MemFree (irp->authstr);
+ MemFree (irp->fig);
+ MemFree (irp->maploc);
+ MemFree (rbp);
+ ValNodeFree (vnp);
+
+ } else {
+
+ prev = &(vnp->next);
+ lastrbp = rbp;
+ }
+ vnp = next;
+ }
+
+ /* resort by existing serial, then pub/unpub/sites/sub, then date */
+
+ if (isRefSeq) {
+ head = SortValNode (head, SortReferencesBR);
+ } else {
+ head = SortValNode (head, SortReferencesB);
+ }
+
+ if (head == NULL) return FALSE;
+
+ /* if taking best GeneRIFs, free remainder */
+
+ if (awp->latestGeneRIFs) {
+ for (vnp = head, i = 0; vnp != NULL && i < 10; vnp = vnp->next, i++) continue;
+ if (vnp != NULL) {
+ next = vnp->next;
+ vnp->next = NULL;
+ for (vnp = next; vnp != NULL; vnp = vnp->next) {
+ rbp = (RefBlockPtr) vnp->data.ptrvalue;
+ MemFree (rbp->uniquestr);
+ irp = (IntRefBlockPtr) rbp;
+ DateFree (irp->date);
+ SeqLocFree (irp->loc);
+ MemFree (irp->authstr);
+ MemFree (irp->fig);
+ MemFree (irp->maploc);
+ MemFree (rbp);
+ }
+ }
+ }
+
+ /* assign serial numbers */
+
+ for (vnp = head, i = 1; vnp != NULL; vnp = vnp->next, i++) {
+ rbp = (RefBlockPtr) vnp->data.ptrvalue;
+ if (rbp != NULL) {
+ rbp->serial = i;
+ }
+ }
+
+ /* allocate reference array for this section */
+
+ numReferences = i - 1;
+ asp->numReferences = numReferences;
+
+ if (numReferences > 0) {
+ referenceArray = (RefBlockPtr PNTR) MemNew (sizeof (RefBlockPtr) * (numReferences + 1));
+ asp->referenceArray = referenceArray;
+
+ if (referenceArray != NULL) {
+
+ /* fill in reference array */
+
+ for (vnp = head, i = 0; vnp != NULL && i < numReferences; vnp = vnp->next, i++) {
+ referenceArray [i] = (RefBlockPtr) vnp->data.ptrvalue;
+ }
+ }
+ }
+
+ /* finally link into blocks for current section */
+
+ ValNodeLink (&(awp->lastblock), head);
+ vnp = awp->lastblock;
+ if (vnp == NULL) return FALSE;
+ while (vnp->next != NULL) {
+ vnp = vnp->next;
+ }
+
+ awp->lastblock = vnp;
+ if (awp->blockList == NULL) {
+ awp->blockList = vnp;
+ }
+
+ return TRUE;
+}
+
+NLM_EXTERN void AddWGSBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Char buf [80];
+ SeqMgrDescContext dcontext;
+ CharPtr first;
+ CharPtr last;
+ ObjectIdPtr oip;
+ SeqDescrPtr sdp;
+ UserFieldPtr ufp;
+ UserObjectPtr uop;
+ Int2 wgstype;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if ( ajp == NULL ) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) return;
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL) {
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop != NULL) {
+ oip = uop->type;
+ first = NULL;
+ last = NULL;
+ wgstype = 0;
+ if (oip != NULL) {
+ if (StringICmp (oip->str, "WGSProjects") == 0) {
+ wgstype = 1;
+ } else if (StringICmp (oip->str, "WGS-Scaffold-List") == 0) {
+ wgstype = 2;
+ } else if (StringICmp (oip->str, "WGS-Contig-List") == 0) {
+ wgstype = 3;
+ }
+ if (wgstype != 0) {
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (oip == NULL || oip->str == NULL || ufp->choice != 1) continue;
+ if (StringICmp (oip->str, "WGS_accession_first") == 0) {
+ first = (CharPtr) ufp->data.ptrvalue;
+ } else if (StringICmp (oip->str, "WGS_accession_last") == 0) {
+ last = (CharPtr) ufp->data.ptrvalue;
+ } else if (StringICmp (oip->str, "Accession_first") == 0) {
+ first = (CharPtr) ufp->data.ptrvalue;
+ } else if (StringICmp (oip->str, "Accession_last") == 0) {
+ last = (CharPtr) ufp->data.ptrvalue;
+ }
+ }
+ if (first != NULL && last != NULL) {
+ bbp = Asn2gbAddBlock (awp, WGS_BLOCK, sizeof (BaseBlock));
+ if (bbp != NULL) {
+ ffstring = FFGetString (ajp);
+ if (ffstring != NULL) {
+ if (wgstype == 1) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "WGS", 12, 0, 0, NULL, FALSE);
+ } else if (wgstype == 2) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "WGS_SCAFLD", 12, 0, 0, NULL, FALSE);
+ } else if (wgstype == 3) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "WGS_CONTIG", 12, 0, 0, NULL, FALSE);
+ }
+
+ if ( GetWWW(ajp) ) {
+ if (StringCmp (first, last) != 0) {
+ FFAddTextToString(ffstring, "<a href=", link_wgs, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "db=Nucleotide&cmd=Search&term=", first, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, ":", last, "[ACCN]>", FALSE, FALSE, TILDE_IGNORE);
+ sprintf (buf, "%s-%s", first, last);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_TO_SPACES);
+ } else {
+ FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "val=", first, ">", FALSE, FALSE, TILDE_IGNORE);
+ sprintf (buf, "%s", first);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_TO_SPACES);
+ }
+ } else {
+ if (StringCmp (first, last) != 0) {
+ sprintf (buf, "%s-%s", first, last);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ } else {
+ sprintf (buf, "%s", first);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ }
+ }
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 0, 0, NULL);
+ FFRecycleString(ajp, ffstring);
+ }
+ }
+ }
+ }
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
+ }
+}
+
+NLM_EXTERN void AddGenomeBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ CharPtr accn;
+ IntAsn2gbJobPtr ajp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ SeqMgrDescContext dcontext;
+ Boolean first = TRUE;
+ CharPtr moltype;
+ ObjectIdPtr oip;
+ SeqDescrPtr sdp;
+ UserFieldPtr ufp;
+ UserObjectPtr uop;
+ UserFieldPtr urf;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if ( ajp == NULL ) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) return;
+
+ bbp = Asn2gbAddBlock (awp, GENOME_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "GENOME", 12, 0, 0, NULL, FALSE);
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL) {
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop != NULL) {
+ oip = uop->type;
+ if (oip != NULL && StringICmp (oip->str, "GenomeProject") == 0) {
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (oip == NULL || oip->str == NULL || ufp->choice != 11) continue;
+ if (StringICmp (oip->str, "Chromosome") != 0) continue;
+ accn = NULL;
+ moltype = NULL;
+ for (urf = (UserFieldPtr) ufp->data.ptrvalue; urf != NULL; urf = urf->next) {
+ oip = urf->label;
+ if (oip == NULL || oip->str == NULL || urf->choice != 1) continue;
+ if (StringICmp (oip->str, "accession") == 0) {
+ accn = (CharPtr) urf->data.ptrvalue;
+ } else if (StringICmp (oip->str, "Moltype") == 0) {
+ moltype = (CharPtr) urf->data.ptrvalue;
+ }
+ }
+ if (! StringHasNoText (accn)) {
+ if (! first) {
+ FFAddNewLine(ffstring);
+ }
+ first = FALSE;
+ FFAddOneString (ffstring, accn, FALSE, FALSE, TILDE_IGNORE);
+ if (! StringHasNoText (moltype)) {
+ FFAddTextToString (ffstring, " (", moltype, ")", FALSE, FALSE, TILDE_TO_SPACES);
+ }
+ }
+ }
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
+ }
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 0, 0, NULL);
+ FFRecycleString(ajp, ffstring);
+}
+
+NLM_EXTERN void AddBasecountBlock (
+ Asn2gbWorkPtr awp,
+ CharPtr bases
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Int4 base_count [5];
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Char buf [80];
+ Char ch;
+ Int2 i;
+ Int4 len;
+ StringItemPtr ffstring;
+ CharPtr ptr;
+ CharPtr str;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, BASECOUNT_BLOCK, sizeof (BaseBlock));
+
+ if (bases == NULL || ajp->ajp.slp != NULL) return;
+ len = bsp->length;
+ for (i = 0; i < 5; i++) {
+ base_count [i] = 0;
+ }
+
+ ptr = bases;
+ ch = *ptr;
+ while (ch != '\0') {
+ ch = TO_UPPER (ch);
+ switch (ch) {
+ case 'A' :
+ (base_count [0])++;
+ break;
+ case 'C' :
+ (base_count [1])++;
+ break;
+ case 'G' :
+ (base_count [2])++;
+ break;
+ case 'T' :
+ (base_count [3])++;
+ break;
+ default :
+ (base_count [4])++;
+ break;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+
+ if (awp->format == GENBANK_FMT || awp->format == GENPEPT_FMT) {
+
+ if (base_count [4] == 0) {
+ sprintf (buf, "%7ld a%7ld c%7ld g%7ld t",
+ (long) base_count [0], (long) base_count [1],
+ (long) base_count [2], (long) base_count [3]);
+ } else {
+ sprintf (buf, "%7ld a%7ld c%7ld g%7ld t%7ld others",
+ (long) base_count [0], (long) base_count [1],
+ (long) base_count [2], (long) base_count [3],
+ (long) base_count [4]);
+ }
+
+ } else if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+
+ sprintf (buf, "Sequence %ld BP; %ld A; %ld C; %ld G; %ld T; %ld other;",
+ (long) len,
+ (long) base_count [0], (long) base_count [1],
+ (long) base_count [2], (long) base_count [3],
+ (long) base_count [4]);
+ }
+
+ ffstring = FFGetString (ajp);
+ if ( ffstring == NULL ) return;
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ FFAddOneString(ffstring, "XX\n", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFStartPrint (ffstring, awp->format, 0, 0, "BASE COUNT", 12, 5, 5, "SQ", FALSE);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ str = FFEndPrint(ajp, ffstring, awp->format, 12, 0, 5, 5, "SQ");
+ FFRecycleString(ajp, ffstring);
+
+ bbp->string = StringSave (str);
+}
+
+NLM_EXTERN void AddOriginBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ Char buf [67];
+ SeqMgrDescContext dcontext;
+ GBBlockPtr gbp;
+ SeqDescrPtr sdp;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ bbp = Asn2gbAddBlock (awp, ORIGIN_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ if (awp->format == GENBANK_FMT || awp->format == GENPEPT_FMT) {
+
+ buf [0] = '\0';
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
+ if (sdp != NULL) {
+ gbp = (GBBlockPtr) sdp->data.ptrvalue;
+ if (gbp != NULL && (! StringHasNoText (gbp->origin))) {
+ StringNCpy_0 (buf, gbp->origin, sizeof (buf));
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ }
+ }
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "ORIGIN", 12, 0, 0, NULL, FALSE);
+
+ if (! StringHasNoText (buf)) {
+ FFAddOneString (ffstring, buf, TRUE, FALSE, TILDE_TO_SPACES);
+ }
+ }
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 0, 12, 0, 0, NULL);
+ FFRecycleString(ajp, ffstring);
+}
+
+#define BASES_PER_BLOCK 1200
+
+NLM_EXTERN void AddSequenceBlock (
+ Asn2gbWorkPtr awp,
+ CharPtr bases
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BioseqPtr bsp;
+ Int4 i;
+ Int4 j;
+ Int4 len;
+ CharPtr ptr;
+ SeqBlockPtr sbp;
+ Int4 start;
+ Int4 stop;
+ CharPtr str;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ if (awp->slp != NULL) {
+ len = SeqLocLen (awp->slp);
+ } else {
+ len = bsp->length;
+ }
+
+ /* if generating GBSeq XML, populate single sequence block */
+
+ if (ajp->gbseq) {
+ sbp = (SeqBlockPtr) Asn2gbAddBlock (awp, SEQUENCE_BLOCK, sizeof (SeqBlock));
+ if (sbp == NULL) return;
+
+ sbp->entityID = bsp->idx.entityID;
+ sbp->itemID = bsp->idx.itemID;
+ sbp->itemtype = OBJ_BIOSEQ;
+
+ sbp->start = 0;
+ sbp->stop = len;
+ return;
+ }
+
+ /* otherwise populate individual sequence blocks for given range */
+
+ ptr = bases;
+
+ for (start = 0; start < len; start += BASES_PER_BLOCK) {
+ sbp = (SeqBlockPtr) Asn2gbAddBlock (awp, SEQUENCE_BLOCK, sizeof (SeqBlock));
+ if (sbp == NULL) continue;
+
+ sbp->entityID = bsp->idx.entityID;
+ sbp->itemID = bsp->idx.itemID;
+ sbp->itemtype = OBJ_BIOSEQ;
+
+ stop = start + BASES_PER_BLOCK;
+ if (stop >= len) {
+ stop = len;
+ }
+
+ sbp->start = start;
+ sbp->stop = stop;
+
+ if (ptr != NULL) {
+ str = MemNew (sizeof (Char) * (BASES_PER_BLOCK + 2));
+ if (str != NULL) {
+ sbp->bases = str;
+ j = stop - start;
+ for (i = 0; i < j; i++) {
+ *str = *ptr;
+ ptr++;
+ str++;
+ }
+ }
+ }
+ }
+}
+
+NLM_EXTERN void AddContigBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ BaseBlockPtr bbp;
+
+ if (awp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, CONTIG_BLOCK, sizeof (BaseBlock));
+}
+
+NLM_EXTERN void AddSlashBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ BaseBlockPtr bbp;
+ CharPtr str;
+
+ if (awp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, SLASH_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ str = MemNew(sizeof(Char) * 4);
+ StringNCpy(str, "//\n", 4);
+
+ bbp->string = str;
+}
+
diff --git a/api/asn2gnb3.c b/api/asn2gnb3.c
new file mode 100644
index 00000000..9506e54a
--- /dev/null
+++ b/api/asn2gnb3.c
@@ -0,0 +1,4312 @@
+/* asn2gnb3.c
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: asn2gnb3.c
+*
+* Author: Karl Sirotkin, Tom Madden, Tatiana Tatusov, Jonathan Kans,
+* Mati Shomrat
+*
+* Version Creation Date: 10/21/98
+*
+* $Revision: 1.4 $
+*
+* File Description: New GenBank flatfile generator - work in progress
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <objall.h>
+#include <objsset.h>
+#include <objsub.h>
+#include <objfdef.h>
+#include <objpubme.h>
+#include <seqport.h>
+#include <sequtil.h>
+#include <sqnutils.h>
+#include <subutil.h>
+#include <tofasta.h>
+#include <explore.h>
+#include <gbfeat.h>
+#include <gbftdef.h>
+#include <edutil.h>
+#include <alignmgr2.h>
+#include <asn2gnbi.h>
+
+#ifdef WIN_MAC
+#if __profile__
+#include <Profiler.h>
+#endif
+#endif
+
+/* ********************************************************************** */
+
+static void AddHistCommentString (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr prefix,
+ CharPtr suffix,
+ DatePtr dp,
+ SeqIdPtr ids
+)
+
+{
+ Int2 count = 0;
+ Char buf [256];
+ Boolean first;
+ Int4 gi = 0;
+ SeqIdPtr sip;
+ CharPtr strd;
+
+ if (dp == NULL || ids == NULL || prefix == NULL || suffix == NULL || ffstring == NULL) return;
+
+ strd = asn2gb_PrintDate (dp);
+ if (strd == NULL) {
+ strd = StringSave ("?");
+ }
+
+ for (sip = ids; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GI) {
+ gi = (long) sip->data.intvalue;
+ count++;
+ }
+ }
+
+ if (count > 1) {
+ sprintf (buf, "%s or before %s %s", prefix, strd, suffix);
+ } else {
+ sprintf (buf, "%s %s %s", prefix, strd, suffix);
+ }
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
+
+ MemFree (strd);
+
+ if (gi == 0) {
+ FFAddOneString (ffstring, " gi:?", FALSE, FALSE, TILDE_EXPAND);
+ return;
+ }
+
+ first = TRUE;
+ for (sip = ids; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GI) {
+ gi = (long) sip->data.intvalue;
+ if (! first) {
+ FFAddOneString (ffstring, ",", FALSE, FALSE, TILDE_IGNORE);
+ }
+ first = FALSE;
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, " gi:", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString (ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
+ sprintf (buf, "%ld", (long) gi);
+ FFAddTextToString (ffstring, "val=", buf, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ sprintf (buf, " gi:%ld", (long) gi);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
+ }
+ }
+ }
+
+ FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_EXPAND);
+}
+
+static void AddHTGSCommentString (
+ StringItemPtr ffstring,
+ BioseqPtr bsp,
+ MolInfoPtr mip
+)
+
+{
+ CharPtr buf = NULL;
+ Char buffer [256];
+ Int4 buflen = 0;
+ DeltaSeqPtr dsp;
+ ValNodePtr head = NULL;
+ Int4 num_s = 0;
+ Int4 num_g = 0;
+ CharPtr str = NULL;
+
+ if (bsp == NULL || mip == NULL || mip->tech < 2) return;
+
+ if (bsp->repr == Seq_repr_delta) {
+ for (dsp = (DeltaSeqPtr) bsp->seq_ext, buflen = 0; dsp != NULL; dsp = dsp->next) {
+ buflen += 80;
+ }
+ if (buflen > 0) {
+ buf = MemNew ((size_t) (buflen + 1));
+ if (buf == NULL) return;
+ CountGapsInDeltaSeq (bsp, &num_s, &num_g, NULL, NULL, buf, buflen);
+ }
+ }
+
+ if (mip->tech == MI_TECH_htgs_0) {
+
+ if (num_s > 0) {
+ sprintf (buffer, "* NOTE: This record contains %ld individual~", (long) (num_g + 1));
+ ValNodeCopyStr (&head, 0, buffer);
+ ValNodeCopyStr (&head, 0, "* sequencing reads that have not been assembled into~");
+ ValNodeCopyStr (&head, 0, "* contigs. Runs of N are used to separate the reads~");
+ ValNodeCopyStr (&head, 0, "* and the order in which they appear is completely~");
+ ValNodeCopyStr (&head, 0, "* arbitrary. Low-pass sequence sampling is useful for~");
+ ValNodeCopyStr (&head, 0, "* identifying clones that may be gene-rich and allows~");
+ ValNodeCopyStr (&head, 0, "* overlap relationships among clones to be deduced.~");
+ ValNodeCopyStr (&head, 0, "* However, it should not be assumed that this clone~");
+ ValNodeCopyStr (&head, 0, "* will be sequenced to completion. In the event that~");
+ ValNodeCopyStr (&head, 0, "* the record is updated, the accession number will~");
+ ValNodeCopyStr (&head, 0, "* be preserved.");
+ }
+ ValNodeCopyStr (&head, 0, "~");
+ ValNodeCopyStr (&head, 0, buf);
+
+ } else if (mip->tech == MI_TECH_htgs_1) {
+
+ ValNodeCopyStr (&head, 0, "* NOTE: This is a \"working draft\" sequence.");
+ if (num_s > 0) {
+ sprintf (buffer, " It currently~* consists of %ld contigs. The true order of the pieces~", (long) (num_g + 1));
+ ValNodeCopyStr (&head, 0, buffer);
+ ValNodeCopyStr (&head, 0, "* is not known and their order in this sequence record is~");
+ ValNodeCopyStr (&head, 0, "* arbitrary. Gaps between the contigs are represented as~");
+ ValNodeCopyStr (&head, 0, "* runs of N, but the exact sizes of the gaps are unknown.");
+ }
+ ValNodeCopyStr (&head, 0, "~* This record will be updated with the finished sequence~");
+ ValNodeCopyStr (&head, 0, "* as soon as it is available and the accession number will~");
+ ValNodeCopyStr (&head, 0, "* be preserved.");
+ ValNodeCopyStr (&head, 0, "~");
+ ValNodeCopyStr (&head, 0, buf);
+
+ } else if (mip->tech == MI_TECH_htgs_2) {
+
+ ValNodeCopyStr (&head, 0, "* NOTE: This is a \"working draft\" sequence.");
+ if (num_s > 0) {
+ sprintf (buffer, " It currently~* consists of %ld contigs. Gaps between the contigs~", (long) (num_g + 1));
+ ValNodeCopyStr (&head, 0, buffer);
+ ValNodeCopyStr (&head, 0, "* are represented as runs of N. The order of the pieces~");
+ ValNodeCopyStr (&head, 0, "* is believed to be correct as given, however the sizes~");
+ ValNodeCopyStr (&head, 0, "* of the gaps between them are based on estimates that have~");
+ ValNodeCopyStr (&head, 0, "* provided by the submittor.");
+ }
+ ValNodeCopyStr (&head, 0, "~* This sequence will be replaced~");
+ ValNodeCopyStr (&head, 0, "* by the finished sequence as soon as it is available and~");
+ ValNodeCopyStr (&head, 0, "* the accession number will be preserved.");
+ ValNodeCopyStr (&head, 0, "~");
+ ValNodeCopyStr (&head, 0, buf);
+
+ } else if ((str = StringForSeqTech (mip->tech)) != NULL) {
+
+ sprintf (buffer, "Method: %s.", str);
+ ValNodeCopyStr (&head, 0, buffer);
+ }
+
+ MemFree (buf);
+
+ str = MergeFFValNodeStrs (head);
+
+ FFAddOneString (ffstring, str, TRUE, TRUE, TILDE_EXPAND);
+
+ MemFree (str);
+ ValNodeFreeData (head);
+}
+
+static void AddWGSMasterCommentString (
+ StringItemPtr ffstring,
+ BioseqPtr bsp,
+ CharPtr wgsaccn,
+ CharPtr wgsname
+)
+
+{
+ size_t acclen;
+ BioSourcePtr biop;
+ Char buf [256];
+ SeqMgrDescContext dcontext;
+ CharPtr first = NULL;
+ CharPtr last = NULL;
+ ObjectIdPtr oip;
+ OrgRefPtr orp;
+ SeqDescrPtr sdp;
+ CharPtr taxname = NULL;
+ UserFieldPtr ufp;
+ UserObjectPtr uop;
+ Char ver [16];
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ if (biop != NULL) {
+ orp = biop->org;
+ if (orp != NULL) {
+ taxname = orp->taxname;
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL) {
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop != NULL) {
+ oip = uop->type;
+ if (oip != NULL && StringICmp (oip->str, "WGSProjects") == 0) {
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (oip == NULL || oip->str == NULL || ufp->choice != 1) continue;
+ if (StringICmp (oip->str, "WGS_accession_first") == 0) {
+ first = (CharPtr) ufp->data.ptrvalue;
+ } else if (StringICmp (oip->str, "WGS_accession_last") == 0) {
+ last = (CharPtr) ufp->data.ptrvalue;
+ }
+ }
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
+ }
+
+ if (StringHasNoText (taxname)) {
+ taxname = "?";
+ }
+ if (StringHasNoText (first)) {
+ first = "?";
+ }
+ if (StringHasNoText (last)) {
+ last = "?";
+ }
+ ver [0] = '\0';
+ acclen = StringLen (wgsname);
+ if (acclen == 12) {
+ StringCpy (ver, wgsname + 4);
+ ver [2] = '\0';
+ } else if (acclen == 13) {
+ StringCpy (ver, wgsname + 4);
+ ver [2] = '\0';
+ } else if (acclen == 15) {
+ StringCpy (ver, wgsname + 7);
+ ver [2] = '\0';
+ }
+
+ sprintf (buf, "The %s whole genome shotgun (WGS) project has the project accession %s.", taxname, wgsaccn);
+ FFAddOneString(ffstring, buf, TRUE, FALSE, TILDE_EXPAND);
+
+ sprintf (buf, " This version of the project (%s) has the accession number %s,", ver, wgsname);
+ FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
+
+ if (StringCmp (first, last) != 0) {
+ sprintf (buf, " and consists of sequences %s-%s.", first, last);
+ FFAddOneString(ffstring, buf, TRUE, FALSE, TILDE_EXPAND);
+ } else {
+ sprintf (buf, " and consists of sequence %s.", first);
+ FFAddOneString(ffstring, buf, TRUE, FALSE, TILDE_EXPAND);
+ }
+}
+
+
+static CharPtr GetMolInfoCommentString (
+ BioseqPtr bsp,
+ MolInfoPtr mip
+)
+
+{
+ Boolean is_aa;
+ CharPtr str = NULL;
+
+ if (bsp == NULL || mip == NULL) return NULL;
+
+ is_aa = ISA_aa (bsp->mol);
+ switch (mip->completeness) {
+ case 1 :
+ str = "COMPLETENESS: full length";
+ break;
+ case 2 :
+ str = "COMPLETENESS: not full length";
+ break;
+ case 3 :
+ if (is_aa) {
+ str = "COMPLETENESS: incomplete on the amino end";
+ } else {
+ str = "COMPLETENESS: incomplete on the 5' end";
+ }
+ break;
+ case 4 :
+ if (is_aa) {
+ str = "COMPLETENESS: incomplete on the carboxy end";
+ } else {
+ str = "COMPLETENESS: incomplete on the 3' end";
+ }
+ break;
+ case 5 :
+ str = "COMPLETENESS: incomplete on both ends";
+ break;
+ case 6 :
+ if (is_aa) {
+ str = "COMPLETENESS: complete on the amino end";
+ } else {
+ str = "COMPLETENESS: complete on the 5' end";
+ }
+ break;
+ case 7 :
+ if (is_aa) {
+ str = "COMPLETENESS: complete on the carboxy end";
+ } else {
+ str = "COMPLETENESS: complete on the 3' end";
+ }
+ break;
+ default :
+ str = "COMPLETENESS: unknown";
+ break;
+ }
+
+ return str;
+}
+
+static CharPtr GetStrForBankit (
+ UserObjectPtr uop
+)
+
+{
+ CharPtr bic = NULL, uvc = NULL, ptr;
+ ObjectIdPtr oip;
+ UserFieldPtr ufp;
+
+ if (uop == NULL) return NULL;
+ if ((oip = uop->type) == NULL) return NULL;
+ if (StringCmp (oip->str, "Submission") != 0) return NULL;
+
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (StringCmp(oip->str, "UniVecComment") == 0) {
+ uvc = ufp->data.ptrvalue;
+ } else if (StringCmp(oip->str, "AdditionalComment") == 0) {
+ bic = ufp->data.ptrvalue;
+ }
+ }
+
+ if (uvc == NULL && bic == NULL) return NULL;
+
+ ptr = (CharPtr) MemNew (StringLen (uvc) + StringLen (bic) + 45);
+ if (uvc != NULL && bic != NULL) {
+ sprintf (ptr, "Vector Explanation: %s~Bankit Comment: %s", uvc, bic);
+ } else if (uvc != NULL) {
+ sprintf (ptr, "Vector Explanation: %s", uvc);
+ } else if (bic != NULL) {
+ sprintf (ptr, "Bankit Comment: %s", bic);
+ }
+
+ return ptr;
+}
+
+static CharPtr reftxt0 = " The reference sequence was derived from ";
+static CharPtr reftxt1 = " This record is predicted by genome sequence analysis and is not yet supported by experimental evidence.";
+static CharPtr reftxt2 = " This record has not yet been subject to final NCBI review.";
+static CharPtr reftxt3 = " The mRNA record is supported by experimental evidence; however, the coding sequence is predicted.";
+static CharPtr reftxt4 = " This record has undergone preliminary review of the sequence, but has not yet been subject to final review.";
+static CharPtr reftxt5 = " This record has been curated by ";
+static CharPtr reftxt6 = " This record is predicted by automated computational analysis.";
+static CharPtr reftxt7 = " This record is provided to represent a collection of whole genome shotgun sequences.";
+static CharPtr reftxt8 = " This record is derived from an annotated genomic sequence (";
+
+static CharPtr GetStatusForRefTrack (
+ UserObjectPtr uop
+)
+
+{
+ CharPtr st;
+ ObjectIdPtr oip;
+ UserFieldPtr ufp, urf = NULL;
+
+ if (uop == NULL) return NULL;
+ if ((oip = uop->type) == NULL) return NULL;
+ if (StringCmp (oip->str, "RefGeneTracking") != 0) return NULL;
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (StringCmp(oip->str, "Assembly") == 0) {
+ urf = ufp;
+ }
+ }
+ /* if (urf == NULL || urf->choice != 11) return NULL; */
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (StringCmp (oip->str, "Status") == 0) {
+ st = (CharPtr) ufp->data.ptrvalue;
+ if (StringICmp (st, "Inferred") == 0) {
+ return "INFERRED ";
+ } else if (StringICmp (st, "Provisional") == 0) {
+ return "PROVISIONAL ";
+ } else if (StringICmp (st, "Predicted") == 0) {
+ return "PREDICTED ";
+ } else if (StringICmp (st, "Validated") == 0) {
+ return "VALIDATED ";
+ } else if (StringICmp (st, "Reviewed") == 0) {
+ return "REVIEWED ";
+ } else if (StringICmp (st, "Model") == 0) {
+ return "MODEL ";
+ } else if (StringICmp (st, "WGS") == 0) {
+ return "WGS ";
+ }
+ }
+ }
+ return NULL;
+}
+
+
+static void AddStrForRefTrack (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ UserObjectPtr uop
+)
+
+{
+ CharPtr accn, curator = NULL, source = NULL, st;
+ ObjectIdPtr oip;
+ UserFieldPtr ufp, tmp, u, urf = NULL;
+ Int2 i = 0;
+ Int2 review = 0,len;
+ Boolean is_accn;
+
+ if ( uop == NULL || ffstring == NULL ) return;
+ if ((oip = uop->type) == NULL) return;
+ if (StringCmp (oip->str, "RefGeneTracking") != 0) return;
+
+ len = StringLen (reftxt0);
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (StringCmp(oip->str, "Assembly") == 0) {
+ urf = ufp;
+ }
+ if (StringCmp (oip->str, "Status") == 0) {
+ st = (CharPtr) ufp->data.ptrvalue;
+ if (StringICmp (st, "Inferred") == 0) {
+ review = 1;
+ } else if (StringICmp (st, "Provisional") == 0) {
+ review = 2;
+ } else if (StringICmp (st, "Predicted") == 0) {
+ review = 3;
+ } else if (StringICmp (st, "Validated") == 0) {
+ review = 4;
+ } else if (StringICmp (st, "Reviewed") == 0) {
+ review = 5;
+ } else if (StringICmp (st, "Model") == 0) {
+ review = 6;
+ } else if (StringICmp (st, "WGS") == 0) {
+ review = 7;
+ }
+ } else if (StringCmp (oip->str, "Collaborator") == 0) {
+ st = (CharPtr) ufp->data.ptrvalue;
+ if (! StringHasNoText (st)) {
+ curator = st;
+ }
+ } else if (StringCmp (oip->str, "GenomicSource") == 0) {
+ st = (CharPtr) ufp->data.ptrvalue;
+ if (! StringHasNoText (st)) {
+ source = st;
+ }
+ }
+ }
+ if (urf != NULL && urf->choice == 11) {
+ for (tmp = urf->data.ptrvalue; tmp != NULL; tmp = tmp->next) {
+ for (u = tmp->data.ptrvalue; u != NULL; u = u->next) {
+ oip = u->label;
+ if (StringCmp (oip->str, "accession") == 0 ||
+ StringCmp (oip->str, "name") == 0) {
+ i++;
+ }
+ }
+ }
+ }
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString(ffstring, "<a href=", ref_link, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, ":", FALSE, FALSE, TILDE_IGNORE);
+ if (review == 1) {
+ FFAddOneString (ffstring, reftxt1, FALSE, FALSE, TILDE_IGNORE);
+ } else if (review == 2) {
+ FFAddOneString (ffstring, reftxt2, FALSE, FALSE, TILDE_IGNORE);
+ } else if (review == 3) {
+ FFAddOneString (ffstring, reftxt3, FALSE, FALSE, TILDE_IGNORE);
+ } else if (review == 4) {
+ FFAddOneString (ffstring, reftxt4, FALSE, FALSE, TILDE_IGNORE);
+ } else if (review == 5) {
+ if (curator == NULL) {
+ curator = "NCBI staff";
+ }
+ FFAddOneString (ffstring, reftxt5, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, curator, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_IGNORE);
+ } else if (review == 6) {
+ FFAddOneString (ffstring, reftxt6, FALSE, FALSE, TILDE_IGNORE);
+ } else if (review == 7) {
+ FFAddOneString (ffstring, reftxt7, FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (review != 5 && curator != NULL) {
+ FFAddOneString (ffstring, reftxt5, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, curator, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (source != NULL) {
+ FFAddOneString (ffstring, reftxt8, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, source, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, ").", FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (i > 0) {
+ FFAddOneString (ffstring, reftxt0, FALSE, FALSE, TILDE_IGNORE);
+
+ for (tmp = urf->data.ptrvalue; tmp != NULL; tmp = tmp->next) {
+ is_accn = TRUE;
+ for (u = tmp->data.ptrvalue; u != NULL; u = u->next) {
+ oip = u->label;
+ if (StringCmp (oip->str, "accession") == 0) break;
+ if (StringCmp (oip->str, "name") == 0) {
+ is_accn = FALSE;
+ break;
+ }
+ }
+ if (u == NULL) continue;
+ accn = (CharPtr) u->data.ptrvalue;
+ if (StringHasNoText (accn)) continue;
+ if (is_accn && GetWWW(ajp) ) {
+ FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "val=", accn, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, accn, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, accn, FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (tmp->next != NULL) {
+ ufp = tmp->next;
+ if (ufp->next != NULL) {
+ FFAddOneString (ffstring, ", ", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, " and ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+ FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_EXPAND);
+ }
+}
+
+static CharPtr GetGenomeBuildNumber (
+ UserObjectPtr uop
+)
+
+{
+ ObjectIdPtr oip;
+ CharPtr str;
+ UserFieldPtr ufp;
+
+ if (uop == NULL) return NULL;
+ if ((oip = uop->type) == NULL) return NULL;
+ if (StringCmp (oip->str, "GenomeBuild") != 0) return NULL;
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (StringCmp(oip->str, "NcbiAnnotation") == 0) {
+ if (ufp->choice == 1) { /* string */
+ str = ufp->data.ptrvalue;
+ if (! StringHasNoText (str)) return str;
+ }
+ } else if (StringCmp (oip->str, "Annotation") == 0) {
+ if (ufp->choice == 1) { /* string */
+ str = ufp->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ if (StringNICmp (str, "NCBI build ", 11) == 0) {
+ if (! StringHasNoText (str + 11)) {
+ return (str + 11);
+ }
+ }
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+static CharPtr GetGenomeVersionNumber (
+ UserObjectPtr uop
+)
+
+{
+ ObjectIdPtr oip;
+ CharPtr str;
+ UserFieldPtr ufp;
+
+ if (uop == NULL) return NULL;
+ if ((oip = uop->type) == NULL) return NULL;
+ if (StringCmp (oip->str, "GenomeBuild") != 0) return NULL;
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (StringCmp(oip->str, "NcbiVersion") == 0) {
+ if (ufp->choice == 1) { /* string */
+ str = ufp->data.ptrvalue;
+ if (! StringHasNoText (str)) return str;
+ }
+ }
+ }
+ return NULL;
+}
+
+
+static CharPtr reftxt11 = "This record is predicted by automated computational analysis. This record is derived from an annotated genomic sequence";
+static CharPtr reftxt12 = "using gene prediction method:";
+
+static void FindModelEvidenceUop (
+ UserObjectPtr uop,
+ Pointer userdata
+)
+
+{
+ ObjectIdPtr oip;
+ UserObjectPtr PNTR uopp;
+
+ if (uop == NULL || userdata == NULL) return;
+ uopp = (UserObjectPtr PNTR) userdata;
+ oip = uop->type;
+ if (oip == NULL) return;
+ if (StringCmp (oip->str, "ModelEvidence") == 0) {
+ *uopp = uop;
+ }
+}
+
+static Boolean DoGetAnnotationComment (
+ BioseqPtr bsp,
+ CharPtr PNTR namep,
+ CharPtr PNTR methodp,
+ BoolPtr mrnaEv,
+ BoolPtr estEv
+)
+
+{
+ SeqMgrDescContext dcontext;
+ CharPtr method = NULL;
+ UserObjectPtr moduop;
+ CharPtr name = NULL;
+ ObjectIdPtr oip;
+ SeqDescrPtr sdp;
+ UserFieldPtr ufp;
+ UserObjectPtr uop;
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL) {
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop != NULL) {
+ moduop = NULL;
+ VisitUserObjectsInUop (uop, (Pointer) &moduop, FindModelEvidenceUop);
+ if (moduop != NULL) {
+ oip = moduop->type;
+ if (oip != NULL && StringCmp(oip->str, "ModelEvidence") == 0) {
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (oip == NULL) continue;
+ if (StringCmp(oip->str, "Contig Name") == 0) {
+ name = (CharPtr) ufp->data.ptrvalue;
+ } else if (StringCmp(oip->str, "Method") == 0) {
+ method = (CharPtr) ufp->data.ptrvalue;
+ } else if (StringCmp(oip->str, "mRNA") == 0) {
+ *mrnaEv = TRUE;
+ } else if (StringCmp(oip->str, "EST") == 0) {
+ *estEv = TRUE;
+ }
+ }
+ }
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
+ }
+ if (StringHasNoText (name)) return FALSE;
+ *namep = name;
+ if (! StringHasNoText (method)) {
+ *methodp = method;
+ }
+ return TRUE;
+}
+
+static Boolean GetAnnotationComment (
+ BioseqPtr bsp,
+ CharPtr PNTR namep,
+ CharPtr PNTR methodp,
+ BoolPtr mrnaEv,
+ BoolPtr estEv
+)
+
+{
+ SeqFeatPtr cds;
+
+ if (DoGetAnnotationComment (bsp, namep, methodp, mrnaEv, estEv)) return TRUE;
+ if (ISA_aa (bsp->mol)) {
+ cds = SeqMgrGetCDSgivenProduct (bsp, NULL);
+ if (cds != NULL) {
+ bsp = BioseqFindFromSeqLoc (cds->location);
+ if (bsp != NULL) {
+ return DoGetAnnotationComment (bsp, namep, methodp, mrnaEv, estEv);
+ }
+ }
+ }
+ return FALSE;
+}
+
+static void FindGeneFeat (
+ SeqFeatPtr sfp,
+ Pointer userdata
+)
+
+{
+ SeqFeatPtr PNTR sfpp;
+
+ if (sfp->data.choice != SEQFEAT_GENE) return;
+ sfpp = (SeqFeatPtr PNTR) userdata;
+ *sfpp = sfp;
+}
+
+static void FindLocusId (
+ ValNodePtr dbxref,
+ CharPtr locusIDp
+)
+
+{
+ DbtagPtr dbt;
+ ObjectIdPtr oip;
+ ValNodePtr vnp;
+
+ for (vnp = dbxref; vnp != NULL; vnp = vnp->next) {
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt == NULL) continue;
+ if (StringICmp (dbt->db, "LocusID") != 0 && StringICmp (dbt->db, "InterimID") != 0) continue;
+ oip = dbt->tag;
+ if (oip == NULL) continue;
+ if (oip->str != NULL) {
+ StringCpy (locusIDp, oip->str);
+ } else if (oip->id > 0) {
+ sprintf (locusIDp, "%ld", (long) oip->id);
+ }
+ }
+}
+
+static Boolean GetGeneAndLocus (
+ BioseqPtr bsp,
+ CharPtr PNTR genep,
+ CharPtr locusIDp,
+ CharPtr taxIDp
+)
+
+{
+ BioSourcePtr biop;
+ DbtagPtr dbt;
+ SeqMgrDescContext dcontext;
+ SeqFeatPtr gene = NULL;
+ GeneRefPtr grp;
+ ObjectIdPtr oip;
+ OrgRefPtr orp;
+ SeqDescrPtr sdp;
+ SeqEntryPtr sep;
+ CharPtr str;
+ ValNodePtr syn;
+ ValNodePtr vnp;
+
+ sep = GetTopSeqEntryForEntityID (bsp->idx.entityID);
+ if (sep == NULL) return FALSE;
+ VisitFeaturesInSep (sep, (Pointer) &gene, FindGeneFeat);
+ if (gene == NULL) return FALSE;
+
+ grp = (GeneRefPtr) gene->data.value.ptrvalue;
+ if (grp == NULL) return FALSE;
+ if (! StringHasNoText (grp->locus)) {
+ *genep = grp->locus;
+ } else {
+ syn = grp->syn;
+ if (syn != NULL) {
+ str = (CharPtr) syn->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ *genep = str;
+ }
+ }
+ }
+ FindLocusId (gene->dbxref, locusIDp);
+ FindLocusId (grp->db, locusIDp);
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ if (biop != NULL) {
+ orp = biop->org;
+ if (orp != NULL) {
+ for (vnp = orp->db; vnp != NULL; vnp = vnp->next) {
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt == NULL) continue;
+ if (StringCmp (dbt->db, "taxon") == 0) {
+ oip = dbt->tag;
+ if (oip == NULL) continue;
+ if (oip->str != NULL) {
+ StringCpy (taxIDp, oip->str);
+ } else if (oip->id > 0) {
+ sprintf (taxIDp, "%ld", (long) oip->id);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (genep == NULL || StringHasNoText (locusIDp)) return FALSE;
+
+ return TRUE;
+}
+
+static CharPtr reftxt21 = "NCBI contigs are derived from assembled genomic sequence data.";
+
+static CharPtr reftxt22 = "Features on this sequence have been produced for build ";
+static CharPtr reftxt23 = " of the NCBI's genome annotation";
+
+static CharPtr nsAreGapsString = "The strings of n's in this record represent gaps between contigs, and the length of each string corresponds to the length of the gap.";
+
+static Boolean IsTpa (
+ BioseqPtr bsp,
+ Boolean has_tpa_assembly,
+ BoolPtr isRefSeqP
+)
+
+{
+ DbtagPtr dbt;
+ Boolean has_bankit = FALSE;
+ Boolean has_genbank = FALSE;
+ Boolean has_gi = FALSE;
+ Boolean has_local = FALSE;
+ Boolean has_refseq = FALSE;
+ Boolean has_smart = FALSE;
+ Boolean has_tpa = FALSE;
+ SeqIdPtr sip;
+
+ if (bsp == NULL || bsp->id == NULL) return FALSE;
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ switch (sip->choice) {
+ case SEQID_LOCAL :
+ has_local = TRUE;
+ break;
+ case SEQID_GENBANK :
+ case SEQID_EMBL :
+ case SEQID_DDBJ :
+ has_genbank = TRUE;
+ break;
+ case SEQID_OTHER :
+ has_refseq = TRUE;
+ if (isRefSeqP != NULL) {
+ *isRefSeqP = TRUE;
+ }
+ break;
+ case SEQID_GI :
+ has_gi = TRUE;
+ break;
+ case SEQID_TPG :
+ case SEQID_TPE :
+ case SEQID_TPD :
+ has_tpa = TRUE;
+ break;
+ case SEQID_GENERAL :
+ dbt = (DbtagPtr) sip->data.ptrvalue;
+ if (dbt != NULL) {
+ if (StringICmp (dbt->db, "BankIt") == 0) {
+ has_bankit = TRUE;
+ }
+ if (StringICmp (dbt->db, "TMSMART") == 0) {
+ has_smart = TRUE;
+ }
+ }
+ break;
+ default :
+ break;
+ }
+ }
+
+ if (has_genbank) return FALSE;
+ if (has_tpa) return TRUE;
+ if (has_refseq) return FALSE;
+ if (has_bankit && has_tpa_assembly) return TRUE;
+ if (has_smart && has_tpa_assembly) return TRUE;
+ if (has_gi) return FALSE;
+ if (has_local && has_tpa_assembly) return TRUE;
+
+ return FALSE;
+}
+
+static Boolean GetAccnVerFromServer (Int4 gi, CharPtr buf)
+
+{
+ AccnVerLookupFunc func;
+ SeqMgrPtr smp;
+ CharPtr str;
+
+ if (buf == NULL) return FALSE;
+ *buf = '\0';
+ smp = SeqMgrWriteLock ();
+ if (smp == NULL) return FALSE;
+ func = smp->accn_ver_lookup_func;
+ SeqMgrUnlock ();
+ if (func == NULL) return FALSE;
+ str = (*func) (gi);
+ if (str == NULL) return FALSE;
+ if (StringLen (str) < 40) {
+ StringCpy (buf, str);
+ }
+ MemFree (str);
+ return TRUE;
+}
+
+static CharPtr GetStrForTpaOrRefSeqHist (
+ BioseqPtr bsp
+)
+
+{
+ Boolean accn;
+ Char buf [64];
+ DbtagPtr dbt;
+ Int4 gi;
+ ValNodePtr head = NULL;
+ SeqHistPtr hist;
+ SeqIdPtr id;
+ Boolean isRefSeq = FALSE;
+ Boolean minus1;
+ Boolean minus2;
+ SeqAlignPtr salp;
+ SeqAlignPtr salptmp;
+ SeqIdPtr sip;
+ Int4 start;
+ Int4 stop;
+ CharPtr str;
+ Char tmp [80];
+
+ hist = bsp->hist;
+ if (hist != NULL && hist->assembly != NULL) {
+ salp = SeqAlignListDup (hist->assembly);
+ AlnMgr2IndexLite (salp);
+ AlnMgr2SortAlnSetByNthRowPos (salp, 1);
+ salptmp = (SeqAlignPtr) (salp->segs);
+ while (salptmp != NULL) {
+ AlnMgr2GetNthSeqRangeInSA (salptmp, 1, &start, &stop);
+ sip = AlnMgr2GetNthSeqIdPtr (salptmp, 2);
+ if (sip != NULL) {
+ id = NULL;
+ accn = FALSE;
+ if (sip->choice == SEQID_GI) {
+ gi = (Int4) sip->data.intvalue;
+ if (GetAccnVerFromServer (gi, buf)) {
+ accn = TRUE;
+ } else {
+ id = GetSeqIdForGI (gi);
+ }
+ } else {
+ id = SeqIdDup (sip);
+ }
+ if (id != NULL || accn) {
+ if (head == NULL) {
+ if (isRefSeq) {
+ ValNodeCopyStr (&head, 0, "REFSEQ_SPAN PRIMARY_IDENTIFIER PRIMARY_SPAN COMP");
+ } else {
+ ValNodeCopyStr (&head, 0, "TPA_SPAN PRIMARY_IDENTIFIER PRIMARY_SPAN COMP");
+ }
+ }
+ if (id != NULL) {
+ SeqIdWrite (id, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
+ if (id->choice == SEQID_GENERAL) {
+ dbt = (DbtagPtr) id->data.ptrvalue;
+ if (dbt != NULL && StringICmp (dbt->db, "ti") == 0) {
+ StringCpy (buf, "TI");
+ SeqIdWrite (id, buf + 2, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 3);
+ }
+ }
+ }
+ sprintf (tmp, "~%ld-%ld ",
+ (long) (start + 1), (long) (stop + 1));
+ /*
+ i = 39 - StringLen (buf);
+ if (i > 0) {
+ tmp [i] = '\0';
+ } else {
+ tmp [21] = '\0';
+ }
+ */
+ tmp [21] = '\0';
+ StringCat (buf, " ");
+ buf [18] = '\0';
+ StringCat (tmp, buf);
+ AlnMgr2GetNthSeqRangeInSA (salptmp, 2, &start, &stop);
+ sprintf (buf, " %ld-%ld ",
+ (long) (start + 1), (long) (stop + 1));
+ buf [21] = '\0';
+ StringCat (tmp, buf);
+ minus1 = (Boolean) (AlnMgr2GetNthStrand (salptmp, 1) == Seq_strand_minus);
+ minus2 = (Boolean) (AlnMgr2GetNthStrand (salptmp, 2) == Seq_strand_minus);
+ if (minus1 || minus2) {
+ if (! (minus1 && minus2)) {
+ StringCat (tmp, "c");
+ }
+ }
+ ValNodeCopyStr (&head, 0, tmp);
+ }
+ SeqIdFree (id);
+ }
+ SeqIdFree (sip);
+ salptmp = salptmp->next;
+ }
+ SeqAlignFree (salp);
+ }
+
+ if (head == NULL) return NULL;
+
+ str = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ return str;
+}
+
+static CharPtr tpaString = "THIRD PARTY ANNOTATION DATABASE: This TPA record uses data from DDBJ/EMBL/GenBank ";
+
+static CharPtr GetStrForTPA (
+ UserObjectPtr uop,
+ BioseqPtr bsp
+)
+
+{
+ Char ch;
+ UserFieldPtr curr;
+ SeqHistPtr hist;
+ Int2 i;
+ Char id [41];
+ Boolean isRefSeq = FALSE;
+ Int2 j;
+ size_t len;
+ ObjectIdPtr oip;
+ CharPtr ptr;
+ CharPtr str;
+ CharPtr tmp;
+ UserFieldPtr ufp;
+
+ if (uop == NULL) return NULL;
+ if ((oip = uop->type) == NULL) return NULL;
+ if (StringCmp (oip->str, "TpaAssembly") != 0) return NULL;
+ if (bsp == NULL) return NULL;
+ hist = bsp->hist;
+ if (hist != NULL && hist->assembly != NULL) return NULL;
+ if (! IsTpa (bsp, TRUE, &isRefSeq)) return NULL;
+ if (isRefSeq) return NULL;
+
+ len = StringLen (tpaString) + StringLen ("entries ") + StringLen ("and ") + 5;
+ i = 0;
+ for (curr = uop->data; curr != NULL; curr = curr->next) {
+ if (curr->choice != 11) continue;
+ for (ufp = curr->data.ptrvalue; ufp != NULL; ufp = ufp->next) {
+ if (ufp->choice != 1) continue;
+ oip = ufp->label;
+ if (oip == NULL || StringICmp (oip->str, "accession") != 0) continue;
+ str = (CharPtr) ufp->data.ptrvalue;
+ if (StringHasNoText (str)) continue;
+ len += StringLen (str) + 2;
+ i++;
+ }
+ }
+ if (i == 0) return NULL;
+
+ ptr = (CharPtr) MemNew (len);
+ if (ptr == NULL) return NULL;
+ StringCpy (ptr, tpaString);
+ if (i > 1) {
+ StringCat (ptr, "entries ");
+ } else {
+ StringCat (ptr, "entry ");
+ }
+
+ j = 0;
+ for (curr = uop->data; curr != NULL; curr = curr->next) {
+ if (curr->choice != 11) continue;
+ for (ufp = curr->data.ptrvalue; ufp != NULL; ufp = ufp->next) {
+ if (ufp->choice != 1) continue;
+ oip = ufp->label;
+ if (oip == NULL || StringICmp (oip->str, "accession") != 0) continue;
+ str = (CharPtr) ufp->data.ptrvalue;
+ if (StringHasNoText (str)) continue;
+ StringNCpy_0 (id, str, sizeof (id));
+ tmp = id;
+ ch = *tmp;
+ while (ch != '\0') {
+ if (IS_LOWER (ch)) {
+ *tmp = TO_UPPER (ch);
+ }
+ tmp++;
+ ch = *tmp;
+ }
+ if (j == i - 1 && i > 1) {
+ StringCat (ptr, " and ");
+ } else if (j > 0) {
+ StringCat (ptr, ", ");
+ }
+ StringCat (ptr, id);
+ j++;
+ }
+ }
+
+ return ptr;
+}
+
+static CharPtr GetStrForGenome (
+ UserObjectPtr uop,
+ BioseqPtr bsp
+)
+
+{
+ ObjectIdPtr oip;
+
+ if (uop == NULL) return NULL;
+ if ((oip = uop->type) == NULL) return NULL;
+ if (StringCmp (oip->str, "GenomeInfo") != 0) return NULL;
+
+ /* !!! need to implement !!! */
+
+ return NULL;
+}
+
+NLM_EXTERN void AddPrimaryBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp = NULL;
+ BioseqPtr bsp;
+ SeqMgrDescContext dcontext;
+ GBSeqPtr gbseq;
+ Boolean has_tpa_assembly = FALSE;
+ SeqHistPtr hist;
+ Boolean isRefSeq = FALSE;
+ ObjectIdPtr oip;
+ SeqDescrPtr sdp;
+ CharPtr str;
+ UserObjectPtr uop;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL) {
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop != NULL) {
+ oip = uop->type;
+ if (oip != NULL) {
+ if (StringCmp (oip->str, "TpaAssembly") == 0) {
+ has_tpa_assembly = TRUE;
+ }
+ }
+ }
+ if (has_tpa_assembly) {
+ sdp = NULL;
+ } else {
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
+ }
+ }
+
+ if (! IsTpa (bsp, has_tpa_assembly, &isRefSeq)) return;
+ hist = bsp->hist;
+ if (hist == NULL || hist->assembly == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ str = GetStrForTpaOrRefSeqHist (bsp);
+ if (str != NULL) {
+
+ bbp = (BaseBlockPtr) Asn2gbAddBlock (awp, PRIMARY_BLOCK, sizeof (BaseBlock));
+ if (bbp != NULL) {
+
+ if (has_tpa_assembly) {
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+ }
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "PRIMARY", 12, 5, 5, "PR", TRUE);
+
+ FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "PR");
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ gbseq->primary = StringSave (str);
+ }
+ }
+ MemFree (str);
+ }
+
+ FFRecycleString(ajp, ffstring);
+}
+
+static CharPtr reftxt32 = "It is defined by coordinates on the sequence of chromosome";
+static CharPtr reftxt33 = "from the";
+static CharPtr reftxt34 = "assembly of the human genome (NCBI build";
+static CharPtr reftxt35 = ").";
+
+static CharPtr GetEncodeString (
+ UserObjectPtr uop,
+ BioseqPtr bsp
+)
+
+{
+ CharPtr assembly_date = NULL;
+ BioSourcePtr biop;
+ CharPtr chromosome = NULL;
+ SeqMgrDescContext dcontext;
+ size_t len;
+ CharPtr ncbi_annotation = NULL;
+ ObjectIdPtr oip;
+ SeqDescrPtr sdp;
+ SubSourcePtr ssp;
+ CharPtr str;
+ UserFieldPtr ufp;
+
+ if (uop == NULL || bsp == NULL) return NULL;
+
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (oip == NULL || oip->str == NULL || ufp->choice != 1) continue;
+ if (StringICmp (oip->str, "AssemblyDate") == 0) {
+ assembly_date = (CharPtr) ufp->data.ptrvalue;
+ } else if (StringICmp (oip->str, "NcbiAnnotation") == 0) {
+ ncbi_annotation = (CharPtr) ufp->data.ptrvalue;
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
+ if (sdp != NULL) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ if (biop != NULL) {
+ for (ssp = biop->subtype; ssp != NULL; ssp = ssp->next) {
+ if (ssp->subtype == SUBSRC_chromosome) {
+ chromosome = ssp->name;
+ }
+ }
+ }
+ }
+
+ if (StringHasNoText (chromosome)) {
+ chromosome = "?";
+ }
+ if (StringHasNoText (assembly_date)) {
+ assembly_date = "?";
+ }
+ if (StringHasNoText (ncbi_annotation)) {
+ ncbi_annotation = "?";
+ }
+
+ len = StringLen (reftxt32) + StringLen (reftxt33) +
+ StringLen (reftxt34) + StringLen (reftxt35) +
+ StringLen (chromosome) +
+ StringLen (assembly_date) +
+ StringLen (ncbi_annotation);
+
+ str = (CharPtr) MemNew (sizeof (Char) * (len + 10));
+ if (str == NULL) return NULL;
+
+ sprintf (str, "%s %s %s %s %s %s%s", reftxt32, chromosome, reftxt33,
+ assembly_date, reftxt34, ncbi_annotation, reftxt35);
+
+ return str;
+}
+
+static void GetAnnotComments (
+ SeqAnnotPtr sap,
+ Pointer userdata
+)
+
+{
+ AnnotDescrPtr desc;
+ ValNodePtr PNTR head;
+ CharPtr str;
+
+ head = (ValNodePtr PNTR) userdata;
+ if (sap == NULL || head == NULL) return;
+
+ for (desc = sap->desc; desc != NULL; desc = desc->next) {
+ str = NULL;
+ if (desc->choice == Annot_descr_comment) {
+ str = (CharPtr) desc->data.ptrvalue;
+ }
+ if (StringHasNoText (str)) continue;
+ ValNodeCopyStr (head, 0, str);
+ }
+}
+
+NLM_EXTERN void AddCommentBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ size_t acclen;
+ IntAsn2gbJobPtr ajp;
+ BioseqPtr bsp;
+ Char buf [128];
+ CommentBlockPtr cbp = NULL;
+ Char ch;
+ Boolean didGenome = FALSE;
+ Boolean didRefTrack = FALSE;
+ Boolean didTPA = FALSE;
+ DbtagPtr dbt;
+ SeqMgrDescContext dcontext;
+ DeltaSeqPtr dsp;
+ Boolean estEv = FALSE;
+ SeqMgrFeatContext fcontext;
+ Boolean first = TRUE;
+ GBBlockPtr gbp;
+ CharPtr geneName = NULL;
+ CharPtr genomeBuildNumber = NULL;
+ CharPtr genomeVersionNumber = NULL;
+ Int4 gi = 0;
+ CommentBlockPtr gsdbcbp = NULL;
+ Int4 gsdbid = 0;
+ Boolean has_gaps = FALSE;
+ Boolean hasRefTrackStatus = FALSE;
+ ValNodePtr head;
+ SeqHistPtr hist;
+ Boolean is_collab = FALSE;
+ Boolean is_encode = FALSE;
+ Boolean is_other = FALSE;
+ Boolean is_tpa = FALSE;
+ Boolean is_wgs = FALSE;
+ SeqLitPtr litp;
+ ObjectIdPtr localID = NULL;
+ Char locusID [32];
+ CharPtr method = NULL;
+ MolInfoPtr mip;
+ Boolean mrnaEv = FALSE;
+ CharPtr name = NULL;
+ ObjectIdPtr oip;
+ Boolean okay;
+ BioseqPtr parent;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+ Boolean showGBBSource = FALSE;
+ SeqIdPtr sip;
+ CharPtr str;
+ Char taxID [32];
+ TextSeqIdPtr tsip;
+ UserObjectPtr uop;
+ ValNodePtr vnp;
+ CharPtr wgsaccn = NULL;
+ CharPtr wgsname = NULL;
+ StringItemPtr ffstring = NULL;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL) {
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop != NULL) {
+ str = GetStatusForRefTrack (uop);
+ if (str != NULL) {
+ hasRefTrackStatus = TRUE;
+ }
+ if (genomeBuildNumber == NULL) {
+ genomeBuildNumber = GetGenomeBuildNumber (uop);
+ }
+ if (genomeVersionNumber == NULL) {
+ genomeVersionNumber = GetGenomeVersionNumber (uop);
+ }
+ oip = uop->type;
+ if (oip != NULL && StringICmp (oip->str, "ENCODE") == 0) {
+ is_encode = TRUE;
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
+ }
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_OTHER) {
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+
+ if (tsip != NULL) {
+ is_other = TRUE;
+ if (StringNCmp (tsip->accession, "NC_", 3) == 0) {
+ if (! StringHasNoText (genomeBuildNumber)) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, "GENOME ANNOTATION ", FALSE, FALSE, TILDE_IGNORE);
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", ref_link, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, ": ", FALSE, FALSE, TILDE_IGNORE);
+
+ FFAddOneString (ffstring, reftxt22, FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, genomeBuildNumber, FALSE, FALSE, TILDE_EXPAND);
+ if (StringHasNoText (genomeVersionNumber)) {
+ genomeVersionNumber = "1";
+ }
+ FFAddOneString (ffstring, " version ", FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, genomeVersionNumber, FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, reftxt23, FALSE, FALSE, TILDE_EXPAND);
+
+ FFAddOneString (ffstring, " [see ", FALSE, FALSE, TILDE_EXPAND);
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", doc_link, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, "documentation", FALSE, FALSE, TILDE_IGNORE);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ FFAddOneString (ffstring, "].", FALSE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+
+ } else if (StringNCmp(tsip->accession, "NT_", 3) == 0 || StringNCmp(tsip->accession, "NW_", 3) == 0) {
+
+ if (is_encode) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, ": ", FALSE, FALSE, TILDE_IGNORE);
+
+ FFAddOneString (ffstring, "This record was provided by the ", FALSE, FALSE, TILDE_EXPAND);
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", link_encode, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, "ENCODE", FALSE, FALSE, TILDE_EXPAND);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, " project.", FALSE, FALSE, TILDE_EXPAND);
+
+ str = GetEncodeString (uop, bsp);
+ if (str != NULL) {
+ FFAddOneString (ffstring, " ", FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
+ }
+ MemFree (str);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+
+ } else if (! hasRefTrackStatus) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, "GENOME ANNOTATION ", FALSE, FALSE, TILDE_IGNORE);
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", ref_link, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, ": ", FALSE, FALSE, TILDE_IGNORE);
+
+ if (! StringHasNoText (genomeBuildNumber)) {
+ FFAddOneString (ffstring, reftxt22, FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, genomeBuildNumber, FALSE, FALSE, TILDE_EXPAND);
+ if (StringHasNoText (genomeVersionNumber)) {
+ genomeVersionNumber = "1";
+ }
+ FFAddOneString (ffstring, " version ", FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, genomeVersionNumber, FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, reftxt23, FALSE, FALSE, TILDE_EXPAND);
+
+ FFAddOneString (ffstring, " [see ", FALSE, FALSE, TILDE_EXPAND);
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", doc_link, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, "documentation", FALSE, FALSE, TILDE_IGNORE);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ FFAddOneString (ffstring, "].", FALSE, FALSE, TILDE_EXPAND);
+ } else {
+
+ FFAddOneString (ffstring, reftxt21, TRUE, FALSE, TILDE_EXPAND);
+
+ FFAddOneString (ffstring, "~Also see:~ ", FALSE, FALSE, TILDE_EXPAND);
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", doc_link, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, "Documentation", FALSE, FALSE, TILDE_IGNORE);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ FFAddOneString (ffstring, " of NCBI's Annotation Process~ ", FALSE, FALSE, TILDE_EXPAND);
+ }
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+
+ } else if (StringNCmp(tsip->accession, "XP_", 3) == 0 ||
+ StringNCmp(tsip->accession, "XM_", 3) == 0 ||
+ StringNCmp(tsip->accession, "XR_", 3) == 0 ||
+ StringNCmp(tsip->accession, "ZP_", 3) == 0) {
+
+ name = NULL;
+ method = NULL;
+ mrnaEv = FALSE;
+ estEv = FALSE;
+ if (GetAnnotationComment (bsp, &name, &method, &mrnaEv, &estEv)) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, "MODEL ", FALSE, FALSE, TILDE_IGNORE);
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", ref_link, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, "REFSEQ", FALSE, FALSE, TILDE_IGNORE);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, ": ", FALSE, FALSE, TILDE_IGNORE);
+
+ FFAddTextToString (ffstring, NULL, reftxt11, " (", FALSE, FALSE, TILDE_IGNORE);
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", nt_link, name, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, name, FALSE, FALSE, TILDE_IGNORE);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ FFAddOneString (ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
+
+ if (method != NULL) {
+ FFAddOneString (ffstring, " ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, reftxt12, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, " ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, method, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ if (mrnaEv || estEv) {
+ FFAddOneString (ffstring, ", supported by ", FALSE, FALSE, TILDE_IGNORE);
+ if (mrnaEv && estEv) {
+ FFAddOneString (ffstring, "mRNA and EST ", FALSE, FALSE, TILDE_IGNORE);
+ } else if (mrnaEv) {
+ FFAddOneString (ffstring, "mRNA ", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, "EST ", FALSE, FALSE, TILDE_IGNORE);
+ }
+ geneName = NULL;
+ locusID [0] = '\0';
+ taxID [0] = '\0';
+ if ( GetWWW(ajp) && GetGeneAndLocus (bsp, &geneName, locusID, taxID)) {
+ FFAddTextToString (ffstring, "<a href=", ev_link, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString (ffstring, "contig=", name, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString (ffstring, "&gene=", geneName, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString (ffstring, "&lid=", locusID, NULL, FALSE, FALSE, TILDE_IGNORE);
+ if (! StringHasNoText (taxID)) {
+ FFAddTextToString (ffstring, "&taxid=", taxID, NULL, FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, "evidence", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString (ffstring, "evidence", FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+
+ FFAddOneString (ffstring, ".", FALSE, FALSE, TILDE_IGNORE);
+
+ FFAddOneString (ffstring, "~Also see:~ ", FALSE, FALSE, TILDE_EXPAND);
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString (ffstring, "<a href=", doc_link, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString (ffstring, "Documentation", FALSE, FALSE, TILDE_IGNORE);
+ if ( GetWWW(ajp) ) {
+ FFAddOneString (ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ FFAddOneString (ffstring, " of NCBI's Annotation Process~ ", FALSE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ } else {
+ if (StringLen (tsip->accession) == 15) {
+ is_wgs = TRUE;
+ if (StringCmp (tsip->accession + 9, "000000") == 0) {
+ wgsaccn = tsip->accession;
+ wgsname = tsip->name; /* master accession has 8 zeroes, name has project version plus 6 zeroes */
+ }
+ }
+ }
+ }
+
+ } else if (sip->choice == SEQID_TPG || sip->choice == SEQID_TPE || sip->choice == SEQID_TPD) {
+
+ is_tpa = TRUE;
+
+ } else if (sip->choice == SEQID_GENBANK || sip->choice == SEQID_EMBL || sip->choice == SEQID_DDBJ) {
+
+ is_collab = TRUE;
+
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL && tsip->accession != NULL) {
+ acclen = StringLen (tsip->accession);
+ if (acclen == 12) {
+ is_wgs = TRUE;
+ if (StringCmp (tsip->accession + 6, "000000") == 0) {
+ wgsaccn = tsip->accession;
+ wgsname = tsip->name; /* master accession has 8 zeroes, name has project version plus 6 zeroes */
+ }
+ } else if (acclen == 13) {
+ is_wgs = TRUE;
+ if (StringCmp (tsip->accession + 6, "0000000") == 0) {
+ wgsaccn = tsip->accession;
+ wgsname = tsip->name; /* master accession has 9 zeroes, name has project version plus 7 zeroes */
+ }
+ } else if (ajp->newSourceOrg && StringLen (tsip->accession) == 6) {
+ ch = tsip->accession [0];
+ if (ch == 'J' || ch == 'K' || ch == 'L' || ch == 'M') {
+ showGBBSource = TRUE;
+ }
+ }
+ }
+
+ } else if (sip->choice == SEQID_GENERAL) {
+ dbt = (DbtagPtr) sip->data.ptrvalue;
+
+ /* show GSDB sequence identifier */
+
+ if (dbt != NULL && StringCmp (dbt->db, "GSDB") == 0 && dbt->tag != NULL) {
+ gsdbcbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (gsdbcbp != NULL) {
+ gsdbcbp->first = first;
+
+ /* string will be created after we know if there are additional comments */
+
+ gsdbid = dbt->tag->id;
+ first = FALSE;
+ }
+ }
+
+ } else if (sip->choice == SEQID_GI) {
+ gi = (Int4) sip->data.intvalue;
+
+ } else if (sip->choice == SEQID_LOCAL) {
+ localID = (ObjectIdPtr) sip->data.ptrvalue;
+ }
+ }
+
+ if (localID != NULL) {
+ if (is_tpa || is_collab) {
+ if (awp->mode == SEQUIN_MODE || awp->mode == DUMP_MODE) {
+ buf [0] = '\0';
+ if (! StringHasNoText (localID->str)) {
+ if (StringLen (localID->str) < 100) {
+ sprintf (buf, "LocalID: %s", localID->str);
+ } else {
+ sprintf (buf, "LocalID string too large");
+ }
+ } else {
+ sprintf (buf, "LocalID: %ld", (long) localID->id);
+ }
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12,5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ }
+ }
+
+ /* RefSeq results in allocated comment string */
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL) {
+
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop != NULL) {
+
+ if (! didTPA) {
+ str = GetStrForTPA (uop, bsp);
+ if (str != NULL) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12,5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ MemFree (str);
+ didTPA = TRUE;
+ }
+ }
+
+ if (! ajp->flags.hideBankItComment) {
+ str = GetStrForBankit (uop);
+ if (str != NULL) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, str, TRUE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12,5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ MemFree (str);
+ }
+ }
+
+ if (! didRefTrack) {
+ str = GetStatusForRefTrack (uop);
+ if (str != NULL) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
+
+ AddStrForRefTrack (ajp, ffstring, uop);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12,5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ /* do not free static str from GetStatusForRefTrack */
+ didRefTrack = TRUE;
+ }
+ }
+
+ if (! didGenome) {
+ str = GetStrForGenome (uop, bsp);
+ if (str != NULL) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ MemFree (str);
+ didGenome = TRUE;
+ }
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
+ }
+
+ if (bsp->repr == Seq_repr_delta && bsp->seq_ext_type == 4 && is_wgs) {
+ has_gaps = FALSE;
+ for (dsp = (DeltaSeqPtr) bsp->seq_ext; dsp; dsp=dsp->next) {
+ if (dsp->choice == 2) {
+ litp = (SeqLitPtr) dsp->data.ptrvalue;
+ if (litp != NULL) {
+ if (litp->seq_data == NULL && litp->length > 0) {
+ has_gaps = TRUE;
+ }
+ }
+ }
+ }
+ if (has_gaps) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, nsAreGapsString, TRUE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ }
+
+ /* Seq-hist results in allocated comment string */
+
+ hist = bsp->hist;
+ if (hist != NULL) {
+
+ if (hist->replaced_by_ids != NULL && hist->replaced_by_date != NULL) {
+
+ okay = TRUE;
+ for (sip = hist->replaced_by_ids; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GI) {
+ if (gi == (Int4) sip->data.intvalue) {
+ okay = FALSE;
+ }
+ }
+ }
+
+ if (okay) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ AddHistCommentString (ajp, ffstring, "[WARNING] On", "this sequence was replaced by a newer version",
+ hist->replaced_by_date, hist->replaced_by_ids);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ }
+
+ if (hist->replace_ids != NULL && hist->replace_date != NULL && awp->mode != SEQUIN_MODE) {
+
+ okay = TRUE;
+ for (sip = hist->replace_ids; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GI) {
+ if (gi == (Int4) sip->data.intvalue) {
+ okay = FALSE;
+ }
+ }
+ }
+
+ if (okay) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ AddHistCommentString (ajp, ffstring, "On", "this sequence version replaced",
+ hist->replace_date, hist->replace_ids);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ }
+
+ }
+
+ /* just save IDs for comment, maploc, and region descriptors */
+
+ /*
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_comment, &dcontext);
+ while (sdp != NULL) {
+ if (sdp->data.ptrvalue != NULL) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_comment, &dcontext);
+ }
+ */
+
+ /* WGS master comment goes before comment descriptors */
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp != NULL) {
+
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip != NULL) {
+ if (mip->tech == MI_TECH_wgs) {
+
+ if (wgsname != NULL) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ /*
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ */
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ AddWGSMasterCommentString (ffstring,bsp, wgsaccn, wgsname);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ }
+ }
+ }
+
+ if (showGBBSource) {
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_genbank, &dcontext);
+ if (sdp != NULL) {
+ gbp = (GBBlockPtr) sdp->data.ptrvalue;
+ if (gbp != NULL && (! StringHasNoText (gbp->source))) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, "Original source text: ", FALSE, FALSE, TILDE_EXPAND);
+ FFAddOneString (ffstring, gbp->source, TRUE, TRUE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_comment, &dcontext);
+ while (sdp != NULL) {
+ if (sdp->data.ptrvalue != NULL) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_comment, &dcontext);
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_maploc, &dcontext);
+ while (sdp != NULL) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_maploc, &dcontext);
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_region, &dcontext);
+ while (sdp != NULL) {
+ if (sdp->data.ptrvalue != NULL) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_region, &dcontext);
+ }
+
+ /* HTGS results in allocated comment string */
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp != NULL) {
+
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip != NULL) {
+ if (mip->completeness != 0 && is_other) {
+
+ str = GetMolInfoCommentString (bsp, mip);
+
+ if (str != NULL) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, str, TRUE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+
+ }
+ if (mip->tech == MI_TECH_htgs_0 ||
+ mip->tech == MI_TECH_htgs_1 ||
+ mip->tech == MI_TECH_htgs_2) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ /*
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ */
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ AddHTGSCommentString (ffstring, bsp, mip);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+
+ } else {
+ str = StringForSeqTech (mip->tech);
+ if (! StringHasNoText (str)) {
+
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ /*
+ cbp->entityID = dcontext.entityID;
+ cbp->itemID = dcontext.itemID;
+ cbp->itemtype = OBJ_SEQDESC;
+ */
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddTextToString (ffstring, "Method: ", str, NULL, TRUE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ }
+ }
+ }
+
+ /* add comment features that are full length on appropriate segment */
+
+ parent = awp->parent;
+ if (parent == NULL) return;
+
+ sfp = SeqMgrGetNextFeature (parent, NULL, SEQFEAT_COMMENT, 0, &fcontext);
+ while (sfp != NULL) {
+ if (fcontext.left == awp->from && fcontext.right == awp->to) {
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+ cbp->entityID = fcontext.entityID;
+ cbp->itemID = fcontext.itemID;
+ cbp->itemtype = OBJ_SEQFEAT;
+ cbp->first = first;
+ first = FALSE;
+ }
+ }
+ sfp = SeqMgrGetNextFeature (parent, sfp, SEQFEAT_COMMENT, 0, &fcontext);
+ }
+
+ /* look for Seq-annot.desc.comment on annots packaged on current bioseq */
+
+ head = NULL;
+ VisitAnnotsOnBsp (bsp, (Pointer) &head, GetAnnotComments);
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (StringHasNoText (str)) continue;
+ cbp = (CommentBlockPtr) Asn2gbAddBlock (awp, COMMENT_BLOCK, sizeof (CommentBlock));
+ if (cbp != NULL) {
+
+ cbp->first = first;
+ first = FALSE;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ FFAddOneString (ffstring, str, TRUE, FALSE, TILDE_EXPAND);
+
+ cbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+ }
+ ValNodeFreeData (head);
+
+ if (gsdbcbp != NULL) {
+
+ /* if there were no subsequent comments, do not add period after GSDB id */
+
+ if (cbp == NULL) {
+ sprintf (buf, "GSDB:S:%ld", (long) gsdbid);
+ } else {
+ sprintf (buf, "GSDB:S:%ld.", (long) gsdbid);
+ }
+
+ if (gsdbcbp->first) {
+ FFStartPrint (ffstring, awp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, awp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ /* CheckEndPunctuation, ConvertDoubleQuotes, and ExpandTildes already taken into account */
+
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
+
+ gsdbcbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 12, 5, 5, "CC");
+ FFRecycleString(ajp, ffstring);
+ ffstring = FFGetString(ajp);
+ }
+
+ FFRecycleString(ajp, ffstring);
+}
+
+NLM_EXTERN void AddFeatHeaderBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BaseBlockPtr bbp;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+
+ bbp = Asn2gbAddBlock (awp, FEATHEADER_BLOCK, sizeof (BaseBlock));
+ if (bbp == NULL) return;
+
+ if (awp->format == FTABLE_FMT) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+ FFStartPrint (ffstring, awp->format, 0, 12, "FEATURES", 21, 5, 0, "FH", TRUE);
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ FFAddOneString (ffstring, "Key", FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 13 , FALSE);
+ }
+
+ FFAddOneString (ffstring, "Location/Qualifiers", FALSE, FALSE, TILDE_TO_SPACES);
+
+ if (awp->format == EMBL_FMT || awp->format == EMBLPEPT_FMT) {
+ FFAddNewLine(ffstring);
+ FFAddNewLine(ffstring);
+ }
+
+ bbp->string = FFEndPrint(ajp, ffstring, awp->format, 12, 21, 5, 0, "FH");
+ FFRecycleString(ajp, ffstring);
+}
+
+static Uint2 ComputeSourceHash (
+ CharPtr key,
+ Uint2 start
+)
+
+{
+ Uint4 h;
+ Uint2 M;
+ Uint2 S;
+
+ if (key == NULL) return start;
+
+ M = 101; /* prime key */
+ S = 256; /* size of alphabet */
+
+ for (h = start; *key != '\0'; key++) {
+ h = (S * h + *key) % M;
+ }
+
+ return (Uint2) h;
+}
+
+static BaseBlockPtr AddSource (
+ Asn2gbWorkPtr awp,
+ ValNodePtr PNTR head,
+ BioSourcePtr biop,
+ CharPtr comment
+)
+
+{
+ BaseBlockPtr bbp;
+ DbtagPtr dbt;
+ Uint2 hash;
+ SourceType idx;
+ IntSrcBlockPtr isp;
+ ObjectIdPtr oip;
+ OrgModPtr omp;
+ OrgNamePtr onp;
+ OrgRefPtr orp;
+ SubSourcePtr ssp;
+ CharPtr str;
+ Uint1 subtype;
+ Char tmp [16];
+ ValNodePtr vnp;
+
+ if (awp == NULL || head == NULL || biop == NULL) return NULL;
+
+ bbp = (BaseBlockPtr) MemNew (sizeof (IntSrcBlock));
+ if (bbp == NULL) return NULL;
+ bbp->blocktype = SOURCEFEAT_BLOCK;
+ bbp->section = awp->currsection;
+
+ ValNodeAddPointer (head, 0, bbp);
+
+ isp = (IntSrcBlockPtr) bbp;
+ isp->biop = biop;
+ isp->is_focus = biop->is_focus;
+ if (biop->origin == 5) {
+ isp->is_synthetic = TRUE;
+ }
+
+ orp = biop->org;
+ if (orp == NULL) return bbp;
+
+ isp->orghash = ComputeSourceHash (orp->taxname, 0);
+ isp->taxname = orp->taxname;
+
+ hash = 0;
+ onp = orp->orgname;
+ if (onp != NULL) {
+ if (StringICmp (onp->div, "SYN") == 0) {
+ isp->is_synthetic = TRUE;
+ }
+ isp->omp = onp->mod;
+ for (omp = onp->mod; omp != NULL; omp = omp->next) {
+ subtype = omp->subtype;
+ if (subtype == 253) {
+ subtype = 35;
+ } else if (subtype == 254) {
+ subtype = 36;
+ } else if (subtype == 255) {
+ subtype = 37;
+ }
+ if (subtype < 38) {
+ idx = orgModToSourceIdx [subtype];
+ if (idx > 0 && idx < ASN2GNBK_TOTAL_SOURCE) {
+ str = asn2gnbk_source_quals [idx].name;
+ hash = ComputeSourceHash (str, hash);
+ hash = ComputeSourceHash (omp->subname, hash);
+ }
+ }
+ }
+ }
+ if (comment != NULL) {
+ hash = ComputeSourceHash ("note", hash);
+ hash = ComputeSourceHash (comment, hash);
+ }
+ isp->modhash = hash;
+
+ hash = 0;
+ for (ssp = biop->subtype; ssp != NULL; ssp = ssp->next) {
+ subtype = ssp->subtype;
+ if (subtype == 255) {
+ subtype = 29;
+ }
+ if (subtype < 30) {
+ idx = subSourceToSourceIdx [subtype];
+ if (idx > 0 && idx < ASN2GNBK_TOTAL_SOURCE) {
+ str = asn2gnbk_source_quals [idx].name;
+ hash = ComputeSourceHash (str, hash);
+ hash = ComputeSourceHash (ssp->name, hash);
+ }
+ }
+ }
+ isp->subhash = hash;
+ isp->ssp = biop->subtype;
+
+ hash = 0;
+ for (vnp = orp->db; vnp != NULL; vnp = vnp->next) {
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt != NULL) {
+ hash = ComputeSourceHash (dbt->db, hash);
+ oip = dbt->tag;
+ if (oip != NULL) {
+ if (oip->str != NULL) {
+ hash = ComputeSourceHash (oip->str, hash);
+ } else {
+ sprintf (tmp, "%ld", (long) oip->id);
+ hash = ComputeSourceHash (tmp, hash);
+ }
+ }
+ }
+ }
+ isp->xrfhash = hash;
+ isp->vnp = orp->db;
+
+ return bbp;
+}
+
+static int LIBCALLBACK SortSourcesByHash (
+ VoidPtr ptr1,
+ VoidPtr ptr2
+)
+
+{
+ Int4 diff;
+ IntSrcBlockPtr isp1;
+ IntSrcBlockPtr isp2;
+ ValNodePtr vnp1;
+ ValNodePtr vnp2;
+
+ if (ptr1 == NULL || ptr2 == NULL) return 0;
+ vnp1 = *((ValNodePtr PNTR) ptr1);
+ vnp2 = *((ValNodePtr PNTR) ptr2);
+ if (vnp1 == NULL || vnp2 == NULL) return 0;
+ isp1 = (IntSrcBlockPtr) vnp1->data.ptrvalue;
+ isp2 = (IntSrcBlockPtr) vnp2->data.ptrvalue;
+ if (isp1 == NULL || isp2 == NULL) return 0;
+
+ if (isp1->is_focus && (! isp2->is_focus)) return -1;
+ if (isp2->is_focus && (! isp1->is_focus)) return 1;
+
+ diff = isp1->orghash - isp2->orghash;
+ if (diff > 0) return -1;
+ if (diff < 0) return 1;
+
+ diff = isp1->xrfhash - isp2->xrfhash;
+ if (diff > 0) return -1;
+ if (diff < 0) return 1;
+
+ /* sort so that sources with modifiers come first */
+
+ diff = isp1->modhash - isp2->modhash;
+ if (diff > 0) return -1;
+ if (diff < 0) return 1;
+
+ diff = isp1->subhash - isp2->subhash;
+ if (diff > 0) return -1;
+ if (diff < 0) return 1;
+
+ /* if all hashes are equal, descriptor comes first */
+
+ if (isp1->is_descriptor && (! isp2->is_descriptor)) {
+ return -1;
+ } else if (isp2->is_descriptor && (! isp1->is_descriptor)) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static int LIBCALLBACK SortSourcesByPos (
+ VoidPtr ptr1,
+ VoidPtr ptr2
+)
+
+{
+ IntSrcBlockPtr isp1;
+ IntSrcBlockPtr isp2;
+ ValNodePtr vnp1;
+ ValNodePtr vnp2;
+
+ if (ptr1 == NULL || ptr2 == NULL) return 0;
+ vnp1 = *((ValNodePtr PNTR) ptr1);
+ vnp2 = *((ValNodePtr PNTR) ptr2);
+ if (vnp1 == NULL || vnp2 == NULL) return 0;
+ isp1 = (IntSrcBlockPtr) vnp1->data.ptrvalue;
+ isp2 = (IntSrcBlockPtr) vnp2->data.ptrvalue;
+ if (isp1 == NULL || isp2 == NULL) return 0;
+
+ /* descriptor always goes first */
+
+ if (isp1->is_descriptor && (! isp2->is_descriptor)) {
+ return -1;
+ } else if (isp2->is_descriptor && (! isp1->is_descriptor)) {
+ return 1;
+ }
+
+ /* feature with smallest left extreme is first */
+
+ if (isp1->left > isp2->left) {
+ return 1;
+ } else if (isp1->left < isp2->left) {
+ return -1;
+ }
+
+ /* if same left extreme, shortest source feature is first just for flatfile */
+
+ if (isp1->right > isp2->right) {
+ return 1;
+ } else if (isp1->right < isp2->right) {
+ return -1;
+ }
+
+ return 0;
+}
+
+/* */
+/* s_isFuzzyLoc () -- Determines is a location has fuzzy coordinates */
+/* */
+
+static Boolean s_isFuzzyLoc ( SeqLocPtr pLocation )
+{
+ SeqIntPtr pIntLocation;
+
+ if (pLocation == NULL)
+ return FALSE;
+
+ if (pLocation->choice != SEQLOC_INT)
+ return FALSE;
+
+ if (pLocation->data.ptrvalue == NULL)
+ return FALSE;
+
+ pIntLocation = (SeqIntPtr) pLocation->data.ptrvalue;
+
+ if ((pIntLocation->if_from != NULL) && (pIntLocation->if_from->choice == 2))
+ return TRUE;
+
+ if ((pIntLocation->if_to != NULL) && (pIntLocation->if_to->choice == 2))
+ return TRUE;
+
+ return FALSE;
+}
+
+static void GetSourcesOnBioseq (
+ Asn2gbWorkPtr awp,
+ BioseqPtr target,
+ BioseqPtr bsp,
+ Int4 from,
+ Int4 to
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BaseBlockPtr bbp;
+ BioSourcePtr biop;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ Boolean hasNulls;
+ Int4 left;
+ Boolean loop = FALSE;
+ Int2 idx;
+ IntSrcBlockPtr isp;
+ Int4Ptr ivals;
+ SeqLocPtr newloc;
+ Boolean noLeft;
+ Boolean noRight;
+ Int2 numivals;
+ Boolean okay;
+ Int4 right;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+ SeqInt sint;
+ SeqIdPtr sip;
+ Boolean split;
+ Int4 start;
+ Int4 stop;
+ Uint1 strand;
+ ValNode vn;
+ ValNodePtr vnp;
+
+ if (awp == NULL || target == NULL || bsp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+
+ if (awp->format != FTABLE_FMT || awp->mode == DUMP_MODE) {
+
+ /* full length loc for descriptors */
+
+ sint.from = 0;
+ if (ajp->ajp.slp != NULL) {
+ sint.to = SeqLocLen (ajp->ajp.slp) - 1;
+ } else {
+ sint.to = bsp->length - 1;
+ }
+ sint.strand = Seq_strand_plus;
+ sint.id = SeqIdStripLocus (SeqIdDup (SeqIdFindBest (bsp->id, 0)));
+ sint.if_from = NULL;
+ sint.if_to = NULL;
+
+ vn.choice = SEQLOC_INT;
+ vn.data.ptrvalue = (Pointer) &sint;
+ vn.next = NULL;
+
+ /* if SWISS-PROT, may have multiple source descriptors */
+
+ if (ISA_aa (bsp->mol)) {
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_SWISSPROT) {
+ loop = TRUE;
+ }
+ }
+ }
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_source, &dcontext);
+ while (sdp != NULL) {
+
+ /* check if descriptor on part already added on segmented bioseq */
+
+ okay = TRUE;
+ for (vnp = awp->srchead; vnp != NULL && okay; vnp = vnp->next) {
+ bbp = (BaseBlockPtr) vnp->data.ptrvalue;
+ if (bbp != NULL) {
+ if (bbp->entityID == dcontext.entityID &&
+ bbp->itemID == dcontext.itemID &&
+ bbp->itemtype == OBJ_SEQDESC) {
+ okay = FALSE;
+ }
+ }
+ }
+
+ if (okay) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ bbp = AddSource (awp, &(awp->srchead), biop, NULL);
+ if (bbp != NULL) {
+
+ bbp->entityID = dcontext.entityID;
+ bbp->itemID = dcontext.itemID;
+ bbp->itemtype = OBJ_SEQDESC;
+
+ isp = (IntSrcBlockPtr) bbp;
+ isp->loc = SeqLocMerge (target, &vn, NULL, FALSE, TRUE, FALSE);
+ isp->left = 0;
+ isp->right = bsp->length - 1;
+ isp->is_descriptor = TRUE;
+ }
+ }
+
+ /* if SWISS-PROT, loop through multiple source descriptors */
+
+ if (loop) {
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_source, &dcontext);
+ } else {
+ sdp = NULL;
+ }
+ }
+
+ SeqIdFree (sint.id);
+ }
+
+ if ((! awp->contig) || awp->showconsource) {
+
+ /* features are indexed on parent if segmented */
+
+ bsp = awp->parent;
+
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_BIOSRC, 0, &fcontext);
+ while (sfp != NULL) {
+ ivals = fcontext.ivals;
+ numivals = fcontext.numivals;
+ if (ivals != NULL && numivals > 0) {
+
+ idx = (numivals - 1) * 2;
+ start = ivals [idx];
+ stop = ivals [idx + 1];
+ if (stop >= from && stop <= to && (ajp->ajp.slp == NULL || SeqLocCompare (sfp->location, ajp->ajp.slp) > 0)) {
+
+ biop = (BioSourcePtr) sfp->data.value.ptrvalue;
+ bbp = AddSource (awp, &(awp->srchead), biop, sfp->comment);
+ if (bbp != NULL) {
+
+ bbp->entityID = fcontext.entityID;
+ bbp->itemID = fcontext.itemID;
+ bbp->itemtype = OBJ_SEQFEAT;
+
+ isp = (IntSrcBlockPtr) bbp;
+ if (sfp->location != NULL && sfp->location->choice == SEQLOC_PNT) {
+ isp->loc = AsnIoMemCopy ((Pointer) sfp->location,
+ (AsnReadFunc) SeqLocAsnRead,
+ (AsnWriteFunc) SeqLocAsnWrite);
+ } else if (s_isFuzzyLoc (sfp->location)) {
+ isp->loc = AsnIoMemCopy ((Pointer) sfp->location,
+ (AsnReadFunc) SeqLocAsnRead,
+ (AsnWriteFunc) SeqLocAsnWrite);
+ } else if (SeqLocId(sfp->location) == NULL) {
+ isp->loc = AsnIoMemCopy ((Pointer) sfp->location,
+ (AsnReadFunc) SeqLocAsnRead,
+ (AsnWriteFunc) SeqLocAsnWrite);
+ } else {
+ CheckSeqLocForPartial (sfp->location, &noLeft, &noRight);
+ hasNulls = LocationHasNullsBetween (sfp->location);
+ isp->loc = SeqLocMerge (target, sfp->location, NULL, FALSE, TRUE, hasNulls);
+ SetSeqLocPartial (isp->loc, noLeft, noRight);
+ }
+ isp->left = fcontext.left;
+ isp->right = fcontext.right;
+ isp->comment = sfp->comment;
+ if (ajp->ajp.slp != NULL) {
+ sip = SeqIdParse ("lcl|dummy");
+ left = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_LEFT_END);
+ right = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_RIGHT_END);
+ strand = SeqLocStrand (ajp->ajp.slp);
+ split = FALSE;
+ newloc = SeqLocReMapEx (sip, ajp->ajp.slp, isp->loc, 0, FALSE, ajp->masterStyle);
+ /*
+ newloc = SeqLocCopyRegion (sip, isp->loc, bsp, left, right, strand, &split);
+ */
+ SeqIdFree (sip);
+ if (newloc != NULL) {
+ A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
+ isp->loc = SeqLocFree (isp->loc);
+ isp->loc = newloc;
+ isp->left = left;
+ isp->right = right;
+ }
+ }
+ }
+ }
+ }
+
+ sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_BIOSRC, 0, &fcontext);
+ }
+ }
+}
+
+static Boolean LIBCALLBACK GetSourcesOnSeg (
+ SeqLocPtr slp,
+ SeqMgrSegmentContextPtr context
+)
+
+{
+ Asn2gbWorkPtr awp;
+ BioseqPtr bsp;
+ Int4 from;
+ SeqLocPtr loc;
+ SeqEntryPtr oldscope;
+ SeqEntryPtr sep;
+ SeqIdPtr sip;
+ Int4 to;
+
+ if (slp == NULL || context == NULL) return FALSE;
+ awp = (Asn2gbWorkPtr) context->userdata;
+
+ from = context->cumOffset;
+ to = from + context->to - context->from;
+
+ sip = SeqLocId (slp);
+ if (sip == NULL) {
+ loc = SeqLocFindNext (slp, NULL);
+ if (loc != NULL) {
+ sip = SeqLocId (loc);
+ }
+ }
+ if (sip == NULL) return TRUE;
+
+ /* biosource descriptors only on parts within entity */
+
+ sep = GetTopSeqEntryForEntityID (awp->entityID);
+ oldscope = SeqEntrySetScope (sep);
+ bsp = BioseqFind (sip);
+ SeqEntrySetScope (oldscope);
+
+ if (bsp != NULL) {
+ GetSourcesOnBioseq (awp, awp->target, bsp, from, to);
+ return TRUE;
+ }
+
+ /* if we ever want to fetch remote sources, code goes here */
+
+#if 0
+ Uint2 entityID;
+
+ /* may remote fetch genome component if not already in memory */
+
+ bsp = BioseqLockById (sip);
+
+ if (bsp == NULL) return TRUE;
+
+ entityID = ObjMgrGetEntityIDForPointer (bsp);
+
+ if (entityID != awp->entityID) {
+
+ /* if segment not packaged in record, may need to feature index it */
+
+ if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
+ SeqMgrIndexFeatures (entityID, NULL);
+ }
+
+ /* collect features indexed on the remote bioseq */
+
+ from = 0;
+ to = bsp->length - 1;
+ }
+
+ GetSourcesOnBioseq (awp, awp->target, bsp, from, to);
+
+ BioseqUnlock (bsp);
+#endif
+
+ return TRUE;
+}
+
+/* isIdenticalSource() -- Checks to see if two sources are identical */
+/* by comparing the actual values in the */
+/* fields. This only gets called if the two */
+/* sources hashed the same -- it's a double- */
+/* check since two non-identical things will */
+/* occassionally hash to the same value. */
+
+static Boolean isIdenticalSource (IntSrcBlockPtr isp1, IntSrcBlockPtr isp2)
+{
+ OrgModPtr omp1;
+ OrgModPtr omp2;
+ SubSourcePtr ssp1;
+ SubSourcePtr ssp2;
+ ValNodePtr vnp1;
+ ValNodePtr vnp2;
+ ObjectIdPtr oip1;
+ ObjectIdPtr oip2;
+ DbtagPtr dbt1;
+ DbtagPtr dbt2;
+
+ if (isp1->is_focus != isp2->is_focus)
+ return FALSE;
+
+ /* Compare the taxonomy names */
+
+ if (StringICmp(isp1->taxname,isp2->taxname) != 0)
+ return FALSE;
+
+ /* Compare the comment */
+
+ if (StringICmp(isp1->comment,isp2->comment) != 0)
+ return FALSE;
+
+ /* Compare the org mods */
+
+ omp1 = isp1->omp;
+ omp2 = isp2->omp;
+ while (omp1 != NULL && omp2 != NULL)
+ {
+ if (omp1->subtype != omp2->subtype)
+ return FALSE;
+ if (StringICmp (omp1->subname, omp2->subname) != 0)
+ return FALSE;
+ omp1 = omp1->next;
+ omp2 = omp2->next;
+ }
+
+ if (omp1 != NULL || omp2 != NULL)
+ return FALSE;
+
+ /* Compare the subtypes */
+
+ ssp1 = isp1->ssp;
+ ssp2 = isp2->ssp;
+
+ while (ssp1 != NULL && ssp2 != NULL)
+ {
+ if (ssp1->subtype != ssp2->subtype)
+ return FALSE;
+ if (StringICmp(ssp1->name,ssp2->name) != 0)
+ return FALSE;
+ ssp1 = ssp1->next;
+ ssp2 = ssp2->next;
+ }
+
+ if (ssp1 != NULL || ssp2 != NULL)
+ return FALSE;
+
+ /* Compare the DB tags */
+
+ vnp1 = isp1->vnp;
+ vnp2 = isp2->vnp;
+
+ while (vnp1 != NULL && vnp2 != NULL)
+ {
+ dbt1 = (DbtagPtr) vnp1->data.ptrvalue;
+ dbt2 = (DbtagPtr) vnp2->data.ptrvalue;
+
+ if ((dbt1 != NULL) && (dbt2 != NULL)) {
+ if (dbt1->db != dbt2->db)
+ return FALSE;
+
+ oip1 = dbt1->tag;
+ oip2 = dbt2->tag;
+ if ((oip1 != NULL) && (oip2 != NULL)) {
+ if (oip1->str != NULL) {
+ if (StringICmp(oip1->str, oip2->str) != 0)
+ return FALSE;
+ } else {
+ if (oip1->id != oip2->id)
+ return FALSE;
+ }
+ }
+ else if (oip1 != NULL)
+ return FALSE;
+ else if (oip2 != NULL)
+ return FALSE;
+ }
+ else if (dbt1 != NULL)
+ return FALSE;
+ else if (dbt2 != NULL)
+ return FALSE;
+
+ vnp1 = vnp1->next;
+ vnp2 = vnp2->next;
+ }
+
+ if (vnp1 != NULL || vnp2 != NULL)
+ return FALSE;
+
+ /* If it passed all checks, then they */
+ /* are the same, so return true. */
+
+ return TRUE;
+}
+
+static void CleanupPackedSeqInt (SeqLocPtr location)
+
+{
+ SeqLocPtr head = NULL;
+ SeqIntPtr loc;
+ SeqIntPtr sintp;
+ SeqLocPtr slp;
+
+ if (location == NULL || location->choice != SEQLOC_PACKED_INT || location->data.ptrvalue == NULL) return;
+
+ slp = SeqLocFindNext (location, NULL);
+ while (slp != NULL) {
+ if (slp->choice == SEQLOC_INT) {
+ sintp = (SeqIntPtr) slp->data.ptrvalue;
+ if (sintp != NULL) {
+ loc = AsnIoMemCopy (sintp, (AsnReadFunc) SeqIntAsnRead,
+ (AsnWriteFunc) SeqIntAsnWrite);
+ ValNodeAddPointer (&head, SEQLOC_INT, loc);
+ }
+ }
+ slp = SeqLocFindNext (location, slp);
+ }
+ if (head == NULL) return;
+
+ location->data.ptrvalue = SeqLocFree (location->data.ptrvalue);
+ location->data.ptrvalue = head;
+
+ slp = location->data.ptrvalue;
+ if (slp == NULL || slp->next != NULL) return;
+ /* here seqloc_packed_int points to a single location element, so no need for seqloc_packed_int parent */
+ location->choice = slp->choice;
+ location->data.ptrvalue = (Pointer) slp->data.ptrvalue;
+ MemFree (slp);
+}
+
+
+NLM_EXTERN void AddSourceFeatBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BaseBlockPtr bbp;
+ BioseqPtr bsp;
+ SeqFeatPtr cds;
+ SeqMgrFeatContext context;
+ BioseqPtr dna;
+ SeqLocPtr duploc;
+ Boolean excise;
+ GBFeaturePtr gbfeat = NULL;
+ GBSeqPtr gbseq;
+ ValNodePtr head = NULL;
+ IntSrcBlockPtr isp;
+ IntSrcBlockPtr lastisp;
+ IntSrcBlockPtr descrIsp;
+ ValNodePtr next;
+ ValNodePtr PNTR prev;
+ SeqInt sint;
+ SeqLocPtr slp;
+ CharPtr str;
+ BioseqPtr target;
+ ValNode vn;
+ ValNodePtr vnp;
+ Boolean descHasFocus = FALSE;
+ StringItemPtr ffstring;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ asp = awp->asp;
+ if (asp == NULL) return;
+ bsp = awp->bsp;
+ if (bsp == NULL) return;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return;
+
+
+ /* collect biosources on bioseq */
+
+ awp->srchead = NULL;
+ GetSourcesOnBioseq (awp, bsp, bsp, awp->from, awp->to);
+ target = bsp;
+
+ if (bsp->repr == Seq_repr_seg) {
+
+ /* collect biosource descriptors on local parts */
+
+ SeqMgrExploreSegments (bsp, (Pointer) awp, GetSourcesOnSeg);
+ target = awp->target;
+ }
+
+ if (awp->srchead == NULL && ISA_aa (bsp->mol)) {
+
+ /* if protein with no sources, get sources applicable to DNA location of CDS */
+
+ cds = SeqMgrGetCDSgivenProduct (bsp, &context);
+ if (cds != NULL) {
+ dna = BioseqFindFromSeqLoc (cds->location);
+ if (dna != NULL) {
+ GetSourcesOnBioseq (awp, dna, dna, context.left, context.right);
+ target = dna;
+ }
+ }
+ }
+
+ head = awp->srchead;
+ awp->srchead = NULL;
+
+ if (head == NULL && (awp->format != FTABLE_FMT || awp->mode == DUMP_MODE)) {
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ sint.from = 0;
+ sint.to = bsp->length - 1;
+ sint.strand = Seq_strand_plus;
+ sint.id = SeqIdStripLocus (SeqIdDup (SeqIdFindBest (bsp->id, 0)));
+ sint.if_from = NULL;
+ sint.if_to = NULL;
+
+ vn.choice = SEQLOC_INT;
+ vn.data.ptrvalue = (Pointer) &sint;
+ vn.next = NULL;
+
+ FFStartPrint (ffstring, awp->format, 5, 21, NULL, 0, 5, 21, "FT", FALSE);
+ FFAddOneString(ffstring, "source", FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 21 - 5 - StringLen("source"), FALSE);
+
+ if (gbseq != NULL) {
+ gbfeat = GBFeatureNew ();
+ if (gbfeat != NULL) {
+ gbfeat->key = StringSave ("source");
+ }
+ }
+
+ str = FFFlatLoc (ajp, bsp, &vn, (Boolean) (awp->style == MASTER_STYLE));
+ if ( GetWWW(ajp) ) {
+ FF_www_featloc (ffstring, str);
+ } else {
+ FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ if (gbseq != NULL) {
+ if (gbfeat != NULL) {
+ if (! StringHasNoText (str)) {
+ gbfeat->location = StringSave (str);
+ } else {
+ gbfeat->location = StringSave ("");
+ }
+ }
+ }
+
+ MemFree (str);
+
+ if (ajp->flags.needOrganismQual) {
+ FFAddNewLine(ffstring);
+ FFAddTextToString (ffstring, "/organism=\"", "unknown", "\"", FALSE, TRUE, TILDE_TO_SPACES);
+#ifdef ASN2GNBK_PRINT_UNKNOWN_ORG
+ } else {
+ FFAddNewLine(ffstring);
+ FFAddTextToString (ffstring, "/organism=\"", "unknown", "\"", FALSE, TRUE, TILDE_TO_SPACES);
+#endif
+ }
+
+ str = GetMolTypeQual (bsp);
+ if (str == NULL) {
+ switch (bsp->mol) {
+ case Seq_mol_dna :
+ str = "unassigned DNA";
+ break;
+ case Seq_mol_rna :
+ str = "unassigned RNA";
+ break;
+ case Seq_mol_aa :
+ break;
+ default :
+ str = "unassigned DNA";
+ break;
+ }
+ }
+ if (str != NULL) {
+ FFAddNewLine(ffstring);
+ FFAddTextToString (ffstring, "/mol_type=\"", str, "\"", FALSE, TRUE, TILDE_TO_SPACES);
+ }
+
+ str = FFEndPrint(ajp, ffstring, awp->format, 5, 21, 5, 21, "FT");
+
+ bbp = (BaseBlockPtr) Asn2gbAddBlock (awp, SOURCEFEAT_BLOCK, sizeof (IntSrcBlock));
+ if (bbp != NULL) {
+ bbp->section = awp->currsection;
+ bbp->string = str;
+ } else {
+ MemFree(str);
+ }
+ FFRecycleString(ajp, ffstring);
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (gbseq != NULL) {
+ if (gbfeat != NULL) {
+ AddFeatureToGbseq (gbseq, gbfeat, str, NULL);
+ }
+ }
+ }
+
+ if (head == NULL) return;
+
+ /* sort by hash values */
+
+ head = SortValNode (head, SortSourcesByHash);
+
+ /* unique sources, excise duplicates from list */
+
+ prev = &(head);
+ vnp = head;
+ lastisp = NULL;
+ while (vnp != NULL) {
+ excise = FALSE;
+ next = vnp->next;
+ isp = (IntSrcBlockPtr) vnp->data.ptrvalue;
+ if (isp->is_descriptor && isp->is_focus)
+ descHasFocus = TRUE;
+ if (lastisp != NULL) {
+ if (isp != NULL) {
+ if (lastisp->is_focus == isp->is_focus &&
+ lastisp->orghash == isp->orghash &&
+ lastisp->xrfhash == isp->xrfhash) {
+
+ /* check for identical modifiers */
+
+ if (lastisp->modhash == isp->modhash &&
+ lastisp->subhash == isp->subhash) {
+
+ excise = isIdenticalSource (isp, lastisp);
+
+ /* or modifiers only in lastisp (e.g., on part bioseq) */
+
+ } else if (isp->modhash == 0 && isp->subhash == 0) {
+ excise = isIdenticalSource (isp, lastisp);
+ }
+ }
+ }
+ }
+ if (excise) {
+ *prev = vnp->next;
+ vnp->next = NULL;
+
+ /* combine locations of duplicate sources */
+
+ if (lastisp != NULL) {
+ slp = SeqLocMerge (target, lastisp->loc, isp->loc, FALSE, TRUE, FALSE);
+ lastisp->loc = SeqLocFree (lastisp->loc);
+ lastisp->loc = slp;
+ lastisp->left = MIN (lastisp->left,isp->left);
+ lastisp->right = MAX (lastisp->right, isp->right);
+ }
+
+ /* and remove duplicate source */
+
+ SeqLocFree (isp->loc);
+ MemFree (isp);
+ ValNodeFree (vnp);
+
+ } else {
+
+ prev = &(vnp->next);
+ lastisp = isp;
+ }
+ vnp = next;
+ }
+
+ /* Sort again, by location this time */
+
+ head = SortValNode (head, SortSourcesByPos);
+
+ /* If the descriptor has a focus, then subtract */
+ /* out all the other source locations. */
+
+ descrIsp = (IntSrcBlockPtr) head->data.ptrvalue; /* Sorted 1st by now */
+
+ if ((descHasFocus) && (! descrIsp->is_synthetic)) {
+
+ vnp = head;
+ duploc = AsnIoMemCopy ((Pointer) descrIsp->loc,
+ (AsnReadFunc) SeqLocAsnRead,
+ (AsnWriteFunc) SeqLocAsnWrite);
+ vnp = vnp->next;
+ while (vnp != NULL) {
+ isp = (IntSrcBlockPtr) vnp->data.ptrvalue;
+ if (SeqLocAinB (descrIsp->loc, isp->loc) >= 0) {
+ vnp = NULL; /* break the chain */
+ descrIsp->loc = SeqLocFree (descrIsp->loc);
+ descrIsp->loc = duploc;
+ duploc = NULL;
+ } else {
+ descrIsp->loc = SeqLocSubtract (descrIsp->loc, isp->loc);
+ vnp = vnp->next;
+ }
+ }
+ CleanupPackedSeqInt (descrIsp->loc);
+ descrIsp->left = SeqLocStart (descrIsp->loc);
+ descrIsp->right = SeqLocStop (descrIsp->loc);
+ SeqLocFree (duploc);
+ }
+
+ /* if features completely subtracted descriptor
+ intervals, suppress in release, entrez modes */
+
+ if (descrIsp->loc == NULL && ajp->flags.hideEmptySource && head->next != NULL) {
+ vnp = head->next;
+ head->next = NULL;
+ ValNodeFreeData (head);
+ head = vnp;
+ }
+
+ /* finally link into blocks for current section */
+
+ ValNodeLink (&(awp->lastblock), head);
+ vnp = awp->lastblock;
+ if (vnp == NULL) return;
+ while (vnp->next != NULL) {
+ vnp = vnp->next;
+ }
+
+ awp->lastblock = vnp;
+ if (awp->blockList == NULL) {
+ awp->blockList = vnp;
+ }
+ FFRecycleString(ajp, ffstring);
+}
+
+static Boolean IsCDD (
+ SeqFeatPtr sfp
+)
+
+{
+ DbtagPtr dbt;
+ ValNodePtr vnp;
+
+ for (vnp = sfp->dbxref; vnp != NULL; vnp = vnp->next) {
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt != NULL && StringCmp (dbt->db, "CDD") == 0) return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void GetFeatsOnCdsProduct (
+ SeqFeatPtr cds,
+ BioseqPtr nbsp,
+ BioseqPtr pbsp,
+ IntAsn2gbJobPtr ajp,
+ Asn2gbWorkPtr awp
+)
+
+{
+ FeatBlockPtr fbp;
+ IntFeatBlockPtr ifp;
+ Boolean isRefSeq;
+ Int4 lastleft;
+ Int4 lastright;
+ SeqAnnotPtr lastsap;
+ SeqFeatPtr lastsfp;
+ SeqLocPtr location;
+ SeqLocPtr newloc;
+ SeqMgrFeatContext pcontext;
+ SeqFeatPtr prt;
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+ Boolean suppress;
+
+ if (cds == NULL || ajp == NULL || awp == NULL) return;
+ if (nbsp == NULL || pbsp == NULL || (! ISA_aa (pbsp->mol))) return;
+
+ if (awp->hideCdsProdFeats) return;
+
+ isRefSeq = FALSE;
+ for (sip = nbsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_OTHER) {
+ isRefSeq = TRUE;
+ }
+ }
+
+ /* explore mat_peptides, sites, etc. */
+
+ lastsfp = NULL;
+ lastsap = NULL;
+ lastleft = 0;
+ lastright = 0;
+
+ prt = SeqMgrGetNextFeature (pbsp, NULL, 0, 0, &pcontext);
+ while (prt != NULL) {
+
+ if (pcontext.featdeftype == FEATDEF_REGION ||
+ pcontext.featdeftype == FEATDEF_SITE ||
+ pcontext.featdeftype == FEATDEF_BOND ||
+ pcontext.featdeftype == FEATDEF_mat_peptide_aa ||
+ pcontext.featdeftype == FEATDEF_sig_peptide_aa ||
+ pcontext.featdeftype == FEATDEF_transit_peptide_aa ||
+ (pcontext.featdeftype == FEATDEF_preprotein /* && isRefSeq */)) {
+
+ if (awp->hideCddFeats && pcontext.featdeftype == FEATDEF_REGION && IsCDD (prt)) {
+
+ /* passing this test prevents mapping of COG CDD region features */
+
+ } else if (pcontext.dnaStop >= awp->from && pcontext.dnaStop <= awp->to) {
+
+ /* suppress duplicate features (on protein) */
+
+ suppress = FALSE;
+ if (lastsfp != NULL && lastsap != NULL) {
+ if (lastsfp->idx.subtype == prt->idx.subtype &&
+ lastleft == pcontext.left &&
+ lastright == pcontext.right) {
+ if (lastsap == pcontext.sap ||
+ (lastsap->desc == NULL && pcontext.sap->desc == NULL)) {
+ if (AsnIoMemComp (lastsfp, prt, (AsnWriteFunc) SeqFeatAsnWrite)) {
+ suppress = TRUE;
+ }
+ }
+ }
+ }
+
+ /* make sure feature maps within nucleotide sublocation */
+
+ if (! suppress) {
+ if (ajp->ajp.slp != NULL) {
+ location = aaFeatLoc_to_dnaFeatLoc (cds, prt->location);
+ slp = SeqLocMerge (nbsp, location, NULL, FALSE, TRUE, FALSE);
+ if (slp != NULL) {
+ sip = SeqIdParse ("lcl|dummy");
+ newloc = SeqLocReMapEx (sip, ajp->ajp.slp, slp, 0, FALSE, ajp->masterStyle);
+ SeqIdFree (sip);
+ SeqLocFree (slp);
+ if (newloc == NULL) {
+ suppress = TRUE;
+ }
+ SeqLocFree (newloc);
+ } else {
+ suppress = TRUE;
+ }
+ SeqLocFree (location);
+ }
+ }
+
+ if (! suppress) {
+
+ fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntFeatBlock));
+ if (fbp != NULL) {
+
+ fbp->entityID = pcontext.entityID;
+ fbp->itemID = pcontext.itemID;
+ fbp->itemtype = OBJ_SEQFEAT;
+ fbp->featdeftype = pcontext.featdeftype;
+ ifp = (IntFeatBlockPtr) fbp;
+ ifp->mapToNuc = TRUE;
+ ifp->mapToProt = FALSE;
+ ifp->mapToGen = FALSE;
+ ifp->mapToMrna = FALSE;
+ ifp->mapToPep = FALSE;
+ ifp->firstfeat = awp->firstfeat;
+ awp->firstfeat = FALSE;
+ }
+ }
+
+ lastsfp = prt;
+ lastsap = pcontext.sap;
+ lastleft = pcontext.left;
+ lastright = pcontext.right;
+
+ }
+ }
+ prt = SeqMgrGetNextFeature (pbsp, prt, 0, 0, &pcontext);
+ }
+}
+
+static Boolean NotEMBLorDDBJ (
+ BioseqPtr bsp
+)
+
+{
+ SeqIdPtr sip;
+
+ if (bsp == NULL) return TRUE;
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_EMBL) return FALSE;
+ if (sip->choice == SEQID_DDBJ) return FALSE;
+ }
+ return TRUE;
+}
+
+static Boolean LIBCALLBACK GetFeatsOnBioseq (
+ SeqFeatPtr sfp,
+ SeqMgrFeatContextPtr fcontext
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ Asn2gbWorkPtr awp;
+ BioseqPtr bsp;
+ Char buf [41];
+ SeqFeatPtr cds;
+ SeqMgrFeatContext cdscontext;
+ SeqMgrDescContext dcontext;
+ FeatBlockPtr fbp;
+ SeqLocPtr firstslp;
+ GBQualPtr gbq;
+ SeqFeatPtr gene;
+ Int4 gi;
+ GeneRefPtr grp;
+ Boolean juststop = FALSE;
+ IntCdsBlockPtr icp;
+ Int2 idx;
+ IntFeatBlockPtr ifp;
+ Int4Ptr ivals;
+ Int2 j;
+ SeqAnnotPtr lastsap;
+ SeqFeatPtr lastsfp;
+ SeqLocPtr lastslp;
+ SeqLocPtr newloc;
+ Int2 numivals;
+ Boolean okay;
+ SeqEntryPtr oldscope;
+ BioseqPtr parent;
+ Boolean partial5;
+ Boolean partial3;
+ ValNodePtr ppr;
+ PubdescPtr pdp;
+ BioseqPtr prod;
+ Boolean pseudo = FALSE;
+ SeqDescrPtr sdp;
+ SeqEntryPtr sep;
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+ Int4 start;
+ Int4 stop;
+ TextSeqIdPtr tsip;
+ ValNodePtr vnp;
+
+ if (sfp == NULL || fcontext == NULL) return FALSE;
+ awp = (Asn2gbWorkPtr) fcontext->userdata;
+ if (awp == NULL) return FALSE;
+ ajp = awp->ajp;
+ if (ajp == NULL) return FALSE;
+ asp = awp->asp;
+ if (asp == NULL) return FALSE;
+ bsp = asp->bsp;
+ if (bsp == NULL) return FALSE;
+
+ if (fcontext->featdeftype == FEATDEF_PUB ||
+ fcontext->featdeftype == FEATDEF_NON_STD_RESIDUE ||
+ fcontext->featdeftype == FEATDEF_RSITE ||
+ fcontext->featdeftype == FEATDEF_SEQ) return TRUE;
+
+ if (fcontext->featdeftype == FEATDEF_BIOSRC) return TRUE;
+
+ if (ajp->flags.validateFeats &&
+ (fcontext->featdeftype == FEATDEF_BAD ||
+ fcontext->featdeftype == FEATDEF_virion)) {
+ return TRUE;
+ }
+
+ if (ISA_na (bsp->mol) && fcontext->featdeftype == FEATDEF_HET) return TRUE;
+
+ /* check feature customization flags */
+
+ if (awp->hideImpFeats && sfp->data.choice == SEQFEAT_IMP) return TRUE;
+ if (awp->hideSnpFeats && fcontext->featdeftype == FEATDEF_variation) return TRUE;
+ if (awp->hideExonFeats && fcontext->featdeftype == FEATDEF_exon) return TRUE;
+ if (awp->hideIntronFeats && fcontext->featdeftype == FEATDEF_intron) return TRUE;
+ if (awp->hideMiscFeats && fcontext->featdeftype == FEATDEF_misc_feature) return TRUE;
+ if (awp->hideRemImpFeats && sfp->data.choice == SEQFEAT_IMP) {
+ if (fcontext->featdeftype != FEATDEF_variation &&
+ fcontext->featdeftype != FEATDEF_exon &&
+ fcontext->featdeftype != FEATDEF_intron &&
+ fcontext->featdeftype != FEATDEF_misc_feature) return TRUE;
+ }
+ if (ISA_aa (bsp->mol) && fcontext->featdeftype == FEATDEF_REGION &&
+ awp->hideCddFeats && IsCDD (sfp)) return TRUE;
+
+ /* DDBJ does not want to show gene features */
+
+ if (fcontext->seqfeattype == SEQFEAT_GENE && awp->hideGeneFeats) return TRUE;
+
+ /* suppress comment features that are full length */
+
+ if (fcontext->seqfeattype == SEQFEAT_COMMENT &&
+ fcontext->left == awp->from && fcontext->right == awp->to) return TRUE;
+
+ ivals = fcontext->ivals;
+ numivals = fcontext->numivals;
+
+ /* check to see if last interval is on this awp->from - awp->to range */
+
+ if (ivals != NULL && numivals > 0) {
+ idx = (numivals - 1) * 2;
+ start = ivals [idx];
+ stop = ivals [idx + 1];
+ if (stop < awp->from || stop > awp->to) {
+
+ /* may need to map sig_peptide on a different segment */
+
+ if (fcontext->seqfeattype == SEQFEAT_CDREGION) {
+ sip = SeqLocIdForProduct (sfp->product);
+ bsp = BioseqFind (sip);
+ GetFeatsOnCdsProduct (sfp, asp->bsp, bsp, ajp, awp);
+ }
+
+ if (! awp->showAllFeats) return TRUE;
+
+ /* if showing one segment, only show features covering this segment */
+
+ if (fcontext->right < awp->from || fcontext->left > awp->to) return TRUE;
+
+ } else if (fcontext->farloc && NotEMBLorDDBJ (awp->bsp)) {
+
+ /* last interval may not have been mapped to bioseq if far */
+
+ firstslp = NULL;
+ lastslp = NULL;
+
+ slp = SeqLocFindNext (sfp->location, NULL);
+ while (slp != NULL) {
+ if (slp->choice != SEQLOC_NULL) {
+ lastslp = slp;
+ if (firstslp == NULL) {
+ firstslp = slp;
+ }
+ }
+ slp = SeqLocFindNext (sfp->location, slp);
+ }
+
+ /* !!! EMBL may have different desired behavior on where to map !!! */
+
+ if (firstslp != NULL && SeqLocStrand (firstslp) == Seq_strand_minus) {
+ slp = firstslp;
+ } else {
+ slp = lastslp;
+ }
+
+ if (slp != NULL) {
+ sip = SeqLocId (slp);
+ if (sip != NULL) {
+ bsp = BioseqFindCore (sip);
+ if (bsp == NULL || (bsp != awp->parent && bsp != awp->bsp)) {
+
+ return TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ /* make sure feature is within sublocation */
+
+ if (ajp->ajp.slp != NULL) {
+ if (SeqLocCompare (sfp->location, ajp->ajp.slp) == SLC_NO_MATCH) {
+ slp = SeqLocMerge (bsp, sfp->location, NULL, FALSE, TRUE, FALSE);
+ if (slp == NULL) return TRUE;
+ sip = SeqIdParse ("lcl|dummy");
+ newloc = SeqLocReMapEx (sip, ajp->ajp.slp, slp, 0, FALSE, ajp->masterStyle);
+ SeqIdFree (sip);
+ SeqLocFree (slp);
+ if (newloc == NULL) return TRUE;
+ SeqLocFree (newloc);
+ }
+ }
+
+ /* suppress duplicate features (on nucleotide) */
+
+ lastsfp = awp->lastsfp;
+ lastsap = awp->lastsap;
+ if (lastsfp != NULL && lastsap != NULL) {
+ if (lastsfp->idx.subtype == sfp->idx.subtype &&
+ awp->lastleft == fcontext->left &&
+ awp->lastright == fcontext->right) {
+ if (lastsap == fcontext->sap ||
+ (lastsap->desc == NULL && fcontext->sap->desc == NULL)) {
+ if (AsnIoMemComp (lastsfp, sfp, (AsnWriteFunc) SeqFeatAsnWrite)) {
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ /* if RELEASE_MODE, verify that features have all mandatory qualifiers */
+
+ if (ajp->flags.needRequiredQuals) {
+ okay = FALSE;
+
+ switch (fcontext->featdeftype) {
+
+ case FEATDEF_CDS:
+ if (ajp->flags.checkCDSproductID) {
+ /* non-pseudo CDS must have /product */
+ if (sfp->pseudo) {
+ pseudo = TRUE;
+ }
+ grp = SeqMgrGetGeneXref (sfp);
+ if (grp == NULL) {
+ sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
+ oldscope = SeqEntrySetScope (sep);
+ gene = SeqMgrGetOverlappingGene (sfp->location, NULL);
+ SeqEntrySetScope (oldscope);
+ if (gene != NULL) {
+ grp = (GeneRefPtr) gene->data.value.ptrvalue;
+ if (gene->pseudo) {
+ pseudo = TRUE;
+ }
+ }
+ }
+ if (grp != NULL && grp->pseudo) {
+ pseudo = TRUE;
+ }
+ if (sfp->location != NULL) {
+ if (CheckSeqLocForPartial (sfp->location, &partial5, &partial3)) {
+ if (partial5 && (! partial3)) {
+ if (SeqLocLen (sfp->location) <= 5) {
+ juststop = TRUE;
+ }
+ }
+ }
+ }
+ if (pseudo || juststop) {
+ okay = TRUE;
+ } else if (sfp->product != NULL) {
+ sip = SeqLocIdForProduct (sfp->product);
+ if (sip != NULL) {
+ if ((sip->choice == SEQID_GI && sip->data.intvalue > 0) ||
+ sip->choice == SEQID_LOCAL) {
+ sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
+ oldscope = SeqEntrySetScope (sep);
+ prod = BioseqFind (sip);
+ SeqEntrySetScope (oldscope);
+ if (prod != NULL) {
+ for (sip = prod->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GENBANK ||
+ sip->choice == SEQID_EMBL ||
+ sip->choice == SEQID_DDBJ ||
+ sip->choice == SEQID_OTHER ||
+ sip->choice == SEQID_PATENT ||
+ sip->choice == SEQID_TPG ||
+ sip->choice == SEQID_TPE ||
+ sip->choice == SEQID_TPD) {
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL && (! StringHasNoText (tsip->accession))) {
+ if (ValidateAccn (tsip->accession) == 0)
+ okay = TRUE;
+ }
+ }
+ }
+ } else if (sip->choice == SEQID_GI && sip->data.intvalue > 0) {
+ /* RELEASE_MODE requires that /protein_id is an accession */
+ gi = sip->data.intvalue;
+ if (GetAccnVerFromServer (gi, buf)) {
+ okay = TRUE;
+ } else {
+ sip = GetSeqIdForGI (gi);
+ if (sip != NULL) {
+ okay = TRUE;
+ }
+ }
+ }
+ } else if (sip->choice == SEQID_GENBANK ||
+ sip->choice == SEQID_EMBL ||
+ sip->choice == SEQID_DDBJ ||
+ sip->choice == SEQID_OTHER ||
+ sip->choice == SEQID_PATENT ||
+ sip->choice == SEQID_TPG ||
+ sip->choice == SEQID_TPE ||
+ sip->choice == SEQID_TPD) {
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL && (! StringHasNoText (tsip->accession))) {
+ if (ValidateAccn (tsip->accession) == 0)
+ okay = TRUE;
+ }
+ }
+ }
+ } else {
+ if (sfp->excpt && (! StringHasNoText (sfp->except_text))) {
+ if (StringStr (sfp->except_text, "rearrangement required for product") != NULL) {
+ okay = TRUE;
+ }
+ }
+ }
+ } else {
+ okay = TRUE;
+ }
+ if (! okay) {
+ ajp->relModeError = TRUE;
+ }
+ break;
+
+ case FEATDEF_conflict:
+ if (sfp->cit == NULL) {
+ /* RefSeq allows conflict with accession in comment instead of sfp->cit */
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_OTHER) {
+ if (! StringHasNoText (sfp->comment)) {
+ okay = TRUE;
+ }
+ }
+ }
+ }
+ /* continue on to old_sequence */
+ case FEATDEF_old_sequence:
+ /* conflict and old_sequence require a publication printable on the segment */
+ vnp = sfp->cit;
+
+ if (vnp != NULL && asp->referenceArray != NULL) {
+ for (ppr = vnp->data.ptrvalue; ppr != NULL; ppr = ppr->next) {
+ j = MatchRef (ppr, asp->referenceArray, asp->numReferences);
+ if (j > 0) {
+ okay = TRUE;
+ break;
+ }
+ }
+ }
+ break;
+
+ case FEATDEF_GENE:
+ /* gene requires /gene or /locus_tag, but desc or syn can be mapped to /gene */
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ if (grp != NULL) {
+ if (! StringHasNoText (grp->locus)) {
+ okay = TRUE;
+ } else if (! StringHasNoText (grp->locus_tag)) {
+ okay = TRUE;
+ } else if (! StringHasNoText (grp->desc)) {
+ okay = TRUE;
+ } else {
+ vnp = grp->syn;
+ if (vnp != NULL) {
+ if (! StringHasNoText (vnp->data.ptrvalue)) {
+ okay = TRUE;
+ }
+ }
+ }
+ }
+ break;
+
+ case FEATDEF_protein_bind:
+ case FEATDEF_misc_binding:
+ /* protein_bind or misc_binding require FTQUAL_bound_moiety */
+ gbq = sfp->qual;
+ while (gbq != NULL) {
+ if (StringICmp (gbq->qual, "bound_moiety") == 0 && (! StringHasNoText (gbq->val))) {
+ okay = TRUE;
+ break;
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case FEATDEF_modified_base:
+ /* modified_base requires FTQUAL_mod_base */
+ gbq = sfp->qual;
+ while (gbq != NULL) {
+ if (StringICmp (gbq->qual, "mod_base") == 0 && (! StringHasNoText (gbq->val))) {
+ okay = TRUE;
+ break;
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ default:
+ if (fcontext->featdeftype >= FEATDEF_GENE && fcontext->featdeftype < FEATDEF_MAX) {
+ okay = TRUE;
+ }
+ break;
+ }
+
+ if (okay == FALSE) return TRUE;
+ }
+
+ /* if RELEASE_MODE, suppress features with location on segmented Bioseq */
+
+ if (ajp->flags.suppressSegLoc) {
+ bsp = awp->parent;
+ if (bsp != NULL && bsp->repr == Seq_repr_seg) {
+ slp = SeqLocFindNext (sfp->location, NULL);
+ while (slp != NULL) {
+ sip = SeqLocId (slp);
+ if (sip != NULL) {
+ if (SeqIdIn (sip, bsp->id)) return TRUE;
+ }
+ slp = SeqLocFindNext (sfp->location, slp);
+ }
+ }
+ }
+
+ awp->lastsfp = sfp;
+ awp->lastsap = fcontext->sap;
+ awp->lastleft = fcontext->left;
+ awp->lastright = fcontext->right;
+
+ if (fcontext->seqfeattype == SEQFEAT_CDREGION) {
+ fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
+ } else {
+ fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntFeatBlock));
+ }
+ if (fbp == NULL) return TRUE;
+
+ fbp->entityID = fcontext->entityID;
+ fbp->itemID = fcontext->itemID;
+ fbp->itemtype = OBJ_SEQFEAT;
+ fbp->featdeftype = fcontext->featdeftype;
+ ifp = (IntFeatBlockPtr) fbp;
+ ifp->mapToNuc = FALSE;
+ ifp->mapToProt = FALSE;
+ ifp->mapToGen = FALSE;
+ ifp->mapToMrna = FALSE;
+ ifp->mapToPep = FALSE;
+ ifp->firstfeat = awp->firstfeat;
+ awp->firstfeat = FALSE;
+ awp->featseen = TRUE;
+
+ /* optionally map CDS from cDNA onto genomic */
+
+ if (awp->isGPS && ISA_na (bsp->mol) && awp->copyGpsCdsUp &&
+ fcontext->featdeftype == FEATDEF_mRNA) {
+ sip = SeqLocIdForProduct (sfp->product);
+ bsp = BioseqFind (sip);
+ if (bsp != NULL && ISA_na (bsp->mol)) {
+ cds = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &cdscontext);
+ if (cds != NULL) {
+ fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
+ if (fbp != NULL) {
+
+ fbp->entityID = cdscontext.entityID;
+ fbp->itemID = cdscontext.itemID;
+ fbp->itemtype = OBJ_SEQFEAT;
+ fbp->featdeftype = cdscontext.featdeftype;
+ ifp = (IntFeatBlockPtr) fbp;
+ ifp->mapToNuc = FALSE;
+ ifp->mapToProt = FALSE;
+ ifp->mapToGen = TRUE;
+ ifp->mapToMrna = FALSE;
+ ifp->mapToPep = FALSE;
+ ifp->firstfeat = awp->firstfeat;
+ awp->firstfeat = FALSE;
+ }
+ }
+ }
+ }
+
+ if (fcontext->seqfeattype != SEQFEAT_CDREGION) return TRUE;
+
+ /* if feature table format, do not get features from protein product */
+
+ if (awp->format == FTABLE_FMT) return TRUE;
+
+ /* if CDS, collect more information from product protein bioseq - may be part */
+
+ sip = SeqLocIdForProduct (sfp->product);
+ bsp = BioseqFind (sip);
+ if (bsp == NULL || (! ISA_aa (bsp->mol))) return TRUE;
+
+ ifp->isCDS = TRUE;
+ icp = (IntCdsBlockPtr) ifp;
+
+ /* first explore pubs to pick up figure and maploc */
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_pub, &dcontext);
+ while (sdp != NULL) {
+ pdp = (PubdescPtr) sdp->data.ptrvalue;
+ if (pdp != NULL) {
+ if (icp->fig == NULL) {
+ icp->fig = StringSaveNoNull (pdp->fig);
+ }
+ if (icp->maploc == NULL) {
+ icp->maploc = StringSaveNoNull (pdp->maploc);
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_pub, &dcontext);
+ }
+
+ /* product may be segmented part, and remaining features are indexed on parent */
+
+ parent = SeqMgrGetParentOfPart (bsp, NULL);
+ if (parent != NULL) {
+ bsp = parent;
+ }
+
+ /* then explore mat_peptides, sites, etc. */
+
+ GetFeatsOnCdsProduct (sfp, asp->bsp, bsp, ajp, awp);
+
+ return TRUE;
+}
+
+static Boolean LIBCALLBACK GetFeatsOnSeg (
+ SeqLocPtr slp,
+ SeqMgrSegmentContextPtr context
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbWorkPtr awp;
+ BioseqPtr bsp;
+ Uint2 entityID;
+ Int4 from;
+ Int4 left;
+ SeqLocPtr loc;
+ Int4 right;
+ SeqIdPtr sip;
+ Int4 to;
+
+ if (slp == NULL || context == NULL) return FALSE;
+ awp = (Asn2gbWorkPtr) context->userdata;
+ if (awp == NULL) return FALSE;
+ ajp = awp->ajp;
+ if (ajp == NULL) return FALSE;
+
+ /* do not fetch outside of desired component */
+
+ if (ajp->ajp.slp != NULL) {
+ left = GetOffsetInBioseq (ajp->ajp.slp, awp->parent, SEQLOC_LEFT_END);
+ right = GetOffsetInBioseq (ajp->ajp.slp, awp->parent, SEQLOC_RIGHT_END);
+
+ from = context->cumOffset;
+ to = from + context->to - context->from;
+
+ if (left > to) return TRUE;
+ if (right < from) return TRUE;
+ }
+
+ from = awp->from;
+ to = awp->to;
+
+ sip = SeqLocId (slp);
+ if (sip == NULL) {
+ loc = SeqLocFindNext (slp, NULL);
+ if (loc != NULL) {
+ sip = SeqLocId (loc);
+ }
+ }
+ if (sip == NULL) return TRUE;
+
+ /* may want to remote fetch genome component if not already in memory */
+
+ bsp = BioseqLockById (sip);
+
+ if (bsp == NULL) return TRUE;
+
+ entityID = ObjMgrGetEntityIDForPointer (bsp);
+
+ if (entityID != awp->entityID) {
+
+ /* if segment not packaged in record, may need to feature index it */
+
+ if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
+ SeqMgrIndexFeatures (entityID, NULL);
+ }
+
+ /* collect features indexed on the remote bioseq */
+
+ awp->from = 0;
+ awp->to = bsp->length - 1;
+ }
+
+ awp->lastsfp = NULL;
+ awp->lastsap = NULL;
+ awp->lastleft = 0;
+ awp->lastright = 0;
+
+ if (context->strand == Seq_strand_minus) {
+ SeqMgrExploreFeaturesRev (bsp, (Pointer) awp, GetFeatsOnBioseq, /* awp->slp */ slp, NULL, NULL);
+ } else {
+ SeqMgrExploreFeatures (bsp, (Pointer) awp, GetFeatsOnBioseq, /* awp->slp */ slp, NULL, NULL);
+ }
+
+ /* restore original from and to */
+
+ awp->from = from;
+ awp->to = to;
+
+ BioseqUnlock (bsp);
+
+ return TRUE;
+}
+
+NLM_EXTERN void AddFeatureBlock (
+ Asn2gbWorkPtr awp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ BioseqPtr bsp;
+ SeqFeatPtr cds;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ FeatBlockPtr fbp;
+ SeqFeatPtr gene;
+ IntFeatBlockPtr ifp;
+ Boolean is_other;
+ MolInfoPtr mip;
+ SeqFeatPtr mrna;
+ SeqFeatPtr prot;
+ SeqDescrPtr sdp;
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+
+ if (awp == NULL) return;
+ ajp = awp->ajp;
+ if (ajp == NULL) return;
+ bsp = awp->parent;
+ if (bsp == NULL) return;
+
+ awp->lastsfp = NULL;
+ awp->lastsap = NULL;
+ awp->lastleft = 0;
+ awp->lastright = 0;
+
+ /* optionally map gene from genomic onto cDNA */
+
+ if (awp->isGPS && ISA_na (bsp->mol) && awp->copyGpsGeneDown) {
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp != NULL && sdp->choice == Seq_descr_molinfo) {
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip != NULL) {
+ if (mip->biomol == MOLECULE_TYPE_MRNA) {
+ mrna = SeqMgrGetRNAgivenProduct (bsp, NULL);
+ if (mrna != NULL) {
+ gene = SeqMgrGetOverlappingGene (mrna->location, &fcontext);
+ if (gene != NULL && gene->data.choice == SEQFEAT_GENE) {
+
+ fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
+ if (fbp != NULL) {
+
+ fbp->entityID = fcontext.entityID;
+ fbp->itemID = fcontext.itemID;
+ fbp->itemtype = OBJ_SEQFEAT;
+ fbp->featdeftype = fcontext.featdeftype;
+ ifp = (IntFeatBlockPtr) fbp;
+ ifp->mapToNuc = FALSE;
+ ifp->mapToProt = FALSE;
+ ifp->mapToGen = FALSE;
+ ifp->mapToMrna = TRUE;
+ ifp->mapToPep = FALSE;
+ ifp->isCDS = TRUE;
+ ifp->firstfeat = awp->firstfeat;
+ awp->firstfeat = FALSE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (awp->farFeatsSuppress) {
+
+ if (bsp->repr == Seq_repr_seg || bsp->repr == Seq_repr_delta) {
+
+ /* if farFeatsSuppress first collect features on remote segments in MASTER_STYLE */
+
+ SeqMgrExploreSegments (bsp, (Pointer) awp, GetFeatsOnSeg);
+ }
+ }
+
+ if ((! awp->farFeatsSuppress) || (! awp->featseen)) {
+
+ /* reminder - features on near parts are indexed on segmented Bioseq */
+
+ slp = ajp->ajp.slp;
+ if (slp != NULL && SeqLocStrand (slp) == Seq_strand_minus) {
+ SeqMgrExploreFeaturesRev (bsp, (Pointer) awp, GetFeatsOnBioseq, awp->slp, NULL, NULL);
+ } else {
+ SeqMgrExploreFeatures (bsp, (Pointer) awp, GetFeatsOnBioseq, awp->slp, NULL, NULL);
+ }
+ }
+
+ if (awp->format == GENPEPT_FMT && ISA_aa (bsp->mol)) {
+ cds = SeqMgrGetCDSgivenProduct (bsp, &fcontext);
+ if (cds != NULL && cds->data.choice == SEQFEAT_CDREGION) {
+
+ fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
+ if (fbp != NULL) {
+
+ fbp->entityID = fcontext.entityID;
+ fbp->itemID = fcontext.itemID;
+ fbp->itemtype = OBJ_SEQFEAT;
+ fbp->featdeftype = fcontext.featdeftype;
+ ifp = (IntFeatBlockPtr) fbp;
+ ifp->mapToNuc = FALSE;
+ ifp->mapToProt = TRUE;
+ ifp->mapToGen = FALSE;
+ ifp->mapToMrna = FALSE;
+ ifp->mapToPep = FALSE;
+ ifp->isCDS = TRUE;
+ ifp->firstfeat = awp->firstfeat;
+ awp->firstfeat = FALSE;
+ }
+ }
+ prot = SeqMgrGetPROTgivenProduct (bsp, &fcontext);
+ if (prot != NULL && prot->data.choice == SEQFEAT_PROT) {
+
+ is_other = FALSE;
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_OTHER) {
+ is_other = TRUE;
+ }
+ }
+
+ /* for RefSeq records or GenBank not release_mode */
+ if (is_other || (! ajp->flags.forGbRelease)) {
+
+ fbp = (FeatBlockPtr) Asn2gbAddBlock (awp, FEATURE_BLOCK, sizeof (IntCdsBlock));
+ if (fbp != NULL) {
+
+ fbp->entityID = fcontext.entityID;
+ fbp->itemID = fcontext.itemID;
+ fbp->itemtype = OBJ_SEQFEAT;
+ fbp->featdeftype = fcontext.featdeftype;
+ ifp = (IntFeatBlockPtr) fbp;
+ ifp->mapToNuc = FALSE;
+ ifp->mapToProt = FALSE;
+ ifp->mapToGen = FALSE;
+ ifp->mapToMrna = FALSE;
+ ifp->mapToPep = TRUE;
+ ifp->firstfeat = awp->firstfeat;
+ awp->firstfeat = FALSE;
+ }
+ }
+ }
+ }
+
+ if (awp->onlyNearFeats) return;
+ if (awp->nearFeatsSuppress && awp->featseen) return;
+
+ if (! awp->farFeatsSuppress) {
+
+ if (bsp->repr == Seq_repr_seg || bsp->repr == Seq_repr_delta) {
+
+ /* if not farFeatsSuppress now collect features on remote segments in MASTER_STYLE */
+
+ SeqMgrExploreSegments (bsp, (Pointer) awp, GetFeatsOnSeg);
+ }
+ }
+}
+
diff --git a/api/asn2gnb4.c b/api/asn2gnb4.c
new file mode 100644
index 00000000..6b571a30
--- /dev/null
+++ b/api/asn2gnb4.c
@@ -0,0 +1,5056 @@
+/* asn2gnb4.c
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: asn2gnb4.c
+*
+* Author: Karl Sirotkin, Tom Madden, Tatiana Tatusov, Jonathan Kans,
+* Mati Shomrat
+*
+* Version Creation Date: 10/21/98
+*
+* $Revision: 1.3 $
+*
+* File Description: New GenBank flatfile generator - work in progress
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <objall.h>
+#include <objsset.h>
+#include <objsub.h>
+#include <objfdef.h>
+#include <objpubme.h>
+#include <seqport.h>
+#include <sequtil.h>
+#include <sqnutils.h>
+#include <subutil.h>
+#include <tofasta.h>
+#include <explore.h>
+#include <gbfeat.h>
+#include <gbftdef.h>
+#include <edutil.h>
+#include <alignmgr2.h>
+#include <asn2gnbi.h>
+
+#ifdef WIN_MAC
+#if __profile__
+#include <Profiler.h>
+#endif
+#endif
+
+/* ordering arrays for qualifiers and note components */
+
+static FtQualType feat_qual_order [] = {
+ FTQUAL_partial,
+ FTQUAL_gene,
+
+ FTQUAL_locus_tag,
+ FTQUAL_gene_syn_refseq,
+
+ FTQUAL_gene_allele,
+
+ FTQUAL_operon,
+
+ FTQUAL_product,
+
+ FTQUAL_prot_EC_number,
+ FTQUAL_prot_activity,
+
+ FTQUAL_standard_name,
+ FTQUAL_coded_by,
+ FTQUAL_derived_from,
+
+ FTQUAL_prot_name,
+ FTQUAL_region_name,
+ FTQUAL_bond_type,
+ FTQUAL_site_type,
+ FTQUAL_sec_str_type,
+ FTQUAL_heterogen,
+
+ FTQUAL_note,
+ FTQUAL_citation,
+
+ FTQUAL_number,
+
+ FTQUAL_pseudo,
+ FTQUAL_selenocysteine,
+
+ FTQUAL_codon_start,
+
+ FTQUAL_anticodon,
+ FTQUAL_bound_moiety,
+ FTQUAL_clone,
+ FTQUAL_cons_splice,
+ FTQUAL_direction,
+ FTQUAL_function,
+ FTQUAL_evidence,
+ FTQUAL_exception,
+ FTQUAL_frequency,
+ FTQUAL_EC_number,
+ FTQUAL_gene_map,
+ FTQUAL_allele,
+ FTQUAL_map,
+ FTQUAL_mod_base,
+ FTQUAL_PCR_conditions,
+ FTQUAL_phenotype,
+ FTQUAL_rpt_family,
+ FTQUAL_rpt_type,
+ FTQUAL_rpt_unit,
+ FTQUAL_insertion_seq,
+ FTQUAL_transposon,
+ FTQUAL_usedin,
+
+ FTQUAL_illegal_qual,
+
+ FTQUAL_replace,
+
+ FTQUAL_transl_except,
+ FTQUAL_transl_table,
+ FTQUAL_codon,
+ FTQUAL_organism,
+ FTQUAL_label,
+ FTQUAL_cds_product,
+ FTQUAL_protein_id,
+ FTQUAL_transcript_id,
+ FTQUAL_db_xref,
+ FTQUAL_gene_xref,
+ FTQUAL_translation,
+ FTQUAL_transcription,
+ FTQUAL_peptide,
+ (FtQualType) 0
+};
+
+/*
+prot_names after seqfeat_note - gi|4210642|emb|AJ005084.1|HBVAJ5084
+prot_conflict after prot_desc - gi|61183|emb|V01135.1|PIVM02
+figure after prot_desc - gi|400553|gb|S64006.1|
+seqfeat_note after prot_desc - gi|431713|gb|L20354.1|STVPATPOLB
+ but prot_desc after seqfeat_note - AF252556.1
+prot_names after figure - gi|234022|gb|S56149.1|S56149
+seqfeat_note after prot_conflict after figure - gi|234046|gb|S51392.1|S51392
+prot_method after prot_comment (descriptor) after prot_note after prot_desc
+region after seqfeat_note - gi|6554164|gb|AF043644.3|AF043644
+prot_desc after prot_names - gi|6581069|gb|AF202541.1|AF202541 - cannot do !!!
+gene_syn after gene_desc - gi|3386543|gb|AF079528.1|AF079528
+pseudo after note - gi|6598562|gb|AC006419.3|AC006419
+*/
+
+static FtQualType feat_note_order [] = {
+ FTQUAL_transcript_id_note, /* !!! remove October 15, 2003 !!! */
+ FTQUAL_gene_desc,
+ FTQUAL_gene_syn,
+ FTQUAL_trna_codons,
+ FTQUAL_encodes,
+ FTQUAL_prot_desc,
+ FTQUAL_prot_note,
+ FTQUAL_prot_comment,
+ FTQUAL_prot_method,
+ FTQUAL_figure,
+ FTQUAL_maploc,
+ FTQUAL_prot_conflict,
+ FTQUAL_prot_missing,
+ FTQUAL_seqfeat_note,
+ FTQUAL_exception_note,
+ FTQUAL_region,
+ FTQUAL_selenocysteine_note,
+ FTQUAL_prot_names,
+ FTQUAL_bond,
+ FTQUAL_site,
+ FTQUAL_rrna_its,
+ FTQUAL_xtra_prod_quals,
+ FTQUAL_modelev,
+ /* GO terms appear as own qualifiers in RefSeq records, Sequin or Dump mode */
+ FTQUAL_go_component,
+ FTQUAL_go_function,
+ FTQUAL_go_process,
+ (FtQualType) 0
+};
+
+typedef struct featurqual {
+ CharPtr name;
+ QualType qualclass;
+} FeaturQual, PNTR FeaturQualPtr;
+
+static FeaturQual asn2gnbk_featur_quals [ASN2GNBK_TOTAL_FEATUR] = {
+ { "", Qual_class_ignore },
+ { "allele", Qual_class_quote },
+ { "anticodon", Qual_class_anti_codon },
+ { "bond", Qual_class_bond },
+ { "bond_type", Qual_class_bond },
+ { "bound_moiety", Qual_class_quote },
+ { "product", Qual_class_string },
+ { "citation", Qual_class_pubset },
+ { "clone", Qual_class_quote },
+ { "coded_by", Qual_class_seq_loc },
+ { "codon", Qual_class_codon },
+ { "codon_start", Qual_class_int },
+ { "cons_splice", Qual_class_consplice },
+ { "db_xref", Qual_class_db_xref },
+ { "derived_from", Qual_class_seq_loc },
+ { "direction", Qual_class_L_R_B },
+ { "EC_number", Qual_class_EC_quote },
+ { "encodes", Qual_class_encodes },
+ { "evidence", Qual_class_evidence },
+ { "exception", Qual_class_string },
+ { "exception_note", Qual_class_string },
+ { "figure", Qual_class_string },
+ { "frequency", Qual_class_quote },
+ { "function", Qual_class_quote },
+ { "gene", Qual_class_sgml },
+ { "gene_desc", Qual_class_string },
+ { "allele", Qual_class_string },
+ { "map", Qual_class_string },
+ { "gene_syn", Qual_class_gene_syn },
+ { "synonym", Qual_class_gene_syn },
+ { "gene_note", Qual_class_string },
+ { "db_xref", Qual_class_db_xref },
+ { "go_component", Qual_class_go },
+ { "go_function", Qual_class_go },
+ { "go_process", Qual_class_go },
+ { "heterogen", Qual_class_string },
+ { "illegal", Qual_class_illegal },
+ { "insertion_seq", Qual_class_quote },
+ { "label", Qual_class_label },
+ { "locus_tag", Qual_class_locus_tag },
+ { "map", Qual_class_quote },
+ { "maploc", Qual_class_string },
+ { "mod_base", Qual_class_noquote },
+ { "model_evidence", Qual_class_model_ev },
+ { "note", Qual_class_note },
+ { "number", Qual_class_number },
+ { "operon", Qual_class_quote },
+ { "organism", Qual_class_quote },
+ { "partial", Qual_class_boolean },
+ { "PCR_conditions", Qual_class_quote },
+ { "peptide", Qual_class_peptide },
+ { "phenotype", Qual_class_quote },
+ { "product", Qual_class_product },
+ { "product", Qual_class_quote },
+ { "function", Qual_class_valnode },
+ { "prot_comment", Qual_class_string },
+ { "EC_number", Qual_class_EC_valnode },
+ { "prot_note", Qual_class_string },
+ { "prot_method", Qual_class_method },
+ { "prot_conflict", Qual_class_string },
+ { "prot_desc", Qual_class_string },
+ { "prot_missing", Qual_class_string },
+ { "name", Qual_class_tilde },
+ { "prot_names", Qual_class_protnames },
+ { "protein_id", Qual_class_seq_id },
+ { "pseudo", Qual_class_boolean },
+ { "region", Qual_class_region },
+ { "region_name", Qual_class_string },
+ { "replace", Qual_class_replace },
+ { "rpt_family", Qual_class_quote },
+ { "rpt_type", Qual_class_rpt },
+ { "rpt_unit", Qual_class_rpt_unit },
+ { "rrna_its", Qual_class_its },
+ { "sec_str_type", Qual_class_sec_str },
+ { "selenocysteine", Qual_class_boolean },
+ { "selenocysteine", Qual_class_string },
+ { "seqfeat_note", Qual_class_string },
+ { "site", Qual_class_site },
+ { "site_type", Qual_class_site },
+ { "standard_name", Qual_class_quote },
+ { "transcription", Qual_class_transcription },
+ { "transcript_id", Qual_class_seq_id },
+ { "tscpt_id_note", Qual_class_seq_id }, /* !!! remove October 15, 2003 !!! */
+ { "transl_except", Qual_class_code_break },
+ { "transl_table", Qual_class_int },
+ { "translation", Qual_class_translation },
+ { "transposon", Qual_class_quote },
+ { "trna_aa", Qual_class_ignore },
+ { "trna_codons", Qual_class_trna_codons },
+ { "usedin", Qual_class_paren },
+ { "xtra_products", Qual_class_xtraprds }
+};
+
+
+typedef struct qualfeatur {
+ CharPtr name;
+ FtQualType featurclass;
+} QualFeatur, PNTR QualFeaturPtr;
+
+#define NUM_GB_QUALS 26
+
+static QualFeatur qualToFeature [NUM_GB_QUALS] = {
+ { "allele", FTQUAL_allele },
+ { "bound_moiety", FTQUAL_bound_moiety },
+ { "clone", FTQUAL_clone },
+ { "codon", FTQUAL_codon },
+ { "cons_splice", FTQUAL_cons_splice },
+ { "direction", FTQUAL_direction },
+ { "EC_number", FTQUAL_EC_number },
+ { "frequency", FTQUAL_frequency },
+ { "function", FTQUAL_function },
+ { "insertion_seq", FTQUAL_insertion_seq },
+ { "label", FTQUAL_label },
+ { "map", FTQUAL_map },
+ { "mod_base", FTQUAL_mod_base },
+ { "number", FTQUAL_number },
+ { "operon", FTQUAL_operon },
+ { "organism", FTQUAL_organism },
+ { "PCR_conditions", FTQUAL_PCR_conditions },
+ { "phenotype", FTQUAL_phenotype },
+ { "product", FTQUAL_product_quals },
+ { "replace", FTQUAL_replace },
+ { "rpt_family", FTQUAL_rpt_family },
+ { "rpt_type", FTQUAL_rpt_type },
+ { "rpt_unit", FTQUAL_rpt_unit },
+ { "standard_name", FTQUAL_standard_name },
+ { "transposon", FTQUAL_transposon },
+ { "usedin", FTQUAL_usedin }
+};
+
+static Int2 GbqualToFeaturIndex (
+ CharPtr qualname
+)
+
+{
+ Int2 L, R, mid;
+
+ if (qualname == NULL || *qualname == '\0') return 0;
+
+ L = 0;
+ R = NUM_GB_QUALS - 1;
+
+ while (L < R) {
+ mid = (L + R) / 2;
+ if (StringICmp (qualToFeature [mid].name, qualname) < 0) {
+ L = mid + 1;
+ } else {
+ R = mid;
+ }
+ }
+
+ if (StringICmp (qualToFeature [R].name, qualname) == 0) {
+ return qualToFeature [R].featurclass;
+ }
+
+ return 0;
+}
+
+#define NUM_ILLEGAL_QUALS 14
+
+static FeaturQual illegalGbqualList [NUM_ILLEGAL_QUALS] = {
+ { "anticodon", Qual_class_noquote },
+ { "citation", Qual_class_noquote },
+ { "codon_start", Qual_class_noquote },
+ { "db_xref", Qual_class_quote },
+ { "evidence", Qual_class_noquote },
+ { "exception", Qual_class_quote },
+ { "gene", Qual_class_quote },
+ { "note", Qual_class_quote },
+ { "protein_id", Qual_class_quote },
+ { "pseudo", Qual_class_noquote },
+ { "transcript_id", Qual_class_quote },
+ { "transl_except", Qual_class_noquote },
+ { "transl_table", Qual_class_noquote },
+ { "translation", Qual_class_quote },
+};
+
+static Int2 IllegalGbqualToClass (
+ CharPtr qualname
+)
+
+{
+ Int2 L, R, mid;
+
+ if (qualname == NULL || *qualname == '\0') return 0;
+
+ L = 0;
+ R = NUM_ILLEGAL_QUALS - 1;
+
+ while (L < R) {
+ mid = (L + R) / 2;
+ if (StringICmp (illegalGbqualList [mid].name, qualname) < 0) {
+ L = mid + 1;
+ } else {
+ R = mid;
+ }
+ }
+
+ if (StringICmp (illegalGbqualList [R].name, qualname) == 0) {
+ return illegalGbqualList [R].qualclass;
+ }
+
+ return 0;
+}
+
+static CharPtr trnaList [] = {
+ "tRNA-Gap",
+ "tRNA-Ala",
+ "tRNA-Asx",
+ "tRNA-Cys",
+ "tRNA-Asp",
+ "tRNA-Glu",
+ "tRNA-Phe",
+ "tRNA-Gly",
+ "tRNA-His",
+ "tRNA-Ile",
+ "tRNA-Lys",
+ "tRNA-Leu",
+ "tRNA-Met",
+ "tRNA-Asn",
+ "tRNA-Pro",
+ "tRNA-Gln",
+ "tRNA-Arg",
+ "tRNA-Ser",
+ "tRNA-Thr",
+ "tRNA-Sec",
+ "tRNA-Val",
+ "tRNA-Trp",
+ "tRNA-OTHER",
+ "tRNA-Tyr",
+ "tRNA-Glx",
+ "tRNA-TERM",
+ NULL
+};
+
+static CharPtr evidenceText [] = {
+ NULL, "experimental", "not_experimental"
+};
+
+NLM_EXTERN CharPtr secStrText [] = {
+ NULL, "helix", "sheet", "turn"
+};
+
+static CharPtr oops = "?";
+
+static CharPtr SeqCodeNameGet (
+ SeqCodeTablePtr table,
+ Uint1 residue
+)
+
+{
+ Uint1 index;
+
+ if (table != NULL) {
+ index = residue - table->start_at;
+ if ( /*index >= 0 && */ index < table->num) {
+ return (table->names) [index];
+ }
+ }
+
+ return oops;
+}
+
+NLM_EXTERN CharPtr Get3LetterSymbol (
+ IntAsn2gbJobPtr ajp,
+ Uint1 seq_code,
+ SeqCodeTablePtr table,
+ Uint1 residue
+)
+
+{
+ Uint1 code = Seq_code_ncbieaa;
+ Int2 index;
+ Uint1 new_residue;
+ CharPtr ptr;
+ CharPtr retval = NULL;
+ SeqMapTablePtr smtp;
+ SeqCodeTablePtr table_3aa;
+
+ if (residue == 42) { /* stop codon in NCBIeaa */
+ retval = "TERM";
+ return retval;
+ }
+
+ if (ajp->flags.iupacaaOnly) {
+ code = Seq_code_iupacaa;
+ } else {
+ code = Seq_code_ncbieaa;
+ }
+
+ if (seq_code != code) {
+ /* if code and seq_code are identical, then smtp is NULL?? */
+ smtp = SeqMapTableFind (code, seq_code);
+ new_residue = SeqMapTableConvert (smtp, residue);
+ } else {
+ new_residue = residue;
+ }
+
+ /* The following looks for non-symbols (255) and "Undetermined" (88) */
+ if ((int) new_residue == 255 || (int) new_residue == 88) {
+ retval = "OTHER";
+ return retval;
+ } else {
+ ptr = SeqCodeNameGet (table, residue);
+ table_3aa=SeqCodeTableFind (Seq_code_iupacaa3);
+ if (ptr != NULL && table_3aa != NULL) {
+ for (index=0; index < (int) table_3aa->num; index++) {
+ if (StringCmp(ptr, (table_3aa->names) [index]) == 0) {
+ retval = (table_3aa->symbols) [index];
+ return retval;
+ }
+ }
+ }
+ }
+
+ retval = "OTHER";
+ return retval;
+}
+
+static Boolean MatchCit (
+ ValNodePtr ppr,
+ RefBlockPtr rbp
+)
+
+{
+ Char buf [121];
+ size_t len;
+ Int4 uid;
+ ValNodePtr vnp;
+
+ if (ppr == NULL || rbp == NULL) return FALSE;
+ switch (ppr->choice) {
+ case PUB_Muid :
+ uid = ppr->data.intvalue;
+ if (rbp->muid == uid) return TRUE;
+ break;
+ case PUB_PMid :
+ uid = ppr->data.intvalue;
+ if (rbp->pmid == uid) return TRUE;
+ break;
+ case PUB_Equiv :
+ for (vnp = (ValNodePtr) ppr->data.ptrvalue; vnp != NULL; vnp = vnp->next) {
+ if (MatchCit (vnp, rbp)) return TRUE;
+ }
+ break;
+ default :
+ PubLabelUnique (ppr, buf, sizeof (buf) - 1, OM_LABEL_CONTENT, TRUE);
+ len = StringLen (buf);
+ if (len > 0 && buf [len - 1] == '>') {
+ buf [len - 1] = '\0';
+ len--;
+ }
+ len = MIN (len, StringLen (rbp->uniquestr));
+ if (StringNICmp (rbp->uniquestr, buf, len) == 0) return TRUE;
+ break;
+ }
+ return FALSE;
+}
+
+NLM_EXTERN Int2 MatchRef (
+ ValNodePtr ppr,
+ RefBlockPtr PNTR rbpp,
+ Int2 numReferences
+)
+
+{
+ Int2 j;
+ RefBlockPtr rbp;
+
+ if (ppr == NULL || rbpp == NULL) return 0;
+
+ for (j = 0; j < numReferences; j++) {
+ rbp = rbpp [j];
+ if (rbp == NULL) continue;
+ if (MatchCit (ppr, rbp)) return j + 1;
+ }
+ return 0;
+}
+
+/* taken from asn2ff4.c */
+
+static Boolean LookForFuzz (SeqLocPtr head)
+{
+ Boolean retval=FALSE;
+ IntFuzzPtr ifp;
+ PackSeqPntPtr pspp;
+ SeqIntPtr sip;
+ SeqLocPtr slp;
+ SeqPntPtr spp;
+
+ if (head == NULL)
+ return retval;
+
+ slp=NULL;
+ while ((slp = SeqLocFindNext(head, slp)) != NULL)
+ {
+ switch (slp->choice)
+ {
+ case SEQLOC_INT:
+ sip = (SeqIntPtr)(slp->data.ptrvalue);
+ ifp = sip->if_from;
+ if (ifp != NULL)
+ {
+ if (ifp->choice == 4)
+ {
+ if (ifp->a != 0)
+ retval=TRUE;
+ }
+ else
+ retval = TRUE;
+ }
+ ifp = sip->if_to;
+ if (ifp != NULL)
+ {
+ if (ifp->choice == 4)
+ {
+ if (ifp->a != 0)
+ retval=TRUE;
+ }
+ else
+ retval = TRUE;
+ }
+ break;
+ case SEQLOC_PNT:
+ spp = (SeqPntPtr)(slp->data.ptrvalue);
+ ifp = spp->fuzz;
+ if (ifp != NULL)
+ {
+ if (ifp->choice == 4)
+ {
+ if (ifp->a != 0)
+ retval=TRUE;
+ }
+ else
+ retval = TRUE;
+ }
+ break;
+ case SEQLOC_PACKED_PNT:
+ pspp = (PackSeqPntPtr)(slp->data.ptrvalue);
+ ifp = pspp->fuzz;
+ if (ifp != NULL)
+ {
+ if (ifp->choice == 4)
+ {
+ if (ifp->a != 0)
+ retval=TRUE;
+ }
+ else
+ retval = TRUE;
+ }
+ break;
+ default:
+ break;
+ }
+ if (retval == TRUE)
+ break;
+ }
+ return retval;
+}
+
+NLM_EXTERN CharPtr bondList [] = {
+ NULL,
+ "disulfide",
+ "thiolester",
+ "xlink",
+ "thioether",
+ "unclassified"
+};
+
+NLM_EXTERN CharPtr siteList [] = {
+ NULL,
+ "active",
+ "binding",
+ "cleavage",
+ "inhibit",
+ "modified",
+ "glycosylation",
+ "myristoylation",
+ "mutagenized",
+ "metal-binding",
+ "phosphorylation",
+ "acetylation",
+ "amidation",
+ "methylation",
+ "hydroxylation",
+ "sulfatation",
+ "oxidative-deamination",
+ "pyrrolidone-carboxylic-acid",
+ "gamma-carboxyglutamic-acid",
+ "blocked",
+ "lipid-binding",
+ "np-binding",
+ "DNA binding",
+ "signal-peptide",
+ "transit-peptide",
+ "transmembrane-region",
+ "unclassified"
+};
+
+static CharPtr conflict_msg =
+"Protein sequence is in conflict with the conceptual translation";
+
+static CharPtr no_protein_msg =
+"Coding region translates with internal stops";
+
+/**/
+/* s_DisplayQVP () -- Displays the strings in a QVP structure. */
+/* This is a debugging function only. */
+/**/
+
+static void s_DisplayQVP(QualValPtr qvp, Uint1Ptr notetbl)
+{
+ Int2 j;
+ Int2 jdx;
+
+ fprintf(stderr,"\n");
+ for (j = 0, jdx = notetbl [j]; jdx != 0; j++, jdx = notetbl [j])
+ {
+ if (((int) qvp[jdx].str != 0x1000000) &&
+ ((int) qvp[jdx].str != 0x1) &&
+ ((int) qvp[jdx].str != 0xb) &&
+ (qvp[jdx].str != NULL))
+ fprintf(stderr, "%d\t%-25s %s\n", j, asn2gnbk_featur_quals[jdx].name,
+ qvp[jdx].str);
+ else
+ fprintf(stderr, "%d\t%-25s %s\n", j, asn2gnbk_featur_quals[jdx].name,
+ "NULL");
+ }
+}
+
+static Boolean NotInGeneSyn (
+ CharPtr str,
+ ValNodePtr gene_syn)
+
+{
+ CharPtr syn;
+ ValNodePtr vnp;
+
+ for (vnp = gene_syn; vnp != NULL; vnp = vnp->next) {
+ syn = (CharPtr) vnp->data.ptrvalue;
+ if (! StringHasNoText (syn)) {
+ if (StringICmp (str, syn) == 0) return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+typedef struct valqualstruc {
+ Uint2 featdef;
+ FtQualType ftqual;
+} ValQual, PNTR ValQualPtr;
+
+/*
+ WARNING - This list MUST be kept sorted in FEATDEF order as the primary
+ key, and within a FEATDEF group sorted by FTQUAL as the secondary key
+*/
+
+static ValQual legalGbqualList [] = {
+
+ { FEATDEF_GENE , FTQUAL_allele },
+ { FEATDEF_GENE , FTQUAL_function },
+ { FEATDEF_GENE , FTQUAL_label },
+ { FEATDEF_GENE , FTQUAL_map },
+ { FEATDEF_GENE , FTQUAL_operon },
+ { FEATDEF_GENE , FTQUAL_phenotype },
+ { FEATDEF_GENE , FTQUAL_product },
+ { FEATDEF_GENE , FTQUAL_standard_name },
+ { FEATDEF_GENE , FTQUAL_usedin },
+
+ { FEATDEF_CDS , FTQUAL_allele },
+ { FEATDEF_CDS , FTQUAL_codon },
+ { FEATDEF_CDS , FTQUAL_label },
+ { FEATDEF_CDS , FTQUAL_map },
+ { FEATDEF_CDS , FTQUAL_number },
+ { FEATDEF_CDS , FTQUAL_operon },
+ { FEATDEF_CDS , FTQUAL_standard_name },
+ { FEATDEF_CDS , FTQUAL_usedin },
+
+ { FEATDEF_PROT , FTQUAL_product },
+
+ { FEATDEF_preRNA , FTQUAL_allele },
+ { FEATDEF_preRNA , FTQUAL_function },
+ { FEATDEF_preRNA , FTQUAL_label },
+ { FEATDEF_preRNA , FTQUAL_map },
+ { FEATDEF_preRNA , FTQUAL_operon },
+ { FEATDEF_preRNA , FTQUAL_product },
+ { FEATDEF_preRNA , FTQUAL_standard_name },
+ { FEATDEF_preRNA , FTQUAL_usedin },
+
+ { FEATDEF_mRNA , FTQUAL_allele },
+ { FEATDEF_mRNA , FTQUAL_function },
+ { FEATDEF_mRNA , FTQUAL_label },
+ { FEATDEF_mRNA , FTQUAL_map },
+ { FEATDEF_mRNA , FTQUAL_operon },
+ { FEATDEF_mRNA , FTQUAL_product },
+ { FEATDEF_mRNA , FTQUAL_standard_name },
+ { FEATDEF_mRNA , FTQUAL_usedin },
+
+ { FEATDEF_tRNA , FTQUAL_allele },
+ { FEATDEF_tRNA , FTQUAL_function },
+ { FEATDEF_tRNA , FTQUAL_label },
+ { FEATDEF_tRNA , FTQUAL_map },
+ { FEATDEF_tRNA , FTQUAL_product },
+ { FEATDEF_tRNA , FTQUAL_standard_name },
+ { FEATDEF_tRNA , FTQUAL_usedin },
+
+ { FEATDEF_rRNA , FTQUAL_allele },
+ { FEATDEF_rRNA , FTQUAL_function },
+ { FEATDEF_rRNA , FTQUAL_label },
+ { FEATDEF_rRNA , FTQUAL_map },
+ { FEATDEF_rRNA , FTQUAL_product },
+ { FEATDEF_rRNA , FTQUAL_standard_name },
+ { FEATDEF_rRNA , FTQUAL_usedin },
+
+ { FEATDEF_snRNA , FTQUAL_allele },
+ { FEATDEF_snRNA , FTQUAL_function },
+ { FEATDEF_snRNA , FTQUAL_label },
+ { FEATDEF_snRNA , FTQUAL_map },
+ { FEATDEF_snRNA , FTQUAL_product },
+ { FEATDEF_snRNA , FTQUAL_standard_name },
+ { FEATDEF_snRNA , FTQUAL_usedin },
+
+ { FEATDEF_scRNA , FTQUAL_allele },
+ { FEATDEF_scRNA , FTQUAL_function },
+ { FEATDEF_scRNA , FTQUAL_label },
+ { FEATDEF_scRNA , FTQUAL_map },
+ { FEATDEF_scRNA , FTQUAL_product },
+ { FEATDEF_scRNA , FTQUAL_standard_name },
+ { FEATDEF_scRNA , FTQUAL_usedin },
+
+ { FEATDEF_otherRNA , FTQUAL_allele },
+ { FEATDEF_otherRNA , FTQUAL_function },
+ { FEATDEF_otherRNA , FTQUAL_label },
+ { FEATDEF_otherRNA , FTQUAL_map },
+ { FEATDEF_otherRNA , FTQUAL_operon },
+ { FEATDEF_otherRNA , FTQUAL_product },
+ { FEATDEF_otherRNA , FTQUAL_standard_name },
+ { FEATDEF_otherRNA , FTQUAL_usedin },
+
+ { FEATDEF_attenuator , FTQUAL_allele },
+ { FEATDEF_attenuator , FTQUAL_label },
+ { FEATDEF_attenuator , FTQUAL_map },
+ { FEATDEF_attenuator , FTQUAL_operon },
+ { FEATDEF_attenuator , FTQUAL_phenotype },
+ { FEATDEF_attenuator , FTQUAL_usedin },
+
+ { FEATDEF_C_region , FTQUAL_allele },
+ { FEATDEF_C_region , FTQUAL_label },
+ { FEATDEF_C_region , FTQUAL_map },
+ { FEATDEF_C_region , FTQUAL_product },
+ { FEATDEF_C_region , FTQUAL_standard_name },
+ { FEATDEF_C_region , FTQUAL_usedin },
+
+ { FEATDEF_CAAT_signal , FTQUAL_allele },
+ { FEATDEF_CAAT_signal , FTQUAL_label },
+ { FEATDEF_CAAT_signal , FTQUAL_map },
+ { FEATDEF_CAAT_signal , FTQUAL_usedin },
+
+ { FEATDEF_Imp_CDS , FTQUAL_codon },
+ { FEATDEF_Imp_CDS , FTQUAL_EC_number },
+ { FEATDEF_Imp_CDS , FTQUAL_function },
+ { FEATDEF_Imp_CDS , FTQUAL_label },
+ { FEATDEF_Imp_CDS , FTQUAL_map },
+ { FEATDEF_Imp_CDS , FTQUAL_number },
+ { FEATDEF_Imp_CDS , FTQUAL_operon },
+ { FEATDEF_Imp_CDS , FTQUAL_product },
+ { FEATDEF_Imp_CDS , FTQUAL_standard_name },
+ { FEATDEF_Imp_CDS , FTQUAL_usedin },
+
+ { FEATDEF_conflict , FTQUAL_allele },
+ { FEATDEF_conflict , FTQUAL_label },
+ { FEATDEF_conflict , FTQUAL_map },
+ { FEATDEF_conflict , FTQUAL_replace },
+ { FEATDEF_conflict , FTQUAL_usedin },
+
+ { FEATDEF_D_loop , FTQUAL_allele },
+ { FEATDEF_D_loop , FTQUAL_label },
+ { FEATDEF_D_loop , FTQUAL_map },
+ { FEATDEF_D_loop , FTQUAL_usedin },
+
+ { FEATDEF_D_segment , FTQUAL_allele },
+ { FEATDEF_D_segment , FTQUAL_label },
+ { FEATDEF_D_segment , FTQUAL_map },
+ { FEATDEF_D_segment , FTQUAL_product },
+ { FEATDEF_D_segment , FTQUAL_standard_name },
+ { FEATDEF_D_segment , FTQUAL_usedin },
+
+ { FEATDEF_enhancer , FTQUAL_allele },
+ { FEATDEF_enhancer , FTQUAL_label },
+ { FEATDEF_enhancer , FTQUAL_map },
+ { FEATDEF_enhancer , FTQUAL_standard_name },
+ { FEATDEF_enhancer , FTQUAL_usedin },
+
+ { FEATDEF_exon , FTQUAL_allele },
+ { FEATDEF_exon , FTQUAL_EC_number },
+ { FEATDEF_exon , FTQUAL_function },
+ { FEATDEF_exon , FTQUAL_label },
+ { FEATDEF_exon , FTQUAL_map },
+ { FEATDEF_exon , FTQUAL_number },
+ { FEATDEF_exon , FTQUAL_product },
+ { FEATDEF_exon , FTQUAL_standard_name },
+ { FEATDEF_exon , FTQUAL_usedin },
+
+ { FEATDEF_GC_signal , FTQUAL_allele },
+ { FEATDEF_GC_signal , FTQUAL_label },
+ { FEATDEF_GC_signal , FTQUAL_map },
+ { FEATDEF_GC_signal , FTQUAL_usedin },
+
+ { FEATDEF_iDNA , FTQUAL_allele },
+ { FEATDEF_iDNA , FTQUAL_function },
+ { FEATDEF_iDNA , FTQUAL_label },
+ { FEATDEF_iDNA , FTQUAL_map },
+ { FEATDEF_iDNA , FTQUAL_number },
+ { FEATDEF_iDNA , FTQUAL_standard_name },
+ { FEATDEF_iDNA , FTQUAL_usedin },
+
+ { FEATDEF_intron , FTQUAL_allele },
+ { FEATDEF_intron , FTQUAL_cons_splice },
+ { FEATDEF_intron , FTQUAL_function },
+ { FEATDEF_intron , FTQUAL_label },
+ { FEATDEF_intron , FTQUAL_map },
+ { FEATDEF_intron , FTQUAL_number },
+ { FEATDEF_intron , FTQUAL_standard_name },
+ { FEATDEF_intron , FTQUAL_usedin },
+
+ { FEATDEF_J_segment , FTQUAL_allele },
+ { FEATDEF_J_segment , FTQUAL_label },
+ { FEATDEF_J_segment , FTQUAL_map },
+ { FEATDEF_J_segment , FTQUAL_product },
+ { FEATDEF_J_segment , FTQUAL_standard_name },
+ { FEATDEF_J_segment , FTQUAL_usedin },
+
+ { FEATDEF_LTR , FTQUAL_allele },
+ { FEATDEF_LTR , FTQUAL_function },
+ { FEATDEF_LTR , FTQUAL_label },
+ { FEATDEF_LTR , FTQUAL_map },
+ { FEATDEF_LTR , FTQUAL_standard_name },
+ { FEATDEF_LTR , FTQUAL_usedin },
+
+ { FEATDEF_mat_peptide , FTQUAL_allele },
+ { FEATDEF_mat_peptide , FTQUAL_EC_number },
+ { FEATDEF_mat_peptide , FTQUAL_function },
+ { FEATDEF_mat_peptide , FTQUAL_label },
+ { FEATDEF_mat_peptide , FTQUAL_map },
+ { FEATDEF_mat_peptide , FTQUAL_product },
+ { FEATDEF_mat_peptide , FTQUAL_standard_name },
+ { FEATDEF_mat_peptide , FTQUAL_usedin },
+
+ { FEATDEF_misc_binding , FTQUAL_allele },
+ { FEATDEF_misc_binding , FTQUAL_bound_moiety },
+ { FEATDEF_misc_binding , FTQUAL_function },
+ { FEATDEF_misc_binding , FTQUAL_label },
+ { FEATDEF_misc_binding , FTQUAL_map },
+ { FEATDEF_misc_binding , FTQUAL_usedin },
+
+ { FEATDEF_misc_difference , FTQUAL_allele },
+ { FEATDEF_misc_difference , FTQUAL_clone },
+ { FEATDEF_misc_difference , FTQUAL_label },
+ { FEATDEF_misc_difference , FTQUAL_map },
+ { FEATDEF_misc_difference , FTQUAL_phenotype },
+ { FEATDEF_misc_difference , FTQUAL_replace },
+ { FEATDEF_misc_difference , FTQUAL_standard_name },
+ { FEATDEF_misc_difference , FTQUAL_usedin },
+
+ { FEATDEF_misc_feature , FTQUAL_allele },
+ { FEATDEF_misc_feature , FTQUAL_function },
+ { FEATDEF_misc_feature , FTQUAL_label },
+ { FEATDEF_misc_feature , FTQUAL_map },
+ { FEATDEF_misc_feature , FTQUAL_number },
+ { FEATDEF_misc_feature , FTQUAL_phenotype },
+ { FEATDEF_misc_feature , FTQUAL_product },
+ { FEATDEF_misc_feature , FTQUAL_standard_name },
+ { FEATDEF_misc_feature , FTQUAL_usedin },
+
+ { FEATDEF_misc_recomb , FTQUAL_allele },
+ { FEATDEF_misc_recomb , FTQUAL_label },
+ { FEATDEF_misc_recomb , FTQUAL_map },
+ { FEATDEF_misc_recomb , FTQUAL_organism },
+ { FEATDEF_misc_recomb , FTQUAL_standard_name },
+ { FEATDEF_misc_recomb , FTQUAL_usedin },
+
+ { FEATDEF_misc_signal , FTQUAL_allele },
+ { FEATDEF_misc_signal , FTQUAL_function },
+ { FEATDEF_misc_signal , FTQUAL_label },
+ { FEATDEF_misc_signal , FTQUAL_map },
+ { FEATDEF_misc_signal , FTQUAL_operon },
+ { FEATDEF_misc_signal , FTQUAL_phenotype },
+ { FEATDEF_misc_signal , FTQUAL_standard_name },
+ { FEATDEF_misc_signal , FTQUAL_usedin },
+
+ { FEATDEF_misc_structure , FTQUAL_allele },
+ { FEATDEF_misc_structure , FTQUAL_function },
+ { FEATDEF_misc_structure , FTQUAL_label },
+ { FEATDEF_misc_structure , FTQUAL_map },
+ { FEATDEF_misc_structure , FTQUAL_standard_name },
+ { FEATDEF_misc_structure , FTQUAL_usedin },
+
+ { FEATDEF_modified_base , FTQUAL_allele },
+ { FEATDEF_modified_base , FTQUAL_frequency },
+ { FEATDEF_modified_base , FTQUAL_label },
+ { FEATDEF_modified_base , FTQUAL_map },
+ { FEATDEF_modified_base , FTQUAL_mod_base },
+ { FEATDEF_modified_base , FTQUAL_usedin },
+
+ { FEATDEF_N_region , FTQUAL_allele },
+ { FEATDEF_N_region , FTQUAL_label },
+ { FEATDEF_N_region , FTQUAL_map },
+ { FEATDEF_N_region , FTQUAL_product },
+ { FEATDEF_N_region , FTQUAL_standard_name },
+ { FEATDEF_N_region , FTQUAL_usedin },
+
+ { FEATDEF_old_sequence , FTQUAL_allele },
+ { FEATDEF_old_sequence , FTQUAL_label },
+ { FEATDEF_old_sequence , FTQUAL_map },
+ { FEATDEF_old_sequence , FTQUAL_replace },
+ { FEATDEF_old_sequence , FTQUAL_usedin },
+
+ { FEATDEF_polyA_signal , FTQUAL_allele },
+ { FEATDEF_polyA_signal , FTQUAL_label },
+ { FEATDEF_polyA_signal , FTQUAL_map },
+ { FEATDEF_polyA_signal , FTQUAL_usedin },
+
+ { FEATDEF_polyA_site , FTQUAL_allele },
+ { FEATDEF_polyA_site , FTQUAL_label },
+ { FEATDEF_polyA_site , FTQUAL_map },
+ { FEATDEF_polyA_site , FTQUAL_usedin },
+
+ { FEATDEF_prim_transcript , FTQUAL_allele },
+ { FEATDEF_prim_transcript , FTQUAL_function },
+ { FEATDEF_prim_transcript , FTQUAL_label },
+ { FEATDEF_prim_transcript , FTQUAL_map },
+ { FEATDEF_prim_transcript , FTQUAL_operon },
+ { FEATDEF_prim_transcript , FTQUAL_standard_name },
+ { FEATDEF_prim_transcript , FTQUAL_usedin },
+
+ { FEATDEF_primer_bind , FTQUAL_allele },
+ { FEATDEF_primer_bind , FTQUAL_label },
+ { FEATDEF_primer_bind , FTQUAL_map },
+ { FEATDEF_primer_bind , FTQUAL_PCR_conditions },
+ { FEATDEF_primer_bind , FTQUAL_standard_name },
+ { FEATDEF_primer_bind , FTQUAL_usedin },
+
+ { FEATDEF_promoter , FTQUAL_allele },
+ { FEATDEF_promoter , FTQUAL_function },
+ { FEATDEF_promoter , FTQUAL_label },
+ { FEATDEF_promoter , FTQUAL_map },
+ { FEATDEF_promoter , FTQUAL_operon },
+ { FEATDEF_promoter , FTQUAL_phenotype },
+ { FEATDEF_promoter , FTQUAL_standard_name },
+ { FEATDEF_promoter , FTQUAL_usedin },
+
+ { FEATDEF_protein_bind , FTQUAL_allele },
+ { FEATDEF_protein_bind , FTQUAL_bound_moiety },
+ { FEATDEF_protein_bind , FTQUAL_function },
+ { FEATDEF_protein_bind , FTQUAL_label },
+ { FEATDEF_protein_bind , FTQUAL_map },
+ { FEATDEF_protein_bind , FTQUAL_standard_name },
+ { FEATDEF_protein_bind , FTQUAL_usedin },
+
+ { FEATDEF_RBS , FTQUAL_allele },
+ { FEATDEF_RBS , FTQUAL_label },
+ { FEATDEF_RBS , FTQUAL_map },
+ { FEATDEF_RBS , FTQUAL_standard_name },
+ { FEATDEF_RBS , FTQUAL_usedin },
+
+ { FEATDEF_repeat_region , FTQUAL_allele },
+ { FEATDEF_repeat_region , FTQUAL_function },
+ { FEATDEF_repeat_region , FTQUAL_insertion_seq },
+ { FEATDEF_repeat_region , FTQUAL_label },
+ { FEATDEF_repeat_region , FTQUAL_map },
+ { FEATDEF_repeat_region , FTQUAL_rpt_family },
+ { FEATDEF_repeat_region , FTQUAL_rpt_type },
+ { FEATDEF_repeat_region , FTQUAL_rpt_unit },
+ { FEATDEF_repeat_region , FTQUAL_standard_name },
+ { FEATDEF_repeat_region , FTQUAL_transposon },
+ { FEATDEF_repeat_region , FTQUAL_usedin },
+
+ { FEATDEF_repeat_unit , FTQUAL_allele },
+ { FEATDEF_repeat_unit , FTQUAL_function },
+ { FEATDEF_repeat_unit , FTQUAL_label },
+ { FEATDEF_repeat_unit , FTQUAL_map },
+ { FEATDEF_repeat_unit , FTQUAL_rpt_family },
+ { FEATDEF_repeat_unit , FTQUAL_rpt_type },
+ { FEATDEF_repeat_unit , FTQUAL_usedin },
+
+ { FEATDEF_rep_origin , FTQUAL_allele },
+ { FEATDEF_rep_origin , FTQUAL_direction },
+ { FEATDEF_rep_origin , FTQUAL_label },
+ { FEATDEF_rep_origin , FTQUAL_map },
+ { FEATDEF_rep_origin , FTQUAL_standard_name },
+ { FEATDEF_rep_origin , FTQUAL_usedin },
+
+ { FEATDEF_S_region , FTQUAL_allele },
+ { FEATDEF_S_region , FTQUAL_label },
+ { FEATDEF_S_region , FTQUAL_map },
+ { FEATDEF_S_region , FTQUAL_product },
+ { FEATDEF_S_region , FTQUAL_standard_name },
+ { FEATDEF_S_region , FTQUAL_usedin },
+
+ { FEATDEF_satellite , FTQUAL_allele },
+ { FEATDEF_satellite , FTQUAL_label },
+ { FEATDEF_satellite , FTQUAL_map },
+ { FEATDEF_satellite , FTQUAL_rpt_family },
+ { FEATDEF_satellite , FTQUAL_rpt_type },
+ { FEATDEF_satellite , FTQUAL_rpt_unit },
+ { FEATDEF_satellite , FTQUAL_standard_name },
+ { FEATDEF_satellite , FTQUAL_usedin },
+
+ { FEATDEF_sig_peptide , FTQUAL_allele },
+ { FEATDEF_sig_peptide , FTQUAL_function },
+ { FEATDEF_sig_peptide , FTQUAL_label },
+ { FEATDEF_sig_peptide , FTQUAL_map },
+ { FEATDEF_sig_peptide , FTQUAL_product },
+ { FEATDEF_sig_peptide , FTQUAL_standard_name },
+ { FEATDEF_sig_peptide , FTQUAL_usedin },
+
+ { FEATDEF_stem_loop , FTQUAL_allele },
+ { FEATDEF_stem_loop , FTQUAL_function },
+ { FEATDEF_stem_loop , FTQUAL_label },
+ { FEATDEF_stem_loop , FTQUAL_map },
+ { FEATDEF_stem_loop , FTQUAL_operon },
+ { FEATDEF_stem_loop , FTQUAL_standard_name },
+ { FEATDEF_stem_loop , FTQUAL_usedin },
+
+ { FEATDEF_STS , FTQUAL_allele },
+ { FEATDEF_STS , FTQUAL_label },
+ { FEATDEF_STS , FTQUAL_map },
+ { FEATDEF_STS , FTQUAL_standard_name },
+ { FEATDEF_STS , FTQUAL_usedin },
+
+ { FEATDEF_TATA_signal , FTQUAL_allele },
+ { FEATDEF_TATA_signal , FTQUAL_label },
+ { FEATDEF_TATA_signal , FTQUAL_map },
+ { FEATDEF_TATA_signal , FTQUAL_usedin },
+
+ { FEATDEF_terminator , FTQUAL_allele },
+ { FEATDEF_terminator , FTQUAL_label },
+ { FEATDEF_terminator , FTQUAL_map },
+ { FEATDEF_terminator , FTQUAL_operon },
+ { FEATDEF_terminator , FTQUAL_standard_name },
+ { FEATDEF_terminator , FTQUAL_usedin },
+
+ { FEATDEF_transit_peptide , FTQUAL_allele },
+ { FEATDEF_transit_peptide , FTQUAL_function },
+ { FEATDEF_transit_peptide , FTQUAL_label },
+ { FEATDEF_transit_peptide , FTQUAL_map },
+ { FEATDEF_transit_peptide , FTQUAL_product },
+ { FEATDEF_transit_peptide , FTQUAL_standard_name },
+ { FEATDEF_transit_peptide , FTQUAL_usedin },
+
+ { FEATDEF_unsure , FTQUAL_allele },
+ { FEATDEF_unsure , FTQUAL_label },
+ { FEATDEF_unsure , FTQUAL_map },
+ { FEATDEF_unsure , FTQUAL_replace },
+ { FEATDEF_unsure , FTQUAL_usedin },
+
+ { FEATDEF_V_region , FTQUAL_allele },
+ { FEATDEF_V_region , FTQUAL_label },
+ { FEATDEF_V_region , FTQUAL_map },
+ { FEATDEF_V_region , FTQUAL_product },
+ { FEATDEF_V_region , FTQUAL_standard_name },
+ { FEATDEF_V_region , FTQUAL_usedin },
+
+ { FEATDEF_V_segment , FTQUAL_allele },
+ { FEATDEF_V_segment , FTQUAL_label },
+ { FEATDEF_V_segment , FTQUAL_map },
+ { FEATDEF_V_segment , FTQUAL_product },
+ { FEATDEF_V_segment , FTQUAL_standard_name },
+ { FEATDEF_V_segment , FTQUAL_usedin },
+
+ { FEATDEF_variation , FTQUAL_allele },
+ { FEATDEF_variation , FTQUAL_frequency },
+ { FEATDEF_variation , FTQUAL_label },
+ { FEATDEF_variation , FTQUAL_map },
+ { FEATDEF_variation , FTQUAL_phenotype },
+ { FEATDEF_variation , FTQUAL_product },
+ { FEATDEF_variation , FTQUAL_replace },
+ { FEATDEF_variation , FTQUAL_standard_name },
+ { FEATDEF_variation , FTQUAL_usedin },
+
+ { FEATDEF_3clip , FTQUAL_allele },
+ { FEATDEF_3clip , FTQUAL_function },
+ { FEATDEF_3clip , FTQUAL_label },
+ { FEATDEF_3clip , FTQUAL_map },
+ { FEATDEF_3clip , FTQUAL_standard_name },
+ { FEATDEF_3clip , FTQUAL_usedin },
+
+ { FEATDEF_3UTR , FTQUAL_allele },
+ { FEATDEF_3UTR , FTQUAL_function },
+ { FEATDEF_3UTR , FTQUAL_label },
+ { FEATDEF_3UTR , FTQUAL_map },
+ { FEATDEF_3UTR , FTQUAL_standard_name },
+ { FEATDEF_3UTR , FTQUAL_usedin },
+
+ { FEATDEF_5clip , FTQUAL_allele },
+ { FEATDEF_5clip , FTQUAL_function },
+ { FEATDEF_5clip , FTQUAL_label },
+ { FEATDEF_5clip , FTQUAL_map },
+ { FEATDEF_5clip , FTQUAL_standard_name },
+ { FEATDEF_5clip , FTQUAL_usedin },
+
+ { FEATDEF_5UTR , FTQUAL_allele },
+ { FEATDEF_5UTR , FTQUAL_function },
+ { FEATDEF_5UTR , FTQUAL_label },
+ { FEATDEF_5UTR , FTQUAL_map },
+ { FEATDEF_5UTR , FTQUAL_standard_name },
+ { FEATDEF_5UTR , FTQUAL_usedin },
+
+ { FEATDEF_10_signal , FTQUAL_allele },
+ { FEATDEF_10_signal , FTQUAL_label },
+ { FEATDEF_10_signal , FTQUAL_map },
+ { FEATDEF_10_signal , FTQUAL_operon },
+ { FEATDEF_10_signal , FTQUAL_standard_name },
+ { FEATDEF_10_signal , FTQUAL_usedin },
+
+ { FEATDEF_35_signal , FTQUAL_allele },
+ { FEATDEF_35_signal , FTQUAL_label },
+ { FEATDEF_35_signal , FTQUAL_map },
+ { FEATDEF_35_signal , FTQUAL_operon },
+ { FEATDEF_35_signal , FTQUAL_standard_name },
+ { FEATDEF_35_signal , FTQUAL_usedin },
+
+ { FEATDEF_REGION , FTQUAL_function },
+ { FEATDEF_REGION , FTQUAL_label },
+ { FEATDEF_REGION , FTQUAL_map },
+ { FEATDEF_REGION , FTQUAL_number },
+ { FEATDEF_REGION , FTQUAL_phenotype },
+ { FEATDEF_REGION , FTQUAL_product },
+ { FEATDEF_REGION , FTQUAL_standard_name },
+ { FEATDEF_REGION , FTQUAL_usedin },
+
+ { FEATDEF_mat_peptide_aa , FTQUAL_allele },
+ { FEATDEF_mat_peptide_aa , FTQUAL_label },
+ { FEATDEF_mat_peptide_aa , FTQUAL_map },
+ { FEATDEF_mat_peptide_aa , FTQUAL_product },
+ { FEATDEF_mat_peptide_aa , FTQUAL_standard_name },
+ { FEATDEF_mat_peptide_aa , FTQUAL_usedin },
+
+ { FEATDEF_sig_peptide_aa , FTQUAL_allele },
+ { FEATDEF_sig_peptide_aa , FTQUAL_label },
+ { FEATDEF_sig_peptide_aa , FTQUAL_map },
+ { FEATDEF_sig_peptide_aa , FTQUAL_product },
+ { FEATDEF_sig_peptide_aa , FTQUAL_standard_name },
+ { FEATDEF_sig_peptide_aa , FTQUAL_usedin },
+
+ { FEATDEF_transit_peptide_aa , FTQUAL_allele },
+ { FEATDEF_transit_peptide_aa , FTQUAL_label },
+ { FEATDEF_transit_peptide_aa , FTQUAL_map },
+ { FEATDEF_transit_peptide_aa , FTQUAL_product },
+ { FEATDEF_transit_peptide_aa , FTQUAL_standard_name },
+ { FEATDEF_transit_peptide_aa , FTQUAL_usedin },
+
+ { FEATDEF_snoRNA , FTQUAL_allele },
+ { FEATDEF_snoRNA , FTQUAL_function },
+ { FEATDEF_snoRNA , FTQUAL_label },
+ { FEATDEF_snoRNA , FTQUAL_map },
+ { FEATDEF_snoRNA , FTQUAL_product },
+ { FEATDEF_snoRNA , FTQUAL_standard_name },
+ { FEATDEF_snoRNA , FTQUAL_usedin },
+
+ { FEATDEF_operon , FTQUAL_allele },
+ { FEATDEF_operon , FTQUAL_function },
+ { FEATDEF_operon , FTQUAL_label },
+ { FEATDEF_operon , FTQUAL_map },
+ { FEATDEF_operon , FTQUAL_operon },
+ { FEATDEF_operon , FTQUAL_phenotype },
+ { FEATDEF_operon , FTQUAL_standard_name },
+ { FEATDEF_operon , FTQUAL_usedin },
+
+ { FEATDEF_oriT , FTQUAL_allele },
+ { FEATDEF_oriT , FTQUAL_direction },
+ { FEATDEF_oriT , FTQUAL_label },
+ { FEATDEF_oriT , FTQUAL_map },
+ { FEATDEF_oriT , FTQUAL_rpt_type },
+ { FEATDEF_oriT , FTQUAL_rpt_type },
+ { FEATDEF_oriT , FTQUAL_rpt_unit },
+ { FEATDEF_oriT , FTQUAL_standard_name },
+ { FEATDEF_oriT , FTQUAL_usedin }
+};
+
+/* comparison of ValQual's -- first compare featdef then ftqual */
+
+/* macro did not work properly on linux machine, so using function instead */
+/* #define COMPARE_VALQUAL(av,aq,bv,bq) ( ((av)-(bv)) ? ((av)-(bv)) : ((aq)-(bq)) ) */
+
+static Int2 CompareValQual (Uint2 av, FtQualType aq, Uint2 bv, FtQualType bq)
+
+{
+ if (av == bv) return (aq - bq);
+ return (av - bv);
+}
+
+/* Returns TRUE if {featureKey, qualKey} exists in legalGbqualList */
+
+static Boolean AllowedValQual (Uint2 featureKey, FtQualType qualKey)
+
+{
+ Int2 L, R, mid;
+
+ L = 0;
+ R = sizeof (legalGbqualList) / sizeof (ValQual) - 1;
+ while (L < R) {
+ mid = (L + R) / 2;
+ if (CompareValQual (legalGbqualList [mid].featdef,
+ legalGbqualList [mid].ftqual,
+ featureKey, qualKey) < 0)
+ L = mid + 1;
+ else
+ R = mid;
+ }
+ if (CompareValQual (legalGbqualList [R].featdef,
+ legalGbqualList [R].ftqual,
+ featureKey, qualKey)) {
+ return 0;
+ }
+ return 1;
+}
+
+
+static CharPtr validRptString [] = {
+ "tandem", "inverted", "flanking", "terminal", "direct", "dispersed", "other", NULL
+};
+
+static CharPtr validLRBString [] = {
+ "LEFT", "RIGHT", "BOTH", NULL
+};
+
+static CharPtr validConsSpliceString [] = {
+ "(5'site:YES, 3'site:YES)",
+ "(5'site:YES, 3'site:NO)",
+ "(5'site:YES, 3'site:ABSENT)",
+ "(5'site:NO, 3'site:YES)",
+ "(5'site:NO, 3'site:NO)",
+ "(5'site:NO, 3'site:ABSENT)",
+ "(5'site:ABSENT, 3'site:YES)",
+ "(5'site:ABSENT, 3'site:NO)",
+ "(5'site:ABSENT, 3'site:ABSENT)",
+ NULL
+};
+
+static CharPtr validExceptionString [] = {
+ "RNA editing",
+ "reasons given in citation",
+ NULL
+};
+
+static CharPtr validRefSeqExceptionString [] = {
+ "RNA editing",
+ "reasons given in citation",
+ "ribosomal slippage",
+ "ribosome slippage",
+ "trans splicing",
+ "trans-splicing",
+ "alternative processing",
+ "alternate processing",
+ "artificial frameshift",
+ "non-consensus splice site",
+ "nonconsensus splice site",
+ "rearrangement required for product",
+ "modified codon recognition",
+ "unclassified transcription discrepancy",
+ "unclassified translation discrepancy",
+ NULL
+};
+
+static Boolean StringInStringList (CharPtr testString, CharPtr PNTR stringList) {
+ Int2 i;
+ i = 0;
+ while (stringList [i] != NULL) {
+ if (StringICmp (testString, stringList [i]) == 0)
+ return 1;
+ i++;
+ }
+ return 0;
+}
+
+/*
+Functions now public and prototyped in sequtil.h
+Return values are:
+ 0: no problem - Accession is in proper format
+-1: Accession did not start with a letter (or two letters)
+-2: Accession did not contain five numbers (or six numbers after 2 letters)
+-3: the original Accession number to be validated was NULL
+-4: the original Accession number is too long (>16)
+*/
+
+NLM_EXTERN Int2 ValidateAccn (
+ CharPtr accession
+)
+
+{
+ Char ch;
+ Int2 numAlpha = 0;
+ Int2 numDigits = 0;
+ Int2 numUndersc = 0;
+ CharPtr str;
+
+ if (accession == NULL || accession [0] == '\0') return -3;
+
+ if (StringLen (accession) >= 16) return -4;
+
+ if (accession [0] < 'A' || accession [0] > 'Z') return -1;
+
+ str = accession;
+ if (StringNCmp (str, "NZ_", 3) == 0) {
+ str += 3;
+ }
+ ch = *str;
+ while (IS_ALPHA (ch)) {
+ numAlpha++;
+ str++;
+ ch = *str;
+ }
+ while (ch == '_') {
+ numUndersc++;
+ str++;
+ ch = *str;
+ }
+ while (IS_DIGIT (ch)) {
+ numDigits++;
+ str++;
+ ch = *str;
+ }
+ if (ch != '\0' && ch != ' ' && ch != '.') return -2;
+
+ if (numUndersc > 1) return -2;
+
+ if (numUndersc == 0) {
+ if (numAlpha == 1 && numDigits == 5) return 0;
+ if (numAlpha == 2 && numDigits == 6) return 0;
+ if (numAlpha == 3 && numDigits == 5) return 0;
+ if (numAlpha == 4 && numDigits == 8) return 0;
+ } else if (numUndersc == 1) {
+ if (numAlpha != 2 || (numDigits != 6 && numDigits != 8)) return -2;
+ if (accession [0] == 'N' || accession [0] == 'X' || accession [0] == 'Z') {
+ if (accession [1] == 'M' ||
+ accession [1] == 'C' ||
+ accession [1] == 'T' ||
+ accession [1] == 'P' ||
+ accession [1] == 'G' ||
+ accession [1] == 'R' ||
+ accession [1] == 'S' ||
+ accession [1] == 'Z') {
+ return 0;
+ }
+ }
+ }
+
+ return -2;
+}
+
+NLM_EXTERN Int2 ValidateSeqID (
+ SeqIdPtr sip
+)
+
+{
+ Char buf [41];
+
+ if (sip == NULL) return -3;
+ SeqIdWrite (sip, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
+ return ValidateAccn (buf);
+}
+
+static CharPtr mrnaevtext1 = "Derived by automated computational analysis";
+static CharPtr mrnaevtext2 = "using gene prediction method:";
+static CharPtr mrnaevtext3 = "Supporting evidence includes similarity to:";
+
+static void GetStrFormRNAEvidence (
+ UserObjectPtr uop,
+ Pointer userdata
+)
+
+{
+ size_t len;
+ CharPtr method = NULL;
+ Int2 nm = 0;
+ ObjectIdPtr oip;
+ CharPtr str = NULL;
+ CharPtr PNTR strp;
+ Char tmp [20];
+ UserFieldPtr u, ufp, uu;
+
+ if (uop == NULL) return;
+ oip = uop->type;
+ if (oip == NULL) return;
+ if (StringCmp (oip->str, "ModelEvidence") != 0) return;
+ strp = (CharPtr PNTR) userdata;
+
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (oip == NULL || ufp->data.ptrvalue == NULL) continue;
+ if (StringCmp (oip->str, "Method") == 0) {
+ method = StringSaveNoNull ((CharPtr) ufp->data.ptrvalue);
+ }
+ if (StringCmp (oip->str, "mRNA") == 0) {
+ for (u = (UserFieldPtr) ufp->data.ptrvalue; u != NULL; u = u->next) {
+ if (u->data.ptrvalue == NULL) continue;
+ for (uu = (UserFieldPtr) u->data.ptrvalue; uu != NULL; uu = uu->next) {
+ oip = uu->label;
+ if (oip == NULL) continue;
+ if (StringCmp (oip->str, "accession") == 0) {
+ nm++;
+ }
+ }
+ }
+ }
+ }
+
+ len = StringLen (mrnaevtext1) + StringLen (mrnaevtext2) + StringLen (mrnaevtext3) + StringLen (method) + 30;
+ str = (CharPtr) MemNew (len);
+ if (str == NULL) return;
+
+ if (method != NULL) {
+ sprintf (str, "%s %s %s.", mrnaevtext1, mrnaevtext2, method);
+ } else {
+ sprintf (str, "%s.", mrnaevtext1);
+ }
+ if (nm > 0) {
+ StringCat (str, " ");
+ StringCat (str, mrnaevtext3);
+ if (nm > 1) {
+ sprintf (tmp, " %d mRNAs", (int) nm);
+ } else {
+ sprintf (tmp, " %d mRNA", (int) nm);
+ }
+ StringCat (str, tmp);
+ }
+
+ *strp = str;
+}
+
+static Boolean ValidateRptUnit (
+ CharPtr buf
+)
+
+{
+#if 0
+ CharPtr str;
+ Char tmp [255];
+
+ StringNCpy_0 (tmp, buf, sizeof (tmp));
+ TrimSpacesAroundString (tmp);
+
+ str = tmp;
+ /* first check for sequence letters with optional semicolons */
+ while (IS_ALPHA (*str) || *str == ';') str++;
+ if (*str == '\0') return TRUE;
+ /* next check for letters, digits, commas, parentheses, dashes, and underscores */
+ str = tmp;
+ while (IS_ALPHANUM (*str) || *str == '(' || *str == ')' || *str == ',' || *str == ';' || *str == '-' || *str == '_') str++;
+ if (*str == '\0') return TRUE;
+ /* now check for officially legal styles */
+ str = tmp;
+ while (IS_ALPHANUM (*str)) str++;
+ if (*str != '\0') { /* wasn't pure alphanumeric; now check for xxx..yyy */
+ str = buf;
+ while (IS_DIGIT (*str)) str++; /* xxx */
+ if (*str == '\0' /* must be something after the xxx */
+ || StringLen (str) < 3 /* need at least 2 '.'s and a digit*/
+ || str[0] != '.' || str[1] != '.') return FALSE;
+ str+=2;
+ while (IS_DIGIT (*str)) str++;
+ if (*str != '\0') return FALSE; /* mustn't be anything after the yyy */
+ }
+#endif
+ return TRUE;
+}
+
+
+NLM_EXTERN CharPtr goFieldType [] = {
+ "", "text string", "go id", "pubmed id", "evidence", NULL
+};
+
+static CharPtr GetGOtext (
+ UserFieldPtr topufp
+)
+
+{
+ CharPtr evidence = NULL;
+ Char gid [32];
+ CharPtr goid = NULL;
+ Int2 j;
+ ObjectIdPtr oip;
+ Int4 pmid = 0;
+ CharPtr str;
+ CharPtr textstr = NULL;
+ Char tmp [32];
+ UserFieldPtr ufp;
+
+ for (ufp = topufp; ufp != NULL; ufp = ufp->next) {
+ oip = ufp->label;
+ if (oip == NULL) continue;
+ for (j = 0; goFieldType [j] != NULL; j++) {
+ if (StringICmp (oip->str, goFieldType [j]) == 0) break;
+ }
+ if (goFieldType [j] == NULL) continue;
+ switch (j) {
+ case 1 :
+ if (ufp->choice == 1) {
+ textstr = (CharPtr) ufp->data.ptrvalue;
+ }
+ break;
+ case 2 :
+ if (ufp->choice == 1) {
+ goid = (CharPtr) ufp->data.ptrvalue;
+ } else if (ufp->choice == 2) {
+ sprintf (gid, "%ld", (long) (Int4) ufp->data.intvalue);
+ goid = (CharPtr) gid;
+ }
+ break;
+ case 3 :
+ if (ufp->choice == 2) {
+ pmid = (Int4) ufp->data.intvalue;
+ }
+ break;
+ case 4 :
+ if (ufp->choice == 1) {
+ evidence = (CharPtr) ufp->data.ptrvalue;
+ }
+ break;
+ default :
+ break;
+ }
+ }
+ /* if (StringHasNoText (textstr)) return NULL; */
+
+ str = (CharPtr) MemNew (StringLen (textstr) + StringLen (goid) + StringLen (evidence) + 50);
+ if (str == NULL) return NULL;
+
+ StringCpy (str, textstr);
+ if (! StringHasNoText (goid)) {
+ StringCat (str, " [goid ");
+ StringCat (str, goid);
+ StringCat (str, "]");
+ }
+ if (! StringHasNoText (evidence)) {
+ StringCat (str, " [evidence ");
+ StringCat (str, evidence);
+ StringCat (str, "]");
+ }
+ if (pmid != 0) {
+ sprintf (tmp, " [pmid %ld", (long) pmid);
+ StringCat (str, tmp);
+ StringCat (str, "]");
+ }
+ TrimSpacesAroundString (str);
+
+ return str;
+}
+
+static Boolean DbxrefAlreadyInGeneXref (
+ DbtagPtr dbt,
+ ValNodePtr dbxref
+)
+
+{
+ DbtagPtr gdbt;
+ ValNodePtr vnp;
+
+ if (dbt == NULL) return FALSE;
+
+ for (vnp = dbxref; vnp != NULL; vnp = vnp->next) {
+ gdbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (gdbt == NULL) continue;
+ if (DbtagMatch (dbt, gdbt)) return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void FF_www_protein_id(
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr seqid
+)
+{
+
+ if ( GetWWW(ajp) ) {
+ FFAddOneString(ffstring, "<a href=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, link_seq, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "val=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, seqid, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '>', FALSE);
+ FFAddOneString(ffstring, seqid, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, seqid, FALSE, FALSE, TILDE_IGNORE);
+ }
+}
+
+static void FF_www_gcode (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr gcode
+)
+{
+
+ if ( GetWWW(ajp) ) {
+ FFAddOneString(ffstring, "<a href=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, link_code, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "mode=c#SG", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, gcode, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '>', FALSE);
+ FFAddOneString(ffstring, gcode, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, gcode, FALSE, FALSE, TILDE_IGNORE);
+ }
+}
+
+static void FF_AddECnumber (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr str
+)
+{
+ if ( GetWWW(ajp) ) {
+ FFAddOneString(ffstring, "<a href=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, ec_link, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '>', FALSE);
+ FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ }
+}
+
+
+/* FormatFeatureblockQuals should not be called directly,
+ except from FormatFeatureBlock. It performs no input
+ validation. (perhaps it should?) */
+
+static void FormatFeatureBlockQuals (
+ StringItemPtr ffstring,
+ IntAsn2gbJobPtr ajp,
+ Asn2gbSectPtr asp,
+ BioseqPtr bsp,
+ Uint1 featdeftype,
+ ValNodePtr gene_syn,
+ CharPtr lasttype,
+ SeqLocPtr location,
+ BioseqPtr prod,
+ CharPtr protein_pid_g,
+ QualValPtr qvp,
+ Int4 left,
+ Int4 right,
+ Uint1 strand,
+ SeqFeatPtr sfp,
+ BioseqPtr target,
+ Boolean is_other,
+ Boolean is_journalscan,
+ Boolean is_gps
+)
+
+{
+ Boolean add_period;
+ CharPtr ascii;
+ Int2 ascii_len;
+ Boolean at_end = FALSE;
+ ByteStorePtr bs;
+ Char buf[80];
+ Choice cbaa;
+ CodeBreakPtr cbp;
+ Char ch;
+ Uint1 choice;
+ Uint1 code = Seq_code_ncbieaa;
+ Int4 gi;
+ Boolean hadProtDesc = FALSE;
+ DbtagPtr dbt;
+ UserFieldPtr entry;
+ Int4 exp_ev;
+ GBQualPtr gbq;
+ Int2 i;
+ FtQualType idx;
+ Boolean isTRNA;
+ Int2 j;
+ FtQualType jdx;
+ Int4 len;
+ SeqLocPtr newloc;
+ CharPtr notestr;
+ Char numbuf [32];
+ Int2 numcodons;
+ Int2 numsyns;
+ ObjectIdPtr oip;
+ Boolean okay;
+ Boolean only_digits;
+ BioseqPtr pbsp;
+ ValNodePtr ppr;
+ CharPtr prefix;
+ CharPtr protein_seq = NULL;
+ size_t prtlen;
+ CharPtr ptr;
+ Uint1 residue;
+ SeqCodeTablePtr sctp;
+ Int4 sec_str;
+ Uint1 seqcode;
+ Char seqid [50];
+ SeqIntPtr sintp;
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+ Boolean split;
+ SeqPortPtr spp;
+ CharPtr start;
+ CharPtr str;
+ Boolean suppress_period;
+ CharPtr tmp;
+ tRNAPtr trna;
+ UserFieldPtr ufp;
+ UserObjectPtr uop;
+ ValNodePtr vnp;
+ StringItemPtr unique;
+
+ unique = FFGetString(ajp);
+ if ( unique == NULL ) return;
+
+ for (i = 0, idx = feat_qual_order [i]; idx != (FtQualType) 0; i++, idx = feat_qual_order [i]) {
+
+ lasttype = NULL;
+ switch (asn2gnbk_featur_quals [idx].qualclass) {
+
+ case Qual_class_ignore :
+ break;
+
+ case Qual_class_string :
+ if (! StringHasNoText (qvp [idx].str)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_locus_tag :
+ if (! StringHasNoText (qvp [idx].str)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_tilde :
+ if (! StringHasNoText (qvp [idx].str)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_EXPAND);
+ FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
+ FALSE, TRUE, TILDE_EXPAND);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_product :
+ if (StringHasNoText (qvp [idx].str) ||
+ (ajp->flags.dropIllegalQuals &&
+ (! AllowedValQual (featdeftype, FTQUAL_product)))) break;
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ break;
+
+ case Qual_class_sgml :
+ if (! StringHasNoText (qvp [idx].str)) {
+ if (is_journalscan) {
+ ascii_len = Sgml2AsciiLen (qvp [idx].str);
+ start = ascii = MemNew ((size_t) (10 + ascii_len));
+ if (start != NULL) {
+ ascii = Sgml2Ascii (qvp [idx].str, ascii, ascii_len + 1);
+
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddTextToString(ffstring, "\"", start, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+
+ MemFree (start);
+ }
+ } else {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddTextToString(ffstring, "\"", qvp[idx].str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ }
+ break;
+
+ case Qual_class_boolean :
+ if (qvp [idx].ble) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "\n",
+ FALSE, TRUE, TILDE_IGNORE);
+ }
+ break;
+
+ case Qual_class_int :
+ if (qvp [idx].num > 0) {
+ if (idx == FTQUAL_transl_table) {
+ sprintf (numbuf, "%ld", (long) qvp [idx].num);
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FF_www_gcode (ajp, ffstring, numbuf);
+ } else {
+ sprintf (numbuf, "%ld", (long) qvp [idx].num);
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, NULL, numbuf, NULL,
+ FALSE, TRUE, TILDE_IGNORE);
+ }
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_evidence :
+ exp_ev = qvp [idx].num;
+ if (exp_ev > 0 && exp_ev <= 2) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, evidenceText [exp_ev], FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_valnode :
+ for (vnp = qvp[idx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (str != NULL) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddTextToString(ffstring, "\"", str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ }
+ break;
+
+ case Qual_class_gene_syn :
+ /*
+ for (vnp = qvp[idx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (str != NULL) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddTextToString(ffstring, "\"", str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ }
+ */
+ numsyns = 0;
+ for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ numsyns++;
+ }
+ }
+ if (numsyns > 0) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ prefix = NULL;
+ for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ FFAddTextToString (ffstring, prefix, str, NULL, FALSE, FALSE, TILDE_IGNORE);
+ prefix = ", ";
+ }
+ }
+ FFAddOneChar(ffstring, '\"', FALSE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_EC_valnode :
+ for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ okay = TRUE;
+
+ if (str == NULL) continue;
+
+ if (ajp->flags.dropIllegalQuals) {
+ tmp = str;
+ while (*tmp != '\0' && *tmp == '\"')
+ tmp++;
+ for (; *tmp != '\0' && *tmp != '\"'; tmp++) {
+ if (!IS_DIGIT(*tmp) && *tmp != '.' && *tmp != '-') {
+ okay = FALSE;
+ }
+ }
+ }
+ if (!okay) continue;
+
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\"', FALSE);
+ FF_AddECnumber(ajp, ffstring, str);
+ FFAddOneChar(ffstring, '\"', FALSE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_EC_quote :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ okay = TRUE;
+ if (gbq->val == NULL) {
+ okay = FALSE;
+ }
+
+ if (ajp->flags.dropIllegalQuals && okay) {
+ tmp = gbq->val;
+ while (*tmp != '\0' && *tmp == '\"')
+ tmp++;
+ for (; *tmp != '\0' && *tmp != '\"'; tmp++) {
+ if (!IS_DIGIT(*tmp) && *tmp != '.' && *tmp != '-') {
+ okay = FALSE;
+ }
+ }
+ }
+
+ if (StringHasNoText (gbq->val)) {
+ okay = FALSE;
+ }
+
+ if (okay) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\"', FALSE);
+ if (!StringIsJustQuotes (gbq->val)) {
+ FF_AddECnumber (ajp, ffstring, gbq->val);
+ }
+ FFAddOneChar(ffstring, '\"', FALSE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_quote :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, TRUE, TILDE_IGNORE);
+ if (!StringIsJustQuotes (gbq->val)) {
+ FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_IGNORE);
+ }
+ FFAddOneChar(ffstring, '\"', FALSE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_noquote :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_label :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ if (ajp->flags.checkQualSyntax) { /* single token, not just numeric */
+ str = gbq->val;
+ ch = *str;
+ only_digits = TRUE;
+ while (ch != '\0') {
+ if (IS_WHITESP (ch)) break; /* only single token allowed */
+ if (! IS_DIGIT (ch)) {
+ only_digits = FALSE;
+ }
+ str++;
+ ch = *str;
+ }
+ if (only_digits) break; /* must not be just numeric */
+ }
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_number :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+
+ if (ajp->flags.checkQualSyntax) {
+ str = gbq->val;
+
+ if ( StringHasNoText (str) )
+ break;
+ while (!IS_WHITESP (*str) && *str != '\0')
+ str++;
+ if (! StringHasNoText (str) )
+ break;
+ }
+
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_paren :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ tmp = StringSave (gbq->val);
+ str = tmp;
+ len = StringLen (str);
+ if (len > 1 && *str == '(' && str [len - 1] == ')' &&
+ StringChr (str, ',') != NULL) {
+ str++;
+ while (! StringHasNoText (str)) {
+ ptr = StringChr (str, ',');
+ if (ptr == NULL) {
+ ptr = StringChr (str, ')');
+ }
+ if (ptr != NULL) {
+ *ptr = '\0';
+ ptr++;
+ }
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ str = ptr;
+ }
+ } else {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ MemFree (tmp);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_rpt :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ tmp = StringSave (gbq->val);
+ str = tmp;
+ len = StringLen (str);
+ if (len > 1 && *str == '(' && str [len - 1] == ')' &&
+ StringChr (str, ',') != NULL) {
+ str++;
+ while (! StringHasNoText (str)) {
+ ptr = StringChr (str, ',');
+ if (ptr == NULL) {
+ ptr = StringChr (str, ')');
+ }
+ if (ptr != NULL) {
+ *ptr = '\0';
+ ptr++;
+ }
+ if ((! ajp->flags.checkQualSyntax) || (StringInStringList (str, validRptString))) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ str = ptr;
+ }
+ } else {
+ if ((! ajp->flags.checkQualSyntax) || (StringInStringList (str, validRptString))) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ }
+ MemFree (tmp);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_rpt_unit :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+
+ /* in release_mode, must be of the form 123..4567 or a single-token label,
+ or (technically illegal but common) letters and semicolons - NO LONGER CHECKED */
+
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ tmp = StringSave (gbq->val);
+ str = tmp;
+ len = StringLen (str);
+ if (len > 1 && *str == '(' && str [len - 1] == ')' /* && StringChr (str, ',') != NULL */) {
+ str++;
+ while (! StringHasNoText (str)) {
+ ptr = StringChr (str, ',');
+ if (ptr == NULL) {
+ ptr = StringChr (str, ')');
+ }
+ if (ptr != NULL) {
+ *ptr = '\0';
+ ptr++;
+ }
+ if ((! ajp->flags.checkQualSyntax) || (ValidateRptUnit (str))) {
+ TrimSpacesAroundString (str);
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=\"",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\"', FALSE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ str = ptr;
+ }
+ } else {
+ if ((! ajp->flags.checkQualSyntax) || (ValidateRptUnit (str))) {
+ TrimSpacesAroundString (str);
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=\"",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, str, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\"', FALSE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ }
+ MemFree (tmp);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_replace :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '\"', FALSE);
+ if (!StringHasNoText (gbq->val)) {
+ FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
+ }
+ FFAddOneChar(ffstring, '\"', FALSE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_consplice :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+
+ if (ajp->flags.checkQualSyntax && (! StringInStringList (gbq->val, validConsSpliceString)) ) {
+ break;
+ }
+
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_site :
+ if (! StringHasNoText (qvp [idx].str)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", qvp[idx].str, "\"", FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_bond :
+ if (! StringHasNoText (qvp [idx].str)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", qvp[idx].str, "\"", FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_L_R_B :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+
+ if (ajp->flags.checkQualSyntax && (! StringInStringList (gbq->val, validLRBString)) ) {
+ break;
+ }
+
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddOneString(ffstring, gbq->val, FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_sec_str :
+ sec_str = qvp [idx].num;
+ if (sec_str > 0 && sec_str <= 3) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", secStrText[sec_str], "\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_seq_loc :
+ slp = qvp [idx].slp;
+ if (slp != NULL) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ str = FFFlatLoc (ajp, target, slp, /* ajp->masterStyle */ FALSE);
+ FFAddTextToString(ffstring, "\"", str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ MemFree (str);
+ }
+ break;
+
+ case Qual_class_code_break :
+ cbp = qvp [idx].cbp;
+ seqcode = 0;
+ sctp = NULL;
+ while (cbp != NULL) {
+ cbaa = cbp->aa;
+ switch (cbaa.choice) {
+ case 1 :
+ seqcode = Seq_code_ncbieaa;
+ break;
+ case 2 :
+ seqcode = Seq_code_ncbi8aa;
+ break;
+ case 3 :
+ seqcode = Seq_code_ncbistdaa;
+ break;
+ default :
+ break;
+ }
+ if (seqcode != 0) {
+ sctp = SeqCodeTableFind (seqcode);
+ if (sctp != NULL) {
+ slp = NULL;
+ while ((slp = SeqLocFindNext (cbp->loc, slp)) != NULL) {
+ str = NULL;
+ if (ajp->ajp.slp != NULL) {
+ sip = SeqIdParse ("lcl|dummy");
+ split = FALSE;
+ newloc = SeqLocReMapEx (sip, ajp->ajp.slp, slp, 0, FALSE, ajp->masterStyle);
+
+ SeqIdFree (sip);
+ if (newloc != NULL) {
+ A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
+ str = FFFlatLoc (ajp, target, newloc, ajp->masterStyle);
+ SeqLocFree (newloc);
+ }
+ } else {
+ str = FFFlatLoc (ajp, target, slp, ajp->masterStyle);
+ }
+ if (str != NULL) {
+ residue = cbaa.value.intvalue;
+ ptr = Get3LetterSymbol (ajp, seqcode, sctp, residue);
+ if (ptr == NULL) {
+ ptr = "OTHER";
+ }
+ FFAddOneString(ffstring, "/transl_except=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "(pos:", str, ",", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "aa:", ptr, ")", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ MemFree (str);
+ }
+ }
+ }
+ cbp = cbp->next;
+ }
+ break;
+
+ case Qual_class_anti_codon :
+ slp = qvp [FTQUAL_anticodon].slp;
+ newloc = NULL;
+ if (slp != NULL && ajp->ajp.slp != NULL) {
+ sip = SeqIdParse ("lcl|dummy");
+ split = FALSE;
+ newloc = SeqLocReMapEx (sip, ajp->ajp.slp, slp, 0, FALSE, ajp->masterStyle);
+ /*
+ newloc = SeqLocCopyRegion (sip, slp, bsp, left, right, strand, &split);
+ */
+ SeqIdFree (sip);
+ slp = newloc;
+ if (newloc != NULL) {
+ A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
+ }
+ }
+ if (slp != NULL && slp->choice == SEQLOC_INT) {
+ sintp = (SeqIntPtr) slp->data.ptrvalue;
+ if (sintp != NULL) {
+ str = qvp [FTQUAL_trna_aa].str;
+ if (! StringHasNoText (str)) {
+ sprintf(numbuf, "%ld", (long) sintp->from + 1);
+ FFAddTextToString(ffstring, "/anticodon=(pos:", numbuf, "..",
+ FALSE, FALSE, TILDE_IGNORE);
+ sprintf(numbuf, "%ld", (long) sintp->to + 1);
+ FFAddTextToString(ffstring, NULL, numbuf, ",",
+ FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "aa:", str, ")",
+ FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ }
+ }
+ if (newloc != NULL) {
+ SeqLocFree (newloc);
+ }
+ break;
+
+ case Qual_class_codon :
+ gbq = qvp [idx].gbq;
+ if (gbq == NULL || (ajp->flags.dropIllegalQuals && (! AllowedValQual (featdeftype, idx)))) break;
+ if (lasttype == NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[idx].name, "=",
+ FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, gbq->val, FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_pubset :
+ vnp = qvp [idx].vnp;
+ if (vnp != NULL && asp != NULL && asp->referenceArray != NULL) {
+ for (ppr = vnp->data.ptrvalue; ppr != NULL; ppr = ppr->next) {
+ j = MatchRef (ppr, asp->referenceArray, asp->numReferences);
+ if (j > 0) {
+ sprintf (numbuf, "%d", (int) j);
+ FFAddTextToString(ffstring, "/citation=[", numbuf, "]",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ }
+ }
+ break;
+
+ case Qual_class_db_xref :
+ for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
+ buf [0] = '\0';
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt != NULL && (! StringHasNoText (dbt->db))) {
+ oip = dbt->tag;
+ if (oip != NULL) {
+
+ okay = TRUE;
+ if (StringCmp (dbt->db, "PID") == 0 || StringCmp (dbt->db, "GI") == 0) {
+ okay = FALSE;
+ }
+ if (ajp->flags.dropBadDbxref) {
+ /* if RELEASE_MODE, drop unknown dbtag */
+ okay = FALSE;
+ for (j = 0; legalDbXrefs [j] != NULL; j++) {
+ if (StringCmp (dbt->db, legalDbXrefs [j]) == 0) {
+ okay = TRUE;
+ }
+ }
+ if (! okay) {
+ if (is_gps || is_other) {
+ for (j = 0; legalRefSeqDbXrefs [j] != NULL; j++) {
+ if (StringCmp (dbt->db, legalRefSeqDbXrefs [j]) == 0) {
+ okay = TRUE;
+ }
+ }
+ }
+ }
+ }
+ if (okay && idx == FTQUAL_db_xref && qvp [FTQUAL_gene_xref].vnp != NULL) {
+ if (DbxrefAlreadyInGeneXref (dbt, qvp [FTQUAL_gene_xref].vnp)) {
+ okay = FALSE;
+ }
+ }
+
+ if (okay) {
+ if (! StringHasNoText (oip->str)) {
+ if (StringLen (oip->str) < 80) {
+ sprintf (buf, "%s", oip->str);
+ }
+ } else {
+ sprintf (buf, "%ld", (long) oip->id);
+ }
+ }
+ }
+ }
+ if (! StringHasNoText (buf)) {
+ if (StringICmp (buf, protein_pid_g) != 0) {
+ /* already sorted and uniqued by BasicSeqEntryCleanup, per feature */
+ if (StringICmp (dbt->db, "LocusID") == 0 || StringICmp (dbt->db, "InterimID") == 0) {
+ if (FFStringSearch (ffstring, dbt->db, 0) >= 0) {
+ okay = FALSE;
+ }
+ }
+ if (okay) {
+ FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
+ FF_www_db_xref(ajp, ffstring, dbt->db, buf);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+ }
+ break;
+
+
+ case Qual_class_seq_id :
+ sip = qvp [idx].sip;
+ if (sip != NULL) {
+ /* should always be found above for protein_id or transcript_id
+ prod = BioseqFind (sip);
+ */
+ if (prod != NULL) {
+ choice = 0;
+ for (sip = prod->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GENBANK ||
+ sip->choice == SEQID_EMBL ||
+ sip->choice == SEQID_DDBJ ||
+ sip->choice == SEQID_OTHER ||
+ sip->choice == SEQID_TPG ||
+ sip->choice == SEQID_TPE ||
+ sip->choice == SEQID_TPD) {
+ choice = sip->choice;
+ if (SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FF_www_protein_id(ajp, ffstring, seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ }
+ } else if (sip->choice == SEQID_GI) {
+ if (choice == 0) {
+ sprintf (seqid, "%ld", (long) sip->data.intvalue);
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FF_www_protein_id(ajp, ffstring, seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ }
+ sprintf (seqid, "%ld", (long) sip->data.intvalue);
+ FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
+ FF_www_db_xref(ajp, ffstring, "GI", seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ } else if (sip->choice == SEQID_GENERAL) {
+ dbt = (DbtagPtr) sip->data.ptrvalue;
+ if (dbt != NULL && StringCmp (dbt->db, "PID") == 0) {
+ /*
+ oip = dbt->tag;
+ if (oip != NULL) {
+ if (! StringHasNoText (oip->str)) {
+ sprintf (seqid, "PID:%s", oip->str);
+ NewContLine ();
+ gb_AddString ("/db_xref=\"", seqid, "\"", FALSE, TRUE, TILDE_TO_SPACES);
+ }
+ }
+ */
+ } else if (dbt != NULL) {
+ pbsp = BioseqFind (sip);
+ if (pbsp != NULL && pbsp->id != NULL && pbsp->id->next == NULL) {
+ if (SeqIdWrite (sip, seqid, PRINTID_REPORT, sizeof (seqid)) != NULL) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FF_www_protein_id(ajp, ffstring, seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if (sip->choice == SEQID_GI) {
+ gi = sip->data.intvalue;
+ if (GetAccnVerFromServer (gi, seqid)) {
+ if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FF_www_protein_id(ajp, ffstring, seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ ajp->relModeError = TRUE;
+ }
+ } else {
+ sip = GetSeqIdForGI(gi);
+ if (sip != NULL && SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
+ if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FF_www_protein_id(ajp, ffstring, seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ ajp->relModeError = TRUE;
+ }
+ } else if (! ajp->flags.dropIllegalQuals) {
+ sprintf (seqid, "%ld", (long) gi);
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FF_www_protein_id(ajp, ffstring, seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ ajp->relModeError = TRUE;
+ }
+ }
+
+ sprintf (seqid, "%ld", (long) gi);
+ FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
+ FF_www_db_xref(ajp, ffstring, "GI", seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ } else if (SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
+ if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals [idx].name, "=\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FF_www_protein_id(ajp, ffstring, seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ ajp->relModeError = TRUE;
+ }
+
+ gi = GetGIForSeqId (sip);
+ if (gi > 0) {
+ sprintf (seqid, "%ld", (long) gi);
+ FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
+ FF_www_db_xref(ajp, ffstring, "GI", seqid);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+ }
+ break;
+
+ case Qual_class_translation :
+ if (qvp [idx].ble) {
+ if ((prod == NULL && ajp->transIfNoProd) || ajp->alwaysTranslCds) {
+ bs = ProteinFromCdRegionEx (sfp, TRUE, FALSE);
+ if (bs != NULL) {
+ str = BSMerge (bs, NULL);
+ bs = BSFree (bs);
+ if (str != NULL) {
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ *ptr = TO_UPPER (ch);
+ ptr++;
+ ch = *ptr;
+ }
+ prtlen = StringLen (str);
+ if (prtlen > 1) {
+ if (str [prtlen - 1] == '*') {
+ str [prtlen - 1] = '\0';
+ }
+ }
+ if (! StringHasNoText (str)) {
+ FFAddTextToString(ffstring, "/translation=\"", str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ MemFree (str);
+ }
+ } else {
+ ajp->relModeError = TRUE;
+ }
+ } else if (prod != NULL) {
+ len = SeqLocLen (sfp->product);
+ if (len > 0) {
+ if (SeqLocStart (location) == 0 || (bsp != NULL && SeqLocStop (location) == bsp->length - 1)) {
+ at_end = TRUE;
+ }
+ str = (CharPtr) MemNew ((size_t) (len + 1) * sizeof (Char));
+ protein_seq = str;
+ if (ajp->flags.iupacaaOnly) {
+ code = Seq_code_iupacaa;
+ } else {
+ code = Seq_code_ncbieaa;
+ }
+ spp = SeqPortNewByLoc (sfp->product, code);
+ if (spp != NULL) {
+ SeqPortSet_do_virtual (spp, TRUE);
+ while ((residue = SeqPortGetResidue (spp)) != SEQPORT_EOF) {
+ if (! (IS_residue (residue))) continue;
+ if (residue == INVALID_RESIDUE) {
+ residue = (Uint1) 'X';
+ }
+ *protein_seq = residue;
+ protein_seq++;
+ }
+ /*
+ if (at_end && StringLen (str) < GENPEPT_MIN) {
+ str = MemFree (str);
+ }
+ */
+ if (! StringHasNoText (str)) {
+ FFAddTextToString(ffstring, "/translation=\"", str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ MemFree (str);
+ } else {
+ ajp->relModeError = TRUE;
+ }
+ SeqPortFree (spp);
+ } else {
+ ajp->relModeError = TRUE;
+ }
+ }
+ }
+ break;
+
+ case Qual_class_transcription :
+ if (qvp [idx].ble) {
+ if (ajp->showTranscript) {
+ str = GetSequenceByFeature (sfp);
+ if (str != NULL) {
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ *ptr = TO_UPPER (ch);
+ ptr++;
+ ch = *ptr;
+ }
+ if (! StringHasNoText (str)) {
+ FFAddTextToString(ffstring, "/transcription=\"", str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ MemFree (str);
+ }
+ }
+ }
+ break;
+
+ case Qual_class_peptide :
+ if (qvp [idx].ble) {
+ if (ajp->showPeptide) {
+ str = GetSequenceByFeature (sfp);
+ if (str != NULL) {
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ *ptr = TO_UPPER (ch);
+ ptr++;
+ ch = *ptr;
+ }
+ if (! StringHasNoText (str)) {
+ FFAddTextToString(ffstring, "/peptide=\"", str, "\"",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ MemFree (str);
+ }
+ }
+ }
+ break;
+
+ case Qual_class_illegal :
+ for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (str != NULL) {
+ FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddNewLine(ffstring);
+ }
+ }
+ break;
+
+ case Qual_class_note :
+ if (! ajp->flags.goQualsToNote) {
+
+ /* in sequin_mode and dump_mode in RefSeq, GO terms show up as separate /qualifiers */
+
+ for (j = 0, jdx = feat_note_order [j]; jdx != 0; j++, jdx = feat_note_order [j]) {
+ switch (asn2gnbk_featur_quals [jdx].qualclass) {
+
+ case Qual_class_go :
+ if (qvp [jdx].ufp != NULL) {
+ for (entry = qvp [jdx].ufp; entry != NULL; entry = entry->next) {
+ if (entry == NULL || entry->choice != 11) break;
+ ufp = (UserFieldPtr) entry->data.ptrvalue;
+ str = GetGOtext (ufp);
+ if (! StringHasNoText (str)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_featur_quals[jdx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", str, "\"",
+ FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ MemFree (str);
+ }
+ }
+ break;
+
+ default :
+ break;
+ }
+ }
+ }
+
+ /*head = NULL;*/
+ notestr = NULL;
+ prefix = NULL;
+ add_period = FALSE;
+ suppress_period = FALSE;
+ lasttype = NULL;
+ isTRNA = TRUE;
+
+
+#ifdef DISPLAY_STRINGS
+ s_DisplayQVP (qvp, feat_note_order);
+#endif
+ for (j = 0, jdx = feat_note_order [j]; jdx != 0; j++, jdx = feat_note_order [j]) {
+ switch (asn2gnbk_featur_quals [jdx].qualclass) {
+
+ case Qual_class_string :
+ if (! StringHasNoText (qvp [jdx].str)) {
+ if (jdx == FTQUAL_figure) {
+ if (!IsEllipsis (qvp [jdx].str))
+ s_RemovePeriodFromEnd (qvp [jdx].str);
+ sprintf (buf, "This sequence comes from %s", qvp [jdx].str);
+ FFAddString_NoRedund (unique, prefix, buf, NULL);
+ add_period = FALSE;
+ } else if (jdx == FTQUAL_maploc) {
+ if (!IsEllipsis (qvp [jdx].str))
+ s_RemovePeriodFromEnd (qvp [jdx].str);
+ sprintf (buf, "Map location %s", qvp [jdx].str);
+ FFAddString_NoRedund (unique, prefix, buf, NULL);
+ add_period = FALSE;
+ } else if (jdx == FTQUAL_seqfeat_note) {
+ str = StringSave (qvp [jdx].str);
+ TrimSpacesAndJunkFromEnds (str, TRUE);
+ if (! IsEllipsis (str))
+ add_period = s_RemovePeriodFromEnd (str);
+ /* NOTE -- The following function call cleans up some strings
+ (i.e., U34661 & U31565) but should be commented back
+ in only if the problem can't be fixed upstream of here
+
+ s_StringCleanup(str);
+
+ */
+ FFAddString_NoRedund (unique, prefix, str, NULL);
+ MemFree (str);
+ if (hadProtDesc) {
+ suppress_period = TRUE;
+ }
+ } else if (jdx == FTQUAL_prot_note) {
+ str = StringSave (qvp [jdx].str);
+ TrimSpacesAndJunkFromEnds (str, TRUE);
+ if (! IsEllipsis (str))
+ s_RemovePeriodFromEnd (str);
+ FFAddString_NoRedund (unique, prefix, str, NULL);
+ MemFree (str);
+ add_period = FALSE;
+ } else if (jdx == FTQUAL_prot_desc) {
+ str = StringSave (qvp [jdx].str);
+ TrimSpacesAndJunkFromEnds (str, TRUE);
+ if (! IsEllipsis (str))
+ add_period = s_RemovePeriodFromEnd (str);
+ FFAddString_NoRedund (unique, prefix, str, NULL);
+ MemFree (str);
+ hadProtDesc = TRUE; /* gi|347886|gb|M96268.1|ECOUBIA */
+ } else {
+ if (! IsEllipsis (qvp [jdx].str)) {
+ s_RemovePeriodFromEnd (qvp [jdx].str);
+ }
+ FFAddString_NoRedund (unique, prefix, qvp [jdx].str, NULL);
+ add_period = FALSE;
+ }
+ prefix = "; ";
+ }
+ break;
+
+ case Qual_class_encodes :
+ if (! StringHasNoText (qvp [jdx].str)) {
+ if (! IsEllipsis (qvp [jdx].str)) {
+ s_RemovePeriodFromEnd (qvp [jdx].str);
+ }
+ FFAddTextToString (unique, prefix, "encodes ", NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddString_NoRedund (unique, NULL, qvp [jdx].str, NULL);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ break;
+
+ case Qual_class_locus_tag :
+ if (! StringHasNoText (qvp [jdx].str)) {
+ if (! IsEllipsis (qvp [jdx].str)) {
+ s_RemovePeriodFromEnd (qvp [jdx].str);
+ }
+ FFAddTextToString (unique, prefix, "locus_tag: ", NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddString_NoRedund (unique, NULL, qvp [jdx].str, NULL);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ break;
+
+ case Qual_class_go :
+ if (ajp->flags.goQualsToNote && qvp [jdx].ufp != NULL) {
+ for (entry = qvp [jdx].ufp; entry != NULL; entry = entry->next) {
+ if (entry == NULL || entry->choice != 11) break;
+ ufp = (UserFieldPtr) entry->data.ptrvalue;
+ str = GetGOtext (ufp);
+ if (! StringHasNoText (str)) {
+ if (StringCmp (prefix, "; ") == 0) {
+ prefix = ";\n";
+ }
+ FFAddTextToString (unique, prefix, asn2gnbk_featur_quals[jdx].name, ": ", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(unique, NULL, str, NULL, FALSE, FALSE, TILDE_IGNORE);
+ }
+ MemFree (str);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ }
+ break;
+
+ case Qual_class_method :
+ if (! StringHasNoText (qvp [jdx].str)) {
+ if ( FFEmpty(unique) ) {
+ prefix = "Method: ";
+ } else {
+ prefix = "; Method: ";
+ }
+ FFAddString_NoRedund (unique, prefix, qvp [jdx].str, NULL);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ break;
+
+ case Qual_class_valnode :
+ for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ FFAddString_NoRedund (unique, prefix, str, NULL);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ }
+ break;
+
+ case Qual_class_gene_syn :
+ numsyns = 0;
+ for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ numsyns++;
+ }
+ }
+ if (numsyns > 0) {
+ if (numsyns > 1) {
+ FFAddTextToString (unique, prefix, "synonyms: ", NULL, FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddTextToString (unique, prefix, "synonym: ", NULL, FALSE, FALSE, TILDE_IGNORE);
+ }
+ prefix = NULL;
+ for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ FFAddTextToString (unique, prefix, str, NULL, FALSE, FALSE, TILDE_IGNORE);
+ prefix = ", ";
+ }
+ }
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ break;
+
+ case Qual_class_region :
+ if (! StringHasNoText (qvp [jdx].str)) {
+ if ( FFEmpty(unique) ) {
+ prefix = "Region: ";
+ } else {
+ prefix = "; Region: ";
+ }
+#ifdef ASN2GNBK_STRIP_NOTE_PERIODS
+ FFAddTextToString(unique, prefix, qvp [jdx].str, NULL, FALSE, FALSE, TILDE_IGNORE);
+#else
+ FFAddString_NoRedund (unique, prefix, qvp [jdx].str, NULL);
+#endif
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ break;
+
+ case Qual_class_site :
+ if (! StringHasNoText (qvp [jdx].str)) {
+ FFAddString_NoRedund (unique, prefix, qvp [jdx].str, " site");
+ add_period = FALSE;
+ prefix = "\n";
+ }
+ break;
+
+ case Qual_class_bond :
+ if (! StringHasNoText (qvp [jdx].str)) {
+ FFAddString_NoRedund (unique, prefix, qvp [jdx].str, " bond");
+ add_period = FALSE;
+ prefix = "\n";
+ }
+ break;
+
+ case Qual_class_protnames :
+ /* process gene sgml for check against subsequent protein names */
+ start = NULL;
+ if (! StringHasNoText (qvp [FTQUAL_gene].str)) {
+ if (is_journalscan) {
+ ascii_len = Sgml2AsciiLen (qvp [FTQUAL_gene].str);
+ start = ascii = MemNew ((size_t) (10 + ascii_len));
+ if (start != NULL) {
+ ascii = Sgml2Ascii (qvp [FTQUAL_gene].str, ascii, ascii_len + 1);
+ }
+ } else {
+ start = StringSaveNoNull (qvp [FTQUAL_gene].str);
+ }
+ }
+ for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ /* case sensitive - gi|4973426|gb|AF148501.1|AF148501 */
+ /* check with and without sgml conversion */
+ if (StringCmp (start, str) != 0 &&
+ StringCmp (qvp [FTQUAL_gene].str, str) != 0) {
+ if (! StringStr (qvp [FTQUAL_prot_desc].str, str)) {
+ /* if (NotInGeneSyn (str, gene_syn)) { */
+ FFAddString_NoRedund (unique, prefix, str, NULL);
+ prefix = "; ";
+ add_period = FALSE;
+ /* } */
+ }
+ }
+ }
+ }
+ MemFree (start);
+ break;
+
+ case Qual_class_xtraprds :
+ gbq = qvp [jdx].gbq;
+ if (lasttype == NULL && gbq != NULL) {
+ lasttype = gbq->qual;
+ }
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (! StringHasNoText (gbq->val)) {
+ if (StringCmp(gbq->val,qvp[FTQUAL_gene].str) != 0 &&
+ StringCmp(gbq->val,qvp[FTQUAL_product].str) != 0) {
+ if (!isTRNA || !StringStr (gbq->val, "RNA")) {
+ FFAddString_NoRedund (unique, prefix, gbq->val, NULL);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ }
+ }
+ gbq = gbq->next;
+ }
+ break;
+
+ case Qual_class_its :
+ str = qvp [jdx].str;
+ if (! StringHasNoText (str)) {
+ if (sfp->comment == NULL || StringStr (sfp->comment, str) == NULL) {
+ FFAddString_NoRedund (unique, prefix, str, NULL);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ }
+ break;
+
+ case Qual_class_trna_codons :
+ trna = qvp [jdx].trp;
+ if (trna) {
+ numcodons = ComposeCodonsRecognizedString (trna, numbuf, sizeof (numbuf));
+ if (numcodons < 1 || StringHasNoText (numbuf)) {
+ } else if (numcodons == 1) {
+ isTRNA = TRUE;
+ sprintf (buf, "codon recognized: %s", numbuf);
+ if (StringStr (qvp [FTQUAL_seqfeat_note].str, buf) == NULL) {
+ FFAddString_NoRedund (unique, prefix, "codon recognized: ", numbuf);
+ prefix = "; ";
+ }
+ } else {
+ isTRNA = TRUE;
+ FFAddString_NoRedund (unique, prefix, "codons recognized: ", numbuf);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ }
+ break;
+
+ case Qual_class_model_ev :
+ uop = qvp [jdx].uop;
+ if (uop != NULL) {
+ str = NULL;
+ VisitUserObjectsInUop (sfp->ext, (Pointer) &str, GetStrFormRNAEvidence);
+ if (! StringHasNoText (str)) {
+ FFAddString_NoRedund (unique, prefix, str, NULL);
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ }
+ break;
+
+ case Qual_class_seq_id :
+ sip = qvp [jdx].sip;
+ if (sip != NULL) {
+ /* should always be found above for protein_id or transcript_id
+ prod = BioseqFind (sip);
+ */
+ if (prod != NULL) {
+ choice = 0;
+ for (sip = prod->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GENBANK ||
+ sip->choice == SEQID_EMBL ||
+ sip->choice == SEQID_DDBJ ||
+ sip->choice == SEQID_OTHER ||
+ sip->choice == SEQID_TPG ||
+ sip->choice == SEQID_TPE ||
+ sip->choice == SEQID_TPD) {
+ choice = sip->choice;
+ if (SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
+ FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
+ FALSE, FALSE, TILDE_IGNORE);
+ }
+ } else if (sip->choice == SEQID_GI) {
+ if (choice == 0) {
+ sprintf (seqid, "%ld", (long) sip->data.intvalue);
+ FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
+ FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+ } else {
+ if (sip->choice == SEQID_GI) {
+ gi = sip->data.intvalue;
+ if (GetAccnVerFromServer (gi, seqid)) {
+ if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
+ FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
+ FALSE, FALSE, TILDE_IGNORE);
+ }
+ } else {
+ sip = GetSeqIdForGI(gi);
+ if (sip != NULL && SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
+ if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
+ FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
+ FALSE, FALSE, TILDE_IGNORE);
+ }
+ } else if (! ajp->flags.dropIllegalQuals) {
+ sprintf (seqid, "%ld", (long) gi);
+ FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
+ FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ } else if (SeqIdWrite (sip, seqid, PRINTID_TEXTID_ACC_VER, sizeof (seqid)) != NULL) {
+ if ((! ajp->flags.dropIllegalQuals) || ValidateAccn (seqid) == 0) {
+ FFAddTextToString(unique, prefix, "transcript found in: ", seqid,
+ FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+ prefix = "; ";
+ add_period = FALSE;
+ }
+ break;
+
+ default :
+ break;
+ }
+ }
+
+ if ( !FFEmpty(unique) ) {
+ notestr = FFToCharPtr(unique);
+ TrimSpacesAroundString (notestr);
+ if (add_period) {
+ if (! suppress_period) {
+ s_AddPeriodToEnd (notestr);
+ }
+ }
+
+#ifdef ASN2GNBK_STRIP_NOTE_PERIODS
+ if (! IsEllipsis (notestr))
+ s_RemovePeriodFromEnd (notestr);
+#endif
+
+ FFAddOneString(ffstring, "/note=\"", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, notestr, FALSE, TRUE, TILDE_EXPAND);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+
+ MemFree (notestr);
+ /*ValNodeFreeData (head);*/
+ }
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ FFRecycleString(ajp, unique);
+}
+
+
+
+static void FF_asn2gb_www_featkey (
+ StringItemPtr ffstring,
+ CharPtr key,
+ SeqLocPtr slp,
+ Int4 from,
+ Int4 to,
+ Uint1 strand,
+ Uint4 itemID
+)
+
+{
+ BioseqPtr bsp;
+ Int4 gi = 0;
+ SeqIdPtr sip;
+ Boolean is_aa = FALSE;
+ Char gi_buf[16];
+ Char itemID_buf[16];
+
+ bsp = BioseqFindFromSeqLoc (slp);
+ if (bsp != NULL) {
+ is_aa = ISA_aa (bsp->mol);
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GI) {
+ gi = (Int4) sip->data.intvalue;
+ }
+ }
+ }
+
+ sprintf(gi_buf, "%ld", (long)gi);
+ sprintf(itemID_buf, "%ld", (long)itemID);
+
+
+ FFAddOneString(ffstring, "<a href=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, link_feat, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "val=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, gi_buf, FALSE, FALSE, TILDE_IGNORE);
+ if (itemID > 0) {
+ FFAddOneString(ffstring, "&itemID=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, itemID_buf, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+
+ if ( is_aa ) {
+ FFAddOneString(ffstring, "&view=gpwithparts>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, "&view=gbwithparts>", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ FFAddOneString(ffstring, key, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+}
+
+
+NLM_EXTERN SeqIdPtr SeqLocIdForProduct (
+ SeqLocPtr product
+)
+
+{
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+
+ /* in case product is a SEQLOC_EQUIV */
+
+ if (product == NULL) return NULL;
+ sip = SeqLocId (product);
+ if (sip != NULL) return sip;
+ slp = SeqLocFindNext (product, NULL);
+ while (slp != NULL) {
+ sip = SeqLocId (slp);
+ if (sip != NULL) return sip;
+ slp = SeqLocFindNext (product, slp);
+ }
+ return NULL;
+}
+
+NLM_EXTERN CharPtr goQualType [] = {
+ "", "Process", "Component", "Function", NULL
+};
+
+static void RecordGoFieldsInQVP (
+ UserFieldPtr ufp,
+ Pointer userdata
+)
+
+{
+ UserFieldPtr entry;
+ Int2 i;
+ ObjectIdPtr oip;
+ QualValPtr qvp;
+
+ qvp = (QualValPtr) userdata;
+
+ if (ufp == NULL || ufp->choice != 11) return;
+ oip = ufp->label;
+ if (oip == NULL) return;
+ for (i = 0; goQualType [i] != NULL; i++) {
+ if (StringICmp (oip->str, goQualType [i]) == 0) break;
+ }
+ if (goQualType [i] == NULL) return;
+
+ entry = ufp->data.ptrvalue;
+ if (entry == NULL || entry->choice != 11) return;
+
+ /* ufp = (UserFieldPtr) entry->data.ptrvalue; */
+ switch (i) {
+ case 1 :
+ qvp [FTQUAL_go_process].ufp = entry;
+ break;
+ case 2 :
+ qvp [FTQUAL_go_component].ufp = entry;
+ break;
+ case 3 :
+ qvp [FTQUAL_go_function].ufp = entry;
+ break;
+ default :
+ break;
+ }
+}
+
+static void RecordUserObjectsInQVP (
+ UserObjectPtr uop,
+ Pointer userdata
+)
+
+{
+ ObjectIdPtr oip;
+ QualValPtr qvp;
+
+ if (uop == NULL || userdata == NULL) return;
+ qvp = (QualValPtr) userdata;
+ oip = uop->type;
+ if (oip == NULL) return;
+ if (StringCmp (oip->str, "ModelEvidence") == 0) {
+ qvp [FTQUAL_modelev].uop = uop;
+ } else if (StringCmp (oip->str, "GeneOntology") == 0) {
+ VisitUserFieldsInUop (uop, (Pointer) qvp, RecordGoFieldsInQVP);
+ }
+}
+
+static void AddIntervalsToGbfeat (
+ GBFeaturePtr gbfeat,
+ SeqLocPtr location,
+ BioseqPtr target
+)
+
+{
+ Char accn [41];
+ SeqLocPtr copy = NULL;
+ Int4 from;
+ GBIntervalPtr gbint;
+ Int4 gi;
+ GBIntervalPtr last = NULL;
+ Int4 point;
+ SeqIntPtr sint;
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+ SeqPntPtr spp;
+ Int4 to;
+ Int4 swap;
+
+ if (gbfeat == NULL || location == NULL) return;
+ if (target != NULL) {
+ copy = SeqLocMerge (target, location, NULL, FALSE, TRUE, FALSE);
+ location = copy;
+ }
+
+ slp = SeqLocFindNext (location, NULL);
+ while (slp != NULL) {
+ from = 0;
+ to = 0;
+ point = 0;
+ sip = NULL;
+ switch (slp->choice) {
+ case SEQLOC_WHOLE :
+ sip = (SeqIdPtr) slp->data.ptrvalue;
+ if (sip != NULL) {
+ from = 1;
+ to = SeqLocLen (slp);
+ if (to < 0) {
+ sip = NULL;
+ }
+ }
+ break;
+ case SEQLOC_INT :
+ sint = (SeqIntPtr) slp->data.ptrvalue;
+ if (sint != NULL) {
+ from = sint->from + 1;
+ to = sint->to + 1;
+ sip = sint->id;
+ if (sint->strand == Seq_strand_minus && from < to) {
+ swap = from;
+ from = to;
+ to = swap;
+ }
+ }
+ break;
+ case SEQLOC_PNT :
+ spp = (SeqPntPtr) slp->data.ptrvalue;
+ if (spp != NULL) {
+ point = spp->point + 1;
+ sip = spp->id;
+ }
+ break;
+ default :
+ break;
+ }
+ if (sip != NULL) {
+ accn [0] = '\0';
+ if (sip->choice == SEQID_GI) {
+ gi = sip->data.intvalue;
+ if (! GetAccnVerFromServer (gi, accn)) {
+ accn [0] = '\0';
+ }
+ if (StringHasNoText (accn)) {
+ sip = GetSeqIdForGI (gi);
+ SeqIdWrite (sip, accn, PRINTID_TEXTID_ACC_VER, sizeof (accn));
+ SeqIdFree (sip);
+ }
+ } else {
+ SeqIdWrite (sip, accn, PRINTID_TEXTID_ACC_VER, sizeof (accn));
+ }
+ if (! StringHasNoText (accn)) {
+ gbint = GBIntervalNew ();
+ if (gbint != NULL) {
+ gbint->from = from;
+ gbint->to = to;
+ gbint->point = point;
+ gbint->accession = StringSave (accn);
+ if (gbfeat->intervals == NULL) {
+ gbfeat->intervals = gbint;
+ } else {
+ last->next = gbint;
+ }
+ last = gbint;
+ }
+ }
+ }
+ slp = SeqLocFindNext (location, slp);
+ }
+
+ SeqLocFree (copy);
+}
+
+static void ParseException (
+ CharPtr original,
+ CharPtr PNTR exception_string,
+ CharPtr PNTR exception_note,
+ Boolean dropIllegalQuals,
+ Boolean isRefSeq
+)
+
+{
+ ValNodePtr excpt = NULL, note = NULL, vnp;
+ Boolean first, found;
+ Int2 i;
+ size_t len;
+ CharPtr ptr, str, tmp;
+
+ if (StringHasNoText (original) || exception_string == NULL || exception_note == NULL) return;
+
+ if (! dropIllegalQuals) {
+ *exception_string = StringSave (original);
+ return;
+ }
+
+ str = StringSave (original);
+ if (str == NULL) return;
+
+ tmp = str;
+ while (! StringHasNoText (tmp)) {
+ ptr = StringChr (tmp, ',');
+ if (ptr != NULL) {
+ *ptr = '\0';
+ ptr++;
+ }
+ TrimSpacesAroundString (tmp);
+ found = FALSE;
+ for (i = 0; validExceptionString [i] != NULL; i++) {
+ if (StringICmp (tmp, validExceptionString [i]) == 0) {
+ found = TRUE;
+ break;
+ }
+ }
+ if (! found) {
+ if (isRefSeq) {
+ for (i = 0; validRefSeqExceptionString [i] != NULL; i++) {
+ if (StringICmp (tmp, validRefSeqExceptionString [i]) == 0) {
+ found = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ if (found) {
+ ValNodeCopyStr (&excpt, 0, tmp);
+ } else {
+ ValNodeCopyStr (&note, 0, tmp);
+ }
+ tmp = ptr;
+ }
+
+ if (excpt != NULL) {
+ for (vnp = excpt, len = 0; vnp != NULL; vnp = vnp->next) {
+ tmp = (CharPtr) vnp->data.ptrvalue;
+ len += StringLen (tmp) + 3;
+ }
+ ptr = (CharPtr) MemNew (len + 2);
+ if (ptr != NULL) {
+ for (vnp = excpt, first = TRUE; vnp != NULL; vnp = vnp->next) {
+ if (! first) {
+ StringCat (ptr, ", ");
+ }
+ tmp = (CharPtr) vnp->data.ptrvalue;
+ StringCat (ptr, tmp);
+ first = FALSE;
+ }
+ }
+ *exception_string = ptr;
+ }
+
+ if (note != NULL) {
+ for (vnp = note, len = 0; vnp != NULL; vnp = vnp->next) {
+ tmp = (CharPtr) vnp->data.ptrvalue;
+ len += StringLen (tmp) + 3;
+ }
+ ptr = (CharPtr) MemNew (len + 2);
+ if (ptr != NULL) {
+ for (vnp = note, first = TRUE; vnp != NULL; vnp = vnp->next) {
+ if (! first) {
+ StringCat (ptr, ", ");
+ }
+ tmp = (CharPtr) vnp->data.ptrvalue;
+ StringCat (ptr, tmp);
+ first = FALSE;
+ }
+ }
+ *exception_note = ptr;
+ }
+
+ ValNodeFreeData (excpt);
+ ValNodeFreeData (note);
+ MemFree (str);
+}
+
+static CharPtr FormatFeatureBlockEx (
+ IntAsn2gbJobPtr ajp,
+ Asn2gbSectPtr asp,
+ BioseqPtr bsp,
+ BioseqPtr target,
+ SeqFeatPtr sfp,
+ SeqMgrFeatContextPtr fcontext,
+ QualValPtr qvp,
+ FmtType format,
+ IntFeatBlockPtr ifp,
+ Boolean isProt,
+ Boolean doKey
+)
+
+{
+ Uint1 aa;
+ Int2 bondidx;
+ BioseqSetPtr bssp;
+ Choice cbaa;
+ CodeBreakPtr cbp;
+ BioseqPtr cdna;
+ SeqFeatPtr cds;
+ Char ch;
+ Uint1 code = Seq_code_ncbieaa;
+ CdRegionPtr crp;
+ SeqMgrDescContext dcontext;
+ Boolean encode_prefix = FALSE;
+ CharPtr exception_note = NULL;
+ CharPtr exception_string = NULL;
+ Uint1 featdeftype;
+ Uint1 from;
+ GBQualPtr gbq;
+ GBFeaturePtr gbfeat = NULL;
+ GBSeqPtr gbseq;
+ SeqMgrFeatContext gcontext;
+ ValNodePtr gcp;
+ SeqFeatPtr gene = NULL;
+ ValNodePtr gene_syn = NULL;
+ GeneRefPtr grp;
+ IntCdsBlockPtr icp;
+ Uint2 idx;
+ ValNodePtr illegal = NULL;
+ ImpFeatPtr imp = NULL;
+ IndxPtr index;
+ Boolean is_gps = FALSE;
+ Boolean is_journalscan = FALSE;
+ Boolean is_other = FALSE;
+ Uint4 itemID;
+ CharPtr key = NULL;
+ CharPtr lasttype = NULL;
+ Int4 left = -1;
+ SeqLocPtr loc = NULL;
+ SeqLocPtr location = NULL;
+ SeqLocPtr locforgene = NULL;
+ SeqMgrFeatContext mcontext;
+ MolInfoPtr mip;
+ SeqFeatPtr mrna;
+ SeqLocPtr newloc;
+ Boolean noLeft;
+ Boolean noRight;
+ SeqMgrFeatContext ocontext;
+ SeqEntryPtr oldscope;
+ SeqFeatPtr operon = NULL;
+ Uint2 partial;
+ SeqMgrFeatContext pcontext;
+ BioseqPtr prd;
+ CharPtr precursor_comment = NULL;
+ BioseqPtr prod = NULL;
+ SeqFeatPtr prot;
+ Boolean protein = FALSE;
+ Char protein_pid_g [32];
+ ProtRefPtr prp;
+ ProtRefPtr prpxref;
+ Boolean pseudo = FALSE;
+ CharPtr ptr;
+ Int2 qualclass;
+ Uint1 residue;
+ Int4 right = -1;
+ RnaRefPtr rrp;
+ SeqCodeTablePtr sctp;
+ SeqDescrPtr sdp;
+ SeqEntryPtr sep;
+ Uint1 seqcode;
+ Uint1 shift;
+ SeqIdPtr sip;
+ Int2 siteidx;
+ SeqMapTablePtr smtp;
+ Boolean split;
+ CharPtr str;
+ Uint1 strand = Seq_strand_unknown;
+ CharPtr tmp;
+ tRNAPtr trna;
+ BioseqPtr unlockme = NULL;
+ ValNodePtr vnp;
+ StringItemPtr ffstring;
+
+
+ if (ajp == NULL || fcontext == NULL || qvp == NULL || ifp == NULL) return NULL;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return NULL;
+
+ if (ajp->index && asp != NULL) {
+ index = &asp->index;
+ } else {
+ index = NULL;
+ }
+
+ if (ajp->gbseq && asp != NULL) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ protein_pid_g [0] = '\0';
+
+ itemID = fcontext->itemID;
+
+ if (doKey) {
+ /* may need to map location between aa and dna */
+
+ if (ifp->mapToNuc) {
+
+ /* map mat_peptide, etc., to nucleotide coordinates */
+
+ sip = SeqLocId (sfp->location);
+ prd = BioseqFind (sip);
+ cds = SeqMgrGetCDSgivenProduct (prd, NULL);
+ CheckSeqLocForPartial (sfp->location, &noLeft, &noRight);
+ location = aaFeatLoc_to_dnaFeatLoc (cds, sfp->location);
+ SetSeqLocPartial (location, noLeft, noRight);
+ locforgene = location;
+ loc = location;
+
+ } else if (ifp->mapToProt) {
+
+ /* map CDS to protein product coordinates */
+
+ sip = SeqLocIdForProduct (sfp->product);
+ prd = BioseqFind (sip);
+ cds = SeqMgrGetCDSgivenProduct (prd, NULL);
+ location = dnaLoc_to_aaLoc (cds, sfp->location, TRUE, NULL, FALSE);
+ SetSeqLocPartial (location, FALSE, FALSE);
+ locforgene = sfp->location;
+ loc = location;
+
+ } else if (ifp->mapToGen) {
+
+ /* map CDS from cDNA to genomic Bioseq */
+
+ cdna = BioseqFindFromSeqLoc (sfp->location);
+ mrna = SeqMgrGetRNAgivenProduct (cdna, &mcontext);
+ CheckSeqLocForPartial (sfp->location, &noLeft, &noRight);
+ location = productLoc_to_locationLoc (mrna, sfp->location);
+ SetSeqLocPartial (location, noLeft, noRight);
+ locforgene = location;
+ loc = location;
+
+ } else if (ifp->mapToMrna) {
+
+ /* map gene from genomic to cDNA Bioseq */
+
+ sep = SeqMgrGetSeqEntryForData (bsp);
+ location = CreateWholeInterval (sep);
+ SetSeqLocPartial (location, FALSE, FALSE);
+ locforgene = location;
+ loc = location;
+
+ } else if (ifp->mapToPep) {
+
+ /* map protein processing from precursor to subpeptide Bioseq */
+
+ sep = SeqMgrGetSeqEntryForData (bsp);
+ location = CreateWholeInterval (sep);
+ SetSeqLocPartial (location, FALSE, FALSE);
+ locforgene = location;
+ loc = location;
+
+ } else {
+
+ /* no aa-dna or dna-aa mapping, just use location */
+
+ location = sfp->location;
+ locforgene = sfp->location;
+ }
+ if (location == NULL) return NULL;
+
+ sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
+ if (sep == NULL && IS_Bioseq_set (sep)) {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL && bssp->_class == BioseqseqSet_class_gen_prod_set) {
+ is_gps = TRUE;
+ }
+ }
+
+ if (bsp != NULL) {
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_OTHER) {
+ is_other = TRUE;
+ } else if (sip->choice == SEQID_GIBBSQ ||
+ sip->choice == SEQID_GIBBMT ||
+ sip->choice == SEQID_GIIM) {
+ is_journalscan = TRUE;
+ }
+ }
+ }
+
+ featdeftype = fcontext->featdeftype;
+ if (featdeftype < FEATDEF_GENE || featdeftype >= FEATDEF_MAX) {
+ featdeftype = FEATDEF_BAD;
+ }
+ key = FindKeyFromFeatDefType (featdeftype, TRUE);
+
+ if (format == GENPEPT_FMT && isProt) {
+ if (featdeftype == FEATDEF_REGION) {
+ key = "Region";
+ } else if (featdeftype == FEATDEF_BOND) {
+ key = "Bond";
+ } else if (featdeftype == FEATDEF_SITE) {
+ key = "Site";
+ }
+ if (ifp->mapToPep) {
+ if (featdeftype >= FEATDEF_preprotein && featdeftype <= FEATDEF_transit_peptide_aa) {
+ key = "Precursor";
+ itemID = 0;
+ }
+ }
+ }
+ if (! isProt) {
+ if (featdeftype == FEATDEF_preprotein) {
+ if (! is_other) {
+ key = "misc_feature";
+ encode_prefix = TRUE;
+ }
+ }
+ }
+
+ /* deal with unmappable impfeats */
+
+ if (featdeftype == FEATDEF_BAD && fcontext->seqfeattype == SEQFEAT_IMP) {
+ imp = (ImpFeatPtr) sfp->data.value.ptrvalue;
+ if (imp != NULL) {
+ key = imp->key;
+ }
+ }
+
+ FFStartPrint(ffstring, format, 5, 21, NULL, 0, 5, 21, "FT", /* ifp->firstfeat */ FALSE);
+ if (ajp->ajp.slp != NULL) {
+ FFAddOneString(ffstring, key, FALSE, FALSE, TILDE_IGNORE);
+ } else if ( GetWWW(ajp) /* && SeqMgrGetParentOfPart (bsp, NULL) == NULL */ ) {
+ FF_asn2gb_www_featkey (ffstring, key, sfp->location, fcontext->left + 1, fcontext->right + 1, fcontext->strand, itemID);
+ } else {
+ FFAddOneString(ffstring, key, FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddNChar(ffstring, ' ', 21 - 5 - StringLen(key), FALSE);
+
+ if (gbseq != NULL) {
+ gbfeat = GBFeatureNew ();
+ if (gbfeat != NULL) {
+ gbfeat->key = StringSave (key);
+ }
+ }
+
+ if (imp == NULL || StringHasNoText (imp->loc)) {
+
+
+ if (ajp->ajp.slp != NULL) {
+ sip = SeqIdParse ("lcl|dummy");
+ left = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_LEFT_END);
+ right = GetOffsetInBioseq (ajp->ajp.slp, bsp, SEQLOC_RIGHT_END);
+ strand = SeqLocStrand (ajp->ajp.slp);
+ split = FALSE;
+ newloc = SeqLocReMapEx (sip, ajp->ajp.slp, location, 0, FALSE, ajp->masterStyle);
+ /*
+ newloc = SeqLocCopyRegion (sip, location, bsp, left, right, strand, &split);
+ */
+ SeqIdFree (sip);
+ if (newloc == NULL) return NULL;
+ A2GBSeqLocReplaceID (newloc, ajp->ajp.slp);
+ str = FFFlatLoc (ajp, target, newloc, ajp->masterStyle);
+ SeqLocFree (newloc);
+ } else {
+ str = FFFlatLoc (ajp, target, location, ajp->masterStyle);
+ }
+ } else {
+ str = StringSave (imp->loc);
+ }
+ if ( GetWWW(ajp) ) {
+ FF_www_featloc (ffstring, str);
+ } else {
+ FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ if (gbseq != NULL) {
+ if (gbfeat != NULL) {
+ gbfeat->location = StringSave (str);
+ if (ajp->masterStyle) {
+ AddIntervalsToGbfeat (gbfeat, location, target);
+ } else {
+ AddIntervalsToGbfeat (gbfeat, location, NULL);
+ }
+ }
+ }
+
+ MemFree (str);
+
+ } else {
+
+ location = sfp->location;
+ locforgene = sfp->location;
+ }
+
+ /* populate qualifier table from feature fields */
+
+ /*
+ if (sfp->partial == TRUE)
+ sfp->partial = FlatAnnotPartial(sfp, use_product);
+ */
+
+ if (sfp->partial) {
+ partial = SeqLocPartialCheck (location);
+ if (partial == SLP_COMPLETE /* || partial > SLP_OTHER */ ) {
+ qvp [FTQUAL_partial].ble = TRUE;
+ }
+ if (LookForFuzz (location)) {
+ qvp [FTQUAL_partial].ble = FALSE;
+ }
+ if (imp != NULL) {
+ if (StringChr (imp->loc, '<') != NULL || StringChr (imp->loc, '>') != NULL) {
+ qvp [FTQUAL_partial].ble = FALSE;
+ }
+ }
+
+ /* hide unclassified /partial in RELEASE_MODE and ENTREZ_MODE */
+
+ if (ajp->mode == RELEASE_MODE || ajp->mode == ENTREZ_MODE) {
+ qvp [FTQUAL_partial].ble = FALSE;
+ }
+ /*
+ if (ajp->flags.checkQualSyntax) {
+ switch (featdeftype) {
+ case FEATDEF_conflict:
+ case FEATDEF_mutation:
+ case FEATDEF_N_region:
+ case FEATDEF_polyA_site:
+ qvp [FTQUAL_partial].ble = FALSE;
+ break;
+ default:
+ break;
+ }
+ }
+ */
+ }
+ if (ifp->mapToProt) {
+ qvp [FTQUAL_partial].ble = FALSE;
+ }
+
+ if (sfp->pseudo) {
+ pseudo = TRUE;
+ }
+
+ if (fcontext->seqfeattype == SEQFEAT_GENE) {
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ if (grp != NULL) {
+ if (! StringHasNoText (grp->locus)) {
+ qvp [FTQUAL_gene].str = grp->locus;
+ qvp [FTQUAL_locus_tag].str = grp->locus_tag;
+ qvp [FTQUAL_gene_desc].str = grp->desc;
+ qvp [FTQUAL_gene_syn].vnp = grp->syn;
+ } else if (grp->locus_tag != NULL) {
+ qvp [FTQUAL_locus_tag].str = grp->locus_tag;
+ qvp [FTQUAL_gene_desc].str = grp->desc;
+ qvp [FTQUAL_gene_syn].vnp = grp->syn;
+ } else if (! StringHasNoText (grp->desc)) {
+ qvp [FTQUAL_gene].str = grp->desc;
+ qvp [FTQUAL_gene_syn].vnp = grp->syn;
+ } else if (grp->syn != NULL) {
+ vnp = grp->syn;
+ qvp [FTQUAL_gene].str = (CharPtr) vnp->data.ptrvalue;
+ vnp = vnp->next;
+ qvp [FTQUAL_gene_syn].vnp = vnp;
+ }
+ qvp [FTQUAL_gene_map].str = grp->maploc;
+ qvp [FTQUAL_gene_allele].str = grp->allele;
+ qvp [FTQUAL_gene_xref].vnp = grp->db;
+ if (grp->pseudo) {
+ pseudo = TRUE;
+ }
+ }
+ if (! ajp->flags.geneSynsToNote) {
+ qvp [FTQUAL_gene_syn_refseq].vnp = qvp [FTQUAL_gene_syn].vnp;
+ qvp [FTQUAL_gene_syn].vnp = NULL;
+ }
+ operon = SeqMgrGetOverlappingOperon (locforgene, &ocontext);
+ if (operon != NULL) {
+ for (gbq = operon->qual; gbq != NULL; gbq = gbq->next) {
+ if (StringCmp (gbq->qual, "operon") == 0) {
+ qvp [FTQUAL_operon].gbq = gbq;
+ }
+ }
+ }
+
+ } else {
+
+ grp = SeqMgrGetGeneXref (sfp);
+ if (grp != NULL) {
+ qvp [FTQUAL_gene_xref].vnp = grp->db;
+ }
+ if (grp == NULL) {
+ sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
+ oldscope = SeqEntrySetScope (sep);
+ gene = SeqMgrGetOverlappingGene (locforgene, &gcontext);
+ SeqEntrySetScope (oldscope);
+ if (gene != NULL) {
+ qvp [FTQUAL_gene_note].str = gene->comment;
+ grp = (GeneRefPtr) gene->data.value.ptrvalue;
+ if (gene->pseudo) {
+ pseudo = TRUE;
+ }
+ if (grp != NULL && grp->db != NULL) {
+ qvp [FTQUAL_gene_xref].vnp = grp->db;
+ } else {
+ qvp [FTQUAL_gene_xref].vnp = gene->dbxref;
+ }
+ }
+ }
+ if (grp != NULL && grp->pseudo) {
+ pseudo = TRUE;
+ }
+ if (grp != NULL && (! SeqMgrGeneIsSuppressed (grp)) &&
+ (fcontext->featdeftype != FEATDEF_repeat_region || gene == NULL)) {
+ if (! StringHasNoText (grp->locus)) {
+ qvp [FTQUAL_gene].str = grp->locus;
+ qvp [FTQUAL_locus_tag].str = grp->locus_tag;
+ gene_syn = grp->syn;
+ } else if (! StringHasNoText (grp->locus_tag)) {
+ qvp [FTQUAL_locus_tag].str = grp->locus_tag;
+ gene_syn = grp->syn;
+ } else if (! StringHasNoText (grp->desc)) {
+ qvp [FTQUAL_gene].str = grp->desc;
+ gene_syn = grp->syn;
+ } else if (grp->syn != NULL) {
+ vnp = grp->syn;
+ qvp [FTQUAL_gene].str = (CharPtr) vnp->data.ptrvalue;
+ vnp = vnp->next;
+ gene_syn = vnp;
+ }
+ }
+ if (grp != NULL && fcontext->featdeftype != FEATDEF_variation) {
+ qvp [FTQUAL_gene_allele].str = grp->allele; /* now propagating /allele */
+ }
+ if (fcontext->seqfeattype != SEQFEAT_CDREGION &&
+ fcontext->seqfeattype != SEQFEAT_RNA) {
+ qvp [FTQUAL_gene_xref].vnp = NULL;
+ }
+ if (fcontext->featdeftype != FEATDEF_operon) {
+ grp = SeqMgrGetGeneXref (sfp);
+ if (grp == NULL || (! SeqMgrGeneIsSuppressed (grp))) {
+ operon = SeqMgrGetOverlappingOperon (locforgene, &ocontext);
+ if (operon != NULL) {
+ for (gbq = operon->qual; gbq != NULL; gbq = gbq->next) {
+ if (StringCmp (gbq->qual, "operon") == 0) {
+ qvp [FTQUAL_operon].gbq = gbq;
+ }
+ }
+ }
+ }
+ }
+
+ /* specific fields set here */
+
+ switch (fcontext->seqfeattype) {
+ case SEQFEAT_CDREGION :
+ if (! ifp->mapToProt) {
+ crp = (CdRegionPtr) sfp->data.value.ptrvalue;
+ if (crp != NULL) {
+
+ qvp [FTQUAL_codon_start].num = crp->frame;
+ if (qvp [FTQUAL_codon_start].num == 0) {
+ qvp [FTQUAL_codon_start].num = 1;
+ }
+ qvp [FTQUAL_transl_except].cbp = crp->code_break;
+ for (cbp = crp->code_break; cbp != NULL; cbp = cbp->next) {
+ seqcode = 0;
+ sctp = NULL;
+ cbaa = cbp->aa;
+ switch (cbaa.choice) {
+ case 1 :
+ seqcode = Seq_code_ncbieaa;
+ break;
+ case 2 :
+ seqcode = Seq_code_ncbi8aa;
+ break;
+ case 3 :
+ seqcode = Seq_code_ncbistdaa;
+ break;
+ default :
+ break;
+ }
+ if (seqcode != 0) {
+ sctp = SeqCodeTableFind (seqcode);
+ if (sctp != NULL) {
+ residue = cbaa.value.intvalue;
+ if (residue != 42) {
+ if (seqcode != Seq_code_ncbieaa) {
+ smtp = SeqMapTableFind (seqcode, Seq_code_ncbieaa);
+ residue = SeqMapTableConvert (smtp, residue);
+ }
+ if (residue == 'U') {
+ if (ajp->flags.selenocysteineToNote) {
+ qvp [FTQUAL_selenocysteine_note].str = "selenocysteine";
+ } else {
+ qvp [FTQUAL_selenocysteine].ble = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ gcp = crp->genetic_code;
+ if (gcp != NULL) {
+ for (vnp = gcp->data.ptrvalue; vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == 2 && vnp->data.intvalue != 0) {
+ qvp [FTQUAL_transl_table].num = vnp->data.intvalue;
+ }
+ }
+
+ /* suppress table 1, but always show it in GBSeqXML */
+
+ if (qvp [FTQUAL_transl_table].num == 1 && ajp->gbseq == NULL) {
+ qvp [FTQUAL_transl_table].num = 0;
+ }
+ }
+
+ if (sfp->product != NULL && SeqLocLen (sfp->product) != 0) {
+ protein = TRUE;
+ }
+ if (crp->conflict && (protein || (! sfp->excpt))) {
+ if (protein) {
+ qvp [FTQUAL_prot_conflict].str = conflict_msg;
+ } else {
+ /*
+ qvp [FTQUAL_prot_missing].str = no_protein_msg;
+ */
+ }
+ }
+ }
+
+ sip = SeqLocIdForProduct (sfp->product);
+ qvp [FTQUAL_protein_id].sip = sip;
+
+ sep = GetTopSeqEntryForEntityID (ajp->ajp.entityID);
+
+ if (! ajp->alwaysTranslCds) {
+
+ /* by default only show /translation if product bioseq is within entity */
+
+ oldscope = SeqEntrySetScope (sep);
+ prod = BioseqFind (sip);
+ SeqEntrySetScope (oldscope);
+
+ if (prod == NULL && ajp->showFarTransl) {
+
+ /* but flag can override and force far /translation */
+
+ prod = BioseqLockById (sip);
+ unlockme = prod;
+ }
+ }
+
+ prp = NULL;
+
+ if (prod != NULL) {
+ for (sip = prod->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GI) {
+ sprintf (protein_pid_g, "PID:g%ld", (long) sip->data.intvalue);
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (prod, NULL, Seq_descr_comment, &dcontext);
+ if (sdp != NULL && dcontext.level == 0) {
+ if (! StringHasNoText ((CharPtr) sdp->data.ptrvalue)) {
+ qvp [FTQUAL_prot_comment].str = (CharPtr) sdp->data.ptrvalue;
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (prod, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp != NULL && dcontext.level == 0) {
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip != NULL && mip->tech > 1 &&
+ mip->tech != MI_TECH_concept_trans &&
+ mip->tech != MI_TECH_concept_trans_a) {
+ str = StringForSeqTech (mip->tech);
+ if (! StringHasNoText (str)) {
+ qvp [FTQUAL_prot_method].str = str;
+ }
+ }
+ }
+ prot = SeqMgrGetBestProteinFeature (prod, &pcontext);
+ if (prot != NULL) {
+ prp = (ProtRefPtr) prot->data.value.ptrvalue;
+ if (prp != NULL && prp->processed < 2) {
+ qvp [FTQUAL_prot_note].str = prot->comment;
+ }
+ }
+ }
+
+ /* protein xref overrides names, but should not prevent /protein_id, etc. */
+
+ prpxref = SeqMgrGetProtXref (sfp);
+ if (prpxref != NULL) {
+ prp = prpxref;
+ }
+ if (prp != NULL) {
+ vnp = prp->name;
+ if (vnp != NULL && (! StringHasNoText ((CharPtr) vnp->data.ptrvalue))) {
+ qvp [FTQUAL_cds_product].str = (CharPtr) vnp->data.ptrvalue;
+ vnp = vnp->next;
+ qvp [FTQUAL_prot_names].vnp = vnp;
+ }
+ qvp [FTQUAL_prot_desc].str = prp->desc;
+ qvp [FTQUAL_prot_activity].vnp = prp->activity;
+ qvp [FTQUAL_prot_EC_number].vnp = prp->ec;
+ }
+
+ if (! pseudo) {
+ if (prod != NULL || ajp->transIfNoProd || ajp->alwaysTranslCds) {
+ if (doKey) {
+ qvp [FTQUAL_translation].ble = TRUE;
+ }
+ }
+ }
+
+ if (ifp->isCDS) {
+ icp = (IntCdsBlockPtr) ifp;
+ qvp [FTQUAL_figure].str = icp->fig;
+ qvp [FTQUAL_maploc].str = icp->maploc;
+ }
+ } else {
+ qvp [FTQUAL_coded_by].slp = sfp->location;
+
+ crp = (CdRegionPtr) sfp->data.value.ptrvalue;
+ if (crp != NULL) {
+ gcp = crp->genetic_code;
+ if (gcp != NULL) {
+ for (vnp = gcp->data.ptrvalue; vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == 2 && vnp->data.intvalue != 0) {
+ qvp [FTQUAL_transl_table].num = vnp->data.intvalue;
+ }
+ }
+
+ /* suppress table 1 */
+
+ if (qvp [FTQUAL_transl_table].num == 1) {
+ qvp [FTQUAL_transl_table].num = 0;
+ }
+ }
+ for (cbp = crp->code_break; cbp != NULL; cbp = cbp->next) {
+ seqcode = 0;
+ sctp = NULL;
+ cbaa = cbp->aa;
+ switch (cbaa.choice) {
+ case 1 :
+ seqcode = Seq_code_ncbieaa;
+ break;
+ case 2 :
+ seqcode = Seq_code_ncbi8aa;
+ break;
+ case 3 :
+ seqcode = Seq_code_ncbistdaa;
+ break;
+ default :
+ break;
+ }
+ if (seqcode != 0) {
+ sctp = SeqCodeTableFind (seqcode);
+ if (sctp != NULL) {
+ residue = cbaa.value.intvalue;
+ if (residue != 42) {
+ if (seqcode != Seq_code_ncbieaa) {
+ smtp = SeqMapTableFind (seqcode, Seq_code_ncbieaa);
+ residue = SeqMapTableConvert (smtp, residue);
+ }
+ if (residue == 'U') {
+ if (ajp->flags.selenocysteineToNote) {
+ qvp [FTQUAL_selenocysteine_note].str = "selenocysteine";
+ } else {
+ qvp [FTQUAL_selenocysteine].ble = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+ case SEQFEAT_PROT :
+ if (! ifp->mapToPep) {
+ prp = (ProtRefPtr) sfp->data.value.ptrvalue;
+ if (prp != NULL) {
+ vnp = prp->name;
+ if (vnp != NULL && (! StringHasNoText ((CharPtr) vnp->data.ptrvalue))) {
+ qvp [FTQUAL_product].str = (CharPtr) vnp->data.ptrvalue;
+ vnp = vnp->next;
+ qvp [FTQUAL_prot_names].vnp = vnp;
+ }
+ if (format != GENPEPT_FMT) {
+ qvp [FTQUAL_prot_desc].str = prp->desc;
+ } else {
+ qvp [FTQUAL_prot_name].str = prp->desc;
+ }
+ if (format != GENPEPT_FMT || prp->processed != 2) {
+ qvp [FTQUAL_prot_activity].vnp = prp->activity;
+ }
+ qvp [FTQUAL_prot_EC_number].vnp = prp->ec;
+ }
+ sip = SeqLocIdForProduct (sfp->product);
+ if (sip != NULL) {
+ /* for RefSeq records or GenBank not release_mode */
+ if (is_other || (! ajp->flags.forGbRelease)) {
+ qvp [FTQUAL_protein_id].sip = sip;
+ }
+ prod = BioseqFind (sip);
+ }
+ } else {
+ qvp [FTQUAL_derived_from].slp = sfp->location;
+ sip = SeqLocIdForProduct (sfp->product);
+ if (sip != NULL) {
+ prod = BioseqFind (sip);
+ if (prod != NULL) {
+ prot = SeqMgrGetBestProteinFeature (prod, NULL);
+ if (prot != NULL) {
+ precursor_comment = prot->comment;
+ }
+ }
+ }
+ }
+ prp = (ProtRefPtr) sfp->data.value.ptrvalue;
+ if (prp != NULL) {
+ if (! pseudo) {
+ if (ajp->showPeptide) {
+ if (prp->processed == 2 || prp->processed == 3 || prp->processed == 4) {
+ qvp [FTQUAL_peptide].ble = TRUE;
+ }
+ }
+ }
+ if (prp->processed == 3 || prp->processed == 4) {
+ if (! is_other) {
+ /* Only RefSeq allows product on signal or transit peptide */
+ qvp [FTQUAL_product].str = NULL;
+ }
+ }
+ if (prp->processed == 1 && encode_prefix && (! is_other)) {
+ qvp [FTQUAL_encodes].str = qvp [FTQUAL_product].str;
+ qvp [FTQUAL_product].str = NULL;
+ }
+ }
+ break;
+ case SEQFEAT_RNA :
+ rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
+ if (rrp != NULL) {
+ if (rrp->pseudo) {
+ pseudo = TRUE;
+ }
+ if (rrp->type == 2) {
+ sip = SeqLocIdForProduct (sfp->product);
+ if (sip != NULL) {
+ /* for RefSeq records or GenBank not release_mode or entrez_mode */
+ if (is_other || (ajp->mode == SEQUIN_MODE || ajp->mode == DUMP_MODE)) {
+ qvp [FTQUAL_transcript_id].sip = sip;
+ } else {
+ /* otherwise now goes in note */
+ qvp [FTQUAL_transcript_id_note].sip = sip; /* !!! remove October 15, 2003 !!! */
+ }
+ prod = BioseqFind (sip);
+ }
+ if (! pseudo) {
+ if (ajp->showTranscript) {
+ qvp [FTQUAL_transcription].ble = TRUE;
+ }
+ }
+ }
+ if (rrp->type == 3) {
+ if (rrp->ext.choice == 1) {
+ /* amino acid could not be parsed into structured form */
+ if (! ajp->flags.dropIllegalQuals) {
+ str = (CharPtr) rrp->ext.value.ptrvalue;
+ qvp [FTQUAL_product].str = str;
+ } else {
+ qvp [FTQUAL_product].str = "tRNA-OTHER";
+ }
+ } else if (rrp->ext.choice == 2) {
+ trna = (tRNAPtr) rrp->ext.value.ptrvalue;
+ if (trna != NULL) {
+ aa = 0;
+ if (trna->aatype == 2) {
+ aa = trna->aa;
+ } else {
+ from = 0;
+ switch (trna->aatype) {
+ case 0 :
+ from = 0;
+ break;
+ case 1 :
+ from = Seq_code_iupacaa;
+ break;
+ case 2 :
+ from = Seq_code_ncbieaa;
+ break;
+ case 3 :
+ from = Seq_code_ncbi8aa;
+ break;
+ case 4 :
+ from = Seq_code_ncbistdaa;
+ break;
+ default:
+ break;
+ }
+ if (ajp->flags.iupacaaOnly) {
+ code = Seq_code_iupacaa;
+ } else {
+ code = Seq_code_ncbieaa;
+ }
+ smtp = SeqMapTableFind (code, from);
+ if (smtp != NULL) {
+ aa = SeqMapTableConvert (smtp, trna->aa);
+ if (aa == 255 && from == Seq_code_iupacaa && trna->aa == 'U') {
+ aa = 'U';
+ }
+ }
+ }
+ if (ajp->flags.iupacaaOnly) {
+ smtp = SeqMapTableFind (Seq_code_iupacaa, Seq_code_ncbieaa);
+ if (smtp != NULL) {
+ aa = SeqMapTableConvert (smtp, trna->aa);
+ } else {
+ aa = 'X';
+ }
+ }
+ if (aa > 0 && aa != 255) {
+ if (aa <= 74) {
+ shift = 0;
+ } else if (aa > 79) {
+ shift = 2;
+ } else {
+ shift = 1;
+ }
+ if (aa != '*') {
+ idx = aa - (64 + shift);
+ } else {
+ idx = 25;
+ }
+ if (idx > 0 && idx < 26) {
+ str = trnaList [idx];
+ qvp [FTQUAL_product].str = str;
+ if (StringNICmp (str, "tRNA-", 5) == 0) {
+ qvp [FTQUAL_trna_aa].str = str + 5;
+ }
+ }
+ }
+ qvp [FTQUAL_anticodon].slp = trna->anticodon;
+ qvp [FTQUAL_trna_codons].trp = trna;
+ }
+ }
+ } else {
+ if (rrp->ext.choice == 1) {
+ str = (CharPtr) rrp->ext.value.ptrvalue;
+ qvp [FTQUAL_product].str = str;
+
+ /*
+ if (rrp->type == 255 && (! StringHasNoText (str))) {
+ if (StringICmp (str, "internal transcribed spacer 1") == 0 ||
+ StringICmp (str, "internal transcribed spacer ITS1") == 0 ||
+ StringICmp (str, "ITS1") == 0) {
+ qvp [FTQUAL_rrna_its].str = "ITS1";
+ } else if (StringICmp (str, "internal transcribed spacer 2") == 0 ||
+ StringICmp (str, "internal transcribed spacer ITS2") == 0 ||
+ StringICmp (str, "ITS2") == 0) {
+ qvp [FTQUAL_rrna_its].str = "ITS2";
+ } else if (StringICmp (str, "internal transcribed spacer 3") == 0 ||
+ StringICmp (str, "internal transcribed spacer ITS3") == 0 ||
+ StringICmp (str, "ITS3") == 0) {
+ qvp [FTQUAL_rrna_its].str = "ITS3";
+ }
+ }
+ */
+ }
+ }
+ }
+ break;
+ case SEQFEAT_REGION :
+ if (format == GENPEPT_FMT && featdeftype == FEATDEF_REGION && isProt) {
+ qvp [FTQUAL_region_name].str = (CharPtr) sfp->data.value.ptrvalue;
+ } else {
+ qvp [FTQUAL_region].str = (CharPtr) sfp->data.value.ptrvalue;
+ }
+ break;
+ case SEQFEAT_COMMENT :
+ break;
+ case SEQFEAT_BOND :
+ bondidx = (Int2) sfp->data.value.intvalue;
+ if (bondidx == 255) {
+ bondidx = 5;
+ }
+ if (bondidx > 0 && bondidx < 6) {
+ if (format == GENPEPT_FMT && isProt) {
+ qvp [FTQUAL_bond_type].str = bondList [bondidx];
+ } else {
+ qvp [FTQUAL_bond].str = bondList [bondidx];
+ }
+ }
+ break;
+ case SEQFEAT_SITE :
+ siteidx = (Int2) sfp->data.value.intvalue;
+ if (siteidx == 255) {
+ siteidx = 26;
+ }
+ if (siteidx > 0 && siteidx < 27) {
+ if (format == GENPEPT_FMT && isProt) {
+ qvp [FTQUAL_site_type].str = siteList [siteidx];
+ } else {
+ qvp [FTQUAL_site].str = siteList [siteidx];
+ }
+ }
+ break;
+ case SEQFEAT_PSEC_STR :
+ qvp [FTQUAL_sec_str_type].num = sfp->data.value.intvalue;
+ break;
+ case SEQFEAT_HET :
+ qvp [FTQUAL_heterogen].str = (CharPtr) sfp->data.value.ptrvalue;
+ break;
+ default :
+ break;
+ }
+ }
+
+ /* common fields set here */
+
+ VisitUserObjectsInUop (sfp->ext, (Pointer) qvp, RecordUserObjectsInQVP);
+
+ if (fcontext->featdeftype == FEATDEF_repeat_region) {
+ pseudo = FALSE;
+ }
+
+ qvp [FTQUAL_pseudo].ble = pseudo;
+
+ qvp [FTQUAL_seqfeat_note].str = sfp->comment;
+
+ /* if RELEASE_MODE, check list of features that can have /pseudo */
+
+ if (ajp->flags.dropIllegalQuals && pseudo &&
+ (fcontext->seqfeattype == SEQFEAT_RNA || fcontext->seqfeattype == SEQFEAT_IMP) ) {
+ switch (featdeftype) {
+
+ case FEATDEF_allele:
+ case FEATDEF_attenuator:
+ case FEATDEF_CAAT_signal:
+ case FEATDEF_conflict:
+ case FEATDEF_D_loop:
+ case FEATDEF_enhancer:
+ case FEATDEF_GC_signal:
+ case FEATDEF_iDNA:
+ case FEATDEF_intron:
+ case FEATDEF_LTR:
+ case FEATDEF_misc_binding:
+ case FEATDEF_misc_difference:
+ case FEATDEF_misc_recomb:
+ case FEATDEF_misc_RNA:
+ case FEATDEF_misc_signal:
+ case FEATDEF_misc_structure:
+ case FEATDEF_modified_base:
+ case FEATDEF_mutation:
+ case FEATDEF_old_sequence:
+ case FEATDEF_polyA_signal:
+ case FEATDEF_polyA_site:
+ case FEATDEF_precursor_RNA:
+ case FEATDEF_prim_transcript:
+ case FEATDEF_primer_bind:
+ case FEATDEF_protein_bind:
+ case FEATDEF_RBS:
+ case FEATDEF_repeat_region:
+ case FEATDEF_repeat_unit:
+ case FEATDEF_rep_origin:
+ case FEATDEF_satellite:
+ case FEATDEF_stem_loop:
+ case FEATDEF_STS:
+ case FEATDEF_TATA_signal:
+ case FEATDEF_terminator:
+ case FEATDEF_unsure:
+ case FEATDEF_variation:
+ case FEATDEF_3clip:
+ case FEATDEF_3UTR:
+ case FEATDEF_5clip:
+ case FEATDEF_5UTR:
+ case FEATDEF_10_signal:
+ case FEATDEF_35_signal:
+ qvp [FTQUAL_pseudo].ble = FALSE;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (format != GENPEPT_FMT) {
+ qvp [FTQUAL_evidence].num = sfp->exp_ev;
+ }
+
+ /* exception currently legal only on CDS */
+
+ if ((! ajp->flags.dropIllegalQuals) || fcontext->seqfeattype == SEQFEAT_CDREGION) {
+ qvp [FTQUAL_exception].str = sfp->except_text;
+
+ if (sfp->excpt && qvp [FTQUAL_exception].str == NULL) {
+ if (qvp [FTQUAL_seqfeat_note].str != NULL) {
+ if (ajp->flags.dropIllegalQuals &&
+ (! StringInStringList (qvp [FTQUAL_seqfeat_note].str, validExceptionString))) {
+ /* !!! if ajp->flags.dropIllegalQuals, check CDS list to avoid losing note !!! */
+ qvp [FTQUAL_exception].str = NULL;
+ } else {
+ /* if no /exception text, use text in comment, remove from /note */
+
+ qvp [FTQUAL_exception].str = qvp [FTQUAL_seqfeat_note].str;
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+ } else {
+ qvp [FTQUAL_exception].str = "No explanation supplied";
+ }
+
+ /* !!! if ajp->flags.dropIllegalQuals, check CDS list here as well !!! */
+ if (ajp->flags.dropIllegalQuals &&
+ (! StringInStringList (qvp [FTQUAL_seqfeat_note].str, validExceptionString))) {
+ qvp [FTQUAL_exception].str = NULL;
+ }
+ }
+ if (ajp->flags.dropIllegalQuals) {
+ str = qvp [FTQUAL_exception].str;
+ ParseException (str, &exception_string, &exception_note, TRUE, is_other);
+ qvp [FTQUAL_exception].str = exception_string;
+ qvp [FTQUAL_exception_note].str = exception_note;
+ /*
+ if (is_other) {
+ if (! StringInStringList (qvp [FTQUAL_exception].str, validRefSeqExceptionString)) {
+ qvp [FTQUAL_exception_note].str = qvp [FTQUAL_exception].str;
+ qvp [FTQUAL_exception].str = NULL;
+ }
+ } else {
+ if (! StringInStringList (qvp [FTQUAL_exception].str, validExceptionString)) {
+ qvp [FTQUAL_exception_note].str = qvp [FTQUAL_exception].str;
+ qvp [FTQUAL_exception].str = NULL;
+ }
+ }
+ */
+ }
+ } else {
+ qvp [FTQUAL_exception_note].str = sfp->except_text;
+ }
+ if (StringHasNoText (qvp [FTQUAL_exception].str)) {
+ qvp [FTQUAL_exception].str = NULL;
+ }
+ if (StringHasNoText (qvp [FTQUAL_exception_note].str)) {
+ qvp [FTQUAL_exception_note].str = NULL;
+ }
+
+ qvp [FTQUAL_db_xref].vnp = sfp->dbxref;
+ qvp [FTQUAL_citation].vnp = sfp->cit;
+
+ /* /product same as sfp->comment will suppress /note */
+
+ if (! StringHasNoText (qvp [FTQUAL_product].str) &&
+ StringICmp (sfp->comment, qvp [FTQUAL_product].str) == 0) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+ /* case sensitive AJ011317.1 */
+ if (! StringHasNoText (qvp [FTQUAL_cds_product].str) &&
+ StringCmp (sfp->comment, qvp [FTQUAL_cds_product].str) == 0) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+
+ /* /gene same as sfp->comment will suppress /note */
+ /* case sensitive -gi|6572973|gb|AF195052.1|AF195052 */
+
+ if (! StringHasNoText (qvp [FTQUAL_gene].str) &&
+ StringCmp (sfp->comment, qvp [FTQUAL_gene].str) == 0) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+
+ /* gene /note same as sfp->comment will suppress /note - U92435.1 says do not do this */
+
+ /*
+ if (! StringHasNoText (qvp [FTQUAL_gene_note].str) &&
+ StringICmp (sfp->comment, qvp [FTQUAL_gene_note].str) == 0) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+ */
+
+ /* if site sfp->comment contains site name, suppress site in /note */
+
+ if (! StringHasNoText (qvp [FTQUAL_site].str) &&
+ StringStr (sfp->comment, qvp [FTQUAL_site].str) != NULL) {
+ qvp [FTQUAL_site].str = NULL;
+ }
+
+ /* /EC_number same as sfp->comment will suppress /note */
+
+ for (vnp = qvp [FTQUAL_prot_EC_number].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if ((! StringHasNoText (str)) &&
+ StringICmp (sfp->comment, str) == 0) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+ }
+
+ /* mat_peptide precursor same as sfp->comment will suppress /note in GenPept */
+
+ if (precursor_comment != NULL && StringCmp (precursor_comment, sfp->comment) == 0) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+
+
+ /* now go through gbqual list */
+
+ for (gbq = sfp->qual; gbq != NULL; gbq = gbq->next) {
+ idx = GbqualToFeaturIndex (gbq->qual);
+ if (idx > 0 && idx < ASN2GNBK_TOTAL_FEATUR) {
+ if (qvp [idx].gbq == NULL) {
+ if (idx == FTQUAL_product_quals) {
+ if (qvp [FTQUAL_product].str == NULL) {
+ qvp [FTQUAL_product].str = gbq->val;
+ } else if (qvp [FTQUAL_xtra_prod_quals].gbq == NULL) {
+ /* chain will include remaining product gbquals */
+ qvp [FTQUAL_xtra_prod_quals].gbq = gbq;
+ }
+ } else {
+ qvp [idx].gbq = gbq;
+ }
+ }
+
+ } else if (idx == 0) {
+
+ qualclass = IllegalGbqualToClass (gbq->qual);
+ if (qualclass == 0) {
+ qualclass = Qual_class_quote;
+ }
+ tmp = StringSave (gbq->val);
+ if (tmp != NULL) {
+ str = MemNew (sizeof (Char) * (StringLen (gbq->qual) + StringLen (tmp) + 10));
+ if (str != NULL) {
+ if (qualclass == Qual_class_quote) {
+ if (StringIsJustQuotes (tmp)) {
+ sprintf (str, "/%s", gbq->qual);
+ } else {
+ ptr = tmp;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch == '"') {
+ *ptr = '\'';
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ sprintf (str, "/%s=\"%s\"", gbq->qual, tmp);
+ }
+ ValNodeCopyStr (&illegal, 0, str);
+ } else if (qualclass == Qual_class_noquote || qualclass == Qual_class_label) {
+ if (StringIsJustQuotes (tmp)) {
+ sprintf (str, "/%s", gbq->qual);
+ } else {
+ sprintf (str, "/%s=%s", gbq->qual, tmp);
+ }
+ ValNodeCopyStr (&illegal, 0, str);
+ }
+ MemFree (str);
+ }
+ MemFree (tmp);
+ }
+ }
+ }
+
+ /* illegal qualifiers are copied and formatted in valnode chain */
+
+ if (! ajp->flags.dropIllegalQuals) {
+ qvp [FTQUAL_illegal_qual].vnp = illegal;
+ }
+
+ /* remove protein description that equals the gene name, case sensitive */
+
+ if (StringCmp (qvp [FTQUAL_gene].str, qvp [FTQUAL_prot_desc].str) == 0) {
+ qvp [FTQUAL_prot_desc].str = NULL;
+ }
+
+ /* remove protein description that equals the cds product, case sensitive */
+
+ if (StringCmp (qvp [FTQUAL_cds_product].str, qvp [FTQUAL_prot_desc].str) == 0) {
+ qvp [FTQUAL_prot_desc].str = NULL;
+ }
+
+ /* remove comment contained in prot_desc - gi|4530123|gb|AF071539.1|AF071539 */
+
+ if (StringStr (qvp [FTQUAL_prot_desc].str, qvp [FTQUAL_seqfeat_note].str) != NULL) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+
+ /* remove protein description that equals the standard name */
+
+ if (qvp [FTQUAL_standard_name].gbq != NULL && qvp [FTQUAL_prot_desc].str != NULL) {
+ gbq = qvp [FTQUAL_standard_name].gbq;
+ lasttype = gbq->qual;
+ while (gbq != NULL && StringICmp (gbq->qual, lasttype) == 0) {
+ if (StringICmp (gbq->val, qvp [FTQUAL_prot_desc].str) == 0) {
+ qvp [FTQUAL_prot_desc].str = NULL;
+ }
+ gbq = gbq->next;
+ }
+ }
+
+ /* remove protein description that equals a gene synonym - case insensitive AF109216.1 */
+
+ for (vnp = gene_syn; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if ((! StringHasNoText (str)) &&
+ StringCmp (str, qvp [FTQUAL_prot_desc].str) == 0) {
+ /* NC_001823 leave in prot_desc if no cds_product */
+ if (qvp [FTQUAL_cds_product].str != NULL) {
+ qvp [FTQUAL_prot_desc].str = NULL;
+ }
+ }
+ }
+
+ /* remove comment that equals a gene synonym */
+
+ if (format != GENPEPT_FMT && (! ifp->mapToProt)) {
+ for (vnp = gene_syn; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if ((! StringHasNoText (str)) &&
+ StringICmp (str, qvp [FTQUAL_seqfeat_note].str) == 0) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+ }
+ }
+
+ /* remove protein comment descriptor that equals the protein note */
+
+ if (StringCmp (qvp [FTQUAL_prot_note].str, qvp [FTQUAL_prot_comment].str) == 0) {
+ qvp [FTQUAL_prot_comment].str = NULL;
+ }
+
+ /* suppress cds comment if a subset of protein note - AF002218.1 */
+
+ if (StringStr (qvp [FTQUAL_prot_note].str, qvp [FTQUAL_seqfeat_note].str) != NULL) {
+ qvp [FTQUAL_seqfeat_note].str = NULL;
+ }
+
+ /* suppress selenocysteine note if already in comment */
+
+ if (StringStr (sfp->comment, "selenocysteine") != NULL) {
+ qvp [FTQUAL_selenocysteine_note].str = NULL;
+ }
+
+ /* if /allele inherited from gene, suppress allele gbqual on feature */
+
+ if (qvp [FTQUAL_gene_allele].str != NULL) {
+ qvp [FTQUAL_allele].gbq = NULL;
+ }
+
+ /* now print qualifiers from table */
+
+#ifdef DISPLAY_STRINGS
+ s_DisplayQVP(qvp, feat_note_order);
+#endif
+
+ /* Strip duplicate notes */
+
+ if ((StringCmp(qvp[FTQUAL_product].str,
+ qvp[FTQUAL_seqfeat_note].str) == 0)) {
+ qvp[FTQUAL_seqfeat_note].str = NULL;
+ }
+
+ if ((qvp[FTQUAL_standard_name].gbq != NULL) &&
+ (qvp[FTQUAL_standard_name].gbq->val != NULL)) {
+ if ((StringCmp(qvp[FTQUAL_seqfeat_note].str,
+ qvp[FTQUAL_standard_name].gbq->val) == 0)) {
+ qvp[FTQUAL_seqfeat_note].str = NULL;
+ }
+ }
+
+ /* Display strings for debugging purposes */
+
+#ifdef DISPLAY_STRINGS
+ s_DisplayQVP(qvp, feat_qual_order);
+#endif
+
+ /* optionally populate indexes for NCBI internal database */
+
+ if (index != NULL) {
+ if (! StringHasNoText (qvp [FTQUAL_gene].str)) {
+ ValNodeCopyStrToHead (&(index->genes), 0, qvp [FTQUAL_gene].str);
+ }
+ }
+
+ if (doKey) {
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+
+ /* Build the flat file */
+ FormatFeatureBlockQuals (ffstring, ajp, asp, bsp, featdeftype, gene_syn,
+ lasttype, location, prod,
+ protein_pid_g, qvp,
+ left, right, strand,
+ sfp, target, is_other,
+ is_journalscan, is_gps);
+
+ /* ??? and then deal with the various note types separately (not in order table) ??? */
+
+ /* free aa-dna or dna-aa mapped location */
+
+ SeqLocFree (loc);
+
+ ValNodeFreeData (illegal);
+ MemFree (exception_string);
+ MemFree (exception_note);
+
+ BioseqUnlock (unlockme);
+
+ str = FFEndPrint (ajp, ffstring, format, 21, 21, 21, 21, "FT");
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (gbseq != NULL) {
+ if (gbfeat != NULL) {
+ AddFeatureToGbseq (gbseq, gbfeat, str, sfp);
+ }
+ }
+
+ FFRecycleString(ajp, ffstring);
+ return str;
+}
+
+NLM_EXTERN CharPtr FormatFeatureBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BioseqPtr bsp;
+ SeqMgrFeatContext fcontext;
+ FmtType format;
+ QualValPtr qvp;
+ SeqFeatPtr sfp;
+ BioseqPtr target;
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+ target = asp->target;
+ bsp = asp->bsp;
+ if (target == NULL || bsp == NULL) return NULL;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ qvp = afp->qvp;
+ if (qvp == NULL) return NULL;
+ format = afp->format;
+
+ /* all features in this list are known to be valid for the designated mode */
+
+ sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
+ if (sfp == NULL) return NULL;
+
+ return FormatFeatureBlockEx (ajp, asp, bsp, target, sfp, &fcontext, qvp,
+ format, (IntFeatBlockPtr) bbp, ISA_aa (bsp->mol), TRUE);
+}
+
+
+/* stand alone function to produce qualifiers in genbank style */
+
+static void StripLeadingSpaces (
+ CharPtr str
+)
+
+{
+ Uchar ch;
+ CharPtr dst;
+ CharPtr ptr;
+
+
+ if (str == NULL || str [0] == '\0') return;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ while (ch == ' ') {
+ ptr++;
+ ch = *ptr;
+ }
+ while (ch != '\n' && ch != '\r') {
+ *dst = ch;
+ dst++;
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = ch;
+ dst++;
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = '\0';
+}
+
+NLM_EXTERN CharPtr FormatFeatureQuals (
+ SeqFeatPtr sfp
+)
+
+{
+ IntAsn2gbJob ajb;
+ IntAsn2gbJobPtr ajp;
+ BioseqPtr bsp;
+ SeqMgrFeatContext fcontext;
+ IntCdsBlock ifb;
+ IntFeatBlockPtr ifp;
+ size_t max;
+ QualValPtr qvp;
+ CharPtr str;
+
+ if (sfp == NULL) return NULL;
+ bsp = BioseqFindFromSeqLoc (sfp->location);
+ if (bsp == NULL) return NULL;
+
+ if (SeqMgrGetDesiredFeature (0, bsp, 0, 0, sfp, &fcontext) != sfp) return NULL;
+
+ MemSet ((Pointer) &ajb, 0, sizeof (IntAsn2gbJob));
+ ajp = &ajb;
+ MemSet ((Pointer) &ifb, 0, sizeof (IntCdsBlock));
+ ifp = (IntFeatBlockPtr) &ifb;
+
+ max = (size_t) (MAX (ASN2GNBK_TOTAL_SOURCE, ASN2GNBK_TOTAL_FEATUR));
+ qvp = MemNew (sizeof (QualVal) * (max + 5));
+ if (qvp == NULL) return NULL;
+
+ str = FormatFeatureBlockEx (ajp, NULL, NULL, NULL, sfp, &fcontext, qvp,
+ GENBANK_FMT, ifp, FALSE, FALSE);
+
+ MemFree (qvp);
+ StripLeadingSpaces (str);
+ return str;
+}
+
diff --git a/api/asn2gnb5.c b/api/asn2gnb5.c
new file mode 100644
index 00000000..e338a417
--- /dev/null
+++ b/api/asn2gnb5.c
@@ -0,0 +1,3618 @@
+/* asn2gnb5.c
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: asn2gnb5.c
+*
+* Author: Karl Sirotkin, Tom Madden, Tatiana Tatusov, Jonathan Kans,
+* Mati Shomrat
+*
+* Version Creation Date: 10/21/98
+*
+* $Revision: 1.3 $
+*
+* File Description: New GenBank flatfile generator - work in progress
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <objall.h>
+#include <objsset.h>
+#include <objsub.h>
+#include <objfdef.h>
+#include <objpubme.h>
+#include <seqport.h>
+#include <sequtil.h>
+#include <sqnutils.h>
+#include <subutil.h>
+#include <tofasta.h>
+#include <explore.h>
+#include <gbfeat.h>
+#include <gbftdef.h>
+#include <edutil.h>
+#include <alignmgr2.h>
+#include <asn2gnbi.h>
+
+#ifdef WIN_MAC
+#if __profile__
+#include <Profiler.h>
+#endif
+#endif
+
+/* URLs */
+
+NLM_EXTERN Char link_feat [MAX_WWWBUF];
+#define DEF_LINK_FEAT "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?"
+
+NLM_EXTERN Char link_seq [MAX_WWWBUF];
+#define DEF_LINK_SEQ "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?"
+
+NLM_EXTERN Char link_wgs [MAX_WWWBUF];
+#define DEF_LINK_WGS "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?"
+
+NLM_EXTERN Char link_omim [MAX_WWWBUF];
+#define DEF_LINK_OMIM "http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id="
+
+NLM_EXTERN Char ref_link [MAX_WWWBUF];
+#define DEF_LINK_REF "http://www.ncbi.nlm.nih.gov/RefSeq/"
+
+NLM_EXTERN Char nt_link [MAX_WWWBUF];
+#define DEF_LINK_NT "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?view=graph&val="
+
+NLM_EXTERN Char doc_link [MAX_WWWBUF];
+#define DEF_LINK_DOC "http://www.ncbi.nlm.nih.gov/genome/guide/build.html"
+
+NLM_EXTERN Char ev_link [MAX_WWWBUF];
+#define DEF_LINK_EV "http://www.ncbi.nlm.nih.gov/sutils/evv.cgi?"
+
+NLM_EXTERN Char ec_link [MAX_WWWBUF];
+#define DEF_LINK_EC "http://www.expasy.ch/cgi-bin/nicezyme.pl?"
+
+NLM_EXTERN Char link_tax [MAX_WWWBUF];
+#define DEF_LINK_TAX "http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?"
+
+static Char link_ff [MAX_WWWBUF];
+#define DEF_LINK_FF "/cgi-bin/Entrez/getfeat?"
+
+NLM_EXTERN Char link_muid [MAX_WWWBUF];
+#define DEF_LINK_MUID "/entrez/utils/qmap.cgi?"
+
+static Char link_ace [MAX_WWWBUF];
+#define DEF_LINK_ACE "http://www.ncbi.nlm.nih.gov/IEB/Research/Acembly/av.cgi?db=worm&c=gene&q="
+
+NLM_EXTERN Char link_code [MAX_WWWBUF];
+#define DEF_LINK_CODE "http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi?"
+
+static Char link_fly [MAX_WWWBUF];
+#define DEF_LINK_FLY "http://flybase.bio.indiana.edu/.bin/fbidq.html?"
+
+static Char link_fly_fban [MAX_WWWBUF];
+#define DEF_LINK_FBAN "http://www.fruitfly.org/cgi-bin/annot/fban?"
+
+static Char link_fly_fbgn [MAX_WWWBUF];
+#define DEF_LINK_FBGN "http://flybase.bio.indiana.edu/.bin/fbidq.html?"
+
+static Char link_cog [MAX_WWWBUF];
+#define DEF_LINK_COG "http://www.ncbi.nlm.nih.gov/cgi-bin/COG/palox?"
+
+static Char link_sgd [MAX_WWWBUF];
+#define DEF_LINK_SGD "/cgi-bin/Entrez/referer?http://genome-www4.stanford.edu/cgi-bin/SGD/locus.pl?locus="
+
+static Char link_gdb [MAX_WWWBUF];
+#define DEF_LINK_GDB "http://www.gdb.org/gdb-bin/genera/genera/hgd/DBObject/GDB:"
+
+static Char link_ck [MAX_WWWBUF];
+#define DEF_LINK_CK "http://flybane.berkeley.edu/cgi-bin/cDNA/CK_clone.pl?db=CK&dbid="
+
+static Char link_rice [MAX_WWWBUF];
+#define DEF_LINK_RICE "http://ars-genome.cornell.edu/cgi-bin/WebAce/webace?db=ricegenes&class=Marker&object="
+
+static Char link_sp [MAX_WWWBUF];
+#define DEF_LINK_SP "/cgi-bin/Entrez/referer?http://expasy.hcuge.ch/cgi-bin/sprot-search-ac%3f"
+
+static Char link_pdb [MAX_WWWBUF];
+#define DEF_LINK_PDB "/cgi-bin/Entrez/referer?http://expasy.hcuge.ch/cgi-bin/get-pdb-entry%3f"
+
+static Char link_UniSTS [MAX_WWWBUF];
+#define DEF_LINK_UniSTS "http://www.ncbi.nlm.nih.gov/genome/sts/sts.cgi?uid="
+
+static Char link_dbSTS [MAX_WWWBUF];
+#define DEF_LINK_dbSTS "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?"
+
+static Char link_dbEST [MAX_WWWBUF];
+#define DEF_LINK_dbEST "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?"
+
+static Char link_locus [MAX_WWWBUF];
+#define DEF_LINK_LOCUS "http://www.ncbi.nlm.nih.gov/LocusLink/LocRpt.cgi?l="
+
+static Char link_snp [MAX_WWWBUF];
+#define DEF_LINK_SNP "http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?type=rs&rs="
+
+static Char link_ratmap [MAX_WWWBUF];
+#define DEF_LINK_RATMAP "http://ratmap.gen.gu.se/action.lasso?-database=RATMAPfmPro&-layout=Detail&-response=/RM/Detail+Format.html&-search&-recid="
+
+static Char link_rgd [MAX_WWWBUF];
+#define DEF_LINK_RGD "http://rgd.mcw.edu/query/query.cgi?id="
+
+static Char link_mgd [MAX_WWWBUF];
+#define DEF_LINK_MGD "http://www.informatics.jax.org/searches/accession_report.cgi?id=MGI:"
+
+static Char link_cdd [MAX_WWWBUF];
+#define DEF_LINK_CDD "http://www.ncbi.nlm.nih.gov/Structure/cdd/cddsrv.cgi?uid="
+
+static Char link_niaest [MAX_WWWBUF];
+#define DEF_LINK_NIAEST "http://lgsun.grc.nia.nih.gov/cgi-bin/pro3?sname1="
+
+static Char link_worm_base [MAX_WWWBUF];
+#define DEF_LINK_WORM_BASE "http://www.wormbase.org/db/get?class=Sequence;name="
+
+static Char link_worfdb [MAX_WWWBUF];
+#define DEF_LINK_WORFDB "http://worfdb.dfci.harvard.edu/search.pl?form=1&search="
+
+static Char link_nextdb [MAX_WWWBUF];
+#define DEF_LINK_NEXTDB "http://nematode.lab.nig.ac.jp/cgi-bin/db/ShowGeneInfo.sh?celk="
+
+static Char link_imgt [MAX_WWWBUF];
+#define DEF_LINK_IMGT "http://imgt.cines.fr:8104/cgi-bin/IMGTlect.jv?query=202+"
+
+static Char link_ifo [MAX_WWWBUF];
+#define DEF_LINK_IFO "http://www.ifo.or.jp/index_e.html"
+
+static Char link_jcm [MAX_WWWBUF];
+#define DEF_LINK_JCM "http://www.jcm.riken.go.jp/cgi-bin/jcm/jcm_number?JCM="
+
+static Char link_isfinder [MAX_WWWBUF];
+#define DEF_LINK_ISFINDER "http://www-is.biotoul.fr/scripts/is/is_spec.idc?name="
+
+static Char link_gabi [MAX_WWWBUF];
+#define DEF_LINK_GABI "https://gabi.rzpd.de/cgi-bin-protected/GreenCards.pl.cgi?Mode=ShowBioObject&BioObjectName="
+
+static Char link_fantom [MAX_WWWBUF];
+#define DEF_LINK_FANTOM "http://fantom.gsc.riken.go.jp/db/view/main.cgi?masterid="
+
+static Char link_interpro [MAX_WWWBUF];
+#define DEF_LINK_INTERPRO "http://www.ebi.ac.uk/interpro/ISearch?mode=ipr&query="
+
+static Char link_genedb [MAX_WWWBUF];
+#define DEF_LINK_GENEDB "http://www.genedb.org/genedb/Dispatcher?formType=navBar&submit=Search+for&organism=All%3Apombe%3Acerevisiae%3Adicty%3Aasp%3Atryp%3Aleish%3Amalaria%3Astyphi%3Aglossina&desc=yes&ohmr=%2F&name="
+
+static Char link_geneid [MAX_WWWBUF];
+#define DEF_LINK_GENEID "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=retrieve&dopt=graphics&list_uids="
+
+static Char link_zfin [MAX_WWWBUF];
+#define DEF_LINK_ZFIN "http://zfin.org/cgi-bin/webdriver?MIval=aa-markerview.apg&OID="
+
+static Char link_rebase [MAX_WWWBUF];
+#define DEF_LINK_REBASE "http://rebase.neb.com/rebase/enz/"
+
+NLM_EXTERN Char link_encode [MAX_WWWBUF];
+#define DEF_LINK_ENCODE "http://www.nhgri.nih.gov/10005107"
+
+/* www utility functions */
+
+NLM_EXTERN Boolean GetWWW (IntAsn2gbJobPtr ajp) {
+ return ajp->www;
+}
+
+NLM_EXTERN void FiniWWW (IntAsn2gbJobPtr ajp) {
+ ajp->www = FALSE;
+}
+
+NLM_EXTERN void InitWWW (IntAsn2gbJobPtr ajp)
+{
+ ajp->www = TRUE;
+
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_FEAT", DEF_LINK_FEAT, link_feat, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_WGS", DEF_LINK_WGS, link_wgs, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_OMIM", DEF_LINK_OMIM, link_omim, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_REF", DEF_LINK_REF, ref_link, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_NT", DEF_LINK_NT, nt_link, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_DOC", DEF_LINK_DOC, doc_link, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_EV", DEF_LINK_EV, ev_link, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_EC", DEF_LINK_EC, ec_link, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_FF", DEF_LINK_FF, link_ff, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_MUID", DEF_LINK_MUID, link_muid, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_FF", DEF_LINK_FF, link_ff, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_MUID", DEF_LINK_MUID, link_muid, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_ACE", DEF_LINK_ACE, link_ace, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SEQ", DEF_LINK_SEQ, link_seq, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_TAX", DEF_LINK_TAX, link_tax, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_CODE", DEF_LINK_CODE, link_code, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_FLY", DEF_LINK_FLY, link_fly, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_COG", DEF_LINK_COG, link_cog, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SGD", DEF_LINK_SGD, link_sgd, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SGD", DEF_LINK_GDB, link_gdb, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_CK", DEF_LINK_CK, link_ck, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_RICE", DEF_LINK_RICE, link_rice, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SP", DEF_LINK_SP, link_sp, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_PDB", DEF_LINK_PDB, link_pdb, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_OMIM", DEF_LINK_OMIM, link_omim, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_UniSTS", DEF_LINK_UniSTS, link_UniSTS, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_dbSTS", DEF_LINK_dbSTS, link_dbSTS, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_dbEST", DEF_LINK_dbEST, link_dbEST, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_LOCUS", DEF_LINK_LOCUS, link_locus, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_SNP", DEF_LINK_SNP, link_snp, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_RATMAP", DEF_LINK_RATMAP, link_ratmap, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_RGD", DEF_LINK_RGD, link_rgd, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_MGD", DEF_LINK_MGD, link_mgd, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_FBGN", DEF_LINK_FBGN, link_fly_fbgn, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_FBAN", DEF_LINK_FBAN, link_fly_fban, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_CDD", DEF_LINK_CDD, link_cdd, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_NIAEST", DEF_LINK_NIAEST, link_niaest, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_WORM_BASE", DEF_LINK_WORM_BASE, link_worm_base, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_WORFDB", DEF_LINK_WORFDB, link_worfdb, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_NEXTDB", DEF_LINK_NEXTDB, link_nextdb, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_IMGT", DEF_LINK_IMGT, link_imgt, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_IFO", DEF_LINK_IFO, link_ifo, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_JCM", DEF_LINK_JCM, link_jcm, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_ISFINDER", DEF_LINK_ISFINDER, link_isfinder, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_GABI", DEF_LINK_GABI, link_gabi, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_FANTOM", DEF_LINK_FANTOM, link_fantom, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_INTERPRO", DEF_LINK_INTERPRO, link_interpro, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_GENEDB", DEF_LINK_GENEDB, link_genedb, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_GENEID", DEF_LINK_GENEID, link_geneid, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_ZFIN", DEF_LINK_ZFIN, link_zfin, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_REBASE", DEF_LINK_REBASE, link_rebase, MAX_WWWBUF);
+ GetAppParam ("NCBI", "WWWENTREZ", "LINK_ENCODE", DEF_LINK_ENCODE, link_encode, MAX_WWWBUF);
+}
+
+
+
+NLM_EXTERN void FF_www_featloc(StringItemPtr ffstring, CharPtr loc)
+{
+ CharPtr ptr;
+
+ if (loc == NULL) return;
+
+ for ( ptr = loc; *ptr != '\0'; ++ptr ) {
+ switch (*ptr) {
+ case '<' :
+ /*FFAddOneString(ffstring, "<", FALSE, FALSE, TILDE_IGNORE);*/
+ FFAddOneString(ffstring, "&lt;", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ case '>' :
+ /*FFAddOneString(ffstring, ">", FALSE, FALSE, TILDE_IGNORE);*/
+ FFAddOneString(ffstring, "&gt;", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ default:
+ FFAddOneChar(ffstring, *ptr, FALSE);
+ break;
+ }
+ }
+}
+
+
+static void FF_www_db_xref_std (
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier,
+ CharPtr link
+)
+{
+ while (*identifier == ' ')
+ identifier++;
+
+ FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "<a href=", link, identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, ">", identifier, "</a>", FALSE, FALSE, TILDE_IGNORE);
+}
+
+static void FF_www_db_xref_fly (
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ CharPtr link = link_fly;
+
+ if ( StringStr(identifier, "FBa") != NULL ) {
+ link = link_fly_fban;
+ }
+ if ( StringStr(identifier, "FBg") != NULL ) {
+ link = link_fly_fbgn;
+ }
+
+ FF_www_db_xref_std(ffstring, db, identifier, link);
+}
+
+static void FF_www_db_xref_mgd (
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ if (StringNICmp (identifier, "MGI:", 4) == 0) {
+ identifier += 4;
+ } else if (StringNICmp (identifier, "MGD:", 4) == 0) {
+ identifier += 4;
+ }
+
+ FF_www_db_xref_std(ffstring, "MGI", identifier, link_mgd);
+}
+
+static void FF_www_db_xref_pid(
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ if ( *identifier != 'g' ) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_seq);
+ return;
+ }
+ ++identifier;
+
+ FFAddTextToString(ffstring, NULL, db, ":g", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "<a href=", link_seq, "val=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, identifier, ">", identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+}
+
+/*prefix = "<a href=%sval=gnl|dbest|%s>"; */
+static void FF_www_db_xref_dbEST(
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ while (*identifier == ' ')
+ identifier++;
+
+ FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "<a href=", link_dbEST, "val=gnl|dbest|", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, identifier, ">", identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+}
+
+static void FF_www_db_xref_dbSTS(
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ while (*identifier == ' ')
+ identifier++;
+
+ FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "<a href=", link_dbSTS, "val=gnl|dbsst|", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, identifier, ">", identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+}
+
+static void FF_www_db_xref_niaEST(
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ while (*identifier == ' ')
+ identifier++;
+
+ FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "<a href=", link_niaest, identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "&val=1>", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+}
+
+
+static void FF_www_db_xref_ifo(
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ while (*identifier == ' ')
+ identifier++;
+
+ FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "<a href=", link_ifo, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+}
+
+
+static void FF_www_db_xref_gdb(
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ CharPtr start;
+ Char id[20], PNTR idp = id;
+
+ FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
+
+ if ( (start = StringStr(identifier, "G00-")) != NULL ) {
+ /* G00-id-id */
+ start += StringLen("G00-");
+ while ( *start != '\0' ) {
+ if ( *start != '-' ) {
+ *idp++ = *start++;
+ } else {
+ *start++;
+ }
+ }
+ *idp = '\0';
+ FFAddTextToString(ffstring, "<a href=", link_gdb, id, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, ">", identifier, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else if ( IS_DIGIT(*identifier) ) {
+ /* id */
+ FFAddTextToString(ffstring, "<a href=", link_gdb, identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, ">", identifier, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, identifier, FALSE, FALSE, TILDE_IGNORE);
+ }
+}
+
+static void FF_www_db_xref_rebase (
+ StringItemPtr ffstring,
+ CharPtr db,
+ CharPtr identifier
+)
+{
+ while (*identifier == ' ')
+ identifier++;
+
+ FFAddTextToString(ffstring, NULL, db, ":", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "<a href=", link_rebase, identifier, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, ".html>", identifier, "</a>", FALSE, FALSE, TILDE_IGNORE);
+}
+
+
+static void Do_www_db_xref(
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr db, CharPtr identifier
+)
+{
+ if ( ffstring == NULL || db == NULL || identifier == NULL ) return;
+
+ if ( StringCmp(db, "FLYBASE") == 0) {
+ FF_www_db_xref_fly(ffstring, db, identifier);
+ } else if ( StringCmp(db , "COG") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_cog);
+ } else if ( StringCmp(db , "UniSTS") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_UniSTS);
+ } else if ( StringCmp(db , "LocusID") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_locus);
+ } else if ( StringCmp(db , "InterimID") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_locus);
+ } else if ( StringCmp(db , "MIM") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_omim);
+ } else if ( StringCmp(db , "SGD") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_sgd);
+ } else if ( StringCmp(db , "IMGT/LIGM") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_imgt);
+ } else if ( StringCmp(db , "CK") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_ck);
+ } else if ( StringCmp(db , "RiceGenes") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_rice);
+ } else if ( StringCmp(db , "dbSNP") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_snp);
+ } else if ( StringCmp(db , "RATMAP") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_ratmap);
+ } else if ( StringCmp(db , "RGD") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_rgd);
+ } else if ( StringCmp(db , "MGI") == 0) {
+ FF_www_db_xref_mgd(ffstring, db, identifier);
+ } else if ( StringCmp(db , "MGD") == 0) {
+ FF_www_db_xref_mgd(ffstring, db, identifier);
+ } else if ( StringCmp(db , "CDD") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_cdd);
+ } else if ( StringCmp(db , "JCM") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_jcm);
+ } else if ( StringCmp(db , "ISFinder") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_isfinder);
+ } else if ( StringCmp(db , "GABI") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_gabi);
+ } else if ( StringCmp(db , "ZFIN") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_zfin);
+ } else if ( StringCmp(db , "FANTOM_DB") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_fantom);
+ } else if ( StringCmp(db , "Interpro") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_interpro);
+ } else if ( StringCmp(db , "GeneDB") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_genedb);
+ } else if ( StringCmp(db , "GeneID") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_geneid);
+ } else if ( StringCmp(db , "PID") == 0) {
+ FF_www_db_xref_pid(ffstring, db, identifier);
+ } else if ( StringCmp(db , "dbEST") == 0) {
+ FF_www_db_xref_dbEST(ffstring, db, identifier);
+ } else if ( StringCmp(db , "dbSTS") == 0) {
+ FF_www_db_xref_dbSTS(ffstring, db, identifier);
+ } else if ( StringCmp(db , "niaEST") == 0) {
+ FF_www_db_xref_niaEST(ffstring, db, identifier);
+ } else if ( StringCmp(db , "WormBase") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_worm_base);
+ } else if ( StringCmp(db , "AceView/WormGenes") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_ace);
+ } else if ( StringCmp(db , "WorfDB") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_worfdb);
+ } else if ( StringCmp(db , "NextDB") == 0) {
+ FF_www_db_xref_std(ffstring, db, identifier, link_nextdb);
+ } else if ( StringCmp(db , "IFO") == 0) {
+ FF_www_db_xref_ifo(ffstring, db, identifier);
+ } else if ( StringCmp(db , "GDB") == 0) {
+ FF_www_db_xref_gdb(ffstring, db, identifier);
+ } else if ( StringCmp(db , "REBASE") == 0) {
+ FF_www_db_xref_rebase(ffstring, db, identifier);
+
+ } else {
+ /* default: no link just the text */
+ FFAddTextToString(ffstring, db, ":", identifier, FALSE, FALSE, TILDE_IGNORE);
+ }
+}
+
+NLM_EXTERN void FF_www_db_xref(
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr db, CharPtr identifier
+)
+{
+ if ( ffstring == NULL || db == NULL || identifier == NULL ) return;
+
+ if ( GetWWW(ajp) ) {
+ Do_www_db_xref (ajp, ffstring, db, identifier);
+ } else { /* not in www mode */
+ if (StringCmp(db , "MGD") == 0 || StringCmp(db , "MGI") == 0) {
+ if (StringNICmp (identifier, "MGI:", 4) == 0) {
+ identifier += 4;
+ } else if (StringNICmp (identifier, "MGD:", 4) == 0) {
+ identifier += 4;
+ }
+ FFAddTextToString(ffstring, "MGI", ":", identifier, FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddTextToString(ffstring, db, ":", identifier, FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+}
+
+/* public function to get URLs for collaboration-approved db_xrefs */
+
+static Boolean links_loaded = FALSE;
+
+NLM_EXTERN CharPtr asn2gnbk_dbxref (
+ DbtagPtr dbt
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Char buf [80];
+ StringItemPtr ffstring;
+ ObjectIdPtr oip;
+ CharPtr ptr;
+ CharPtr str;
+ CharPtr tmp;
+
+ if (dbt == NULL) return NULL;
+ if (StringHasNoText (dbt->db)) return NULL;
+ oip = dbt->tag;
+ if (oip == NULL) return NULL;
+
+ if (! StringHasNoText (oip->str)) {
+ if (StringLen (dbt->db) + StringLen (oip->str) < 80) {
+ sprintf (buf, "%s", oip->str);
+ }
+ } else {
+ sprintf (buf, "%ld", (long) oip->id);
+ }
+
+ ajp = (IntAsn2gbJobPtr) MemNew (sizeof (IntAsn2gbJob));
+ if (ajp == NULL) return NULL;
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return NULL;
+
+ if (! links_loaded) {
+ InitWWW (ajp);
+ links_loaded = TRUE;
+ }
+ ajp->www = TRUE;
+
+ Do_www_db_xref (ajp, ffstring, dbt->db, buf);
+
+ ajp->www = FALSE;
+
+ str = FFToCharPtr (ffstring);
+
+ FFRecycleString (ajp, ffstring);
+ MemFree (ajp);
+
+ tmp = StringChr (str, '<');
+ if (tmp != NULL) {
+ ptr = StringSave (tmp);
+ tmp = StringChr (ptr, '>');
+ if (tmp != NULL) {
+ tmp++;
+ *tmp = '\0';
+ }
+ MemFree (str);
+ str = ptr;
+ } else {
+ str = MemFree (str);
+ }
+
+ return str;
+}
+
+/* format references section */
+
+NLM_EXTERN AuthListPtr GetAuthListPtr (
+ PubdescPtr pdp,
+ CitSubPtr csp
+)
+
+{
+ AuthListPtr alp = NULL;
+ CitArtPtr cap;
+ CitBookPtr cbp;
+ CitGenPtr cgp;
+ CitPatPtr cpp;
+ ValNodePtr vnp;
+
+ if (csp != NULL) {
+ alp = csp->authors;
+ if (alp != NULL) return alp;
+ }
+ if (pdp == NULL) return NULL;
+
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ switch (vnp->choice) {
+ case PUB_Gen :
+ cgp = (CitGenPtr) vnp->data.ptrvalue;
+ if (cgp != NULL) {
+ alp = cgp->authors;
+ }
+ break;
+ case PUB_Sub :
+ csp = (CitSubPtr) vnp->data.ptrvalue;
+ if (csp != NULL) {
+ alp = csp->authors;
+ }
+ break;
+ case PUB_Article :
+ cap = (CitArtPtr) vnp->data.ptrvalue;
+ if (cap != NULL) {
+ alp = cap->authors;
+ }
+ break;
+ case PUB_Book :
+ case PUB_Proc :
+ case PUB_Man :
+ cbp = (CitBookPtr) vnp->data.ptrvalue;
+ if (cbp != NULL) {
+ alp = cbp->authors;
+ }
+ break;
+ case PUB_Patent :
+ cpp = (CitPatPtr) vnp->data.ptrvalue;
+ if (cpp != NULL) {
+ alp = cpp->authors;
+ }
+ break;
+ default :
+ break;
+ }
+
+ if (alp != NULL) return alp;
+ }
+
+ return NULL;
+}
+
+static CharPtr MakeSingleAuthorString (
+ FmtType format,
+ CharPtr prefix,
+ CharPtr name,
+ CharPtr initials,
+ CharPtr suffix,
+ IndxPtr index,
+ GBReferencePtr gbref
+)
+
+{
+ Char ch;
+ Char dummy [10];
+ size_t len;
+ CharPtr nametoindex;
+ CharPtr ptr;
+ CharPtr str;
+ CharPtr tmp;
+
+ if (name == NULL) return NULL;
+
+ /* !!! clean up 'et al' as (presumably) last author !!! */
+
+ /* !!! temporary to suppress diff !!! */
+ {
+ if (StringLen (name) <= 6 &&
+ (StringNICmp (name, "et al", 5) == 0 || StringNICmp (name, "et,al", 5) == 0)) {
+ if (StringCmp (prefix, " and ") == 0) {
+ prefix = NULL;
+ dummy [0] = ' ';
+ StringNCpy_0 (dummy + 1, name, sizeof (dummy) - 1);
+ name = dummy;
+ }
+ }
+ }
+ /*
+ if (StringLen (name) <= 6 &&
+ (StringNICmp (name, "et al", 5) == 0 || StringNICmp (name, "et,al", 5) == 0)) {
+ name = "et al.";
+ if (StringCmp (prefix, " and ") == 0) {
+ prefix = ", ";
+ }
+ }
+ */
+
+ len = StringLen (name) + StringLen (initials) + StringLen (suffix) + StringLen (prefix);
+ str = MemNew (sizeof (Char) * (len + 4));
+ if (str == NULL) return NULL;
+
+ ptr = str;
+ if (! StringHasNoText (prefix)) {
+ ptr = StringMove (ptr, prefix);
+ }
+ nametoindex = ptr;
+
+ /* initials and suffix to support structured name fields */
+
+ tmp = StringMove (ptr, name);
+ if (! StringHasNoText (initials)) {
+ tmp = StringMove (tmp, ",");
+ tmp = StringMove (tmp, initials);
+ }
+ if (! StringHasNoText (suffix)) {
+ tmp = StringMove (tmp, " ");
+ tmp = StringMove (tmp, suffix);
+ }
+
+ /* optionally populate indexes for NCBI internal database */
+
+ if (index != NULL) {
+ ValNodeCopyStrToHead (&(index->authors), 0, nametoindex);
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (gbref != NULL) {
+ ValNodeCopyStr (&(gbref->authors), 0, nametoindex);
+ }
+
+ /* if embl, remove commas in individual names, starting after prefix */
+
+ if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+ tmp = ptr;
+ ch = *tmp;
+ while (ch != '\0') {
+ if (ch == ',') {
+ *tmp = ' ';
+ }
+ tmp++;
+ ch = *tmp;
+ }
+ }
+
+ return str;
+}
+
+NLM_EXTERN CharPtr GetAuthorsString (
+ FmtType format,
+ AuthListPtr alp,
+ CharPtr PNTR consortP,
+ IndxPtr index,
+ GBReferencePtr gbref
+)
+
+{
+ AuthorPtr ap;
+ ValNodePtr conslist;
+ Int2 count;
+ ValNodePtr head = NULL;
+ ValNodePtr names;
+ ValNodePtr next;
+ NameStdPtr nsp;
+ PersonIdPtr pid;
+ ValNodePtr pidlist;
+ CharPtr prefix = NULL;
+ CharPtr str;
+ ValNodePtr vnp;
+
+ if (alp == NULL) return NULL;
+
+ alp = AsnIoMemCopy ((Pointer) alp,
+ (AsnReadFunc) AuthListAsnRead,
+ (AsnWriteFunc) AuthListAsnWrite);
+ if (alp == NULL) return NULL;
+
+ count = 0;
+ if (alp->choice == 1) {
+
+ pidlist = NULL;
+ conslist = NULL;
+
+ for (names = alp->names; names != NULL; names = names->next) {
+ ap = (AuthorPtr) names->data.ptrvalue;
+ if (ap == NULL) continue;
+ pid = ap->name;
+ if (pid == NULL) continue;
+ if (pid->choice == 2 || pid->choice == 3 || pid->choice == 4) {
+ ValNodeAddPointer (&pidlist, 0, (Pointer) pid);
+ } else if (pid->choice == 5) {
+ ValNodeAddPointer (&conslist, 0, (Pointer) pid);
+ }
+ }
+
+ for (vnp = pidlist; vnp != NULL; vnp = vnp->next) {
+ next = vnp->next;
+ if (next == NULL) {
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ if (count == 0) {
+ prefix = NULL;
+ } else {
+ prefix = " and ";
+ }
+ }
+ }
+ str = NULL;
+ pid = (PersonIdPtr) vnp->data.ptrvalue;
+ if (pid->choice == 2) {
+ nsp = (NameStdPtr) pid->data;
+ if (nsp != NULL) {
+ if (! StringHasNoText (nsp->names [0])) {
+ str = MakeSingleAuthorString (format, prefix, nsp->names [0], nsp->names [4], nsp->names [5], index, gbref);
+ } else if (! StringHasNoText (nsp->names [3])) {
+ str = MakeSingleAuthorString (format, prefix, nsp->names [3], NULL, NULL, index, gbref);
+ }
+ }
+ } else if (pid->choice == 3 || pid->choice == 4) {
+ str = MakeSingleAuthorString (format, prefix, (CharPtr) pid->data, NULL, NULL, index, gbref);
+ }
+ if (str != NULL) {
+ ValNodeAddStr (&head, 0, str);
+ count++;
+ }
+ prefix = ", ";
+ }
+
+ for (vnp = conslist; vnp != NULL; vnp = vnp->next) {
+ str = NULL;
+ pid = (PersonIdPtr) vnp->data.ptrvalue;
+ if (pid->choice == 5) {
+ str = MakeSingleAuthorString (format, NULL, (CharPtr) pid->data, NULL, NULL, index, NULL);
+ if ((! StringHasNoText (str)) && consortP != NULL && *consortP == NULL) {
+ *consortP = StringSave (str);
+ }
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (gbref != NULL) {
+ gbref->consortium = StringSave (str);
+ }
+
+ str = MemFree (str);
+ }
+ }
+
+ ValNodeFree (pidlist);
+ ValNodeFree (conslist);
+
+ } else if (alp->choice == 2 || alp->choice == 3) {
+ for (vnp = alp->names; vnp != NULL; vnp = vnp->next) {
+ next = vnp->next;
+ if (next == NULL) {
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ if (count == 0) {
+ prefix = NULL;
+ } else {
+ prefix = " and ";
+ }
+ }
+ }
+ str = MakeSingleAuthorString (format, prefix, (CharPtr) vnp->data.ptrvalue, NULL, NULL, index, gbref);
+ if (str != NULL) {
+ ValNodeAddStr (&head, 0, str);
+ count++;
+ }
+ prefix = ", ";
+ }
+ }
+
+ str = MergeFFValNodeStrs (head);
+
+ ValNodeFreeData (head);
+
+ AuthListFree (alp);
+
+ return str;
+}
+
+/*
+Strips all spaces in string in following manner. If the function
+meet several spaces (spaces and tabs) in succession it replaces them
+with one space. Strips all spaces after '(' and before ')'
+*/
+
+static void StrStripSpaces (
+ CharPtr str
+)
+
+{
+ CharPtr new_str;
+
+ if (str == NULL) return;
+
+ new_str = str;
+ while (*str != '\0') {
+ *new_str++ = *str;
+ if (*str == ' ' || *str == '\t' || *str == '(') {
+ for (str++; *str == ' ' || *str == '\t'; str++) continue;
+ if (*str == ')' || *str == ',') {
+ new_str--;
+ }
+ } else {
+ str++;
+ }
+ }
+ *new_str = '\0';
+}
+
+static Boolean AllCaps (
+ CharPtr p
+)
+
+{
+ if (p == NULL) return FALSE;
+
+ for (p++; p != NULL && *p != '\0'; p++) {
+ if (IS_LOWER (*p)) return FALSE;
+ }
+ return TRUE;
+}
+
+static void CleanEquals (
+ CharPtr p
+)
+
+{
+ if (p == NULL) return;
+
+ for (; *p != '\0'; p++) {
+ if (*p == '\"') {
+ *p = '\'';
+ }
+ }
+}
+
+static CharPtr GetPubTitle (
+ FmtType format,
+ PubdescPtr pdp,
+ CitSubPtr csp
+)
+
+{
+ CitArtPtr cap;
+ CitBookPtr cbp;
+ CitGenPtr cgp;
+ Char ch;
+ CitPatPtr cpp;
+ MedlineEntryPtr mep;
+ CharPtr ptr;
+ CharPtr title = NULL;
+ ValNodePtr ttl = NULL;
+ ValNodePtr vnp;
+
+ if (csp != NULL) {
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ title = "Direct Submission";
+ return StringSave (title);
+ } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+ return NULL;
+ }
+ }
+ if (pdp == NULL) return NULL;
+
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ switch (vnp->choice) {
+ case PUB_Gen :
+ cgp = (CitGenPtr) vnp->data.ptrvalue;
+ if (cgp != NULL) {
+ if (! StringHasNoText (cgp->title)) return StringSave (cgp->title);
+ if (! StringHasNoText (cgp->cit)) {
+ ptr = StringStr (cgp->cit, "Title=\"");
+ if (ptr != NULL) {
+ title = StringSave (ptr + 7);
+ for (ptr = title; *ptr != '\0'; ptr++) {
+ if (*ptr == '"') {
+ *ptr = '\0';
+ break;
+ }
+ }
+ return title;
+ }
+ }
+ }
+ break;
+ case PUB_Sub :
+ csp = (CitSubPtr) vnp->data.ptrvalue;
+ if (csp != NULL) {
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ title = "Direct Submission";
+ return StringSave (title);
+ } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+ return NULL;
+ }
+ }
+ break;
+ case PUB_Medline :
+ mep = (MedlineEntryPtr) vnp->data.ptrvalue;
+ if (mep != NULL) {
+ cap = mep->cit;
+ if (cap != NULL) {
+ ttl = cap->title;
+ }
+ }
+ break;
+ case PUB_Article :
+ cap = (CitArtPtr) vnp->data.ptrvalue;
+ if (cap != NULL) {
+ ttl = cap->title;
+ }
+ break;
+ /* case PUB_Book : */
+ case PUB_Proc :
+ case PUB_Man :
+ cbp = (CitBookPtr) vnp->data.ptrvalue;
+ if (cbp != NULL) {
+ ttl = cbp->title;
+ if (ttl != NULL) {
+ title = (CharPtr) ttl->data.ptrvalue;
+ if (! StringHasNoText (title)) {
+ title = StringSave (title);
+ if (StringLen (title) > 3) {
+ ch = *title;
+ if (IS_LOWER (ch)) {
+ *title = TO_UPPER (ch);
+ }
+ ptr = title;
+ if (AllCaps (ptr)) {
+ for (ptr++; ptr != NULL && *ptr != '\0'; ptr++) {
+ ch = *ptr;
+ *ptr = TO_LOWER (ch);
+ }
+ }
+ }
+ return title;
+ }
+ }
+ }
+ break;
+ case PUB_Patent :
+ cpp = (CitPatPtr) vnp->data.ptrvalue;
+ if (cpp != NULL) {
+ title = cpp->title;
+ if (! StringHasNoText (title)) {
+ return StringSave (title);
+ }
+ }
+ break;
+ default :
+ break;
+ }
+
+ if (ttl != NULL) {
+ title = (CharPtr) ttl->data.ptrvalue;
+ if (! StringHasNoText (title)) {
+ return StringSave (title);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+static void CleanPubTitle (
+ CharPtr title
+)
+
+{
+ CharPtr p;
+ Boolean remove_it;
+
+ if (title == NULL) return;
+
+ CleanEquals (title);
+
+ for (p = title + StringLen (title) - 1; p > title + 2; p--) {
+ if (*p == ' ') {
+ *p = '\0';
+ } else if (*p == '.') {
+ remove_it = FALSE;
+ if (p > title + 5) {
+ if (*(p - 1) != '.' || *(p - 2) != '.') {
+ remove_it = TRUE;
+ }
+ }
+ if (remove_it) {
+ *p = '\0';
+ }
+ break;
+ } else {
+ break;
+ }
+ }
+}
+
+/*
+medline type page numbering is expanded (e.g., 125-35 -> 125-135,
+F124-34 -> F124-F134, 12a-c -> 12a-12c).
+If only one page is given, this is output without a dash.
+Expanded numbering is validated to ensure that the
+first number is smaller than or equal to the second and
+that the first letter is less than or identical to the second
+(i.e., a < c). If the input is all letters (i.e., roman numerals)
+this is not validated.
+
+Return values:
+ 0 : valid page numbering.
+-1 : invalid page numbering.
+*/
+
+#define MAX_PAGE_DIGITS 12
+
+static Int2 FixPages (
+ CharPtr out_pages,
+ CharPtr in_pages
+)
+
+{
+ Boolean dash=TRUE, first_alpha;
+ Char firstbegin[MAX_PAGE_DIGITS];
+ Char secondbegin[MAX_PAGE_DIGITS];
+ Char firstend[MAX_PAGE_DIGITS];
+ Char secondend[MAX_PAGE_DIGITS];
+ Char temp[MAX_PAGE_DIGITS];
+ CharPtr alphabegin, numbegin, alphaend, numend, ptr, in=in_pages;
+ Int2 diff, index, retval=0;
+ Int2 length_nb, length_ab, length_ne, length_ae;
+ Int4 num1=0, num2=0;
+
+ if (in_pages == NULL) return retval;
+
+ while (*in != '\0')
+ { /* Check for digits in input*/
+ if (IS_DIGIT(*in))
+ break;
+ in++;
+ }
+
+ if (*in == '\0' || (in != in_pages && *(in-1) == ' '))
+ { /* if all letters (i.e. roman numerals), put out. */
+ out_pages = StringCpy(out_pages, in_pages);
+ return retval;
+ }
+
+ in = in_pages;
+ if (IS_DIGIT(*in))
+ { /* Do digits come first? */
+ first_alpha = FALSE;
+ index=0;
+ while (IS_DIGIT(*in) || *in == ' ')
+ {
+ firstbegin[index] = *in;
+ if (*in != ' ')
+ index++;
+ in++;
+ if (*in == '-')
+ break;
+
+ }
+ firstbegin[index] = '\0';
+ index=0;
+ if (*in != '-')
+ { /* After digits look for letters. */
+ while (IS_ALPHA(*in) || *in == ' ')
+ {
+ secondbegin[index] = *in;
+ index++;
+ in++;
+ if (*in == '-')
+ break;
+ }
+ }
+ secondbegin[index] = '\0';
+ if (*in == '-') /* if dash is not present, note */
+ in++;
+ else
+ dash=FALSE;
+ index=0;
+ while (IS_DIGIT(*in) || *in == ' ')
+ { /* Look for digits. */
+ firstend[index] = *in;
+ if (*in != ' ')
+ index++;
+ in++;
+ }
+ firstend[index] = '\0';
+ index=0;
+ if (*in != '\0')
+ { /* Look for letters again. */
+ while (IS_ALPHA(*in) || *in == ' ')
+ {
+ secondend[index] = *in;
+ index++;
+ in++;
+ }
+ }
+ secondend[index] = '\0';
+ }
+ else
+ { /* Do letters come first? */
+ first_alpha = TRUE;
+ index=0;
+ while (IS_ALPHA(*in) || *in == ' ')
+ {
+ firstbegin[index] = *in;
+ index++;
+ in++;
+ if (*in == '-')
+ break;
+ }
+ firstbegin[index] = '\0';
+ index=0;
+ if (*in != '-')
+ { /* After letters look for digits. */
+ while (IS_DIGIT(*in) || *in == ' ')
+ {
+ secondbegin[index] = *in;
+ if (*in != ' ')
+ index++;
+ in++;
+ if (*in == '-')
+ break;
+ }
+ }
+ secondbegin[index] = '\0';
+ if (*in == '-') /* Note if dash is missing. */
+ in++;
+ else
+ dash=FALSE;
+ index=0;
+ while (IS_ALPHA(*in) || *in == ' ')
+ { /* Look for letters again. */
+ firstend[index] = *in;
+ index++;
+ in++;
+ }
+ firstend[index] = '\0';
+ index=0;
+ if (*in != '\0')
+ { /* Any digits here? */
+ while (IS_DIGIT(*in) || *in == ' ')
+ {
+ secondend[index] = *in;
+ if (*in != ' ')
+ index++;
+ in++;
+ }
+ }
+ secondend[index] = '\0';
+ }
+
+ if (first_alpha)
+ {
+ alphabegin = firstbegin;
+ numbegin = secondbegin;
+ alphaend = firstend;
+ numend = secondend;
+ }
+ else
+ {
+ numbegin = firstbegin;
+ alphabegin = secondbegin;
+ numend = firstend;
+ alphaend = secondend;
+ }
+
+ length_nb = StringLen(numbegin);
+ length_ab = StringLen(alphabegin);
+ length_ne = StringLen(numend);
+ length_ae = StringLen(alphaend);
+
+ /* If no dash, but second letters or numbers present, reject. */
+ if (dash == FALSE)
+ {
+ if (length_ne != 0 || length_ae != 0)
+ retval = -1;
+ }
+ /* Check for situations like "AAA-123" or "222-ABC". */
+ if (dash == TRUE)
+ {
+ if (length_ne == 0 && length_ab == 0)
+ retval = -1;
+ else if (length_ae == 0 && length_nb == 0)
+ retval = -1;
+ }
+
+ /* The following expands "F502-512" into "F502-F512" and
+ checks, for entries like "12a-12c" that a > c. "12aa-12ab",
+ "125G-137A", "125-G137" would be rejected. */
+ if (retval == 0)
+ {
+ if (length_ab > 0)
+ {
+ if (length_ae > 0)
+ {
+ if (StringCmp(alphabegin, alphaend) != 0)
+ {
+ if (length_ab != 1 || length_ae != 1)
+ retval = -1;
+ else if (*alphabegin > *alphaend)
+ retval = -1;
+ }
+ }
+ else
+ {
+ alphaend = alphabegin;
+ length_ae = length_ab;
+ }
+ }
+ else if (length_ae > 0)
+ retval = -1;
+ }
+
+/* The following expands "125-37" into "125-137". */
+ if (retval == 0)
+ {
+ if (length_nb > 0)
+ {
+ if (length_ne > 0)
+ {
+ diff = length_nb - length_ne;
+ if (diff > 0)
+ {
+ index=0;
+ while (numend[index] != '\0')
+ {
+ temp[index+diff] = numend[index];
+ index++;
+ }
+ temp[index+diff] = numend[index];
+ for (index=0; index<diff; index++)
+ temp[index] = numbegin[index];
+ index=0;
+ while (temp[index] != '\0')
+ {
+ numend[index] = temp[index];
+ index++;
+ }
+ numend[index] = temp[index];
+ }
+ }
+ else
+ {
+ numend = numbegin;
+ length_ne = length_nb;
+ }
+
+ }
+ else if (length_ne > 0)
+ retval = -1;
+ /* Check that the first number is <= the second (expanded) number. */
+ if (retval == 0)
+ {
+ /* sscanf(numbegin, "%ld", &num_type);
+ num1 = (Int4) num_type;
+ sscanf( numend, "%ld", &num_type);
+ num2 = (Int4) num_type;
+ */
+ num1 = (Int4) atol(numbegin);
+ num2 = (Int4) atol(numend);
+ if (num2 < num1)
+ retval = -1;
+ }
+ }
+
+ if (retval == -1)
+ {
+ out_pages = StringCpy(out_pages, in_pages);
+ }
+ else
+ {
+ ptr = out_pages;
+ /* Place expanded and validated page numbers into "out_pages". */
+ if (first_alpha)
+ {
+ while (*alphabegin != '\0')
+ {
+ *ptr = *alphabegin;
+ alphabegin++;
+ ptr++;
+ }
+ while (*numbegin != '\0')
+ {
+ *ptr = *numbegin;
+ numbegin++;
+ ptr++;
+ }
+ if (dash == TRUE)
+ {
+ *ptr = '-';
+ ptr++;
+ while (*alphaend != '\0')
+ {
+ *ptr = *alphaend;
+ alphaend++;
+ ptr++;
+ }
+ while (*numend != '\0')
+ {
+ *ptr = *numend;
+ numend++;
+ ptr++;
+ }
+ }
+ *ptr = '\0';
+ }
+ else
+ {
+ while (*numbegin != '\0')
+ {
+ *ptr = *numbegin;
+ numbegin++;
+ ptr++;
+ }
+ while (*alphabegin != '\0')
+ {
+ *ptr = *alphabegin;
+ alphabegin++;
+ ptr++;
+ }
+ if (dash == TRUE)
+ {
+ *ptr = '-';
+ ptr++;
+ while (*numend != '\0')
+ {
+ *ptr = *numend;
+ numend++;
+ ptr++;
+ }
+ while (*alphaend != '\0')
+ {
+ *ptr = *alphaend;
+ alphaend++;
+ ptr++;
+ }
+ }
+ *ptr = '\0';
+ }
+ }
+ return retval;
+}
+
+/* !!! still need to add StripParanthesis equivalent !!! */
+
+static void DoSup (
+ ValNodePtr PNTR head,
+ CharPtr issue,
+ CharPtr part_sup,
+ CharPtr part_supi
+)
+
+{
+ size_t len;
+ CharPtr str;
+ CharPtr temp;
+
+ len = StringLen (issue) + StringLen (part_sup) + StringLen (part_supi) + 25;
+ str = MemNew (sizeof (Char) * len);
+ if (str == NULL) return;
+ temp = str;
+
+ if (! StringHasNoText (part_sup)) {
+ *temp = ' ';
+ temp++;
+ temp = StringMove (temp, part_sup);
+ }
+ if (StringHasNoText (issue) && StringHasNoText (part_supi)) {
+ ValNodeCopyStr (head, 0, str);
+ MemFree (str);
+ return;
+ }
+ *temp = ' ';
+ temp++;
+ *temp = '(';
+ temp++;
+ if (! StringHasNoText (issue)) {
+ temp = StringMove (temp, issue);
+ }
+ if (! StringHasNoText (part_supi)) {
+ *temp = ' ';
+ temp++;
+ temp = StringMove (temp, part_supi);
+ }
+ *temp = ')';
+ temp++;
+ ValNodeCopyStr (head, 0, str);
+ MemFree (str);
+}
+
+static CharPtr FormatCitJour (
+ FmtType format,
+ Boolean citArtIsoJta,
+ CitJourPtr cjp
+)
+
+{
+ Char buf [256];
+ DatePtr dp;
+ Boolean electronic_journal = FALSE;
+ ValNodePtr head = NULL;
+ ImprintPtr imp;
+ CharPtr issue = NULL;
+ Char pages [128];
+ CharPtr part_sup = NULL;
+ CharPtr part_supi = NULL;
+ CharPtr rsult = NULL;
+ CharPtr title;
+ ValNodePtr ttl;
+ CharPtr volume;
+ Char year [8];
+
+ if (cjp == NULL) return NULL;
+
+ ttl = cjp->title;
+ if (ttl == NULL) return NULL;
+
+ /* always use iso_jta title if present */
+
+ while (ttl != NULL && ttl->choice != Cit_title_iso_jta) {
+ ttl = ttl->next;
+ }
+
+ /* release mode requires iso_jta title */
+
+ if (ttl == NULL) {
+ ttl = cjp->title;
+ if (ttl != NULL && ttl->choice == Cit_title_name) {
+ title = (CharPtr) ttl->data.ptrvalue;
+ if (title != NULL && StringNCmp (title, "(er)", 4) == 0) {
+ electronic_journal = TRUE;
+ }
+ }
+ if (citArtIsoJta && (! electronic_journal)) return NULL;
+ }
+
+ imp = cjp->imp;
+ if (imp == NULL) return NULL;
+
+ dp = imp->date;
+ year [0] = '\0';
+ if (dp != NULL) {
+ if (dp->data [0] == 1) {
+ if (dp->data [1] != 0) {
+ sprintf (year, " (%ld)", (long) (1900 + dp->data [1]));
+ }
+ } else {
+ StringCpy (year, " (");
+ StringNCat (year, dp->str, 4);
+ StringCat (year, ")");
+ }
+ }
+
+ if (imp->prepub == 1 || imp->prepub == 255) {
+ sprintf (buf, "Unpublished %s", year);
+ return StringSave (buf);
+ }
+
+ title = (CharPtr) ttl->data.ptrvalue;
+ if (StringLen (title) < 3) return StringSave (".");
+
+ ValNodeCopyStr (&head, 0, title);
+
+ volume = imp->volume;
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ issue = imp->issue;
+ part_sup = imp->part_sup;
+ part_supi = imp->part_supi;
+ }
+ pages [0] = '\0';
+ if (electronic_journal) {
+ StringNCpy_0 (pages, imp->pages, sizeof (pages));
+ } else {
+ FixPages (pages, imp->pages);
+ }
+
+ if (! StringHasNoText (volume)) {
+ AddValNodeString (&head, " ", volume, NULL);
+ }
+
+ if ((! StringHasNoText (volume)) || (! StringHasNoText (pages))) {
+ DoSup (&head, issue, part_sup, part_supi);
+ }
+
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ if (! StringHasNoText (pages)) {
+ AddValNodeString (&head, ", ", pages, NULL);
+ }
+ } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+ if (! StringHasNoText (pages)) {
+ AddValNodeString (&head, ":", pages, NULL);
+ } else if (imp->prepub == 2 || (StringHasNoText (volume))) {
+ ValNodeCopyStr (&head, 0, " 0:0-0");
+ }
+ }
+
+ ValNodeCopyStr (&head, 0, year);
+
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ if (imp->prepub == 2) {
+ ValNodeCopyStr (&head, 0, " In press");
+ }
+ }
+
+ rsult = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ return rsult;
+}
+
+static CharPtr MakeAffilStr (
+ AffilPtr afp
+)
+
+{
+ ValNodePtr head = NULL;
+ CharPtr prefix = "";
+ CharPtr rsult = NULL;
+
+ if (afp == NULL) return NULL;
+
+ if (! StringHasNoText (afp->affil)) {
+ ValNodeCopyStr (&head, 0, afp->affil);
+ prefix = ", ";
+ }
+
+ if (afp->choice == 2) {
+ if (! StringHasNoText (afp->div)) {
+ AddValNodeString (&head, prefix, afp->div, NULL);
+ prefix = ", ";
+ }
+ if (! StringHasNoText (afp->street)) {
+ AddValNodeString (&head, prefix, afp->street, NULL);
+ prefix = ", ";
+ }
+ if (! StringHasNoText (afp->city)) {
+ AddValNodeString (&head, prefix, afp->city, NULL);
+ prefix = ", ";
+ }
+ if (! StringHasNoText (afp->sub)) {
+ AddValNodeString (&head, prefix, afp->sub, NULL);
+ prefix = ", ";
+ }
+ if (! StringHasNoText (afp->country)) {
+ AddValNodeString (&head, prefix, afp->country, NULL);
+ prefix = ", ";
+ }
+ }
+
+ rsult = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ return rsult;
+}
+
+static CharPtr GetAffil (
+ AffilPtr afp
+)
+
+{
+ Boolean need_comma=FALSE;
+ CharPtr string=NULL, temp, ptr;
+ Char ch;
+ Int2 aflen=15;
+
+ if (afp == NULL) return NULL;
+ if (afp) {
+ if (afp -> choice == 1){
+ if (afp -> affil){
+ aflen += StringLen(afp -> affil);
+ }
+ }else if (afp -> choice == 2){
+ aflen += StringLen (afp -> affil) +
+ StringLen (afp -> div) +
+ StringLen (afp -> city) +
+ StringLen (afp -> sub) +
+ StringLen (afp -> street) +
+ StringLen (afp -> country) + StringLen(afp->postal_code);
+ }
+
+ temp = string = MemNew(aflen);
+
+ if ( afp -> choice == 1){
+ if (afp -> affil){
+ ptr = afp->affil;
+ while ((*temp = *ptr) != '\0')
+ {
+ temp++; ptr++;
+ }
+ }
+ }else if (afp -> choice == 2){
+
+ if( afp -> div) {
+ if (need_comma)
+ {
+ *temp = ','; temp++;
+ *temp = ' '; temp++;
+ }
+ ptr = afp->div;
+ while ((*temp = *ptr) != '\0')
+ {
+ temp++; ptr++;
+ }
+ need_comma = TRUE;
+ }
+
+ if(afp -> affil) {
+ if (need_comma)
+ {
+ *temp = ','; temp++;
+ *temp = ' '; temp++;
+ }
+ ptr = afp->affil;
+ while ((*temp = *ptr) != '\0')
+ {
+ temp++; ptr++;
+ }
+ need_comma = TRUE;
+ }
+
+ if(afp -> street) {
+ if (need_comma)
+ {
+ *temp = ','; temp++;
+ *temp = ' '; temp++;
+ }
+ ptr = afp->street;
+ while ((*temp = *ptr) != '\0')
+ {
+ temp++; ptr++;
+ }
+ need_comma = TRUE;
+ }
+
+ if( afp -> city) {
+ if (need_comma)
+ {
+ *temp = ','; temp++;
+ *temp = ' '; temp++;
+ }
+ ptr = afp->city;
+ while ((*temp = *ptr) != '\0')
+ {
+ temp++; ptr++;
+ }
+ need_comma = TRUE;
+ }
+
+ if( afp -> sub) {
+ if (need_comma)
+ {
+ *temp = ','; temp++;
+ *temp = ' '; temp++;
+ }
+ ptr = afp->sub;
+ while ((*temp = *ptr) != '\0')
+ {
+ temp++; ptr++;
+ }
+ need_comma = TRUE;
+ }
+
+ if( afp -> postal_code){
+ *temp = ' ';
+ temp++;
+ ptr = afp->postal_code;
+ while ((*temp = *ptr) != '\0')
+ {
+ temp++; ptr++;
+ }
+ }
+
+ if( afp -> country){
+ if (need_comma)
+ {
+ *temp = ','; temp++;
+ *temp = ' '; temp++;
+ }
+ ptr = afp->country;
+ while ((*temp = *ptr) != '\0')
+ {
+ temp++; ptr++;
+ }
+ need_comma = TRUE;
+ }
+ }
+ temp++;
+ *temp = '\0';
+ }
+
+ /* convert double quotes to single quotes */
+
+ ptr = string;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch == '\"') {
+ *ptr = '\'';
+ }
+ ptr++;
+ ch = *ptr;
+ }
+
+ return string;
+}
+
+static CharPtr FormatCitBookArt (
+ FmtType format,
+ CitBookPtr cbp
+)
+
+{
+ AffilPtr afp;
+ AuthListPtr alp;
+ CharPtr book_title = NULL;
+ Char buf [256];
+ Char ch;
+ DatePtr dp;
+ ValNodePtr head = NULL;
+ ImprintPtr imp;
+ CharPtr issue = NULL;
+ ValNodePtr names = NULL;
+ Char pages [128];
+ CharPtr part_sup = NULL;
+ CharPtr part_supi = NULL;
+ CharPtr rsult = NULL;
+ CharPtr str;
+ CharPtr title;
+ ValNodePtr ttl;
+ ValNodePtr vnp;
+ CharPtr volume;
+ Char year [8];
+
+ if (cbp == NULL) return NULL;
+
+ ttl = cbp->title;
+ if (ttl == NULL) return NULL;
+
+ imp = cbp->imp;
+ if (imp == NULL) return NULL;
+
+ dp = imp->date;
+ year [0] = '\0';
+ if (dp != NULL) {
+ if (dp->data [0] == 1) {
+ if (dp->data [1] != 0) {
+ sprintf (year, "(%ld)", (long) (1900 + dp->data [1]));
+ }
+ } else {
+ StringCpy (year, "(");
+ StringNCat (year, dp->str, 4);
+ StringCpy (year, ")");
+ }
+ }
+
+ if (imp->prepub == 1 || imp->prepub == 255) {
+ sprintf (buf, "Unpublished %s", year);
+ return StringSave (buf);
+ }
+
+ title = (CharPtr) ttl->data.ptrvalue;
+ if (StringLen (title) < 3) return StringSave (".");
+
+ ValNodeCopyStr (&head, 0, "(in) ");
+
+ alp = cbp->authors;
+ if (alp != NULL) {
+ str = GetAuthorsString (format, alp, NULL, NULL, NULL);
+ if (str != NULL) {
+ ValNodeCopyStr (&head, 0, str);
+ names = alp->names;
+ if (names != NULL) {
+ if (names->next != NULL) {
+ ValNodeCopyStr (&head, 0, " (Eds.);");
+ } else {
+ ValNodeCopyStr (&head, 0, " (Ed.);");
+ }
+ }
+ ValNodeCopyStr (&head, 0, "\n");
+ }
+ MemFree (str);
+ }
+
+ book_title = StringSaveNoNull (title);
+ vnp = ValNodeAddStr (&head, 0, book_title);
+ if (book_title != NULL) {
+
+ /* make book title all caps */
+
+ title = book_title;
+ ch = *title;
+ while (ch != '\0') {
+ *title = TO_UPPER (ch);
+ title++;
+ ch = *title;
+ }
+ }
+
+ volume = imp->volume;
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ issue = imp->issue;
+ part_sup = imp->part_sup;
+ part_supi = imp->part_supi;
+ }
+ pages [0] = '\0';
+ FixPages (pages, imp->pages);
+
+ if ((! StringHasNoText (volume)) && (StringCmp (volume, "0") != 0)) {
+ AddValNodeString (&head, ", Vol. ", volume, NULL);
+ DoSup (&head, issue, part_sup, part_supi);
+ }
+
+ if (! StringHasNoText (pages)) {
+ AddValNodeString (&head, ": ", pages, NULL);
+ }
+
+ if (book_title != NULL) {
+ ValNodeCopyStr (&head, 0, ";\n");
+ }
+
+ afp = imp->pub;
+ if (afp != NULL) {
+ str = MakeAffilStr (afp);
+ if (str != NULL) {
+ ValNodeCopyStr (&head, 0, str);
+ ValNodeCopyStr (&head, 0, " ");
+ MemFree (str);
+ }
+ }
+
+ AddValNodeString (&head, NULL, year, NULL);
+
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ if (imp->prepub == 2) {
+ ValNodeCopyStr (&head, 0, " In press");
+ }
+ }
+
+ rsult = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ return rsult;
+}
+
+static CharPtr FormatCitBook (
+ FmtType format,
+ CitBookPtr cbp
+)
+
+{
+ AffilPtr afp;
+ char year[5];
+ CharPtr bookTitle=NULL;
+ CharPtr retval = NULL;
+ CharPtr temp;
+ DatePtr dp;
+ ImprintPtr ip;
+ int aflen = 0;
+ CharPtr p;
+ CharPtr affilStr = NULL;
+
+ /* Check parameters */
+
+ if (cbp == NULL)
+ return NULL;
+
+ if ( cbp -> othertype != 0)
+ return NULL;
+
+ ip = cbp -> imp;
+
+ /* Format the year */
+
+ dp = ip -> date;
+ year[0] = '\0';
+
+ if ( dp -> data[0] == 1)
+ sprintf(year,"%ld",(long) ( 1900+dp -> data[1]));
+ else
+ {
+ StringNCpy( (CharPtr) year, (CharPtr) dp -> str, (size_t) 4);
+ year[4] = '\0';
+ }
+
+ /* Get the book title */
+
+ if (cbp->title)
+ bookTitle = StringSave(cbp -> title -> data.ptrvalue);
+
+ /* Get the affiliation length */
+
+ if ( ip -> pub){
+ afp = ip -> pub;
+ aflen = StringLen(afp -> affil)+ 5;
+ if ( afp -> choice == 2){
+ aflen += 3 + StringLen(afp -> div);
+ aflen += 3 + StringLen(afp -> street);
+ aflen += 3 + StringLen(afp -> city);
+ aflen += 3 + StringLen(afp -> sub);
+ aflen += 3 + StringLen(afp -> country);
+ }
+ } else{
+ aflen = 22;
+ }
+ if (ip->prepub == 2)
+ aflen += 10;
+
+ /* Create a Char String big enough to hold */
+ /* the title, year, and affiliation. */
+
+ temp = retval = MemNew( (size_t) (30+StringLen( bookTitle)+StringLen( year) + aflen) );
+
+ /* Convert the title to upper case and */
+ /* add it to the string. */
+
+ for ( p = bookTitle; *p; p++)
+ *p = TO_UPPER(*p);
+
+ /* temp = StringMove(temp, "Book: "); */
+ temp = StringMove(temp, "(in) ");
+ temp = StringMove(temp, bookTitle);
+ temp = StringMove(temp, ".");
+
+ /* Add the affiliation to the string */
+
+ if ( ip -> pub)
+ {
+ afp = ip -> pub;
+ *temp = ' ';
+ temp++;
+ affilStr = MakeAffilStr(afp);
+ temp = StringMove(temp,affilStr);
+ }
+
+ /* Add the year to the string */
+
+ if (year[0] != '\0')
+ {
+ if (affilStr != NULL)
+ temp = StringMove(temp," (");
+ else
+ temp = StringMove(temp, "(");
+ temp = StringMove(temp, year);
+ temp = StringMove(temp, ")");
+ }
+
+ /* If in press, add note */
+
+ if (ip->prepub == 2)
+ temp = StringMove(temp, ", In press");
+
+ /* Clean up and return */
+
+ if (bookTitle)
+ MemFree(bookTitle);
+
+ return retval;
+
+}
+
+static CharPtr FormatThesis (
+ FmtType format,
+ CitBookPtr cbp
+)
+
+{
+ AffilPtr afp;
+ Char ch;
+ DatePtr dp;
+ ValNodePtr head = NULL;
+ ImprintPtr imp;
+ CharPtr ptr;
+ CharPtr rsult = NULL;
+ CharPtr str;
+ CharPtr suffix = NULL;
+ Char year [8];
+
+ if (cbp == NULL) return NULL;
+ if (cbp->othertype != 2 || cbp->let_type != 3) return NULL;
+
+ imp = cbp->imp;
+ if (imp == NULL) return NULL;
+
+ dp = imp->date;
+ year [0] = '\0';
+ if (dp != NULL) {
+ if (dp->data [0] == 1) {
+ if (dp->data [1] != 0) {
+ sprintf (year, "%ld", (long) (1900 + dp->data [1]));
+ }
+ } else {
+ StringNCpy (year, dp->str, (size_t) 4);
+ year [4] = '\0';
+ }
+ }
+
+ AddValNodeString (&head, "Thesis (", year, ")");
+
+ if (imp->prepub == 2) {
+ suffix = ", In press";
+ }
+
+ str = NULL;
+ afp = imp->pub;
+ if (afp != NULL) {
+ if (afp->choice == 1) {
+ if (StringLen (afp->affil) > 7) {
+ str = StringSave (afp->affil);
+ }
+ } else if (afp->choice == 2) {
+ str = MakeAffilStr (afp);
+ }
+ }
+
+ if (str != NULL) {
+
+ /* convert double quotes to single quotes */
+
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch == '\"') {
+ *ptr = '\'';
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ AddValNodeString (&head, " ", str, suffix);
+ MemFree (str);
+ }
+
+ rsult = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ return rsult;
+}
+
+static CharPtr FormatCitArt (
+ FmtType format,
+ Boolean citArtIsoJta,
+ CitArtPtr cap
+)
+
+{
+ CitBookPtr cbp;
+ CitJourPtr cjp;
+ CharPtr rsult = NULL;
+
+ if (cap == NULL) return NULL;
+
+ switch (cap->from) {
+ case 1 :
+ cjp = (CitJourPtr) cap->fromptr;
+ if (cjp != NULL) {
+ rsult = FormatCitJour (format, citArtIsoJta, cjp);
+ }
+ break;
+ case 2 :
+ cbp = (CitBookPtr) cap->fromptr;
+ if (cbp != NULL) {
+ rsult = FormatCitBookArt (format, cbp);
+ }
+ break;
+ case 3 :
+ cbp = (CitBookPtr) cap->fromptr;
+ if (cbp != NULL) {
+ rsult = FormatCitBookArt (format, cbp);
+ }
+ break;
+ default :
+ break;
+ }
+
+ return rsult;
+}
+
+static CharPtr FormatCitPat (
+ FmtType format,
+ CitPatPtr cpp,
+ SeqIdPtr seqidp
+)
+
+{
+ AffilPtr afp;
+ AuthListPtr alp;
+ Char date [40];
+ ValNodePtr head = NULL;
+ CharPtr prefix = NULL;
+ CharPtr rsult = NULL;
+ SeqIdPtr sip;
+ CharPtr suffix = NULL;
+ PatentSeqIdPtr psip;
+ Int4 pat_seqid = 0;
+ Char buf[10];
+
+ if (cpp == NULL) return NULL;
+
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ ValNodeCopyStr (&head, 0, "Patent: ");
+ suffix = " ";
+ } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+ ValNodeCopyStr (&head, 0, "Patent number ");
+ }
+
+ if (! StringHasNoText (cpp->country)) {
+ AddValNodeString (&head, NULL, cpp->country, suffix);
+ }
+
+ if (! StringHasNoText (cpp->number)) {
+ ValNodeCopyStr (&head, 0, cpp->number);
+ } else if (! StringHasNoText (cpp->app_number)) {
+ AddValNodeString (&head, "(", cpp->app_number, ")");
+ }
+
+ if (! StringHasNoText (cpp->doc_type)) {
+ AddValNodeString (&head, "-", cpp->doc_type, NULL);
+ }
+
+ /* pat_seqid test */
+
+ for (sip = seqidp; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_PATENT) {
+ psip = (PatentSeqIdPtr) sip -> data.ptrvalue;
+ if (psip != NULL) {
+ pat_seqid = psip->seqid;
+ }
+ }
+ }
+ if (pat_seqid > 0) {
+ if (format == EMBL_FMT) {
+ sprintf(buf,"%s%ld%s", "/", (long) pat_seqid, ", ");
+ ValNodeCopyStr (&head, 0, buf);
+ } else {
+ sprintf(buf,"%s%ld ", " ", (long) pat_seqid);
+ ValNodeCopyStr (&head, 0, buf);
+ }
+ } else {
+ ValNodeCopyStr (&head, 0, " ");
+ }
+
+ /* Date */
+
+ date [0] = '\0';
+ if (cpp->date_issue != NULL) {
+ DateToFF (date, cpp->date_issue, FALSE);
+ } else if (cpp->app_date != NULL) {
+ DateToFF (date, cpp->app_date, FALSE);
+ }
+ if (! StringHasNoText (date)) {
+ ValNodeCopyStr (&head, 0, date);
+ }
+
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+ ValNodeCopyStr (&head, 0, ";");
+ } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+ ValNodeCopyStr (&head, 0, ".");
+ }
+
+ alp = cpp->authors;
+ if (alp != NULL) {
+ afp = alp->affil;
+ if (afp != NULL) {
+ suffix = NULL;
+ if (afp->choice == 2) {
+ suffix = ";";
+ }
+
+ /* If and of the affiliation fields are */
+ /* non-blank, put them on a new line. */
+
+ if ((! StringHasNoText (afp->affil)) ||
+ (! StringHasNoText (afp->street)) ||
+ (! StringHasNoText (afp->div)) ||
+ (! StringHasNoText (afp->city)) ||
+ (! StringHasNoText (afp->sub)) ||
+ (! StringHasNoText (afp->country)))
+ ValNodeCopyStr (&head, 0, "\n");
+
+ /* Write out the affiliation fields */
+
+ if (! StringHasNoText (afp->affil)) {
+ AddValNodeString (&head, NULL, afp->affil, suffix);
+ prefix = " ";
+ }
+ if (! StringHasNoText (afp->street)) {
+ AddValNodeString (&head, prefix, afp->street, ";");
+ prefix = " ";
+ }
+ if (! StringHasNoText (afp->div)) {
+ AddValNodeString (&head, prefix, afp->div, ";");
+ prefix = " ";
+ }
+ if (! StringHasNoText (afp->city)) {
+ AddValNodeString (&head, prefix, afp->city, NULL);
+ prefix = ", ";
+ }
+ if (! StringHasNoText (afp->sub)) {
+ AddValNodeString (&head, prefix, afp->sub, NULL);
+ }
+ if (! StringHasNoText (afp->country)) {
+ AddValNodeString (&head, ";\n", afp->country, ";");
+ }
+ }
+ }
+
+ rsult = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ /*
+ s_StringCleanup(rsult);
+ */
+
+ return rsult;
+}
+
+static CharPtr FormatCitGen (
+ FmtType format,
+ Boolean dropBadCitGens,
+ Boolean noAffilOnUnpub,
+ CitGenPtr cgp
+)
+
+{
+ CharPtr affil = NULL;
+ AuthListPtr alp = NULL;
+ Char ch;
+ DatePtr dp;
+ ValNodePtr head = NULL;
+ CharPtr inpress = NULL;
+ CharPtr journal = NULL;
+ Char pages [128];
+ CharPtr prefix = NULL;
+ CharPtr ptr;
+ CharPtr rsult = NULL;
+ Char year [8];
+
+ if (cgp == NULL) return NULL;
+
+ if (cgp->journal == NULL && StringNICmp (cgp->cit, "unpublished", 11) == 0) {
+ if (noAffilOnUnpub) {
+
+ /* !!! temporarily put date in unpublished citation for QA !!! */
+
+ if (dropBadCitGens) {
+ year [0] = '\0';
+ dp = cgp->date;
+ if (dp != NULL) {
+ if (dp->data [0] == 1) {
+ if (dp->data [1] != 0) {
+ sprintf (year, " (%ld)", (long) (1900 + dp->data [1]));
+ }
+ } else {
+ StringCpy (year, " (");
+ StringNCat (year, dp->str, 4);
+ StringCat (year, ")");
+ }
+ }
+ AddValNodeString (&head, NULL, "Unpublished", NULL);
+ AddValNodeString (&head, NULL, year, NULL);
+ rsult = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+ return rsult;
+ }
+
+ /* !!! remove above section once QA against asn2ff is done !!! */
+
+ return StringSave ("Unpublished");
+ }
+
+ alp = cgp->authors;
+ if (alp != NULL) {
+ affil = GetAffil (alp->affil);
+ if (! StringHasNoText (affil)) {
+ rsult = MemNew ((size_t) StringLen (affil) + (size_t) StringLen (cgp->cit) + 15);
+ StringCpy (rsult, "Unpublished ");
+ StringCat (rsult, affil);
+ TrimSpacesAroundString (rsult);
+ return rsult;
+ }
+ }
+
+ rsult = StringSave (cgp->cit);
+ TrimSpacesAroundString (rsult);
+ return rsult;
+ }
+
+ year [0] = '\0';
+ dp = cgp->date;
+ if (dp != NULL) {
+ if (dp->data [0] == 1) {
+ if (dp->data [1] != 0) {
+ sprintf (year, " (%ld)", (long) (1900 + dp->data [1]));
+ }
+ } else {
+ StringCpy (year, " (");
+ StringNCat (year, dp->str, 4);
+ StringCat (year, ")");
+ }
+ }
+
+ pages [0] = '\0';
+ if (cgp->pages != NULL) {
+ FixPages (pages, cgp->pages);
+ }
+
+ if (cgp->journal != NULL) {
+ journal = (CharPtr) cgp->journal->data.ptrvalue;
+ }
+ if (cgp->cit != NULL) {
+ ptr = StringStr (cgp->cit, "Journal=\"");
+ if (ptr != NULL) {
+ journal = ptr + 9;
+ } else if (StringNICmp (cgp->cit, "submitted", 8) == 0 ||
+ StringNICmp (cgp->cit, "unpublished", 11) == 0) {
+
+ if ((! dropBadCitGens) || journal != NULL) {
+ inpress = cgp->cit;
+ } else {
+ inpress = "Unpublished";
+ }
+ } else if (StringNICmp (cgp->cit, "Online Publication", 18) == 0 ||
+ StringNICmp (cgp->cit, "Published Only in DataBase", 26) == 0) {
+
+ inpress = cgp->cit;
+ } else if ((! dropBadCitGens) && journal == NULL) {
+ journal = cgp->cit;
+ }
+ }
+ if (journal != NULL) {
+ journal = StringSave (journal);
+ for (ptr = journal, ch = *ptr; ch != '\0'; ptr++, ch = *ptr) {
+ if (ch == '=' || ch == '\"') {
+ *ptr = '\0';
+ }
+ }
+ ValNodeAddStr (&head, 0, journal);
+ prefix = " ";
+ }
+
+ if (! StringHasNoText (inpress)) {
+ AddValNodeString (&head, prefix, inpress, NULL);
+ prefix = " ";
+ }
+
+ if (! StringHasNoText (cgp->volume)) {
+ AddValNodeString (&head, prefix, cgp->volume, NULL);
+ }
+
+ if (! StringHasNoText (pages)) {
+ if (format == GENBANK_FMT) {
+ AddValNodeString (&head, ", ", pages, NULL);
+ } else if (format == EMBL_FMT) {
+ AddValNodeString (&head, ":", pages, NULL);
+ }
+ }
+
+ if (! StringHasNoText (year)) {
+ AddValNodeString (&head, NULL, year, NULL);
+ }
+
+ rsult = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ return rsult;
+}
+
+static CharPtr FormatCitSub (
+ FmtType format,
+ CitSubPtr csp
+)
+
+{
+ CharPtr affil;
+ AffilPtr afp;
+ AuthListPtr alp;
+ Char buf [256];
+ Char date [40];
+ ValNodePtr head = NULL;
+ CharPtr rsult = NULL;
+
+ if (csp == NULL) return NULL;
+
+ date [0] = '\0';
+ if (csp->date != NULL) {
+ DateToFF (date, csp->date, TRUE);
+ }
+ if (StringHasNoText (date)) {
+ StringCpy (date, "??-???-????");
+ }
+
+ sprintf (buf, "Submitted (%s)", date);
+ ValNodeCopyStr (&head, 0, buf);
+
+ alp = csp->authors;
+ if (alp != NULL) {
+ afp = alp->affil;
+ if (afp != NULL) {
+ affil = GetAffil (afp);
+ if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+ if (StringNCmp(affil, " to the EMBL/GenBank/DDBJ databases.", 36) != 0) {
+ ValNodeCopyStr (&head, 0, " to the EMBL/GenBank/DDBJ databases.\n");
+ } else {
+ ValNodeCopyStr (&head, 0, " ");
+ }
+ } else {
+ ValNodeCopyStr (&head, 0, " ");
+ }
+ ValNodeCopyStr (&head, 0, affil);
+ MemFree (affil);
+ } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+ ValNodeCopyStr (&head, 0, " to the EMBL/GenBank/DDBJ databases.\n");
+ }
+ }
+
+ rsult = MergeFFValNodeStrs (head);
+ ValNodeFreeData (head);
+
+ return rsult;
+}
+
+static CharPtr GetPubJournal (
+ FmtType format,
+ Boolean dropBadCitGens,
+ Boolean noAffilOnUnpub,
+ Boolean citArtIsoJta,
+ PubdescPtr pdp,
+ CitSubPtr csp,
+ SeqIdPtr seqidp,
+ IndxPtr index
+)
+
+{
+ CitArtPtr cap;
+ CitBookPtr cbp;
+ CitGenPtr cgp;
+ CitPatPtr cpp;
+ CharPtr journal = NULL;
+ MedlineEntryPtr mep;
+ ValNodePtr vnp;
+
+ if (csp != NULL) {
+ return FormatCitSub (format, csp);
+ }
+ if (pdp == NULL) return NULL;
+
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ switch (vnp->choice) {
+ case PUB_Gen :
+ cgp = (CitGenPtr) vnp->data.ptrvalue;
+ if (cgp != NULL) {
+ if (StringNICmp ("BackBone id_pub", cgp->cit, 15) != 0) {
+ if (cgp->cit == NULL && cgp->journal == NULL && cgp->date == NULL && cgp->serial_number) {
+ break; /* skip just serial number */
+ }
+ }
+ journal = FormatCitGen (format, dropBadCitGens, noAffilOnUnpub, cgp);
+ }
+ break;
+ case PUB_Sub :
+ csp = (CitSubPtr) vnp->data.ptrvalue;
+ if (csp != NULL) {
+ journal = FormatCitSub (format, csp);
+ }
+ break;
+ case PUB_Medline :
+ mep = (MedlineEntryPtr) vnp->data.ptrvalue;
+ if (mep != NULL) {
+ cap = mep->cit;
+ if (cap != NULL) {
+ journal = FormatCitArt (format, citArtIsoJta, cap);
+ }
+ }
+ break;
+ case PUB_Article :
+ cap = (CitArtPtr) vnp->data.ptrvalue;
+ if (cap != NULL) {
+ journal = FormatCitArt (format, citArtIsoJta, cap);
+ }
+ break;
+ case PUB_Book :
+ case PUB_Proc :
+ cbp = (CitBookPtr) vnp->data.ptrvalue;
+ if (cbp != NULL) {
+ journal = FormatCitBook (format, cbp);
+ }
+ break;
+ case PUB_Man :
+ cbp = (CitBookPtr) vnp->data.ptrvalue;
+ if (cbp != NULL) {
+ journal = FormatThesis (format, cbp);
+ }
+ break;
+ case PUB_Patent :
+ cpp = (CitPatPtr) vnp->data.ptrvalue;
+ if (cpp != NULL) {
+ journal = FormatCitPat (format, cpp, seqidp);
+ }
+ break;
+ default :
+ break;
+ }
+
+ /* optionally populate indexes for NCBI internal database */
+
+ if (index != NULL && journal != NULL) {
+
+ /* skip non-informative cit-gens */
+
+ if (StringNICmp (journal, "submitted", 8) == 0 ||
+ StringNICmp (journal, "unpublished", 11) == 0 ||
+ StringNICmp (journal, "Online Publication", 18) == 0 ||
+ StringNICmp (journal, "Published Only in DataBase", 26) == 0) {
+ } else {
+ ValNodeCopyStrToHead (&(index->journals), 0, journal);
+ }
+ }
+
+ if (journal != NULL) return journal;
+ }
+
+ return NULL;
+}
+
+static Int4 GetMuid (
+ PubdescPtr pdp
+)
+
+{
+ MedlineEntryPtr mep;
+ ValNodePtr vnp;
+
+ if (pdp == NULL) return 0;
+
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ switch (vnp->choice) {
+ case PUB_Medline :
+ mep = (MedlineEntryPtr) vnp->data.ptrvalue;
+ if (mep != NULL) {
+ return mep->uid;
+ }
+ break;
+ case PUB_Muid :
+ return vnp->data.intvalue;
+ default :
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static Int4 GetPmid (
+ PubdescPtr pdp
+)
+
+{
+ MedlineEntryPtr mep;
+ ValNodePtr vnp;
+
+ if (pdp == NULL) return 0;
+
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ switch (vnp->choice) {
+ case PUB_Medline :
+ mep = (MedlineEntryPtr) vnp->data.ptrvalue;
+ if (mep != NULL) {
+ return mep->pmid;
+ }
+ break;
+ case PUB_PMid :
+ return vnp->data.intvalue;
+ default :
+ break;
+ }
+ }
+
+ return 0;
+}
+
+NLM_EXTERN CharPtr CleanQualValue (
+ CharPtr str
+)
+
+{
+ Char ch;
+ CharPtr dst;
+ CharPtr ptr;
+
+ if (str == NULL || str [0] == '\0') return NULL;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch == '\n' || ch == '\r' || ch == '\t' || ch == '"') {
+ *dst = ' ';
+ dst++;
+ } else {
+ *dst = ch;
+ dst++;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = '\0';
+
+ return str;
+}
+
+NLM_EXTERN CharPtr Asn2gnbkCompressSpaces (CharPtr str)
+
+{
+ Char ch;
+ CharPtr dst;
+ Char last;
+ CharPtr ptr;
+
+ if (str != NULL && str [0] != '\0') {
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0' && ch <= ' ') {
+ ptr++;
+ ch = *ptr;
+ }
+ while (ch != '\0') {
+ *dst = ch;
+ dst++;
+ ptr++;
+ last = ch;
+ ch = *ptr;
+ if (ch != '\0' && ch < ' ') {
+ *ptr = ' ';
+ ch = *ptr;
+ }
+ while (ch != '\0' && last <= ' ' && ch <= ' ') {
+ ptr++;
+ ch = *ptr;
+ }
+ }
+ *dst = '\0';
+ dst = NULL;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch != ' ') {
+ dst = NULL;
+ } else if (dst == NULL) {
+ dst = ptr;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ if (dst != NULL) {
+ *dst = '\0';
+ }
+ }
+ return str;
+}
+
+NLM_EXTERN CharPtr StripAllSpaces (
+ CharPtr str
+)
+
+{
+ Char ch;
+ CharPtr dst;
+ CharPtr ptr;
+
+ if (str == NULL || str [0] == '\0') return NULL;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch == ' ' || ch == '\t') {
+ } else {
+ *dst = ch;
+ dst++;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = '\0';
+
+ return str;
+}
+
+static CharPtr remarksText [] = {
+ "full automatic", "full staff_review", "full staff_entry",
+ "simple staff_review", "simple staff_entry", "simple automatic",
+ "unannotated automatic", "unannotated staff_review", "unannotated staff_entry",
+ NULL
+};
+
+static void AddReferenceToGbseq (
+ GBSeqPtr gbseq,
+ GBReferencePtr gbref,
+ CharPtr str
+)
+
+{
+ CharPtr copy;
+ CharPtr ptr;
+ CharPtr ref;
+
+ if (gbseq == NULL || gbref == NULL || StringHasNoText (str)) return;
+
+ copy = StringSave (str);
+
+ /* link in reverse order, to be reversed in slash block */
+
+ gbref->next = gbseq->references;
+ gbseq->references = gbref;
+
+ /* now parse or make ASN required default values for remaining fields */
+
+ if (StringNCmp (copy, "REFERENCE ", 12) == 0) {
+ ref = copy + 12;
+ ptr = StringStr (ref, "\n AUTHORS");
+ if (ptr == NULL) {
+ ptr = StringStr (ref, ")\n");
+ }
+ if (ptr != NULL) {
+ *ptr = '\0';
+ gbref->reference = StringSave (ref);
+ }
+ }
+
+ if (gbref->reference == NULL) {
+ gbref->reference = StringSave ("?");
+ }
+
+ CleanQualValue (gbref->reference);
+ Asn2gnbkCompressSpaces (gbref->reference);
+
+ if (gbref->journal == NULL) {
+ gbref->journal = StringSave ("?");
+ }
+
+ CleanQualValue (gbref->journal);
+ Asn2gnbkCompressSpaces (gbref->journal);
+
+ MemFree (copy);
+}
+
+static Boolean IsCitSub (
+ PubdescPtr pdp,
+ CitSubPtr csp
+)
+
+{
+ ValNodePtr vnp;
+
+ if (csp != NULL) return TRUE;
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == PUB_Sub) return TRUE;
+ }
+ return FALSE;
+}
+
+static void FF_www_muid(
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ Int4 muid
+)
+{
+ Char numbuf[40];
+
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString(ffstring, "<a href=", link_muid, NULL, FALSE, FALSE, TILDE_IGNORE);
+ sprintf(numbuf, "%ld", (long)muid);
+ FFAddTextToString(ffstring, "uid=", numbuf, "&form=6&db=m&Dopt=r>", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, numbuf, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(ffstring, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ sprintf(numbuf, "%ld", (long)muid);
+ FFAddOneString(ffstring, numbuf, FALSE, FALSE, TILDE_IGNORE);
+ }
+}
+
+NLM_EXTERN CharPtr FormatReferenceBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ AuthListPtr alp;
+ Asn2gbSectPtr asp;
+ BioseqPtr bsp;
+ Char buf [150];
+ CitArtPtr cap;
+ Char ch;
+ CitJourPtr cjp;
+ Boolean citArtIsoJta;
+ CharPtr consortium;
+ CitRetractPtr crp;
+ CitSubPtr csp = NULL;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ Int4 gibbsq;
+ GBReferencePtr gbref = NULL;
+ GBSeqPtr gbseq;
+ Int2 i;
+ ImprintPtr imp;
+ IndxPtr index;
+ IntRefBlockPtr irp;
+ size_t len;
+ SeqLocPtr loc = NULL;
+ MedlineEntryPtr mep;
+ Int4 muid = 0;
+ Boolean needsPeriod = FALSE;
+ SeqLocPtr nextslp;
+ Boolean notFound;
+ ObjMgrDataPtr omdp;
+ PubdescPtr pdp = NULL;
+ PubdescPtr pdpcopy = NULL;
+ PubmedEntryPtr pep = NULL;
+ Int4 pmid = 0;
+ CharPtr prefix = NULL;
+ RefBlockPtr rbp;
+ SubmitBlockPtr sbp;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp = NULL;
+ SeqIdPtr sip;
+ SeqLocPtr slp;
+ SeqSubmitPtr ssp;
+ Int4 start;
+ Int4 stop;
+ CharPtr str;
+ Boolean strict_isojta;
+ CharPtr suffix = NULL;
+ CharPtr tmp;
+ Boolean trailingPeriod = TRUE;
+ ValNodePtr vnp;
+ StringItemPtr ffstring, temp;
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ rbp = (RefBlockPtr) bbp;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+ bsp = asp->bsp;
+ if (bsp == NULL) return NULL;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return NULL;
+
+ if (ajp->index) {
+ index = &asp->index;
+ } else {
+ index = NULL;
+ }
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (! StringHasNoText (rbp->string)) return StringSave (rbp->string);
+
+ /* could be descriptor, feature, or submit block citation */
+
+ if (rbp->itemtype == OBJ_SEQDESC) {
+
+ sdp = SeqMgrGetDesiredDescriptor (rbp->entityID, NULL, rbp->itemID, 0, NULL, &dcontext);
+ if (sdp != NULL && dcontext.seqdesctype == Seq_descr_pub) {
+ pdp = (PubdescPtr) sdp->data.ptrvalue;
+ }
+
+ } else if (rbp->itemtype == OBJ_SEQFEAT) {
+
+ sfp = SeqMgrGetDesiredFeature (rbp->entityID, NULL, rbp->itemID, 0, NULL, &fcontext);
+ if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_PUB) {
+ pdp = (PubdescPtr) sfp->data.value.ptrvalue;
+ }
+
+ } else if (rbp->itemtype == OBJ_SEQSUB_CIT) {
+
+ omdp = ObjMgrGetData (rbp->entityID);
+ if (omdp != NULL && omdp->datatype == OBJ_SEQSUB) {
+ ssp = (SeqSubmitPtr) omdp->dataptr;
+ if (ssp != NULL && ssp->datatype == 1) {
+ sbp = ssp->sub;
+ if (sbp != NULL) {
+ csp = sbp->cit;
+ }
+ }
+ }
+ }
+
+ if (pdp == NULL && csp == NULL) return NULL;
+
+ temp = FFGetString(ajp);
+ if ( temp == NULL ) {
+ FFRecycleString(ajp, ffstring);
+ return NULL;
+ }
+
+ /* any justuids left at this point is RefSeq protein, and should be fetched */
+
+ irp = (IntRefBlockPtr) rbp;
+ if (irp->justuids) {
+ if (rbp->pmid != 0) {
+ pep = GetPubMedForUid (rbp->pmid);
+ } else if (rbp->muid != 0) {
+ pep = GetPubMedForUid (rbp->muid);
+ }
+ if (pep != NULL) {
+ mep = (MedlineEntryPtr) pep->medent;
+ if (mep != NULL && mep->cit != NULL) {
+ pdpcopy = AsnIoMemCopy ((Pointer) pdp,
+ (AsnReadFunc) PubdescAsnRead,
+ (AsnWriteFunc) PubdescAsnWrite);
+ cap = AsnIoMemCopy ((Pointer) mep->cit,
+ (AsnReadFunc) CitArtAsnRead,
+ (AsnWriteFunc) CitArtAsnWrite);
+ vnp = ValNodeAddPointer (&(pdpcopy->pub), PUB_Article, (Pointer) cap);
+ pdp = pdpcopy;
+ }
+ }
+ }
+
+ /* print serial number */
+ FFStartPrint(temp, afp->format, 0, 12, "REFERENCE", 12, 5, 5, "RN", TRUE);
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ if (rbp->serial > 99) {
+ sprintf (buf, "%d ", (int) rbp->serial);
+ } else {
+ sprintf (buf, "%d", (int) rbp->serial);
+ }
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ sprintf (buf, "[%d]", (int) rbp->serial);
+ }
+
+ FFAddOneString(temp, buf, FALSE, FALSE, TILDE_TO_SPACES);
+
+ /* print base range */
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+
+ if (rbp->sites != 3) {
+ FFAddNChar(temp, ' ', 15 - temp->pos, FALSE);
+ }
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+
+ if (rbp->sites == 0) {
+ FFLineWrap(ffstring, temp, 0, 5, ASN2FF_EMBL_MAX, "RN");
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+ FFStartPrint(temp, afp->format, 0, 0, NULL, 0, 5, 5, "RP", FALSE);
+ }
+ }
+
+ if (rbp->sites == 1 || rbp->sites == 2) {
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFAddOneString(temp, "(sites)", FALSE, FALSE, TILDE_TO_SPACES);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ } else {
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RP");
+ }
+ } else if (rbp->sites == 3) {
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ } else {
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RP");
+ }
+ } else {
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFAddNChar(temp, ' ', 15 - temp->pos, FALSE);
+ if (afp->format == GENBANK_FMT) {
+ FFAddOneString(temp, "(bases ", FALSE, FALSE, TILDE_TO_SPACES);
+ } else {
+ FFAddOneString(temp, "(residues ", FALSE, FALSE, TILDE_TO_SPACES);
+ }
+ }
+
+ irp = (IntRefBlockPtr) rbp;
+ loc = irp->loc;
+
+ if (loc != NULL) {
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ suffix = "; ";
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ suffix = ", ";
+ }
+
+ slp = SeqLocFindNext (loc, NULL);
+ while (slp != NULL) {
+ nextslp = SeqLocFindNext (loc, slp);
+ start = SeqLocStart (slp) + 1;
+ stop = SeqLocStop (slp) + 1;
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ sprintf (buf, "%ld to %ld", (long) start, (long) stop);
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ sprintf (buf, "%ld-%ld", (long) start, (long) stop);
+ }
+ if (nextslp == NULL) {
+ suffix = NULL;
+ }
+ FFAddTextToString(temp, NULL, buf, suffix, FALSE, FALSE, TILDE_TO_SPACES);
+ slp = nextslp;
+ }
+
+ } else {
+
+ /* code still used for ssp->cit */
+
+ start = 1;
+ stop = bsp->length;
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ sprintf (buf, "%ld to %ld", (long) start, (long) stop);
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ sprintf (buf, "%ld-%ld", (long) start, (long) stop);
+ }
+ FFAddOneString(temp, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ }
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFAddOneString(temp, ")", FALSE, FALSE, TILDE_TO_SPACES);
+ }
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ } else {
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RP");
+ }
+ }
+
+ if (gbseq != NULL) {
+ gbref = GBReferenceNew ();
+ }
+
+ /* print author list */
+
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+ FFStartPrint(temp, afp->format, 2, 12, "AUTHORS", 12, 5, 5, "RA", FALSE);
+
+ str = NULL;
+ consortium = NULL;
+
+ alp = GetAuthListPtr (pdp, csp);
+ if (alp != NULL) {
+ str = GetAuthorsString (afp->format, alp, &consortium, index, gbref);
+ TrimSpacesAroundString (str);
+ }
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ suffix = NULL;
+ trailingPeriod = TRUE;
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ trailingPeriod = FALSE;
+ len = StringLen (str);
+ if (len > 0 && str [len - 1] != '.') {
+ suffix = ".;";
+ } else {
+ suffix = ";";
+ }
+ }
+
+ /* if no authors were found, period will still be added by this call */
+ if (str != NULL) {
+ FFAddTextToString(temp, NULL, str, suffix, trailingPeriod, FALSE, TILDE_TO_SPACES);
+ } else {
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFAddOneChar(temp, '.', FALSE);
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ FFAddOneChar(temp, ';', FALSE);
+ }
+ }
+
+ MemFree (str);
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ } else {
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RA");
+ }
+
+ /* print consortium */
+
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+ if (! StringHasNoText (consortium)) {
+ FFStartPrint (temp, afp->format, 2, 12, "CONSRTM", 12, 5, 5, "CM", FALSE);
+ FFAddTextToString (temp, NULL, consortium, suffix, FALSE, FALSE, TILDE_TO_SPACES);
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ } else {
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "CM");
+ }
+ }
+ MemFree (consortium);
+
+ /* print title */
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ str = GetPubTitle (afp->format, pdp, csp);
+ CleanPubTitle (str);
+ StrStripSpaces (str);
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ prefix = NULL;
+ suffix = NULL;
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ if (str != NULL) {
+ prefix = "\"";
+ suffix = "\";";
+ } else {
+ prefix = NULL;
+ suffix = ";";
+ }
+ }
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ if (! StringHasNoText (str)) {
+ FFStartPrint (temp, afp->format, 2, 12, "TITLE", 12, 5, 5, "RT", FALSE);
+
+ FFAddTextToString (temp, prefix, str, suffix, FALSE, FALSE, TILDE_TO_SPACES);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ }
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ FFStartPrint (temp, afp->format, 2, 12, "TITLE", 12, 5, 5, "RT", FALSE);
+ if (! StringHasNoText (str)) {
+
+ FFAddTextToString (temp, prefix, str, suffix, FALSE, FALSE, TILDE_TO_SPACES);
+
+ } else {
+ FFAddOneChar (temp, ';', FALSE);
+ }
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RT");
+ }
+
+ if (gbseq != NULL) {
+ if (gbref != NULL) {
+ gbref->title = StringSaveNoNull (str);
+ }
+ }
+
+ MemFree (str);
+
+ /* print journal */
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ FFStartPrint (temp, afp->format, 2, 12, "JOURNAL", 12, 5, 5, "RL", FALSE);
+
+ /* Only GenBank/EMBL/DDBJ require ISO JTA in ENTREZ/RELEASE modes (RefSeq should later) */
+
+ citArtIsoJta = ajp->flags.citArtIsoJta;
+ strict_isojta = FALSE;
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GENBANK ||
+ sip->choice == SEQID_EMBL ||
+ sip->choice == SEQID_DDBJ ||
+ /* sip->choice == SEQID_OTHER || */
+ sip->choice == SEQID_TPG ||
+ sip->choice == SEQID_TPE ||
+ sip->choice == SEQID_TPD) {
+ strict_isojta = TRUE;
+ }
+ }
+ if (! strict_isojta) {
+ citArtIsoJta = FALSE;
+ }
+
+ str = GetPubJournal (afp->format, ajp->flags.dropBadCitGens,
+ ajp->flags.noAffilOnUnpub, citArtIsoJta,
+ pdp, csp, bsp->id, index);
+ if (str == NULL) {
+ str = StringSave ("Unpublished");
+ }
+ StrStripSpaces (str);
+ TrimSpacesAroundString (str);
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ needsPeriod = FALSE;
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ if (! IsCitSub (pdp, csp)) {
+ needsPeriod = TRUE;
+ }
+ }
+
+ FFAddOneString (temp, str, FALSE, FALSE, TILDE_IGNORE);
+ if (needsPeriod) {
+ FFAddOneChar(temp, '.', FALSE);
+ }
+
+ if (gbseq != NULL) {
+ if (gbref != NULL) {
+ gbref->journal = StringSaveNoNull (str);
+ tmp = gbref->journal;
+ if (tmp != NULL) {
+ ch = *tmp;
+ while (ch != '\0') {
+ if (ch == '\n' || ch == '\r' || ch == '\t') {
+ *tmp = ' ';
+ }
+ tmp++;
+ ch = *tmp;
+ }
+ TrimSpacesAroundString (gbref->journal);
+ }
+ }
+ }
+
+ MemFree (str);
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ } else {
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RL");
+ }
+
+ /* print muid */
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ muid = GetMuid (pdp);
+ if (muid > 0) {
+ FFStartPrint (temp, afp->format, 2, 12, "MEDLINE", 12, 5, 5, "RX", FALSE);
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ FF_www_muid (ajp, temp, muid);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ sprintf (buf, "MEDLINE; %ld.", (long) muid);
+ FFAddOneString (temp, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "RX");
+ }
+ }
+
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+ pmid = GetPmid (pdp);
+ if (pmid > 0) {
+ FFStartPrint (temp, afp->format, 3, 12, "PUBMED", 12, 5, 5, "RX", FALSE);
+
+ FF_www_muid (ajp, temp, pmid);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ }
+ }
+
+ if (gbseq != NULL) {
+ if (gbref != NULL) {
+ gbref->medline = muid;
+ gbref->pubmed = pmid;
+ }
+ }
+
+ if (pdp == NULL) {
+ str = FFToCharPtr(ffstring);
+
+ if (gbseq != NULL) {
+ if (gbref != NULL) {
+ AddReferenceToGbseq (gbseq, gbref, str);
+ }
+ }
+
+ FFRecycleString(ajp, ffstring);
+ FFRecycleString(ajp, temp);
+ if (pep != NULL) {
+ PubmedEntryFree (pep);
+ }
+ if (pdpcopy != NULL) {
+ PubdescFree (pdpcopy);
+ }
+
+ return str;
+ }
+
+
+ /* !!! remainder of fields are only for GenBank !!! */
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+
+ prefix = "REMARK";
+
+ if (pdp->comment != NULL) {
+ for (i = 0, notFound = TRUE; notFound && remarksText [i] != NULL; i++) {
+ if (StringCmp (pdp->comment, remarksText [i]) == 0) {
+ notFound = FALSE;
+ }
+ }
+ if (notFound) {
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
+ FFAddOneString (temp, pdp->comment, FALSE, TRUE, TILDE_EXPAND);
+ /* AddCommentWithURLlinks(ajp, temp, NULL, pdp->comment, NULL); */
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ prefix = NULL;
+
+ if (gbseq != NULL) {
+ if (gbref != NULL) {
+ gbref->remark = StringSave (pdp->comment);
+ }
+ }
+
+ }
+ }
+
+ gibbsq = 0;
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_GIBBSQ) {
+ gibbsq = sip->data.intvalue;
+ }
+ }
+ csp = NULL;
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == PUB_Sub) {
+ csp = (CitSubPtr) vnp->data.ptrvalue;
+ }
+ }
+ if (gibbsq > 0 /* && csp == NULL */) {
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ sprintf (buf, "GenBank staff at the National Library of Medicine created this entry [NCBI gibbsq %ld] from the original journal article.", (long) gibbsq);
+ FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
+ FFAddOneString (temp, buf, FALSE, FALSE, TILDE_EXPAND);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ prefix = NULL;
+
+ /* gibbsq comment section (fields may be copied from degenerate pubdesc) */
+
+ str = pdp->fig;
+ if (StringHasNoText (str)) {
+ str = irp->fig;
+ }
+ if (! StringHasNoText (str)) {
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ sprintf (buf, "This sequence comes from %s", str);
+ FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
+ FFAddOneString (temp, buf, TRUE, TRUE, TILDE_EXPAND);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ prefix = NULL;
+ }
+
+ if (pdp->poly_a || irp->poly_a) {
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ FFStartPrint (temp ,afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
+ FFAddOneString (temp, "Polyadenylate residues occurring in the figure were omitted from the sequence.", TRUE, TRUE, TILDE_EXPAND);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ prefix = NULL;
+ }
+
+ str = pdp->maploc;
+ if (StringHasNoText (str)) {
+ str = irp->maploc;
+ }
+ if (! StringHasNoText (str)) {
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ sprintf (buf, "Map location: %s", str);
+ FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
+ FFAddOneString (temp, buf, TRUE, TRUE, TILDE_EXPAND);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ prefix = NULL;
+ }
+
+ }
+
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == PUB_Article) {
+ cap = (CitArtPtr) vnp->data.ptrvalue;
+ if (cap != NULL && cap->from == 1) {
+ cjp = (CitJourPtr) cap->fromptr;
+ if (cjp != NULL) {
+ imp = cjp->imp;
+ if (imp != NULL) {
+ crp = imp->retract;
+ if (crp != NULL && crp->type == 3) {
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
+ FFAddOneString (temp, "Erratum:", FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddTextToString (temp, "[", crp->exp, "]", FALSE, TRUE, TILDE_EXPAND);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ prefix = NULL;
+ }
+ }
+ }
+ }
+ } else if (vnp->choice == PUB_Sub) {
+ csp = (CitSubPtr) vnp->data.ptrvalue;
+ if (csp != NULL) {
+ if (! StringHasNoText (csp->descr)) {
+ FFRecycleString(ajp, temp);
+ temp = FFGetString(ajp);
+
+ FFStartPrint (temp, afp->format, 2, 12, prefix, 12, 5, 5, NULL, FALSE);
+ /* FFAddOneString (temp, csp->descr, FALSE, TRUE, TILDE_EXPAND); */
+ AddCommentWithURLlinks(ajp, temp, NULL, csp->descr, NULL);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ prefix = NULL;
+ }
+ }
+ }
+ }
+
+ }
+
+ str = FFToCharPtr(ffstring);
+
+ if (gbseq != NULL) {
+ if (gbref != NULL) {
+ AddReferenceToGbseq (gbseq, gbref, str);
+ }
+ }
+
+ FFRecycleString(ajp, ffstring);
+ FFRecycleString(ajp, temp);
+ if (pep != NULL) {
+ PubmedEntryFree (pep);
+ }
+ if (pdpcopy != NULL) {
+ PubdescFree (pdpcopy);
+ }
+
+ return str;
+}
+
+
diff --git a/api/asn2gnb6.c b/api/asn2gnb6.c
new file mode 100644
index 00000000..70e3366c
--- /dev/null
+++ b/api/asn2gnb6.c
@@ -0,0 +1,3851 @@
+/* asn2gnb6.c
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: asn2gnb6.c
+*
+* Author: Karl Sirotkin, Tom Madden, Tatiana Tatusov, Jonathan Kans,
+* Mati Shomrat
+*
+* Version Creation Date: 10/21/98
+*
+* $Revision: 1.2 $
+*
+* File Description: New GenBank flatfile generator - work in progress
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <objall.h>
+#include <objsset.h>
+#include <objsub.h>
+#include <objfdef.h>
+#include <objpubme.h>
+#include <seqport.h>
+#include <sequtil.h>
+#include <sqnutils.h>
+#include <subutil.h>
+#include <tofasta.h>
+#include <explore.h>
+#include <gbfeat.h>
+#include <gbftdef.h>
+#include <edutil.h>
+#include <alignmgr2.h>
+#include <asn2gnbi.h>
+
+#ifdef WIN_MAC
+#if __profile__
+#include <Profiler.h>
+#endif
+#endif
+
+/* ordering arrays for qualifiers and note components */
+
+static SourceType source_qual_order [] = {
+ SCQUAL_organism,
+
+ SCQUAL_organelle,
+
+ SCQUAL_mol_type,
+
+ SCQUAL_strain,
+ SCQUAL_sub_strain,
+ SCQUAL_variety,
+ SCQUAL_serotype,
+ SCQUAL_serovar,
+ SCQUAL_cultivar,
+ SCQUAL_isolate,
+ SCQUAL_isolation_source,
+ SCQUAL_spec_or_nat_host,
+ SCQUAL_sub_species,
+ SCQUAL_specimen_voucher,
+
+ SCQUAL_db_xref,
+ SCQUAL_org_xref,
+
+ SCQUAL_chromosome,
+
+ SCQUAL_segment,
+
+ SCQUAL_map,
+ SCQUAL_clone,
+ SCQUAL_sub_clone,
+ SCQUAL_haplotype,
+ SCQUAL_sex,
+ SCQUAL_cell_line,
+ SCQUAL_cell_type,
+ SCQUAL_tissue_type,
+ SCQUAL_clone_lib,
+ SCQUAL_dev_stage,
+ SCQUAL_ecotype,
+ SCQUAL_frequency,
+
+ SCQUAL_germline,
+ SCQUAL_rearranged,
+ SCQUAL_transgenic,
+ SCQUAL_environmental_sample,
+
+ SCQUAL_lab_host,
+ SCQUAL_pop_variant,
+ SCQUAL_tissue_lib,
+
+ SCQUAL_plasmid_name,
+ SCQUAL_transposon_name,
+ SCQUAL_ins_seq_name,
+
+ SCQUAL_country,
+
+ SCQUAL_focus,
+
+ SCQUAL_note,
+
+ SCQUAL_sequenced_mol,
+ SCQUAL_label,
+ SCQUAL_usedin,
+ SCQUAL_citation,
+ (SourceType) 0
+};
+
+static SourceType source_desc_note_order [] = {
+ SCQUAL_seqfeat_note,
+ SCQUAL_orgmod_note,
+ SCQUAL_subsource_note,
+
+ SCQUAL_type,
+ SCQUAL_sub_type,
+ SCQUAL_serogroup,
+ SCQUAL_pathovar,
+ SCQUAL_chemovar,
+ SCQUAL_biovar,
+ SCQUAL_biotype,
+ SCQUAL_group,
+ SCQUAL_sub_group,
+ SCQUAL_common,
+ SCQUAL_acronym,
+ SCQUAL_dosage,
+
+ SCQUAL_authority,
+ SCQUAL_forma,
+ SCQUAL_forma_specialis,
+ SCQUAL_synonym,
+ SCQUAL_anamorph,
+ SCQUAL_teleomorph,
+ SCQUAL_breed,
+
+ SCQUAL_genotype,
+ SCQUAL_plastid_name,
+
+ SCQUAL_endogenous_virus_name,
+
+ SCQUAL_common_name,
+
+ SCQUAL_zero_orgmod,
+ SCQUAL_one_orgmod,
+ SCQUAL_zero_subsrc,
+
+ /* SCQUAL_old_lineage, */
+
+ /* SCQUAL_old_name, */
+ (SourceType) 0
+};
+
+static SourceType source_feat_note_order [] = {
+ SCQUAL_unstructured,
+
+ SCQUAL_type,
+ SCQUAL_sub_type,
+ SCQUAL_serogroup,
+ SCQUAL_pathovar,
+ SCQUAL_chemovar,
+ SCQUAL_biovar,
+ SCQUAL_biotype,
+ SCQUAL_group,
+ SCQUAL_sub_group,
+ SCQUAL_common,
+ SCQUAL_acronym,
+ SCQUAL_dosage,
+
+ SCQUAL_authority,
+ SCQUAL_forma,
+ SCQUAL_forma_specialis,
+ SCQUAL_synonym,
+ SCQUAL_anamorph,
+ SCQUAL_teleomorph,
+ SCQUAL_breed,
+
+ SCQUAL_genotype,
+ SCQUAL_plastid_name,
+
+ SCQUAL_endogenous_virus_name,
+
+ SCQUAL_seqfeat_note,
+ SCQUAL_orgmod_note,
+ SCQUAL_subsource_note,
+
+ SCQUAL_common_name,
+
+ SCQUAL_zero_orgmod,
+ SCQUAL_one_orgmod,
+ SCQUAL_zero_subsrc,
+
+ /* SCQUAL_old_lineage, */
+
+ /* SCQUAL_old_name, */
+ (SourceType) 0
+};
+
+NLM_EXTERN SourceQual asn2gnbk_source_quals [ASN2GNBK_TOTAL_SOURCE] = {
+ { "", Qual_class_ignore },
+ { "acronym", Qual_class_orgmod },
+ { "anamorph", Qual_class_orgmod },
+ { "authority", Qual_class_orgmod },
+ { "biotype", Qual_class_orgmod },
+ { "biovar", Qual_class_orgmod },
+ { "breed", Qual_class_orgmod },
+ { "cell_line", Qual_class_subsource },
+ { "cell_type", Qual_class_subsource },
+ { "chemovar", Qual_class_orgmod },
+ { "chromosome", Qual_class_subsource },
+ { "citation", Qual_class_pubset },
+ { "clone", Qual_class_subsource },
+ { "clone_lib", Qual_class_subsource },
+ { "common", Qual_class_orgmod },
+ { "common", Qual_class_string },
+ { "country", Qual_class_subsource },
+ { "cultivar", Qual_class_orgmod },
+ { "db_xref", Qual_class_db_xref },
+ { "db_xref", Qual_class_db_xref },
+ { "dev_stage", Qual_class_subsource },
+ { "dosage", Qual_class_orgmod },
+ { "ecotype", Qual_class_orgmod },
+ { "endogenous_virus", Qual_class_subsource },
+ { "environmental_sample", Qual_class_subsource },
+ { "extrachromosomal", Qual_class_boolean },
+ { "focus", Qual_class_boolean },
+ { "forma", Qual_class_orgmod },
+ { "forma_specialis", Qual_class_orgmod },
+ { "frequency", Qual_class_subsource },
+ { "gb_acronym", Qual_class_orgmod },
+ { "gb_anamorph", Qual_class_orgmod },
+ { "gb_synonym", Qual_class_orgmod },
+ { "genotype", Qual_class_subsource },
+ { "germline", Qual_class_subsource },
+ { "group", Qual_class_orgmod },
+ { "haplotype", Qual_class_subsource },
+ { "insertion_seq", Qual_class_subsource },
+ { "isolate", Qual_class_orgmod },
+ { "isolation_source", Qual_class_subsource },
+ { "lab_host", Qual_class_subsource },
+ { "label", Qual_class_label },
+ { "macronuclear", Qual_class_boolean },
+ { "map", Qual_class_subsource },
+ { "mol_type", Qual_class_string },
+ { "note", Qual_class_note },
+ { "old_lineage", Qual_class_orgmod },
+ { "old_name", Qual_class_orgmod },
+ { "organism", Qual_class_string },
+ { "organelle", Qual_class_organelle },
+ { "orgmod_note", Qual_class_orgmod },
+ { "pathovar", Qual_class_orgmod },
+ { "plasmid", Qual_class_subsource },
+ { "plastid", Qual_class_subsource },
+ { "pop_variant", Qual_class_subsource },
+ { "rearranged", Qual_class_subsource },
+ { "segment", Qual_class_subsource },
+ { "seqfeat_note", Qual_class_string },
+ { "sequenced_mol", Qual_class_quote },
+ { "serogroup", Qual_class_orgmod },
+ { "serotype", Qual_class_orgmod },
+ { "serovar", Qual_class_orgmod },
+ { "sex", Qual_class_subsource },
+ { "specific_host", Qual_class_orgmod },
+ { "specimen_voucher", Qual_class_orgmod },
+ { "strain", Qual_class_orgmod },
+ { "sub_clone", Qual_class_subsource },
+ { "subgroup", Qual_class_orgmod },
+ { "sub_species", Qual_class_orgmod },
+ { "sub_strain", Qual_class_orgmod },
+ { "subtype", Qual_class_orgmod },
+ { "subsource_note", Qual_class_subsource },
+ { "synonym", Qual_class_orgmod },
+ { "teleomorph", Qual_class_orgmod },
+ { "tissue_lib", Qual_class_subsource },
+ { "tissue_type", Qual_class_subsource },
+ { "transgenic", Qual_class_subsource },
+ { "transposon", Qual_class_subsource },
+ { "type", Qual_class_orgmod },
+ { "unstructured", Qual_class_valnode },
+ { "usedin", Qual_class_quote },
+ { "variety", Qual_class_orgmod },
+ { "?", Qual_class_orgmod },
+ { "?", Qual_class_orgmod },
+ { "?", Qual_class_subsource },
+};
+
+NLM_EXTERN SourceType subSourceToSourceIdx [30] = {
+ SCQUAL_zero_subsrc,
+ SCQUAL_chromosome,
+ SCQUAL_map,
+ SCQUAL_clone,
+ SCQUAL_sub_clone,
+ SCQUAL_haplotype,
+ SCQUAL_genotype,
+ SCQUAL_sex,
+ SCQUAL_cell_line,
+ SCQUAL_cell_type,
+ SCQUAL_tissue_type,
+ SCQUAL_clone_lib,
+ SCQUAL_dev_stage,
+ SCQUAL_frequency,
+ SCQUAL_germline,
+ SCQUAL_rearranged,
+ SCQUAL_lab_host,
+ SCQUAL_pop_variant,
+ SCQUAL_tissue_lib,
+ SCQUAL_plasmid_name,
+ SCQUAL_transposon_name,
+ SCQUAL_ins_seq_name,
+ SCQUAL_plastid_name,
+ SCQUAL_country,
+ SCQUAL_segment,
+ SCQUAL_endogenous_virus_name,
+ SCQUAL_transgenic,
+ SCQUAL_environmental_sample,
+ SCQUAL_isolation_source,
+ SCQUAL_subsource_note
+};
+
+/* ********************************************************************** */
+
+/* ********************************************************************** */
+
+/* format functions allocate printable string for given paragraph */
+
+/* superset of http://www.ncbi.nlm.nih.gov/collab/db_xref.html and RefSeq db_xrefs */
+
+NLM_EXTERN CharPtr legalDbXrefs [] = {
+ "PIDe", "PIDd", "PIDg", "PID",
+ "AceView/WormGenes",
+ "ATCC",
+ "ATCC(in host)",
+ "ATCC(dna)",
+ "BDGP_EST",
+ "BDGP_INS",
+ "CDD",
+ "CK",
+ "COG",
+ "dbEST",
+ "dbSNP",
+ "dbSTS",
+ "ENSEMBL",
+ "ESTLIB",
+ "FANTOM_DB",
+ "FLYBASE",
+ "GABI",
+ "GDB",
+ "GeneDB",
+ "GeneID",
+ "GI",
+ "GO",
+ "GOA",
+ "IFO",
+ "IMGT/LIGM",
+ "IMGT/HLA",
+ "InterimID",
+ "Interpro",
+ "ISFinder",
+ "JCM",
+ "LocusID",
+ "MaizeDB",
+ "MGD",
+ "MGI",
+ "MIM",
+ "NextDB",
+ "niaEST",
+ "PIR",
+ "PSEUDO",
+ "RATMAP",
+ "RiceGenes",
+ "REMTREMBL",
+ "RGD",
+ "RZPD",
+ "SGD",
+ "SoyBase",
+ "SPTREMBL",
+ "SWISS-PROT",
+ "taxon",
+ "UniGene",
+ "UniSTS",
+ "WorfDB",
+ "WormBase",
+ "ZFIN",
+ NULL
+};
+
+NLM_EXTERN CharPtr legalRefSeqDbXrefs [] = {
+ "REBASE",
+ NULL
+};
+
+static CharPtr organellePrefix [] = {
+ NULL,
+ NULL,
+ "Chloroplast ",
+ "Chromoplast ",
+ "Kinetoplast ",
+ "Mitochondrion ",
+ "Plastid ",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "Cyanelle ",
+ NULL,
+ NULL,
+ "Nucleomorph ",
+ "Apicoplast ",
+ "Leucoplast ",
+ "Proplastid ",
+ NULL
+};
+
+static CharPtr newOrganellePrefix [] = {
+ NULL,
+ NULL,
+ "chloroplast ",
+ "chromoplast ",
+ "kinetoplast ",
+ "mitochondrion ",
+ "plastid ",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "cyanelle ",
+ NULL,
+ NULL,
+ "nucleomorph ",
+ "apicoplast ",
+ "leucoplast ",
+ "proplastid ",
+ NULL
+};
+
+NLM_EXTERN CharPtr FormatSourceBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ CharPtr acr = NULL;
+ Boolean addPeriod = TRUE;
+ IntAsn2gbJobPtr ajp;
+ CharPtr ana = NULL;
+ Asn2gbSectPtr asp;
+ BioSourcePtr biop = NULL;
+ CharPtr com = NULL;
+ CharPtr common = NULL;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ CharPtr gbacr = NULL;
+ CharPtr gbana = NULL;
+ GBBlockPtr gbp = NULL;
+ GBSeqPtr gbseq;
+ CharPtr gbsyn = NULL;
+ Uint1 genome;
+ ValNodePtr mod = NULL;
+ OrgModPtr omp = NULL;
+ OrgNamePtr onp;
+ CharPtr organelle = NULL;
+ OrgRefPtr orp;
+ CharPtr prefix = " (";
+ SeqDescrPtr sdp;
+ CharPtr second = NULL;
+ SeqFeatPtr sfp;
+ CharPtr str;
+ CharPtr syn = NULL;
+ CharPtr taxname = NULL;
+ Boolean using_anamorph = FALSE;
+ StringItemPtr ffstring, temp;
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+
+ if (! StringHasNoText (bbp->string)) return StringSave (bbp->string);
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return NULL;
+
+ if (bbp->itemtype == OBJ_SEQDESC) {
+ sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID, 0, NULL, &dcontext);
+ if (sdp != NULL) {
+ if (dcontext.seqdesctype == Seq_descr_source) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ } else if (dcontext.seqdesctype == Seq_descr_genbank) {
+ gbp = (GBBlockPtr) sdp->data.ptrvalue;
+ }
+ }
+ } else if (bbp->itemtype == OBJ_SEQFEAT) {
+ sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
+ if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_BIOSRC) {
+ biop = (BioSourcePtr) sfp->data.value.ptrvalue;
+ }
+ }
+ if (gbp != NULL) {
+ common = gbp->source;
+ }
+
+ if (biop != NULL) {
+ genome = biop->genome;
+ if (genome <= 19) {
+ if (ajp->newSourceOrg && (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT)) {
+ organelle = newOrganellePrefix [genome];
+ } else {
+ organelle = organellePrefix [genome];
+ }
+ }
+ orp = biop->org;
+ if (orp != NULL) {
+ taxname = orp->taxname;
+ common = orp->common;
+ mod = orp->mod;
+ onp = orp->orgname;
+ if (onp != NULL) {
+
+ if (ajp->newSourceOrg) {
+ for (omp = onp->mod; omp != NULL; omp = omp->next) {
+ switch (omp->subtype) {
+ case ORGMOD_common :
+ com = omp->subname;
+ break;
+ case ORGMOD_acronym :
+ acr = omp->subname;
+ break;
+ case ORGMOD_synonym :
+ syn = omp->subname;
+ break;
+ case ORGMOD_anamorph :
+ ana = omp->subname;
+ break;
+ case ORGMOD_gb_acronym :
+ gbacr = omp->subname;
+ break;
+ case ORGMOD_gb_anamorph :
+ gbana = omp->subname;
+ break;
+ case ORGMOD_gb_synonym :
+ gbsyn = omp->subname;
+ break;
+ default :
+ break;
+ }
+ }
+
+ if (StringHasNoText (second)) {
+ second = syn;
+ using_anamorph = FALSE;
+ }
+ if (StringHasNoText (second)) {
+ second = acr;
+ using_anamorph = FALSE;
+ }
+ if (StringHasNoText (second)) {
+ second = ana;
+ using_anamorph = TRUE;
+ }
+ if (StringHasNoText (second)) {
+ second = com;
+ using_anamorph = FALSE;
+ }
+
+ if (StringHasNoText (second)) {
+ second = gbsyn;
+ using_anamorph = FALSE;
+ }
+ if (StringHasNoText (second)) {
+ second = gbacr;
+ using_anamorph = FALSE;
+ }
+ if (StringHasNoText (second)) {
+ second = gbana;
+ using_anamorph = TRUE;
+ }
+
+ if (StringHasNoText (second)) {
+ second = common;
+ using_anamorph = FALSE;
+ }
+ if (using_anamorph) {
+ prefix = " (anamorph: ";
+ }
+ }
+ }
+ }
+ }
+
+ /* If the organelle prefix is already on the */
+ /* name, don't add it. */
+
+ if (StringNCmp (organelle, taxname, StringLen (organelle)) == 0)
+ organelle = "";
+
+ if (StringHasNoText (common)) {
+ common = taxname;
+ }
+ if (StringHasNoText (common)) {
+ common = "Unknown.";
+ }
+ if (StringHasNoText (taxname)) {
+ taxname = "Unknown.";
+ }
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+
+ temp = FFGetString(ajp);
+
+ if (ajp->newSourceOrg) {
+
+ if (! StringHasNoText (organelle)) {
+ FFAddTextToString(temp, NULL, organelle, NULL, FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddTextToString(temp, NULL, taxname, NULL, FALSE, FALSE, TILDE_IGNORE);
+ if (! StringHasNoText (second)) {
+ FFAddTextToString(temp, prefix, second, ")", FALSE, FALSE, TILDE_IGNORE);
+ }
+ addPeriod = FALSE;
+
+ } else {
+ FFAddTextToString(temp, NULL, common, NULL, FALSE, FALSE, TILDE_IGNORE);
+ while (mod != NULL) {
+ str = (CharPtr) mod->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ FFAddTextToString(temp, " ", str, NULL, FALSE, FALSE, TILDE_IGNORE);
+ }
+ mod = mod->next;
+ }
+ }
+
+ str = FFToCharPtr(temp);
+ if (StringCmp (str, ".") == 0) {
+ str = MemFree (str);
+ }
+ FFRecycleString(ajp, temp);
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ gbseq->source = StringSave (str);
+ }
+
+
+ FFStartPrint(ffstring, afp->format, 0, 12, "SOURCE", 12, 5, 5, "OS", TRUE);
+ if (str != NULL) {
+ FFAddTextToString(ffstring, NULL, str, NULL, addPeriod, FALSE, TILDE_TO_SPACES);
+ } else {
+ FFAddOneChar(ffstring, '.', FALSE);
+ }
+
+ MemFree (str);
+
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+
+ FFStartPrint(ffstring, afp->format, 0, 12, "SOURCE", 12, 5, 5, "OS", TRUE);
+ FFAddTextToString(ffstring, NULL, taxname, NULL, FALSE, FALSE, TILDE_TO_SPACES);
+ if ( StringICmp(taxname, common) != 0 ) {
+ FFAddTextToString(ffstring, " (", common, ")", FALSE, FALSE, TILDE_TO_SPACES);
+ }
+ }
+
+ str = FFEndPrint(ajp, ffstring, afp->format, 12, 12, 0, 5, "OS");
+ FFRecycleString(ajp, ffstring);
+ return str;
+}
+
+NLM_EXTERN CharPtr FormatOrganismBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BioSourcePtr biop = NULL;
+ Char ch;
+ CharPtr common = NULL;
+ DbtagPtr dbt;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ GBSeqPtr gbseq;
+ Uint1 genome;
+ CharPtr lineage = NULL;
+ ObjectIdPtr oip;
+ OrgNamePtr onp;
+ CharPtr organelle = NULL;
+ OrgRefPtr orp;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+ CharPtr str;
+ Int4 taxid = -1;
+ CharPtr taxname = NULL;
+ CharPtr tmp;
+ CharPtr ptr;
+ ValNodePtr vnp;
+ StringItemPtr ffstring, temp;
+ Char buf [16];
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+
+
+ if (! StringHasNoText (bbp->string)) return StringSave (bbp->string);
+
+ if (bbp->itemtype == OBJ_SEQDESC) {
+ sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID, 0, NULL, &dcontext);
+ if (sdp != NULL && dcontext.seqdesctype == Seq_descr_source) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ }
+ } else if (bbp->itemtype == OBJ_SEQFEAT) {
+ sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
+ if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_BIOSRC) {
+ biop = (BioSourcePtr) sfp->data.value.ptrvalue;
+ }
+ }
+ if (biop != NULL) {
+ genome = biop->genome;
+ if (genome <= 19) {
+ organelle = organellePrefix [genome];
+ }
+ orp = biop->org;
+ if (orp != NULL) {
+ taxname = orp->taxname;
+ common = orp->common;
+ onp = orp->orgname;
+ if (onp != NULL) {
+ lineage = onp->lineage;
+ }
+ for (vnp = orp->db; vnp != NULL; vnp = vnp->next) {
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt == NULL) continue;
+ if (StringCmp (dbt->db, "taxon") == 0) {
+ oip = dbt->tag;
+ if (oip != NULL) {
+ taxid = oip->id;
+ }
+ }
+ }
+ }
+ }
+
+ /* If the organelle prefix is already on the */
+ /* name, don't add it. */
+
+ if (StringNCmp (organelle, taxname, StringLen (organelle)) == 0)
+ organelle = "";
+
+ if (StringHasNoText (common)) {
+ common = taxname;
+ }
+ if (StringHasNoText (common)) {
+ common = "Unknown.";
+ }
+ if (StringHasNoText (taxname)) {
+ taxname = "Unknown.";
+ }
+ if (StringHasNoText (lineage)) {
+ lineage = "Unclassified.";
+ }
+
+ ffstring = FFGetString(ajp);
+ temp = FFGetString(ajp);
+ if ( ffstring == NULL || temp == NULL ) return NULL;
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+
+ FFStartPrint(temp, afp->format, 2, 12, "ORGANISM", 12, 5, 5, "OC", FALSE);
+ if (! ajp->newSourceOrg) {
+ FFAddOneString(temp, organelle, FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (StringNICmp (taxname, "Unknown", 7) != 0) {
+ if ( GetWWW(ajp) ) {
+ if (taxid != -1) {
+ FFAddOneString(temp, "<a href=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(temp, link_tax, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(temp, "id=", FALSE, FALSE, TILDE_IGNORE);
+ sprintf (buf, "%ld", (long) taxid);
+ FFAddOneString(temp, buf, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(temp, ">", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(temp, "<a href=", FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(temp, link_tax, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(temp, "name=", FALSE, FALSE, TILDE_IGNORE);
+ tmp = StringSave (taxname);
+ if (tmp != NULL) {
+ ptr = tmp;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (IS_WHITESP (ch)) {
+ *ptr = '+';
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ FFAddOneString(temp, tmp, FALSE, FALSE, TILDE_IGNORE);
+ MemFree (tmp);
+ }
+ FFAddOneString(temp, ">", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString(temp, taxname, FALSE, FALSE, TILDE_IGNORE);
+ FFAddOneString(temp, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(temp, taxname, FALSE, FALSE, TILDE_IGNORE);
+ }
+ } else {
+ FFAddOneString(temp, taxname, FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ FFRecycleString(ajp, temp);
+
+ temp = FFGetString(ajp);
+ FFStartPrint(temp, afp->format, 12, 12, NULL, 0, 5, 5, "OC", FALSE);
+ FFAddTextToString(temp, NULL, lineage, NULL, TRUE, FALSE, TILDE_TO_SPACES);
+ FFLineWrap(ffstring, temp, 12, 12, ASN2FF_GB_MAX, NULL);
+ FFRecycleString(ajp, temp);
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ temp = FFGetString(ajp);
+ if (! ajp->newSourceOrg) {
+ FFAddOneString(temp, organelle, FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneString(temp, taxname, FALSE, FALSE, TILDE_IGNORE);
+ gbseq->organism = FFToCharPtr(temp);
+ gbseq->taxonomy = StringSave (lineage);
+ FFRecycleString(ajp, temp);
+ }
+
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ FFStartPrint(temp, afp->format, 12, 12, NULL, 0, 5, 5, "OC", FALSE);
+ FFAddTextToString(temp, NULL, lineage, NULL, TRUE, FALSE, TILDE_TO_SPACES);
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "OC");
+ FFRecycleString(ajp, temp);
+ if ( !StringHasNoText(organelle) ) {
+ temp = FFGetString(ajp);
+ if ( temp != NULL ) {
+ FFStartPrint(temp, afp->format, 12, 12, NULL, 0, 5, 5, "OG", FALSE);
+ FFAddTextToString(temp, NULL, organelle, NULL, TRUE, FALSE, TILDE_TO_SPACES);
+ FFLineWrap(ffstring, temp, 5, 5, ASN2FF_EMBL_MAX, "OG");
+ FFRecycleString(ajp, temp);
+ }
+ }
+ }
+
+ str = FFToCharPtr(ffstring);
+ FFRecycleString(ajp, ffstring);
+ return str;
+}
+
+/* A tilde is not an EOL if it is found in a sring of the form: */
+/* /~alpahnumdot/ where alphanumdot is either alpha numeric or '.' */
+/* */
+/* str points to the tilde in question. */
+static Boolean IsTildeEOL(CharPtr str) {
+ CharPtr ptr;
+
+ if ( *(str - 1) != '/' ) return TRUE;
+
+ ++str;
+
+
+ for ( ptr = str;
+ IS_ALPHANUM(*ptr) || *ptr == '_' || *ptr == '-' || *ptr == '.';
+ ++ptr) continue;
+
+ return *ptr == '/' ? FALSE : TRUE;
+}
+
+/* returns a pointer to the first character past the url */
+static CharPtr FindUrlEnding(CharPtr str) {
+ CharPtr ptr;
+
+ for ( ptr = str;
+ !IS_WHITESP(*ptr) && *ptr != '\0' && *ptr != '(' && *ptr != '\"';
+ ++ptr ) {
+ if ( *ptr == '~' ) {
+ if ( IsTildeEOL(ptr) ) break;
+ }
+ }
+
+ --ptr;
+
+ /* back up over any trailing periods, commas, or parentheses */
+ while ( (*ptr == '.') || (*ptr == ',') || (*ptr == ')') ) {
+ --ptr;
+ }
+
+ ++ptr;
+
+ return ptr;
+}
+
+NLM_EXTERN void AddCommentWithURLlinks (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr prefix,
+ CharPtr str,
+ CharPtr suffix
+)
+
+{
+ Char ch;
+ CharPtr ptr;
+
+ while (! StringHasNoText (str)) {
+ ptr = StringStr (str, "http://");
+ if (ptr == NULL) {
+ if (prefix != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ }
+ AddCommentStringWithTildes (ffstring, str);
+ if (suffix != NULL) {
+ FFAddOneString(ffstring, suffix, FALSE, FALSE, TILDE_IGNORE);
+ }
+ return;
+ }
+
+ *ptr = '\0';
+ AddCommentStringWithTildes (ffstring, str);
+ *ptr = 'h';
+
+ str = ptr;
+ ptr = FindUrlEnding(str);
+
+
+ ch = *ptr;
+ *ptr = '\0';
+ if ( GetWWW(ajp) ) {
+ FFAddTextToString(ffstring, "<a href=", str, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, NULL, str, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ FFAddOneString(ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ *ptr = ch;
+ str = ptr;
+ }
+}
+
+static void CatenateCommentInGbseq (
+ GBSeqPtr gbseq,
+ CharPtr str
+)
+
+{
+ Char ch;
+ CharPtr tmp;
+
+ if (gbseq == NULL || StringHasNoText (str)) return;
+
+ if (StringNCmp (str, "COMMENT ", 12) == 0) {
+ str += 12;
+ }
+ if (gbseq->comment == NULL) {
+ gbseq->comment = StringSave (str);
+ } else {
+ tmp = (CharPtr) MemNew (StringLen (gbseq->comment) + StringLen (str) + 4);
+ StringCpy (tmp, gbseq->comment);
+ StringCat (tmp, "; ");
+ StringCat (tmp, str);
+ gbseq->comment = MemFree (gbseq->comment);
+ gbseq->comment = tmp;
+ }
+
+ tmp = gbseq->comment;
+ if (tmp == NULL) return;
+ ch = *tmp;
+ while (ch != '\0') {
+ if (ch == '\n' || ch == '\r' || ch == '\t') {
+ *tmp = ' ';
+ }
+ tmp++;
+ ch = *tmp;
+ }
+ TrimSpacesAroundString (gbseq->comment);
+ Asn2gnbkCompressSpaces (gbseq->comment);
+}
+
+
+NLM_EXTERN CharPtr FormatCommentBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ Boolean add_period;
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ CommentBlockPtr cbp;
+ CharPtr db;
+ DbtagPtr dbt;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ GBSeqPtr gbseq;
+ size_t len;
+ ObjectIdPtr oip;
+ CharPtr prefix;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+ Char sfx [32];
+ CharPtr str;
+ CharPtr suffix;
+ CharPtr title;
+ StringItemPtr ffstring;
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+
+ cbp = (CommentBlockPtr) bbp;
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ /* some comments are allocated (along with possible first COMMENT label) */
+
+ if (! StringHasNoText (bbp->string)) {
+ str = StringSave (bbp->string);
+ CatenateCommentInGbseq (gbseq, str);
+ return str;
+ }
+
+ title = NULL;
+ prefix = NULL;
+ suffix = NULL;
+ add_period = FALSE;
+ sfx [0] = '\0';
+
+ if (bbp->itemtype == OBJ_SEQDESC) {
+
+ /* usually should reference comment, maploc, or region descriptor IDs */
+
+ sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID, 0, NULL, &dcontext);
+ if (sdp != NULL) {
+
+ if (dcontext.seqdesctype == Seq_descr_comment) {
+
+ title = (CharPtr) sdp->data.ptrvalue;
+
+ } else if (dcontext.seqdesctype == Seq_descr_maploc) {
+
+ dbt = (DbtagPtr) sdp->data.ptrvalue;
+ if (dbt != NULL) {
+ db = dbt->db;
+ oip = dbt->tag;
+ if (oip != NULL) {
+ if (oip->str != NULL) {
+
+ title = oip->str;
+ prefix = ("Map location: ");
+
+ } else if (db != NULL && oip->id != 0) {
+
+ title = db;
+ prefix = ("Map location: (Database ");
+ sprintf (sfx, "; id # %ld).", (long) oip->id);
+ suffix = sfx;
+
+ }
+ }
+ }
+
+ } else if (dcontext.seqdesctype == Seq_descr_region) {
+
+ title = (CharPtr) sdp->data.ptrvalue;
+ prefix = "Region: ";
+
+ }
+ }
+
+ } else if (bbp->itemtype == OBJ_SEQFEAT) {
+
+ /* also have to deal with comment feature across entire sequence */
+
+ sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
+ if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_COMMENT) {
+
+ title = sfp->comment;
+ }
+ }
+
+ if (title == NULL) return NULL;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return NULL;
+
+ if (cbp->first) {
+ FFStartPrint (ffstring, afp->format, 0, 12, "COMMENT", 12, 5, 5, "CC", TRUE);
+ } else {
+ FFStartPrint (ffstring, afp->format, 0, 12, NULL, 12, 5, 5, "CC", FALSE);
+ }
+
+ str = StringSave (title);
+ TrimSpacesAndJunkFromEnds (str, TRUE);
+ if (! IsEllipsis (str)) {
+ s_RemovePeriodFromEnd (str);
+ len = StringLen (str);
+ if (len > 0 && str [len - 1] != '.') {
+ add_period = TRUE;
+ }
+ }
+ AddCommentWithURLlinks(ajp, ffstring, prefix, str, suffix);
+ /*
+ if ( GetWWW(ajp) && prefix == NULL && suffix == NULL) {
+
+ AddCommentWithURLlinks (ffstring, str);
+ } else {
+ FFAddTextToString (ffstring, prefix, str, suffix, FALSE, TRUE, TILDE_OLD_EXPAND);
+ }
+ */
+ if (add_period) {
+ FFAddOneChar (ffstring, '.',FALSE);
+ }
+ MemFree (str);
+
+ str = FFEndPrint(ajp, ffstring, afp->format, 12, 12, 5, 5, "CC");
+
+ CatenateCommentInGbseq (gbseq, str);
+
+ FFRecycleString(ajp, ffstring);
+ return str;
+}
+
+/* format features section */
+
+static Boolean is_real_id (
+ SeqIdPtr sip,
+ SeqIdPtr this_sip
+)
+
+{
+ BioseqPtr bsp;
+
+ if (sip == NULL || this_sip == NULL) return FALSE;
+
+ if (! SeqIdIn (sip, this_sip)) {
+ bsp = BioseqFind (sip);
+ if (bsp == NULL) return TRUE; /* ??? */
+ if (bsp->repr == Seq_repr_virtual) return FALSE;
+ }
+
+ return TRUE;
+}
+
+static Boolean FlatVirtLoc (
+ BioseqPtr bsp,
+ SeqLocPtr location
+)
+
+{
+ SeqIntPtr sintp;
+ SeqIdPtr sip;
+ SeqPntPtr spp;
+
+ if (bsp == NULL || location == NULL) return FALSE;
+
+ switch (location->choice) {
+ case SEQLOC_WHOLE :
+ sip = (SeqIdPtr) location->data.ptrvalue;
+ if (sip == NULL) return TRUE;
+ if (! is_real_id (sip, bsp->id)) return TRUE;
+ break;
+ case SEQLOC_INT :
+ sintp = (SeqIntPtr) location->data.ptrvalue;
+ if (sintp == NULL) return TRUE;
+ sip = sintp->id;
+ if (sip == NULL) return TRUE;
+ if (! is_real_id (sip, bsp->id)) return TRUE;
+ break;
+ case SEQLOC_PNT :
+ spp = (SeqPntPtr) location->data.ptrvalue;
+ if (spp == NULL) return TRUE;
+ sip = spp->id;
+ if (sip == NULL) return TRUE;
+ if (! is_real_id (sip, bsp->id)) return TRUE;
+ break;
+ default :
+ break;
+ }
+
+ return FALSE;
+}
+
+static Uint1 order [NUM_SEQID];
+static Boolean order_initialized = FALSE;
+
+static CharPtr lim_str [5] = { "", ">","<", ">", "<" };
+
+NLM_EXTERN Boolean GetAccnVerFromServer (Int4 gi, CharPtr buf)
+
+{
+ AccnVerLookupFunc func;
+ SeqMgrPtr smp;
+ CharPtr str;
+
+ if (buf == NULL) return FALSE;
+ *buf = '\0';
+ smp = SeqMgrWriteLock ();
+ if (smp == NULL) return FALSE;
+ func = smp->accn_ver_lookup_func;
+ SeqMgrUnlock ();
+ if (func == NULL) return FALSE;
+ str = (*func) (gi);
+ if (str == NULL) return FALSE;
+ if (StringLen (str) < 40) {
+ StringCpy (buf, str);
+ }
+ MemFree (str);
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* FFFlatLoc functions . */
+/******************************************************************************/
+
+static Boolean FF_FlatNullAhead (
+ BioseqPtr bsp,
+ ValNodePtr location
+)
+
+{
+ SeqLocPtr next;
+
+ if (bsp == NULL || location == NULL) return FALSE;
+
+ next = location->next;
+ if (next == NULL) return TRUE;
+ if (next->choice == SEQLOC_NULL) return TRUE;
+ if (FlatVirtLoc (bsp, next)) return TRUE;
+
+ return FALSE;
+}
+
+
+
+static void FlatLocSeqId (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ SeqIdPtr sip
+)
+
+{
+ BioseqPtr bsp;
+ Char buf [40];
+ ObjectIdPtr oip;
+ SeqIdPtr use_id = NULL;
+ Boolean was_lock = FALSE;
+
+ if (ffstring == NULL || sip == NULL) return;
+
+ buf [0] = '\0';
+ bsp = BioseqFind (sip);
+ if (bsp != NULL) {
+ use_id = SeqIdSelect (bsp->id, order, NUM_SEQID);
+ } else if (sip->choice == SEQID_GI) {
+ if (GetAccnVerFromServer (sip->data.intvalue, buf)) {
+ FFAddTextToString(ffstring, NULL, buf, ":", FALSE, FALSE, TILDE_IGNORE);
+ /*AddValNodeString (head, NULL, buf, ":");*/
+ return;
+ }
+ use_id = GetSeqIdForGI (sip->data.intvalue);
+ }
+ if (use_id == NULL && bsp == NULL) {
+ bsp = BioseqLockById (sip);
+ was_lock = TRUE;
+ if (bsp != NULL) {
+ use_id = SeqIdSelect (bsp->id, order, NUM_SEQID);
+ }
+ }
+ if (use_id != NULL) {
+ SeqIdWrite (use_id, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
+ if (use_id->choice == SEQID_GI) {
+ ajp->relModeError = TRUE;
+ }
+ } else if (sip->choice == SEQID_GI) {
+ SeqIdWrite (sip, buf, PRINTID_FASTA_LONG, sizeof (buf) - 1);
+ ajp->relModeError = TRUE;
+ } else {
+ SeqIdWrite (sip, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
+ if (sip->choice == SEQID_GI) {
+ ajp->relModeError = TRUE;
+ }
+ }
+ if (was_lock) {
+ BioseqUnlock (bsp);
+ }
+ if (StringHasNoText (buf)) {
+ StringCpy (buf, "?00000");
+ ajp->relModeError = TRUE;
+ if (use_id != NULL && use_id->choice == SEQID_LOCAL) {
+ oip = (ObjectIdPtr) use_id->data.ptrvalue;
+ if (oip != NULL && (! StringHasNoText (oip->str))) {
+ StringNCpy_0 (buf, oip->str, 13);
+ }
+ }
+ }
+ FFAddTextToString(ffstring, NULL, buf, ":", FALSE, FALSE, TILDE_IGNORE);
+}
+
+
+
+static void FlatLocCaret (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ SeqIdPtr sip,
+ SeqIdPtr this_sip,
+ Int4 point,
+ IntFuzzPtr fuzz
+)
+
+{
+ Char buf [128];
+ Uint1 index;
+
+ if (ffstring == NULL) return;
+
+ if (sip != NULL && (! SeqIdIn (sip, this_sip))) {
+ FlatLocSeqId (ajp, ffstring, sip);
+ }
+
+ buf [0] = '\0';
+ point++; /* orginal FlatLocHalfCaret was called with point + 1 */
+
+ if (fuzz != NULL) {
+ switch (fuzz->choice) {
+ case 1 :
+ sprintf (buf, "(%ld.%ld)..(%ld.%ld)",
+ (long) (point - fuzz->a),
+ (long) point,
+ (long) point,
+ (long) (point + fuzz->a));
+ break;
+ case 2 :
+ sprintf (buf, "%ld^%ld",
+ (long) (1 + fuzz->b),
+ (long) (1 + fuzz->a));
+ break;
+ case 3 :
+ sprintf (buf, "%ld^%ld",
+ (long) (point - point * ((double) fuzz->a / 1000.0)),
+ (long) (point + point * ((double) fuzz->a / 1000.0)));
+ break;
+ case 4 :
+ if (fuzz->a == 3) { /* space to right */
+ sprintf (buf, "%ld^%ld", (long) (point), (long) (point + 1));
+ } else if (fuzz->a == 4 && point > 1) { /* space to left */
+ sprintf (buf, "%ld^%ld", (long) (point - 1), (long) point);
+ } else {
+ index = (Uint1) fuzz->a;
+ if (index > 4) {
+ index = 0;
+ }
+ sprintf (buf, "%s%ld", lim_str [index], (long) point);
+ }
+ break;
+ default :
+ sprintf (buf, "%ld", (long) point);
+ break;
+ }
+ } else {
+ sprintf (buf, "%ld", (long) point);
+ }
+
+ FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
+}
+
+
+static void FlatLocPoint (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ SeqIdPtr sip,
+ SeqIdPtr this_sip,
+ Int4 point,
+ IntFuzzPtr fuzz
+)
+
+{
+ Char buf [128];
+ Uint1 index;
+
+ if (ffstring == NULL) return;
+
+ if (sip != NULL && (! SeqIdIn (sip, this_sip))) {
+ FlatLocSeqId (ajp, ffstring, sip);
+ }
+
+ buf [0] = '\0';
+ point++;
+
+ if (fuzz != NULL) {
+ switch (fuzz->choice) {
+ case 1 :
+ sprintf (buf, "(%ld.%ld)",
+ (long) (point - fuzz->a),
+ (long) (point + fuzz->a));
+ break;
+ case 2 :
+ sprintf (buf, "(%ld.%ld)",
+ (long) (1 + fuzz->b),
+ (long) (1 + fuzz->a));
+ break;
+ case 3 :
+ sprintf (buf, "(%ld.%ld)",
+ (long) (point - point * ((double) fuzz->a / 1000.0)),
+ (long) (point + point * ((double) fuzz->a / 1000.0)));
+ break;
+ case 4 :
+ index = (Uint1) fuzz->a;
+ if (index > 4) {
+ index = 0;
+ }
+ sprintf (buf, "%s%ld", lim_str [index], (long) point);
+ break;
+ default :
+ sprintf (buf, "%ld", (long) point);
+ break;
+ }
+ } else {
+ sprintf (buf, "%ld", (long) point);
+ }
+
+ FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
+}
+
+
+static void FlatLocElement (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ BioseqPtr bsp,
+ SeqLocPtr location
+)
+
+{
+ Boolean minus_strand = FALSE;
+ SeqBondPtr sbp;
+ SeqIntPtr sintp;
+ SeqIdPtr sip;
+ SeqPntPtr spp;
+ BioseqPtr wholebsp;
+
+ if (ffstring == NULL || bsp == NULL || location == NULL) return;
+
+ switch (location->choice) {
+ case SEQLOC_WHOLE :
+ sip = (SeqIdPtr) location->data.ptrvalue;
+ if (sip == NULL) return;
+ wholebsp = BioseqFind (sip);
+ if (wholebsp == NULL) return;
+ if (is_real_id (sip, bsp->id)) {
+ FlatLocPoint (ajp, ffstring, sip, bsp->id, 0, NULL);
+ if (bsp->length > 0) {
+ FFAddOneString(ffstring, "..", FALSE, FALSE, TILDE_IGNORE);
+ FlatLocPoint (ajp, ffstring, NULL, bsp->id, bsp->length - 1, NULL);
+ }
+ }
+ break;
+ case SEQLOC_INT :
+ sintp = (SeqIntPtr) location->data.ptrvalue;
+ if (sintp == NULL) return;
+ sip = sintp->id;
+ if (sip == NULL) return;
+ if (is_real_id (sip, bsp->id)) {
+ minus_strand = (Boolean) (sintp->strand == Seq_strand_minus);
+ if (minus_strand) {
+ FFAddOneString(ffstring, "complement(", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FlatLocPoint (ajp, ffstring, sip, bsp->id, sintp->from, sintp->if_from);
+ if (sintp->to > 0 &&
+ (sintp->to != sintp->from ||
+ sintp->if_from != NULL ||
+ sintp->if_to != NULL)) {
+ FFAddOneString(ffstring, "..", FALSE, FALSE, TILDE_IGNORE);
+ FlatLocPoint (ajp, ffstring, NULL, bsp->id, sintp->to, sintp->if_to);
+ }
+ if (minus_strand) {
+ FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ break;
+ case SEQLOC_PNT :
+ spp = (SeqPntPtr) location->data.ptrvalue;
+ if (spp == NULL) return;
+ sip = spp->id;
+ if (sip == NULL) return;
+ if (is_real_id (sip, bsp->id)) {
+ minus_strand = (Boolean) (spp->strand == Seq_strand_minus);
+ if (minus_strand) {
+ FFAddOneString(ffstring, "complement(", FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (spp->fuzz != NULL) {
+ FlatLocCaret (ajp, ffstring, sip, bsp->id, spp->point, spp->fuzz);
+ } else {
+ FlatLocPoint (ajp, ffstring, sip, bsp->id, spp->point, NULL);
+ }
+ if (minus_strand) {
+ FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ break;
+ case SEQLOC_BOND :
+ sbp = (SeqBondPtr) location->data.ptrvalue;
+ if (sbp == NULL) return;
+ spp = sbp->a;
+ if (spp == NULL) return;
+ sip = spp->id;
+ if (sip == NULL) return;
+ FFAddOneString(ffstring, "bond(", FALSE, FALSE, TILDE_IGNORE);
+ FlatLocPoint (ajp, ffstring, sip, bsp->id, spp->point, spp->fuzz);
+ spp = sbp->b;
+ if (spp != NULL) {
+ FFAddOneString(ffstring, ",", FALSE, FALSE, TILDE_IGNORE);
+ FlatLocPoint (ajp, ffstring, NULL, bsp->id, spp->point, spp->fuzz);
+ }
+ FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
+ break;
+ default :
+ /* unexpected internal complex type or unimplemented SEQLOC_FEAT */
+ return;
+ }
+}
+
+
+
+static void FF_FlatPackedPoint (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ PackSeqPntPtr pspp,
+ BioseqPtr bsp
+)
+
+{
+ Uint1 dex;
+
+ if (ffstring == NULL || pspp == NULL || bsp == NULL) return;
+
+ for (dex = 0; dex < pspp->used; dex++) {
+ FlatLocPoint (ajp, ffstring, pspp->id, bsp->id, pspp->pnts [dex], pspp->fuzz);
+ }
+}
+
+
+static void FF_DoFlatLoc (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ BioseqPtr bsp,
+ SeqLocPtr location,
+ Boolean ok_to_complement
+);
+
+static void FF_GroupFlatLoc (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ BioseqPtr bsp,
+ SeqLocPtr location,
+ CharPtr prefix,
+ Boolean is_flat_order
+)
+
+{
+ Boolean found_non_virt = FALSE;
+ SeqIdPtr hold_next;
+ Int2 parens = 1;
+ PackSeqPntPtr pspp;
+ SeqLocPtr slp;
+ Boolean special_mode = FALSE; /* join in order */
+
+ if (ffstring == NULL || bsp == NULL || location == NULL) return;
+
+ /* prefix will have the first parenthesis */
+
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+
+ for (slp = (SeqLocPtr) location->data.ptrvalue; slp != NULL; slp = slp->next) {
+
+ if (slp->choice == SEQLOC_NULL || FlatVirtLoc (bsp, slp)) {
+ if (slp != location && slp->next != NULL) {
+ if (special_mode) {
+ special_mode = FALSE;
+ FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
+ parens--;
+ }
+ }
+ continue;
+ }
+
+ if (found_non_virt && slp->choice != SEQLOC_EMPTY && slp->choice != SEQLOC_NULL) {
+ FFAddOneString(ffstring, ",", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ switch (slp->choice) {
+ case SEQLOC_WHOLE :
+ case SEQLOC_PNT :
+ case SEQLOC_BOND :
+ case SEQLOC_FEAT :
+ found_non_virt = TRUE;
+ if (FlatVirtLoc (bsp, slp)) {
+ if (slp != location && slp->next != NULL) {
+ if (special_mode) {
+ special_mode = FALSE;
+ FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
+ parens--;
+ }
+ }
+ } else {
+ FlatLocElement (ajp, ffstring, bsp, slp);
+ }
+ break;
+ case SEQLOC_INT :
+ found_non_virt = TRUE;
+ if (is_flat_order && (! FF_FlatNullAhead (bsp, slp))) {
+ special_mode = TRUE;
+ FFAddOneString(ffstring, "join(", FALSE, FALSE, TILDE_IGNORE);
+ parens++;
+ }
+ FlatLocElement (ajp, ffstring, bsp, slp);
+ break;
+ case SEQLOC_PACKED_PNT :
+ found_non_virt = TRUE;
+ pspp = (PackSeqPntPtr) slp->data.ptrvalue;
+ if (pspp != NULL) {
+ FF_FlatPackedPoint (ajp, ffstring, pspp, bsp);
+ }
+ break;
+ case SEQLOC_PACKED_INT :
+ case SEQLOC_MIX :
+ case SEQLOC_EQUIV :
+ found_non_virt = TRUE;
+ hold_next = slp->next;
+ slp->next = NULL;
+ FF_DoFlatLoc (ajp, ffstring, bsp, slp, FALSE);
+ slp->next = hold_next;
+ break;
+ default :
+ break;
+ }
+
+ }
+
+ while (parens > 0) {
+ FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
+ parens--;
+ }
+}
+
+
+
+
+static void FF_DoFlatLoc (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ BioseqPtr bsp,
+ SeqLocPtr location,
+ Boolean ok_to_complement
+)
+
+{
+ Boolean found_null;
+ SeqLocPtr next_loc;
+ PackSeqPntPtr pspp;
+ SeqLocPtr slp;
+
+ if (ffstring == NULL || bsp == NULL || location == NULL) return;
+
+ /* deal with complement of entire location */
+
+ if (ok_to_complement && SeqLocStrand (location) == Seq_strand_minus) {
+ slp = AsnIoMemCopy ((Pointer) location,
+ (AsnReadFunc) SeqLocAsnRead,
+ (AsnWriteFunc) SeqLocAsnWrite);
+ if (slp != NULL) {
+ SeqLocRevCmp (slp);
+ FFAddOneString(ffstring, "complement(", FALSE, FALSE, TILDE_IGNORE);
+ FF_DoFlatLoc (ajp, ffstring, bsp, slp, FALSE);
+ FFAddOneString(ffstring, ")", FALSE, FALSE, TILDE_IGNORE);
+ }
+ SeqLocFree (slp);
+ return;
+ }
+
+ /* handle each location component */
+
+ for (slp = location; slp != NULL; slp = slp->next) {
+
+ if (slp->choice == SEQLOC_NULL || FlatVirtLoc (bsp, slp)) continue;
+
+ /* print comma between components */
+
+ if (slp != location) {
+ FFAddOneString(ffstring, ",", FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ switch (slp->choice) {
+ case SEQLOC_MIX :
+ case SEQLOC_PACKED_INT :
+ found_null = FALSE;
+ for (next_loc = (SeqLocPtr) slp->data.ptrvalue;
+ next_loc != NULL;
+ next_loc = next_loc->next) {
+ if (next_loc->choice == SEQLOC_NULL ||
+ FlatVirtLoc (bsp, next_loc) /* ||
+ LocationHasNullsBetween (slp) */ )
+ found_null = TRUE;
+ }
+ if (found_null) {
+ FF_GroupFlatLoc (ajp, ffstring, bsp, slp, "order(", TRUE);
+ } else {
+ FF_GroupFlatLoc (ajp, ffstring, bsp, slp, "join(", FALSE);
+ }
+ break;
+ case SEQLOC_EQUIV :
+ FF_GroupFlatLoc (ajp, ffstring, bsp, slp, "one-of(", FALSE);
+ break;
+ case SEQLOC_PACKED_PNT :
+ pspp = (PackSeqPntPtr) slp->data.ptrvalue;
+ if (pspp != NULL) {
+ FF_FlatPackedPoint (ajp, ffstring, pspp, bsp);
+ }
+ break;
+ default :
+ FlatLocElement (ajp, ffstring, bsp, slp);
+ break;
+ }
+
+ }
+}
+
+
+
+
+NLM_EXTERN CharPtr FFFlatLoc (
+ IntAsn2gbJobPtr ajp,
+ BioseqPtr bsp,
+ SeqLocPtr location,
+ Boolean masterStyle
+)
+
+{
+ Boolean hasNulls;
+ IntFuzzPtr fuzz = NULL;
+ SeqLocPtr loc;
+ Boolean noLeft;
+ Boolean noRight;
+ Uint1 num = 1;
+ SeqPntPtr spp;
+ CharPtr str;
+ SeqLocPtr tmp;
+ StringItemPtr ffstring = NULL;
+
+ if (bsp == NULL || location == NULL) return NULL;
+
+ ffstring = FFGetString(ajp);
+
+ if (! order_initialized) {
+ order [SEQID_GENBANK] = num++;
+ order [SEQID_EMBL] = num++;
+ order [SEQID_DDBJ] = num++;
+ order [SEQID_OTHER] = num++;
+ order [SEQID_TPG] = num++;
+ order [SEQID_TPE] = num++;
+ order [SEQID_TPD] = num++;
+ order [SEQID_GIBBSQ] = num++;
+ order [SEQID_GIBBMT] = num++;
+ order [SEQID_PRF] = num++;
+ order [SEQID_PDB] = num++;
+ order [SEQID_PIR] = num++;
+ order [SEQID_SWISSPROT] = num++;
+ order [SEQID_PATENT] = num++;
+ order [SEQID_GI] = num++;;
+ order [SEQID_GENERAL] = num++;
+ order [SEQID_LOCAL] = num++;
+ order [SEQID_GIIM] = num++;
+ order_initialized = TRUE;
+ }
+
+ if (masterStyle) {
+
+ /* map location from parts to segmented bioseq */
+
+ if (location->choice == SEQLOC_PNT) {
+ spp = (SeqPntPtr) location->data.ptrvalue;
+ if (spp != NULL) {
+ fuzz = spp->fuzz;
+ }
+ }
+
+ CheckSeqLocForPartial (location, &noLeft, &noRight);
+ hasNulls = LocationHasNullsBetween (location);
+ loc = SeqLocMerge (bsp, location, NULL, FALSE, TRUE, hasNulls);
+ if (loc == NULL) {
+ tmp = TrimLocInSegment (bsp, location, &noLeft, &noRight);
+ loc = SeqLocMerge (bsp, tmp, NULL, FALSE, TRUE, hasNulls);
+ SeqLocFree (tmp);
+ }
+ if (loc == NULL) {
+ return StringSave ("?");
+ }
+ FreeAllFuzz (loc);
+ SetSeqLocPartial (loc, noLeft, noRight);
+
+ if (loc->choice == SEQLOC_PNT && fuzz != NULL) {
+ spp = (SeqPntPtr) loc->data.ptrvalue;
+ if (spp != NULL && spp->fuzz == NULL) {
+ spp->fuzz = AsnIoMemCopy ((Pointer) fuzz,
+ (AsnReadFunc) IntFuzzAsnRead,
+ (AsnWriteFunc) IntFuzzAsnWrite);
+ }
+ }
+
+ FF_DoFlatLoc (ajp, ffstring, bsp, loc, TRUE);
+
+ SeqLocFree (loc);
+
+ } else {
+ FF_DoFlatLoc (ajp, ffstring, bsp, location, TRUE);
+ }
+
+ str = FFToCharPtr(ffstring);
+ FFRecycleString(ajp, ffstring);
+ return str;
+}
+
+
+
+
+static void PromoteSeqId (SeqIdPtr sip, Pointer userdata)
+
+{
+ SeqIdPtr bestid, newid, oldid;
+
+ bestid = (SeqIdPtr) userdata;
+
+ newid = SeqIdDup (bestid);
+ if (newid == NULL) return;
+
+ oldid = ValNodeNew (NULL);
+ if (oldid == NULL) return;
+
+ MemCopy (oldid, sip, sizeof (ValNode));
+ oldid->next = NULL;
+
+ sip->choice = newid->choice;
+ sip->data.ptrvalue = newid->data.ptrvalue;
+
+ SeqIdFree (oldid);
+ ValNodeFree (newid);
+
+ SeqIdStripLocus (sip);
+}
+
+NLM_EXTERN SeqLocPtr SeqLocReMapEx (
+ SeqIdPtr newid,
+ SeqLocPtr seq_loc,
+ SeqLocPtr location,
+ Int4 offset,
+ Boolean rev,
+ Boolean masterStyle
+)
+
+{
+ BioseqPtr bsp;
+ Boolean hasNulls;
+ IntFuzzPtr fuzz = NULL;
+ SeqLocPtr loc;
+ Boolean noLeft;
+ Boolean noRight;
+ SeqEntryPtr scope;
+ SeqIdPtr sip;
+ SeqLocPtr slp = NULL;
+ SeqPntPtr spp;
+ SeqLocPtr tmp;
+
+ if (newid == NULL || seq_loc == NULL || location == NULL) return NULL;
+
+ if (masterStyle) {
+
+ sip = SeqLocId (seq_loc);
+ if (sip == NULL) return NULL;
+ bsp = BioseqFind (sip);
+ if (bsp == NULL) {
+ scope = SeqEntrySetScope (NULL);
+ bsp = BioseqFind (sip);
+ SeqEntrySetScope (scope);
+ }
+ if (bsp == NULL) return NULL;
+ sip = SeqIdFindBest (bsp->id, 0);
+
+ /* map location from parts to segmented bioseq */
+
+ if (location->choice == SEQLOC_PNT) {
+ spp = (SeqPntPtr) location->data.ptrvalue;
+ if (spp != NULL) {
+ fuzz = spp->fuzz;
+ }
+ }
+
+ CheckSeqLocForPartial (location, &noLeft, &noRight);
+ hasNulls = LocationHasNullsBetween (location);
+ loc = SeqLocMerge (bsp, location, NULL, FALSE, TRUE, hasNulls);
+ if (loc == NULL) {
+ tmp = TrimLocInSegment (bsp, location, &noLeft, &noRight);
+ loc = SeqLocMerge (bsp, tmp, NULL, FALSE, TRUE, hasNulls);
+ SeqLocFree (tmp);
+ }
+ if (loc == NULL) {
+ return NULL;
+ }
+ FreeAllFuzz (loc);
+ SetSeqLocPartial (loc, noLeft, noRight);
+
+ if (loc->choice == SEQLOC_PNT && fuzz != NULL) {
+ spp = (SeqPntPtr) loc->data.ptrvalue;
+ if (spp != NULL && spp->fuzz == NULL) {
+ spp->fuzz = AsnIoMemCopy ((Pointer) fuzz,
+ (AsnReadFunc) IntFuzzAsnRead,
+ (AsnWriteFunc) IntFuzzAsnWrite);
+ }
+ }
+
+ scope = SeqEntrySetScope (NULL);
+ slp = SeqLocReMap (newid, seq_loc, loc, offset, rev);
+ SeqEntrySetScope (scope);
+
+ SeqLocFree (loc);
+
+ VisitSeqIdsInSeqLoc (slp, (Pointer) sip, PromoteSeqId);
+ } else {
+
+ scope = SeqEntrySetScope (NULL);
+ slp = SeqLocReMap (newid, seq_loc, location, offset, rev);
+ SeqEntrySetScope (scope);
+ }
+
+ return slp;
+}
+
+
+/******************************************************************************/
+/* End FFFlatLoc functions. */
+/******************************************************************************/
+
+
+
+static void SubSourceToQualArray (
+ SubSourcePtr ssp,
+ QualValPtr qvp
+)
+
+{
+ SourceType idx;
+ Uint1 subtype;
+
+ if (ssp == NULL || qvp == NULL) return;
+
+ while (ssp != NULL) {
+ subtype = ssp->subtype;
+ if (subtype == 255) {
+ subtype = 29;
+ }
+ if (subtype < 30) {
+ idx = subSourceToSourceIdx [subtype];
+ if (idx > 0 && idx < ASN2GNBK_TOTAL_SOURCE) {
+ if (qvp [idx].ssp == NULL) {
+ qvp [idx].ssp = ssp;
+ }
+ }
+ }
+ ssp = ssp->next;
+ }
+}
+
+NLM_EXTERN SourceType orgModToSourceIdx [38] = {
+ SCQUAL_zero_orgmod,
+ SCQUAL_one_orgmod,
+ SCQUAL_strain,
+ SCQUAL_sub_strain,
+ SCQUAL_type,
+ SCQUAL_sub_type,
+ SCQUAL_variety,
+ SCQUAL_serotype,
+ SCQUAL_serogroup,
+ SCQUAL_serovar,
+ SCQUAL_cultivar,
+ SCQUAL_pathovar,
+ SCQUAL_chemovar,
+ SCQUAL_biovar,
+ SCQUAL_biotype,
+ SCQUAL_group,
+ SCQUAL_sub_group,
+ SCQUAL_isolate,
+ SCQUAL_common,
+ SCQUAL_acronym,
+ SCQUAL_dosage,
+ SCQUAL_spec_or_nat_host,
+ SCQUAL_sub_species,
+ SCQUAL_specimen_voucher,
+ SCQUAL_authority,
+ SCQUAL_forma,
+ SCQUAL_forma_specialis,
+ SCQUAL_ecotype,
+ SCQUAL_synonym,
+ SCQUAL_anamorph,
+ SCQUAL_teleomorph,
+ SCQUAL_breed,
+ SCQUAL_gb_acronym,
+ SCQUAL_gb_anamorph,
+ SCQUAL_gb_synonym,
+ SCQUAL_old_lineage,
+ SCQUAL_old_name,
+ SCQUAL_orgmod_note
+};
+
+static void OrgModToQualArray (
+ OrgModPtr omp,
+ QualValPtr qvp
+)
+
+{
+ SourceType idx;
+ Uint1 subtype;
+
+ if (omp == NULL || qvp == NULL) return;
+
+ while (omp != NULL) {
+ subtype = omp->subtype;
+ if (subtype == 253) {
+ subtype = 35;
+ } else if (subtype == 254) {
+ subtype = 36;
+ } else if (subtype == 255) {
+ subtype = 37;
+ }
+ if (subtype < 38) {
+ idx = orgModToSourceIdx [subtype];
+ if (idx > 0 && idx < ASN2GNBK_TOTAL_SOURCE) {
+ if (qvp [idx].omp == NULL) {
+ qvp [idx].omp = omp;
+ }
+ }
+ }
+ omp = omp->next;
+ }
+}
+
+static CharPtr organelleQual [] = {
+ NULL,
+ NULL,
+ "/organelle=\"plastid:chloroplast\"",
+ "/organelle=\"plastid:chromoplast\"",
+ "/organelle=\"mitochondrion:kinetoplast\"",
+ "/organelle=\"mitochondrion\"",
+ "/organelle=\"plastid\"",
+ "/macronuclear",
+ NULL,
+ "/plasmid=\"\"",
+ "/transposon=\"\"",
+ "/insertion_seq=\"\"",
+ "/organelle=\"plastid:cyanelle\"",
+ "/proviral",
+ "/virion",
+ "/organelle=\"nucleomorph\"",
+ "/organelle=\"plastid:apicoplast\"",
+ "/organelle=\"plastid:leucoplast\"",
+ "/organelle=\"plastid:proplastid\"",
+ NULL
+};
+
+NLM_EXTERN Boolean StringIsJustQuotes (
+ CharPtr str
+)
+
+{
+ Nlm_Uchar ch; /* to use 8bit characters in multibyte languages */
+
+ if (str != NULL) {
+ ch = *str;
+ while (ch != '\0') {
+ if (ch > ' ' && ch != '"' && ch != '\'') {
+ return FALSE;
+ }
+ str++;
+ ch = *str;
+ }
+ }
+ return TRUE;
+}
+
+static CharPtr RemoveAllSpaces (
+ CharPtr str
+)
+
+{
+ Char ch;
+ CharPtr dst;
+ CharPtr ptr;
+
+ if (str == NULL || str [0] == '\0') return NULL;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch != ' ') {
+ *dst = ch;
+ dst++;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = '\0';
+
+ return str;
+}
+
+NLM_EXTERN void AddFeatureToGbseq (
+ GBSeqPtr gbseq,
+ GBFeaturePtr gbfeat,
+ CharPtr str,
+ SeqFeatPtr sfp
+)
+
+{
+ Char ch;
+ CharPtr copy;
+ GBQualifierPtr gbqual;
+ GBQualifierPtr last = NULL;
+ CharPtr ptr;
+ CharPtr qual;
+ CharPtr val;
+
+ if (gbseq == NULL || gbfeat == NULL || StringHasNoText (str)) return;
+
+ copy = StringSave (str);
+
+ /* link in reverse order, to be reversed in slash block */
+
+ gbfeat->next = gbseq->feature_table;
+ gbseq->feature_table = gbfeat;
+
+ /* now parse qualifiers */
+
+ ptr = StringStr (copy, " /");
+ while (ptr != NULL) {
+ qual = ptr + 22;
+ val = qual;
+ ch = *val;
+ while (ch != '=' && ch != '\n' && ch != '\0') {
+ val++;
+ ch = *val;
+ }
+ /*
+ val = StringChr (qual, '=');
+ if (val == NULL) {
+ val = StringChr (qual, '\n');
+ }
+ */
+ if (ch != '\0' /* val != NULL */) {
+ *val = '\0';
+ val++;
+ if (ch == '=') {
+ if (*val == '"') {
+ val++;
+ }
+ ptr = StringStr (val, "\n /");
+ if (ptr != NULL) {
+ *ptr = '\0';
+ ptr++;
+ }
+ } else {
+ ptr = StringStr (val, " /");
+ val = NULL;
+ }
+ gbqual = GBQualifierNew ();
+ if (gbqual != NULL) {
+ gbqual->name = StringSave (qual);
+ if (! StringHasNoText (val)) {
+ gbqual->value = StringSave (val);
+ CleanQualValue (gbqual->value);
+ Asn2gnbkCompressSpaces (gbqual->value);
+ if (sfp != NULL) {
+ if (sfp->data.choice == SEQFEAT_CDREGION &&
+ StringICmp (qual, "translation") == 0) {
+ RemoveAllSpaces (gbqual->value);
+ } else if (sfp->data.choice == SEQFEAT_RNA &&
+ StringICmp (qual, "transcription") == 0) {
+ RemoveAllSpaces (gbqual->value);
+ } else if (sfp->data.choice == SEQFEAT_PROT &&
+ StringICmp (qual, "peptide") == 0) {
+ RemoveAllSpaces (gbqual->value);
+ }
+ }
+ }
+ }
+ } else {
+ gbqual = GBQualifierNew ();
+ if (gbqual != NULL) {
+ gbqual->name = StringSave (qual);
+ }
+ }
+ if (gbfeat->quals == NULL) {
+ gbfeat->quals = gbqual;
+ } else if (last != NULL) {
+ last->next = gbqual;
+ }
+ last = gbqual;
+ }
+
+ MemFree (copy);
+}
+
+NLM_EXTERN CharPtr GetMolTypeQual (
+ BioseqPtr bsp
+)
+
+{
+ SeqMgrDescContext dcontext;
+ MolInfoPtr mip;
+ SeqDescrPtr sdp;
+
+ if (bsp == NULL) return NULL;
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp == NULL) return NULL;
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip == NULL) return NULL;
+
+ switch (mip->biomol) {
+ case 0 :
+ switch (bsp->mol) {
+ case Seq_mol_dna :
+ return "unassigned DNA";
+ case Seq_mol_rna :
+ return "unassigned RNA";
+ case Seq_mol_na :
+ break;
+ default :
+ break;
+ }
+ break;
+ case MOLECULE_TYPE_GENOMIC :
+ switch (bsp->mol) {
+ case Seq_mol_dna :
+ return "genomic DNA";
+ case Seq_mol_rna :
+ return "genomic RNA";
+ case Seq_mol_na :
+ break;
+ default :
+ break;
+ }
+ break;
+ case MOLECULE_TYPE_PRE_MRNA :
+ return "pre-RNA";
+ case MOLECULE_TYPE_MRNA :
+ return "mRNA";
+ case MOLECULE_TYPE_RRNA :
+ return "rRNA";
+ case MOLECULE_TYPE_TRNA :
+ return "tRNA";
+ case MOLECULE_TYPE_SNRNA :
+ return "snRNA";
+ case MOLECULE_TYPE_SCRNA :
+ return "scRNA";
+ case MOLECULE_TYPE_PEPTIDE :
+ break;
+ case MOLECULE_TYPE_OTHER_GENETIC_MATERIAL :
+ switch (bsp->mol) {
+ case Seq_mol_dna :
+ return "other DNA";
+ case Seq_mol_rna :
+ return "other RNA";
+ case Seq_mol_na :
+ break;
+ default :
+ break;
+ }
+ break;
+ case MOLECULE_TYPE_GENOMIC_MRNA_MIX :
+ break;
+ case MOLECULE_TYPE_CRNA :
+ return "other RNA";
+ break;
+ case MOLECULE_TYPE_SNORNA :
+ return "snoRNA";
+ break;
+ case MOLECULE_TYPE_TRANSCRIBED_RNA :
+ return "other RNA";
+ break;
+ case 255 :
+ switch (bsp->mol) {
+ case Seq_mol_dna :
+ return "other DNA";
+ case Seq_mol_rna :
+ return "other RNA";
+ case Seq_mol_na :
+ break;
+ default :
+ break;
+ }
+ break;
+ default :
+ break;
+ }
+
+ return NULL;
+}
+
+NLM_EXTERN CharPtr FormatSourceFeatBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ Boolean add_period;
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BioSourcePtr biop = NULL;
+ BioseqPtr bsp;
+ Char buf [80];
+ CharPtr common = NULL;
+ DbtagPtr dbt;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ GBFeaturePtr gbfeat = NULL;
+ GBSeqPtr gbseq;
+ Int2 i;
+ Uint1 idx;
+ IntSrcBlockPtr isp;
+ Boolean is_desc = TRUE;
+ Int2 j;
+ Uint1 jdx;
+ Uint1 lastomptype;
+ Uint1 lastssptype;
+ SeqLocPtr location = NULL;
+ CharPtr notestr;
+ SourceType PNTR notetbl = NULL;
+ Boolean okay;
+ ObjectIdPtr oip;
+ OrgModPtr omp;
+ OrgNamePtr onp = NULL;
+ OrgRefPtr orp = NULL;
+ CharPtr prefix;
+ SourceType PNTR qualtbl = NULL;
+ QualValPtr qvp;
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp = NULL;
+ SubSourcePtr ssp;
+ CharPtr str;
+ CharPtr taxname = NULL;
+ ValNodePtr vnp;
+ StringItemPtr ffstring, unique;
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+ bsp = asp->bsp;
+ if (bsp == NULL) return NULL;
+ qvp = afp->qvp;
+ if (qvp == NULL) return NULL;
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (! StringHasNoText (bbp->string)) return StringSave (bbp->string);
+
+ isp = (IntSrcBlockPtr) bbp;
+
+ /* could be descriptor or feature */
+
+ if (bbp->itemtype == OBJ_SEQDESC) {
+ sdp = SeqMgrGetDesiredDescriptor (bbp->entityID, NULL, bbp->itemID, 0, NULL, &dcontext);
+ if (sdp != NULL && dcontext.seqdesctype == Seq_descr_source) {
+ biop = (BioSourcePtr) sdp->data.ptrvalue;
+ }
+ } else if (bbp->itemtype == OBJ_SEQFEAT) {
+ sfp = SeqMgrGetDesiredFeature (bbp->entityID, NULL, bbp->itemID, 0, NULL, &fcontext);
+ if (sfp != NULL && fcontext.seqfeattype == SEQFEAT_BIOSRC) {
+ biop = (BioSourcePtr) sfp->data.value.ptrvalue;
+ }
+ is_desc = FALSE;
+ }
+
+ if (biop == NULL) return NULL;
+
+ unique = FFGetString(ajp);
+ if ( unique == NULL ) return NULL;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return NULL;
+
+ FFStartPrint (ffstring, afp->format, 5, 21, NULL, 0, 5, 21, "FT", FALSE);
+ FFAddOneString (ffstring, "source", FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 21 - 5 - StringLen("source"), FALSE);
+
+ if (gbseq != NULL) {
+ gbfeat = GBFeatureNew ();
+ if (gbfeat != NULL) {
+ gbfeat->key = StringSave ("source");
+ }
+ }
+
+ location = isp->loc;
+
+ str = FFFlatLoc (ajp, bsp, location, ajp->masterStyle);
+ if ( GetWWW(ajp) ) {
+ FF_www_featloc (ffstring, str);
+ } else {
+ FFAddOneString (ffstring, str, FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFAddOneChar(ffstring, '\n', FALSE);
+
+ if (gbseq != NULL) {
+ if (gbfeat != NULL) {
+ if (! StringHasNoText (str)) {
+ gbfeat->location = StringSave (str);
+ } else {
+ gbfeat->location = StringSave ("");
+ }
+ }
+ }
+
+ MemFree (str);
+
+ orp = biop->org;
+ if (orp != NULL) {
+ taxname = orp->taxname;
+ /* common = orp->common; */
+ }
+ if (StringHasNoText (taxname)) {
+ if (ajp->flags.needOrganismQual) {
+ taxname = "unknown";
+ common = orp->common;
+#ifdef ASN2GNBK_PRINT_UNKNOWN_ORG
+ } else {
+ taxname = "unknown";
+ common = orp->common;
+#endif
+ }
+ }
+
+ /* populate qualifier table from biosource fields */
+
+ qvp [SCQUAL_organism].str = taxname;
+ qvp [SCQUAL_common_name].str = common;
+
+ if (biop->is_focus) {
+ qvp [SCQUAL_focus].ble = TRUE;
+ }
+
+ str = GetMolTypeQual (bsp);
+ if (str == NULL) {
+ switch (bsp->mol) {
+ case Seq_mol_dna :
+ str = "unassigned DNA";
+ break;
+ case Seq_mol_rna :
+ str = "unassigned RNA";
+ break;
+ case Seq_mol_aa :
+ break;
+ default :
+ str = "unassigned DNA";
+ break;
+ }
+ }
+ qvp [SCQUAL_mol_type].str = str;
+
+ SubSourceToQualArray (biop->subtype, qvp);
+
+ if (orp != NULL) {
+ onp = orp->orgname;
+ if (onp != NULL) {
+ OrgModToQualArray (onp->mod, qvp);
+ }
+
+ if (! is_desc) {
+ qvp [SCQUAL_unstructured].vnp = orp->mod;
+ }
+ qvp [SCQUAL_db_xref].vnp = orp->db;
+ }
+
+ if (sfp != NULL) {
+ qvp [SCQUAL_org_xref].vnp = sfp->dbxref;
+ }
+
+ /* organelle currently prints /mitochondrion, /virion, etc. */
+
+ qvp [SCQUAL_organelle].num = biop->genome;
+
+ /* some qualifiers are flags in genome and names in subsource, print once with name */
+
+ if (qvp [SCQUAL_ins_seq_name].ssp != NULL &&
+ qvp [SCQUAL_organelle].num == GENOME_insertion_seq) {
+ qvp [SCQUAL_organelle].num = 0;
+ }
+ if (qvp [SCQUAL_plasmid_name].ssp != NULL &&
+ qvp [SCQUAL_organelle].num == GENOME_plasmid) {
+ qvp [SCQUAL_organelle].num = 0;
+ }
+ /* AF095904.1
+ if (qvp [SCQUAL_plastid_name].ssp != NULL &&
+ qvp [SCQUAL_organelle].num == GENOME_plastid) {
+ qvp [SCQUAL_organelle].num = 0;
+ }
+ */
+ if (qvp [SCQUAL_transposon_name].ssp != NULL &&
+ qvp [SCQUAL_organelle].num == GENOME_transposon) {
+ qvp [SCQUAL_organelle].num = 0;
+ }
+
+ if (sfp != NULL) {
+ qvp [SCQUAL_seqfeat_note].str = sfp->comment;
+ }
+
+ /* now print qualifiers from table */
+
+ qualtbl = source_qual_order;
+ if (is_desc) {
+ notetbl = source_desc_note_order;
+ } else {
+ notetbl = source_feat_note_order;
+ }
+
+ for (i = 0, idx = qualtbl [i]; idx != 0; i++, idx = qualtbl [i]) {
+
+ lastomptype = 0;
+ lastssptype = 0;
+ switch (asn2gnbk_source_quals [idx].qualclass) {
+
+ case Qual_class_ignore :
+ break;
+
+ case Qual_class_string :
+ if (! StringHasNoText (qvp [idx].str)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=",
+ FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", qvp [idx].str, "\"",
+ FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+ break;
+
+ case Qual_class_boolean :
+ if (qvp [idx].ble) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "\n",
+ FALSE, TRUE, TILDE_IGNORE);
+ }
+ break;
+
+ case Qual_class_organelle :
+ j = (Int2) qvp [idx].num;
+ if (organelleQual [j] != NULL) {
+ FFAddTextToString(ffstring, NULL, organelleQual[j], "\n",
+ FALSE, FALSE, TILDE_IGNORE);
+ }
+ break;
+
+ case Qual_class_orgmod :
+ omp = qvp [idx].omp;
+ if (lastomptype == 0 && omp != NULL) {
+ lastomptype = omp->subtype;
+ }
+ while (omp != NULL && omp->subtype == lastomptype) {
+ if (StringIsJustQuotes (omp->subname)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=\"\"\n",
+ FALSE, TRUE, TILDE_IGNORE);
+ } else if (! StringHasNoText (omp->subname)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", omp->subname, "\"\n",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ }
+ omp = omp->next;
+ }
+ break;
+
+ case Qual_class_subsource :
+ ssp = qvp [idx].ssp;
+ if (lastssptype == 0 && ssp != NULL) {
+ lastssptype = ssp->subtype;
+ }
+ while (ssp != NULL && ssp->subtype == lastssptype) {
+ if (ssp->subtype == SUBSRC_germline ||
+ ssp->subtype == SUBSRC_rearranged ||
+ ssp->subtype == SUBSRC_transgenic ||
+ ssp->subtype == SUBSRC_environmental_sample) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "\n",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ } else if (StringIsJustQuotes (ssp->name)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=\"\"\n",
+ FALSE, TRUE, TILDE_IGNORE);
+ } else if (! StringHasNoText (ssp->name)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [idx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", ssp->name, "\"\n",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ }
+ ssp = ssp->next;
+ }
+ break;
+
+ case Qual_class_pubset :
+ break;
+
+ case Qual_class_quote :
+ break;
+
+ case Qual_class_noquote :
+ break;
+
+ case Qual_class_label :
+ break;
+
+ case Qual_class_db_xref :
+ for (vnp = qvp [idx].vnp; vnp != NULL; vnp = vnp->next) {
+ buf [0] = '\0';
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt != NULL && (! StringHasNoText (dbt->db))) {
+ oip = dbt->tag;
+ if (oip != NULL) {
+
+ okay = TRUE;
+ if (ajp->flags.dropBadDbxref) {
+ /* if RELEASE_MODE, drop unknown dbtag */
+ okay = FALSE;
+ for (j = 0; legalDbXrefs [j] != NULL; j++) {
+ if (StringCmp (dbt->db, legalDbXrefs [j]) == 0) {
+ okay = TRUE;
+ }
+ }
+ }
+
+ if (okay) {
+ if (! StringHasNoText (oip->str)) {
+ if (StringLen (dbt->db) + StringLen (oip->str) < 80) {
+ sprintf (buf, "%s", oip->str);
+ }
+ } else {
+ sprintf (buf, "%ld", (long) oip->id);
+ }
+ }
+ }
+ }
+ if (! StringHasNoText (buf)) {
+ FFAddOneString(ffstring, "/db_xref=\"", FALSE, FALSE, TILDE_IGNORE);
+ FF_www_db_xref(ajp, ffstring, dbt->db, buf);
+ FFAddOneString(ffstring, "\"\n", FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ break;
+
+ case Qual_class_illegal :
+ break;
+
+ case Qual_class_note :
+ if (! ajp->flags.srcQualsToNote) {
+
+ /* in sequin_mode and dump_mode, all orgmods and subsources show up as separate /qualifiers */
+
+ for (j = 0, jdx = notetbl [j]; jdx != 0; j++, jdx = notetbl [j]) {
+
+ lastomptype = 0;
+ lastssptype = 0;
+ switch (asn2gnbk_source_quals [jdx].qualclass) {
+
+ case Qual_class_orgmod :
+ if (jdx == SCQUAL_orgmod_note) break;
+ omp = qvp [jdx].omp;
+ if (lastomptype == 0 && omp != NULL) {
+ lastomptype = omp->subtype;
+ }
+ while (omp != NULL && omp->subtype == lastomptype) {
+ if (StringIsJustQuotes (omp->subname)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [jdx].name, "=\"\"\n",
+ FALSE, TRUE, TILDE_IGNORE);
+ } else if (! StringHasNoText (omp->subname)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [jdx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", omp->subname, "\"\n",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ }
+ omp = omp->next;
+ }
+ break;
+
+ case Qual_class_subsource :
+ if (jdx == SCQUAL_subsource_note) break;
+ ssp = qvp [jdx].ssp;
+ if (lastssptype == 0 && ssp != NULL) {
+ lastssptype = ssp->subtype;
+ }
+ while (ssp != NULL && ssp->subtype == lastssptype) {
+ if (StringIsJustQuotes (ssp->name)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [jdx].name, "=\"\"\n",
+ FALSE, TRUE, TILDE_IGNORE);
+
+ } else if (! StringHasNoText (ssp->name)) {
+ FFAddTextToString(ffstring, "/", asn2gnbk_source_quals [jdx].name, "=",
+ FALSE, TRUE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "\"", ssp->name, "\"\n",
+ FALSE, TRUE, TILDE_TO_SPACES);
+ }
+ ssp = ssp->next;
+ }
+ break;
+
+ default :
+ break;
+ }
+ }
+ }
+
+ notestr = NULL;
+ prefix = "";
+ add_period = FALSE;
+
+ if (biop->genome == 8) {
+ FFAddTextToString(unique, "", "extrachromosomal", NULL, FALSE, FALSE, TILDE_IGNORE);
+ prefix = "\n";
+ }
+
+ for (j = 0, jdx = notetbl [j]; jdx != 0; j++, jdx = notetbl [j]) {
+
+ lastomptype = 0;
+ lastssptype = 0;
+ switch (asn2gnbk_source_quals [jdx].qualclass) {
+
+ case Qual_class_string :
+ if (! StringHasNoText (qvp [jdx].str)) {
+ FFAddString_NoRedund (unique, prefix, qvp [jdx].str, NULL);
+ add_period = FALSE;
+ prefix = "\n";
+ }
+ break;
+
+ case Qual_class_orgmod :
+ if ((! ajp->flags.srcQualsToNote) && jdx != SCQUAL_orgmod_note) break;
+ omp = qvp [jdx].omp;
+ if (lastomptype == 0 && omp != NULL) {
+ lastomptype = omp->subtype;
+ }
+ while (omp != NULL && omp->subtype == lastomptype) {
+ if (! StringHasNoText (omp->subname)) {
+ if (jdx == SCQUAL_orgmod_note) {
+ sprintf (buf, "%s", prefix);
+ } else {
+ sprintf (buf, "%s%s: ", prefix, asn2gnbk_source_quals [jdx].name);
+ }
+
+ str = StringSave (omp->subname);
+ add_period = s_RemovePeriodFromEnd (str);
+ if (jdx == SCQUAL_orgmod_note) {
+ FFAddString_NoRedund (unique, buf, str, NULL);
+ } else {
+ FFAddTextToString(unique, buf, str, NULL, FALSE, FALSE, TILDE_IGNORE);
+ }
+ MemFree (str);
+
+ if (jdx == SCQUAL_orgmod_note) {
+ if (add_period) {
+ prefix = ".\n";
+ } else {
+ prefix = "\n";
+ }
+ } else {
+ prefix = "; ";
+ }
+ }
+ omp = omp->next;
+ }
+ break;
+
+ case Qual_class_subsource :
+ if ((! ajp->flags.srcQualsToNote) && jdx != SCQUAL_subsource_note) break;
+ ssp = qvp [jdx].ssp;
+ if (lastssptype == 0 && ssp != NULL) {
+ lastssptype = ssp->subtype;
+ }
+ while (ssp != NULL && ssp->subtype == lastssptype) {
+ if (! StringHasNoText (ssp->name)) {
+ if (jdx == SCQUAL_subsource_note) {
+ sprintf (buf, "%s", prefix);
+ } else {
+ sprintf (buf, "%s%s: ", prefix, asn2gnbk_source_quals [jdx].name);
+ }
+
+ str = StringSave (ssp->name);
+ add_period = s_RemovePeriodFromEnd (str);
+ if (jdx == SCQUAL_subsource_note) {
+ FFAddString_NoRedund (unique, buf, str, NULL);
+ } else {
+ FFAddTextToString(unique, buf, str, NULL, FALSE, FALSE, TILDE_IGNORE);
+ }
+ MemFree (str);
+
+ if (jdx == SCQUAL_subsource_note) {
+ if (add_period) {
+ prefix = ".\n";
+ } else {
+ prefix = "\n";
+ }
+ } else {
+ prefix = "; ";
+ }
+ }
+ ssp = ssp->next;
+ }
+ break;
+
+ case Qual_class_valnode :
+ for (vnp = qvp [jdx].vnp; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (! StringHasNoText (str)) {
+ FFAddString_NoRedund (unique, prefix, str, NULL);
+ add_period = FALSE;
+ prefix = "; ";
+ }
+ }
+ break;
+
+ default :
+ break;
+ }
+ }
+ if ( !FFEmpty(unique) ) {
+ notestr = FFToCharPtr(unique);
+
+ if (add_period) {
+ s_AddPeriodToEnd (notestr);
+ }
+
+#ifdef ASN2GNBK_STRIP_NOTE_PERIODS
+ if (! IsEllipsis (notestr))
+ s_RemovePeriodFromEnd (notestr);
+#endif
+
+ FFAddOneString (ffstring, "/note=\"", FALSE, FALSE, TILDE_IGNORE);
+ if (is_desc) {
+ /* AB055064.1 says TILDE_IGNORE on descriptors */
+ FFAddOneString (ffstring, notestr, FALSE, TRUE, TILDE_IGNORE);
+ } else {
+ /* ASZ93724.1 says TILDE_EXPAND on features */
+ FFAddOneString (ffstring, notestr, FALSE, TRUE, TILDE_EXPAND);
+ }
+ FFAddOneString (ffstring, "\"", FALSE, FALSE, TILDE_IGNORE);
+
+ MemFree (notestr);
+ }
+ break;
+ default :
+ break;
+ }
+ }
+
+ /* and then deal with the various note types separately (not in order table) */
+
+ str = FFEndPrint(ajp, ffstring, afp->format, 21, 21, 5, 21, "FT");
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (gbseq != NULL) {
+ if (gbfeat != NULL) {
+ AddFeatureToGbseq (gbseq, gbfeat, str, NULL);
+ }
+ }
+
+ FFRecycleString(ajp, unique);
+ FFRecycleString(ajp, ffstring);
+ return str;
+}
+
+
+static Boolean CountBasesByRead (
+ IntAsn2gbJobPtr ajp,
+ BioseqPtr bsp,
+ Int4Ptr base_count
+)
+
+{
+ Byte bases [400];
+ Uint1 code = Seq_code_iupacna;
+ Int2 ctr;
+ Int2 i;
+ Int4 len;
+ Uint1 residue;
+ SeqPortPtr spp = NULL;
+ Int4 total = 0;
+
+ if (ISA_aa (bsp->mol)) {
+ code = Seq_code_ncbieaa;
+ }
+
+ if (ajp->ajp.slp != NULL) {
+ spp = SeqPortNewByLoc (ajp->ajp.slp, code);
+ len = SeqLocLen (ajp->ajp.slp);
+ } else {
+ spp = SeqPortNew (bsp, 0, -1, 0, code);
+ len = bsp->length;
+ }
+ if (spp == NULL) return FALSE;
+ if (bsp->repr == Seq_repr_delta || bsp->repr == Seq_repr_virtual) {
+ SeqPortSet_do_virtual (spp, TRUE);
+ }
+
+ /* use SeqPortRead rather than SeqPortGetResidue for faster performance */
+
+ ctr = SeqPortRead (spp, bases, sizeof (bases));
+ i = 0;
+ residue = (Uint1) bases [i];
+ while (residue != SEQPORT_EOF) {
+ if (IS_residue (residue)) {
+ total++;
+ switch (residue) {
+ case 'A' :
+ (base_count [0])++;
+ break;
+ case 'C' :
+ (base_count [1])++;
+ break;
+ case 'G' :
+ (base_count [2])++;
+ break;
+ case 'T' :
+ (base_count [3])++;
+ break;
+ default :
+ (base_count [4])++;
+ break;
+ }
+ }
+ i++;
+ if (i >= ctr) {
+ i = 0;
+ ctr = SeqPortRead (spp, bases, sizeof (bases));
+ if (ctr < 0) {
+ bases [0] = -ctr;
+ } else if (ctr < 1) {
+ bases [0] = SEQPORT_EOF;
+ }
+ }
+ residue = (Uint1) bases [i];
+ }
+
+ SeqPortFree (spp);
+
+ return TRUE;
+}
+
+static void LIBCALLBACK CountBasesByStream (
+ CharPtr sequence,
+ Pointer userdata
+)
+
+{
+ Int4Ptr base_count;
+ Char ch;
+ CharPtr ptr;
+
+ base_count = (Int4Ptr) userdata;
+
+ ptr = sequence;
+ ch = *ptr;
+ while (ch != '\0') {
+ ch = TO_UPPER (ch);
+ switch (ch) {
+ case 'A' :
+ (base_count [0])++;
+ break;
+ case 'C' :
+ (base_count [1])++;
+ break;
+ case 'G' :
+ (base_count [2])++;
+ break;
+ case 'T' :
+ (base_count [3])++;
+ break;
+ default :
+ (base_count [4])++;
+ break;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+}
+
+NLM_EXTERN CharPtr FormatBasecountBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ Int4 base_count [5];
+ BioseqPtr bsp;
+ Char buf [80];
+ Int2 i;
+ Int4 len;
+ StringItemPtr ffstring;
+ CharPtr str;
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+ bsp = (asp->bsp);
+ if (bsp == NULL) return NULL;
+
+ /* after first formatting, result is cached into bbp->string */
+
+ if (! StringHasNoText (bbp->string)) return StringSave (bbp->string);
+
+ for (i = 0; i < 5; i++) {
+ base_count [i] = 0;
+ }
+
+ if (ajp->ajp.slp != NULL) {
+ len = SeqLocLen (ajp->ajp.slp);
+ if (! CountBasesByRead (ajp, bsp, base_count)) return NULL;
+ } else {
+ len = bsp->length;
+ SeqPortStream (bsp, TRUE, (Pointer) base_count, CountBasesByStream);
+ }
+
+ if (afp->format == GENBANK_FMT || afp->format == GENPEPT_FMT) {
+
+ if (base_count [4] == 0) {
+ sprintf (buf, "%7ld a%7ld c%7ld g%7ld t",
+ (long) base_count [0], (long) base_count [1],
+ (long) base_count [2], (long) base_count [3]);
+ } else {
+ sprintf (buf, "%7ld a%7ld c%7ld g%7ld t%7ld others",
+ (long) base_count [0], (long) base_count [1],
+ (long) base_count [2], (long) base_count [3],
+ (long) base_count [4]);
+ }
+
+ } else if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+
+ sprintf (buf, "Sequence %ld BP; %ld A; %ld C; %ld G; %ld T; %ld other;",
+ (long) len,
+ (long) base_count [0], (long) base_count [1],
+ (long) base_count [2], (long) base_count [3],
+ (long) base_count [4]);
+ }
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return NULL;
+
+ if (afp->format == EMBL_FMT || afp->format == EMBLPEPT_FMT) {
+ FFAddOneString(ffstring, "XX\n", FALSE, FALSE, TILDE_IGNORE);
+ }
+ FFStartPrint (ffstring, afp->format, 0, 0, "BASE COUNT", 12, 5, 5, "SQ", FALSE);
+ FFAddOneString (ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ str = FFEndPrint(ajp, ffstring, afp->format, 12, 0, 5, 5, "SQ");
+ FFRecycleString(ajp, ffstring);
+
+ return str;
+}
+
+static void PrintSeqLine (
+ StringItemPtr ffstring,
+ FmtType format,
+ CharPtr buf,
+ Int4 start,
+ Int4 stop
+)
+
+{
+ size_t len;
+ Char pos [16];
+ Int4 pad;
+
+ len = StringLen (buf);
+ if (len > 0 && buf [len - 1] == ' ') {
+ buf [len - 1] = '\0';
+ }
+
+ if (format == GENBANK_FMT || format == GENPEPT_FMT) {
+
+ sprintf (pos, "%9ld", (long) (start + 1));
+ FFAddOneString(ffstring, pos, FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, ' ', FALSE);
+ FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ } else if (format == EMBL_FMT || format == EMBLPEPT_FMT) {
+
+ sprintf (pos, "%8ld", (long) (stop));
+ FFAddNChar(ffstring, ' ', 5, FALSE);
+ FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_TO_SPACES);
+ pad = 72 - 5 - StringLen(buf);
+ FFAddNChar(ffstring, ' ', pad, FALSE);
+ FFAddOneString(ffstring, pos, FALSE, FALSE, TILDE_TO_SPACES);
+ FFAddOneChar(ffstring, '\n', FALSE);
+ }
+}
+
+static CharPtr CompressNonBases (CharPtr str)
+
+{
+ Char ch;
+ CharPtr dst;
+ CharPtr ptr;
+
+ if (str == NULL || str [0] == '\0') return NULL;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (IS_ALPHA (ch)) {
+ *dst = ch;
+ dst++;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = '\0';
+
+ return str;
+}
+
+/*
+static void CatenateSequenceInGbseq (
+ GBSeqPtr gbseq,
+ CharPtr str
+)
+
+{
+ Char ch;
+ CharPtr tmp;
+
+ if (gbseq == NULL || StringHasNoText (str)) return;
+
+ if (gbseq->sequence == NULL) {
+ gbseq->sequence = StringSave (str);
+ } else {
+ tmp = (CharPtr) MemNew (StringLen (gbseq->sequence) + StringLen (str) + 2);
+ StringCpy (tmp, gbseq->sequence);
+ StringCat (tmp, str);
+ gbseq->sequence = MemFree (gbseq->sequence);
+ gbseq->sequence = tmp;
+ }
+
+ tmp = gbseq->sequence;
+ if (tmp == NULL) return;
+ ch = *tmp;
+ while (ch != '\0') {
+ if (ch == '\n' || ch == '\r' || ch == '\t') {
+ *tmp = ' ';
+ }
+ tmp++;
+ ch = *tmp;
+ }
+ TrimSpacesAroundString (gbseq->sequence);
+ CompressNonBases (gbseq->sequence);
+}
+*/
+
+ static Uint1 fasta_order [NUM_SEQID] = {
+ 33, /* 0 = not set */
+ 20, /* 1 = local Object-id */
+ 15, /* 2 = gibbsq */
+ 16, /* 3 = gibbmt */
+ 30, /* 4 = giim Giimport-id */
+ 10, /* 5 = genbank */
+ 10, /* 6 = embl */
+ 10, /* 7 = pir */
+ 10, /* 8 = swissprot */
+ 15, /* 9 = patent */
+ 20, /* 10 = other TextSeqId */
+ 20, /* 11 = general Dbtag */
+ 255, /* 12 = gi */
+ 10, /* 13 = ddbj */
+ 10, /* 14 = prf */
+ 12, /* 15 = pdb */
+ 10, /* 16 = tpg */
+ 10, /* 17 = tpe */
+ 10 /* 18 = tpd */
+ };
+
+static void PrintGenome (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ SeqLocPtr slp_head,
+ CharPtr prefix,
+ Boolean segWithParts
+)
+{
+ Char buf[40], val[166];
+ Boolean first = TRUE;
+ SeqLocPtr slp;
+ Int4 from, to, start, stop;
+ SeqIdPtr sid, newid;
+ BioseqPtr bsp = NULL;
+ Int2 p1=0, p2=0;
+
+ for (slp = slp_head; slp; slp = slp->next) {
+ from = to = 0;
+ sid = SeqLocId(slp);
+ if (slp->choice == SEQLOC_INT || slp->choice == SEQLOC_WHOLE) {
+ start = from = SeqLocStart(slp);
+ stop = to = SeqLocStop(slp);
+ } else if (slp->choice == SEQLOC_NULL){
+ sprintf(val, ",%s", "gap()");
+ FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
+ continue;
+ } else {
+ continue;
+ }
+ if (sid == NULL) {
+ continue;
+ }
+ newid = NULL;
+ buf [0] = '\0';
+ if (sid->choice == SEQID_GI) {
+ if (GetAccnVerFromServer (sid->data.intvalue, buf)) {
+ /* no need to call GetSeqIdForGI */
+ } else {
+ newid = GetSeqIdForGI (sid->data.intvalue);
+ if (newid != NULL && segWithParts) {
+ if (newid->choice == SEQID_GIBBSQ ||
+ newid->choice == SEQID_GIBBMT ||
+ newid->choice == SEQID_GIIM) {
+ bsp = BioseqFind (newid);
+ if (bsp != NULL && bsp->repr == Seq_repr_virtual) {
+ if (bsp->length > 0) {
+ sprintf (val, ",gap(%ld)", (long) bsp->length);
+ } else {
+ sprintf(val, ",%s", "gap()");
+ }
+ FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
+ continue;
+ }
+ }
+ }
+ }
+ } else if (sid->choice == SEQID_GENERAL) {
+ newid = sid;
+ } else {
+ newid = sid;
+ }
+ if (prefix != NULL) {
+ FFAddOneString(ffstring, prefix, FALSE, FALSE, TILDE_IGNORE);
+ }
+ if (first) {
+ first = FALSE;
+ } else {
+ FFAddOneChar(ffstring, ',', FALSE);
+ /*ff_AddChar(',');*/
+ }
+ if (! StringHasNoText (buf)) {
+ /* filled in by GetAccnVerFromServer */
+ } else if (newid != NULL) {
+ SeqIdWrite (SeqIdSelect (newid, fasta_order, NUM_SEQID),
+ buf, PRINTID_TEXTID_ACC_VER, sizeof(buf) -1 );
+ } else if (sid->choice == SEQID_GI) {
+ SeqIdWrite (sid, buf, PRINTID_FASTA_LONG, sizeof (buf) - 1);
+ }
+
+ if (SeqLocStrand (slp) == Seq_strand_minus) {
+ FFAddOneString(ffstring, "complement(", FALSE, FALSE, TILDE_IGNORE);
+ }
+ if ( GetWWW(ajp) ) {
+ if (newid == NULL) {
+ newid = sid;
+ }
+ if (newid->choice != SEQID_GENERAL) {
+ FFAddTextToString(ffstring, "<a href=", link_seq, NULL, FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, "val=", buf, ">", FALSE, FALSE, TILDE_IGNORE);
+ FFAddTextToString(ffstring, NULL, buf, "</a>", FALSE, FALSE, TILDE_IGNORE);
+ }
+ } else {
+ FFAddOneString(ffstring, buf, FALSE, FALSE, TILDE_IGNORE);
+ }
+
+ if (SeqLocStrand(slp) == Seq_strand_minus) {
+ sprintf (val,":%ld..%ld)", (long) start+1, (long) stop+1);
+ } else {
+ sprintf (val,":%ld..%ld", (long) start+1, (long) stop+1);
+ }
+ FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
+ p1 += StringLen (val);
+ p2 += StringLen (val);
+ }
+}
+
+static Boolean SegHasParts (
+ BioseqPtr bsp
+)
+
+{
+ BioseqSetPtr bssp;
+ SeqEntryPtr sep;
+
+ if (bsp == NULL || bsp->repr != Seq_repr_seg) return FALSE;
+ sep = bsp->seqentry;
+ if (sep == NULL) return FALSE;
+ sep = sep->next;
+ if (sep == NULL || (! IS_Bioseq_set (sep))) return FALSE;
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL && bssp->_class == BioseqseqSet_class_parts) return TRUE;
+ return FALSE;
+}
+
+static Boolean DeltaLitOnly (
+ BioseqPtr bsp
+)
+
+{
+ ValNodePtr vnp;
+
+ if (bsp == NULL || bsp->repr != Seq_repr_delta) return FALSE;
+ for (vnp = (ValNodePtr)(bsp->seq_ext); vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == 1) return FALSE;
+ }
+ return TRUE;
+}
+
+NLM_EXTERN CharPtr FormatContigBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ BioseqPtr bsp;
+ DeltaSeqPtr dsp;
+ GBSeqPtr gbseq;
+ SeqLitPtr litp;
+ CharPtr prefix = NULL;
+ Boolean segWithParts = FALSE;
+ SeqLocPtr slp_head = NULL;
+ CharPtr str;
+ Char val [20];
+ StringItemPtr ffstring;
+/* CharPtr label;*/
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+ bsp = (asp->bsp);
+ if (bsp == NULL) return NULL;
+
+ ffstring = FFGetString(ajp);
+ if ( ffstring == NULL ) return NULL;
+
+ FFStartPrint (ffstring, afp->format, 0, 0, "CONTIG", 12, 5, 5, "CO", FALSE);
+ /*
+ if ( GetWWW(ajp) ) {
+ label = "CONTIG ";
+ } else {
+ label = "CONTIG";
+ }
+
+ FFAddOneString(ffstring, label, FALSE, FALSE, TILDE_IGNORE);
+ FFAddNChar(ffstring, ' ', 12 - StringLen(label), FALSE);
+ */
+
+ FFAddOneString(ffstring, "join(", FALSE, FALSE, TILDE_IGNORE);
+
+ if (bsp->seq_ext_type == 1) {
+
+ if (bsp->repr == Seq_repr_seg && SegHasParts (bsp)) {
+ segWithParts = TRUE;
+ }
+
+ slp_head = (SeqLocPtr) bsp->seq_ext;
+ PrintGenome (ajp, ffstring, slp_head, prefix, segWithParts);
+
+ } else if (bsp->seq_ext_type == 4) {
+
+ for (dsp = (DeltaSeqPtr) bsp->seq_ext; dsp != NULL; dsp=dsp->next) {
+ if (dsp->choice == 1) {
+
+ slp_head = (SeqLocPtr) dsp->data.ptrvalue;
+ PrintGenome (ajp, ffstring, slp_head, prefix, FALSE);
+
+ } else {
+
+ litp = (SeqLitPtr) dsp->data.ptrvalue;
+ if (litp != NULL) {
+ if (litp->seq_data != NULL) {
+ if (litp->length == 0) {
+ sprintf (val, "gap(%ld)", (long) litp->length);
+ FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
+ } else {
+ /* don't know what to do here */
+ }
+ } else {
+ if (prefix != NULL) {
+ sprintf (val, "%sgap(%ld)", prefix, (long) litp->length);
+ } else {
+ sprintf (val, "gap(%ld)", (long) litp->length);
+ }
+ FFAddOneString(ffstring, val, FALSE, FALSE, TILDE_IGNORE);
+ }
+ }
+ }
+
+ prefix = ",";
+ }
+ }
+
+ FFAddOneChar(ffstring, ')', FALSE);
+
+ str = FFEndPrint(ajp, ffstring, afp->format, 12, 12, 5, 5, "CO");
+ FFRecycleString(ajp, ffstring);
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ if (StringLen (str) > 12) {
+ gbseq->contig = StringSave (str + 12);
+ } else {
+ gbseq->contig = StringSave (str);
+ }
+
+ CleanQualValue (gbseq->contig);
+ Asn2gnbkCompressSpaces (gbseq->contig);
+ StripAllSpaces (gbseq->contig);
+ }
+
+ return str;
+}
+
+static void LIBCALLBACK SaveGBSeqSequence (
+ CharPtr sequence,
+ Pointer userdata
+)
+
+{
+ CharPtr tmp;
+ CharPtr PNTR tmpp;
+
+ tmpp = (CharPtr PNTR) userdata;
+ tmp = *tmpp;
+
+ tmp = StringMove (tmp, sequence);
+
+ *tmpp = tmp;
+}
+
+NLM_EXTERN CharPtr FormatSequenceBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ Byte bases [400];
+ Int2 blk;
+ BioseqPtr bsp;
+ Char buf [80];
+ Char ch;
+ Int2 cnt;
+ Uint1 code = Seq_code_iupacna;
+ Int2 count;
+ Int2 ctr;
+ GBSeqPtr gbseq;
+ Int2 i;
+ IntAsn2gbSectPtr iasp;
+ Boolean is_na;
+ Int2 lin;
+ Int4 pos;
+ CharPtr ptr;
+ Uint1 residue;
+ SeqBlockPtr sbp;
+ SeqPortPtr spp;
+ Int4 start;
+ Int4 stop;
+ CharPtr str;
+ CharPtr tmp;
+ StringItemPtr ffstring;
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ sbp = (SeqBlockPtr) bbp;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+ iasp = (IntAsn2gbSectPtr) asp;
+ bsp = (asp->bsp);
+ if (bsp == NULL) return NULL;
+
+ /* if GBSeq XML, use SeqPortStream on single block */
+
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+
+ str = MemNew (sizeof (Char) * (bsp->length + 10));
+ if (str == NULL) return NULL;
+
+ tmp = str;
+ SeqPortStream (bsp, TRUE, (Pointer) &tmp, SaveGBSeqSequence);
+ gbseq->sequence = StringSave (str);
+
+ tmp = gbseq->sequence;
+ if (tmp == NULL) return NULL;
+ ch = *tmp;
+ while (ch != '\0') {
+ if (ch == '\n' || ch == '\r' || ch == '\t') {
+ *tmp = ' ';
+ }
+ tmp++;
+ ch = *tmp;
+ }
+ TrimSpacesAroundString (gbseq->sequence);
+ CompressNonBases (gbseq->sequence);
+
+ return str;
+ }
+
+ /* if subsequence cached with SeqPortStream, use it */
+
+ if (sbp->bases != NULL) {
+ ffstring = FFGetString (ajp);
+
+ start = sbp->start;
+ stop = sbp->stop;
+
+ count = 0;
+ blk = 0;
+ lin = 0;
+
+ ptr = sbp->bases;
+ ch = *ptr;
+
+ while (ch != '\0') {
+ buf [count] = (Char) (TO_LOWER (ch));
+ count++;
+ ptr++;
+ ch = *ptr;
+
+ blk++;
+ lin++;
+ if (lin >= 60) {
+
+ buf [count] = '\0';
+ PrintSeqLine (ffstring, afp->format, buf, start, start + cnt);
+ count = 0;
+ cnt = 0;
+ blk = 0;
+ lin = 0;
+ start += 60;
+
+ } else if (blk >= 10) {
+
+ buf [count] = ' ';
+ count++;
+ blk = 0;
+
+ }
+ }
+
+ buf [count] = '\0';
+ if (count > 0) {
+ PrintSeqLine (ffstring, afp->format, buf, start, start + cnt);
+ }
+
+ str = FFToCharPtr(ffstring);
+
+ FFRecycleString (ajp, ffstring);
+ return str;
+ }
+
+ /* otherwise split into smaller blocks */
+
+ spp = iasp->spp;
+ if (spp == NULL) {
+
+ /* if first time, create SeqPort for this section */
+
+ if (ISA_aa (bsp->mol)) {
+ if (ajp->flags.iupacaaOnly) {
+ code = Seq_code_iupacaa;
+ } else {
+ code = Seq_code_ncbieaa;
+ }
+ }
+
+ if (ajp->ajp.slp != NULL) {
+ spp = SeqPortNewByLoc (ajp->ajp.slp, code);
+ } else {
+ spp = SeqPortNew (bsp, 0, -1, 0, code);
+ }
+ if (spp == NULL) return NULL;
+ if (bsp->repr == Seq_repr_delta || bsp->repr == Seq_repr_virtual) {
+ SeqPortSet_do_virtual (spp, TRUE);
+ }
+
+ iasp->spp = spp;
+ }
+
+ start = sbp->start;
+ stop = sbp->stop;
+
+ if (start != spp->curpos) {
+ SeqPortSeek (spp, start, SEEK_SET);
+ }
+
+ pos = start;
+
+ count = 0;
+ cnt = 0;
+ blk = 0;
+ lin = 0;
+
+ is_na = ISA_na (bsp->mol);
+
+ ctr = (Int2) MIN ((Int4) (stop - pos), (Int4) sizeof (bases));
+ ctr = SeqPortRead (spp, bases, ctr);
+
+ i = 0;
+
+ if (ctr < 0) {
+ residue = -ctr;
+ } else if (ctr < 1) {
+ residue = SEQPORT_EOF;
+ } else {
+ residue = (Uint1) bases [i];
+ }
+
+
+ ffstring = FFGetString(ajp);
+ while (pos < stop && residue != SEQPORT_EOF) {
+
+ if (residue == INVALID_RESIDUE) {
+ if (is_na) {
+ residue = 'N';
+ } else {
+ residue = 'X';
+ }
+ }
+
+ if (IS_residue (residue)) {
+
+ buf [count] = (Char) (TO_LOWER (residue));
+ count++;
+ cnt++;
+ pos++;
+
+ blk++;
+ lin++;
+ if (lin >= 60) {
+
+ buf [count] = '\0';
+ PrintSeqLine (ffstring, afp->format, buf, start, start + cnt);
+ count = 0;
+ cnt = 0;
+ blk = 0;
+ lin = 0;
+ start += 60;
+
+ } else if (blk >= 10) {
+
+ buf [count] = ' ';
+ count++;
+ blk = 0;
+
+ }
+ }
+
+ i++;
+ if (i >= ctr) {
+ i = 0;
+ ctr = (Int2) MIN ((Int4) (stop - pos), (Int4) sizeof (bases));
+ ctr = SeqPortRead (spp, bases, ctr);
+ if (ctr < 0) {
+ bases [0] = -ctr;
+ } else if (ctr < 1) {
+ bases [0] = SEQPORT_EOF;
+ }
+ }
+ residue = (Uint1) bases [i];
+ }
+
+ buf [count] = '\0';
+ if (count > 0) {
+ PrintSeqLine (ffstring, afp->format, buf, start, start + cnt);
+ }
+
+ if (ajp->transientSeqPort) {
+ iasp->spp = SeqPortFree (iasp->spp);
+ }
+
+ str = FFToCharPtr(ffstring);
+
+ /* optionally populate gbseq for XML-ized GenBank format */
+
+ /*
+ if (ajp->gbseq) {
+ gbseq = &asp->gbseq;
+ } else {
+ gbseq = NULL;
+ }
+
+ if (gbseq != NULL) {
+ CatenateSequenceInGbseq (gbseq, str);
+ }
+ */
+
+ FFRecycleString(ajp, ffstring);
+ return str;
+}
+
+NLM_EXTERN CharPtr FormatSlashBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+)
+
+{
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ GBFeaturePtr currf, headf, nextf;
+ GBReferencePtr currr, headr, nextr;
+ GBSeqPtr gbseq;
+ IndxPtr index;
+
+ if (afp == NULL || bbp == NULL) return NULL;
+ ajp = afp->ajp;
+ if (ajp == NULL) return NULL;
+ asp = afp->asp;
+ if (asp == NULL) return NULL;
+
+ /* sort and unique indexes */
+
+ index = ajp->index;
+
+ if (index != NULL) {
+
+ MemCopy (index, &asp->index, sizeof (IndxBlock));
+ MemSet (&asp->index, 0, sizeof (IndxBlock));
+
+ index->authors = ValNodeSort (index->authors, SortVnpByString);
+ index->authors = UniqueValNode (index->authors);
+
+ index->genes = ValNodeSort (index->genes, SortVnpByString);
+ index->genes = UniqueValNode (index->genes);
+
+ index->journals = ValNodeSort (index->journals, SortVnpByString);
+ index->journals = UniqueValNode (index->journals);
+
+ index->keywords = ValNodeSort (index->keywords, SortVnpByString);
+ index->keywords = UniqueValNode (index->keywords);
+
+ index->secondaries = ValNodeSort (index->secondaries, SortVnpByString);
+ index->secondaries = UniqueValNode (index->secondaries);
+ }
+
+ /* adjust XML-ized GenBank format */
+
+ gbseq = ajp->gbseq;
+
+ if (gbseq != NULL) {
+
+ MemCopy (gbseq, &asp->gbseq, sizeof (GBSeq));
+ MemSet (&asp->gbseq, 0, sizeof (GBSeq));
+
+ /* reverse order of references */
+
+ headr = NULL;
+ for (currr = gbseq->references; currr != NULL; currr = nextr) {
+ nextr = currr->next;
+ currr->next = headr;
+ headr = currr;
+ }
+ gbseq->references = headr;
+
+ /* reverse order of features */
+
+ headf = NULL;
+ for (currf = gbseq->feature_table; currf != NULL; currf = nextf) {
+ nextf = currf->next;
+ currf->next = headf;
+ headf = currf;
+ }
+ gbseq->feature_table = headf;
+ }
+
+ /* slash always has string pre-allocated by add slash block function */
+
+ return StringSaveNoNull (bbp->string);
+}
+
+
diff --git a/api/asn2gnbi.h b/api/asn2gnbi.h
new file mode 100644
index 00000000..e9232dd7
--- /dev/null
+++ b/api/asn2gnbi.h
@@ -0,0 +1,1008 @@
+/* asn2gnbi.h
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information (NCBI)
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government do not place any restriction on its use or reproduction.
+* We would, however, appreciate having the NCBI and the author cited in
+* any work or product based on this material
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* ===========================================================================
+*
+* File Name: asn2gnbi.h
+*
+* Author: Karl Sirotkin, Tom Madden, Tatiana Tatusov, Jonathan Kans
+*
+* Version Creation Date: 12/30/03
+*
+* $Revision: 1.3 $
+*
+* File Description: New GenBank flatfile generator, internal header
+*
+* Modifications:
+* --------------------------------------------------------------------------
+* ==========================================================================
+*/
+
+#ifndef _ASN2NGNBI_
+#define _ASN2NGNBI_
+
+#include <asn2gnbp.h>
+
+#undef NLM_EXTERN
+#ifdef NLM_IMPORT
+#define NLM_EXTERN NLM_IMPORT
+#else
+#define NLM_EXTERN extern
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#define ASN2FF_EMBL_MAX 78
+#define ASN2FF_GB_MAX 79
+#define SEQID_MAX_LEN 41
+
+#define TILDE_IGNORE 0
+#define TILDE_TO_SPACES 1
+#define TILDE_EXPAND 2
+#define TILDE_OLD_EXPAND 3
+
+
+/* flags set by mode to customize behavior */
+
+typedef struct asn2gbflags {
+ Boolean suppressLocalID;
+ Boolean validateFeats;
+ Boolean ignorePatPubs;
+ Boolean dropShortAA;
+ Boolean avoidLocusColl;
+ Boolean iupacaaOnly;
+ Boolean dropBadCitGens;
+ Boolean noAffilOnUnpub;
+ Boolean dropIllegalQuals;
+ Boolean checkQualSyntax;
+ Boolean needRequiredQuals;
+ Boolean needOrganismQual;
+ Boolean needAtLeastOneRef;
+ Boolean citArtIsoJta;
+ Boolean dropBadDbxref;
+ Boolean useEmblMolType;
+ Boolean hideBankItComment;
+ Boolean checkCDSproductID;
+ Boolean suppressSegLoc;
+ Boolean srcQualsToNote;
+ Boolean hideEmptySource;
+ Boolean goQualsToNote;
+ Boolean geneSynsToNote;
+ Boolean selenocysteineToNote;
+ Boolean forGbRelease;
+} Asn2gbFlags, PNTR Asn2gbFlagsPtr;
+
+/* internal Asn2gbSect structure has fields on top of Asn2gbSect fields */
+
+typedef struct int_Asn2gbSect {
+ Asn2gbSect asp;
+ SeqPortPtr spp;
+} IntAsn2gbSect, PNTR IntAsn2gbSectPtr;
+
+/* string structure */
+
+#define STRING_BUF_LEN 1024
+
+typedef struct stringitem {
+ struct stringitem *curr;
+ struct stringitem *next;
+ Pointer iajp;
+ Char buf [STRING_BUF_LEN];
+ Int4 pos;
+} StringItem, PNTR StringItemPtr;
+
+/* internal asn2gbjob structure has fields on top of Asn2gbJob fields */
+
+typedef struct int_asn2gb_job {
+ Asn2gbJob ajp;
+ FmtType format;
+ ModType mode;
+ Asn2gbFlags flags;
+ Boolean showFarTransl;
+ Boolean transIfNoProd;
+ Boolean alwaysTranslCds;
+ Boolean showTranscript;
+ Boolean showPeptide;
+ Boolean transientSeqPort;
+ Boolean masterStyle;
+ Boolean newSourceOrg;
+ ValNodePtr lockedBspList;
+ Boolean relModeError;
+ Boolean skipProts;
+ Boolean skipMrnas;
+ IndxPtr index;
+ GBSeqPtr gbseq;
+ StringItemPtr pool;
+ Boolean www;
+} IntAsn2gbJob, PNTR IntAsn2gbJobPtr;
+
+/* structure for storing working parameters while building asn2gb_job structure */
+
+typedef struct asn2gbwork {
+ IntAsn2gbJobPtr ajp;
+ Uint2 entityID;
+
+ FmtType format;
+ ModType mode;
+ StlType style;
+
+ ValNodePtr pubhead; /* for collecting publications */
+ ValNodePtr srchead; /* for collecting biosources */
+
+ /* linked lists of paragraphs, sections, blocks */
+
+ ValNodePtr sectionList;
+ ValNodePtr blockList; /* reset for each new section */
+
+ /* most recent node of linked lists, for quickly adding next node */
+
+ ValNodePtr lastsection;
+ ValNodePtr lastblock; /* reset for each new section */
+
+ Int4 currsection;
+
+ /* section fields needed for populating blocks */
+
+ Asn2gbSectPtr asp;
+
+ BioseqPtr target;
+ BioseqPtr parent;
+ BioseqPtr bsp;
+ BioseqPtr refs;
+ SeqLocPtr slp;
+ Uint2 seg;
+ Int4 numsegs;
+ Int4 partcount;
+ Int4 from;
+ Int4 to;
+ Boolean showAllFeats;
+
+ Boolean contig;
+ Boolean showconfeats;
+ Boolean showconsource;
+
+ Boolean onlyNearFeats;
+ Boolean farFeatsSuppress;
+ Boolean nearFeatsSuppress;
+
+ Boolean citSubsFirst;
+ Boolean hideGeneFeats;
+ Boolean newLocusLine;
+ Boolean showBaseCount;
+
+ Boolean hideImpFeats;
+ Boolean hideRemImpFeats;
+ Boolean hideSnpFeats;
+ Boolean hideExonFeats;
+ Boolean hideIntronFeats;
+ Boolean hideMiscFeats;
+ Boolean hideCddFeats;
+ Boolean hideCdsProdFeats;
+
+ Boolean hideGeneRIFs;
+ Boolean onlyGeneRIFs;
+ Boolean latestGeneRIFs;
+
+ Boolean showRefs;
+
+ Boolean isGPS;
+ Boolean copyGpsCdsUp;
+ Boolean copyGpsGeneDown;
+
+ Boolean showContigAndSeq;
+
+ Char basename [SEQID_MAX_LEN];
+
+ SeqFeatPtr lastsfp;
+ SeqAnnotPtr lastsap;
+ Int4 lastleft;
+ Int4 lastright;
+
+ Boolean firstfeat;
+ Boolean featseen;
+
+ SeqSubmitPtr ssp;
+ Boolean hup;
+
+ Boolean stream;
+
+ Boolean failed;
+} Asn2gbWork, PNTR Asn2gbWorkPtr;
+
+/* array for assigning biosource and feature data fields to qualifiers */
+/* should be allocated to MAX (ASN2GNBK_TOTAL_SOURCE, ASN2GNBK_TOTAL_FEATUR) */
+
+typedef union qualval {
+ CharPtr str;
+ Boolean ble;
+ Int4 num;
+ ValNodePtr vnp;
+ GBQualPtr gbq;
+ OrgModPtr omp;
+ SubSourcePtr ssp;
+ CodeBreakPtr cbp;
+ SeqLocPtr slp;
+ SeqIdPtr sip;
+ tRNAPtr trp;
+ UserObjectPtr uop;
+ UserFieldPtr ufp;
+} QualVal, PNTR QualValPtr;
+
+/* structure passed to individual paragraph format functions */
+
+typedef struct asn2gbformat {
+ IntAsn2gbJobPtr ajp;
+ Asn2gbSectPtr asp;
+ QualValPtr qvp;
+
+ FmtType format;
+} Asn2gbFormat, PNTR Asn2gbFormatPtr;
+
+
+/* Seq-hist replacedBy is preformatted into string field, */
+/* then comment descriptors, Map location:, and Region:, */
+/* then comment features, finally HTGS */
+
+typedef struct comment_block {
+ ASN2GB_BASE_BLOCK
+ Boolean first;
+} CommentBlock, PNTR CommentBlockPtr;
+
+/* internal reference block has fields on top of RefBlock fields */
+
+typedef struct int_ref_block {
+ RefBlock rb;
+ DatePtr date; /* internal sorting use only */
+ SeqLocPtr loc; /* final location on target bioseq */
+ CharPtr authstr; /* author string */
+ Uint2 index; /* index if feature on target bioseq */
+ Boolean justuids; /* gibb pub with uids and Figure, etc. */
+ CharPtr fig; /* figure string from equivalent gibb pub */
+ CharPtr maploc; /* maploc string from equivalent gibb pub */
+ Boolean poly_a; /* poly_a field from equivalent gibb pub */
+} IntRefBlock, PNTR IntRefBlockPtr;
+
+/* internal source block has fields on top of BaseBlock fields */
+
+typedef struct int_src_block {
+ BaseBlock bb;
+ Boolean is_descriptor;
+ Boolean is_focus;
+ Boolean is_synthetic;
+ BioSourcePtr biop;
+ Uint4 orghash;
+ Uint4 modhash;
+ Uint4 subhash;
+ Uint4 xrfhash;
+ SeqLocPtr loc; /* final location on target bioseq */
+ CharPtr taxname;
+ CharPtr comment;
+ OrgModPtr omp;
+ SubSourcePtr ssp;
+ ValNodePtr vnp;
+ Int4 left;
+ Int4 right;
+} IntSrcBlock, PNTR IntSrcBlockPtr;
+
+/* internal feature block has fields on top of FeatBlock fields */
+
+typedef struct int_feat_block {
+ FeatBlock fb;
+ Boolean mapToNuc;
+ Boolean mapToProt;
+ Boolean mapToGen;
+ Boolean mapToMrna;
+ Boolean mapToPep;
+ Boolean isCDS; /* set if using IntCdsBlock */
+ Boolean firstfeat;
+} IntFeatBlock, PNTR IntFeatBlockPtr;
+
+/* internal cds block has fields on top of IntFeatBlock fields */
+
+typedef struct int_cds_block {
+ IntFeatBlock ifb;
+ CharPtr fig; /* figure string from pub */
+ CharPtr maploc; /* maploc string from pub */
+} IntCdsBlock, PNTR IntCdsBlockPtr;
+
+
+/* enumerated qualifier category definitions */
+
+typedef enum {
+ Qual_class_ignore = 0,
+ Qual_class_string,
+ Qual_class_tilde,
+ Qual_class_sgml,
+ Qual_class_boolean,
+ Qual_class_int,
+ Qual_class_evidence,
+ Qual_class_valnode,
+ Qual_class_EC_valnode,
+ Qual_class_xtraprds,
+ Qual_class_quote,
+ Qual_class_EC_quote,
+ Qual_class_noquote,
+ Qual_class_label,
+ Qual_class_number,
+ Qual_class_paren,
+ Qual_class_region,
+ Qual_class_replace,
+ Qual_class_consplice,
+ Qual_class_bond,
+ Qual_class_site,
+ Qual_class_L_R_B,
+ Qual_class_rpt,
+ Qual_class_organelle,
+ Qual_class_orgmod,
+ Qual_class_subsource,
+ Qual_class_code_break,
+ Qual_class_anti_codon,
+ Qual_class_codon,
+ Qual_class_method,
+ Qual_class_pubset,
+ Qual_class_db_xref,
+ Qual_class_seq_id,
+ Qual_class_seq_loc,
+ Qual_class_its,
+ Qual_class_sec_str,
+ Qual_class_trna_codons,
+ Qual_class_translation,
+ Qual_class_transcription,
+ Qual_class_peptide,
+ Qual_class_protnames,
+ Qual_class_encodes,
+ Qual_class_illegal,
+ Qual_class_note,
+ Qual_class_rpt_unit,
+ Qual_class_product,
+ Qual_class_model_ev,
+ Qual_class_gene_syn,
+ Qual_class_locus_tag,
+ Qual_class_go
+} QualType;
+
+/* source 'feature' */
+
+/* some qualifiers will require additional content verification not
+ explicitly indicated by the class type */
+
+typedef enum {
+ SCQUAL_acronym = 1,
+ SCQUAL_anamorph,
+ SCQUAL_authority,
+ SCQUAL_biotype,
+ SCQUAL_biovar,
+ SCQUAL_breed,
+ SCQUAL_cell_line,
+ SCQUAL_cell_type,
+ SCQUAL_chemovar,
+ SCQUAL_chromosome,
+ SCQUAL_citation,
+ SCQUAL_clone,
+ SCQUAL_clone_lib,
+ SCQUAL_common,
+ SCQUAL_common_name,
+ SCQUAL_country,
+ SCQUAL_cultivar,
+ SCQUAL_db_xref,
+ SCQUAL_org_xref,
+ SCQUAL_dev_stage,
+ SCQUAL_dosage,
+ SCQUAL_ecotype,
+ SCQUAL_endogenous_virus_name,
+ SCQUAL_environmental_sample,
+ SCQUAL_extrachrom,
+ SCQUAL_focus,
+ SCQUAL_forma,
+ SCQUAL_forma_specialis,
+ SCQUAL_frequency,
+ SCQUAL_gb_acronym,
+ SCQUAL_gb_anamorph,
+ SCQUAL_gb_synonym,
+ SCQUAL_genotype,
+ SCQUAL_germline,
+ SCQUAL_group,
+ SCQUAL_haplotype,
+ SCQUAL_ins_seq_name,
+ SCQUAL_isolate,
+ SCQUAL_isolation_source,
+ SCQUAL_lab_host,
+ SCQUAL_label,
+ SCQUAL_macronuclear,
+ SCQUAL_map,
+ SCQUAL_mol_type,
+ SCQUAL_note,
+ SCQUAL_old_lineage,
+ SCQUAL_old_name,
+ SCQUAL_organism,
+ SCQUAL_organelle,
+ SCQUAL_orgmod_note,
+ SCQUAL_pathovar,
+ SCQUAL_plasmid_name,
+ SCQUAL_plastid_name,
+ SCQUAL_pop_variant,
+ SCQUAL_rearranged,
+ SCQUAL_segment,
+ SCQUAL_seqfeat_note,
+ SCQUAL_sequenced_mol,
+ SCQUAL_serogroup,
+ SCQUAL_serotype,
+ SCQUAL_serovar,
+ SCQUAL_sex,
+ SCQUAL_spec_or_nat_host,
+ SCQUAL_specimen_voucher,
+ SCQUAL_strain,
+ SCQUAL_sub_clone,
+ SCQUAL_sub_group,
+ SCQUAL_sub_species,
+ SCQUAL_sub_strain,
+ SCQUAL_sub_type,
+ SCQUAL_subsource_note,
+ SCQUAL_synonym,
+ SCQUAL_teleomorph,
+ SCQUAL_tissue_lib,
+ SCQUAL_tissue_type,
+ SCQUAL_transgenic,
+ SCQUAL_transposon_name,
+ SCQUAL_type,
+ SCQUAL_unstructured,
+ SCQUAL_usedin,
+ SCQUAL_variety,
+ SCQUAL_zero_orgmod,
+ SCQUAL_one_orgmod,
+ SCQUAL_zero_subsrc,
+ ASN2GNBK_TOTAL_SOURCE
+} SourceType;
+
+NLM_EXTERN SourceType orgModToSourceIdx [38];
+
+typedef enum {
+ FTQUAL_allele = 1,
+ FTQUAL_anticodon,
+ FTQUAL_bond,
+ FTQUAL_bond_type,
+ FTQUAL_bound_moiety,
+ FTQUAL_cds_product,
+ FTQUAL_citation,
+ FTQUAL_clone,
+ FTQUAL_coded_by,
+ FTQUAL_codon,
+ FTQUAL_codon_start,
+ FTQUAL_cons_splice,
+ FTQUAL_db_xref,
+ FTQUAL_derived_from,
+ FTQUAL_direction,
+ FTQUAL_EC_number,
+ FTQUAL_encodes,
+ FTQUAL_evidence,
+ FTQUAL_exception,
+ FTQUAL_exception_note,
+ FTQUAL_figure,
+ FTQUAL_frequency,
+ FTQUAL_function,
+ FTQUAL_gene,
+ FTQUAL_gene_desc,
+ FTQUAL_gene_allele,
+ FTQUAL_gene_map,
+ FTQUAL_gene_syn,
+ FTQUAL_gene_syn_refseq,
+ FTQUAL_gene_note,
+ FTQUAL_gene_xref,
+ FTQUAL_go_component,
+ FTQUAL_go_function,
+ FTQUAL_go_process,
+ FTQUAL_heterogen,
+ FTQUAL_illegal_qual,
+ FTQUAL_insertion_seq,
+ FTQUAL_label,
+ FTQUAL_locus_tag,
+ FTQUAL_map,
+ FTQUAL_maploc,
+ FTQUAL_mod_base,
+ FTQUAL_modelev,
+ FTQUAL_note,
+ FTQUAL_number,
+ FTQUAL_operon,
+ FTQUAL_organism,
+ FTQUAL_partial,
+ FTQUAL_PCR_conditions,
+ FTQUAL_peptide,
+ FTQUAL_phenotype,
+ FTQUAL_product,
+ FTQUAL_product_quals,
+ FTQUAL_prot_activity,
+ FTQUAL_prot_comment,
+ FTQUAL_prot_EC_number,
+ FTQUAL_prot_note,
+ FTQUAL_prot_method,
+ FTQUAL_prot_conflict,
+ FTQUAL_prot_desc,
+ FTQUAL_prot_missing,
+ FTQUAL_prot_name,
+ FTQUAL_prot_names,
+ FTQUAL_protein_id,
+ FTQUAL_pseudo,
+ FTQUAL_region,
+ FTQUAL_region_name,
+ FTQUAL_replace,
+ FTQUAL_rpt_family,
+ FTQUAL_rpt_type,
+ FTQUAL_rpt_unit,
+ FTQUAL_rrna_its,
+ FTQUAL_sec_str_type,
+ FTQUAL_selenocysteine,
+ FTQUAL_selenocysteine_note,
+ FTQUAL_seqfeat_note,
+ FTQUAL_site,
+ FTQUAL_site_type,
+ FTQUAL_standard_name,
+ FTQUAL_transcription,
+ FTQUAL_transcript_id,
+ FTQUAL_transcript_id_note, /* !!! remove October 15, 2003 !!! */
+ FTQUAL_transl_except,
+ FTQUAL_transl_table,
+ FTQUAL_translation,
+ FTQUAL_transposon,
+ FTQUAL_trna_aa,
+ FTQUAL_trna_codons,
+ FTQUAL_usedin,
+ FTQUAL_xtra_prod_quals,
+ ASN2GNBK_TOTAL_FEATUR
+} FtQualType;
+
+#define MAX_WWWBUF 328
+
+NLM_EXTERN Char link_feat [MAX_WWWBUF];
+NLM_EXTERN Char link_seq [MAX_WWWBUF];
+NLM_EXTERN Char link_wgs [MAX_WWWBUF];
+NLM_EXTERN Char link_omim [MAX_WWWBUF];
+NLM_EXTERN Char ref_link [MAX_WWWBUF];
+NLM_EXTERN Char nt_link [MAX_WWWBUF];
+NLM_EXTERN Char doc_link [MAX_WWWBUF];
+NLM_EXTERN Char ev_link [MAX_WWWBUF];
+NLM_EXTERN Char ec_link [MAX_WWWBUF];
+NLM_EXTERN Char link_tax [MAX_WWWBUF];
+NLM_EXTERN Char link_muid [MAX_WWWBUF];
+NLM_EXTERN Char link_code [MAX_WWWBUF];
+NLM_EXTERN Char link_encode [MAX_WWWBUF];
+
+NLM_EXTERN void FF_www_db_xref(
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr db, CharPtr identifier
+);
+
+NLM_EXTERN Boolean StringIsJustQuotes (
+ CharPtr str
+);
+
+
+typedef struct sourcequal {
+ CharPtr name;
+ QualType qualclass;
+} SourceQual, PNTR SourceQualPtr;
+
+NLM_EXTERN SourceQual asn2gnbk_source_quals [ASN2GNBK_TOTAL_SOURCE];
+
+NLM_EXTERN SourceType subSourceToSourceIdx [30];
+
+NLM_EXTERN void DoOneSection (
+ BioseqPtr target,
+ BioseqPtr parent,
+ BioseqPtr bsp,
+ BioseqPtr refs,
+ SeqLocPtr slp,
+ Uint2 seg,
+ Int4 from,
+ Int4 to,
+ Boolean contig,
+ Boolean onePartOfSeg,
+ Asn2gbWorkPtr awp
+);
+
+NLM_EXTERN void DoOneBioseq (
+ BioseqPtr bsp,
+ Pointer userdata
+);
+
+NLM_EXTERN BaseBlockPtr Asn2gbAddBlock (
+ Asn2gbWorkPtr awp,
+ BlockType blocktype,
+ size_t size
+);
+
+NLM_EXTERN void InitWWW (IntAsn2gbJobPtr ajp);
+NLM_EXTERN void FiniWWW (IntAsn2gbJobPtr ajp);
+NLM_EXTERN Boolean GetWWW (IntAsn2gbJobPtr ajp);
+
+NLM_EXTERN StringItemPtr FFGetString (IntAsn2gbJobPtr ajp);
+NLM_EXTERN void FFRecycleString (IntAsn2gbJobPtr ajp, StringItemPtr ffstring);
+NLM_EXTERN void FFAddOneChar (
+ StringItemPtr sip,
+ Char ch,
+ Boolean convertQuotes
+);
+NLM_EXTERN void FFAddNewLine(StringItemPtr ffstring);
+NLM_EXTERN void FFAddNChar (
+ StringItemPtr sip,
+ Char ch,
+ Int4 n,
+ Boolean convertQuotes
+);
+NLM_EXTERN void FFExpandTildes (StringItemPtr sip, CharPtr PNTR cpp);
+NLM_EXTERN void FFReplaceTildesWithSpaces (StringItemPtr ffstring, CharPtr PNTR cpp);
+NLM_EXTERN void FFOldExpand (StringItemPtr sip, CharPtr PNTR cpp);
+NLM_EXTERN void AddCommentStringWithTildes (StringItemPtr ffstring, CharPtr string);
+NLM_EXTERN void AddCommentWithURLlinks (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ CharPtr prefix,
+ CharPtr str,
+ CharPtr suffix
+);
+NLM_EXTERN void AddStringWithTildes (StringItemPtr ffstring, CharPtr string);
+NLM_EXTERN void FFProcessTildes (StringItemPtr sip, CharPtr PNTR cpp, Int2 tildeAction);
+NLM_EXTERN void FFAddPeriod (StringItemPtr sip);
+NLM_EXTERN void FFAddOneString (
+ StringItemPtr sip,
+ CharPtr string,
+ Boolean addPeriod,
+ Boolean convertQuotes,
+ Int2 tildeAction
+);
+NLM_EXTERN void FFCatenateSubString (
+ StringItemPtr dest,
+ StringItemPtr start_sip, Int4 start_pos,
+ StringItemPtr end_sip, Int4 end_pos
+);
+NLM_EXTERN CharPtr FFToCharPtr (StringItemPtr sip);
+NLM_EXTERN void FFSkipLink (StringItemPtr PNTR iterp, Int4Ptr ip);
+NLM_EXTERN Boolean FFIsStartOfLink (StringItemPtr iter, Int4 pos);
+NLM_EXTERN void FFSavePosition(StringItemPtr ffstring, StringItemPtr PNTR bufptr, Int4 PNTR posptr);
+NLM_EXTERN void FFTrim (
+ StringItemPtr ffstring,
+ StringItemPtr line_start,
+ Int4 line_pos,
+ Int4 line_prefix_len
+);NLM_EXTERN void FFCalculateLineBreak (
+ StringItemPtr PNTR break_sip, Int4 PNTR break_pos,
+ Int4 init_indent, Int4 visible
+);
+NLM_EXTERN void FFLineWrap (
+ StringItemPtr dest,
+ StringItemPtr src,
+ Int4 init_indent,
+ Int4 cont_indent,
+ Int4 line_max,
+ CharPtr eb_line_prefix
+);
+NLM_EXTERN void FFStartPrint (
+ StringItemPtr sip,
+ FmtType format,
+ Int4 gb_init_indent,
+ Int4 gb_cont_indent,
+ CharPtr gb_label,
+ Int4 gb_tab_to,
+ Int4 eb_init_indent,
+ Int4 eb_cont_indent,
+ CharPtr eb_line_prefix,
+ Boolean eb_print_xx
+);
+NLM_EXTERN void FFAddTextToString (
+ StringItemPtr ffstring,
+ CharPtr prefix,
+ CharPtr string,
+ CharPtr suffix,
+ Boolean addPeriod,
+ Boolean convertQuotes,
+ Int2 tildeAction
+);
+NLM_EXTERN CharPtr FFEndPrint (
+ IntAsn2gbJobPtr ajp,
+ StringItemPtr ffstring,
+ FmtType format,
+ Int2 gb_init_indent,
+ Int2 gb_cont_indent,
+ Int2 eb_init_indent,
+ Int2 eb_cont_indent,
+ CharPtr eb_line_prefix
+);
+NLM_EXTERN Uint4 FFLength(StringItemPtr ffstring);
+NLM_EXTERN Char FFCharAt(StringItemPtr ffstring, Uint4 pos);
+NLM_EXTERN Char FFFindChar (
+ StringItemPtr ffstring,
+ StringItemPtr start_buf,
+ Uint4 start_pos,
+ Uint4 old_pos,
+ Uint4 new_pos
+);
+NLM_EXTERN Boolean FFEmpty(StringItemPtr ffstring);
+NLM_EXTERN Int4 FFStringSearch (
+ StringItemPtr text,
+ const CharPtr pattern,
+ Uint4 position
+);
+NLM_EXTERN Boolean IsWholeWordSubstr (
+ StringItemPtr searchStr,
+ Uint4 foundPos,
+ CharPtr subStr
+);
+
+NLM_EXTERN ValNodePtr ValNodeCopyStrToHead (ValNodePtr PNTR head, Int2 choice, CharPtr str);
+NLM_EXTERN CharPtr MergeFFValNodeStrs (
+ ValNodePtr list
+);
+NLM_EXTERN void AddValNodeString (
+ ValNodePtr PNTR head,
+ CharPtr prefix,
+ CharPtr string,
+ CharPtr suffix
+);
+NLM_EXTERN void FFAddString_NoRedund (
+ StringItemPtr unique,
+ CharPtr prefix,
+ CharPtr string,
+ CharPtr suffix
+);
+NLM_EXTERN void s_AddPeriodToEnd (CharPtr someString);
+NLM_EXTERN Boolean s_RemovePeriodFromEnd (CharPtr someString);
+NLM_EXTERN Boolean IsEllipsis (
+ CharPtr str
+);
+NLM_EXTERN void A2GBSeqLocReplaceID (
+ SeqLocPtr newloc,
+ SeqLocPtr ajpslp
+);
+NLM_EXTERN CharPtr asn2gb_PrintDate (
+ DatePtr dp
+);
+NLM_EXTERN CharPtr DateToFF (
+ CharPtr buf,
+ DatePtr dp,
+ Boolean citSub
+);
+
+NLM_EXTERN CharPtr FFFlatLoc (
+ IntAsn2gbJobPtr ajp,
+ BioseqPtr bsp,
+ SeqLocPtr location,
+ Boolean masterStyle
+);
+
+NLM_EXTERN void FF_www_featloc(StringItemPtr ffstring, CharPtr loc);
+
+NLM_EXTERN CharPtr GetMolTypeQual (
+ BioseqPtr bsp
+);
+
+NLM_EXTERN void AddFeatureToGbseq (
+ GBSeqPtr gbseq,
+ GBFeaturePtr gbfeat,
+ CharPtr str,
+ SeqFeatPtr sfp
+);
+
+NLM_EXTERN SeqIdPtr SeqLocIdForProduct (
+ SeqLocPtr product
+);
+
+NLM_EXTERN CharPtr GetAuthorsString (
+ FmtType format,
+ AuthListPtr alp,
+ CharPtr PNTR consortP,
+ IndxPtr index,
+ GBReferencePtr gbref
+);
+
+NLM_EXTERN AuthListPtr GetAuthListPtr (
+ PubdescPtr pdp,
+ CitSubPtr csp
+);
+
+NLM_EXTERN Int2 MatchRef (
+ ValNodePtr ppr,
+ RefBlockPtr PNTR rbpp,
+ Int2 numReferences
+);
+
+NLM_EXTERN SeqLocPtr SeqLocReMapEx (
+ SeqIdPtr newid,
+ SeqLocPtr seq_loc,
+ SeqLocPtr location,
+ Int4 offset,
+ Boolean rev,
+ Boolean masterStyle
+);
+
+NLM_EXTERN CharPtr Get3LetterSymbol (
+ IntAsn2gbJobPtr ajp,
+ Uint1 seq_code,
+ SeqCodeTablePtr table,
+ Uint1 residue
+);
+
+NLM_EXTERN CharPtr CleanQualValue (
+ CharPtr str
+);
+NLM_EXTERN CharPtr Asn2gnbkCompressSpaces (CharPtr str);
+NLM_EXTERN CharPtr StripAllSpaces (
+ CharPtr str
+);
+
+NLM_EXTERN Boolean GetAccnVerFromServer (Int4 gi, CharPtr buf);
+
+NLM_EXTERN CharPtr bondList [];
+NLM_EXTERN CharPtr siteList [];
+NLM_EXTERN CharPtr secStrText [];
+
+NLM_EXTERN CharPtr goQualType [];
+NLM_EXTERN CharPtr goFieldType [];
+
+NLM_EXTERN CharPtr legalDbXrefs [];
+NLM_EXTERN CharPtr legalRefSeqDbXrefs [];
+
+
+NLM_EXTERN void AddFeatureBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN Boolean AddReferenceBlock (
+ Asn2gbWorkPtr awp,
+ Boolean isRefSeq
+);
+NLM_EXTERN void AddSourceFeatBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddFeatureBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddLocusBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddAccessionBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddVersionBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddDbsourceBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddDateBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddDeflineBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddKeywordsBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddSegmentBlock (
+ Asn2gbWorkPtr awp,
+ Boolean onePartOfSeg
+);
+NLM_EXTERN void AddSourceBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddOrganismBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddCommentBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddPrimaryBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddFeatHeaderBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddSourceFeatBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddWGSBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddGenomeBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddContigBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddBasecountBlock (
+ Asn2gbWorkPtr awp,
+ CharPtr bases
+);
+NLM_EXTERN void AddOriginBlock (
+ Asn2gbWorkPtr awp
+);
+NLM_EXTERN void AddSequenceBlock (
+ Asn2gbWorkPtr awp,
+ CharPtr bases
+);
+NLM_EXTERN void AddSlashBlock (
+ Asn2gbWorkPtr awp
+);
+
+NLM_EXTERN CharPtr DefaultFormatBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatSourceBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatOrganismBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatReferenceBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatCommentBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatSourceFeatBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatFeatureBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatBasecountBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatSequenceBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatContigBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+NLM_EXTERN CharPtr FormatSlashBlock (
+ Asn2gbFormatPtr afp,
+ BaseBlockPtr bbp
+);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef NLM_EXTERN
+#ifdef NLM_EXPORT
+#define NLM_EXTERN NLM_EXPORT
+#else
+#define NLM_EXTERN
+#endif
+
+#endif /* ndef _ASN2NGNBI_ */
+
diff --git a/api/asn2gnbp.h b/api/asn2gnbp.h
index 2c550826..9ef75af3 100644
--- a/api/asn2gnbp.h
+++ b/api/asn2gnbp.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 10/21/98
*
-* $Revision: 6.27 $
+* $Revision: 6.28 $
*
* File Description: New GenBank flatfile generator, private header
*
@@ -274,6 +274,12 @@ NLM_EXTERN CharPtr asn2gnbk_dbxref (
DbtagPtr dbt
);
+/* public function to get string of genbank-style feature qualifiers */
+
+NLM_EXTERN CharPtr FormatFeatureQuals (
+ SeqFeatPtr sfp
+);
+
#ifdef __cplusplus
}
diff --git a/api/edutil.c b/api/edutil.c
index b6ea951e..6949eef2 100644
--- a/api/edutil.c
+++ b/api/edutil.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 2/4/94
*
-* $Revision: 6.20 $
+* $Revision: 6.21 $
*
* File Description: Sequence editing utilities
*
@@ -39,6 +39,9 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: edutil.c,v $
+* Revision 6.21 2003/11/03 19:37:42 bollin
+* SegLocToPartsEx now handles SEQLOC_PNT as well as SEQLOC_INT
+*
* Revision 6.20 2003/06/03 20:25:34 kans
* SeqLocReplaceID works on bonds if both ends bonded to the same Seq-id
*
@@ -441,24 +444,36 @@ NLM_EXTERN SeqLocPtr LIBCALL SegLocToPartsEx (BioseqPtr seg, SeqLocPtr slp, Bool
&split);
while (tmp2 != NULL)
{
- next = tmp2->next;
- tmp2->next = NULL;
- if (tmp2->choice == SEQLOC_INT)
- {
- if (nullsBetween && notFirst) {
- tmp3 = ValNodeNew (NULL);
- if (tmp3 != NULL) {
- tmp3->choice = SEQLOC_NULL;
- SeqLocAdd (&newloc, tmp3, TRUE, FALSE);
- }
- }
- notFirst = TRUE;
- sintp = (SeqIntPtr)(tmp2->data.ptrvalue);
- sintp->from += tstart;
- sintp->to += tstart;
- SeqLocAdd(&newloc, tmp2, TRUE, FALSE);
- }
- tmp2 = next;
+ next = tmp2->next;
+ tmp2->next = NULL;
+ if (tmp2->choice == SEQLOC_INT)
+ {
+ if (nullsBetween && notFirst) {
+ tmp3 = ValNodeNew (NULL);
+ if (tmp3 != NULL) {
+ tmp3->choice = SEQLOC_NULL;
+ SeqLocAdd (&newloc, tmp3, TRUE, FALSE);
+ }
+ }
+ notFirst = TRUE;
+ sintp = (SeqIntPtr)(tmp2->data.ptrvalue);
+ sintp->from += tstart;
+ sintp->to += tstart;
+ SeqLocAdd(&newloc, tmp2, TRUE, FALSE);
+ }
+ else if (tmp2->choice == SEQLOC_PNT)
+ {
+ if (nullsBetween && notFirst) {
+ tmp3 = ValNodeNew (NULL);
+ if (tmp3 != NULL) {
+ tmp3->choice = SEQLOC_NULL;
+ SeqLocAdd (&newloc, tmp3, TRUE, FALSE);
+ }
+ }
+ notFirst = TRUE;
+ SeqLocAdd (&newloc, tmp2, TRUE, FALSE);
+ }
+ tmp2 = next;
}
left_end = right_end + 1;
}
diff --git a/api/findrepl.c b/api/findrepl.c
index 37e91158..862d87cc 100644
--- a/api/findrepl.c
+++ b/api/findrepl.c
@@ -44,6 +44,9 @@
* RCS Modification History:
* -------------------------
* $Log: findrepl.c,v $
+* Revision 6.11 2003/11/21 17:58:46 bollin
+* remove tax ref and common name when changing taxonomy name via ASN Find/Replace
+*
* Revision 6.10 2003/07/31 20:54:54 kans
* FindReplaceString does not need do_replace argument
*
@@ -906,6 +909,30 @@ static void FindReplPubdesc (
}
}
+static void RemoveTaxRef (OrgRefPtr orp)
+{
+ ValNodePtr vnp, next;
+ ValNodePtr PNTR prev;
+ DbtagPtr dbt;
+
+ vnp = orp->db;
+ if (vnp == NULL) return;
+ prev = (ValNodePtr PNTR) &(orp->db);
+ while (vnp != NULL) {
+ next = vnp->next;
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt != NULL && StringICmp ((CharPtr) dbt->db, "taxon") == 0) {
+ *prev = vnp->next;
+ vnp->next = NULL;
+ DbtagFree (dbt);
+ ValNodeFree (vnp);
+ } else {
+ prev = (ValNodePtr PNTR) &(vnp->next);
+ }
+ vnp = next;
+ }
+}
+
static void FindReplBioSource (
BioSourcePtr biop,
OrgRefPtr orp,
@@ -916,6 +943,7 @@ static void FindReplBioSource (
OrgModPtr omp;
OrgNamePtr onp;
SubSourcePtr ssp;
+ CharPtr old_taxname;
if (biop != NULL) {
orp = biop->org;
@@ -930,7 +958,14 @@ static void FindReplBioSource (
}
}
if (orp != NULL) {
+ old_taxname = StringSave (orp->taxname);
FindReplString (&(orp->taxname), fsp);
+ if (StringCmp (old_taxname, orp->taxname) != 0)
+ {
+ RemoveTaxRef (orp);
+ orp->common = MemFree (orp->common);
+ }
+ MemFree (old_taxname);
FindReplString (&(orp->common), fsp);
FindReplStringList (orp->mod, fsp);
FindReplStringList (orp->syn, fsp);
diff --git a/api/gbparint.c b/api/gbparint.c
index 0f0bf761..fe07f1ee 100644
--- a/api/gbparint.c
+++ b/api/gbparint.c
@@ -28,6 +28,10 @@
* Author: Karl Sirotkin
*
* $Log: gbparint.c,v $
+* Revision 6.6 2003/12/05 16:42:11 bazhin
+* Nlm_gbparselex() and Nlm_gbparselex_ver() functions now can handle
+* RefSeq and WGS accessions.
+*
* Revision 6.5 2001/06/07 17:00:54 tatiana
* added gi option in Nlm_gbparselex()
*
@@ -1830,6 +1834,35 @@ NLM_EXTERN SeqLocPtr Nlm_gbreplace_ver(Boolean PNTR keep_rawPt, int PNTR parenPt
return retval;
}
+/**********************************************************/
+static int Nlm_gbparse_accprefix(CharPtr acc)
+{
+ CharPtr p;
+ int ret;
+
+ if(acc == NULL || *acc == '\0')
+ return(0);
+
+ for(p = acc; IS_ALPHA(*p) != 0;)
+ p++;
+ ret = p - acc;
+ if(*p == '_')
+ {
+ if(ret == 2)
+ {
+ for(p++; IS_ALPHA(*p) != 0;)
+ p++;
+ ret = p - acc;
+ if(ret != 3 && ret != 7)
+ ret = 1;
+ }
+ else
+ ret = 1;
+ }
+ else if(ret != 1 && ret != 2 && ret != 4)
+ ret = 1;
+ return(ret);
+}
char Saved_ch;
@@ -1919,7 +1952,7 @@ Nlm_gbparselex(CharPtr linein, ValNodePtr PNTR lexed)
case '5': case '6': case '7': case '8': case '9':
skip_new_token = FALSE;
current_token -> choice = GBPARSE_INT_NUMBER;
- for (dex=0, spare = current_col; isdigit(*spare); spare ++){
+ for (dex=0, spare = current_col; isdigit((int) *spare); spare ++){
dex ++ ;
}
current_token -> data.ptrvalue = MemNew(dex+1);
@@ -2176,19 +2209,14 @@ Nlm_gbparselex(CharPtr linein, ValNodePtr PNTR lexed)
/* new accessions have .version !! 2/15/1999 */
skip_new_token = FALSE;
current_token -> choice = GBPARSE_INT_ACCESION;
- if (IS_ALPHA(*(current_col + 1))) {
- spare = current_col + 2;
- dex = 2;
- } else {
- spare = current_col + 1;
- dex = 1;
- }
- for (; isdigit(*spare); spare ++){
+ dex = Nlm_gbparse_accprefix(current_col);
+ spare = current_col + dex;
+ for (; isdigit((int) *spare); spare ++){
dex ++ ;
}
if (*spare == '.') {
dex ++ ;
- for (spare++; isdigit(*spare); spare ++){
+ for (spare++; isdigit((int) *spare); spare ++){
dex ++ ;
}
}
@@ -2302,7 +2330,7 @@ Nlm_gbparselex_ver(CharPtr linein, ValNodePtr PNTR lexed, Boolean accver)
case '5': case '6': case '7': case '8': case '9':
skip_new_token = FALSE;
current_token -> choice = GBPARSE_INT_NUMBER;
- for (dex=0, spare = current_col; isdigit(*spare); spare ++){
+ for (dex=0, spare = current_col; isdigit((int) *spare); spare ++){
dex ++ ;
}
current_token -> data.ptrvalue = MemNew(dex+1);
@@ -2559,19 +2587,14 @@ Nlm_gbparselex_ver(CharPtr linein, ValNodePtr PNTR lexed, Boolean accver)
/* new accessions have .version !! 2/15/1999 */
skip_new_token = FALSE;
current_token -> choice = GBPARSE_INT_ACCESION;
- if (IS_ALPHA(*(current_col + 1))) {
- spare = current_col + 2;
- dex = 2;
- } else {
- spare = current_col + 1;
- dex = 1;
- }
- for (; isdigit(*spare); spare ++){
+ dex = Nlm_gbparse_accprefix(current_col);
+ spare = current_col + dex;
+ for (; isdigit((int) *spare); spare ++){
dex ++ ;
}
if (accver != FALSE && *spare == '.') {
dex ++ ;
- for (spare++; isdigit(*spare); spare ++){
+ for (spare++; isdigit((int) *spare); spare ++){
dex ++ ;
}
}
@@ -2616,7 +2639,7 @@ Nlm_gbparselex_ver(CharPtr linein, ValNodePtr PNTR lexed, Boolean accver)
NLM_EXTERN CharPtr
Nlm_non_white(CharPtr ch)
{
- while (isspace(*++ch))if (! *ch) break;
+ while (isspace((int) *++ch))if (! *ch) break;
;
return ch;
}
diff --git a/api/lsqfetch.c b/api/lsqfetch.c
index 68378ca3..d56f3026 100644
--- a/api/lsqfetch.c
+++ b/api/lsqfetch.c
@@ -37,6 +37,15 @@
* Date Name Description of modification
*
* $Log: lsqfetch.c,v $
+* Revision 6.19 2003/11/13 17:18:02 kans
+* added SearchAltIndex, finished Alt fetch for chimp revision
+*
+* Revision 6.18 2003/11/12 23:49:11 kans
+* SortIfpByID needed LIBCALLBACK for PC
+*
+* Revision 6.17 2003/11/12 23:38:48 kans
+* changing AltIndexedFastaLibFetchEnable prototype, implementation not yet finished
+*
* Revision 6.16 2003/08/27 21:24:05 kans
* enable alt indexed fasta looks up previously registered function, changes settings for new path
*
@@ -87,6 +96,15 @@
* Revision changed to 6.0
*
* $Log: lsqfetch.c,v $
+* Revision 6.19 2003/11/13 17:18:02 kans
+* added SearchAltIndex, finished Alt fetch for chimp revision
+*
+* Revision 6.18 2003/11/12 23:49:11 kans
+* SortIfpByID needed LIBCALLBACK for PC
+*
+* Revision 6.17 2003/11/12 23:38:48 kans
+* changing AltIndexedFastaLibFetchEnable prototype, implementation not yet finished
+*
* Revision 6.16 2003/08/27 21:24:05 kans
* enable alt indexed fasta looks up previously registered function, changes settings for new path
*
@@ -1374,6 +1392,18 @@ NLM_EXTERN void IndexedFastaLibFetchDisable (void)
static CharPtr altfastalibfetchproc = "AltIndexedFastaLibBioseqFetch";
+typedef struct idfip {
+ CharPtr seqid;
+ FastaIndexPtr fip;
+} IdFip, PNTR IdFipPtr;
+
+typedef struct alibftch {
+ CharPtr path;
+ ValNodePtr fiplist;
+ IdFipPtr index;
+ Int4 numids;
+} AltLibFetchData, PNTR AltLibFetchPtr;
+
static void ChangeLocalToGenbank (BioseqPtr bsp, Pointer userdata)
{
@@ -1390,38 +1420,79 @@ static void ChangeLocalToGenbank (BioseqPtr bsp, Pointer userdata)
SeqMgrReplaceInBioseqIndex (bsp);
}
+static FastaIndexPtr SearchAltIndex (
+ AltLibFetchPtr alfp,
+ CharPtr seqid
+)
+
+{
+ int compare;
+ IdFipPtr ifp;
+ Int4 L, R, mid;
+
+ if (alfp == NULL || alfp->index == NULL) return NULL;
+ ifp = alfp->index;
+ if (StringHasNoText (seqid)) return NULL;
+
+ L = 0;
+ R = alfp->numids - 1;
+ while (L < R) {
+ mid = (L + R) / 2;
+ compare = StringICmp (ifp [mid].seqid, seqid);
+ if (compare < 0) {
+ L = mid + 1;
+ } else {
+ R = mid;
+ }
+ }
+
+ if (StringICmp (ifp [R].seqid, seqid) == 0) {
+ return ifp [R].fip;
+ }
+
+ return NULL;
+}
+
static Int2 LIBCALLBACK AltIndexedFastaLibBioseqFetchFunc (Pointer data)
{
+ AltLibFetchPtr alfp;
BioseqPtr bsp;
Pointer dataptr = NULL;
Uint2 datatype, entityID = 0;
Char file [FILENAME_MAX], path [PATH_MAX], id [41];
- FastaLibFetchPtr flfp;
+ FastaIndexPtr fip;
FILE *fp;
Int4 offset;
OMProcControlPtr ompcp;
ObjMgrProcPtr ompp;
SeqEntryPtr sep = NULL;
SeqIdPtr sip;
+ CharPtr tmp;
ompcp = (OMProcControlPtr) data;
if (ompcp == NULL) return OM_MSG_RET_ERROR;
ompp = ompcp->proc;
if (ompp == NULL) return OM_MSG_RET_ERROR;
- flfp = (FastaLibFetchPtr) ompp->procdata;
- if (flfp == NULL) return OM_MSG_RET_ERROR;
+ alfp = (AltLibFetchPtr) ompp->procdata;
+ if (alfp == NULL) return OM_MSG_RET_ERROR;
sip = (SeqIdPtr) ompcp->input_data;
if (sip == NULL) return OM_MSG_RET_ERROR;
if (sip->choice == SEQID_GENBANK) {
SeqIdWrite (sip, id, PRINTID_REPORT, sizeof (id));
- if (flfp->currentfip != NULL) {
- offset = SearchFastaIndex (flfp->currentfip, id);
+ fip = SearchAltIndex (alfp, id);
+ if (fip != NULL) {
+ offset = SearchFastaIndex (fip, id);
if (offset < 0) return OM_MSG_RET_ERROR;
- sprintf (file, "%s.fsa", flfp->fastaname);
- StringNCpy_0 (path, flfp->path, sizeof (path));
+ StringCpy (file, fip->file);
+ tmp = StringStr (file, ".idx");
+ if (tmp != NULL) {
+ *tmp = '\0';
+ }
+ StringCat (file, ".fa");
+ StringNCpy_0 (path, fip->path, sizeof (path));
FileBuildPath (path, NULL, file);
fp = FileOpen (path, "r");
if (fp == NULL) return OM_MSG_RET_ERROR;
@@ -1443,41 +1514,94 @@ static Int2 LIBCALLBACK AltIndexedFastaLibBioseqFetchFunc (Pointer data)
return OM_MSG_RET_DONE;
}
-NLM_EXTERN Boolean AltIndexedFastaLibFetchEnable (CharPtr path, CharPtr fastaname)
+static int LIBCALLBACK SortIfpByID (VoidPtr vp1, VoidPtr vp2)
{
- Char file [FILENAME_MAX];
- FastaLibFetchPtr flfp = NULL;
- Boolean is_new = FALSE;
- ObjMgrPtr omp;
- ObjMgrProcPtr ompp;
- Char str [PATH_MAX];
+ IdFipPtr ifp1, ifp2;
+
+ if (vp1 == NULL || vp2 == NULL) return 0;
+ ifp1 = (IdFipPtr) vp1;
+ ifp2 = (IdFipPtr) vp2;
+ if (ifp1 == NULL || ifp2 == NULL) return 0;
+ return StringICmp (ifp1->seqid, ifp2->seqid);
+}
+
+NLM_EXTERN Boolean AltIndexedFastaLibFetchEnable (CharPtr path)
+
+{
+ AltLibFetchPtr alfp = NULL;
+ Char file [FILENAME_MAX];
+ FastaIndexPtr fip;
+ ValNodePtr head;
+ Int4 i;
+ IdFipPtr ifp;
+ Boolean is_new = FALSE;
+ Int4 j;
+ Int4 numids = 0;
+ ObjMgrPtr omp;
+ ObjMgrProcPtr ompp;
+ Char str [PATH_MAX];
+ CharPtr tmp;
+ ValNodePtr vnp;
StringNCpy_0 (str, path, sizeof (str));
TrimSpacesAroundString (str);
omp = ObjMgrGet ();
ompp = ObjMgrProcFind (omp, 0, altfastalibfetchproc, OMPROC_FETCH);
if (ompp != NULL) {
- flfp = (FastaLibFetchPtr) ompp->procdata;
- if (flfp != NULL) {
- flfp->path = MemFree (flfp->path);
- flfp->fastaname = MemFree (flfp->fastaname);
- flfp->currentfip = FreeFastaIndex (flfp->currentfip);
+ alfp = (AltLibFetchPtr) ompp->procdata;
+ if (alfp != NULL) {
+ alfp->path = MemFree (alfp->path);
+ for (vnp = alfp->fiplist; vnp != NULL; vnp = vnp->next) {
+ fip = (FastaIndexPtr) vnp->data.ptrvalue;
+ FreeFastaIndex (fip);
+ }
+ alfp->fiplist = ValNodeFree (alfp->fiplist);
+ alfp->index = MemFree (alfp->index);
}
} else {
- flfp = (FastaLibFetchPtr) MemNew (sizeof (FastaLibFetchData));
+ alfp = (AltLibFetchPtr) MemNew (sizeof (AltLibFetchData));
is_new = TRUE;
}
- if (flfp != NULL) {
- flfp->path = StringSave (str);
- flfp->fastaname = StringSave (fastaname);
- sprintf (file, "%s.idx", fastaname);
- FileBuildPath (str, NULL, file);
- flfp->currentfip = ReadFastaIndex (str);
+ if (alfp != NULL) {
+ alfp->path = StringSave (str);
+ head = DirCatalog (str);
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == 0) {
+ tmp = (CharPtr) vnp->data.ptrvalue;
+ if (StringStr (tmp, ".idx") != NULL) {
+ StringCpy (str, alfp->path);
+ sprintf (file, "%s", tmp);
+ FileBuildPath (str, NULL, file);
+ fip = ReadFastaIndex (str);
+ if (fip != NULL) {
+ ValNodeAddPointer (&(alfp->fiplist), 0, (Pointer) fip);
+ numids += fip->numlines;
+ }
+ }
+ }
+ }
+ ValNodeFreeData (head);
+ ifp = (IdFipPtr) MemNew (sizeof (IdFip) * (numids + 2));
+ alfp->index = ifp;
+ alfp->numids = numids;
+ if (ifp != NULL) {
+ i = 0;
+ for (vnp = alfp->fiplist; vnp != NULL; vnp = vnp->next) {
+ fip = (FastaIndexPtr) vnp->data.ptrvalue;
+ if (fip != NULL) {
+ for (j = 0; j < fip->numlines; j++, i++) {
+ ifp [i].seqid = fip->seqids [j];
+ ifp [i].fip = fip;
+ }
+ }
+ }
+ HeapSort (ifp, (size_t) numids, sizeof (IdFip), SortIfpByID);
+ }
}
if (is_new) {
ObjMgrProcLoad (OMPROC_FETCH, altfastalibfetchproc, altfastalibfetchproc,
- OBJ_SEQID, 0, OBJ_BIOSEQ, 0, (Pointer) flfp,
+ OBJ_SEQID, 0, OBJ_BIOSEQ, 0, (Pointer) alfp,
AltIndexedFastaLibBioseqFetchFunc, PROC_PRIORITY_DEFAULT);
}
return TRUE;
@@ -1486,20 +1610,26 @@ NLM_EXTERN Boolean AltIndexedFastaLibFetchEnable (CharPtr path, CharPtr fastanam
NLM_EXTERN void AltIndexedFastaLibFetchDisable (void)
{
- FastaLibFetchPtr flfp;
- ObjMgrPtr omp;
- ObjMgrProcPtr ompp;
+ AltLibFetchPtr alfp;
+ FastaIndexPtr fip;
+ ObjMgrPtr omp;
+ ObjMgrProcPtr ompp;
+ ValNodePtr vnp;
omp = ObjMgrGet ();
ompp = ObjMgrProcFind (omp, 0, altfastalibfetchproc, OMPROC_FETCH);
if (ompp == NULL) return;
ObjMgrFreeUserData (0, ompp->procid, OMPROC_FETCH, 0);
- flfp = (FastaLibFetchPtr) ompp->procdata;
- if (flfp == NULL) return;
- MemFree (flfp->path);
- MemFree (flfp->fastaname);
- FreeFastaIndex (flfp->currentfip);
- MemFree (flfp);
+ alfp = (AltLibFetchPtr) ompp->procdata;
+ if (alfp == NULL) return;
+ alfp->path = MemFree (alfp->path);
+ for (vnp = alfp->fiplist; vnp != NULL; vnp = vnp->next) {
+ fip = (FastaIndexPtr) vnp->data.ptrvalue;
+ FreeFastaIndex (fip);
+ }
+ alfp->fiplist = ValNodeFree (alfp->fiplist);
+ alfp->index = MemFree (alfp->index);
+ MemFree (alfp);
}
/* common function for creating indexes of fasta library files */
diff --git a/api/lsqfetch.h b/api/lsqfetch.h
index 52a59363..55ad3377 100644
--- a/api/lsqfetch.h
+++ b/api/lsqfetch.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 5/25/95
*
-* $Revision: 6.3 $
+* $Revision: 6.4 $
*
* File Description: Utilities for fetching local sequences
*
@@ -40,6 +40,9 @@
*
*
* $Log: lsqfetch.h,v $
+* Revision 6.4 2003/11/12 23:38:49 kans
+* changing AltIndexedFastaLibFetchEnable prototype, implementation not yet finished
+*
* Revision 6.3 2003/08/27 19:27:43 kans
* added AltIndexedFastaLibFetch functions for chimpanzee genome project
*
@@ -254,9 +257,9 @@ NLM_EXTERN Boolean CheckDnaResidue PROTO((CharPtr seq_ptr, Int4 ck_len, Int4Ptr
NLM_EXTERN Boolean IndexedFastaLibFetchEnable (CharPtr path);
NLM_EXTERN void IndexedFastaLibFetchDisable (void);
-/* alternative indexed FASTA lib functions - currently uses chimpanzee genome contig naming convention */
+/* alternative indexed FASTA lib functions - currently uses new chimpanzee genome contig naming convention */
-NLM_EXTERN Boolean AltIndexedFastaLibFetchEnable (CharPtr path, CharPtr fastaname);
+NLM_EXTERN Boolean AltIndexedFastaLibFetchEnable (CharPtr path);
NLM_EXTERN void AltIndexedFastaLibFetchDisable (void);
/* common function for creating indexes of fasta library files */
diff --git a/api/objmgr.c b/api/objmgr.c
index 0bcdbf29..a9ad80df 100644
--- a/api/objmgr.c
+++ b/api/objmgr.c
@@ -29,13 +29,16 @@
*
* Version Creation Date: 9/94
*
-* $Revision: 6.49 $
+* $Revision: 6.50 $
*
* File Description: Manager for Bioseqs and BioseqSets
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: objmgr.c,v $
+* Revision 6.50 2003/12/22 15:29:28 kans
+* ObjMgrSendMsg calls SeqMgrClearFeatureIndexes on OM_MSG_DEL as well as OM_MSG_UPDATE
+*
* Revision 6.49 2002/07/30 14:41:45 kans
* removed omdp->rearranged
*
@@ -4416,7 +4419,8 @@ NLM_EXTERN Boolean LIBCALL ObjMgrSendMsg(Uint2 msg, Uint2 entityID, Uint2 itemID
if (msg == OM_MSG_UPDATE) {
SeqMgrClearFeatureIndexes (entityID, NULL);
- }
+ } else if (msg == OM_MSG_DEL)
+ SeqMgrClearFeatureIndexes (entityID, NULL);
omp = ObjMgrReadLock();
omdp = ObjMgrFindByEntityID(omp, entityID, NULL);
if (omdp != NULL)
diff --git a/api/salpedit.c b/api/salpedit.c
index ae017372..5fd26dfd 100644
--- a/api/salpedit.c
+++ b/api/salpedit.c
@@ -1,3 +1,4 @@
+/* $Id: salpedit.c,v 6.31 2003/11/07 21:22:06 kans Exp $ */
#include <ncbi.h>
#include <ncbimisc.h> /* ValNodeLen */
#include <sequtil.h> /* for GetScoreAndEvalue, SeqIdDupList */
@@ -2199,7 +2200,7 @@ static void sort_list_order(ValNodePtr PNTR ph_list, Uint1 strand)
}
}
- /*
+#if 0
{
FILE *tmp_fp;
tmp_fp = FileOpen("Ins.test", "w");
@@ -2222,7 +2223,7 @@ static void sort_list_order(ValNodePtr PNTR ph_list, Uint1 strand)
Message(MSG_ERROR, "Fail in get_lns");
exit(1);
}
- // inconsistent orientation from LNS //
+ /* inconsistent orientation from LNS */
if((strand == Seq_strand_minus && val == 0) ||
(strand != Seq_strand_minus && val== 1))
{
@@ -2245,7 +2246,7 @@ static void sort_list_order(ValNodePtr PNTR ph_list, Uint1 strand)
}
FileClose(tmp_fp);
}
-*/
+#endif
delete_bad_node(&h_list, 1);
if(h_list == NULL)
diff --git a/api/seqmgr.c b/api/seqmgr.c
index 9994a256..d90546fc 100644
--- a/api/seqmgr.c
+++ b/api/seqmgr.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 9/94
*
-* $Revision: 6.210 $
+* $Revision: 6.212 $
*
* File Description: Manager for Bioseqs and BioseqSets
*
@@ -39,6 +39,12 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: seqmgr.c,v $
+* Revision 6.212 2003/12/12 20:59:48 kans
+* added StrandsMatch to consolate code after TestForOverlap, allow both on candidate to be treated as plus
+*
+* Revision 6.211 2003/11/13 21:59:24 kans
+* GetSeqIdForGI separates SEQID_OTHER from other types, so RefSeq takes higher priority over General
+*
* Revision 6.210 2003/10/24 19:49:11 kans
* operon feature of equal range sorted before gene, mRNA, CDS
*
@@ -2095,7 +2101,7 @@ NLM_EXTERN SeqIdPtr LIBCALL GetSeqIdForGI (Int4 gi)
ObjMgrProcPtr ompp;
OMProcControl ompc;
Int2 ret;
- SeqIdPtr sip, sip2=NULL, other=NULL, gb=NULL;
+ SeqIdPtr sip, sip2=NULL, otherh=NULL, otherl = NULL, gb=NULL;
ValNode vn;
@@ -2118,7 +2124,7 @@ NLM_EXTERN SeqIdPtr LIBCALL GetSeqIdForGI (Int4 gi)
case SEQID_GIBBMT:
case SEQID_PATENT:
case SEQID_GENERAL:
- other = sip;
+ otherl = sip;
break;
case SEQID_GI:
break;
@@ -2135,8 +2141,8 @@ NLM_EXTERN SeqIdPtr LIBCALL GetSeqIdForGI (Int4 gi)
gb = sip;
break;
default:
- if (other == NULL)
- other = sip;
+ if (otherh == NULL)
+ otherh = sip;
break;
}
}
@@ -2145,8 +2151,10 @@ NLM_EXTERN SeqIdPtr LIBCALL GetSeqIdForGI (Int4 gi)
if (gb != NULL)
sip2 = gb;
- else if (other != NULL)
- sip2 = other;
+ else if (otherh != NULL)
+ sip2 = otherh;
+ else if (otherl != NULL)
+ sip2 = otherl;
if (sip2 != NULL)
return SeqIdDup(sip2);
@@ -7670,6 +7678,17 @@ static Boolean CheckInternalExonBoundaries (Int2 numivalsA, Int4Ptr ivalsA, Int2
return TRUE;
}
+static Boolean StrandsMatch (Uint1 featstrand, Uint1 locstrand)
+
+{
+ if (featstrand == locstrand) return TRUE;
+ if (locstrand == Seq_strand_unknown && featstrand != Seq_strand_minus) return TRUE;
+ if (featstrand == Seq_strand_unknown && locstrand != Seq_strand_minus) return TRUE;
+ if (featstrand == Seq_strand_both && locstrand != Seq_strand_minus) return TRUE;
+ if (locstrand == Seq_strand_both) return TRUE;
+ return FALSE;
+}
+
static Int4 TestForOverlap (SMFeatItemPtr feat, SeqLocPtr slp,
Int4 left, Int4 right, Int2 overlapType,
Int2 numivals, Int4Ptr ivals)
@@ -7972,10 +7991,7 @@ static SeqFeatPtr SeqMgrGetBestOverlappingFeat (SeqLocPtr slp, Uint2 subtype,
diff = TestForOverlap (feat, slp, left, right, overlapType, numivals, ivals);
if (diff >= 0) {
- if (feat->strand == strand ||
- (strand == Seq_strand_unknown && feat->strand != Seq_strand_minus) ||
- (feat->strand == Seq_strand_unknown && strand != Seq_strand_minus) ||
- strand == Seq_strand_both) {
+ if (StrandsMatch (feat->strand, strand)) {
if (userfunc != NULL && context != NULL && goOn) {
SeqMgrBestOverlapSetContext (feat, omdp, userdata, context);
@@ -8009,9 +8025,7 @@ static SeqFeatPtr SeqMgrGetBestOverlappingFeat (SeqLocPtr slp, Uint2 subtype,
diff = TestForOverlap (feat, slp, left, right, overlapType, numivals, ivals);
if (diff >= 0) {
- if (feat->strand == strand ||
- (strand == Seq_strand_unknown && feat->strand != Seq_strand_minus) ||
- (feat->strand == Seq_strand_unknown && strand != Seq_strand_minus)) {
+ if (StrandsMatch (feat->strand, strand)) {
if (userfunc != NULL && context != NULL && goOn) {
SeqMgrBestOverlapSetContext (feat, omdp, userdata, context);
@@ -8069,10 +8083,7 @@ NLM_EXTERN Int4 TestFeatOverlap (SeqFeatPtr sfpA, SeqFeatPtr sfpB, Int2 overlapT
overlapType, sfipA->numivals, sfipA->ivals);
if (diff < 0) return -1;
- if (sfipB->strand == sfipA->strand ||
- (sfipA->strand == Seq_strand_unknown && sfipB->strand != Seq_strand_minus) ||
- (sfipB->strand == Seq_strand_unknown && sfipA->strand != Seq_strand_minus) ||
- sfipA->strand == Seq_strand_both) {
+ if (StrandsMatch (sfipB->strand, sfipA->strand)) {
return diff;
}
diff --git a/api/seqport.c b/api/seqport.c
index a42d70d3..50190746 100644
--- a/api/seqport.c
+++ b/api/seqport.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/13/91
*
-* $Revision: 6.82 $
+* $Revision: 6.86 $
*
* File Description: Ports onto Bioseqs
*
@@ -39,6 +39,18 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: seqport.c,v $
+* Revision 6.86 2003/11/18 17:08:46 kans
+* added MapNa4ByteTo4BitString, use in seqport read and get char
+*
+* Revision 6.85 2003/11/18 16:23:05 kans
+* fixed InitNa2to4Bit, use MapNa2ByteTo4BitString in SeqPortQuickGetResidue
+*
+* Revision 6.84 2003/11/17 22:44:31 kans
+* added MapNa2ByteTo4BitString in preparation for faster SeqPortRead from 2na to 4na
+*
+* Revision 6.83 2003/11/05 21:17:22 bollin
+* added new option for Retranslate Coding Regions to handle stop codons at end of complete CDS during retranslate while ignoring stop codons
+*
* Revision 6.82 2003/08/18 21:07:35 kans
* RevCompStr was stepping on str variable
*
@@ -420,6 +432,8 @@ NLM_EXTERN Boolean LIBCALL SeqPortAdjustLength (SeqPortPtr spp);
static Uint1Ptr Na2toIUPAC = NULL;
static Uint1Ptr Na4toIUPAC = NULL;
static Uint1Ptr Na2toNa4 = NULL;
+static Uint1Ptr Na2to4Bit = NULL;
+static Uint1Ptr Na4to4Bit = NULL;
static TNlmMutex seqport_mutex = NULL;
@@ -661,6 +675,160 @@ NLM_EXTERN Uint2Ptr LIBCALL MapNa2ByteToNa4String (Uint1Ptr bytep, Uint2Ptr buf,
return ptr;
}
+static void InitNa2to4Bit (void)
+
+{
+ Int2 base [4], index, j;
+ Uint1 convert [4] = {1, 2, 4, 8};
+ Int4 ret;
+ Uint1Ptr Na2to4Bit_local = NULL;
+
+ ret = NlmMutexLockEx (&seqport_mutex); /* protect this section */
+ if (ret) {
+ ErrPostEx (SEV_FATAL, 0, 0, "MapNa2ByteTo4BitString mutex failed [%ld]", (long) ret);
+ return;
+ }
+
+ if (Na2to4Bit == NULL) {
+ Na2to4Bit_local = MemNew (sizeof (Uint1) * 1024);
+
+ if (Na2to4Bit_local != NULL) {
+ for (base [0] = 0; base [0] < 4; (base [0])++) {
+ for (base [1] = 0; base [1] < 4; (base [1])++) {
+ for (base [2] = 0; base [2] < 4; (base [2])++) {
+ for (base [3] = 0; base [3] < 4; (base [3])++) {
+ index = 4 * (base [0] * 64 + base [1] * 16 + base [2] * 4 + base [3]);
+ for (j = 0; j < 4; j++) {
+ Na2to4Bit_local [index + j] = convert [(base [j])];
+ }
+ }
+ }
+ }
+ }
+ }
+ Na2to4Bit = Na2to4Bit_local;
+ }
+
+ NlmMutexUnlock (seqport_mutex);
+}
+
+NLM_EXTERN Uint4Ptr LIBCALL MapNa2ByteTo4BitString (Uint1Ptr bytep, Uint4Ptr buf, Int4 total)
+
+{
+ Uint4Ptr bp;
+ Uint1 byte;
+ Int2 index;
+ Int4 k;
+ Uint4Ptr ptr;
+
+ if (bytep == NULL || buf == NULL) return buf;
+ ptr = buf;
+
+ /* initialize array if not yet set (first time function is called) */
+
+ if (Na2to4Bit == NULL) {
+ InitNa2to4Bit ();
+ }
+
+ if (Na2to4Bit == NULL) return buf;
+
+ /* now return 4 byte string for each compressed byte */
+
+ for (k = 0; k < total; k++) {
+ byte = *bytep;
+ bytep++;
+ index = 4 * byte;
+ bp = (Uint4Ptr) (Na2to4Bit + index);
+ /* copy 4 bytes at a time */
+ /*
+ for (j = 0; j < 4; j++) {
+ *ptr = *bp;
+ ptr++;
+ bp++;
+ }
+ */
+ *ptr = *bp;
+ ptr++;
+ }
+
+ return ptr;
+}
+
+static void InitNa4to4Bit (void)
+
+{
+ Int2 base [2], index, j;
+ Char convert [16] = {15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ Int4 ret;
+ Uint1Ptr Na4to4Bit_local = NULL;
+
+ ret = NlmMutexLockEx (&seqport_mutex); /* protect this section */
+ if (ret) {
+ ErrPostEx (SEV_FATAL, 0, 0, "MapNa4ByteToIUPACString mutex failed [%ld]", (long) ret);
+ return;
+ }
+
+ if (Na4to4Bit == NULL) {
+ Na4to4Bit_local = MemNew (sizeof (Uint1) * 512);
+
+ if (Na4to4Bit_local != NULL) {
+ for (base [0] = 0; base [0] < 16; (base [0])++) {
+ for (base [1] = 0; base [1] < 16; (base [1])++) {
+ index = 2 * (base [0] * 16 + base [1]);
+ for (j = 0; j < 2; j++) {
+ Na4to4Bit_local [index + j] = convert [(base [j])];
+ }
+ }
+ }
+ }
+ Na4to4Bit = Na4to4Bit_local;
+ }
+
+ NlmMutexUnlock (seqport_mutex);
+}
+
+NLM_EXTERN Uint2Ptr LIBCALL MapNa4ByteTo4BitString (Uint1Ptr bytep, Uint2Ptr buf, Int4 total)
+
+{
+ Uint2Ptr bp;
+ Uint1 byte;
+ Int2 index;
+ Int4 k;
+ Uint2Ptr ptr;
+
+ if (bytep == NULL || buf == NULL) return buf;
+ ptr = buf;
+
+ /* initialize array if not yet set (first time function is called) */
+
+ if (Na4to4Bit == NULL) {
+ InitNa4to4Bit ();
+ }
+
+ if (Na4to4Bit == NULL) return buf;
+
+ /* now return 2 character string for each compressed byte */
+
+ for (k = 0; k < total; k++) {
+ byte = *bytep;
+ bytep++;
+ index = 2 * byte;
+ bp = (Uint2Ptr) (Na4to4Bit + index);
+ /* copy 2 bytes at a time */
+ /*
+ for (j = 0; j < 2; j++) {
+ *ptr = *bp;
+ ptr++;
+ bp++;
+ }
+ */
+ *ptr = *bp;
+ ptr++;
+ }
+
+ return ptr;
+}
+
/*****************************************************************************
*
* SeqPort Routines
@@ -1210,11 +1378,10 @@ SeqLocFindNext((SeqLocPtr)(currchunk->data.ptrvalue), currseg);
SeqPortSetUpAlphabet(spp, curr_code, newcode);
spp->bp = bsp->seq_data;
- /* allocate fast lookup caches for 2na or 4na to iupacna conversion */
+ /* allocate fast lookup caches for 2na or 4na to iupacna or 4na conversion */
- if (newcode == Seq_code_iupacna &&
- (curr_code == Seq_code_ncbi2na ||
- curr_code == Seq_code_ncbi4na)) {
+ if ((newcode == Seq_code_iupacna || newcode == Seq_code_ncbi4na) &&
+ (curr_code == Seq_code_ncbi2na || curr_code == Seq_code_ncbi4na)) {
spp->cacheq = (SPCacheQPtr) MemNew (sizeof (SPCacheQ));
}
@@ -1656,10 +1823,18 @@ static Uint1 LIBCALL SeqPortQuickGetResidue (SeqPortPtr spp, SPCacheQPtr spcpq,
ptr = spcpq->buf;
- if (spp->oldcode == Seq_code_ncbi2na) {
- ptr = (CharPtr) MapNa2ByteToIUPACString (bytes, (Uint4Ptr) ptr, total);
- } else if (spp->oldcode == Seq_code_ncbi4na) {
- ptr = (CharPtr) MapNa4ByteToIUPACString (bytes, (Uint2Ptr) ptr, total);
+ if (spp->newcode == Seq_code_iupacna) {
+ if (spp->oldcode == Seq_code_ncbi2na) {
+ ptr = (CharPtr) MapNa2ByteToIUPACString (bytes, (Uint4Ptr) ptr, total);
+ } else if (spp->oldcode == Seq_code_ncbi4na) {
+ ptr = (CharPtr) MapNa4ByteToIUPACString (bytes, (Uint2Ptr) ptr, total);
+ }
+ } else if (spp->newcode == Seq_code_ncbi4na) {
+ if (spp->oldcode == Seq_code_ncbi2na) {
+ ptr = (CharPtr) MapNa2ByteTo4BitString (bytes, (Uint4Ptr) ptr, total);
+ } else if (spp->oldcode == Seq_code_ncbi4na) {
+ ptr = (CharPtr) MapNa4ByteTo4BitString (bytes, (Uint2Ptr) ptr, total);
+ }
}
spcpq->total = ptr - spcpq->buf;
@@ -2441,7 +2616,70 @@ NLM_EXTERN ByteStorePtr ProteinFromCdRegionEx (SeqFeatPtr sfp, Boolean include_s
tbl = (TransTablePtr) GetAppProperty (str);
tableExists = (Boolean) (tbl != NULL);
- bs = TransTableTranslateCdRegion (&tbl, sfp, include_stop, remove_trailingX);
+ bs = TransTableTranslateCdRegion (&tbl, sfp, include_stop, remove_trailingX,
+ FALSE);
+
+ /* save FSA in genetic code-specific app property name */
+
+ if (! tableExists) {
+ SetAppProperty (str, (Pointer) tbl);
+ }
+
+ return bs;
+}
+
+NLM_EXTERN ByteStorePtr ProteinFromCdRegionExWithTrailingCodonHandling
+(
+ SeqFeatPtr sfp,
+ Boolean include_stop,
+ Boolean remove_trailingX,
+ Boolean no_stop_at_end_of_complete_cds
+)
+
+{
+ ByteStorePtr bs;
+ CdRegionPtr crp;
+ Int2 genCode = 0;
+ Char str [32];
+ Boolean tableExists = FALSE;
+ TransTablePtr tbl = NULL;
+ ValNodePtr vnp;
+
+ if (sfp == NULL || sfp->data.choice != SEQFEAT_CDREGION) return NULL;
+ crp = (CdRegionPtr) sfp->data.value.ptrvalue;
+ if (crp == NULL) return NULL;
+
+ /* find genetic code */
+
+ if (crp->genetic_code != NULL) {
+ vnp = (ValNodePtr) crp->genetic_code->data.ptrvalue;
+ while (vnp != NULL) {
+ if (vnp->choice == 2) {
+ genCode = (Int2) vnp->data.intvalue;
+ }
+ vnp = vnp->next;
+ }
+ }
+
+ if (genCode == 7) {
+ genCode = 4;
+ } else if (genCode == 8) {
+ genCode = 1;
+ } else if (genCode == 0) {
+ genCode = 1;
+ }
+
+ /* set app property name for storing desired FSA */
+
+ sprintf (str, "TransTableFSAforGenCode%d", (int) genCode);
+
+ /* get FSA for desired genetic code if it already exists */
+
+ tbl = (TransTablePtr) GetAppProperty (str);
+ tableExists = (Boolean) (tbl != NULL);
+
+ bs = TransTableTranslateCdRegion (&tbl, sfp, include_stop, remove_trailingX,
+ no_stop_at_end_of_complete_cds);
/* save FSA in genetic code-specific app property name */
@@ -4944,7 +5182,8 @@ static ByteStorePtr TransTableTranslateCommon (
Uint1 frame,
CodeBreakPtr code_break,
Boolean include_stop,
- Boolean remove_trailingX
+ Boolean remove_trailingX,
+ Boolean no_stop_at_end_of_complete_cds
)
{
@@ -5084,7 +5323,10 @@ static ByteStorePtr TransTableTranslateCommon (
}
is_first = FALSE;
- if ((! include_stop) && aa == '*') {
+ if (aa == '*'
+ && (! include_stop
+ || (no_stop_at_end_of_complete_cds && ! partial && *(txt + 1) == 0)))
+ {
got_stop = TRUE;
residue = '\0'; /* signal end of loop */
@@ -5152,14 +5394,16 @@ NLM_EXTERN ByteStorePtr TransTableTranslateSeqLoc (
{
return TransTableTranslateCommon (tblptr, location, NULL, FALSE, genCode,
- frame, NULL, include_stop, remove_trailingX);
+ frame, NULL, include_stop,
+ remove_trailingX, FALSE);
}
NLM_EXTERN ByteStorePtr TransTableTranslateCdRegion (
TransTablePtr PNTR tblptr,
SeqFeatPtr cds,
Boolean include_stop,
- Boolean remove_trailingX
+ Boolean remove_trailingX,
+ Boolean no_stop_at_end_of_complete_cds
)
{
@@ -5185,7 +5429,8 @@ NLM_EXTERN ByteStorePtr TransTableTranslateCdRegion (
return TransTableTranslateCommon (tblptr, cds->location, cds->product, cds->partial,
genCode, crp->frame, crp->code_break,
- include_stop, remove_trailingX);
+ include_stop, remove_trailingX,
+ no_stop_at_end_of_complete_cds);
}
/* allow reuse of translation tables by saving as AppProperty */
diff --git a/api/seqport.h b/api/seqport.h
index 37709155..5be68a8f 100644
--- a/api/seqport.h
+++ b/api/seqport.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/13/91
*
-* $Revision: 6.33 $
+* $Revision: 6.36 $
*
* File Description: Ports onto Bioseqs
*
@@ -40,6 +40,15 @@
*
*
* $Log: seqport.h,v $
+* Revision 6.36 2003/11/18 17:08:46 kans
+* added MapNa4ByteTo4BitString, use in seqport read and get char
+*
+* Revision 6.35 2003/11/17 22:44:31 kans
+* added MapNa2ByteTo4BitString in preparation for faster SeqPortRead from 2na to 4na
+*
+* Revision 6.34 2003/11/05 21:17:22 bollin
+* added new option for Retranslate Coding Regions to handle stop codons at end of complete CDS during retranslate while ignoring stop codons
+*
* Revision 6.33 2002/11/11 18:02:40 kans
* added SeqPortStream to efficiently stream through a sequence
*
@@ -344,6 +353,9 @@ Uint2 or Uint4 for fast integer copying.
NLM_EXTERN Uint4Ptr LIBCALL MapNa2ByteToIUPACString PROTO((Uint1Ptr bytep, Uint4Ptr buf, Int4 total));
NLM_EXTERN Uint2Ptr LIBCALL MapNa4ByteToIUPACString PROTO((Uint1Ptr bytep, Uint2Ptr buf, Int4 total));
NLM_EXTERN Uint2Ptr LIBCALL MapNa2ByteToNa4String PROTO((Uint1Ptr bytep, Uint2Ptr buf, Int4 total));
+NLM_EXTERN Uint4Ptr LIBCALL MapNa2ByteTo4BitString PROTO((Uint1Ptr bytep, Uint4Ptr buf, Int4 total));
+NLM_EXTERN Uint2Ptr LIBCALL MapNa4ByteTo4BitString PROTO((Uint1Ptr bytep, Uint2Ptr buf, Int4 total));
+
/*****************************************************************************
*
@@ -420,6 +432,7 @@ NLM_EXTERN Uint4 BioseqHash PROTO((BioseqPtr bsp));
*****************************************************************************/
NLM_EXTERN ByteStorePtr ProteinFromCdRegion PROTO(( SeqFeatPtr sfp, Boolean include_stop));
NLM_EXTERN ByteStorePtr ProteinFromCdRegionEx PROTO((SeqFeatPtr sfp, Boolean include_stop, Boolean remove_trailingX));
+NLM_EXTERN ByteStorePtr ProteinFromCdRegionExWithTrailingCodonHandling PROTO((SeqFeatPtr sfp, Boolean include_stop, Boolean remove_trailingX, Boolean no_stop_at_end_of_complete_cds));
/*****************************************************************************
*
@@ -662,7 +675,8 @@ NLM_EXTERN ByteStorePtr TransTableTranslateCdRegion (
TransTablePtr PNTR tblptr,
SeqFeatPtr cds,
Boolean include_stop,
- Boolean remove_trailingX
+ Boolean remove_trailingX,
+ Boolean no_stop_at_end_of_complete_cds
);
NLM_EXTERN ByteStorePtr TransTableTranslateSeqLoc (
diff --git a/api/sequtil.c b/api/sequtil.c
index 6b014789..cac63358 100644
--- a/api/sequtil.c
+++ b/api/sequtil.c
@@ -29,13 +29,28 @@
*
* Version Creation Date: 4/1/91
*
-* $Revision: 6.139 $
+* $Revision: 6.144 $
*
* File Description: Sequence Utilities for objseq and objsset
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: sequtil.c,v $
+* Revision 6.144 2004/01/16 16:37:01 kans
+* added CM as scaffold/CON record
+*
+* Revision 6.143 2003/12/18 19:35:53 kans
+* added CQ and CR prefixes
+*
+* Revision 6.142 2003/12/16 16:03:04 kans
+* added CL as ncbi gss
+*
+* Revision 6.141 2003/11/10 16:12:33 kans
+* added CK as genbank est
+*
+* Revision 6.140 2003/10/31 20:51:24 kans
+* added CI and CJ as DDBJ ESTs to WHICH_db_accession
+*
* Revision 6.139 2003/10/24 14:36:12 kans
* added CH as GenBank CONN to WHICH_db_accession
*
@@ -8765,7 +8780,8 @@ NLM_EXTERN Uint4 LIBCALL WHICH_db_accession (CharPtr s)
(StringICmp(temp,"CA") == 0) ||
(StringICmp(temp,"CB") == 0) ||
(StringICmp(temp,"CD") == 0) ||
- (StringICmp(temp,"CF") == 0) ) { /* NCBI EST */
+ (StringICmp(temp,"CF") == 0) ||
+ (StringICmp(temp,"CK") == 0) ) { /* NCBI EST */
retcode = ACCN_NCBI_EST;
} else if ((StringICmp(temp,"BV") == 0)) { /* NCBI STS */
retcode = ACCN_NCBI_STS;
@@ -8777,7 +8793,8 @@ NLM_EXTERN Uint4 LIBCALL WHICH_db_accession (CharPtr s)
} else if ((StringICmp(temp,"AE") == 0)) { /* NCBI genome project data */
retcode = ACCN_NCBI_GENOME;
} else if ((StringICmp(temp,"AH") == 0) ||
- (StringICmp(temp,"CH") == 0)) { /* NCBI segmented set header Bioseq */
+ (StringICmp(temp,"CH") == 0) || /* NCBI segmented set header Bioseq */
+ (StringICmp(temp,"CM") == 0)) {
retcode = ACCN_NCBI_SEGSET | ACCN_AMBIGOUS_MOL; /* A few segmented
proteins are AH */
} else if ((StringICmp(temp,"AS") == 0)) { /* NCBI "other" */
@@ -8790,7 +8807,8 @@ NLM_EXTERN Uint4 LIBCALL WHICH_db_accession (CharPtr s)
(StringICmp(temp,"BZ") == 0) ||
(StringICmp(temp,"CC") == 0) ||
(StringICmp(temp,"CE") == 0) ||
- (StringICmp(temp,"CG") == 0) ) { /* NCBI GSS */
+ (StringICmp(temp,"CG") == 0) ||
+ (StringICmp(temp,"CL") == 0) ) { /* NCBI GSS */
retcode = ACCN_NCBI_GSS;
} else if ((StringICmp(temp,"AR") == 0)) { /* NCBI patent */
retcode = ACCN_NCBI_PATENT;
@@ -8809,11 +8827,13 @@ NLM_EXTERN Uint4 LIBCALL WHICH_db_accession (CharPtr s)
(StringICmp(temp,"AM") == 0)) { /* EMBL direct submission */
retcode = ACCN_EMBL_DIRSUB;
} else if ((StringICmp(temp,"AL") == 0) ||
- (StringICmp(temp,"BX") == 0)) { /* EMBL genome project data */
+ (StringICmp(temp,"BX") == 0)||
+ (StringICmp(temp,"CR") == 0)) { /* EMBL genome project data */
retcode = ACCN_EMBL_GENOME;
} else if ((StringICmp(temp,"AN") == 0)) { /* EMBL CON division */
retcode = ACCN_EMBL_CON;
- } else if ((StringICmp(temp,"AX") == 0)) { /* EMBL patent division */
+ } else if ((StringICmp(temp,"AX") == 0) ||
+ (StringICmp(temp,"CQ") == 0)) { /* EMBL patent division */
retcode = ACCN_EMBL_PATENT;
} else if ((StringICmp(temp,"AT") == 0) ||
(StringICmp(temp,"AU") == 0) ||
@@ -8822,7 +8842,9 @@ NLM_EXTERN Uint4 LIBCALL WHICH_db_accession (CharPtr s)
(StringICmp(temp,"BJ") == 0) ||
(StringICmp(temp,"BP") == 0) ||
(StringICmp(temp,"BW") == 0) ||
- (StringICmp(temp,"BY") == 0)) { /* DDBJ EST's */
+ (StringICmp(temp,"BY") == 0) ||
+ (StringICmp(temp,"CI") == 0) ||
+ (StringICmp(temp,"CJ") == 0)) { /* DDBJ EST's */
retcode = ACCN_DDBJ_EST;
} else if ((StringICmp(temp,"AB") == 0)) { /* DDBJ direct submission */
retcode = ACCN_DDBJ_DIRSUB;
diff --git a/api/sqnutil1.c b/api/sqnutil1.c
index 41e84d32..05f820ed 100644
--- a/api/sqnutil1.c
+++ b/api/sqnutil1.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 9/2/97
*
-* $Revision: 6.283 $
+* $Revision: 6.288 $
*
* File Description:
*
@@ -1671,6 +1671,7 @@ NLM_EXTERN void PromoteXrefsEx (SeqFeatPtr sfp, BioseqPtr bsp, Uint2 entityID, B
CharPtr ptr;
CharPtr rnaseq;
SeqEntryPtr sep;
+ SeqHistPtr shp;
SeqIdPtr sip;
SeqEntryPtr target = NULL;
Uint4 version = 0;
@@ -1964,6 +1965,14 @@ NLM_EXTERN void PromoteXrefsEx (SeqFeatPtr sfp, BioseqPtr bsp, Uint2 entityID, B
gbq->next = NULL;
StringNCpy_0 (id, gbq->val, sizeof (id));
GBQualFree (gbq);
+ } else if (StringICmp (gbq->qual, "secondary_accession") == 0) {
+ *(prevqual) = gbq->next;
+ gbq->next = NULL;
+ shp = ParseStringIntoSeqHist (NULL, gbq->val);
+ if (shp != NULL) {
+ pbsp->hist = shp;
+ }
+ GBQualFree (gbq);
} else {
prevqual = (GBQualPtr PNTR) &(gbq->next);
}
@@ -2285,6 +2294,41 @@ static void CleanDoubleQuote (CharPtr str)
}
}
+static CharPtr RemoveSpacesBetweenTildes (CharPtr str)
+
+{
+ Char ch;
+ CharPtr dst;
+ CharPtr ptr;
+ CharPtr tmp;
+
+ if (str == NULL || str [0] == '\0') return str;
+
+ dst = str;
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0') {
+ *dst = ch;
+ dst++;
+ ptr++;
+ if (ch == '~') {
+ tmp = ptr;
+ ch = *tmp;
+ while (ch != 0 && ch <= ' ') {
+ tmp++;
+ ch = *tmp;
+ }
+ if (ch == '~') {
+ ptr = tmp;
+ }
+ }
+ ch = *ptr;
+ }
+ *dst = '\0';
+
+ return str;
+}
+
static Boolean AlreadyInVnpList (ValNodePtr head, ValNodePtr curr)
{
@@ -2493,43 +2537,53 @@ extern Boolean ParseCodeBreak (SeqFeatPtr sfp, CharPtr val)
/* parse location */
pos = SimpleValuePos (val);
cbp->loc = Nlm_gbparseint (pos, &locmap, &sitesmap, &num_errs, sip);
- MemFree (pos);
if (cbp->loc == NULL) {
CodeBreakFree (cbp);
ErrPostEx (SEV_WARNING, ERR_FEATURE_LocationParsing,
"transl_except parsing failed, %s, drop the transl_except", pos);
+ MemFree (pos);
return FALSE;
}
- sintp = cbp->loc->data.ptrvalue;
- if (sintp == NULL) return FALSE;
- if (sintp->from > sintp->to) {
- temp = sintp->from;
- sintp->from = sintp->to;
- sintp->to = temp;
- }
- sintp->strand = SeqLocStrand (sfp->location);
- strand = sintp->strand;
- diff = SeqLocStop(cbp->loc) - SeqLocStart(cbp->loc); /* SeqLocStop/Start does not do what you think */
- /*
- if ((diff != 2 && (strand != Seq_strand_minus)) ||
- (diff != -2 && (strand == Seq_strand_minus))) {
- pos_range = TRUE;
- }
- */
- if (diff != 2) {
- pos_range = TRUE;
- }
- if (num_errs > 0 || pos_range) {
- CodeBreakFree (cbp);
- ErrPostEx (SEV_WARNING, ERR_FEATURE_LocationParsing,
- "transl_except range is wrong, %s, drop the transl_except", pos);
- return FALSE;
+ if (cbp->loc->choice == SEQLOC_PNT) {
+ /* allow a single point */
}
- if (SeqLocCompare (sfp->location, cbp->loc) != SLC_B_IN_A) {
- CodeBreakFree (cbp);
- ErrPostEx (SEV_WARNING, ERR_FEATURE_LocationParsing,
- "/transl_except not in CDS: %s", val);
- return FALSE;
+ if (cbp->loc->choice == SEQLOC_INT) {
+ sintp = cbp->loc->data.ptrvalue;
+ if (sintp == NULL) {
+ MemFree (pos);
+ return FALSE;
+ }
+ if (sintp->from > sintp->to) {
+ temp = sintp->from;
+ sintp->from = sintp->to;
+ sintp->to = temp;
+ }
+ sintp->strand = SeqLocStrand (sfp->location);
+ strand = sintp->strand;
+ diff = SeqLocStop(cbp->loc) - SeqLocStart(cbp->loc); /* SeqLocStop/Start does not do what you think */
+ /*
+ if ((diff != 2 && (strand != Seq_strand_minus)) ||
+ (diff != -2 && (strand == Seq_strand_minus))) {
+ pos_range = TRUE;
+ }
+ */
+ if (diff != 2) {
+ pos_range = TRUE;
+ }
+ if (num_errs > 0 || pos_range) {
+ CodeBreakFree (cbp);
+ ErrPostEx (SEV_WARNING, ERR_FEATURE_LocationParsing,
+ "transl_except range is wrong, %s, drop the transl_except", pos);
+ MemFree (pos);
+ return FALSE;
+ }
+ if (SeqLocCompare (sfp->location, cbp->loc) != SLC_B_IN_A) {
+ CodeBreakFree (cbp);
+ ErrPostEx (SEV_WARNING, ERR_FEATURE_LocationParsing,
+ "/transl_except not in CDS: %s", val);
+ MemFree (pos);
+ return FALSE;
+ }
}
/* add to code break list */
@@ -2542,6 +2596,7 @@ extern Boolean ParseCodeBreak (SeqFeatPtr sfp, CharPtr val)
}
lastcbp->next = cbp;
}
+ MemFree (pos);
return TRUE;
}
@@ -5825,7 +5880,7 @@ static void CleanupFeatureStrings (SeqFeatPtr sfp, Boolean stripSerial, ValNodeP
}
}
}
- if (prp->processed == 2 && prp->name == NULL) {
+ if ((prp->processed == 1 || prp->processed == 2) && prp->name == NULL) {
ValNodeCopyStr (&(prp->name), 0, "unnamed");
}
break;
@@ -6250,6 +6305,7 @@ static void CleanupDescriptorStrings (ValNodePtr sdp, Boolean stripSerial, ValNo
break;
case Seq_descr_comment :
CleanVisStringJunk ((CharPtr PNTR) &sdp->data.ptrvalue);
+ RemoveSpacesBetweenTildes ((CharPtr) sdp->data.ptrvalue);
break;
case Seq_descr_num :
break;
@@ -7588,7 +7644,8 @@ static Boolean CheckAsnloadPath (CharPtr dirname, CharPtr subdir)
static Boolean CheckDataPath (CharPtr dirname, CharPtr subdir)
{
- return (Boolean) (FileExists (dirname, subdir, "seqcode.val"));
+ if (FileExists (dirname, subdir, "seqcode.val")) return TRUE;
+ return (Boolean) (FileExists (dirname, subdir, "objprt.prt"));
}
static Boolean CheckErrMsgPath (CharPtr dirname, CharPtr subdir)
@@ -7616,7 +7673,7 @@ NLM_EXTERN Boolean UseLocalAsnloadDataAndErrMsg (void)
Char appPath[PATH_MAX];
CharPtr ptr;
- ProgramPath (appPath, sizeof (path));
+ ProgramPath (appPath, sizeof (appPath));
StrCpy(path, appPath);
/* data a sibling of our application? */
ptr = StringRChr (path, DIRDELIMCHR);
diff --git a/api/sqnutil2.c b/api/sqnutil2.c
index a5817f57..42d07c72 100644
--- a/api/sqnutil2.c
+++ b/api/sqnutil2.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 9/2/97
*
-* $Revision: 6.152 $
+* $Revision: 6.160 $
*
* File Description:
*
@@ -1308,6 +1308,7 @@ NLM_EXTERN CharPtr SqnTagFind (SqnTagPtr stp, CharPtr tag)
if (stp == NULL || StringHasNoText (tag)) return NULL;
for (i = 0; i < stp->num_tags; i++) {
if (stp->tag [i] != NULL && StringICmp (stp->tag [i], tag) == 0) {
+ stp->used [i] = TRUE;
return stp->val [i];
}
}
@@ -1734,6 +1735,52 @@ static void AddStringToSeqHist (
tsip->accession = StringSave (str);
}
+NLM_EXTERN SeqHistPtr ParseStringIntoSeqHist (
+ SeqHistPtr shp,
+ CharPtr str
+)
+
+{
+ Char ch;
+ CharPtr last;
+ CharPtr ptr;
+ CharPtr tmp;
+
+ if (shp == NULL) {
+ shp = SeqHistNew ();
+ if (shp == NULL) return shp;
+ }
+
+ if (str != NULL) {
+ tmp = StringSave (str);
+ last = tmp;
+ ptr = last;
+ ch = *ptr;
+ while (ch != '\0') {
+ if (ch == ',') {
+ *ptr = '\0';
+ if (! StringHasNoText (last)) {
+ TrimSpacesAroundString (last);
+ AddStringToSeqHist (shp, last);
+ }
+ ptr++;
+ last = ptr;
+ ch = *ptr;
+ } else {
+ ptr++;
+ ch = *ptr;
+ }
+ }
+ if (! StringHasNoText (last)) {
+ TrimSpacesAroundString (last);
+ AddStringToSeqHist (shp, last);
+ }
+ MemFree (tmp);
+ }
+
+ return shp;
+}
+
NLM_EXTERN SeqHistPtr ParseTitleIntoSeqHist (
SqnTagPtr stp,
SeqHistPtr shp
@@ -3150,11 +3197,11 @@ static Boolean ParseFeatTableLine (CharPtr line, Int4Ptr startP, Int4Ptr stopP,
*partial3P = partial3;
*ispointP = ispoint;
*isminusP = isminus;
- *featP = featType;
- *qualP = qualType;
- *valP = qualVal;
+ *featP = StringSaveNoNull (featType);
+ *qualP = StringSaveNoNull (qualType);
+ *valP = StringSaveNoNull (qualVal);
- ValNodeFree (parsed);
+ ValNodeFreeData (parsed);
return TRUE;
}
@@ -4146,6 +4193,8 @@ NLM_EXTERN void AddQualifierToFeature (SeqFeatPtr sfp, CharPtr qual, CharPtr val
prp->desc = MemFree (prp->desc);
prp->desc = StringSaveNoNull (val);
}
+ } else if (sfp->data.choice == SEQFEAT_CDREGION && StringCmp (qual, "secondary_accession") == 0) {
+ bail = FALSE;
} else if (ifp != NULL && StringICmp (ifp->key, "variation") == 0 && ParseQualIntoSnpUserObject (sfp, qual, val)) {
} else if (ifp != NULL && StringICmp (ifp->key, "STS") == 0 && ParseQualIntoStsUserObject (sfp, qual, val)) {
} else if (ifp != NULL && StringICmp (ifp->key, "misc_feature") == 0 && ParseQualIntoCloneUserObject (sfp, qual, val)) {
@@ -4661,6 +4710,10 @@ static SeqAnnotPtr ReadFeatureTable (FILE *fp, CharPtr seqid, CharPtr annotname)
ParseWhitespaceIntoTabs (line);
}
+ feat = NULL;
+ qual = NULL;
+ val = NULL;
+
if (ParseFeatTableLine (line, &start, &stop, &partial5, &partial3, &ispoint, &isminus, &feat, &qual, &val, offset)) {
if (feat != NULL && start >= 0 && stop >= 0) {
@@ -4865,6 +4918,10 @@ static SeqAnnotPtr ReadFeatureTable (FILE *fp, CharPtr seqid, CharPtr annotname)
}
ErrPostEx (SEV_ERROR, ERR_SEQ_FEAT_WrongQualOnImpFeat, "Qualifier '%s' has no value on %s feature at %s", qual, label, loc);
MemFree (loc);
+
+ } else if (feat != NULL) {
+
+ ErrPostEx (SEV_ERROR, ERR_SEQ_FEAT_ImpFeatBadLoc, "Bad location on feature %s (start %ld, stop %ld)", feat, (long) start, (long) stop);
}
} else if (*line == '[') {
@@ -4881,13 +4938,11 @@ static SeqAnnotPtr ReadFeatureTable (FILE *fp, CharPtr seqid, CharPtr annotname)
SqnTagFree (stp);
}
-/* Uncomment next lines if Purify reports memory leaks here. */
+ /* ParseFeatTableLine copies these three strings, so free here */
- /*
- MemFree (feat);
- MemFree (qual);
- MemFree (val);
- */
+ feat = MemFree (feat);
+ qual = MemFree (qual);
+ val = MemFree (val);
}
@@ -5786,6 +5841,7 @@ NLM_EXTERN Pointer ReadAsnFastaOrFlatFile (FILE *fp, Uint2Ptr datatypeptr, Uint2
tmp = StringChr (line + 1, '[');
if (tmp != NULL) {
if (StringStr (tmp, "[") != NULL && StringStr (tmp, "=") != NULL) {
+ TrimSpacesAroundString (tmp);
title = StringSave (tmp);
}
} else if (fastaAsSimpleSeq) {
@@ -5815,6 +5871,7 @@ NLM_EXTERN Pointer ReadAsnFastaOrFlatFile (FILE *fp, Uint2Ptr datatypeptr, Uint2
tmp += StringLen (seqid);
if (! StringHasNoText (tmp)) {
TrimSpacesAroundString (tmp);
+ title = MemFree (title);
title = StringSaveNoNull (tmp);
}
}
@@ -6360,6 +6417,9 @@ NLM_EXTERN TextFsaPtr TextFsaFree (TextFsaPtr tbl)
}
MemFree (statePtr);
+
+ ValNodeFreeData (tbl->siteList);
+
return MemFree (tbl);
}
diff --git a/api/sqnutils.h b/api/sqnutils.h
index e3a061e3..0e5bb878 100644
--- a/api/sqnutils.h
+++ b/api/sqnutils.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 9/2/97
*
-* $Revision: 6.92 $
+* $Revision: 6.94 $
*
* File Description:
*
@@ -216,6 +216,7 @@ typedef struct sqntag {
Int2 num_tags;
CharPtr tag [MAX_SQN_TAGS];
CharPtr val [MAX_SQN_TAGS];
+ Boolean used [MAX_SQN_TAGS];
} SqnTag, PNTR SqnTagPtr;
NLM_EXTERN SqnTagPtr SqnTagParse (CharPtr ttl);
@@ -261,6 +262,11 @@ NLM_EXTERN SeqHistPtr ParseTitleIntoSeqHist (
SeqHistPtr shp
);
+NLM_EXTERN SeqHistPtr ParseStringIntoSeqHist (
+ SeqHistPtr shp,
+ CharPtr str
+);
+
NLM_EXTERN UserObjectPtr ParseTitleIntoTpaAssembly (
SqnTagPtr stp,
UserObjectPtr uop
diff --git a/api/tofasta.c b/api/tofasta.c
index c605b2a0..f0970b93 100644
--- a/api/tofasta.c
+++ b/api/tofasta.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/12/91
*
-* $Revision: 6.121 $
+* $Revision: 6.125 $
*
* File Description: various sequence objects to fasta output
*
@@ -39,6 +39,18 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: tofasta.c,v $
+* Revision 6.125 2004/01/21 19:22:14 kans
+* UseOrgMods capitalizes first letter of created defline
+*
+* Revision 6.124 2003/12/23 20:58:51 kans
+* ProtDefLine takes prp->activity if prp->name and prp->desc are not set
+*
+* Revision 6.123 2003/11/18 19:04:29 kans
+* added BioseqFastaStream, rapid generator based on SeqPortStream
+*
+* Revision 6.122 2003/11/05 19:24:55 kans
+* BioseqToFastaX checks for virtual with do_virtual not set, prints a single dash as the sequence
+*
* Revision 6.121 2003/08/04 19:51:02 kans
* for complete chromosome title, if > 3 clones (by counting semicolons) then just display count, not full text of clones
*
@@ -1366,6 +1378,15 @@ NLM_EXTERN Boolean BioseqToFastaX (BioseqPtr bsp, MyFsaPtr mfp, Boolean is_na)
code = mfp->code;
}
+ if (repr == Seq_repr_virtual && (! mfp->do_virtual)) {
+ StringCpy (mfp->buf, "-");
+ (*(mfp->myfunc))(bsp, FASTA_SEQLINE, mfp->buf, StringLen(mfp->buf),
+ mfp->mydata);
+ (*(mfp->myfunc))(bsp, FASTA_EOS, mfp->buf, StringLen(mfp->buf),
+ mfp->mydata);
+ return TRUE;
+ }
+
spp = FastaSeqPortEx (bsp, is_na, mfp->do_virtual, code, mfp->seqloc);
if (spp == NULL) return FALSE;
@@ -1384,6 +1405,85 @@ NLM_EXTERN Boolean BioseqToFastaX (BioseqPtr bsp, MyFsaPtr mfp, Boolean is_na)
/*****************************************************************************
*
+* BioseqFastaStream(bsp, fp, expandGaps, maxlen)
+*
+* Rapid FASTA generator using SeqPortStream
+*
+*****************************************************************************/
+
+typedef struct streamfsa {
+ FILE *fp;
+ Char buf [130];
+ Int2 idx;
+ Int2 linelen;
+} StreamFsa, PNTR StreamFsaPtr;
+
+static void LIBCALLBACK FsaStreamProc (
+ CharPtr sequence,
+ Pointer userdata
+)
+
+{
+ Char ch;
+ StreamFsaPtr sfp;
+
+ if (StringHasNoText (sequence) || userdata == NULL) return;
+ sfp = (StreamFsaPtr) userdata;
+
+ ch = *sequence;
+ while (ch != '\0') {
+ sfp->buf [sfp->idx] = ch;
+ (sfp->idx)++;
+
+ if (sfp->idx >= sfp->linelen) {
+ sfp->buf [sfp->idx] = '\0';
+ fprintf (sfp->fp, "%s\n", sfp->buf);
+ sfp->idx = 0;
+ }
+
+ sequence++;
+ ch = *sequence;
+ }
+}
+
+NLM_EXTERN void BioseqFastaStream (BioseqPtr bsp, FILE *fp, Boolean expandGaps, Int2 linelen)
+
+{
+ Char buf [4096];
+ Char id [42];
+ StreamFsa sf;
+
+ if (bsp == NULL || fp == NULL) return;
+ if (linelen > 128) {
+ linelen = 128;
+ }
+ if (linelen < 1) {
+ linelen = 60;
+ }
+
+ id [0] = '\0';
+ SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
+
+ buf [0] = '\0';
+ CreateDefLine (NULL, bsp, buf, sizeof (buf) - 1, 0, NULL, NULL);
+
+ fprintf (fp, ">%s %s\n", id, buf);
+
+ MemSet ((Pointer) &sf, 0, sizeof (StreamFsa));
+ sf.fp = fp;
+ sf.idx = 0;
+ sf.linelen = linelen;
+ SeqPortStream (bsp, expandGaps, (Pointer) &sf, FsaStreamProc);
+
+ if (sf.idx > 0) {
+ sf.buf [sf.idx] = '\0';
+ fprintf (fp, "%s\n", sf.buf);
+ }
+}
+
+
+/*****************************************************************************
+*
* Here are functions that convert FASTA format from file or from memory
*
*****************************************************************************/
@@ -3037,8 +3137,12 @@ static CharPtr FindProtDefLine(BioseqPtr bsp)
}
}
}
- } else if (prp->desc) {
+ } else if (prp && prp->desc) {
title = StringSave(prp->desc);
+ } else if (prp && prp->activity) {
+ if (prp->activity->data.ptrvalue) {
+ title = StringSave (prp->activity->data.ptrvalue);
+ }
}
}
if (title == NULL) {
@@ -3271,6 +3375,7 @@ static CharPtr UseOrgMods(BioseqPtr bsp, CharPtr suffix)
OrgNamePtr onp;
OrgRefPtr orp;
SubSourcePtr ssp;
+ Char ch;
CharPtr name = NULL, chr = NULL, str = NULL,
cln = NULL, map = NULL, def=NULL;
Int2 deflen = 0;
@@ -3333,6 +3438,7 @@ static CharPtr UseOrgMods(BioseqPtr bsp, CharPtr suffix)
}
deflen += StringLen (suffix) + 2;
def = (CharPtr) MemNew(deflen+1);
+ if (def == NULL) return NULL;
if (name) {
def = StringCat(def, name);
MemFree(name);
@@ -3357,6 +3463,9 @@ static CharPtr UseOrgMods(BioseqPtr bsp, CharPtr suffix)
def = StringCat(def, " ");
def = StringCat(def, suffix);
}
+ TrimSpacesAroundString (def);
+ ch = def [0];
+ def [0] = TO_UPPER (ch);
return def;
}
diff --git a/api/tofasta.h b/api/tofasta.h
index 23a30263..6dbedb14 100644
--- a/api/tofasta.h
+++ b/api/tofasta.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/12/91
*
-* $Revision: 6.20 $
+* $Revision: 6.21 $
*
* File Description: various sequence objects to fasta output
*
@@ -39,6 +39,9 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: tofasta.h,v $
+* Revision 6.21 2003/11/18 19:04:29 kans
+* added BioseqFastaStream, rapid generator based on SeqPortStream
+*
* Revision 6.20 2002/07/18 19:28:35 kans
* working implementation of BioseqRawToFastaExtraEx, always zero out all of MyFsa struct, no need for fake seqloc
*
@@ -239,6 +242,16 @@ NLM_EXTERN Boolean BioseqToFastaX PROTO((BioseqPtr bsp, MyFsaPtr mfp, Boolean is
/*****************************************************************************
*
+* BioseqFastaStream(bsp, fp, expandGaps, maxlen)
+*
+* Rapid FASTA generator using SeqPortStream
+*
+*****************************************************************************/
+NLM_EXTERN void BioseqFastaStream PROTO((BioseqPtr bsp, FILE *fp, Boolean expandGaps, Int2 linelen));
+
+
+/*****************************************************************************
+*
* FastaFileFunc(key, buf, data)
* standard "write to file" callback
*
diff --git a/api/txalign.c b/api/txalign.c
index 127cc1a5..21bfec8b 100644
--- a/api/txalign.c
+++ b/api/txalign.c
@@ -1,4 +1,4 @@
-/* $Id: txalign.c,v 6.79 2003/09/26 20:54:10 dondosha Exp $
+/* $Id: txalign.c,v 6.81 2003/11/25 16:24:03 dondosha Exp $
***************************************************************************
* *
* COPYRIGHT NOTICE *
@@ -27,13 +27,19 @@
*
* File Name: txalign.c
*
-* $Revision: 6.79 $
+* $Revision: 6.81 $
*
* File Description: Formating of text alignment for the BLAST output
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: txalign.c,v $
+* Revision 6.81 2003/11/25 16:24:03 dondosha
+* Use query number for synchronizeCheck; do not show structure link if RID not available
+*
+* Revision 6.80 2003/11/20 22:09:26 dondosha
+* Added a PrindDefLinesFromSeqAlignWithPath function with an argument to provide root path for image links
+*
* Revision 6.79 2003/09/26 20:54:10 dondosha
* Revert change in revision 6.77, as it turned trace.cgi links should have stayed as they were
*
@@ -688,15 +694,17 @@ static void addLinkoutForDefline(BioseqPtr bsp, SeqIdPtr sip, FILE* fp){
bdlpTemp=bdlpTemp->next;
}
bdlpTemp=bdlp;
- while(bdlpTemp){
- if(checkLinkoutType(bdlpTemp, linkout_structure)){
- hasLinkout=TRUE;
- gi=GetGIForSeqId(bdlpTemp->seqid);
- fprintf(fp, URL_Structure, RID_glb, firstGi, gi, CDD_RID_glb, "onegroup", StringCmp(Entrez_Query_Term, "") ? Entrez_Query_Term:"none");
- break;
- }
- bdlpTemp=bdlpTemp->next;
- }
+ if (RID_glb) {
+ while(bdlpTemp){
+ if(checkLinkoutType(bdlpTemp, linkout_structure)){
+ hasLinkout=TRUE;
+ gi=GetGIForSeqId(bdlpTemp->seqid);
+ fprintf(fp, URL_Structure, RID_glb, firstGi, gi, CDD_RID_glb, "onegroup", StringCmp(Entrez_Query_Term, "") ? Entrez_Query_Term:"none");
+ break;
+ }
+ bdlpTemp=bdlpTemp->next;
+ }
+ }
bdlpTemp=bdlp;
while(bdlpTemp){
if(checkLinkoutType(bdlpTemp, linkout_geo)){
@@ -749,7 +757,7 @@ static void addLinkoutForBioseq(BioseqPtr bsp, SeqIdPtr sip, SeqIdPtr firstSip,
hasLinkout=TRUE;
fprintf(fp, URL_Unigene, gi);
}
- if(checkLinkoutType(actualBdlp, linkout_structure)){
+ if(RID_glb && checkLinkoutType(actualBdlp, linkout_structure)){
hasLinkout=TRUE;
fprintf(fp, URL_Structure, RID_glb, firstGi, gi, CDD_RID_glb, "onepair", StringCmp(Entrez_Query_Term, "") ? Entrez_Query_Term:"none");
}
@@ -1712,7 +1720,7 @@ static CharPtr DrawTextToBuffer(ValNodePtr tdp_list, CharPtr PNTR m_buf, Boolean
/*check box for getting sequence*/
if(options&TXALIGN_HTML&&options&TXALIGN_MASTER&&DbHasGi&&(options&TXALIGN_GET_SEQUENCE)){
Char checkboxBuf[200];
- sprintf(checkboxBuf, "<input type=\"checkbox\" name=\"getSeqGi\" value=\"%ld\" onClick=\"synchronizeCheck(this.value, 'getSeqAlignment', 'getSeqGi', this.checked)\">", sip->data.intvalue);
+ sprintf(checkboxBuf, "<input type=\"checkbox\" name=\"getSeqGi\" value=\"%ld\" onClick=\"synchronizeCheck(this.value, 'getSeqAlignment%ld', 'getSeqGi', this.checked)\">", sip->data.intvalue, query_number_glb);
sprintf(docbuf+pos,checkboxBuf);
pos += StringLen(checkboxBuf);
@@ -1761,7 +1769,7 @@ static CharPtr DrawTextToBuffer(ValNodePtr tdp_list, CharPtr PNTR m_buf, Boolean
if(!load){
if(options&TXALIGN_HTML&&options&TXALIGN_MASTER&&DbHasGi&&(options&TXALIGN_GET_SEQUENCE)){
Char checkboxBuf[200];
- sprintf(checkboxBuf, "<input type=\"checkbox\" name=\"getSeqMaster\" value=\"\" onClick=\"uncheckable('getSeqAlignment', 'getSeqMaster')\">");
+ sprintf(checkboxBuf, "<input type=\"checkbox\" name=\"getSeqMaster\" value=\"\" onClick=\"uncheckable('getSeqAlignment%ld', 'getSeqMaster')\">", query_number_glb);
sprintf(docbuf+pos,checkboxBuf);
pos += StringLen(checkboxBuf);
@@ -4580,9 +4588,9 @@ Tx_PrintDefLine(BlastDefLinePtr bdsp, CharPtr buffer, Int4 length)
}
NLM_EXTERN Boolean LIBCALL
-PrintDefLinesFromSeqAlignEx2(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp, Uint4 options,
+PrintDefLinesFromSeqAlignWithPath(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp, Uint4 options,
Int4 mode, Int2Ptr marks, Int4 number_of_descriptions,
- CharPtr db_name, CharPtr blast_type)
+ CharPtr db_name, CharPtr blast_type, CharPtr www_root_path)
{
BioseqPtr bsp;
Boolean found_next_one, found_gnl_id, same_id, found_score=FALSE, make_link=FALSE;
@@ -4602,7 +4610,6 @@ PrintDefLinesFromSeqAlignEx2(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp
Char tool_url[128];
DbtagPtr db_tag;
ObjectIdPtr oip;
- CharPtr www_root_path = NULL;
Int2 ColumnDistance=2, extraSpace=0, extraSpace2=0, strLen=0, maxEvalWidth=5, maxNWidth=2;
Char tempBuf[64], tempBuf2[64];
@@ -4617,7 +4624,8 @@ PrintDefLinesFromSeqAlignEx2(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp
}
#ifdef OS_UNIX
- www_root_path = getenv("WWW_ROOT_PATH");
+ if (!www_root_path)
+ www_root_path = getenv("WWW_ROOT_PATH");
#endif
if(!StringICmp(blast_type, "fruitfly")) {
@@ -4651,7 +4659,7 @@ PrintDefLinesFromSeqAlignEx2(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp
/*AAS*/
if (!(options & TXALIGN_DO_NOT_PRINT_TITLE)) {
if ((mode == FIRST_PASS) || (mode == NOT_FIRST_PASS_REPEATS)) {
- if(options&TXALIGN_SHOW_LINKOUT&&options&TXALIGN_HTML){
+ if(RID_glb && options&TXALIGN_SHOW_LINKOUT&&options&TXALIGN_HTML){
if(PairwiseSeqAlignHasLinkout(seqalign, linkout_structure)){
fprintf(outfp, URL_Structure_Overview, RID_glb, 0, 0, CDD_RID_glb, "overview", StringCmp(Entrez_Query_Term, "") ? Entrez_Query_Term:"none");
@@ -4883,14 +4891,14 @@ PrintDefLinesFromSeqAlignEx2(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp
firstnew = FALSE;
fprintf(outfp, "<a name = Evalue></a>");
}
- fprintf(outfp, "<br><IMG SRC=\"%s/images/new.gif\" WIDTH=25 HEIGHT=15 ALT=\"New sequence mark\">", www_root_path == NULL? "/blast" : www_root_path);
+ fprintf(outfp, "<br><IMG SRC=\"%s/blast/images/new.gif\" WIDTH=25 HEIGHT=15 ALT=\"New sequence mark\">", www_root_path == NULL? "" : www_root_path);
} else {
- fprintf(outfp, "<br><IMG SRC=\"%s/images/bg.gif\" WIDTH=25 HEIGHT=15 ALT=\" \">", www_root_path == NULL? "/blast" : www_root_path);
+ fprintf(outfp, "<br><IMG SRC=\"%s/blast/images/bg.gif\" WIDTH=25 HEIGHT=15 ALT=\" \">", www_root_path == NULL? "" : www_root_path);
}
if (txsp->waschecked) {
- fprintf(outfp, "<IMG SRC=\"%s/images/checked.gif\" WIDTH=15 HEIGHT=15 ALT=\"Checked mark\">", www_root_path == NULL? "/blast" : www_root_path);
+ fprintf(outfp, "<IMG SRC=\"%s/blast/images/checked.gif\" WIDTH=15 HEIGHT=15 ALT=\"Checked mark\">", www_root_path == NULL? "" : www_root_path);
} else {
- fprintf(outfp, "<IMG SRC=\"%s/images/bg.gif\" WIDTH=15 HEIGHT=15 ALT=\" \">", www_root_path == NULL? "/blast" : www_root_path);
+ fprintf(outfp, "<IMG SRC=\"%s/blast/images/bg.gif\" WIDTH=15 HEIGHT=15 ALT=\" \">", www_root_path == NULL? "" : www_root_path);
}
}
fprintf(outfp, "%s", HTML_buffer);
@@ -5183,6 +5191,16 @@ PrintDefLinesFromSeqAlignEx2(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp
}
NLM_EXTERN Boolean LIBCALL
+PrintDefLinesFromSeqAlignEx2(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp, Uint4 options,
+ Int4 mode, Int2Ptr marks, Int4 number_of_descriptions,
+ CharPtr db_name, CharPtr blast_type)
+{
+ return PrintDefLinesFromSeqAlignWithPath(seqalign, line_length, outfp,
+ options, mode, marks, number_of_descriptions, db_name,
+ blast_type, NULL);
+}
+
+NLM_EXTERN Boolean LIBCALL
PrintDefLinesFromSeqAlign(SeqAlignPtr seqalign, Int4 line_length, FILE *outfp, Uint4 options, Int4 mode, Int2Ptr marks)
{
Boolean retval;
@@ -5576,7 +5594,7 @@ static Boolean TX_PrintDeflinesWithAsn(BlastDefLinePtr PNTR bdsp,
bestid = SeqIdFindBest(tbdsp->seqid, SEQID_GI);
firstSip=bestid;
if(bestid->choice == SEQID_GI&&asop->html_hot_link&&(asop->txalign_options&TXALIGN_GET_SEQUENCE)){
- fprintf(asop->fp, "<input type=\"checkbox\" name=\"getSeqGi\" value=\"%ld\" onClick=\"synchronizeCheck(this.value, 'getSeqAlignment', 'getSeqGi', this.checked)\">", bestid->data.intvalue);
+ fprintf(asop->fp, "<input type=\"checkbox\" name=\"getSeqGi\" value=\"%ld\" onClick=\"synchronizeCheck(this.value, 'getSeqAlignment%ld', 'getSeqGi', this.checked)\">", bestid->data.intvalue, query_number_glb);
}
fprintf(asop->fp, ">");
@@ -5696,7 +5714,7 @@ NLM_EXTERN int LIBCALLBACK FormatScoreFunc(AlignStatOptionPtr asop)
bestid = SeqIdFindBest(bsp->id, SEQID_GI);
firstSip=bestid;
if(bestid->choice == SEQID_GI&&asop->html_hot_link&&(asop->txalign_options&TXALIGN_GET_SEQUENCE)){
- fprintf(asop->fp, "<input type=\"checkbox\" name=\"getSeqGi\" value=\"%ld\" onClick=\"synchronizeCheck(this.value, 'getSeqAlignment', 'getSeqGi', this.checked)\">", bestid->data.intvalue);
+ fprintf(asop->fp, "<input type=\"checkbox\" name=\"getSeqGi\" value=\"%ld\" onClick=\"synchronizeCheck(this.value, 'getSeqAlignment%ld', 'getSeqGi', this.checked)\">", bestid->data.intvalue, query_number_glb);
}
fprintf(asop->fp, ">");
first = FALSE;
diff --git a/api/txalign.h b/api/txalign.h
index 0c7099c0..949ba262 100644
--- a/api/txalign.h
+++ b/api/txalign.h
@@ -1,4 +1,4 @@
-/* $Id: txalign.h,v 6.15 2002/12/11 16:24:51 jianye Exp $
+/* $Id: txalign.h,v 6.16 2003/11/20 22:09:26 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Initial Version Creation Date: 03/13/94
*
-* $Revision: 6.15 $
+* $Revision: 6.16 $
*
* File Description:
* External include file for various alignments
@@ -38,6 +38,9 @@
*
*
* $Log: txalign.h,v $
+* Revision 6.16 2003/11/20 22:09:26 dondosha
+* Added a PrindDefLinesFromSeqAlignWithPath function with an argument to provide root path for image links
+*
* Revision 6.15 2002/12/11 16:24:51 jianye
* added structure linkout
*
@@ -475,8 +478,6 @@ NLM_EXTERN Boolean ShowTextAlignFromAnnot3 PROTO((
CharPtr blast_type,
Int4Ptr PNTR posMatrix
));
-
-
/* Simple printing function:
Can be used while debugging.. options kept to a minimum
fp==NULL ==> stdout
@@ -571,6 +572,19 @@ NLM_EXTERN Boolean LIBCALL PrintDefLinesFromSeqAlignEx2 PROTO((
CharPtr blast_type
));
+NLM_EXTERN Boolean LIBCALL PrintDefLinesFromSeqAlignWithPath PROTO((
+ SeqAlignPtr seqalign,
+ Int4 line_length,
+ FILE *outfp,
+ Uint4 options,
+ Int4 mode,
+ Int2Ptr marks,
+ Int4 number_of_descriptions,
+ CharPtr db_name,
+ CharPtr blast_type,
+ CharPtr www_root_path
+ ));
+
/*
Fills in the slots with score, bit_score, etc. from the SeqAlign.
*/
diff --git a/api/valid.c b/api/valid.c
index 667a2876..f386b72b 100644
--- a/api/valid.c
+++ b/api/valid.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/94
*
-* $Revision: 6.403 $
+* $Revision: 6.427 $
*
* File Description: Sequence editing utilities
*
@@ -39,6 +39,78 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: valid.c,v $
+* Revision 6.427 2004/01/20 22:25:49 kans
+* when run from tbl2asn, suppress MissingLineage, GenCodeMismatch, and NoTaxonID messages
+*
+* Revision 6.426 2004/01/20 22:09:36 kans
+* tbl2asn sets vsp->seqSubmitParent flag, use this to drop MissingLineage from error to warning
+*
+* Revision 6.425 2004/01/16 17:10:50 kans
+* implemented ERR_SEQ_FEAT_LocusTagProblem
+*
+* Revision 6.424 2004/01/13 18:33:26 kans
+* ValidateCitSub checks ap->affil, set vsp->gcp fields for sbp->sub call to it
+*
+* Revision 6.423 2004/01/12 18:08:36 kans
+* ValidateCitSub called from ValidatePubdesc, gives error if no affiliation fields set
+*
+* Revision 6.422 2004/01/07 20:47:21 kans
+* validate dbxref with legalDbXrefs in asn2gnbi.h instead of old flatfile generator symbols
+*
+* Revision 6.421 2004/01/02 15:06:23 kans
+* modified codon recognition exception text suppresses TrnaCodonWrong error
+*
+* Revision 6.420 2003/12/15 16:47:17 kans
+* artificial, mutagenized, or synthetic suppress other-genetic message
+*
+* Revision 6.419 2003/12/11 20:49:09 kans
+* allow multiple adjacent 3prime UTRs, used in segmented sequences
+*
+* Revision 6.418 2003/12/11 19:22:24 kans
+* electronic journal suppresses no volume, no iso jta errors
+*
+* Revision 6.417 2003/12/10 18:24:10 kans
+* Implemented ERR_SEQ_FEAT_BadConflictFlag and ERR_SEQ_FEAT_ConflictFlagSet
+*
+* Revision 6.416 2003/12/09 22:25:46 kans
+* implemented ERR_SEQ_INST_SeqLocLength test
+*
+* Revision 6.415 2003/12/08 21:10:03 kans
+* added ERR_SEQ_PKG_GraphPackagingProblem, now can only collect graphs on bioseq to validate
+*
+* Revision 6.414 2003/12/08 19:10:23 kans
+* ValidateGraphsOnBioseq uses BSRead instead of BSGetByte for great speedup
+*
+* Revision 6.413 2003/12/05 18:52:12 kans
+* ValidateSeqEntry does not set do_many if BioseqseqSet_class_genbank. GatherSeqEntry visits everything, and should not be called in a loop.
+*
+* Revision 6.412 2003/12/04 22:30:43 kans
+* ValidateGraphOnBioseq uses visit instead of nested gather
+*
+* Revision 6.411 2003/12/03 19:52:11 kans
+* TerminalNs is warning if NC_ record, never error
+*
+* Revision 6.410 2003/12/02 19:54:49 kans
+* ValidateSeqEntry does not need to AssignIDsInEntity every time through the loop, just at beginning
+*
+* Revision 6.409 2003/12/02 15:37:37 kans
+* added vsp->seqSubmitParent for use by tbl2asn, which usually has a Seq-submit wrapper that is added on-the-fly and not indexed
+*
+* Revision 6.408 2003/11/19 18:54:42 kans
+* segmented sequence does not need TPA user object, 5prime UTR only needs to abut first CDS, if mRNA is segmented
+*
+* Revision 6.407 2003/11/18 22:51:20 kans
+* ValidStructClear saves/restores new alignFindRemoteBsp and doSeqHistAssembly fields
+*
+* Revision 6.406 2003/11/14 18:07:16 kans
+* alignment parameters to find remote bsp, do seqhist assembly
+*
+* Revision 6.405 2003/11/13 21:51:42 kans
+* added ERR_SEQ_INST_TpaAssmeblyProblem check
+*
+* Revision 6.404 2003/11/12 20:13:36 kans
+* added East Timor to the legal country codes
+*
* Revision 6.403 2003/10/24 21:31:00 kans
* added test for ERR_SEQ_FEAT_UTRdoesNotAbutCDS on mRNA
*
@@ -1415,7 +1487,7 @@ static char *this_file = __FILE__;
#include <gbftdef.h>
#include <gbfeat.h>
#include <objsub.h>
-#include <asn2ffp.h>
+#include <asn2gnbi.h>
#include <explore.h>
#include <subutil.h>
#include <tofasta.h>
@@ -1453,6 +1525,7 @@ NLM_EXTERN CharPtr FindIDForEntry (SeqEntryPtr sep, CharPtr buf);
NLM_EXTERN void SpellCheckSeqFeat (GatherContextPtr gcp);
NLM_EXTERN void SpellCheckString (ValidStructPtr vsp, CharPtr str);
NLM_EXTERN void SpliceCheck (ValidStructPtr vsp, SeqFeatPtr sfp);
+static void CdConflictCheck (ValidStructPtr vsp, SeqFeatPtr sfp);
static void SpliceCheckEx (ValidStructPtr vsp, SeqFeatPtr sfp, Boolean checkAll);
static void CdsProductIdCheck (ValidStructPtr vsp, SeqFeatPtr sfp);
static void ValidateBioSource (ValidStructPtr vsp, GatherContextPtr gcp, BioSourcePtr biop);
@@ -1460,7 +1533,7 @@ static void ValidatePubdesc (ValidStructPtr vsp, GatherContextPtr gcp, Pubde
static void ValidateSfpCit (ValidStructPtr vsp, GatherContextPtr gcp, SeqFeatPtr sfp);
/* alignment validator */
-NLM_EXTERN Boolean ValidateSeqAlignWithinValidator (ValidStructPtr vsp, SeqEntryPtr sep);
+NLM_EXTERN Boolean ValidateSeqAlignWithinValidator (ValidStructPtr vsp, SeqEntryPtr sep, Boolean find_remote_bsp, Boolean do_hist_assembly);
/*****************************************************************************
*
@@ -1481,9 +1554,12 @@ NLM_EXTERN void ValidStructClear (ValidStructPtr vsp)
Boolean suppressContext;
Boolean validateAlignments;
Boolean farIDsInAlignments;
+ Boolean alignFindRemoteBsp;
+ Boolean doSeqHistAssembly;
Boolean alwaysRequireIsoJTA;
Boolean farFetchCDSproducts;
Boolean validateIDSet;
+ Boolean seqSubmitParent;
TextFsaPtr sourceQualTags;
if (vsp == NULL)
@@ -1500,9 +1576,12 @@ NLM_EXTERN void ValidStructClear (ValidStructPtr vsp)
suppressContext = vsp->suppressContext;
validateAlignments = vsp->validateAlignments;
farIDsInAlignments = vsp->farIDsInAlignments;
+ alignFindRemoteBsp = vsp->alignFindRemoteBsp;
+ doSeqHistAssembly = vsp->doSeqHistAssembly;
alwaysRequireIsoJTA = vsp->alwaysRequireIsoJTA;
farFetchCDSproducts = vsp->farFetchCDSproducts;
validateIDSet = vsp->validateIDSet;
+ seqSubmitParent = vsp->seqSubmitParent;
sourceQualTags = vsp->sourceQualTags;
MemSet ((VoidPtr) vsp, 0, sizeof (ValidStruct));
vsp->errbuf = errbuf;
@@ -1516,9 +1595,12 @@ NLM_EXTERN void ValidStructClear (ValidStructPtr vsp)
vsp->suppressContext = suppressContext;
vsp->validateAlignments = validateAlignments;
vsp->farIDsInAlignments = farIDsInAlignments;
+ vsp->alignFindRemoteBsp = alignFindRemoteBsp;
+ vsp->doSeqHistAssembly = doSeqHistAssembly;
vsp->alwaysRequireIsoJTA = alwaysRequireIsoJTA;
vsp->farFetchCDSproducts = farFetchCDSproducts;
vsp->validateIDSet = validateIDSet;
+ vsp->seqSubmitParent = seqSubmitParent;
vsp->sourceQualTags = sourceQualTags;
return;
}
@@ -2051,8 +2133,11 @@ typedef struct ftprob {
Uint4 num_misplaced_features;
Uint4 num_archaic_locations;
Uint4 num_archaic_products;
+ Uint4 num_misplaced_graphs;
Uint4 num_gene_feats;
Uint4 num_gene_xrefs;
+ Uint4 num_tpa_with_hist;
+ Uint4 num_tpa_without_hist;
} FeatProb, PNTR FeatProbPtr;
static void CheckFeatPacking (BioseqPtr bsp, SeqFeatPtr sfp, Uint4Ptr num_misplaced_features)
@@ -2152,6 +2237,32 @@ static void CheckFeatLocAndProd (SeqFeatPtr sfp, FeatProbPtr fpp)
}
}
+static void CheckGraphPacking (SeqGraphPtr sgp, Pointer userdata)
+
+{
+ BioseqPtr bsp;
+ FeatProbPtr fpp;
+ SeqAnnotPtr sap;
+ BioseqPtr par;
+
+ if (sgp == NULL || userdata == NULL) return;
+ fpp = (FeatProbPtr) userdata;
+ bsp = BioseqFindFromSeqLoc (sgp->loc);
+ if (sgp->idx.parenttype == OBJ_SEQANNOT) {
+ sap = (SeqAnnotPtr) sgp->idx.parentptr;
+ if (sap == NULL) return;
+ if (sap->idx.parenttype == OBJ_BIOSEQ) {
+ /* if graph packaged on bioseq, must be target bioseq */
+ par = (BioseqPtr) sap->idx.parentptr;
+ if (par != bsp && SeqMgrGetParentOfPart (par, NULL) != bsp) {
+ (fpp->num_misplaced_graphs)++;
+ }
+ return;
+ }
+ (fpp->num_misplaced_graphs)++;
+ }
+}
+
static Boolean LIBCALLBACK CountMisplacedFeatures (BioseqPtr bsp, SeqMgrBioseqContextPtr bcontext)
{
FeatProbPtr fpp;
@@ -2188,6 +2299,44 @@ static void CountGeneXrefs (SeqFeatPtr sfp, Pointer userdata)
(fpp->num_gene_xrefs)++;
}
+static Boolean HasTpaUserObject (BioseqPtr bsp)
+
+{
+ SeqMgrDescContext context;
+ UserObjectPtr uop;
+ ObjectIdPtr oip;
+ ValNodePtr vnp;
+
+ if (bsp == NULL) return FALSE;
+ vnp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &context);
+ while (vnp != NULL) {
+ uop = (UserObjectPtr) vnp->data.ptrvalue;
+ if (uop != NULL) {
+ oip = uop->type;
+ if (oip != NULL && StringICmp (oip->str, "TpaAssembly") == 0) return TRUE;
+ }
+ vnp = SeqMgrGetNextDescriptor (bsp, vnp, Seq_descr_user, &context);
+ }
+ return FALSE;
+}
+
+static void CheckTpaHist (BioseqPtr bsp, Pointer userdata)
+
+{
+ FeatProbPtr fpp;
+ SeqHistPtr shp;
+
+ if (bsp == NULL || userdata == NULL) return;
+ fpp = (FeatProbPtr) userdata;
+ if (! HasTpaUserObject (bsp)) return;
+ shp = bsp->hist;
+ if (shp != NULL && shp->assembly != NULL) {
+ (fpp->num_tpa_with_hist)++;
+ } else {
+ (fpp->num_tpa_without_hist)++;
+ }
+}
+
static Boolean IsNoncuratedRefSeq (BioseqPtr bsp, ErrSev *sev)
{
@@ -2258,7 +2407,9 @@ NLM_EXTERN Boolean ValidateSeqEntry (SeqEntryPtr sep, ValidStructPtr vsp)
SeqMgrExploreBioseqs (entityID, NULL, (Pointer) &featprob, CountMisplacedFeatures, TRUE, TRUE, TRUE);
topsep = GetTopSeqEntryForEntityID (entityID);
+ VisitGraphsInSep (topsep, (Pointer) &featprob, CheckGraphPacking);
VisitFeaturesInSep (topsep, (Pointer) &featprob, CountGeneXrefs);
+ VisitBioseqsInSep (topsep, (Pointer) &featprob, CheckTpaHist);
} else {
/* if not using indexing, still need feature->idx.subtype now */
@@ -2283,7 +2434,7 @@ NLM_EXTERN Boolean ValidateSeqEntry (SeqEntryPtr sep, ValidStructPtr vsp)
if (IS_Bioseq_set (sep)) {
bssp = (BioseqSetPtr) (sep->data.ptrvalue);
switch (bssp->_class) {
- case BioseqseqSet_class_genbank:
+ /* case BioseqseqSet_class_genbank: */
case BioseqseqSet_class_pir:
case BioseqseqSet_class_gibb:
case BioseqseqSet_class_gi:
@@ -2364,7 +2515,7 @@ NLM_EXTERN Boolean ValidateSeqEntry (SeqEntryPtr sep, ValidStructPtr vsp)
}
if (first) {
- if (suppress_no_pubs) {
+ if (suppress_no_pubs && (! vsp->seqSubmitParent)) {
omdp = ObjMgrGetData (gc.entityID);
if (omdp == NULL || omdp->datatype != OBJ_SEQSUB) {
sev = SEV_ERROR;
@@ -2385,6 +2536,12 @@ NLM_EXTERN Boolean ValidateSeqEntry (SeqEntryPtr sep, ValidStructPtr vsp)
ValidErr (vsp, SEV_REJECT, ERR_SEQ_PKG_FeaturePackagingProblem, "There is %d mispackaged feature in this record.", (int) featprob.num_misplaced_features);
}
+ if (featprob.num_misplaced_graphs > 1) {
+ ValidErr (vsp, SEV_REJECT, ERR_SEQ_PKG_GraphPackagingProblem, "There are %d mispackaged graphs in this record.", (int) featprob.num_misplaced_graphs);
+ } else if (featprob.num_misplaced_graphs == 1) {
+ ValidErr (vsp, SEV_REJECT, ERR_SEQ_PKG_GraphPackagingProblem, "There is %d mispackaged graph in this record.", (int) featprob.num_misplaced_graphs);
+ }
+
/*
if (featprob.num_archaic_locations > 1) {
ValidErr (vsp, SEV_WARNING, ERR_SEQ_PKG_ArchaicFeatureLocation, "There are %d archaic feature locations in this record.", (int) featprob.num_archaic_locations);
@@ -2403,6 +2560,11 @@ NLM_EXTERN Boolean ValidateSeqEntry (SeqEntryPtr sep, ValidStructPtr vsp)
ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_OnlyGeneXrefs, "There are %ld gene xrefs and no gene features in this record.", (long) featprob.num_gene_xrefs);
}
+ if (featprob.num_tpa_with_hist > 0 && featprob.num_tpa_without_hist > 0) {
+ ValidErr (vsp, SEV_ERROR, ERR_SEQ_INST_TpaAssmeblyProblem, "There are %ld TPAs with history and %ld without history in this record.",
+ (long) featprob.num_tpa_with_hist, (long) featprob.num_tpa_without_hist);
+ }
+
first = FALSE;
}
@@ -2411,13 +2573,13 @@ NLM_EXTERN Boolean ValidateSeqEntry (SeqEntryPtr sep, ValidStructPtr vsp)
topsep = GetTopSeqEntryForEntityID (gc.entityID);
oldsep = SeqEntrySetScope (topsep);
- AssignIDsInEntity (gc.entityID, 0, NULL);
+ /* AssignIDsInEntity (gc.entityID, 0, NULL); */
GatherSeqEntry (sep, (Pointer) vsp, Valid1GatherProc, &gs);
if (vsp->validateAlignments) {
vsp->gcp = NULL;
- ValidateSeqAlignWithinValidator (vsp, sep);
+ ValidateSeqAlignWithinValidator (vsp, sep, vsp->alignFindRemoteBsp, vsp->doSeqHistAssembly);
vsp->gcp = NULL;
}
@@ -3392,6 +3554,7 @@ static void ValidateBioseqInst (GatherContextPtr gcp)
Boolean isGenBankEMBLorDDBJ;
Boolean isPatent = FALSE;
Boolean isPDB = FALSE;
+ Boolean isNC = FALSE;
Boolean isNTorNC = FALSE;
Boolean isNZ;
Boolean is_gps = FALSE;
@@ -3451,6 +3614,7 @@ static void ValidateBioseqInst (GatherContextPtr gcp)
isNTorNC = TRUE;
} else if (StringNICmp (tsip->accession, "NC_", 3) == 0) {
isNTorNC = TRUE;
+ isNC = TRUE;
}
}
} else if (sip1->choice == SEQID_GI) {
@@ -3473,7 +3637,7 @@ static void ValidateBioseqInst (GatherContextPtr gcp)
case SEQID_TPD:
hist = bsp->hist;
if (hist == NULL || hist->assembly == NULL) {
- if (ISA_na (bsp->mol)) {
+ if (ISA_na (bsp->mol) && bsp->repr != Seq_repr_seg) {
SeqIdWrite (bsp->id, buf1, PRINTID_FASTA_SHORT, 40);
ValidErr (vsp, SEV_ERROR, ERR_SEQ_INST_HistAssemblyMissing, "TPA record %s should have Seq-hist.assembly for PRIMARY block", buf1);
}
@@ -4107,6 +4271,14 @@ static void ValidateBioseqInst (GatherContextPtr gcp)
ValidErr (vsp, SEV_ERROR, ERR_SEQ_INST_SeqDataLenWrong, "-1 length on seq-loc of delta seq_ext");
else
len += len2;
+ if (len2 <= 10) {
+ str = SeqLocPrint ((SeqLocPtr) (vnp->data.ptrvalue));
+ if (str == NULL) {
+ str = StringSave ("?");
+ }
+ ValidErr (vsp, SEV_WARNING, ERR_SEQ_INST_SeqLocLength, "Short length (%ld) on seq-loc (%s) of delta seq_ext", (long) len2, str);
+ MemFree (str);
+ }
break;
case 2: /* SeqLitPtr */
slitp = (SeqLitPtr) (vnp->data.ptrvalue);
@@ -4380,7 +4552,9 @@ static void ValidateBioseqInst (GatherContextPtr gcp)
str = GetSequenceByFeature (sfp);
if (str != NULL) {
if (str [0] == 'n' || str [0] == 'N') {
- if (StringICmp (str, "NNNNNNNNNN") == 0) {
+ if (isNC) {
+ sev = SEV_WARNING;
+ } else if (StringICmp (str, "NNNNNNNNNN") == 0) {
sev = SEV_ERROR;
} else {
sev = SEV_WARNING;
@@ -4396,7 +4570,9 @@ static void ValidateBioseqInst (GatherContextPtr gcp)
len = StringLen (str);
if (str != NULL && len > 0) {
if (str [len - 1] == 'n' || str [len - 1] == 'N') {
- if (StringICmp (str, "NNNNNNNNNN") == 0) {
+ if (isNC) {
+ sev = SEV_WARNING;
+ } else if (StringICmp (str, "NNNNNNNNNN") == 0) {
sev = SEV_ERROR;
} else {
sev = SEV_WARNING;
@@ -4499,13 +4675,59 @@ static Boolean IS_NC_IN_SEP (SeqEntryPtr sep)
return is_nc;
}
+static void ValidateCitSub (ValidStructPtr vsp, CitSubPtr csp)
+{
+ AffilPtr ap;
+ AuthListPtr alp;
+ ValNodePtr name;
+ Boolean hasAffil = FALSE;
+ Boolean hasName = FALSE;
+
+ if (vsp == NULL || csp == NULL)
+ return;
+ alp = csp->authors;
+ if (alp != NULL) {
+ if (alp->choice == 1) {
+ for (name = alp->names; name != NULL; name = name->next) {
+ if (!HasNoName (name)) {
+ hasName = TRUE;
+ }
+ }
+ } else if (alp->choice == 2 || alp->choice == 3) {
+ for (name = alp->names; name != NULL; name = name->next) {
+ if (!HasNoText ((CharPtr) name->data.ptrvalue)) {
+ hasName = TRUE;
+ }
+ }
+ }
+ ap = alp->affil;
+ if (ap != NULL) {
+ if (ap->affil == NULL && ap->div == NULL && ap->street == NULL && ap->city == NULL &&
+ ap->sub == NULL && ap->postal_code == NULL && ap->country == NULL &&
+ ap->phone == NULL && ap->fax == NULL && ap->email == NULL) {
+ /* no affiliation */
+ } else {
+ hasAffil = TRUE;
+ }
+ }
+ }
+ if (!hasName) {
+ ValidErr (vsp, SEV_ERROR, ERR_GENERIC_MissingPubInfo, "Submission citation has no author names");
+ }
+ if (!hasAffil) {
+ ValidErr (vsp, SEV_ERROR, ERR_GENERIC_MissingPubInfo, "Submission citation has no affiliation");
+ }
+}
+
static void ValidatePubdesc (ValidStructPtr vsp, GatherContextPtr gcp, PubdescPtr pdp)
{
AuthListPtr alp;
CitArtPtr cap = NULL;
CitGenPtr cgp;
CitJourPtr cjp = NULL;
- Boolean hasName, hasTitle, hasIsoJTA = FALSE, inPress = FALSE;
+ CitSubPtr csp;
+ Boolean hasName, hasTitle, hasIsoJTA = FALSE,
+ inPress = FALSE, electronic_journal = FALSE;
ImprintPtr imp;
Boolean noVol, noPages;
ValNodePtr name;
@@ -4543,6 +4765,12 @@ static void ValidatePubdesc (ValidStructPtr vsp, GatherContextPtr gcp, PubdescPt
uid = vnp->data.intvalue;
}
break;
+ case PUB_Sub :
+ csp = (CitSubPtr) vnp->data.ptrvalue;
+ if (csp != NULL) {
+ ValidateCitSub (vsp, csp);
+ }
+ break;
case PUB_Article:
cap = (CitArtPtr) vnp->data.ptrvalue;
hasName = FALSE;
@@ -4588,6 +4816,11 @@ static void ValidatePubdesc (ValidStructPtr vsp, GatherContextPtr gcp, PubdescPt
}
if (!HasNoText ((CharPtr) title->data.ptrvalue)) {
hasTitle = TRUE;
+ if (title->choice == Cit_title_name) {
+ if (StringNCmp ((CharPtr) title->data.ptrvalue, "(er)", 4) == 0) {
+ electronic_journal = TRUE;
+ }
+ }
}
}
if (!hasTitle) {
@@ -4608,7 +4841,9 @@ static void ValidatePubdesc (ValidStructPtr vsp, GatherContextPtr gcp, PubdescPt
if (noVol && noPages) {
ValidErr (vsp, sev, ERR_GENERIC_MissingPubInfo, "Journal volume and pages missing");
} else if (noVol) {
- ValidErr (vsp, sev, ERR_GENERIC_MissingPubInfo, "Journal volume missing");
+ if (! electronic_journal) {
+ ValidErr (vsp, sev, ERR_GENERIC_MissingPubInfo, "Journal volume missing");
+ }
} else if (noPages) {
ValidErr (vsp, sev, ERR_GENERIC_MissingPubInfo, "Journal pages missing");
}
@@ -4657,7 +4892,9 @@ static void ValidatePubdesc (ValidStructPtr vsp, GatherContextPtr gcp, PubdescPt
}
if (cap != NULL && cjp != NULL && (uid > 0 || inPress || vsp->alwaysRequireIsoJTA)) {
if (! hasIsoJTA) {
- ValidErr (vsp, SEV_WARNING, ERR_GENERIC_MissingPubInfo, "ISO journal title abbreviation missing");
+ if (! electronic_journal) {
+ ValidErr (vsp, SEV_WARNING, ERR_GENERIC_MissingPubInfo, "ISO journal title abbreviation missing");
+ }
}
}
}
@@ -5059,6 +5296,7 @@ static CharPtr countrycodes[] = {
"Djibouti",
"Dominica",
"Dominican Republic",
+ "East Timor",
"Ecuador",
"Egypt",
"El Salvador",
@@ -5488,7 +5726,9 @@ static void ValidateBioSource (ValidStructPtr vsp, GatherContextPtr gcp, BioSour
return;
onp = orp->orgname;
if (onp == NULL || StringHasNoText (onp->lineage)) {
- ValidErr (vsp, SEV_ERROR, ERR_SEQ_DESCR_MissingLineage, "No lineage for this BioSource.");
+ if (! vsp->seqSubmitParent) { /* suppress when validator run from tbl2asn */
+ ValidErr (vsp, SEV_ERROR, ERR_SEQ_DESCR_MissingLineage, "No lineage for this BioSource.");
+ }
} else {
if (biop->genome == GENOME_kinetoplast) {
if (StringStr (onp->lineage, "Kinetoplastida") == 0) {
@@ -5520,8 +5760,8 @@ static void ValidateBioSource (ValidStructPtr vsp, GatherContextPtr gcp, BioSour
id = -1;
dbt = (DbtagPtr) db->data.ptrvalue;
if (dbt != NULL && dbt->db != NULL) {
- for (i = 0; i < DBNUM; i++) {
- if (StringCmp (dbt->db, dbtag [i]) == 0) {
+ for (i = 0; legalDbXrefs [i] != NULL; i++) {
+ if (StringCmp (dbt->db, legalDbXrefs [i]) == 0) {
id = i;
break;
}
@@ -5541,7 +5781,9 @@ static void ValidateBioSource (ValidStructPtr vsp, GatherContextPtr gcp, BioSour
return;
}
}
- ValidErr (vsp, SEV_WARNING, ERR_SEQ_DESCR_NoTaxonID, "BioSource is missing taxon ID");
+ if (! vsp->seqSubmitParent) { /* suppress when validator run from tbl2asn */
+ ValidErr (vsp, SEV_WARNING, ERR_SEQ_DESCR_NoTaxonID, "BioSource is missing taxon ID");
+ }
}
static Boolean IsXr (ValNodePtr sdp)
@@ -6007,35 +6249,6 @@ static void ValidateSeqDescrContext (GatherContextPtr gcp)
* Gather callback for validating context on a Bioseq
*
*****************************************************************************/
-static void ValidateCitSub (ValidStructPtr vsp, CitSubPtr csp)
-{
- AuthListPtr alp;
- ValNodePtr name;
- Boolean hasName = FALSE;
-
- if (vsp == NULL || csp == NULL)
- return;
- alp = csp->authors;
- if (alp != NULL) {
- if (alp->choice == 1) {
- for (name = alp->names; name != NULL; name = name->next) {
- if (!HasNoName (name)) {
- hasName = TRUE;
- }
- }
- } else if (alp->choice == 2 || alp->choice == 3) {
- for (name = alp->names; name != NULL; name = name->next) {
- if (!HasNoText ((CharPtr) name->data.ptrvalue)) {
- hasName = TRUE;
- }
- }
- }
- }
- if (!hasName) {
- ValidErr (vsp, SEV_ERROR, ERR_GENERIC_MissingPubInfo, "Submission citation has no author names");
- }
-}
-
static Boolean DifferentDbxrefs (ValNodePtr dbxref1, ValNodePtr dbxref2)
{
DbtagPtr dbt1, dbt2;
@@ -6224,6 +6437,7 @@ static Boolean ValidateBioseqContextIndexed (BioseqPtr bsp, BioseqValidStrPtr bv
SeqFeatPtr sfp;
SeqMgrFeatContext fcontext;
Uint2 featdeftype = 0;
+ Boolean firstCDS;
SeqFeatPtr last = NULL;
Boolean leave;
CharPtr label = NULL;
@@ -6250,6 +6464,7 @@ static Boolean ValidateBioseqContextIndexed (BioseqPtr bsp, BioseqValidStrPtr bv
OrgRefPtr orp = NULL;
Int4 fiveUTRright;
Int4 cdsRight;
+ Int4 threeUTRright;
gcp = bvsp->gcp;
vsp = bvsp->vsp;
@@ -6437,13 +6652,15 @@ static Boolean ValidateBioseqContextIndexed (BioseqPtr bsp, BioseqValidStrPtr bv
if (bvsp->is_mrna) {
fiveUTRright = 0;
cdsRight = 0;
+ threeUTRright = 0;
+ firstCDS = TRUE;
sfp = SeqMgrGetNextFeature (bsp, NULL, 0, 0, &fcontext);
while (sfp != NULL) {
if (sfp->idx.subtype == FEATDEF_5UTR) {
fiveUTRright = fcontext.right;
} else if (sfp->idx.subtype == FEATDEF_CDS) {
cdsRight = fcontext.right;
- if (fiveUTRright > 0) {
+ if (fiveUTRright > 0 && firstCDS) {
if (fiveUTRright + 1 != fcontext.left) {
if (gcp != NULL) {
gcp->itemID = fcontext.itemID;
@@ -6459,8 +6676,23 @@ static Boolean ValidateBioseqContextIndexed (BioseqPtr bsp, BioseqValidStrPtr bv
}
}
}
+ firstCDS = FALSE;
} else if (sfp->idx.subtype == FEATDEF_3UTR) {
- if (cdsRight > 0) {
+ if (threeUTRright > 0) {
+ if (threeUTRright + 1 != fcontext.left) {
+ if (gcp != NULL) {
+ gcp->itemID = fcontext.itemID;
+ gcp->thistype = OBJ_SEQFEAT;
+ }
+ vsp->descr = NULL;
+ vsp->sfp = sfp;
+ ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_UTRdoesNotAbutCDS, "Previous 3'UTR does not abut next 3'UTR");
+ if (gcp != NULL) {
+ gcp->itemID = olditemid;
+ gcp->thistype = olditemtype;
+ }
+ }
+ } else if (cdsRight > 0) {
if (cdsRight + 1 != fcontext.left) {
if (gcp != NULL) {
gcp->itemID = fcontext.itemID;
@@ -6475,6 +6707,7 @@ static Boolean ValidateBioseqContextIndexed (BioseqPtr bsp, BioseqValidStrPtr bv
}
}
}
+ threeUTRright = fcontext.right;
}
sfp = SeqMgrGetNextFeature (bsp, sfp, 0, 0, &fcontext);
}
@@ -6491,7 +6724,18 @@ static Boolean ValidateBioseqContextIndexed (BioseqPtr bsp, BioseqValidStrPtr bv
bvsp->got_a_pub = TRUE;
csp = sbp->cit;
/* csp = (CitSubPtr) gcp->thisitem; */
+ if (gcp != NULL) {
+ gcp->itemID = 1;
+ gcp->thistype = OBJ_SEQSUB_CIT;
+ }
+ vsp->descr = NULL;
+ vsp->sfp = NULL;
+ vsp->bssp = NULL;
ValidateCitSub (vsp, csp);
+ if (gcp != NULL) {
+ gcp->itemID = olditemid;
+ gcp->thistype = olditemtype;
+ }
}
}
}
@@ -6607,7 +6851,7 @@ static void ValidateBioseqContext (GatherContextPtr gcp)
if (vnp != NULL) {
biop = (BioSourcePtr) vnp->data.ptrvalue;
if (biop != NULL) {
- if (biop->origin == ORG_ARTIFICIAL) {
+ if (biop->origin == ORG_ARTIFICIAL || biop->origin == ORG_MUT || biop->origin == ORG_SYNTHETIC) {
bvs.is_artificial = TRUE;
}
}
@@ -6680,7 +6924,7 @@ static void ValidateBioseqContext (GatherContextPtr gcp)
vsp->descr = NULL;
vsp->sfp = NULL;
- if ((!bvs.got_a_pub) && (!vsp->suppress_no_pubs)) {
+ if ((!bvs.got_a_pub) && (!vsp->suppress_no_pubs) && (! vsp->seqSubmitParent)) {
omdp = NULL;
if (gcp != NULL) {
omdp = ObjMgrGetData (gcp->entityID);
@@ -7273,7 +7517,9 @@ static void CheckTrnaCodons (ValidStructPtr vsp, GatherContextPtr gcp, SeqFeatPt
if (aa == 'U') {
sev = SEV_WARNING;
}
- ValidErr (vsp, sev, ERR_SEQ_FEAT_TrnaCodonWrong, "tRNA codon does not match genetic code");
+ if (StringISearch (sfp->except_text, "modified codon recognition") == NULL) {
+ ValidErr (vsp, sev, ERR_SEQ_FEAT_TrnaCodonWrong, "tRNA codon does not match genetic code");
+ }
}
}
} else if (trp->codon [j] < 255) {
@@ -7712,8 +7958,8 @@ static void CheckForIllegalDbxref (ValidStructPtr vsp, GatherContextPtr gcp, Seq
id = -1;
db = vnp->data.ptrvalue;
if (db != NULL && db->db != NULL) {
- for (i = 0; i < DBNUM; i++) {
- if (StringCmp (db->db, dbtag[i]) == 0) {
+ for (i = 0; legalDbXrefs [i] != NULL; i++) {
+ if (StringCmp (db->db, legalDbXrefs [i]) == 0) {
id = i;
break;
}
@@ -7766,6 +8012,7 @@ static CharPtr legal_exception_strings [] = {
"non-consensus splice site",
"nonconsensus splice site",
"rearrangement required for product",
+ "modified codon recognition",
NULL
};
@@ -7815,7 +8062,7 @@ static void ValidateExceptText (ValidStructPtr vsp, GatherContextPtr gcp, SeqFea
if (IsNCorNT (vsp->sep, sfp->location)) {
sev = SEV_WARNING;
}
- ValidErr (vsp, sev, ERR_SEQ_FEAT_InvalidQualifierValue, "%s is not legal exception explanation", tmp);
+ ValidErr (vsp, sev, ERR_SEQ_FEAT_InvalidQualifierValue, "%s is not a legal exception explanation", tmp);
}
}
tmp = ptr;
@@ -8003,6 +8250,9 @@ NLM_EXTERN void ValidateSeqFeat (GatherContextPtr gcp)
TextSeqIdPtr tsip;
BioseqPtr protBsp;
ErrSev sev;
+ Boolean multitoken;
+ Char ch;
+ CharPtr ptr;
vsp = (ValidStructPtr) (gcp->userdata);
sfp = (SeqFeatPtr) (gcp->thisitem);
@@ -8151,6 +8401,17 @@ NLM_EXTERN void ValidateSeqFeat (GatherContextPtr gcp)
grp->db == NULL && grp->syn == NULL) {
ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_GeneRefHasNoData, "There is a gene feature where all fields are empty");
}
+ if (! StringHasNoText (grp->locus_tag)) {
+ multitoken = FALSE;
+ for (ptr = grp->locus_tag, ch = *ptr; ch != '\0'; ptr++, ch = *ptr) {
+ if (IS_WHITESP (ch)) {
+ multitoken = TRUE;
+ }
+ }
+ if (multitoken) {
+ ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_LocusTagProblem, "Gene locus_tag '%s' should be a single word without any spaces", grp->locus_tag);
+ }
+ }
CheckForIllegalDbxref (vsp, gcp, sfp, grp->db);
/*
for (vnp = grp->db; vnp != NULL; vnp = vnp->next) {
@@ -8215,6 +8476,8 @@ NLM_EXTERN void ValidateSeqFeat (GatherContextPtr gcp)
if ((!pseudo) && (!conflict)) {
CdTransCheck (vsp, sfp);
SpliceCheck (vsp, sfp);
+ } else if (conflict) {
+ CdConflictCheck (vsp, sfp);
}
CdsProductIdCheck (vsp, sfp);
crp = (CdRegionPtr) (sfp->data.value.ptrvalue);
@@ -8276,12 +8539,14 @@ NLM_EXTERN void ValidateSeqFeat (GatherContextPtr gcp)
}
}
if (biopgencode != cdsgencode) {
- if (plastid) {
- ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_GenCodeMismatch,
- "Genetic code conflict between CDS (code %d) and BioSource.genome biological context (%s) (uses code 11)", (int) cdsgencode, plastidtxt [biop->genome]);
- } else {
- ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_GenCodeMismatch,
- "Genetic code conflict between CDS (code %d) and BioSource (code %d)", (int) cdsgencode, (int) biopgencode);
+ if (! vsp->seqSubmitParent) { /* suppress when validator run from tbl2asn */
+ if (plastid) {
+ ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_GenCodeMismatch,
+ "Genetic code conflict between CDS (code %d) and BioSource.genome biological context (%s) (uses code 11)", (int) cdsgencode, plastidtxt [biop->genome]);
+ } else {
+ ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_GenCodeMismatch,
+ "Genetic code conflict between CDS (code %d) and BioSource (code %d)", (int) cdsgencode, (int) biopgencode);
+ }
}
}
}
@@ -8808,6 +9073,31 @@ static Boolean Loc_is_RefSeq (SeqLocPtr location)
return FALSE;
}
+static void CdConflictCheck (ValidStructPtr vsp, SeqFeatPtr sfp)
+
+{
+ ByteStorePtr bs;
+ BioseqPtr bsp;
+ CharPtr str1, str2;
+
+ if (sfp == NULL || vsp == NULL) return;
+
+ bsp = BioseqFindFromSeqLoc (sfp->product);
+ str1 = GetSequenceByBsp (bsp);
+ bs = TransTableTranslateCdRegion (NULL, sfp, FALSE, FALSE, TRUE);
+ str2 = (CharPtr) BSMerge (bs, NULL);
+ BSFree (bs);
+
+ if (str1 != NULL && str2 != NULL && StringCmp (str1, str2) == 0) {
+ ValidErr (vsp, SEV_ERROR, ERR_SEQ_FEAT_BadConflictFlag, "Coding region conflict flag should not be set");
+ } else {
+ ValidErr (vsp, SEV_WARNING, ERR_SEQ_FEAT_ConflictFlagSet, "Coding region conflict flag is set");
+ }
+
+ MemFree (str1);
+ MemFree (str2);
+}
+
static CharPtr bypass_cds_trans_check [] = {
"RNA editing",
"reasons given in citation",
@@ -9765,26 +10055,20 @@ typedef struct grphitem
}
GrphItem , PNTR GrphItemPtr;
-static Boolean GetGraphsProc (GatherObjectPtr gop)
+static void GetGraphsProc (SeqGraphPtr sgp, Pointer userdata)
{
GphGetPtr ggp;
GrphItemPtr gip;
- SeqGraphPtr sgp;
- if (gop == NULL || gop->itemtype != OBJ_SEQGRAPH)
- return TRUE;
- ggp = (GphGetPtr) gop->userdata;
- sgp = (SeqGraphPtr) gop->dataptr;
- if (ggp == NULL || sgp == NULL)
- return TRUE;
+ ggp = (GphGetPtr) userdata;
+ if (ggp == NULL || sgp == NULL) return;
/* only phrap or gap4 currently allowed */
if (StringICmp (sgp->title, "Phrap Quality") == 0 || StringICmp (sgp->title, "Phred Quality") == 0 || StringICmp (sgp->title, "Gap4") == 0) {
/* data type must be bytes */
if (sgp->flags[2] == 3) {
if (SeqIdIn (SeqLocId (sgp->loc), ggp->bsp->id)) {
gip = (GrphItemPtr) MemNew (sizeof (GrphItem));
- if (gip == NULL)
- return TRUE;
+ if (gip == NULL) return;
gip->sgp = sgp;
gip->left = GetOffsetInBioseq (sgp->loc, ggp->bsp, SEQLOC_LEFT_END);
gip->right = GetOffsetInBioseq (sgp->loc, ggp->bsp, SEQLOC_RIGHT_END);
@@ -9792,7 +10076,7 @@ static Boolean GetGraphsProc (GatherObjectPtr gop)
}
}
}
- return TRUE;
+ return;
}
static int LIBCALLBACK SortSeqGraphProc (VoidPtr ptr1, VoidPtr ptr2)
@@ -9826,17 +10110,14 @@ static int LIBCALLBACK SortSeqGraphProc (VoidPtr ptr1, VoidPtr ptr2)
static ValNodePtr GetSeqGraphsOnBioseq (Uint2 entityID, BioseqPtr bsp)
{
- GphGetData ggd;
- GrphItemPtr gip;
- Int2 index;
- Boolean objMgrFilter[OBJ_MAX];
- ValNodePtr vnp;
+ GphGetData ggd;
+ GrphItemPtr gip;
+ Int2 index;
+ ValNodePtr vnp;
ggd.vnp = NULL;
ggd.bsp = bsp;
- MemSet ((Pointer) &objMgrFilter, 0, sizeof (objMgrFilter));
- objMgrFilter[OBJ_SEQGRAPH] = TRUE;
- GatherObjectsInEntity (entityID, 0, NULL, GetGraphsProc, (Pointer) &ggd, objMgrFilter);
+ VisitGraphsOnBsp (bsp, (Pointer) &ggd, GetGraphsProc);
for (vnp = ggd.vnp, index = 1; vnp != NULL; vnp = vnp->next, index++) {
gip = (GrphItemPtr) vnp->data.ptrvalue;
if (gip != NULL) {
@@ -9863,10 +10144,10 @@ static Boolean NextLitLength (DeltaSeqPtr next, Int4Ptr lenp)
static void ValidateGraphsOnBioseq (GatherContextPtr gcp)
{
- Byte bases[400];
+ Byte bases[400], scores [400];
ByteStorePtr bs;
BioseqPtr bsp;
- Int2 ctr, i, val, index;
+ Int2 ctr, i, k, val, index, scount;
Int4 curroffset = 0, gphlen = 0, seqlen = 0, slplen,
bslen, min = INT4_MAX, max = INT4_MIN, j, lastloc = -1,
NsWithScore, GapsWithScore, ACGTsWithoutScore, valsBelowMin,
@@ -10122,6 +10403,9 @@ static void ValidateGraphsOnBioseq (GatherContextPtr gcp)
i = 0;
residue = (Uint1) bases[i];
+ scount = (Int2) BSRead (bs, scores, sizeof (scores));
+ k = 0;
+
NsWithScore = 0;
GapsWithScore = 0;
ACGTsWithoutScore = 0;
@@ -10133,7 +10417,19 @@ static void ValidateGraphsOnBioseq (GatherContextPtr gcp)
while (residue != SEQPORT_EOF && j < sgp->numval) {
if (IS_residue (residue)) {
- val = (Int2) BSGetByte (bs);
+ /* val = (Int2) BSGetByte (bs); */
+ if (k >= scount) {
+ if (scount > 0) {
+ scount = (Int2) BSRead (bs, scores, sizeof (scores));
+ }
+ k = 0;
+ }
+ if (scount > 0) {
+ val = (Int2) scores [k];
+ k++;
+ } else {
+ val = 0;
+ }
if (val < sgp->min.intvalue || val < 0) {
valsBelowMin++;
}
diff --git a/api/valid.h b/api/valid.h
index 8c210331..b15a5828 100644
--- a/api/valid.h
+++ b/api/valid.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/94
*
-* $Revision: 6.10 $
+* $Revision: 6.12 $
*
* File Description: Sequence editing utilities
*
@@ -39,6 +39,12 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: valid.h,v $
+* Revision 6.12 2003/12/02 15:37:37 kans
+* added vsp->seqSubmitParent for use by tbl2asn, which usually has a Seq-submit wrapper that is added on-the-fly and not indexed
+*
+* Revision 6.11 2003/11/14 18:07:17 kans
+* alignment parameters to find remote bsp, do seqhist assembly
+*
* Revision 6.10 2003/03/05 18:47:45 ford
* Added prototype for IsNuclAcc().
*
@@ -151,8 +157,8 @@ typedef struct validstruct {
CharPtr errbuf;
Boolean patch_seq; /* repair invalid sequence residues? */
Boolean non_ascii_chars; /* non ascii chars found in read? */
- Boolean suppress_no_pubs;
- Boolean suppress_no_biosrc;
+ Boolean suppress_no_pubs; /* internal use for no pub anywhere message */
+ Boolean suppress_no_biosrc; /* internal use for no biosource anywhere message */
SpellCheckFunc spellfunc;
SpellCallBackFunc spellcallback;
GatherContextPtr gcp; /* used for reporting the errors */
@@ -164,9 +170,12 @@ typedef struct validstruct {
Boolean suppressContext; /* suppress context part of message */
Boolean validateAlignments; /* call alignval test suite */
Boolean farIDsInAlignments; /* fetch to get far IDs in alignments */
+ Boolean alignFindRemoteBsp; /* do remote fetching in alignment validation */
+ Boolean doSeqHistAssembly; /* do alignment validation in Seq-hist.assembly */
Boolean alwaysRequireIsoJTA; /* force check for iso_jta */
Boolean farFetchCDSproducts; /* lock CDS->products for CdTransCheck, if necessary */
Boolean validateIDSet; /* look for gain or loss of general IDs on sequence update */
+ Boolean seqSubmitParent; /* flag from tbl2asn to suppress no pub message */
TextFsaPtr sourceQualTags; /* for detecting structured qual tags in notes */
} ValidStruct, PNTR ValidStructPtr;
diff --git a/api/valid.msg b/api/valid.msg
index a7923795..bc138e16 100644
--- a/api/valid.msg
+++ b/api/valid.msg
@@ -159,6 +159,13 @@ $^ SeqLitGapLength0, 43
A SeqLit component of a delta Bioseq can specify a gap, but it should not be a gap
of 0 length.
+$^ TpaAssmeblyProblem, 44
+Third party annotation records should have a TpaAssembly user object and a
+Seq-hist.assembly alignment for the PRIMARY block.
+
+$^ SeqLocLength, 45
+A SeqLoc component of a delta Bioseq is suspiciously small.
+
$$ SEQ_DESCR, 2
$^ BioSourceMissing, 1
@@ -334,6 +341,9 @@ A feature location should refer to the accession or gi number, not a local or ge
$^ ArchaicFeatureProduct, 14
A feature product should refer to the accession or gi number, not a local or general ID.
+$^ GraphPackagingProblem, 15
+A graph should be packaged on its bioseq, or on a set containing the Bioseq.
+
$$ SEQ_FEAT, 5
$^ InvalidForType, 1
@@ -608,6 +618,17 @@ the inheritance by overlap.
$^ UTRdoesNotAbutCDS, 66
The 5'UTR and 3'UTR features should exactly abut the CDS feature.
+$^ BadConflictFlag, 67
+The coding region conflict flag is set, but the translated product is the
+same as the instantiated product Bioseq.
+
+$^ ConflictFlagSet, 68
+The coding region conflict flag is appropriately set, but this record should
+be brought to the attention of the source database for possible correction.
+
+$^ LocusTagProblem, 69
+A gene locus_tag should be a single token, with no spaces.
+
$$ SEQ_ALIGN, 6
$^ SeqIdProblem, 1
diff --git a/api/validerr.h b/api/validerr.h
index b4ced162..a6806594 100644
--- a/api/validerr.h
+++ b/api/validerr.h
@@ -45,6 +45,8 @@
#define ERR_SEQ_INST_UnexpectedIdentifierChange 1,41
#define ERR_SEQ_INST_InternalNsInSeqLit 1,42
#define ERR_SEQ_INST_SeqLitGapLength0 1,43
+#define ERR_SEQ_INST_TpaAssmeblyProblem 1,44
+#define ERR_SEQ_INST_SeqLocLength 1,45
#define ERR_SEQ_DESCR 2,0
#define ERR_SEQ_DESCR_BioSourceMissing 2,1
#define ERR_SEQ_DESCR_InvalidForType 2,2
@@ -93,6 +95,7 @@
#define ERR_SEQ_PKG_InconsistentMolInfoBiomols 4,12
#define ERR_SEQ_PKG_ArchaicFeatureLocation 4,13
#define ERR_SEQ_PKG_ArchaicFeatureProduct 4,14
+#define ERR_SEQ_PKG_GraphPackagingProblem 4,15
#define ERR_SEQ_FEAT 5,0
#define ERR_SEQ_FEAT_InvalidForType 5,1
#define ERR_SEQ_FEAT_PartialProblem 5,2
@@ -160,6 +163,9 @@
#define ERR_SEQ_FEAT_BadTrnaAA 5,64
#define ERR_SEQ_FEAT_OnlyGeneXrefs 5,65
#define ERR_SEQ_FEAT_UTRdoesNotAbutCDS 5,66
+#define ERR_SEQ_FEAT_BadConflictFlag 5,67
+#define ERR_SEQ_FEAT_ConflictFlagSet 5,68
+#define ERR_SEQ_FEAT_LocusTagProblem 5,69
#define ERR_SEQ_ALIGN 6,0
#define ERR_SEQ_ALIGN_SeqIdProblem 6,1
#define ERR_SEQ_ALIGN_StrandRev 6,2
diff --git a/asnlib/asn.h b/asnlib/asn.h
index aecb424e..1f3179a1 100644
--- a/asnlib/asn.h
+++ b/asnlib/asn.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/91
*
-* $Revision: 6.10 $
+* $Revision: 6.11 $
*
* File Description:
* This header the interface to all the routines in the ASN.1 libraries
@@ -48,6 +48,9 @@
* 02-24-94 Schuler AsnTypeStringToHex moved here (from asntypes.h)
*
* $Log: asn.h,v $
+* Revision 6.11 2003/12/03 19:31:09 gouriano
+* Corrected DTD generation (a different approach)
+*
* Revision 6.10 2003/09/15 16:16:32 kans
* added AsnWriteEx, AsnTxtWriteEx, and AsnPrintStream
*
@@ -390,6 +393,7 @@ NLM_EXTERN AsnTypePtr LIBCALL AsnTypeFind PROTO((AsnModulePtr amp, CharPtr str))
#define AsnFind(x) AsnTypeFind(NULL,x) /* find type (all) */
NLM_EXTERN CharPtr LIBCALL AsnFindPrimName PROTO((AsnTypePtr atp));
NLM_EXTERN AsnTypePtr LIBCALL AsnFindBaseType PROTO((AsnTypePtr atp));
+NLM_EXTERN AsnTypePtr LIBCALL AsnFindBaseTypeDTD PROTO((AsnTypePtr atp));
NLM_EXTERN CharPtr LIBCALL AsnFindBaseName PROTO((AsnTypePtr atp));
NLM_EXTERN Int2 LIBCALL AsnFindBaseIsa PROTO((AsnTypePtr atp));
NLM_EXTERN AsnTypePtr LIBCALL AsnLinkType PROTO((AsnTypePtr type, AsnTypePtr localtype));
diff --git a/asnlib/asndebin.c b/asnlib/asndebin.c
index 124b32e4..86e1c4f6 100644
--- a/asnlib/asndebin.c
+++ b/asnlib/asndebin.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/4/91
*
-* $Revision: 6.5 $
+* $Revision: 6.6 $
*
* File Description:
* Special binary form (BER) decoder for ASN.1
@@ -45,6 +45,9 @@
* 08-01-93 Gish AsnDeBinReadString calls MemGet instead of MemNew
*
* $Log: asndebin.c,v $
+* Revision 6.6 2003/12/10 15:41:19 sirotkin
+* As per toolkit RT request 15030485 and Jim Ostell, afety checks after ato2=AsnFindBaseIsa(atp) were added.
+*
* Revision 6.5 2002/10/09 19:16:31 ivanov
* Fixed buffer overrun in the AsnDeBinReadReal()
*
@@ -118,9 +121,15 @@ NLM_EXTERN AsnTypePtr LIBCALL AsnBinReadId (AsnIoPtr aip, AsnTypePtr atp)
if (used == ASNDEBIN_EOF) /* end of file */
return NULL;
+ /* see RT toolbox ticket 15030485 for the below fix */
atp2 = AsnFindBaseType(atp); /* find the base type */
- if (atp2 == NULL) return NULL;
+ if (atp2 == NULL)
+ return atp2;
+ if (atp2->type == NULL)
+ return atp2->type;
+ isa = atp2->type->isa;
+
if (atp2->type->isa != CHOICE_TYPE)
{
diff --git a/asnlib/asnenbin.c b/asnlib/asnenbin.c
index 1c34be40..afcf1432 100644
--- a/asnlib/asnenbin.c
+++ b/asnlib/asnenbin.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/4/91
*
-* $Revision: 6.5 $
+* $Revision: 6.6 $
*
* File Description:
* Special binary (BER) encoder for ASN.1
@@ -42,6 +42,9 @@
* 04-20-93 Schuler LIBCALL calling convention
*
* $Log: asnenbin.c,v $
+* Revision 6.6 2003/11/07 20:57:02 beloslyu
+* fix the c++ style comments to a C ones
+*
* Revision 6.5 2003/08/01 16:55:24 gouriano
* workaround MSVC++.NET optimization bug
*
@@ -360,7 +363,7 @@ NLM_EXTERN void AsnEnBinInteger (Int4 theInt, AsnIoPtr aip, AsnTypePtr atp)
{
for (i = 0; i < 3; i++)
octets[i] = octets[i+1];
-// dirty workaround of an optimization bug of MSVC++.NET compiler
+/* dirty workaround of an optimization bug of MSVC++.NET compiler */
#if defined(_MSC_VER)
# if _MSC_VER < 1300
octets[3] = 0;
@@ -424,7 +427,7 @@ NLM_EXTERN void AsnEnBinBigInt (Int8 theInt, AsnIoPtr aip, AsnTypePtr atp)
{
for (i = 0; i < 7; i++)
octets[i] = octets[i+1];
-// dirty workaround of an optimization bug of MSVC++.NET compiler
+/* dirty workaround of an optimization bug of MSVC++.NET compiler */
#if defined(_MSC_VER)
# if _MSC_VER < 1300
octets[7] = 0;
diff --git a/asnlib/asnprint.c b/asnlib/asnprint.c
index 5328c5c4..5d142c66 100644
--- a/asnlib/asnprint.c
+++ b/asnlib/asnprint.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/4/91
*
-* $Revision: 6.18 $
+* $Revision: 6.20 $
*
* File Description:
* Routines for printing ASN.1 value notation (text) messages and
@@ -42,6 +42,12 @@
* 3/4/91 Kans Stricter typecasting for GNU C and C++
*
* $Log: asnprint.c,v $
+* Revision 6.20 2003/12/03 19:31:09 gouriano
+* Corrected DTD generation (a different approach)
+*
+* Revision 6.19 2003/12/02 19:52:48 gouriano
+* Corrected DTD generation
+*
* Revision 6.18 2003/09/15 16:16:32 kans
* added AsnWriteEx, AsnTxtWriteEx, and AsnPrintStream
*
@@ -1901,7 +1907,7 @@ static void AsnXMLElementStart(AsnTypePtr atp, AsnIoPtr aip)
AsnPrintString(GetXMLname(atp), aip);
- atp2 = AsnFindBaseType(atp);
+ atp2 = AsnFindBaseTypeDTD(atp);
if (atp2 == atp)
{
if ((isa == ENUM_TYPE) || (isa == BOOLEAN_TYPE) ||
@@ -2351,7 +2357,8 @@ static Boolean AsnPrintTypeXML (AsnTypePtr atp, AsnIoPtr aip)
if ((atp->optional) || (atp->hasdefault))
repeat = "*";
else
- repeat = "+";
+ repeat = "*";
+// repeat = "+";
AsnXMLElementAdd(NULL, atp->branch, repeat, aip, FALSE);
break;
case INTEGER_TYPE:
@@ -2483,7 +2490,7 @@ static Boolean AsnPrintTypeXML (AsnTypePtr atp, AsnIoPtr aip)
}
else /* primitive.. all text */
{
- atp2 = AsnFindBaseType(atp);
+ atp2 = AsnFindBaseTypeDTD(atp);
if (atp2 != NULL)
{
isa = AsnFindBaseIsa(atp);
diff --git a/asnlib/asntypes.c b/asnlib/asntypes.c
index 11015913..cfce072c 100644
--- a/asnlib/asntypes.c
+++ b/asnlib/asntypes.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/4/91
*
-* $Revision: 6.6 $
+* $Revision: 6.9 $
*
* File Description:
* Routines to deal with internal operations on AsnType objects.
@@ -43,6 +43,15 @@
* 02-24-94 Schuler Make AsnTypeStringToHex LIBCALL too
*
* $Log: asntypes.c,v $
+* Revision 6.9 2003/12/03 19:31:09 gouriano
+* Corrected DTD generation (a different approach)
+*
+* Revision 6.8 2003/12/02 21:40:17 gouriano
+* Revert back to rev 6.6
+*
+* Revision 6.7 2003/12/02 19:52:49 gouriano
+* Corrected DTD generation
+*
* Revision 6.6 2000/07/25 20:30:58 ostell
* added support for printing multiple ASN.1 modules as multiple XML DTD and .mod files
*
@@ -233,6 +242,21 @@ NLM_EXTERN AsnTypePtr LIBCALL AsnFindBaseType (AsnTypePtr atp)
return atp;
}
+NLM_EXTERN AsnTypePtr LIBCALL AsnFindBaseTypeDTD (AsnTypePtr atp)
+{
+ if (atp == NULL) return NULL;
+
+ if (atp->type == NULL) return NULL;
+
+ if (! ISA_BASETYPE(atp->type->isa))
+ {
+ atp = atp->type;
+ if (atp->type == NULL) /* not found */
+ return atp;
+ }
+ return atp;
+}
+
/*****************************************************************************
*
* Int2 AsnFindBaseIsa(atp)
@@ -906,7 +930,7 @@ static void AddXMLname(AsnTypePtr atp, AsnTypePtr PNTR typestack, Int2 stackptr)
isa = AsnFindBaseIsa(atp2);
if ((doitem) && ((isa == SEQOF_TYPE) || (isa == SETOF_TYPE)))
{
- atp2 = AsnFindBaseType(atp);
+ atp2 = AsnFindBaseTypeDTD(atp);
if (atp2 != NULL)
{
if (atp2->name == NULL)
@@ -957,12 +981,12 @@ static void AddXMLname(AsnTypePtr atp, AsnTypePtr PNTR typestack, Int2 stackptr)
for (i = (stackptr - 1); (i >= 0) && (! found); i--)
{
- atp2 = AsnFindBaseType(typestack[i]);
+ atp2 = AsnFindBaseTypeDTD(typestack[i]);
if ((atp2 != NULL) && (atp2->name != NULL) && (IS_UPPER(*(atp2->name))))
{
while (i < stackptr)
{
- atp2 = AsnFindBaseType(typestack[i]);
+ atp2 = AsnFindBaseTypeDTD(typestack[i]);
if (atp2->name == NULL)
tmp = StringMove(tmp, "E");
else
@@ -991,7 +1015,7 @@ static void AddXMLname(AsnTypePtr atp, AsnTypePtr PNTR typestack, Int2 stackptr)
}
}
- atp2 = AsnFindBaseType(atp);
+ atp2 = AsnFindBaseTypeDTD(atp);
if ((! atp->imported) && (atp2 != NULL) && (atp2->type != NULL))
{
isa = atp2->type->isa;
diff --git a/biostruc/cdd/cdd.asn b/biostruc/cdd/cdd.asn
index 83b43ed0..b426377b 100644
--- a/biostruc/cdd/cdd.asn
+++ b/biostruc/cdd/cdd.asn
@@ -1,4 +1,4 @@
---$Revision: 1.18 $
+--$Revision: 1.20 $
--**********************************************************************
--
-- Definitions for CDD's
@@ -22,7 +22,7 @@ NCBI-Cdd DEFINITIONS ::=
BEGIN
-EXPORTS Cdd-id, Cdd-id-set, Cdd, Cdd-set, Cdd-tree, Cdd-tree-set;
+EXPORTS Cdd-id, Cdd-id-set, Cdd, Cdd-set, Cdd-tree, Cdd-tree-set, Cdd-pref-nodes;
IMPORTS Date FROM NCBI-General
Pub FROM NCBI-Pub
@@ -39,6 +39,28 @@ IMPORTS Date FROM NCBI-General
Cn3d-style-dictionary,
Cn3d-user-annotations FROM NCBI-Cn3d
Score-matrix-parameters FROM NCBI-ScoreMat;
+
+-- dealing with lists of preferred tax-nodes
+
+Cdd-org-ref ::= SEQUENCE {
+ reference Org-ref,
+ active BOOLEAN DEFAULT TRUE
+}
+Cdd-org-ref-set ::= SET OF Cdd-org-ref
+
+Cdd-pref-node-descr ::= CHOICE {
+ create-date Date,
+ description VisibleString
+}
+
+Cdd-pref-node-descr-set ::= SET OF Cdd-pref-node-descr
+
+Cdd-pref-nodes ::= SEQUENCE {
+ preferred-nodes Cdd-org-ref-set,
+ model-organisms Cdd-org-ref-set OPTIONAL,
+ optional-nodes Cdd-org-ref-set OPTIONAL,
+ description Cdd-pref-node-descr-set OPTIONAL
+}
-- Cdd's should not exist without a unique accession, but alternative id's may
-- be present as well. It is conceivable that a CD which is created as a merged
@@ -272,19 +294,18 @@ Align-annot-set ::= SEQUENCE OF Align-annot
-- deletions after duplication and do not need a special case for fissions.
Domain-parent ::= SEQUENCE {
+
+ parent-type INTEGER { classical (0), -- the classification of parent child relations
+ fusion (1),
+ deletion (2),
+ permutation (3),
+ other (255) },
parentid Cdd-id, -- identify the section parent by accession
seqannot Seq-annot OPTIONAL -- contains the sequence alignment linking
-- CD alignment models, should align the
-- masters/representatives of each CD
}
-Lineage-info ::= CHOICE {
- simpleparent Domain-parent,
- complexparents SEQUENCE {
- fusionparents SEQUENCE OF Domain-parent OPTIONAL,
- deletionparent SEQUENCE OF Domain-parent OPTIONAL
- }
-}
-- record sequence trees generated by a suitable algorithm.
@@ -385,7 +406,7 @@ Cdd ::= SEQUENCE {
alignannot Align-annot-set OPTIONAL, -- alignment annotation
style-dictionary Cn3d-style-dictionary OPTIONAL, -- record rendering styles
user-annotations Cn3d-user-annotations OPTIONAL, -- user annotations in Cn3D
- ancestors Lineage-info OPTIONAL,
+ ancestors SEQUENCE OF Domain-parent OPTIONAL, -- list of parents
scoreparams Score-matrix-parameters OPTIONAL,
seqtree Sequence-tree OPTIONAL
}
diff --git a/biostruc/cdd/cdd.h b/biostruc/cdd/cdd.h
index 315a0384..35b23ab0 100644
--- a/biostruc/cdd/cdd.h
+++ b/biostruc/cdd/cdd.h
@@ -9,8 +9,8 @@
#include <asn.h>
#endif
-static char * asnfilename = "cdd.h17";
-static AsnValxNode avnx[64] = {
+static char * asnfilename = "cdd.h19";
+static AsnValxNode avnx[70] = {
{20,"unassigned" ,0,0.0,&avnx[1] } ,
{20,"finished-ok" ,1,0.0,&avnx[2] } ,
{20,"pending-release" ,2,0.0,&avnx[3] } ,
@@ -51,37 +51,43 @@ static AsnValxNode avnx[64] = {
{20,"demoted" ,51,0.0,&avnx[38] } ,
{20,"demoted-3d" ,52,0.0,&avnx[39] } ,
{20,"other" ,255,0.0,NULL } ,
- {20,"unassigned" ,0,0.0,&avnx[41] } ,
- {20,"percent-id" ,1,0.0,&avnx[42] } ,
- {20,"kimura-corrected" ,2,0.0,&avnx[43] } ,
- {20,"aligned-score" ,3,0.0,&avnx[44] } ,
- {20,"aligned-score-ext" ,4,0.0,&avnx[45] } ,
- {20,"aligned-score-filled" ,5,0.0,&avnx[46] } ,
- {20,"blast-footprint" ,6,0.0,&avnx[47] } ,
- {20,"blast-full" ,7,0.0,&avnx[48] } ,
+ {20,"classical" ,0,0.0,&avnx[41] } ,
+ {20,"fusion" ,1,0.0,&avnx[42] } ,
+ {20,"deletion" ,2,0.0,&avnx[43] } ,
+ {20,"permutation" ,3,0.0,&avnx[44] } ,
{20,"other" ,255,0.0,NULL } ,
- {20,"unassigned" ,0,0.0,&avnx[50] } ,
- {20,"single-linkage" ,1,0.0,&avnx[51] } ,
- {20,"neighbor-joining" ,2,0.0,&avnx[52] } ,
- {20,"fast-minimum-evolution" ,3,0.0,&avnx[53] } ,
+ {20,"unassigned" ,0,0.0,&avnx[46] } ,
+ {20,"percent-id" ,1,0.0,&avnx[47] } ,
+ {20,"kimura-corrected" ,2,0.0,&avnx[48] } ,
+ {20,"aligned-score" ,3,0.0,&avnx[49] } ,
+ {20,"aligned-score-ext" ,4,0.0,&avnx[50] } ,
+ {20,"aligned-score-filled" ,5,0.0,&avnx[51] } ,
+ {20,"blast-footprint" ,6,0.0,&avnx[52] } ,
+ {20,"blast-full" ,7,0.0,&avnx[53] } ,
{20,"other" ,255,0.0,NULL } ,
{20,"unassigned" ,0,0.0,&avnx[55] } ,
- {20,"blosum45" ,1,0.0,&avnx[56] } ,
- {20,"blosum62" ,2,0.0,&avnx[57] } ,
- {20,"blosum80" ,3,0.0,&avnx[58] } ,
- {20,"pam30" ,4,0.0,&avnx[59] } ,
- {20,"pam70" ,5,0.0,&avnx[60] } ,
- {20,"pam250" ,6,0.0,&avnx[61] } ,
+ {20,"single-linkage" ,1,0.0,&avnx[56] } ,
+ {20,"neighbor-joining" ,2,0.0,&avnx[57] } ,
+ {20,"fast-minimum-evolution" ,3,0.0,&avnx[58] } ,
{20,"other" ,255,0.0,NULL } ,
+ {20,"unassigned" ,0,0.0,&avnx[60] } ,
+ {20,"blosum45" ,1,0.0,&avnx[61] } ,
+ {20,"blosum62" ,2,0.0,&avnx[62] } ,
+ {20,"blosum80" ,3,0.0,&avnx[63] } ,
+ {20,"pam30" ,4,0.0,&avnx[64] } ,
+ {20,"pam70" ,5,0.0,&avnx[65] } ,
+ {20,"pam250" ,6,0.0,&avnx[66] } ,
+ {20,"other" ,255,0.0,NULL } ,
+ {2,NULL,0,0.0,NULL } ,
{2,NULL,0,0.0,NULL } ,
- {2,NULL,0,0.0,NULL } };
+ {2,NULL,1,0.0,NULL } };
-static AsnType atx[184] = {
+static AsnType atx[194] = {
{401, "Cdd-id" ,1,0,0,0,0,1,0,0,NULL,&atx[11],&atx[1],0,&atx[12]} ,
{0, "uid" ,128,0,0,0,0,0,0,0,NULL,&atx[2],NULL,0,&atx[3]} ,
{302, "INTEGER" ,0,2,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{0, "gid" ,128,1,0,0,0,0,0,0,NULL,&atx[4],NULL,0,NULL} ,
- {422, "Global-id" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[5],0,&atx[38]} ,
+ {427, "Global-id" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[5],0,&atx[38]} ,
{0, "accession" ,128,0,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[7]} ,
{323, "VisibleString" ,0,26,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{0, "release" ,128,1,0,1,0,0,0,0,NULL,&atx[6],NULL,0,&atx[8]} ,
@@ -92,22 +98,22 @@ static AsnType atx[184] = {
{402, "Cdd-id-set" ,1,0,0,0,0,1,0,0,NULL,&atx[14],&atx[13],0,&atx[15]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[0],NULL,0,NULL} ,
{312, "SEQUENCE OF" ,0,16,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
- {403, "Cdd" ,1,0,0,0,0,1,0,0,NULL,&atx[10],&atx[16],0,&atx[172]} ,
+ {403, "Cdd" ,1,0,0,0,0,1,0,0,NULL,&atx[10],&atx[16],0,&atx[167]} ,
{0, "name" ,128,0,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[17]} ,
{0, "id" ,128,1,0,0,0,0,0,0,NULL,&atx[12],NULL,0,&atx[18]} ,
{0, "description" ,128,2,0,1,0,0,0,0,NULL,&atx[19],NULL,0,&atx[54]} ,
- {426, "Cdd-descr-set" ,1,0,0,0,0,0,0,0,NULL,&atx[53],&atx[20],0,&atx[66]} ,
+ {431, "Cdd-descr-set" ,1,0,0,0,0,0,0,0,NULL,&atx[53],&atx[20],0,&atx[66]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[21],NULL,0,NULL} ,
- {425, "Cdd-descr" ,1,0,0,0,0,0,0,0,NULL,&atx[11],&atx[22],0,&atx[19]} ,
+ {430, "Cdd-descr" ,1,0,0,0,0,0,0,0,NULL,&atx[11],&atx[22],0,&atx[19]} ,
{0, "othername" ,128,0,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[23]} ,
{0, "category" ,128,1,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[24]} ,
{0, "comment" ,128,2,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[25]} ,
{0, "reference" ,128,3,0,0,0,0,0,0,NULL,&atx[26],NULL,0,&atx[27]} ,
- {408, "Pub" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[58]} ,
+ {409, "Pub" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[58]} ,
{0, "create-date" ,128,4,0,0,0,0,0,0,NULL,&atx[28],NULL,0,&atx[29]} ,
- {407, "Date" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[26]} ,
+ {408, "Date" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[26]} ,
{0, "tax-source" ,128,5,0,0,0,0,0,0,NULL,&atx[30],NULL,0,&atx[31]} ,
- {413, "Org-ref" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[106]} ,
+ {414, "Org-ref" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[106]} ,
{0, "source" ,128,6,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[32]} ,
{0, "status" ,128,7,0,0,0,0,0,0,NULL,&atx[2],&avnx[0],0,&atx[33]} ,
{0, "update-date" ,128,8,0,0,0,0,0,0,NULL,&atx[28],NULL,0,&atx[34]} ,
@@ -115,16 +121,16 @@ static AsnType atx[184] = {
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[6],NULL,0,NULL} ,
{0, "source-id" ,128,10,0,0,0,0,0,0,NULL,&atx[12],NULL,0,&atx[37]} ,
{0, "repeats" ,128,11,0,0,0,0,0,0,NULL,&atx[38],NULL,0,&atx[43]} ,
- {423, "Cdd-repeat" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[39],0,&atx[47]} ,
+ {428, "Cdd-repeat" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[39],0,&atx[47]} ,
{0, "count" ,128,0,0,0,0,0,0,0,NULL,&atx[2],NULL,0,&atx[40]} ,
{0, "location" ,128,1,0,1,0,0,0,0,NULL,&atx[41],NULL,0,&atx[42]} ,
- {416, "Seq-loc" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[122]} ,
+ {417, "Seq-loc" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[122]} ,
{0, "avglen" ,128,2,0,1,0,0,0,0,NULL,&atx[2],NULL,0,NULL} ,
{0, "old-root" ,128,12,0,0,0,0,0,0,NULL,&atx[12],NULL,0,&atx[44]} ,
{0, "curation-status" ,128,13,0,0,0,0,0,0,NULL,&atx[2],&avnx[10],0,&atx[45]} ,
{0, "readonly-status" ,128,14,0,0,0,0,0,0,NULL,&atx[2],&avnx[20],0,&atx[46]} ,
{0, "book-ref" ,128,15,0,0,0,0,0,0,NULL,&atx[47],NULL,0,NULL} ,
- {424, "Cdd-book-ref" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[48],0,&atx[21]} ,
+ {429, "Cdd-book-ref" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[48],0,&atx[21]} ,
{0, "bookname" ,128,0,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[49]} ,
{0, "textelement" ,128,1,0,0,0,0,0,0,NULL,&atx[50],&avnx[24],0,&atx[51]} ,
{310, "ENUMERATED" ,0,10,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
@@ -133,17 +139,17 @@ static AsnType atx[184] = {
{314, "SET OF" ,0,17,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{0, "seqannot" ,128,3,0,1,0,0,0,0,NULL,&atx[14],&atx[55],0,&atx[57]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[56],NULL,0,NULL} ,
- {411, "Seq-annot" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[60]} ,
+ {412, "Seq-annot" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[60]} ,
{0, "features" ,128,4,0,1,0,0,0,0,NULL,&atx[58],NULL,0,&atx[59]} ,
- {409, "Biostruc-annot-set" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[64]} ,
+ {410, "Biostruc-annot-set" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[64]} ,
{0, "sequences" ,128,5,0,1,0,0,0,0,NULL,&atx[60],NULL,0,&atx[61]} ,
- {412, "Seq-entry" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[30]} ,
+ {413, "Seq-entry" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[30]} ,
{0, "profile-range" ,128,6,0,1,0,0,0,0,NULL,&atx[62],NULL,0,&atx[63]} ,
- {415, "Seq-interval" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[41]} ,
+ {416, "Seq-interval" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[41]} ,
{0, "trunc-master" ,128,7,0,1,0,0,0,0,NULL,&atx[64],NULL,0,&atx[65]} ,
- {410, "Bioseq" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[56]} ,
+ {411, "Bioseq" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[56]} ,
{0, "posfreq" ,128,8,0,1,0,0,0,0,NULL,&atx[66],NULL,0,&atx[74]} ,
- {427, "Matrix" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[67],0,&atx[76]} ,
+ {432, "Matrix" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[67],0,&atx[76]} ,
{0, "ncolumns" ,128,0,0,0,0,0,0,0,NULL,&atx[2],NULL,0,&atx[68]} ,
{0, "nrows" ,128,1,0,0,0,0,0,0,NULL,&atx[2],NULL,0,&atx[69]} ,
{0, "row-labels" ,128,2,0,1,0,0,0,0,NULL,&atx[14],&atx[70],0,&atx[71]} ,
@@ -153,10 +159,10 @@ static AsnType atx[184] = {
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[2],NULL,0,NULL} ,
{0, "scoremat" ,128,9,0,1,0,0,0,0,NULL,&atx[66],NULL,0,&atx[75]} ,
{0, "distance" ,128,10,0,1,0,0,0,0,NULL,&atx[76],NULL,0,&atx[82]} ,
- {428, "Triangle" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[77],0,&atx[91]} ,
+ {433, "Triangle" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[77],0,&atx[91]} ,
{0, "nelements" ,128,0,0,0,0,0,0,0,NULL,&atx[2],NULL,0,&atx[78]} ,
{0, "scores" ,128,1,0,1,0,0,0,0,NULL,&atx[79],NULL,0,&atx[80]} ,
- {418, "Score-set" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[125]} ,
+ {419, "Score-set" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[125]} ,
{0, "div-ranks" ,128,2,0,1,0,0,0,0,NULL,&atx[14],&atx[81],0,NULL} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[2],NULL,0,NULL} ,
{0, "parent" ,128,11,0,1,0,0,0,0,NULL,&atx[0],NULL,0,&atx[83]} ,
@@ -165,10 +171,10 @@ static AsnType atx[184] = {
{0, "neighbors" ,128,14,0,1,0,0,0,0,NULL,&atx[12],NULL,0,&atx[86]} ,
{0, "pending" ,128,15,0,1,0,0,0,0,NULL,&atx[14],&atx[87],0,&atx[99]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[88],NULL,0,NULL} ,
- {430, "Update-align" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[89],0,&atx[101]} ,
+ {435, "Update-align" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[89],0,&atx[101]} ,
{0, "description" ,128,0,0,1,0,0,0,0,NULL,&atx[14],&atx[90],0,&atx[97]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[91],NULL,0,NULL} ,
- {429, "Update-comment" ,1,0,0,0,0,0,0,0,NULL,&atx[11],&atx[92],0,&atx[88]} ,
+ {434, "Update-comment" ,1,0,0,0,0,0,0,0,NULL,&atx[11],&atx[92],0,&atx[88]} ,
{0, "comment" ,128,0,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[93]} ,
{0, "addthis" ,128,1,0,0,0,0,0,0,NULL,&atx[41],NULL,0,&atx[94]} ,
{0, "replaces" ,128,2,0,0,0,0,0,0,NULL,&atx[41],NULL,0,&atx[95]} ,
@@ -178,92 +184,102 @@ static AsnType atx[184] = {
{0, "type" ,128,2,0,0,0,0,0,0,NULL,&atx[2],&avnx[34],0,NULL} ,
{0, "rejects" ,128,16,0,1,0,0,0,0,NULL,&atx[14],&atx[100],0,&atx[107]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[101],NULL,0,NULL} ,
- {431, "Reject-id" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[102],0,&atx[117]} ,
+ {436, "Reject-id" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[102],0,&atx[117]} ,
{0, "description" ,128,0,0,1,0,0,0,0,NULL,&atx[14],&atx[103],0,&atx[104]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[91],NULL,0,NULL} ,
{0, "ids" ,128,1,0,0,0,0,0,0,NULL,&atx[53],&atx[105],0,NULL} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[106],NULL,0,NULL} ,
- {414, "Seq-id" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[62]} ,
+ {415, "Seq-id" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[62]} ,
{0, "master3d" ,128,17,0,1,0,0,0,0,NULL,&atx[53],&atx[108],0,&atx[109]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[106],NULL,0,NULL} ,
{0, "alignannot" ,128,18,0,1,0,0,0,0,NULL,&atx[110],NULL,0,&atx[124]} ,
- {434, "Align-annot-set" ,1,0,0,0,0,0,0,0,NULL,&atx[14],&atx[111],0,&atx[131]} ,
+ {439, "Align-annot-set" ,1,0,0,0,0,0,0,0,NULL,&atx[14],&atx[111],0,&atx[130]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[112],NULL,0,NULL} ,
- {433, "Align-annot" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[113],0,&atx[110]} ,
+ {438, "Align-annot" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[113],0,&atx[110]} ,
{0, "location" ,128,0,0,0,0,0,0,0,NULL,&atx[41],NULL,0,&atx[114]} ,
{0, "description" ,128,1,0,1,0,0,0,0,NULL,&atx[6],NULL,0,&atx[115]} ,
{0, "evidence" ,128,2,0,1,0,0,0,0,NULL,&atx[14],&atx[116],0,NULL} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[117],NULL,0,NULL} ,
- {432, "Feature-evidence" ,1,0,0,0,0,0,0,0,NULL,&atx[11],&atx[118],0,&atx[112]} ,
+ {437, "Feature-evidence" ,1,0,0,0,0,0,0,0,NULL,&atx[11],&atx[118],0,&atx[112]} ,
{0, "comment" ,128,0,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[119]} ,
{0, "reference" ,128,1,0,0,0,0,0,0,NULL,&atx[26],NULL,0,&atx[120]} ,
{0, "bsannot" ,128,2,0,0,0,0,0,0,NULL,&atx[58],NULL,0,&atx[121]} ,
{0, "seqfeat" ,128,3,0,0,0,0,0,0,NULL,&atx[122],NULL,0,&atx[123]} ,
- {417, "Seq-feat" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[79]} ,
+ {418, "Seq-feat" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[79]} ,
{0, "book-ref" ,128,4,0,0,0,0,0,0,NULL,&atx[47],NULL,0,NULL} ,
{0, "style-dictionary" ,128,19,0,1,0,0,0,0,NULL,&atx[125],NULL,0,&atx[126]} ,
- {419, "Cn3d-style-dictionary" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[127]} ,
+ {420, "Cn3d-style-dictionary" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[127]} ,
{0, "user-annotations" ,128,20,0,1,0,0,0,0,NULL,&atx[127],NULL,0,&atx[128]} ,
- {420, "Cn3d-user-annotations" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[140]} ,
- {0, "ancestors" ,128,21,0,1,0,0,0,0,NULL,&atx[129],NULL,0,&atx[139]} ,
- {436, "Lineage-info" ,1,0,0,0,0,0,0,0,NULL,&atx[11],&atx[130],0,&atx[142]} ,
- {0, "simpleparent" ,128,0,0,0,0,0,0,0,NULL,&atx[131],NULL,0,&atx[134]} ,
- {435, "Domain-parent" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[132],0,&atx[129]} ,
- {0, "parentid" ,128,0,0,0,0,0,0,0,NULL,&atx[0],NULL,0,&atx[133]} ,
- {0, "seqannot" ,128,1,0,1,0,0,0,0,NULL,&atx[56],NULL,0,NULL} ,
- {0, "complexparents" ,128,1,0,0,0,0,0,0,NULL,&atx[10],&atx[135],0,NULL} ,
- {0, "fusionparents" ,128,0,0,1,0,0,0,0,NULL,&atx[14],&atx[136],0,&atx[137]} ,
- {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[131],NULL,0,NULL} ,
- {0, "deletionparent" ,128,1,0,1,0,0,0,0,NULL,&atx[14],&atx[138],0,NULL} ,
- {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[131],NULL,0,NULL} ,
- {0, "scoreparams" ,128,22,0,1,0,0,0,0,NULL,&atx[140],NULL,0,&atx[141]} ,
- {421, "Score-matrix-parameters" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[4]} ,
- {0, "seqtree" ,128,23,0,1,0,0,0,0,NULL,&atx[142],NULL,0,NULL} ,
- {437, "Sequence-tree" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[143],0,&atx[145]} ,
- {0, "cdAccession" ,128,0,0,1,0,0,0,0,NULL,&atx[6],NULL,0,&atx[144]} ,
- {0, "algorithm" ,128,1,0,0,0,0,0,0,NULL,&atx[145],NULL,0,&atx[154]} ,
- {438, "Algorithm-type" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[146],0,&atx[157]} ,
- {0, "scoring-Scheme" ,128,0,0,0,0,0,0,0,NULL,&atx[2],&avnx[40],0,&atx[147]} ,
- {0, "clustering-Method" ,128,1,0,0,0,0,0,0,NULL,&atx[2],&avnx[49],0,&atx[148]} ,
- {0, "score-Matrix" ,128,2,0,1,0,0,0,0,NULL,&atx[2],&avnx[54],0,&atx[149]} ,
- {0, "gapOpen" ,128,3,0,1,0,0,0,0,NULL,&atx[2],NULL,0,&atx[150]} ,
- {0, "gapExtend" ,128,4,0,1,0,0,0,0,NULL,&atx[2],NULL,0,&atx[151]} ,
- {0, "gapScaleFactor" ,128,5,0,1,0,0,0,0,NULL,&atx[2],NULL,0,&atx[152]} ,
- {0, "nTerminalExt" ,128,6,0,1,0,0,0,0,NULL,&atx[2],NULL,0,&atx[153]} ,
+ {421, "Cn3d-user-annotations" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[135]} ,
+ {0, "ancestors" ,128,21,0,1,0,0,0,0,NULL,&atx[14],&atx[129],0,&atx[134]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[130],NULL,0,NULL} ,
+ {440, "Domain-parent" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[131],0,&atx[137]} ,
+ {0, "parent-type" ,128,0,0,0,0,0,0,0,NULL,&atx[2],&avnx[40],0,&atx[132]} ,
+ {0, "parentid" ,128,1,0,0,0,0,0,0,NULL,&atx[0],NULL,0,&atx[133]} ,
+ {0, "seqannot" ,128,2,0,1,0,0,0,0,NULL,&atx[56],NULL,0,NULL} ,
+ {0, "scoreparams" ,128,22,0,1,0,0,0,0,NULL,&atx[135],NULL,0,&atx[136]} ,
+ {422, "Score-matrix-parameters" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[183]} ,
+ {0, "seqtree" ,128,23,0,1,0,0,0,0,NULL,&atx[137],NULL,0,NULL} ,
+ {441, "Sequence-tree" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[138],0,&atx[140]} ,
+ {0, "cdAccession" ,128,0,0,1,0,0,0,0,NULL,&atx[6],NULL,0,&atx[139]} ,
+ {0, "algorithm" ,128,1,0,0,0,0,0,0,NULL,&atx[140],NULL,0,&atx[149]} ,
+ {442, "Algorithm-type" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[141],0,&atx[152]} ,
+ {0, "scoring-Scheme" ,128,0,0,0,0,0,0,0,NULL,&atx[2],&avnx[45],0,&atx[142]} ,
+ {0, "clustering-Method" ,128,1,0,0,0,0,0,0,NULL,&atx[2],&avnx[54],0,&atx[143]} ,
+ {0, "score-Matrix" ,128,2,0,1,0,0,0,0,NULL,&atx[2],&avnx[59],0,&atx[144]} ,
+ {0, "gapOpen" ,128,3,0,1,0,0,0,0,NULL,&atx[2],NULL,0,&atx[145]} ,
+ {0, "gapExtend" ,128,4,0,1,0,0,0,0,NULL,&atx[2],NULL,0,&atx[146]} ,
+ {0, "gapScaleFactor" ,128,5,0,1,0,0,0,0,NULL,&atx[2],NULL,0,&atx[147]} ,
+ {0, "nTerminalExt" ,128,6,0,1,0,0,0,0,NULL,&atx[2],NULL,0,&atx[148]} ,
{0, "cTerminalExt" ,128,7,0,1,0,0,0,0,NULL,&atx[2],NULL,0,NULL} ,
- {0, "isAnnotated" ,128,2,0,0,1,0,0,0,&avnx[62],&atx[155],NULL,0,&atx[156]} ,
+ {0, "isAnnotated" ,128,2,0,0,1,0,0,0,&avnx[67],&atx[150],NULL,0,&atx[151]} ,
{301, "BOOLEAN" ,0,1,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
- {0, "root" ,128,3,0,0,0,0,0,0,NULL,&atx[157],NULL,0,NULL} ,
- {439, "SeqTree-node" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[158],0,&atx[169]} ,
- {0, "isAnnotated" ,128,0,0,0,1,0,0,0,&avnx[63],&atx[155],NULL,0,&atx[159]} ,
- {0, "name" ,128,1,0,1,0,0,0,0,NULL,&atx[6],NULL,0,&atx[160]} ,
- {0, "distance" ,128,2,0,1,0,0,0,0,NULL,&atx[161],NULL,0,&atx[162]} ,
+ {0, "root" ,128,3,0,0,0,0,0,0,NULL,&atx[152],NULL,0,NULL} ,
+ {443, "SeqTree-node" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[153],0,&atx[164]} ,
+ {0, "isAnnotated" ,128,0,0,0,1,0,0,0,&avnx[68],&atx[150],NULL,0,&atx[154]} ,
+ {0, "name" ,128,1,0,1,0,0,0,0,NULL,&atx[6],NULL,0,&atx[155]} ,
+ {0, "distance" ,128,2,0,1,0,0,0,0,NULL,&atx[156],NULL,0,&atx[157]} ,
{309, "REAL" ,0,9,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
- {0, "children" ,128,3,0,0,0,0,0,0,NULL,&atx[11],&atx[163],0,&atx[168]} ,
- {0, "children" ,128,0,0,0,0,0,0,0,NULL,&atx[14],&atx[164],0,&atx[165]} ,
- {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[157],NULL,0,NULL} ,
- {0, "footprint" ,128,1,0,0,0,0,0,0,NULL,&atx[10],&atx[166],0,NULL} ,
- {0, "seqRange" ,128,0,0,0,0,0,0,0,NULL,&atx[62],NULL,0,&atx[167]} ,
+ {0, "children" ,128,3,0,0,0,0,0,0,NULL,&atx[11],&atx[158],0,&atx[163]} ,
+ {0, "children" ,128,0,0,0,0,0,0,0,NULL,&atx[14],&atx[159],0,&atx[160]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[152],NULL,0,NULL} ,
+ {0, "footprint" ,128,1,0,0,0,0,0,0,NULL,&atx[10],&atx[161],0,NULL} ,
+ {0, "seqRange" ,128,0,0,0,0,0,0,0,NULL,&atx[62],NULL,0,&atx[162]} ,
{0, "rowId" ,128,1,0,1,0,0,0,0,NULL,&atx[2],NULL,0,NULL} ,
- {0, "annotation" ,128,4,0,1,0,0,0,0,NULL,&atx[169],NULL,0,NULL} ,
- {440, "Node-annotation" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[170],0,NULL} ,
- {0, "presentInChildCD" ,128,0,0,1,0,0,0,0,NULL,&atx[6],NULL,0,&atx[171]} ,
+ {0, "annotation" ,128,4,0,1,0,0,0,0,NULL,&atx[164],NULL,0,NULL} ,
+ {444, "Node-annotation" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[165],0,NULL} ,
+ {0, "presentInChildCD" ,128,0,0,1,0,0,0,0,NULL,&atx[6],NULL,0,&atx[166]} ,
{0, "note" ,128,1,0,1,0,0,0,0,NULL,&atx[6],NULL,0,NULL} ,
- {404, "Cdd-set" ,1,0,0,0,0,1,0,0,NULL,&atx[53],&atx[173],0,&atx[174]} ,
+ {404, "Cdd-set" ,1,0,0,0,0,1,0,0,NULL,&atx[53],&atx[168],0,&atx[169]} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[15],NULL,0,NULL} ,
- {405, "Cdd-tree" ,1,0,0,0,0,1,0,0,NULL,&atx[10],&atx[175],0,&atx[182]} ,
- {0, "name" ,128,0,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[176]} ,
- {0, "id" ,128,1,0,0,0,0,0,0,NULL,&atx[12],NULL,0,&atx[177]} ,
- {0, "description" ,128,2,0,1,0,0,0,0,NULL,&atx[19],NULL,0,&atx[178]} ,
- {0, "parent" ,128,3,0,1,0,0,0,0,NULL,&atx[0],NULL,0,&atx[179]} ,
- {0, "children" ,128,4,0,1,0,0,0,0,NULL,&atx[12],NULL,0,&atx[180]} ,
- {0, "siblings" ,128,5,0,1,0,0,0,0,NULL,&atx[12],NULL,0,&atx[181]} ,
+ {405, "Cdd-tree" ,1,0,0,0,0,1,0,0,NULL,&atx[10],&atx[170],0,&atx[177]} ,
+ {0, "name" ,128,0,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[171]} ,
+ {0, "id" ,128,1,0,0,0,0,0,0,NULL,&atx[12],NULL,0,&atx[172]} ,
+ {0, "description" ,128,2,0,1,0,0,0,0,NULL,&atx[19],NULL,0,&atx[173]} ,
+ {0, "parent" ,128,3,0,1,0,0,0,0,NULL,&atx[0],NULL,0,&atx[174]} ,
+ {0, "children" ,128,4,0,1,0,0,0,0,NULL,&atx[12],NULL,0,&atx[175]} ,
+ {0, "siblings" ,128,5,0,1,0,0,0,0,NULL,&atx[12],NULL,0,&atx[176]} ,
{0, "neighbors" ,128,6,0,1,0,0,0,0,NULL,&atx[12],NULL,0,NULL} ,
- {406, "Cdd-tree-set" ,1,0,0,0,0,1,0,0,NULL,&atx[14],&atx[183],0,&atx[28]} ,
- {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[174],NULL,0,NULL} };
+ {406, "Cdd-tree-set" ,1,0,0,0,0,1,0,0,NULL,&atx[14],&atx[178],0,&atx[179]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[169],NULL,0,NULL} ,
+ {407, "Cdd-pref-nodes" ,1,0,0,0,0,1,0,0,NULL,&atx[10],&atx[180],0,&atx[28]} ,
+ {0, "preferred-nodes" ,128,0,0,0,0,0,0,0,NULL,&atx[181],NULL,0,&atx[186]} ,
+ {424, "Cdd-org-ref-set" ,1,0,0,0,0,0,0,0,NULL,&atx[53],&atx[182],0,&atx[191]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[183],NULL,0,NULL} ,
+ {423, "Cdd-org-ref" ,1,0,0,0,0,0,0,0,NULL,&atx[10],&atx[184],0,&atx[181]} ,
+ {0, "reference" ,128,0,0,0,0,0,0,0,NULL,&atx[30],NULL,0,&atx[185]} ,
+ {0, "active" ,128,1,0,0,1,0,0,0,&avnx[69],&atx[150],NULL,0,NULL} ,
+ {0, "model-organisms" ,128,1,0,1,0,0,0,0,NULL,&atx[181],NULL,0,&atx[187]} ,
+ {0, "optional-nodes" ,128,2,0,1,0,0,0,0,NULL,&atx[181],NULL,0,&atx[188]} ,
+ {0, "description" ,128,3,0,1,0,0,0,0,NULL,&atx[189],NULL,0,NULL} ,
+ {426, "Cdd-pref-node-descr-set" ,1,0,0,0,0,0,0,0,NULL,&atx[53],&atx[190],0,&atx[4]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[191],NULL,0,NULL} ,
+ {425, "Cdd-pref-node-descr" ,1,0,0,0,0,0,0,0,NULL,&atx[11],&atx[192],0,&atx[189]} ,
+ {0, "create-date" ,128,0,0,0,0,0,0,0,NULL,&atx[28],NULL,0,&atx[193]} ,
+ {0, "description" ,128,1,0,0,0,0,0,0,NULL,&atx[6],NULL,0,NULL} };
static AsnModule ampx[1] = {
- { "NCBI-Cdd" , "cdd.h17",&atx[0],NULL,NULL,0,0} };
+ { "NCBI-Cdd" , "cdd.h19",&atx[0],NULL,NULL,0,0} };
static AsnValxNodePtr avn = avnx;
static AsnTypePtr at = atx;
@@ -311,23 +327,44 @@ static AsnModulePtr amp = ampx;
#define CDD_style_dictionary &at[124]
#define CDD_user_annotations &at[126]
#define CDD_ancestors &at[128]
-#define CDD_scoreparams &at[139]
-#define CDD_seqtree &at[141]
+#define CDD_ancestors_E &at[129]
+#define CDD_scoreparams &at[134]
+#define CDD_seqtree &at[136]
+
+#define CDD_SET &at[167]
+#define CDD_SET_E &at[168]
+
+#define CDD_TREE &at[169]
+#define CDD_TREE_name &at[170]
+#define CDD_TREE_id &at[171]
+#define CDD_TREE_description &at[172]
+#define CDD_TREE_parent &at[173]
+#define CDD_TREE_children &at[174]
+#define CDD_TREE_siblings &at[175]
+#define CDD_TREE_neighbors &at[176]
+
+#define CDD_TREE_SET &at[177]
+#define CDD_TREE_SET_E &at[178]
+
+#define CDD_PREF_NODES &at[179]
+#define CDD_PREF_NODES_preferred_nodes &at[180]
+#define CDD_PREF_NODES_model_organisms &at[186]
+#define CDD_PREF_NODES_optional_nodes &at[187]
+#define CDD_PREF_NODES_description &at[188]
+
+#define CDD_ORG_REF &at[183]
+#define CDD_ORG_REF_reference &at[184]
+#define CDD_ORG_REF_active &at[185]
-#define CDD_SET &at[172]
-#define CDD_SET_E &at[173]
+#define CDD_ORG_REF_SET &at[181]
+#define CDD_ORG_REF_SET_E &at[182]
-#define CDD_TREE &at[174]
-#define CDD_TREE_name &at[175]
-#define CDD_TREE_id &at[176]
-#define CDD_TREE_description &at[177]
-#define CDD_TREE_parent &at[178]
-#define CDD_TREE_children &at[179]
-#define CDD_TREE_siblings &at[180]
-#define CDD_TREE_neighbors &at[181]
+#define CDD_PREF_NODE_DESCR &at[191]
+#define CDD_PREF_NODE_DESCR_create_date &at[192]
+#define CDD_PREF_NODE_DESCR_description &at[193]
-#define CDD_TREE_SET &at[182]
-#define CDD_TREE_SET_E &at[183]
+#define CDD_PREF_NODE_DESCR_SET &at[189]
+#define CDD_PREF_NODE_DESCR_SET_E &at[190]
#define GLOBAL_ID &at[4]
#define GLOBAL_ID_accession &at[5]
@@ -418,46 +455,39 @@ static AsnModulePtr amp = ampx;
#define ALIGN_ANNOT_SET &at[110]
#define ALIGN_ANNOT_SET_E &at[111]
-#define DOMAIN_PARENT &at[131]
+#define DOMAIN_PARENT &at[130]
+#define DOMAIN_PARENT_parent_type &at[131]
#define DOMAIN_PARENT_parentid &at[132]
#define DOMAIN_PARENT_seqannot &at[133]
-#define LINEAGE_INFO &at[129]
-#define LINEAGE_INFO_simpleparent &at[130]
-#define LINEAGE_INFO_complexparents &at[134]
-#define LINEAGE_INFO_complexparents_fusionparents &at[135]
-#define LINEAGE_INFO_complexparents_fusionparents_E &at[136]
-#define LINEAGE_INFO_complexparents_deletionparent &at[137]
-#define LINEAGE_INFO_complexparents_deletionparent_E &at[138]
-
-#define SEQUENCE_TREE &at[142]
-#define SEQUENCE_TREE_cdAccession &at[143]
-#define SEQUENCE_TREE_algorithm &at[144]
-#define SEQUENCE_TREE_isAnnotated &at[154]
-#define SEQUENCE_TREE_root &at[156]
-
-#define ALGORITHM_TYPE &at[145]
-#define ALGORITHM_TYPE_scoring_Scheme &at[146]
-#define ALGORITHM_TYPE_clustering_Method &at[147]
-#define ALGORITHM_TYPE_score_Matrix &at[148]
-#define ALGORITHM_TYPE_gapOpen &at[149]
-#define ALGORITHM_TYPE_gapExtend &at[150]
-#define ALGORITHM_TYPE_gapScaleFactor &at[151]
-#define ALGORITHM_TYPE_nTerminalExt &at[152]
-#define ALGORITHM_TYPE_cTerminalExt &at[153]
-
-#define SEQTREE_NODE &at[157]
-#define SEQTREE_NODE_isAnnotated &at[158]
-#define SEQTREE_NODE_name &at[159]
-#define SEQTREE_NODE_distance &at[160]
-#define SEQTREE_NODE_children &at[162]
-#define SEQTREE_NODE_children_children &at[163]
-#define SEQTREE_NODE_children_children_E &at[164]
-#define SEQTREE_NODE_children_footprint &at[165]
-#define SEQTREE_NODE_children_footprint_seqRange &at[166]
-#define SEQTREE_NODE_children_footprint_rowId &at[167]
-#define SEQTREE_NODE_annotation &at[168]
-
-#define NODE_ANNOTATION &at[169]
-#define NODE_ANNOTATION_presentInChildCD &at[170]
-#define NODE_ANNOTATION_note &at[171]
+#define SEQUENCE_TREE &at[137]
+#define SEQUENCE_TREE_cdAccession &at[138]
+#define SEQUENCE_TREE_algorithm &at[139]
+#define SEQUENCE_TREE_isAnnotated &at[149]
+#define SEQUENCE_TREE_root &at[151]
+
+#define ALGORITHM_TYPE &at[140]
+#define ALGORITHM_TYPE_scoring_Scheme &at[141]
+#define ALGORITHM_TYPE_clustering_Method &at[142]
+#define ALGORITHM_TYPE_score_Matrix &at[143]
+#define ALGORITHM_TYPE_gapOpen &at[144]
+#define ALGORITHM_TYPE_gapExtend &at[145]
+#define ALGORITHM_TYPE_gapScaleFactor &at[146]
+#define ALGORITHM_TYPE_nTerminalExt &at[147]
+#define ALGORITHM_TYPE_cTerminalExt &at[148]
+
+#define SEQTREE_NODE &at[152]
+#define SEQTREE_NODE_isAnnotated &at[153]
+#define SEQTREE_NODE_name &at[154]
+#define SEQTREE_NODE_distance &at[155]
+#define SEQTREE_NODE_children &at[157]
+#define SEQTREE_NODE_children_children &at[158]
+#define SEQTREE_NODE_children_children_E &at[159]
+#define SEQTREE_NODE_children_footprint &at[160]
+#define SEQTREE_NODE_children_footprint_seqRange &at[161]
+#define SEQTREE_NODE_children_footprint_rowId &at[162]
+#define SEQTREE_NODE_annotation &at[163]
+
+#define NODE_ANNOTATION &at[164]
+#define NODE_ANNOTATION_presentInChildCD &at[165]
+#define NODE_ANNOTATION_note &at[166]
diff --git a/biostruc/cdd/cddposutil.c b/biostruc/cdd/cddposutil.c
index e9c513cc..9ca4dbee 100644
--- a/biostruc/cdd/cddposutil.c
+++ b/biostruc/cdd/cddposutil.c
@@ -1,4 +1,4 @@
-/* $Id: cddposutil.c,v 1.16 2003/05/29 13:17:56 thiessen Exp $
+/* $Id: cddposutil.c,v 1.17 2004/01/22 15:43:57 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Initial Version Creation Date: 12/21/1999
*
-* $Revision: 1.16 $
+* $Revision: 1.17 $
*
* File Description: CDD utilities involving position-specific scoring
* matrices (PSSMs)
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: cddposutil.c,v $
+* Revision 1.17 2004/01/22 15:43:57 bauer
+* call BlastCalculateEffectiveLengths in CddSetUpSearchInternalByLoc
+*
* Revision 1.16 2003/05/29 13:17:56 thiessen
* fix memory leak in CddposFreeMemory()
*
@@ -1708,32 +1711,19 @@ static Int2 LIBCALL CddSetUpSearchInternalByLoc
if (retval)
return retval;
+/* replaced code to calculate effecitve lengths with function call, AMB 1/22/04 */
- if (search->pbp->gapped_calculation &&
- StringCmp(search->prog_name, "blastn") != 0)
- min_query_length = 1/(search->sbp->kbp_gap_std[search->first_context]->K);
- else
- min_query_length = 1/(search->sbp->kbp[search->first_context]->K);
-
- last_length_adjustment = 0;
- for (index=0; index<5; index++)
- {
- length_adjustment = ((search->sbp->kbp[search->first_context]->logK)+log((Nlm_FloatHi)(length-last_length_adjustment)*(Nlm_FloatHi)(MAX(1, (search->dblen)-(search->dbseq_num*last_length_adjustment)))))/(search->sbp->kbp[search->first_context]->H);
- if (length_adjustment >= length-min_query_length)
- {
- length_adjustment = length-min_query_length;
- break;
- }
-
- if (ABS(last_length_adjustment-length_adjustment) <= 1)
- break;
- last_length_adjustment = length_adjustment;
+ if (!BlastCalculateEffectiveLengths(options, search->dbseq_num, search->dblen,
+ length, search->sbp->kbp_gap_std[search->first_context],
+ &effective_query_length, &length_adjustment)) {
+ ErrPostEx(SEV_WARNING, 0, 0, "BlastCalculateEffectiveLengths failed!");
}
- search->length_adjustment = MAX(length_adjustment, 0);
+/* old code below to set values in 'search' */
+
+ search->length_adjustment = MAX(length_adjustment, 0);
search->dblen_eff = MAX(1, search->dblen - search->dbseq_num*search->length_adjustment);
- effective_query_length = MAX(length - search->length_adjustment, min_query_length);
-
+
for (index=search->first_context; index<=search->last_context; index++)
{
search->context[index].query->effective_length = effective_query_length;
diff --git a/biostruc/cdd/cddserver.c b/biostruc/cdd/cddserver.c
index 1e015e6c..a8a2522e 100644
--- a/biostruc/cdd/cddserver.c
+++ b/biostruc/cdd/cddserver.c
@@ -1,4 +1,4 @@
-/* $Id: cddserver.c,v 1.41 2003/10/07 21:21:09 bauer Exp $
+/* $Id: cddserver.c,v 1.42 2003/11/19 14:37:52 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Initial Version Creation Date: 2/10/2000
*
-* $Revision: 1.41 $
+* $Revision: 1.42 $
*
* File Description:
* CD WWW-Server, Cd summary pages and alignments directly from the
@@ -38,6 +38,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: cddserver.c,v $
+* Revision 1.42 2003/11/19 14:37:52 bauer
+* more consistent use of PSSM-IDs
+*
* Revision 1.41 2003/10/07 21:21:09 bauer
* initial changes to support drawing of hierarchies
*
@@ -193,8 +196,8 @@
#undef DEBUG
#undef NOCN3D4
-#undef USE_CDTRK
-#undef DRAW_TREES
+#define USE_CDTRK
+#define DRAW_TREES
typedef struct _private_tree_node_ {
CdTreeNodePtr pcdtree;
@@ -1752,7 +1755,10 @@ static void CDDSrvInfoBlk(CddPtr pcdd, FILE *table, CharPtr dbversion,
}
}
fprintf(table,"<FORM METHOD=\"POST\" ACTION=\"%scddsrv.cgi\" name=\"listform\" enctype=\"application/x-www-form-urlencoded\">\n",URLBase);
- fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"uid\" VALUE=\"%s\">\n",cCDDid);
+ if (iPssmId > 0) {
+ fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"uid\" VALUE=\"%d\">\n",iPssmId);
+ } else
+ fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"uid\" VALUE=\"%s\">\n",cCDDid);
fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"version\" VALUE=\"%s\">\n",dbversion);
fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"ascbin\" VALUE=\"5\">\n");
fprintf(table,"</FORM>\n");
@@ -1773,7 +1779,10 @@ static void CDDSrvInfoBlk(CddPtr pcdd, FILE *table, CharPtr dbversion,
/* Begin Viewing Form */
/*---------------------------------------------------------------------------*/
fprintf(table," <FORM METHOD=\"POST\" ACTION=\"%scddsrv.cgi\" name=\"mainform\">\n",URLBase);
- fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"uid\" VALUE=\"%s\">\n",cCDDid);
+ if (iPssmId > 0) {
+ fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"uid\" VALUE=\"%d\">\n",iPssmId);
+ } else
+ fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"uid\" VALUE=\"%s\">\n",cCDDid);
fprintf(table," <INPUT TYPE=\"HIDDEN\" NAME=\"version\" VALUE=\"%s\">\n",dbversion);
if (txids) {
vnp = txids; while (vnp) {
@@ -2613,6 +2622,56 @@ static void CddSrvRemoveNotes(CddPtr pcdd)
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
+/* return the consensus sequence as a Seq-Entry */
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+static void CddSrvReturnConsensus(CddPtr pcdd, Int4 iPssmId)
+{
+
+ AsnIoPtr aip;
+ SeqEntryPtr sep, sepThis;
+ BioseqSetPtr bssp;
+ BioseqPtr bsp;
+ SeqIdPtr sip, sipNew;
+ DbtagPtr dbtp;
+ ObjectIdPtr oidp;
+
+ bssp = (BioseqSetPtr) pcdd->sequences->data.ptrvalue;
+ sepThis = (SeqEntryPtr) bssp->seq_set;
+ while (sepThis) {
+ bsp = sepThis->data.ptrvalue;
+ sip = bsp->id;
+ if (SipIsConsensus(sip)) {
+ sep = sepThis;
+ sep->next = NULL;
+ if (iPssmId > 0) { /* add a SeqId to consensus, which records PSSMid */
+ sipNew = (SeqIdPtr) ValNodeNew(NULL);
+ sipNew->choice = SEQID_GENERAL;
+ dbtp = (DbtagPtr) DbtagNew();
+ dbtp->db = StringSave("CDD");
+ oidp = ObjectIdNew();
+ oidp->id = iPssmId;
+ dbtp->tag = oidp;
+ sipNew->data.ptrvalue = dbtp;
+ sipNew->next = sip;
+ bsp->id = sipNew;
+ }
+ break;
+ }
+ sepThis = sepThis->next;
+ }
+ strcpy(OutputName,GetTempName("cddsrv"));
+ aip = AsnIoOpen(OutputName, "w");
+ SeqEntryAsnWrite((SeqEntryPtr) sep, aip, NULL);
+ AsnIoClose(aip);
+ printf("Content-type: text/html\n\n");
+ PrintFile(OutputName);
+ RemoveTempFiles();
+ return;
+}
+
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
/* MAIN Function for cddserver */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
@@ -2688,6 +2747,7 @@ Int2 Main()
Boolean bHasConsensus = FALSE;
Boolean bShowTax = FALSE;
Boolean bEvidenceViewer = FALSE;
+ Boolean bConsensusOnly = FALSE;
Char CDDalign[PATH_MAX], CDDidx[PATH_MAX];
Char CDDfile[PATH_MAX], ErrMsg[PATH_MAX];
Char chain[2], cChain;
@@ -2775,6 +2835,13 @@ Int2 Main()
}
/*---------------------------------------------------------------------------*/
+/* CD-Server as server for consensus sequences (formatted as SeqEntry) */
+/*---------------------------------------------------------------------------*/
+ if ((indx = WWWFindName(www_info, "GETCSEQ")) >= 0) {
+ bConsensusOnly = TRUE;
+ }
+
+/*---------------------------------------------------------------------------*/
/* retrieve the Cdd unique identifier */
/*---------------------------------------------------------------------------*/
if ((indx = WWWFindName(www_info, "uid")) < 0)
@@ -2887,6 +2954,18 @@ Int2 Main()
}
CddSrvRemoveNotes(pcdd);
bHasConsensus = CddHasConsensus(pcdd);
+/*---------------------------------------------------------------------------*/
+/* return consensus sequence if required */
+/*---------------------------------------------------------------------------*/
+ if (bConsensusOnly) {
+ if (bHasConsensus) {
+ CddSrvReturnConsensus(pcdd,iPssmId);
+ } else {
+ CddHtmlError("This CD does not have a consensus sequence!");
+ }
+ exit(0);
+ }
+
alen = CddGetAlignmentLength(pcdd);
/*---------------------------------------------------------------------------*/
diff --git a/biostruc/cdd/cddsrv.h b/biostruc/cdd/cddsrv.h
index 26ce4e8d..8dc64c0e 100644
--- a/biostruc/cdd/cddsrv.h
+++ b/biostruc/cdd/cddsrv.h
@@ -1,4 +1,4 @@
-/* $Id: cddsrv.h,v 1.16 2003/10/07 21:21:09 bauer Exp $
+/* $Id: cddsrv.h,v 1.17 2003/11/19 14:37:52 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Initial Version Creation Date: 9/20/1999
*
-* $Revision: 1.16 $
+* $Revision: 1.17 $
*
* File Description:
* header file for the CD-server CGI-bin
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: cddsrv.h,v $
+* Revision 1.17 2003/11/19 14:37:52 bauer
+* more consistent use of PSSM-IDs
+*
* Revision 1.16 2003/10/07 21:21:09 bauer
* initial changes to support drawing of hierarchies
*
@@ -160,9 +163,11 @@ typedef struct cddsum {
} CddSum, PNTR CddSumPtr;
typedef struct cdddesc {
+ Int4 iPssmId;
Char cCddId[PATH_MAX];
Char cDescr[CDD_MAX_DESCR];
Char cSourc[PATH_MAX];
+ Int4 iPssmLength;
struct cdddesc PNTR next;
} CddDesc, PNTR CddDescPtr;
diff --git a/biostruc/cdd/cddutil.c b/biostruc/cdd/cddutil.c
index 9f0e00f1..6970757d 100644
--- a/biostruc/cdd/cddutil.c
+++ b/biostruc/cdd/cddutil.c
@@ -1,4 +1,4 @@
-/* $Id: cddutil.c,v 1.89 2003/10/07 21:19:39 bauer Exp $
+/* $Id: cddutil.c,v 1.91 2003/12/09 22:21:35 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,13 +29,19 @@
*
* Initial Version Creation Date: 10/18/1999
*
-* $Revision: 1.89 $
+* $Revision: 1.91 $
*
* File Description: CDD utility routines
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: cddutil.c,v $
+* Revision 1.91 2003/12/09 22:21:35 bauer
+* added CddCountResTypes
+*
+* Revision 1.90 2003/12/09 18:48:05 bauer
+* commented out deprecated fields in BlastKarlinBlkCopy
+*
* Revision 1.89 2003/10/07 21:19:39 bauer
* made CddMasterIs3D more general
*
@@ -2016,6 +2022,73 @@ Nlm_FloatHiPtr LIBCALL SeqAlignInform(SeqAlignPtr salp, BioseqPtr bsp_master,
/* Calculate per column information content for a CDD from the seqalign */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
+Int4 ** LIBCALL CddCountResTypes(CddPtr pcdd, Int4 *ncols)
+{
+ BioseqSetPtr bssp;
+ Boolean bHasConsensus = CddHasConsensus(pcdd);
+ Int4 offset, qlength, i, j, c;
+ Int4 **ResFreqTable;
+ SeqAlignPtr salp;
+ DenseDiagPtr ddp;
+ SeqIdPtr sip;
+ BioseqPtr bsp;
+ Uint1 *buffer;
+ SeqPortPtr spp;
+
+ if (!pcdd) return(NULL);
+ if (!pcdd->trunc_master) return(NULL);
+ bssp = pcdd->sequences->data.ptrvalue;
+ offset = pcdd->profile_range->from;
+ qlength = pcdd->trunc_master->length;
+ *ncols = qlength;
+ ResFreqTable = MemNew(qlength*sizeof(Int4 *));
+ for (i=0;i<qlength;i++) {
+ ResFreqTable[i] = MemNew(26*sizeof(Int4));
+ for (j=0;j<26;j++) ResFreqTable[i][j] = 0;
+ }
+ salp = pcdd->seqannot->data;
+ if (!bHasConsensus) { /* count residues in the master/representative too */
+ ddp = salp->segs;
+ sip = ddp->id;
+ bsp = CddRetrieveBioseqById(sip,bssp->seq_set);
+ buffer = MemNew((bsp->length)*sizeof(Uint1));
+ spp = SeqPortNew(bsp, 0, bsp->length-1, Seq_strand_unknown, Seq_code_ncbistdaa);
+ for (i=0; i<bsp->length;i++) buffer[i] = SeqPortGetResidue(spp);
+ spp = SeqPortFree(spp);
+ while (ddp) {
+ for (c=ddp->starts[0];c<ddp->starts[0]+ddp->len;c++) {
+ ResFreqTable[c-offset][buffer[c]]++;
+ }
+ ddp = ddp->next;
+ }
+ MemFree(buffer);
+ }
+ while (salp) {
+ ddp = salp->segs;
+ sip = ddp->id->next;
+ bsp = CddRetrieveBioseqById(sip,bssp->seq_set);
+ buffer = MemNew((bsp->length)*sizeof(Uint1));
+ spp = SeqPortNew(bsp, 0, bsp->length-1, Seq_strand_unknown, Seq_code_ncbistdaa);
+ for (i=0; i<bsp->length;i++) buffer[i] = SeqPortGetResidue(spp);
+ spp = SeqPortFree(spp);
+ while (ddp) {
+ for (c=ddp->starts[1];c<ddp->starts[1]+ddp->len;c++) {
+ i = ddp->starts[0]-offset+c-ddp->starts[1];
+ ResFreqTable[i][buffer[c]]++;
+ }
+ ddp = ddp->next;
+ }
+ MemFree(buffer);
+ salp = salp->next;
+ }
+ return(ResFreqTable);
+}
+
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+/* Calculate per column information content for a CDD from the seqalign */
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
Nlm_FloatHiPtr LIBCALL CddAlignInform(CddPtr pcdd, Nlm_FloatHi * Niobs)
{
Int4 offset;
@@ -4603,12 +4676,12 @@ static void BlastKarlinBlkCopy(BLAST_KarlinBlkPtr kbp_in,BLAST_KarlinBlkPtr kbp_
kbp_out->K = kbp_in->K;
kbp_out->logK = kbp_in->logK;
kbp_out->H = kbp_in->H;
- kbp_out->Lambda_real = kbp_in->Lambda_real;
+/* kbp_out->Lambda_real = kbp_in->Lambda_real;
kbp_out->K_real = kbp_in->K_real;
kbp_out->logK_real = kbp_in->logK_real;
kbp_out->H_real = kbp_in->H_real;
kbp_out->q_frame = kbp_in->q_frame;
- kbp_out->s_frame = kbp_in->s_frame;
+ kbp_out->s_frame = kbp_in->s_frame; */
kbp_out->paramC = kbp_in->paramC;
}
@@ -4671,13 +4744,13 @@ Seq_Mtf * LIBCALL CddDenDiagCposComp2KBP(BioseqPtr bspFake, Int4 iPseudo,
if (iPseudo <= 0) { /* need to determine first */
AInf = SeqAlignInform(salp, bspFake, bHasConsensus, 0);
for (i=0;i<bspFake->length;i++) SumAInf += AInf[i];
- if (SumAInf > 84) iPseudo = 10; /* purely empirical */
- else if (SumAInf > 55) iPseudo = 7;
- else if (SumAInf > 43) iPseudo = 5;
- else if (SumAInf > 41.5) iPseudo = 4;
- else if (SumAInf > 40) iPseudo = 3;
- else if (SumAInf > 39) iPseudo = 2;
- else iPseudo = 1;
+ if (SumAInf > 84 ) iPseudo = 10; /* purely empirical */
+ else if (SumAInf > 55 ) iPseudo = 7;
+ else if (SumAInf > 43 ) iPseudo = 5;
+ else if (SumAInf > 41.5) iPseudo = 4;
+ else if (SumAInf > 40 ) iPseudo = 3;
+ else if (SumAInf > 39 ) iPseudo = 2;
+ else iPseudo = 1;
MemFree(AInf);
if (pcdd && bWriteOut) printf("%s AInf:%6.1f PseudoCt: %d\n",cAccession,SumAInf, iPseudo);
}
diff --git a/biostruc/cdd/cddutil.h b/biostruc/cdd/cddutil.h
index 6200793c..df5ffe64 100644
--- a/biostruc/cdd/cddutil.h
+++ b/biostruc/cdd/cddutil.h
@@ -1,4 +1,4 @@
-/* $Id: cddutil.h,v 1.51 2003/08/25 19:09:47 bauer Exp $
+/* $Id: cddutil.h,v 1.52 2003/12/09 22:21:35 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,13 +29,16 @@
*
* Initial Version Creation Date: 12/15/1999
*
-* $Revision: 1.51 $
+* $Revision: 1.52 $
*
* File Description: Header file for cdd api utility functions
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: cddutil.h,v $
+* Revision 1.52 2003/12/09 22:21:35 bauer
+* added CddCountResTypes
+*
* Revision 1.51 2003/08/25 19:09:47 bauer
* added SeqAlignReadFromFile
*
@@ -493,6 +496,7 @@ Int2 LIBCALL CddTrimSeqAligns(CddPtr pcdd);
/*---------------------------------------------------------------------------*/
Nlm_FloatHi LIBCALL SeqAlignConservation(SeqAlignPtr salp, Nlm_FloatHi fract,BioseqPtr bsp_master, Boolean bHasConsensus, Int4 offset);
Nlm_FloatHiPtr LIBCALL SeqAlignInform(SeqAlignPtr salp, BioseqPtr bsp_master,Boolean bHasConsensus,Int4 offset);
+Int4 ** LIBCALL CddCountResTypes(CddPtr pcdd, Int4 *ncols);
Nlm_FloatHiPtr LIBCALL CddAlignInform(CddPtr pcdd, Nlm_FloatHi * Niobs);
Nlm_FloatHiPtr LIBCALL CddPssmInform(CddPtr pcdd);
Nlm_FloatHiPtr LIBCALL CddPosFreqInform(Nlm_FloatHi **posFreq, Int4 ncol, Int4 nrow);
diff --git a/biostruc/cdd/objcdd.c b/biostruc/cdd/objcdd.c
index bf488ee7..22af4d76 100644
--- a/biostruc/cdd/objcdd.c
+++ b/biostruc/cdd/objcdd.c
@@ -36,7 +36,7 @@ objcddAsnLoad(void)
/**************************************************
* Generated object loaders for Module NCBI-Cdd
-* Generated using ASNCODE Revision: 6.14 at Aug 14, 2003 10:05 AM
+* Generated using ASNCODE Revision: 6.14 at Jan 15, 2004 1:40 PM
*
**************************************************/
@@ -361,7 +361,7 @@ CddFree(CddPtr ptr)
MemFree(ptr -> name);
CddIdSetFree(ptr -> id);
CddDescrSetFree(ptr -> description);
- { SeqAnnotPtr sap, next; sap = ptr -> seqannot; while(sap) { next = sap->next; sap->next = NULL; sap = SeqAnnotFree(sap); sap = next; } }
+ AsnGenericUserSeqOfFree(ptr -> seqannot, (AsnOptFreeFunc) SeqAnnotFree);
BiostrucAnnotSetFree(ptr -> features);
SeqEntryFree(ptr -> sequences);
SeqIntFree(ptr -> profile_range);
@@ -379,7 +379,7 @@ CddFree(CddPtr ptr)
AlignAnnotSetFree(ptr -> alignannot);
Cn3dStyleDictionaryFree(ptr -> style_dictionary);
Cn3dUserAnnotationsFree(ptr -> user_annotations);
- LineageInfoFree(ptr -> ancestors);
+ AsnGenericUserSeqOfFree(ptr -> ancestors, (AsnOptFreeFunc) DomainParentFree);
ScoreMatrixParametersFree(ptr -> scoreparams);
SequenceTreeFree(ptr -> seqtree);
return MemFree(ptr);
@@ -581,14 +581,14 @@ CddAsnRead(AsnIoPtr aip, AsnTypePtr orig)
atp = AsnReadId(aip,amp, atp);
}
if (atp == CDD_ancestors) {
- ptr -> ancestors = LineageInfoAsnRead(aip, atp);
- if (aip -> io_failure) {
+ ptr -> ancestors = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DomainParentAsnRead, (AsnOptFreeFunc) DomainParentFree);
+ if (isError && ptr -> ancestors == NULL) {
goto erret;
}
atp = AsnReadId(aip,amp, atp);
}
if (atp == CDD_scoreparams) {
- ptr -> scoreparams = (ScoreMatrixParameters *)ScoreMatrixParametersAsnRead(aip, atp);
+ ptr -> scoreparams = ScoreMatrixParametersAsnRead(aip, atp);
if (aip -> io_failure) {
goto erret;
}
@@ -666,7 +666,7 @@ CddAsnWrite(CddPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
goto erret;
}
}
- if (ptr->seqannot != NULL) if (SeqAnnotSetAsnWrite(ptr->seqannot,aip,CDD_seqannot,CDD_seqannot_E)==FALSE) goto erret;
+ AsnGenericUserSeqOfAsnWrite(ptr -> seqannot, (AsnWriteFunc) SeqAnnotAsnWrite, aip, CDD_seqannot, CDD_seqannot_E);
if (ptr -> features != NULL) {
if ( ! BiostrucAnnotSetAsnWrite(ptr -> features, aip, CDD_features)) {
goto erret;
@@ -740,11 +740,7 @@ CddAsnWrite(CddPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
goto erret;
}
}
- if (ptr -> ancestors != NULL) {
- if ( ! LineageInfoAsnWrite(ptr -> ancestors, aip, CDD_ancestors)) {
- goto erret;
- }
- }
+ AsnGenericUserSeqOfAsnWrite(ptr -> ancestors, (AsnWriteFunc) DomainParentAsnWrite, aip, CDD_ancestors, CDD_ancestors_E);
if (ptr -> scoreparams != NULL) {
if ( ! ScoreMatrixParametersAsnWrite(ptr -> scoreparams, aip, CDD_scoreparams)) {
goto erret;
@@ -1230,6 +1226,772 @@ erret:
/**************************************************
*
+* CddPrefNodesNew()
+*
+**************************************************/
+NLM_EXTERN
+CddPrefNodesPtr LIBCALL
+CddPrefNodesNew(void)
+{
+ CddPrefNodesPtr ptr = MemNew((size_t) sizeof(CddPrefNodes));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* CddPrefNodesFree()
+*
+**************************************************/
+NLM_EXTERN
+CddPrefNodesPtr LIBCALL
+CddPrefNodesFree(CddPrefNodesPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ CddOrgRefSetFree(ptr -> preferred_nodes);
+ CddOrgRefSetFree(ptr -> model_organisms);
+ CddOrgRefSetFree(ptr -> optional_nodes);
+ CddPrefNodeDescrSetFree(ptr -> description);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* CddPrefNodesAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+CddPrefNodesPtr LIBCALL
+CddPrefNodesAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ CddPrefNodesPtr ptr;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* CddPrefNodes ::= (self contained) */
+ atp = AsnReadId(aip, amp, CDD_PREF_NODES);
+ } else {
+ atp = AsnLinkType(orig, CDD_PREF_NODES);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = CddPrefNodesNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == CDD_PREF_NODES_preferred_nodes) {
+ ptr -> preferred_nodes = CddOrgRefSetAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == CDD_PREF_NODES_model_organisms) {
+ ptr -> model_organisms = CddOrgRefSetAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == CDD_PREF_NODES_optional_nodes) {
+ ptr -> optional_nodes = CddOrgRefSetAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == CDD_PREF_NODES_description) {
+ ptr -> description = CddPrefNodeDescrSetAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = CddPrefNodesFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* CddPrefNodesAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+CddPrefNodesAsnWrite(CddPrefNodesPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, CDD_PREF_NODES); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> preferred_nodes != NULL) {
+ if ( ! CddOrgRefSetAsnWrite(ptr -> preferred_nodes, aip, CDD_PREF_NODES_preferred_nodes)) {
+ goto erret;
+ }
+ }
+ if (ptr -> model_organisms != NULL) {
+ if ( ! CddOrgRefSetAsnWrite(ptr -> model_organisms, aip, CDD_PREF_NODES_model_organisms)) {
+ goto erret;
+ }
+ }
+ if (ptr -> optional_nodes != NULL) {
+ if ( ! CddOrgRefSetAsnWrite(ptr -> optional_nodes, aip, CDD_PREF_NODES_optional_nodes)) {
+ goto erret;
+ }
+ }
+ if (ptr -> description != NULL) {
+ if ( ! CddPrefNodeDescrSetAsnWrite(ptr -> description, aip, CDD_PREF_NODES_description)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* CddOrgRefNew()
+*
+**************************************************/
+NLM_EXTERN
+CddOrgRefPtr LIBCALL
+CddOrgRefNew(void)
+{
+ CddOrgRefPtr ptr = MemNew((size_t) sizeof(CddOrgRef));
+
+ ptr -> active = 1;
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* CddOrgRefFree()
+*
+**************************************************/
+NLM_EXTERN
+CddOrgRefPtr LIBCALL
+CddOrgRefFree(CddOrgRefPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ OrgRefFree((OrgRefPtr)ptr -> reference);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* CddOrgRefAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+CddOrgRefPtr LIBCALL
+CddOrgRefAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ CddOrgRefPtr ptr;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* CddOrgRef ::= (self contained) */
+ atp = AsnReadId(aip, amp, CDD_ORG_REF);
+ } else {
+ atp = AsnLinkType(orig, CDD_ORG_REF);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = CddOrgRefNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == CDD_ORG_REF_reference) {
+ ptr -> reference = OrgRefAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == CDD_ORG_REF_active) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> active = av.boolvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = CddOrgRefFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* CddOrgRefAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+CddOrgRefAsnWrite(CddOrgRefPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, CDD_ORG_REF); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> reference != NULL) {
+ if ( ! OrgRefAsnWrite((OrgRefPtr)ptr -> reference, aip, CDD_ORG_REF_reference)) {
+ goto erret;
+ }
+ }
+ av.boolvalue = ptr -> active;
+ retval = AsnWrite(aip, CDD_ORG_REF_active, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* CddOrgRefSetFree()
+*
+**************************************************/
+NLM_EXTERN
+CddOrgRefSetPtr LIBCALL
+CddOrgRefSetFree(CddOrgRefSetPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericUserSeqOfFree(ptr, (AsnOptFreeFunc) CddOrgRefFree);
+ return NULL;
+}
+
+
+/**************************************************
+*
+* CddOrgRefSetAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+CddOrgRefSetPtr LIBCALL
+CddOrgRefSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ CddOrgRefSetPtr ptr;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* CddOrgRefSet ::= (self contained) */
+ atp = AsnReadId(aip, amp, CDD_ORG_REF_SET);
+ } else {
+ atp = AsnLinkType(orig, CDD_ORG_REF_SET);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ func = NULL;
+
+ ptr = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) CddOrgRefAsnRead, (AsnOptFreeFunc) CddOrgRefFree);
+ if (isError && ptr == NULL) {
+ goto erret;
+ }
+
+
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = CddOrgRefSetFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* CddOrgRefSetAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+CddOrgRefSetAsnWrite(CddOrgRefSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, CDD_ORG_REF_SET); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) CddOrgRefAsnWrite, aip, atp, CDD_ORG_REF_SET_E);
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* CddPrefNodeDescrFree()
+*
+**************************************************/
+NLM_EXTERN
+CddPrefNodeDescrPtr LIBCALL
+CddPrefNodeDescrFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case CddPrefNodeDescr_create_date:
+ DateFree(anp -> data.ptrvalue);
+ break;
+ case CddPrefNodeDescr_description:
+ MemFree(anp -> data.ptrvalue);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* CddPrefNodeDescrAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+CddPrefNodeDescrPtr LIBCALL
+CddPrefNodeDescrAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError = FALSE;
+ Boolean nullIsError = FALSE;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* CddPrefNodeDescr ::= (self contained) */
+ atp = AsnReadId(aip, amp, CDD_PREF_NODE_DESCR);
+ } else {
+ atp = AsnLinkType(orig, CDD_PREF_NODE_DESCR); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == CDD_PREF_NODE_DESCR_create_date) {
+ choice = CddPrefNodeDescr_create_date;
+ func = (AsnReadFunc) DateAsnRead;
+ }
+ else if (atp == CDD_PREF_NODE_DESCR_description) {
+ choice = CddPrefNodeDescr_description;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.ptrvalue = av.ptrvalue;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (aip -> io_failure) goto erret;
+
+ if (nullIsError && anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ aip -> io_failure = TRUE;
+ goto ret;
+}
+
+
+/**************************************************
+*
+* CddPrefNodeDescrAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+CddPrefNodeDescrAsnWrite(CddPrefNodeDescrPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, CDD_PREF_NODE_DESCR); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ case CddPrefNodeDescr_create_date:
+ writetype = CDD_PREF_NODE_DESCR_create_date;
+ func = (AsnWriteFunc) DateAsnWrite;
+ break;
+ case CddPrefNodeDescr_description:
+ av.ptrvalue = anp->data.ptrvalue;
+ retval = AsnWrite(aip, CDD_PREF_NODE_DESCR_description, &av);
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* CddPrefNodeDescrSetFree()
+*
+**************************************************/
+NLM_EXTERN
+CddPrefNodeDescrSetPtr LIBCALL
+CddPrefNodeDescrSetFree(CddPrefNodeDescrSetPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericChoiceSeqOfFree(ptr, (AsnOptFreeFunc) CddPrefNodeDescrFree);
+ return NULL;
+}
+
+
+/**************************************************
+*
+* CddPrefNodeDescrSetAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+CddPrefNodeDescrSetPtr LIBCALL
+CddPrefNodeDescrSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ CddPrefNodeDescrSetPtr ptr;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* CddPrefNodeDescrSet ::= (self contained) */
+ atp = AsnReadId(aip, amp, CDD_PREF_NODE_DESCR_SET);
+ } else {
+ atp = AsnLinkType(orig, CDD_PREF_NODE_DESCR_SET);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ func = NULL;
+
+ ptr = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) CddPrefNodeDescrAsnRead, (AsnOptFreeFunc) CddPrefNodeDescrFree);
+ if (isError && ptr == NULL) {
+ goto erret;
+ }
+
+
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = CddPrefNodeDescrSetFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* CddPrefNodeDescrSetAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+CddPrefNodeDescrSetAsnWrite(CddPrefNodeDescrSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! objcddAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, CDD_PREF_NODE_DESCR_SET); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ retval = AsnGenericChoiceSeqOfAsnWrite(ptr , (AsnWriteFunc) CddPrefNodeDescrAsnWrite, aip, atp, CDD_PREF_NODE_DESCR_SET_E);
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
* GlobalIdNew()
*
**************************************************/
@@ -3718,6 +4480,13 @@ DomainParentAsnRead(AsnIoPtr aip, AsnTypePtr orig)
atp = AsnReadId(aip,amp, atp);
func = NULL;
+ if (atp == DOMAIN_PARENT_parent_type) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> parent_type = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
if (atp == DOMAIN_PARENT_parentid) {
ptr -> parentid = CddIdAsnRead(aip, atp);
if (aip -> io_failure) {
@@ -3783,6 +4552,8 @@ DomainParentAsnWrite(DomainParentPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
goto erret;
}
+ av.intvalue = ptr -> parent_type;
+ retval = AsnWrite(aip, DOMAIN_PARENT_parent_type, &av);
if (ptr -> parentid != NULL) {
if ( ! CddIdAsnWrite(ptr -> parentid, aip, DOMAIN_PARENT_parentid)) {
goto erret;
@@ -3807,341 +4578,6 @@ erret:
/**************************************************
*
-* LineageInfo_complexparentsNew()
-*
-**************************************************/
-static
-LineageInfo_complexparentsPtr LIBCALL
-LineageInfo_complexparentsNew(void)
-{
- LineageInfo_complexparentsPtr ptr = MemNew((size_t) sizeof(LineageInfo_complexparents));
-
- return ptr;
-
-}
-
-
-/**************************************************
-*
-* LineageInfoFree()
-*
-**************************************************/
-NLM_EXTERN
-LineageInfoPtr LIBCALL
-LineageInfoFree(ValNodePtr anp)
-{
- Pointer pnt;
-
- if (anp == NULL) {
- return NULL;
- }
-
- pnt = anp->data.ptrvalue;
- switch (anp->choice)
- {
- default:
- break;
- case LineageInfo_simpleparent:
- DomainParentFree(anp -> data.ptrvalue);
- break;
- case LineageInfo_LineageInfo_Complexparents:
- LineageInfo_complexparentsFree(anp -> data.ptrvalue);
- break;
- }
- return MemFree(anp);
-}
-
-
-/**************************************************
-*
-* LineageInfo_complexparentsFree()
-*
-**************************************************/
-static
-LineageInfo_complexparentsPtr LIBCALL
-LineageInfo_complexparentsFree(LineageInfo_complexparentsPtr ptr)
-{
-
- if(ptr == NULL) {
- return NULL;
- }
- AsnGenericUserSeqOfFree(ptr -> fusionparents, (AsnOptFreeFunc) DomainParentFree);
- AsnGenericUserSeqOfFree(ptr -> deletionparent, (AsnOptFreeFunc) DomainParentFree);
- return MemFree(ptr);
-}
-
-
-/**************************************************
-*
-* LineageInfoAsnRead()
-*
-**************************************************/
-NLM_EXTERN
-LineageInfoPtr LIBCALL
-LineageInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
-{
- DataVal av;
- AsnTypePtr atp;
- ValNodePtr anp;
- Uint1 choice;
- Boolean isError = FALSE;
- Boolean nullIsError = FALSE;
- AsnReadFunc func;
-
- if (! loaded)
- {
- if (! objcddAsnLoad()) {
- return NULL;
- }
- }
-
- if (aip == NULL) {
- return NULL;
- }
-
- if (orig == NULL) { /* LineageInfo ::= (self contained) */
- atp = AsnReadId(aip, amp, LINEAGE_INFO);
- } else {
- atp = AsnLinkType(orig, LINEAGE_INFO); /* link in local tree */
- }
- if (atp == NULL) {
- return NULL;
- }
-
- anp = ValNodeNew(NULL);
- if (anp == NULL) {
- goto erret;
- }
- if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
- goto erret;
- }
-
- func = NULL;
-
- atp = AsnReadId(aip, amp, atp); /* find the choice */
- if (atp == NULL) {
- goto erret;
- }
- if (atp == LINEAGE_INFO_simpleparent) {
- choice = LineageInfo_simpleparent;
- func = (AsnReadFunc) DomainParentAsnRead;
- }
- else if (atp == LINEAGE_INFO_complexparents) {
- choice = LineageInfo_LineageInfo_Complexparents;
- func = (AsnReadFunc) LineageInfo_complexparentsAsnRead;
- }
- anp->choice = choice;
- if (func != NULL)
- {
- anp->data.ptrvalue = (* func)(aip, atp);
- if (aip -> io_failure) goto erret;
-
- if (nullIsError && anp->data.ptrvalue == NULL) {
- goto erret;
- }
- }
-
-ret:
- AsnUnlinkType(orig); /* unlink local tree */
- return anp;
-
-erret:
- anp = MemFree(anp);
- aip -> io_failure = TRUE;
- goto ret;
-}
-
-
-/**************************************************
-*
-* LineageInfo_complexparentsAsnRead()
-*
-**************************************************/
-static
-LineageInfo_complexparentsPtr LIBCALL
-LineageInfo_complexparentsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
-{
- DataVal av;
- AsnTypePtr atp;
- Boolean isError = FALSE;
- AsnReadFunc func;
- LineageInfo_complexparentsPtr ptr;
-
- if (! loaded)
- {
- if (! objcddAsnLoad()) {
- return NULL;
- }
- }
-
- if (aip == NULL) {
- return NULL;
- }
-
- if (orig == NULL) { /* LineageInfo_complexparents ::= (self contained) */
- atp = AsnReadId(aip, amp, LINEAGE_INFO_complexparents);
- } else {
- atp = AsnLinkType(orig, LINEAGE_INFO_complexparents);
- }
- /* link in local tree */
- if (atp == NULL) {
- return NULL;
- }
-
- ptr = LineageInfo_complexparentsNew();
- if (ptr == NULL) {
- goto erret;
- }
- if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
- goto erret;
- }
-
- atp = AsnReadId(aip,amp, atp);
- func = NULL;
-
- if (atp == LINEAGE_INFO_complexparents_fusionparents) {
- ptr -> fusionparents = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DomainParentAsnRead, (AsnOptFreeFunc) DomainParentFree);
- if (isError && ptr -> fusionparents == NULL) {
- goto erret;
- }
- atp = AsnReadId(aip,amp, atp);
- }
- if (atp == LINEAGE_INFO_complexparents_deletionparent) {
- ptr -> deletionparent = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) DomainParentAsnRead, (AsnOptFreeFunc) DomainParentFree);
- if (isError && ptr -> deletionparent == NULL) {
- goto erret;
- }
- atp = AsnReadId(aip,amp, atp);
- }
-
- if (AsnReadVal(aip, atp, &av) <= 0) {
- goto erret;
- }
- /* end struct */
-
-ret:
- AsnUnlinkType(orig); /* unlink local tree */
- return ptr;
-
-erret:
- aip -> io_failure = TRUE;
- ptr = LineageInfo_complexparentsFree(ptr);
- goto ret;
-}
-
-
-
-/**************************************************
-*
-* LineageInfoAsnWrite()
-*
-**************************************************/
-NLM_EXTERN Boolean LIBCALL
-LineageInfoAsnWrite(LineageInfoPtr anp, AsnIoPtr aip, AsnTypePtr orig)
-
-{
- DataVal av;
- AsnTypePtr atp, writetype = NULL;
- Pointer pnt;
- AsnWriteFunc func = NULL;
- Boolean retval = FALSE;
-
- if (! loaded)
- {
- if (! objcddAsnLoad())
- return FALSE;
- }
-
- if (aip == NULL)
- return FALSE;
-
- atp = AsnLinkType(orig, LINEAGE_INFO); /* link local tree */
- if (atp == NULL) {
- return FALSE;
- }
-
- if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
-
- av.ptrvalue = (Pointer)anp;
- if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
- goto erret;
- }
-
- pnt = anp->data.ptrvalue;
- switch (anp->choice)
- {
- case LineageInfo_simpleparent:
- writetype = LINEAGE_INFO_simpleparent;
- func = (AsnWriteFunc) DomainParentAsnWrite;
- break;
- case LineageInfo_LineageInfo_Complexparents:
- writetype = LINEAGE_INFO_complexparents;
- func = (AsnWriteFunc) LineageInfo_complexparentsAsnWrite;
- break;
- }
- if (writetype != NULL) {
- retval = (* func)(pnt, aip, writetype); /* write it out */
- }
- if (!retval) {
- goto erret;
- }
- retval = TRUE;
-
-erret:
- AsnUnlinkType(orig); /* unlink local tree */
- return retval;
-}
-
-
-/**************************************************
-*
-* LineageInfo_complexparentsAsnWrite()
-*
-**************************************************/
-static Boolean LIBCALL
-LineageInfo_complexparentsAsnWrite(LineageInfo_complexparentsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
-{
- DataVal av;
- AsnTypePtr atp;
- Boolean retval = FALSE;
-
- if (! loaded)
- {
- if (! objcddAsnLoad()) {
- return FALSE;
- }
- }
-
- if (aip == NULL) {
- return FALSE;
- }
-
- atp = AsnLinkType(orig, LINEAGE_INFO_complexparents); /* link local tree */
- if (atp == NULL) {
- return FALSE;
- }
-
- if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
- if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
- goto erret;
- }
-
- AsnGenericUserSeqOfAsnWrite(ptr -> fusionparents, (AsnWriteFunc) DomainParentAsnWrite, aip, LINEAGE_INFO_complexparents_fusionparents, LINEAGE_INFO_complexparents_fusionparents_E);
- AsnGenericUserSeqOfAsnWrite(ptr -> deletionparent, (AsnWriteFunc) DomainParentAsnWrite, aip, LINEAGE_INFO_complexparents_deletionparent, LINEAGE_INFO_complexparents_deletionparent_E);
- if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
- goto erret;
- }
- retval = TRUE;
-
-erret:
- AsnUnlinkType(orig); /* unlink local tree */
- return retval;
-}
-
-
-
-/**************************************************
-*
* SequenceTreeNew()
*
**************************************************/
diff --git a/biostruc/cdd/objcdd.h b/biostruc/cdd/objcdd.h
index 57347fc0..5be0a2b9 100644
--- a/biostruc/cdd/objcdd.h
+++ b/biostruc/cdd/objcdd.h
@@ -20,7 +20,7 @@ extern "C" { /* } */
/**************************************************
*
* Generated objects for Module NCBI-Cdd
-* Generated using ASNCODE Revision: 6.14 at Aug 14, 2003 10:05 AM
+* Generated using ASNCODE Revision: 6.14 at Jan 15, 2004 1:40 PM
*
**************************************************/
@@ -86,7 +86,7 @@ typedef struct struct_Cdd {
struct struct_Align_annot PNTR alignannot;
struct struct_Cn3d_style_dictionary PNTR style_dictionary;
struct struct_Cn3d_user_annotations PNTR user_annotations;
- ValNodePtr ancestors;
+ struct struct_Domain_parent PNTR ancestors;
struct struct_Score_matrix_parameters PNTR scoreparams;
struct struct_Sequence_tree PNTR seqtree;
} Cdd, PNTR CddPtr;
@@ -165,6 +165,95 @@ NLM_EXTERN Boolean LIBCALL CddTreeSetAsnWrite PROTO (( CddTreeSetPtr , AsnIoPtr,
/**************************************************
*
+* CddPrefNodes
+*
+**************************************************/
+typedef struct struct_Cdd_pref_nodes {
+ struct struct_Cdd_org_ref PNTR preferred_nodes;
+ struct struct_Cdd_org_ref PNTR model_organisms;
+ struct struct_Cdd_org_ref PNTR optional_nodes;
+ ValNodePtr description;
+} CddPrefNodes, PNTR CddPrefNodesPtr;
+
+
+NLM_EXTERN CddPrefNodesPtr LIBCALL CddPrefNodesFree PROTO ((CddPrefNodesPtr ));
+NLM_EXTERN CddPrefNodesPtr LIBCALL CddPrefNodesNew PROTO (( void ));
+NLM_EXTERN CddPrefNodesPtr LIBCALL CddPrefNodesAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL CddPrefNodesAsnWrite PROTO (( CddPrefNodesPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* CddOrgRef
+*
+**************************************************/
+typedef struct struct_Cdd_org_ref {
+ struct struct_Cdd_org_ref PNTR next;
+ OrgRefPtr reference;
+ Uint1 active;
+} CddOrgRef, PNTR CddOrgRefPtr;
+
+
+NLM_EXTERN CddOrgRefPtr LIBCALL CddOrgRefFree PROTO ((CddOrgRefPtr ));
+NLM_EXTERN CddOrgRefPtr LIBCALL CddOrgRefNew PROTO (( void ));
+NLM_EXTERN CddOrgRefPtr LIBCALL CddOrgRefAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL CddOrgRefAsnWrite PROTO (( CddOrgRefPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* CddOrgRefSet
+*
+**************************************************/
+typedef struct struct_Cdd_org_ref CddOrgRefSet;
+typedef struct struct_Cdd_org_ref PNTR CddOrgRefSetPtr;
+#define CddOrgRefSetNew() Cdd_org_refNew()
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+NLM_EXTERN CddOrgRefSetPtr LIBCALL CddOrgRefSetFree PROTO ((CddOrgRefSetPtr ));
+NLM_EXTERN CddOrgRefSetPtr LIBCALL CddOrgRefSetNew PROTO (( void ));
+NLM_EXTERN CddOrgRefSetPtr LIBCALL CddOrgRefSetAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL CddOrgRefSetAsnWrite PROTO (( CddOrgRefSetPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+typedef ValNodePtr CddPrefNodeDescrPtr;
+typedef ValNode CddPrefNodeDescr;
+#define CddPrefNodeDescr_create_date 1
+#define CddPrefNodeDescr_description 2
+
+
+NLM_EXTERN CddPrefNodeDescrPtr LIBCALL CddPrefNodeDescrFree PROTO ((CddPrefNodeDescrPtr ));
+NLM_EXTERN CddPrefNodeDescrPtr LIBCALL CddPrefNodeDescrAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL CddPrefNodeDescrAsnWrite PROTO (( CddPrefNodeDescrPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* CddPrefNodeDescrSet
+*
+**************************************************/
+typedef ValNode CddPrefNodeDescrSet;
+typedef ValNodePtr CddPrefNodeDescrSetPtr;
+#define CddPrefNodeDescrSetNew() ValNodeNew(NULL)
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+NLM_EXTERN CddPrefNodeDescrSetPtr LIBCALL CddPrefNodeDescrSetFree PROTO ((CddPrefNodeDescrSetPtr ));
+NLM_EXTERN CddPrefNodeDescrSetPtr LIBCALL CddPrefNodeDescrSetNew PROTO (( void ));
+NLM_EXTERN CddPrefNodeDescrSetPtr LIBCALL CddPrefNodeDescrSetAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL CddPrefNodeDescrSetAsnWrite PROTO (( CddPrefNodeDescrSetPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
* GlobalId
*
**************************************************/
@@ -430,6 +519,7 @@ NLM_EXTERN Boolean LIBCALL AlignAnnotSetAsnWrite PROTO (( AlignAnnotSetPtr , Asn
**************************************************/
typedef struct struct_Domain_parent {
struct struct_Domain_parent PNTR next;
+ Int4 parent_type;
ValNodePtr parentid;
struct seqannot PNTR seqannot;
} DomainParent, PNTR DomainParentPtr;
@@ -440,41 +530,6 @@ NLM_EXTERN DomainParentPtr LIBCALL DomainParentNew PROTO (( void ));
NLM_EXTERN DomainParentPtr LIBCALL DomainParentAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
NLM_EXTERN Boolean LIBCALL DomainParentAsnWrite PROTO (( DomainParentPtr , AsnIoPtr, AsnTypePtr));
-typedef ValNodePtr LineageInfoPtr;
-typedef ValNode LineageInfo;
-#define LineageInfo_simpleparent 1
-#define LineageInfo_LineageInfo_Complexparents 2
-
-
-NLM_EXTERN LineageInfoPtr LIBCALL LineageInfoFree PROTO ((LineageInfoPtr ));
-NLM_EXTERN LineageInfoPtr LIBCALL LineageInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
-NLM_EXTERN Boolean LIBCALL LineageInfoAsnWrite PROTO (( LineageInfoPtr , AsnIoPtr, AsnTypePtr));
-
-
-
-/**************************************************
-*
-* LineageInfo_complexparents
-*
-**************************************************/
-
-#ifdef NLM_GENERATED_CODE_PROTO
-
-typedef struct struct_LineageInfo_Complexparents {
- struct struct_Domain_parent PNTR fusionparents;
- struct struct_Domain_parent PNTR deletionparent;
-} LineageInfo_complexparents, PNTR LineageInfo_complexparentsPtr;
-#endif /* NLM_GENERATED_CODE_PROTO */
-
-#ifdef NLM_GENERATED_CODE_PROTO
-
-static LineageInfo_complexparentsPtr LIBCALL LineageInfo_complexparentsFree PROTO ((LineageInfo_complexparentsPtr ));
-static LineageInfo_complexparentsPtr LIBCALL LineageInfo_complexparentsNew PROTO (( void ));
-static LineageInfo_complexparentsPtr LIBCALL LineageInfo_complexparentsAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
-static Boolean LIBCALL LineageInfo_complexparentsAsnWrite PROTO (( LineageInfo_complexparentsPtr , AsnIoPtr, AsnTypePtr));
-
-#endif /* NLM_GENERATED_CODE_PROTO */
-
/**************************************************
diff --git a/biostruc/cdd/wrpsb.h b/biostruc/cdd/wrpsb.h
index df17492c..4d0ec534 100644
--- a/biostruc/cdd/wrpsb.h
+++ b/biostruc/cdd/wrpsb.h
@@ -1,4 +1,4 @@
-/* $Id: wrpsb.h,v 1.15 2003/10/07 21:15:15 bauer Exp $
+/* $Id: wrpsb.h,v 1.16 2003/11/19 14:34:31 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Initial Version Creation Date: 1/19/2000
*
-* $Revision: 1.15 $
+* $Revision: 1.16 $
*
* File Description:
* Header file for WWW-RPS BLAST client
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: wrpsb.h,v $
+* Revision 1.16 2003/11/19 14:34:31 bauer
+* changes to support SeqAnnot export
+*
* Revision 1.15 2003/10/07 21:15:15 bauer
* support generation of Sequence Annotation from CD-Search results
*
@@ -92,10 +95,10 @@
#define DEFAULT_DATALIB "cdd"
#define DEFAULT_EVALUE "0.01"
#define DEFAULT_NHITS "25"
-#define NUMARGS (sizeof(myargs)/sizeof(myargs[0]))
+/* #define NUMARGS (sizeof(myargs)/sizeof(myargs[0])) */
#define RPS_MAGIC_NUMBER 7702
#define WRPSB_GRAPH_WIDTH 600
-#define WRPSB_GRAPH_MAXROW 25
+#define WRPSB_GRAPH_MAXROW 12
#define WRPSB_GRAPH_HEIGHT 16
#define WRPSB_GRAPH_SPACER 4
#define BUFFER_LENGTH 3072
@@ -111,6 +114,9 @@
#define RETRIEVEPRECALC 4
#define DRAWQUEUED 5
#define DRAWONLY 6
+#define DARTSIZELIMIT 1500
+#define DARTFAMILYNUM 15000
+
typedef struct _txdfline_struct {
@@ -197,7 +203,7 @@ static Char CDDpath[PATH_MAX];
static Char ENTREZurl[PATH_MAX];
static Char DOCSUMurl[PATH_MAX];
static Char MAILto[PATH_MAX];
-static FILE *OutputFile = NULL;
+static FILE *OutputFile;
static Char OutputName[200];
static Char gunzip[PATH_MAX];
static Char MMDBpath[PATH_MAX];
@@ -207,7 +213,7 @@ static Char CDDextens[PATH_MAX];
static Char RAWextens[PATH_MAX];
static Char TREextens[PATH_MAX];
static Char SEQextens[PATH_MAX];
-static Int2 SortOn = 0;
+static Int2 SortOn;
static Int4 cnt_MMDBid;
static Char cCDDid[PATH_MAX];
static Char CDDdescr[PATH_MAX];
@@ -241,6 +247,9 @@ static Char ODBCINI[PATH_MAX];
static Char DARTUSER[PATH_MAX];
static Char DARTPASS[PATH_MAX];
+static unsigned iDartFam[DARTFAMILYNUM];
+static Int4 iDartFamNum;
+
/*---------------------------------------------------------------------------*/
/* DART color scheme */
/*---------------------------------------------------------------------------*/
diff --git a/biostruc/cdd/wrpsbcl3.c b/biostruc/cdd/wrpsbcl3.c
index 7ad03ded..6824506f 100644
--- a/biostruc/cdd/wrpsbcl3.c
+++ b/biostruc/cdd/wrpsbcl3.c
@@ -1,4 +1,4 @@
-/* $Id: wrpsbcl3.c,v 1.35 2003/10/07 21:15:15 bauer Exp $
+/* $Id: wrpsbcl3.c,v 1.36 2003/11/19 14:34:31 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Initial Version Creation Date: 4/19/2000
*
-* $Revision: 1.35 $
+* $Revision: 1.36 $
*
* File Description:
* WWW-RPS BLAST client
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: wrpsbcl3.c,v $
+* Revision 1.36 2003/11/19 14:34:31 bauer
+* changes to support SeqAnnot export
+*
* Revision 1.35 2003/10/07 21:15:15 bauer
* support generation of Sequence Annotation from CD-Search results
*
@@ -148,9 +151,6 @@
#undef CDSEARCH_TEST /* use iblast1 instead of public service rpsblast */
#define WIN_GIF
-#define DARTSIZELIMIT 1500
-#define DARTFAMILYNUM 5000
-
#include <ncbi.h>
#include <ncbimain.h>
#include <sequtil.h>
@@ -176,9 +176,6 @@
#include <pmfapi.h>
#include <entrez2.h>
-unsigned iDartFam[DARTFAMILYNUM];
-Int4 iDartFamNum = 0;
-
ReadDBFILEPtr rdfp = NULL;
/*---------------------------------------------------------------------------*/
@@ -633,9 +630,9 @@ static Boolean WRPSBDrawSearchPage()
databases[4] = CDDSearch5;
databases[5] = CDDSearch6;
databases[6] = CDDSearch7;
+ datab_nam[6] = CDDSname7;
datab_nam[4] = CDDSname5;
datab_nam[5] = CDDSname6;
- datab_nam[6] = CDDSname7;
}
@@ -727,7 +724,7 @@ static Boolean WRPSBDrawSearchPage()
printf("</FORM>\n");
printf("<hr>\n");
- printf("<b><a href=\"http://www.ncbi.nlm.nih.gov/htbin-post/Entrez/query?uid=9254694&form=6&db=m&Dopt=r\">Reference</a>:</b>\n");
+ printf("<b><a href=\"http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=9254694&dopt=Abstract\">Reference</a>:</b>\n");
printf("Altschul, Stephen F., Thomas L. Madden, Alejandro A. Sch&auml;ffer, \n");
printf("Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), \n");
printf("\"Gapped BLAST and PSI-BLAST: a new generation of protein database search\n");
@@ -817,6 +814,7 @@ static void WRPSBCl3PrintGraphics(AlignmentAbstractPtr aap, FILE *table, Int4 ma
Char aln[CDD_MAX_DESCR], cTmp2[24];
CharPtr buf;
+ biasstring[0] = '\0';
if (query_bsp && querygi <= 0) {
buf = MemNew((query_bsp->length+1)*sizeof(Char));
@@ -914,8 +912,7 @@ static void WRPSBCl3PrintGraphics(AlignmentAbstractPtr aap, FILE *table, Int4 ma
}
aapThis = aap;
while (aapThis) {
- if (aapThis->row <= WRPSB_GRAPH_MAXROW &&
- (iGraphMode == 2 || aapThis->bDrawThisOne)) {
+ if (aapThis->row <= WRPSB_GRAPH_MAXROW && (iGraphMode == 2 || aapThis->bDrawThisOne)) {
nblocks++;
ulx = aapThis->gstart + 5;
lrx = aapThis->gstop + 5;
@@ -1063,7 +1060,7 @@ static void WRPSBCl3PrintGraphics(AlignmentAbstractPtr aap, FILE *table, Int4 ma
fprintf(table,"<img src=\"%swrpsb.cgi?PIC=%d,%d,%d",
URLcgi,GraphWidth,query_bsp->length,nblocks);
aapThis = aap; while (aapThis) {
- if (aapThis->bDrawThisOne) {
+ if (aapThis->row <= WRPSB_GRAPH_MAXROW && (iGraphMode == 2 || aapThis->bDrawThisOne)) {
fprintf(table,",%d,%d,%d,%s,%d,%d,%d,%d",aapThis->gstart,aapThis->gstop - aapThis->gstart,
aapThis->row,aapThis->cGraphId,aapThis->colcyc,
(Int4)(aapThis->nmissg * 100.0),(Int4)(aapThis->cmissg * 100.0),
@@ -1103,6 +1100,7 @@ static Dart_Connect *WRPSBConnectDart()
} else {
Connection = Dart_Init2("CDart", DARTUSER, DARTPASS);
}
+ iDartFamNum = 0;
Dart_CdFamily(Connection, iDartFam, DARTFAMILYNUM, &iDartFamNum);
return (Connection);
}
@@ -1114,524 +1112,6 @@ static void WRPSBDisConnectDart(Dart_Connect *Connection)
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
-/* check whether a hit is unique, or to a CD hit somewhere else in the list */
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-static Boolean WRPSBHitIsNew(AlignmentAbstractPtr aapThis,
- AlignmentAbstractPtr aapHead,
- Dart_Connect *Connection)
-{
- AlignmentAbstractPtr aap;
- int Size, i;
- unsigned Gilist[DARTSIZELIMIT];
- char Accession[DARTSIZELIMIT][30];
-
- if (!aapThis) return FALSE;
- for (i=0;i<iDartFamNum;i++) {
- if (iDartFam[i] == aapThis->pssmid) {
- aapThis->bIsArch = TRUE;
- return(TRUE);
- }
- }
- if (Connection) {
- if (aapThis->pssmid > 0) {
- if (Dart_SameSim(Connection,aapThis->pssmid,Gilist,DARTSIZELIMIT,&Size)) {
- for (i=0;i<Size;i++) {
- if (!Dart_CDGi2Acc(Connection,Gilist[i],Accession[i],30)) {
- Accession[i][0] = '\0';
- }
- }
- }
- } else {
- if (Dart_Related(Connection,aapThis->cCDDid,Gilist,DARTSIZELIMIT,&Size,NULL)) {
- for (i=0;i<Size;i++) {
- if (!Dart_CDGi2Acc(Connection,Gilist[i],Accession[i],30)) {
- Accession[i][0] = '\0';
- }
- }
- }
- }
- } else {
- Size = 0;
- }
-
- aap = aapHead; while (aap) {
- if (aapThis->pssmid > -1 && aap->pssmid > -1) {
- if (aapThis->pssmid == aap->pssmid) {
- aapThis->colcyc = aap->colcyc;
- return FALSE;
- }
- }
- for (i=0;i<Size;i++) {
- if (Nlm_StrCmp(Accession[i],aap->cCDDid) == 0) {
- aapThis->colcyc = aap->colcyc;
- return FALSE;
- }
- }
- if (Nlm_StrCmp(CDDlocat,"inhouse")==0) { /* map names just for inhouse */
- if (aapThis->cCDDid && aap->cCDDid) {
- if (Nlm_StrCmp(aapThis->cCDDid,aap->cCDDid) == 0) {
- aapThis->colcyc = aap->colcyc;
- return FALSE;
- }
- }
- if (Nlm_StrICmp(aapThis->cGraphId,aap->cGraphId) == 0) {
- aapThis->colcyc = aap->colcyc;
- return FALSE;
- }
- }
- aap = aap->next;
- }
- return TRUE;
-}
-
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-/* define the indents on a block containing repeats according to the alignmt */
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-static void WRPSBIndentsViaSeqAlign(CddRepeatPtr pcdr,
- AlignmentAbstractPtr aap,
- Int4 iGraphWidth,
- Int4 length)
-{
- SeqLocPtr slp;
- SeqIntPtr sintp;
- Int4Ptr istarts;
- Int4 i = 0, j, s1, s2;
- CddExpAlignPtr pCDea;
- DenseSegPtr dsp;
-
- istarts = MemNew(pcdr->count * sizeof (Int4));
- slp = (SeqLocPtr) pcdr->location->data.ptrvalue;
- while (slp) {
- sintp = (SeqIntPtr) slp->data.ptrvalue;
- istarts[i] = sintp->from; i++;
- slp = slp->next;
- }
-
- pCDea = CddExpAlignNew();
- CddExpAlignAlloc(pCDea,length);
- dsp = aap->salp->segs;
- for (i=0;i<dsp->numseg;i++) {
- s1 = dsp->starts[i*2];
- s2 = dsp->starts[i*2+1];
- if (s1 >=0 && s2>= 0) {
- for (j=0;j<dsp->lens[i];j++) {
- pCDea->adata[s1+j]=s2+j;
- }
- }
- }
- aap->indents = MemNew(pcdr->count * sizeof (Int4));
- aap->nindents = 0;
- for (i=0;i<pcdr->count;i++) {
- for (j=0;j<length;j++) {
- if (pCDea->adata[j] >= istarts[i]) {
- s1 = (j * iGraphWidth) / (length - 1);
- if (s1 > aap->gstart && s1 < aap->gstop) {
- aap->indents[aap->nindents] = s1;
- aap->nindents++;
- }
- break;
- }
- }
- }
- MemFree(istarts);
-}
-
-
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-/* fill in the Alignment Abstract Data Structure */
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-static AlignmentAbstractPtr WRPSBCl3AbstractAlignment(BlastPruneSapStructPtr prune,
- BioseqPtr query_bsp,
- Int4 iGraphWidth,
- Int4 *mxr,
- Int4 iGraphMode,
- CharPtr dbversion,
- Boolean *bAnyPdb,
- Dart_Connect *Connection)
-{
- Boolean *bConflict;
- Boolean bDbIsOasis = TRUE, found_score = FALSE;
- Int4 maxrow = 1, i, pssmid;
- Int4 lastcol = -1;
- Int4 iCount = 0, replen;
- Int4 iColValue, number, score, fullCDstart, fullCDstop, nindent;
- Int4 *iOvrlap, *iMutual;
- AlignmentAbstractPtr aap, aapThis, aapTmp, aapHead = NULL;
- BioseqPtr bsp;
- CddTreePtr pcddt;
- CddDescrPtr description;
- CddRepeatPtr pcdr;
- CharPtr cTemp;
- CharPtr cCurrDesc;
- DbtagPtr dbtp;
- DenseSegPtr dsp;
- ObjectIdPtr oidp;
- ScorePtr thisScorePtr;
- SeqAlignPtr sap;
- SeqIdPtr sip, gi_list;
- TxDfLineStructPtr txsp;
- Nlm_FloatHi evalue, bit_score;
- Char path[PATH_MAX], hpath[PATH_MAX];
- Char buffer[BUFFER_LENGTH+1];
- Char cDatabase[16];
- Char cCDDid[16];
- Char CDDidx[PATH_MAX];
-
- Nlm_StrCpy(CDDidx,DATApath);
- Nlm_StrCat(CDDidx,"/cdd.idx");
-
-/* if (Nlm_StrCmp(myargs[1].strvalue,"cdd_prop")==0) bDbIsOasis = FALSE; */
-
- sap = prune->sap;
- *bAnyPdb = FALSE;
- while (sap) {
- iCount++;
- aapThis = (AlignmentAbstractPtr)MemNew(sizeof(AlignmentAbstract));
- aapThis->salp = sap; aapThis->pssmid = -1;
- dsp = sap->segs;
- for (i=0;i<dsp->numseg;i++) {
- if (dsp->starts[2*i] > -1) {
- aapThis->mstart = dsp->starts[2*i];
- aapThis->nmissg = (Nlm_FloatHi) dsp->starts[2*i+1];
- fullCDstart = aapThis->mstart - aapThis->nmissg;
- break;
- }
- }
- for (i=0;i<dsp->numseg;i++) {
- if (dsp->starts[2*i] > -1) {
- aapThis->mstop = dsp->starts[2*i]+dsp->lens[i]-1;
- aapThis->cmissg = (Nlm_FloatHi) (dsp->starts[2*i+1]+dsp->lens[i]-1);
- }
- }
- aapThis->gstart = (aapThis->mstart * iGraphWidth) / (query_bsp->length-1);
- aapThis->gstop = (aapThis->mstop * iGraphWidth) / (query_bsp->length-1);
- aapThis->score = sap->score;
- sip = dsp->ids->next;
- thisScorePtr = sap->score;
- found_score = GetScoreAndEvalue(sap, &score, &bit_score, &evalue, &number);
- if (evalue > 100.0 ) iColValue = 204;
- else if (evalue > 1.0 ) iColValue = 153;
- else if (evalue > 0.01 ) iColValue = 102;
- else if (evalue > 0.0001) iColValue = 51;
- else iColValue = 0;
- bsp = BioseqLockById(sip);
- if (!bsp) {
- if (sip->choice == SEQID_GENERAL) {
- dbtp = sip->data.ptrvalue;
- if (Nlm_StrCmp(dbtp->db,"Cdd") == 0) {
- oidp = dbtp->tag;
- CddPssmIdFromAcc(&pssmid, oidp->str, CDDidx);
- oidp = ObjectIdNew();
- oidp->id = pssmid;
- dbtp = DbtagNew();
- dbtp->db = StringSave("CDD");
- dbtp->tag = oidp;
- sip->data.ptrvalue = dbtp;
- bsp = BioseqLockById(sip);
- }
- }
- }
- if (bsp) aapThis->nmissg = aapThis->nmissg/(Nlm_FloatHi)bsp->length;
- else aapThis->nmissg = 0;
- if (bsp) {
- fullCDstop = aapThis->mstop + bsp->length - 1 - aapThis->cmissg;
- aapThis->cmissg = ((Nlm_FloatHi)bsp->length-1.0-aapThis->cmissg)/(Nlm_FloatHi) bsp->length;
- } else aapThis->cmissg = 0;
- txsp = (TxDfLineStructPtr) MemNew(sizeof(TxDfLineStruct));
- txsp->segs_str = NULL;
- txsp->segs_buflen = 0;
- if(bsp != NULL) {
- gi_list = GetUseThisGi(sap);
- if (gi_list) {
- FilterTheDefline(bsp, gi_list, buffer, BUFFER_LENGTH, &(txsp->title));
- gi_list = SeqIdSetFree(gi_list);
- sip = SeqIdFree(sip);
- txsp->id = SeqIdParse(buffer);
- } else {
- SeqIdWrite(bsp->id, buffer, PRINTID_FASTA_LONG, BUFFER_LENGTH);
- txsp->title = StringSave(BioseqGetTitle(bsp));
- txsp->id = sip;
- }
- txsp->is_na = (bsp->mol != Seq_mol_aa);
- } else {
- SeqIdWrite(sip, buffer, PRINTID_FASTA_LONG, BUFFER_LENGTH);
- txsp->title = StringSave("Unknown");
- txsp->is_na = FALSE;
- txsp->id = sip;
- }
- txsp->seqalign = sap;
- txsp->buffer_id = StringSave(buffer);
- txsp->score = score;
- txsp->bit_score = bit_score;
- txsp->evalue = evalue;
- txsp->number = number;
- txsp->found_score = found_score;
- SeqAlignSegsStr(sap, 1, &txsp->segs_str, &txsp->segs_buflen, &txsp->segs_used);
- txsp->isnew = FALSE;
- txsp->waschecked = FALSE;
- if(bsp != NULL) BioseqUnlock(bsp);
- aapThis->defline = txsp;
- aapThis->long_defline = MemNew(sizeof(Char)*(2+strlen(aapThis->defline->title)+strlen(aapThis->defline->buffer_id)));
- StrCpy(aapThis->long_defline, aapThis->defline->buffer_id);
- StrCat(aapThis->long_defline," ");
- StrCat(aapThis->long_defline,aapThis->defline->title);
- cTemp = StringSave(txsp->buffer_id);
- if (strncmp(cTemp,"gnl|",4)==0) {
- strtok(cTemp,"|");
- aapThis->cDatabase = StringSave(strtok(NULL,"|"));
- Nlm_StrCpy(path,strtok(NULL,"|"));
- aapThis->cCDDid = StringSave(strtok(path," "));
- MemFree(cTemp);
- } else WRPSBHtmlError("Could not interpret subject defline!");
- aapThis->bIsProfile = FALSE;
- if (StringICmp(aapThis->cDatabase,"Smart")==0) {
- aapThis->red = 255;
- aapThis->green = aapThis->blue = iColValue;
- if (StrNCmp(aapThis->cCDDid,"smart0",6) == 0) {
- cTemp = StringSave(txsp->title);
- aapThis->cGraphId = StringSave(strtok(cTemp,","));
- MemFree(cTemp);
- } else {
- aapThis->cGraphId = aapThis->cCDDid;
- }
- } else if (StringICmp(aapThis->cDatabase,"Pfam") ==0) {
- aapThis->blue = 255;
- aapThis->red = aapThis->green = iColValue;
- cTemp = StringSave(txsp->title);
- aapThis->cGraphId = StringSave(strtok(cTemp,","));
- MemFree(cTemp);
- } else if (StringICmp(aapThis->cDatabase,"scop1.39") ==0) {
- aapThis->green = 255;
- aapThis->red = aapThis->blue = iColValue;
- aapThis->bIsProfile = TRUE;
- aapThis->cGraphId = aapThis->cCDDid;
- } else if (StringICmp(aapThis->cDatabase,"Load") ==0) {
- aapThis->green = iColValue;
- aapThis->red = aapThis->blue = 255;
- cTemp = StringSave(aapThis->cCDDid);
- if (strstr(cTemp,":")) {
- strtok(cTemp,":");
- aapThis->cGraphId = StringSave(strtok(NULL,":"));
- } else {
- strtok(cTemp,"_");
- aapThis->cGraphId = StringSave(strtok(NULL,"_"));
- }
- MemFree(cTemp);
- } else if (StringCmp(aapThis->cDatabase,"CDD") == 0) {
- aapThis->pssmid = atoi(aapThis->cCDDid);
- cTemp = StringSave(txsp->title);
- aapThis->cCDDid = StringSave(strtok(cTemp,","));
- aapThis->cGraphId = StringSave(strtok(NULL,","));
- if (!aapThis->cGraphId) aapThis->cGraphId = StringSave("obsolete");
- if (Nlm_StrNCmp(aapThis->cGraphId," ",1) == 0) aapThis->cGraphId = aapThis->cGraphId+1;
- CddTruncStringAtFirstPunct(aapThis->cGraphId);
- CddFillBlanksInString(aapThis->cGraphId);
- } else if (StringCmp(aapThis->cDatabase,"Cdd") == 0) {
- cTemp = StringSave(txsp->title);
- if (Nlm_StrStr(cTemp,",") != NULL) {
- if (Nlm_StrStr(cTemp,";") == NULL ||
- Nlm_StrStr(cTemp,",") < Nlm_StrStr(cTemp,";")) {
- aapThis->cGraphId = StringSave(strtok(cTemp,","));
- } else aapThis->cGraphId = StringSave(strtok(cTemp,";"));
- } else aapThis->cGraphId = StringSave(strtok(cTemp,";"));
- } else if (StringCmp(aapThis->cDatabase,"Cog") == 0) {
- cTemp = StringSave(txsp->title);
- if (Nlm_StrStr(cTemp,",") != NULL) {
- if (Nlm_StrStr(cTemp,";") == NULL ||
- Nlm_StrStr(cTemp,",") < Nlm_StrStr(cTemp,";")) {
- aapThis->cGraphId = StringSave(strtok(cTemp,","));
- } else aapThis->cGraphId = StringSave(strtok(cTemp,";"));
- } else aapThis->cGraphId = StringSave(strtok(cTemp,";"));
- } else {
- aapThis->green = iColValue;
- aapThis->red = aapThis->blue = 255;
- aapThis->cGraphId = aapThis->cCDDid;
- }
- aapThis->bIsArch = FALSE;
- aapThis->bIsArchComplete = FALSE;
- if (WRPSBHitIsNew(aapThis,aapHead,Connection)) {
- if (!aapThis->bIsArch) {
- aapThis->colcyc = lastcol + 1;
- if (aapThis->colcyc >= iNcolors) {
- aapThis->colcyc -= iNcolors;
- }
- lastcol = aapThis->colcyc;
- } else {
- aapThis->bIsArchComplete = (aapThis->nmissg + aapThis->cmissg < 0.1);
- }
- }
-
-/*
- if (evalue > 0.01) {
- aapThis->red = iDartCol[aapThis->colcyc+iNcolors][0];
- aapThis->green = iDartCol[aapThis->colcyc+iNcolors][1];
- aapThis->blue = iDartCol[aapThis->colcyc+iNcolors][2];
-
- } else {
- aapThis->red = iDartCol[aapThis->colcyc][0];
- aapThis->green = iDartCol[aapThis->colcyc][1];
- aapThis->blue = iDartCol[aapThis->colcyc][2];
- }
-*/
- if (aapThis->bIsArch) {
- aapThis->colcyc = 255;
- aapThis->red = 200;
- aapThis->green = 200;
- aapThis->blue = 200;
- } else {
- aapThis->red = iDartCol[aapThis->colcyc][0];
- aapThis->green = iDartCol[aapThis->colcyc][1];
- aapThis->blue = iDartCol[aapThis->colcyc][2];
- }
- sprintf(aapThis->name,"ali%d",(Int4)random());
- aapThis->bIsOasis = bDbIsOasis;
- if (bDbIsOasis) {
- Nlm_StrCpy(path,CDDPrefix);
- if (Nlm_StrNCmp(aapThis->cCDDid,"COG",3) == 0 || Nlm_StrNCmp(aapThis->cCDDid,"KOG",3) == 0) {
- strcat(path,CDDefault);
- } else strcat(path,dbversion);
- strcat(path,CDDPost_O);
- Nlm_StrCpy(hpath,OASIScgi);
- } else {
- Nlm_StrCpy(path,CDDPrefix);
- strcat(path,dbversion);
- strcat(path,CDDPost_C);
- Nlm_StrCpy(hpath,CDDcgi);
- }
- strcat(path,"/"); strcat(path,aapThis->cCDDid); strcat(path,TREextens);
- strcat(hpath,aapThis->cCDDid);
- strcat(hpath,"&version=");
- if (Nlm_StrNCmp(aapThis->cCDDid,"COG",3) == 0 || Nlm_StrNCmp(aapThis->cCDDid,"KOG",3) == 0) {
- strcat(hpath,CDDefault);
- } else strcat(hpath,dbversion);
- aapThis->cHtmlLink = StringSave(hpath);
-/*---------------------------------------------------------------------------*/
-/* Open Cdd tree file and add description to aapThis data structure */
-/* changed to binary read to get prepared for the v1.00 rollout. Aron 6/12/00*/
-/*---------------------------------------------------------------------------*/
- pcddt = (CddTreePtr) CddTreeReadFromFile(path,TRUE);
- aapThis->bHasStructure = FALSE;
- if (pcddt) {
- aapThis->description = pcddt->description;
- description = aapThis->description;
- while (description) {
- if (description->choice == CddDescr_comment) {
- cCurrDesc = description->data.ptrvalue;
- if (Nlm_StrCmp(cCurrDesc,"linked to 3D-structure")==0) {
- aapThis->bHasStructure = TRUE;
- *bAnyPdb = TRUE;
- }
- }
- if (description->choice == CddDescr_repeats) {
- pcdr = (CddRepeatPtr) description->data.ptrvalue;
- nindent = pcdr->count - 1;
- if (NULL == pcdr->location) {
- replen = (fullCDstop - fullCDstart + 1) / (nindent+1);
- aapThis->nindents = 0;
- aapThis->indents = MemNew(nindent * sizeof(Int4));
- for (i=0;i<nindent;i++) {
- fullCDstop = ((fullCDstart + (i+1)*replen) * iGraphWidth) / (query_bsp->length - 1);
- if (fullCDstop > aapThis->gstart && fullCDstop < aapThis->gstop) {
- aapThis->indents[aapThis->nindents] = fullCDstop;
- aapThis->nindents++;
- }
- }
- } else {
- WRPSBIndentsViaSeqAlign(pcdr,aapThis,iGraphWidth,query_bsp->length);
- }
- }
- description = description->next;
- }
- }
-/*---------------------------------------------------------------------------*/
-/* get the file name for the FASTA-sequence file which stores the subject.. */
-/*---------------------------------------------------------------------------*/
- aapThis->cSeqFile = MemNew(PATH_MAX*sizeof(Char));
- if (bDbIsOasis) {
- Nlm_StrCpy(aapThis->cSeqFile,CDDPrefix);
- if (Nlm_StrNCmp(aapThis->cCDDid,"COG",3) == 0 || Nlm_StrNCmp(aapThis->cCDDid,"KOG",3) == 0) {
- strcat(aapThis->cSeqFile,CDDefault);
- } else {
- strcat(aapThis->cSeqFile,dbversion);
- }
- strcat(aapThis->cSeqFile,CDDPost_O);
- } else {
- Nlm_StrCpy(aapThis->cSeqFile,CDDPrefix); strcat(aapThis->cSeqFile,dbversion);
- strcat(aapThis->cSeqFile,CDDPost_C);
- }
- strcat(aapThis->cSeqFile,"/"); strcat(aapThis->cSeqFile,aapThis->cCDDid);
- strcat(aapThis->cSeqFile,SEQextens);
-
-/*---------------------------------------------------------------------------*/
-/* Check for overlaps and determine row number */
-/* Check for mutal overlap if condensed graphics is selected */
-/*---------------------------------------------------------------------------*/
- iOvrlap = MemNew(maxrow*sizeof(Int4));
- iMutual = MemNew(maxrow*sizeof(Int4));
- for (i=0;i<maxrow;i++) iOvrlap[i]=0;
- aapThis->row = 1; aapThis->bDrawThisOne = TRUE;
- if (aapHead) {
- aapTmp = aapHead;
- while (aapTmp) {
- if (aapTmp->bDrawThisOne) {
- if (OverlapInterval(aapTmp->mstart,aapTmp->mstop, aapThis->mstart,aapThis->mstop))
- iOvrlap[aapTmp->row-1] = 1;
- if (iGraphMode == 1 || iGraphMode == 3) {
- if (OverlapMutual(aapTmp->mstart,aapTmp->mstop,aapThis->mstart,aapThis->mstop)) {
- iMutual[aapTmp->row-1] = 1;
- if (aapThis->bIsArch) {
- if (aapThis->bIsArchComplete) {
- if (!aapTmp->bIsArch || !aapTmp->bIsArchComplete) iMutual[aapTmp->row-1] = 0;
- }
- } else {
- if (aapTmp->bIsArch) iMutual[aapTmp->row-1] = 0;
- }
- }
- }
- }
- aapTmp = aapTmp->next;
- }
- aapThis->row = 0;
- for (i=0;i<maxrow;i++) {
- if (iOvrlap[i]==0) {
- aapThis->row = i+1;
- break;
- }
- }
- if (iGraphMode == 1 || iGraphMode == 3) for (i=0;i<maxrow;i++) {
- if (iMutual[i]==1) {
- aapThis->bDrawThisOne = FALSE;
- break;
- }
- }
- if (aapThis->row == 0) aapThis->row = maxrow+1;
- }
- MemFree(iMutual);
- MemFree(iOvrlap);
- if (aapThis->row > maxrow) maxrow = aapThis->row;
-
- aapThis->next = NULL;
-
- if (aapHead==NULL) {
- aapHead = aapThis;
- aap = aapHead;
- } else {
- aap->next = aapThis;
- aap = aapThis;
- }
- sap = sap->next;
- }
- *mxr = maxrow;
- return(aapHead);
-}
-
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static Boolean WRPSBPrintDbInformationBasic (CharPtr database, Boolean is_aa, Int4 line_length, CharPtr definition, Int4 number_seqs, Int8 total_length, FILE *outfp, Boolean html)
@@ -1661,169 +1141,6 @@ static Boolean WRPSBPrintDbInformationBasic (CharPtr database, Boolean is_aa, In
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-static void WRPSBCl3SeqAnnot(AlignmentAbstractPtr aapIn, FILE *table,
- Boolean bSeqAlign)
-{
- AsnIoPtr aip;
- AlignmentAbstractPtr aap;
- SeqAnnotPtr sap;
- SeqLocPtr slp;
- SeqFeatPtr sfp, sfpHead = NULL, sfpTail = NULL;
- DenseSegPtr dsp;
- SeqIdPtr sipQuery;
- SeqIntPtr sintp;
- DbtagPtr dbtp;
- ObjectIdPtr oidp;
- Char dupstr[PATH_MAX];
- CharPtr part1, rest, thispart;
- UserObjectPtr uop;
- UserFieldPtr ufp, ufpTail;
- Nlm_FloatHi evalue, bit_score;
- Int4 score, number, i, icnt;
- Boolean found_score;
- AnnotDescPtr adp, adp2;
- DatePtr dp;
- SeqAlignPtr salpTail = NULL, salpHead = NULL;
-
- sap = SeqAnnotNew();
- if (bSeqAlign) {
- sap->type = 2; /* Sequence Alignment */
- } else sap->type = 1; /* feature table */
- adp = (AnnotDescPtr) ValNodeNew(NULL);
- adp->choice = Annot_descr_name;
- adp->data.ptrvalue = StringSave("CDDSearch");
- sap->desc = adp;
- adp2 = (AnnotDescPtr) ValNodeNew(NULL);
- dp = DateCurr();
- adp2->choice = Annot_descr_create_date;
- adp2->data.ptrvalue = dp;
- adp->next = adp2;
- aap = aapIn;
- while (aap) {
- if (aap->bDrawThisOne) {
- sfp = SeqFeatNew();
- if (bSeqAlign) {
- if (!salpHead) {
- salpHead = aap->salp;
- } else salpTail->next = aap->salp;
- salpTail = aap->salp;
- salpTail->next = NULL;
- } else {
- sfp->data.choice = 9;
- strncpy(dupstr,aap->long_defline,PATH_MAX);
- part1 = strtok(dupstr," ");
- if (part1) {
- rest = dupstr + strlen(part1) + 1;
- } else {
- rest = StringSave(aap->long_defline);
- }
- icnt = 0;
- for (i=0;i<Nlm_StrLen(rest);i++) {
- if (rest[i] == ',') icnt++;
- if (icnt > 1) break;
- }
- if (icnt > 1) {
- i = i+2;
- } else i = 0;
- thispart = &rest[i];
- for (i=0;i<Nlm_StrLen(thispart);i++) {
- if (thispart[i] == '.' || thispart[i] == ';') {
- thispart[i] = '\0';
- break;
- }
- }
- sfp->data.value.ptrvalue = StringSave(thispart);
- sfp->comment = StringSave(aap->cGraphId); /* comment is short name */
- if (aap->nmissg >= 0.2 || aap->cmissg >= 0.2) sfp->partial = TRUE;
- dsp = aap->salp->segs;
- sipQuery = dsp->ids;
- slp = (SeqLocPtr) ValNodeNew(NULL); slp->choice = SEQLOC_INT;
- sintp=SeqIntNew(); sintp->from = aap->mstart; sintp->to = aap->mstop;
- sintp->id = SeqIdDup(sipQuery); slp->data.ptrvalue = sintp;
- sfp->location = slp;
- if (sfp->partial) {
- SetSeqLocPartial(sfp->location, aap->nmissg >= 0.2, aap->cmissg >= 0.2);
- }
- uop = UserObjectNew();
- oidp = ObjectIdNew();
- oidp->str = StringSave("cddScoreData");
- uop->type = oidp;
- ufp = UserFieldNew();
- oidp = ObjectIdNew();
- oidp->str = StringSave("definition");
- ufp->label = oidp;
- ufp->choice = 1;
- ufp->data.ptrvalue = StringSave(aap->cCDDid);
- uop->data = ufp;
- ufpTail = ufp;
- ufp = UserFieldNew();
- oidp = ObjectIdNew();
- oidp->str = StringSave("short_name");
- ufp->label = oidp;
- ufp->choice = 1;
- ufp->data.ptrvalue = StringSave(aap->cGraphId);
- ufpTail->next = ufp;
- ufpTail = ufp;
- found_score = GetScoreAndEvalue(aap->salp, &score, &bit_score, &evalue, &number);
- if (found_score) {
- ufp = UserFieldNew();
- oidp = ObjectIdNew();
- oidp->str = StringSave("score");
- ufp->label = oidp;
- ufp->choice = 2;
- ufp->data.intvalue = score;
- ufpTail->next = ufp;
- ufpTail = ufp;
- ufp = UserFieldNew();
- oidp = ObjectIdNew();
- oidp->str = StringSave("evalue");
- ufp->label = oidp;
- ufp->choice = 3;
- ufp->data.realvalue = score;
- ufpTail->next = ufp;
- ufpTail = ufp;
- ufp = UserFieldNew();
- oidp = ObjectIdNew();
- oidp->str = StringSave("bit_score");
- ufp->label = oidp;
- ufp->choice = 3;
- ufp->data.realvalue = bit_score;
- ufpTail->next = ufp;
- ufpTail = ufp;
- }
- sfp->ext = uop;
- dbtp = DbtagNew();
- dbtp->db = StringSave(aap->cDatabase);
- oidp = ObjectIdNew();
- oidp->id = aap->pssmid;
- dbtp->tag = oidp;
- sfp->dbxref = ValNodeNew(NULL);
- sfp->dbxref->data.ptrvalue = dbtp;
- if (!sfpHead) {
- sfpHead = sfp;
- } else {
- sfpTail->next = sfp;
- }
- sfpTail = sfp;
- }
- }
- aap = aap->next;
- }
- if (bSeqAlign) {
- sap->data = salpHead;
- } else sap->data = sfpHead;
- strcpy(OutputName,GetTempName("wrpsbcl3"));
- aip = AsnIoOpen(OutputName, "w");
- SeqAnnotAsnWrite((SeqAnnotPtr) sap, aip, NULL);
- AsnIoClose(aip);
- PrintFile(OutputName);
- RemoveTempFiles();
-}
-
-/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
/* this is the main wrapper routine for formatting html-rps-blast-output */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
@@ -1874,7 +1191,7 @@ static void WRPSBCl3ViewSeqAlign(SeqAlignPtr seqalign, BioseqPtr query_bsp,
#ifdef RESULTS_FILE
Nlm_StrCpy(tableName,(CharPtr) GetTempName("wrpsb"));
if (!(table = FileOpen(tableName,"w"))) {
- WRPSBHtmlError("Temp File Open Failed on Server");
+ WRPSBHtmlError("Temp File Open Failed on Server",bAnnotOnly);
}
#endif
#ifndef RESULTS_FILE
@@ -1935,12 +1252,16 @@ static void WRPSBCl3ViewSeqAlign(SeqAlignPtr seqalign, BioseqPtr query_bsp,
if (prune->number == 0) {
if (iGraphMode && !bAnnotOnly) {
WRPSBCl3PrintGraphics(NULL,table,0,query_bsp,mask, iGraphMode, GraphWidth, bDirect, bIsPrecalc, querygi);
- }
- fprintf(table, "<br><strong>...No hits found!</strong>\n");
+ }
+ if (bAnnotOnly) {
+ WRPSBCl3SeqAnnot(NULL, table, bSeqAlign, FALSE);
+ } else fprintf(table, "<br><strong>...No hits found!</strong>\n");
} else {
- aap = WRPSBCl3AbstractAlignment(prune,query_bsp,GraphWidth-10,&maxrow,iGraphMode,dbversion, &bAnyPdb, Connection);
+ aap = WRPSBCl3AbstractAlignment(prune,query_bsp,GraphWidth-10,&maxrow,iGraphMode,dbversion, &bAnyPdb, Connection, TRUE,
+ CDDefault,DATApath,CDDPrefix,CDDPost_C,CDDPost_O,
+ TREextens,SEQextens,OASIScgi,CDDcgi,NULL,iDartFam,iDartFamNum, bAnnotOnly);
if (bAnnotOnly) {
- WRPSBCl3SeqAnnot(aap, table, bSeqAlign);
+ WRPSBCl3SeqAnnot(aap, table, bSeqAlign, FALSE);
WRPSBSearchFoot(bAnnotOnly, bNoWrap);
}
if (iGraphMode && !bAnnotOnly) {
@@ -2092,7 +1413,7 @@ static AlignmentAbstractPtr WRPSBWWWargs(WWWInfoPtr www_info, Boolean *bIsQueued
if (GetArgc() <2) *bMode = FALSE; else *bMode = TRUE;
} else if (WWWGetMethod(www_info) == WWW_GET) {
if (WWWGetNumEntries(www_info)<1) {
- if (!WRPSBDrawSearchPage()) WRPSBHtmlError("Could not draw initial page...");
+ if (!WRPSBDrawSearchPage()) WRPSBHtmlError("Could not draw initial page...", FALSE);
} else *bMode = TRUE;
} else if (WWWGetMethod(www_info) == WWW_POST) {
*bMode = TRUE;
@@ -2128,26 +1449,26 @@ static AlignmentAbstractPtr WRPSBWWWargs(WWWInfoPtr www_info, Boolean *bIsQueued
*bIsPic = TRUE;
www_arg = WWWGetValueByIndex(www_info, indx);
*GraphWidth = (Int4) atoi(strtok(www_arg,","));
- if (*GraphWidth <= 0 || *GraphWidth > 10000) WRPSBHtmlError("Error in image formatting - invalid Graphics Width!");
+ if (*GraphWidth <= 0 || *GraphWidth > 10000) WRPSBHtmlError("Error in image formatting - invalid Graphics Width!", FALSE);
*qlength = (Int4) atoi(strtok(NULL,","));
- if (*qlength <= 0) WRPSBHtmlError("Error in image formatting - invalid query length!");
+ if (*qlength <= 0) WRPSBHtmlError("Error in image formatting - invalid query length!", FALSE);
nhits = (Int4) atoi(strtok(NULL,","));
- if (nhits < 0) WRPSBHtmlError("Error in image formatting - invalid number of hits");
+ if (nhits < 0) WRPSBHtmlError("Error in image formatting - invalid number of hits", FALSE);
for (i=0;i<nhits;i++) {
aapThis = MemNew(sizeof(AlignmentAbstract));
from = (Int4) atoi(strtok(NULL,","));
- if (from < 0) WRPSBHtmlError("Error in image formatting - invalid interval");
+ if (from < 0) WRPSBHtmlError("Error in image formatting - invalid interval", FALSE);
aapThis->gstart = from;
to = (Int4) atoi(strtok(NULL,",")) + from;
- if (to < 0 || to < from) WRPSBHtmlError("Error in image formatting - invalid interval");
+ if (to < 0 || to < from) WRPSBHtmlError("Error in image formatting - invalid interval", FALSE);
aapThis->gstop = to;
row = (Int4) atoi(strtok(NULL,","));
aapThis->row = row;
- if (row < 0) WRPSBHtmlError("Error in image formatting - invalid row");
+ if (row < 0) WRPSBHtmlError("Error in image formatting - invalid row", FALSE);
name = StringSave(strtok(NULL,","));
aapThis->cGraphId = name;
colcyc = (Int4) atoi(strtok(NULL,","));
- if (colcyc < 0) WRPSBHtmlError("Error in image formatting - invalid color");
+ if (colcyc < 0) WRPSBHtmlError("Error in image formatting - invalid color", FALSE);
aapThis->colcyc = colcyc;
if (colcyc == 255) {
aapThis->bIsArch = TRUE;
@@ -2161,13 +1482,13 @@ static AlignmentAbstractPtr WRPSBWWWargs(WWWInfoPtr www_info, Boolean *bIsQueued
aapThis->bIsArch = FALSE;
}
nmiss = (Int4) atoi(strtok(NULL,","));
- if (nmiss < 0 || nmiss >= 100) WRPSBHtmlError("Error in image formatting - invalid truncation");
+ if (nmiss < 0 || nmiss >= 100) WRPSBHtmlError("Error in image formatting - invalid truncation", FALSE);
aapThis->nmissg = (Nlm_FloatHi) nmiss / 100.0;
cmiss = (Int4) atoi(strtok(NULL,","));
- if (cmiss < 0 || cmiss >= 100) WRPSBHtmlError("Error in image formatting - invalid truncation");
+ if (cmiss < 0 || cmiss >= 100) WRPSBHtmlError("Error in image formatting - invalid truncation", FALSE);
aapThis->cmissg = (Nlm_FloatHi) cmiss / 100.0;
nindent = (Int4) atoi(strtok(NULL,","));
- if (nindent < 0) WRPSBHtmlError("Error in image formatting - invalid indentation");
+ if (nindent < 0) WRPSBHtmlError("Error in image formatting - invalid indentation", FALSE);
aapThis->nindents = nindent;
indents = (Int4Ptr) MemNew(nindent * sizeof(Int4));
for (j=0;j<nindent;j++) {
@@ -2185,7 +1506,7 @@ static AlignmentAbstractPtr WRPSBWWWargs(WWWInfoPtr www_info, Boolean *bIsQueued
}
nhits = (Int4) atoi(strtok(NULL,","));
- if (nhits < 0) WRPSBHtmlError("Error in image formatting - invalid number of biased regions");
+ if (nhits < 0) WRPSBHtmlError("Error in image formatting - invalid number of biased regions", FALSE);
for (i=0;i<nhits;i++) {
sintp = SeqIntNew();
sintp->from = (Int4) atoi(strtok(NULL,","));
@@ -2281,7 +1602,7 @@ static AlignmentAbstractPtr WRPSBWWWargs(WWWInfoPtr www_info, Boolean *bIsQueued
if (Nlm_StrCmp(www_arg,"precalc") == 0) *bIsPrecalc = TRUE;
} else {
*bQueryIsFasta = TRUE;
- myargs[21].intvalue = 0;
+ if (!*bAnnotOnly) myargs[21].intvalue = 0;
}
if (*bIsPrecalc) {
if ((indx = WWWFindName(www_info,"FULL")) >= 0) {
@@ -2296,7 +1617,7 @@ static AlignmentAbstractPtr WRPSBWWWargs(WWWInfoPtr www_info, Boolean *bIsQueued
if ((indx = WWWFindName(www_info,"SEQUENCE")) >= 0) {
*sequence = WWWGetValueByIndex(www_info,indx);
if ((*sequence == NULL || *sequence[0]==NULLB) && *rid == NULL) {
- WRPSBHtmlError("Query SEQUENCE missing from input!");
+ WRPSBHtmlError("Query SEQUENCE missing from input!", *bAnnotOnly);
}
}
return(aapHead);
@@ -2345,13 +1666,15 @@ static Int4 WRPSBGiForAcc(CharPtr accession)
/* return a bioseq using the SEQUENCE field supplied to the cgi-bin. */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
-static BioseqPtr WRPSBGetSequence(CharPtr pcsq, Int4 *gi)
+static BioseqPtr WRPSBGetSequence(CharPtr pcsq, Int4 *gi, Boolean bBelieveQuery,
+ Boolean bAnnotOnly)
{
BioseqPtr bsp;
SeqEntryPtr sep;
SeqIdPtr sip = NULL;
CharPtr chptr, outptr;
CharPtr sequence, accession, tempstr;
+ CharPtr errmsg;
Int4Ptr giptr;
Int4 numgi = 0;
Boolean bIsFasta = FALSE;
@@ -2391,8 +1714,9 @@ static BioseqPtr WRPSBGetSequence(CharPtr pcsq, Int4 *gi)
} */
/*---------------------------------------------------------------------------*/
- if (!pcsq) WRPSBHtmlError("No query sequence - nothing to report!");
- sequence = StringSave(Nlm_StrUpper(pcsq));
+ if (!pcsq) WRPSBHtmlError("No query sequence - nothing to report!", bAnnotOnly);
+ sequence = StringSave(pcsq);
+ sequence = Nlm_StrUpper(sequence);
chptr = sequence;
while (IS_WHITESP(*chptr) && *chptr != NULLB) chptr++;
if (chptr[0] == '>') {
@@ -2431,12 +1755,32 @@ static BioseqPtr WRPSBGetSequence(CharPtr pcsq, Int4 *gi)
}
}
if (bIsFasta) {
- if((sep=FastaToSeqBuffEx(pcsq, &outptr,FALSE,NULL,FALSE))==NULL)
- WRPSBHtmlError("Can not convert FASTA formatted sequence!");
- if(sep->choice != 1) WRPSBHtmlError("Conversion from FASTA failed!");
+ errmsg = MemNew(1024*sizeof(Char));
+ if((sep=FastaToSeqBuffEx(pcsq, &outptr,FALSE,&errmsg,bBelieveQuery))==NULL)
+ WRPSBHtmlError("Can not convert FASTA formatted sequence!", bAnnotOnly);
+ if(sep->choice != 1) WRPSBHtmlError("Conversion from FASTA failed!", bAnnotOnly);
bsp = (BioseqPtr) sep->data.ptrvalue;
+ sip = bsp->id;
+ while (sip) {
+ if (sip->choice == SEQID_GI) {
+ *gi = sip->data.intvalue;
+ bsp->id = sip;
+ break;
+ }
+ sip = sip->next;
+ }
+/*
+ if (bBelieveQuery) {
+ if (*gi > 0) {
+ WRPSBHtmlError("Sequence conversion successful");
+ } else {
+ if (errmsg) WRPSBHtmlError(errmsg);
+ else WRPSBHtmlError(pcsq);
+ }
+ }
+ */
}
- if (!bsp) WRPSBHtmlError("Could not find sequence!");
+ if (!bsp) WRPSBHtmlError("Could not find sequence!", bAnnotOnly);
return(bsp);
/*---------------------------------------------------------------------------*/
@@ -2631,26 +1975,26 @@ Int2 Main (void)
/*---------------------------------------------------------------------------*/
/* Get Default Arguments (but DON'T read from command line) */
/*---------------------------------------------------------------------------*/
- if (!WRPSBGetArgs ("blastcl3", NUMARGS, myargs)) WRPSBHtmlError("Can't read Arguments!");
+ if (!WRPSBGetArgs ("blastcl3", NUMARGS, myargs)) WRPSBHtmlError("Can't read Arguments!", FALSE);
/*---------------------------------------------------------------------------*/
/* retrieve names for directories etc. */
/*---------------------------------------------------------------------------*/
- if (!CddGetParams()) WRPSBHtmlError("Couldn't read from config file...");
+ if (!CddGetParams()) WRPSBHtmlError("Couldn't read from config file...", FALSE);
blast_program = StringSave(myargs[0].strvalue);
/*---------------------------------------------------------------------------*/
/* Begin processing www information block */
/*---------------------------------------------------------------------------*/
if (WWWGetArgs(&www_info) != WWWErrOk) {
- WRPSBHtmlError("Failed to process posting - check your get/post syntax.");
+ WRPSBHtmlError("Failed to process posting - check your get/post syntax.", FALSE);
}
/*---------------------------------------------------------------------------*/
/* set the BLASTDB environment variable */
/*---------------------------------------------------------------------------*/
if (putenv("BLASTDB=/blast/db/blast")) {
- WRPSBHtmlError("Error setting environment variable BLASTDB");
+ WRPSBHtmlError("Error setting environment variable BLASTDB", FALSE);
}
/*---------------------------------------------------------------------------*/
@@ -2682,7 +2026,7 @@ Int2 Main (void)
/*---------------------------------------------------------------------------*/
/* if called without arguments, draw the initial WRPSB page */
/*---------------------------------------------------------------------------*/
- if (!bMode) if (!WRPSBDrawSearchPage()) WRPSBHtmlError("Could not draw initial page...");
+ if (!bMode) if (!WRPSBDrawSearchPage()) WRPSBHtmlError("Could not draw initial page...", bAnnotOnly);
/*---------------------------------------------------------------------------*/
/* start initializing stuff required for database access */
@@ -2697,9 +2041,9 @@ Int2 Main (void)
/*---------------------------------------------------------------------------*/
if (!rid) {
EntrezSetService ("Entrez2");
- if (!PubSeqFetchEnable()) WRPSBHtmlError("Cannot initialize PubSeqFetch!");
+ if (!PubSeqFetchEnable()) WRPSBHtmlError("Cannot initialize PubSeqFetch!", bAnnotOnly);
if(!(rdfp = readdb_new_ex("nr", READDB_DB_IS_PROT, FALSE)))
- WRPSBHtmlError("Readdb init failed");
+ WRPSBHtmlError("Readdb init failed", bAnnotOnly);
}
/*---------------------------------------------------------------------------*/
@@ -2714,7 +2058,7 @@ Int2 Main (void)
}
#else */
if (putenv("NI_SERVICE_NAME_NETBLAST=rpsblast")) {
- WRPSBHtmlError("Error setting environment");
+ WRPSBHtmlError("Error setting environment", bAnnotOnly);
}
/* #endif */
}
@@ -2735,7 +2079,7 @@ Int2 Main (void)
if (myargs[26].intvalue) html = TRUE;
align_view = (Int1) myargs[4].intvalue;
align_type = BlastGetTypes(blast_program, &query_is_na, &db_is_na);
- if(align_type == blast_type_undefined) WRPSBHtmlError("Blast Type not defined!");
+ if(align_type == blast_type_undefined) WRPSBHtmlError("Blast Type not defined!", bAnnotOnly);
if (StringICmp("blastx", blast_program) == 0) {
if (align_view != 0) {
ErrPostEx(SEV_FATAL, 0, 0, "This option is not available with blastx");
@@ -2749,7 +2093,7 @@ Int2 Main (void)
}
options = BLASTOptionNew(blast_program, (Boolean) myargs [16].intvalue);
- if (options == NULL) WRPSBHtmlError("Could not initialize Blast Options!");
+ if (options == NULL) WRPSBHtmlError("Could not initialize Blast Options!", bAnnotOnly);
/*---------------------------------------------------------------------------*/
/* If option RPS Blast set - option "program" is ignored by the engine */
/*---------------------------------------------------------------------------*/
@@ -2758,17 +2102,18 @@ Int2 Main (void)
/*---------------------------------------------------------------------------*/
/* deal with sequence information - unless the query is retrieved from queue */
/*---------------------------------------------------------------------------*/
+ believe_query = FALSE;
+ if (myargs[21].intvalue != 0 || bAnnotOnly) believe_query = TRUE;
if (!rid) {
gi = 0;
- bsp = WRPSBGetSequence(sequence, &gi);
- if (gi) {
+ bsp = WRPSBGetSequence(sequence, &gi, believe_query, bAnnotOnly);
+ if (gi || bAnnotOnly) {
myargs[21].intvalue = 1;
} else {
myargs[21].intvalue = 0;
}
query_bsp = bsp;
}
- believe_query = FALSE; if (myargs[21].intvalue != 0) believe_query = TRUE;
/*---------------------------------------------------------------------------*/
/* Section to get data needed for displaying pre-calculated RPS-Blast alignmt*/
@@ -2777,7 +2122,7 @@ Int2 Main (void)
Connection = WRPSBConnectDart();
Dart_Gi2Seq(Connection,(unsigned)gi,NULL,NULL,NULL,0,NULL,0,NULL,0,
NULL,0,NULL,&sap,NULL);
- if (!sap) WRPSBHtmlError("Could not read precalculated alignment!");
+ if (!sap) WRPSBHtmlError("Could not read precalculated alignment!", bAnnotOnly);
myargs[13].intvalue = myargs[14].intvalue = 250; /* number of hits */
}
@@ -2841,10 +2186,10 @@ Int2 Main (void)
else query_is_na = FALSE;
}
- if (!bsp) WRPSBHtmlError("Query SEQUENCE missing from input!");
+ if (!bsp) WRPSBHtmlError("Query SEQUENCE missing from input!", bAnnotOnly);
if (ISA_na(bsp->mol)) query_is_na = TRUE;
if (query_is_na) {
- WRPSBHtmlError("Can not process nucleotide sequences!");
+ WRPSBHtmlError("Can not process nucleotide sequences!", bAnnotOnly);
}
qlength = query_bsp->length;
@@ -2923,7 +2268,7 @@ Int2 Main (void)
if (!rid && !bIsQueued /* && !bIsPrecalc */) {
if (! BlastInit("blastcl3", &bl3hp, &response)) {
ErrPostEx(SEV_FATAL, 0, 0, "Unable to initialize BLAST service");
- WRPSBHtmlError("Unable to initialize BLAST service!");
+ WRPSBHtmlError("Unable to initialize BLAST service!", bAnnotOnly);
return (1);
}
@@ -2934,11 +2279,11 @@ Int2 Main (void)
} else {
#ifdef CDSEARCH_TEST
if (putenv("NI_SERVICE_NAME_NETBLAST=dart_test")) {
- WRPSBHtmlError("Error setting environment");
+ WRPSBHtmlError("Error setting environment", bAnnotOnly);
}
if (! BlastInit("blastcl3", &bl3hp, &response)) {
ErrPostEx(SEV_FATAL, 0, 0, "Unable to initialize BLAST service");
- WRPSBHtmlError("Unable to initialize BLAST service!");
+ WRPSBHtmlError("Unable to initialize BLAST service!", bAnnotOnly);
return (1);
}
if (response && response->choice == BlastResponse_init) {
@@ -2947,17 +2292,17 @@ Int2 Main (void)
date = blast_version->date;
} else {
ErrPostEx(SEV_FATAL, 0, 0, "Unable to connect to service");
- WRPSBHtmlError("Unable to connect to service!");
+ WRPSBHtmlError("Unable to connect to service!", bAnnotOnly);
return (1);
}
#else
ErrPostEx(SEV_FATAL, 0, 0, "Unable to connect to service");
- WRPSBHtmlError("Unable to connect to service!");
+ WRPSBHtmlError("Unable to connect to service!", bAnnotOnly);
return (1);
#endif
}
if (!BlastNetBioseqFetchEnable(bl3hp, blast_database, db_is_na, TRUE))
- WRPSBHtmlError("Unable to connect to Blast Database!");
+ WRPSBHtmlError("Unable to connect to Blast Database!", bAnnotOnly);
}
retval=0;
@@ -2997,7 +2342,7 @@ Int2 Main (void)
blast_database = NULL; other_returns = NULL; error_returns = NULL;
Qstatus = (Int2) QBlastGetResults(rid,&sap,&query_bsp,&blast_program,&blast_database,&other_returns, &error_returns);
if (Qstatus < 0) {
- WRPSBHtmlError("Error retrieving CD-Search request from BLAST Queue!");
+ WRPSBHtmlError("Error retrieving CD-Search request from BLAST Queue!", bAnnotOnly);
return(1);
}
if (Qstatus > 0) {
@@ -3009,14 +2354,14 @@ Int2 Main (void)
}
ReadDBBioseqFetchEnable ("wrpsb", blast_database, db_is_na, TRUE);
if (!sap) sap = (SeqAnnotPtr) BLASTGetSeqAnnotByRID(rid);
- if (!sap) WRPSBHtmlError("BLAST queue did not return alignment");
+ if (!sap) WRPSBHtmlError("BLAST queue did not return alignment", bAnnotOnly);
if (!query_bsp) {
salp = sap->data;
dsp = salp->segs;
sip = dsp->ids;
query_bsp = BioseqLockById(sip);
}
- if (!query_bsp) WRPSBHtmlError("BLAST queue did not return query sequence");
+ if (!query_bsp) WRPSBHtmlError("BLAST queue did not return query sequence", bAnnotOnly);
else {
sip = query_bsp->id;
if (sip->choice != SEQID_LOCAL) believe_query = TRUE;
@@ -3027,7 +2372,7 @@ Int2 Main (void)
version = BlastGetVersionNumber();
if (!salp) {
if (error_returns) {
- WRPSBHtmlError("No sequence alignment retrieved from BLAST queue!");
+ WRPSBHtmlError("No sequence alignment retrieved from BLAST queue!", bAnnotOnly);
}
}
}
@@ -3039,7 +2384,7 @@ Int2 Main (void)
ErrPostEx(SEV_ERROR, 0, 0, pBEM->msg);
error_returns = error_returns->next;
}
- WRPSBHtmlError(pBEM->msg);
+ WRPSBHtmlError(pBEM->msg, bAnnotOnly);
}
}
@@ -3098,14 +2443,14 @@ Int2 Main (void)
} else {
if (dbname[0] == '\0') { /* worst case - don't know a thing about db */
Nlm_StrCpy(dbname,"cdd");
- Nlm_StrCpy(dbversion,"v1.62");
+ Nlm_StrCpy(dbversion,"v1.63");
}
}
}
if (Nlm_StrCmp(dbname,"unknown")) {
if (! BlastInit("blastcl3", &bl3hp, &response)) {
ErrPostEx(SEV_FATAL, 0, 0, "Unable to initialize BLAST service");
- WRPSBHtmlError("Unable to initialize BLAST service!");
+ WRPSBHtmlError("Unable to initialize BLAST service!", bAnnotOnly);
return (1);
}
BlastNetBioseqFetchEnable(bl3hp, dbname, db_is_na, TRUE);
@@ -3116,7 +2461,7 @@ Int2 Main (void)
if (bIsQueued) {
rid = QBlastSubmitJob(query_bsp,blast_program,blast_database,options);
- if (!rid) WRPSBHtmlError("Error submitting CD-Search job to BLAST queue!");
+ if (!rid) WRPSBHtmlError("Error submitting CD-Search job to BLAST queue!", bAnnotOnly);
QRPSBWait(rid,iGraphMode,iPairMode,iHowLong,options->expect_value,options->hitlist_size);
}
diff --git a/biostruc/cdd/wrpsbtool.c b/biostruc/cdd/wrpsbtool.c
index fbb1f4ee..d2eeaf12 100644
--- a/biostruc/cdd/wrpsbtool.c
+++ b/biostruc/cdd/wrpsbtool.c
@@ -1,4 +1,4 @@
-/* $Id: wrpsbtool.c,v 1.20 2003/10/07 21:16:06 bauer Exp $
+/* $Id: wrpsbtool.c,v 1.21 2003/11/19 14:34:31 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Initial Version Creation Date: 4/19/2000
*
-* $Revision: 1.20 $
+* $Revision: 1.21 $
*
* File Description:
* tools for WWW-RPS BLAST
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: wrpsbtool.c,v $
+* Revision 1.21 2003/11/19 14:34:31 bauer
+* changes to support SeqAnnot export
+*
* Revision 1.20 2003/10/07 21:16:06 bauer
* support generation of Sequence Annotation from CD-Search results
*
@@ -87,7 +90,7 @@
*
* Revision 1.4 2000/08/01 21:23:03 bauer
* added Entrez-Hotlink for Query
-*
+*
* Revision 1.3 2000/07/24 15:43:37 bauer
* fixed problem with pairwise alignment displays involvinb profile-only CDs
*
@@ -104,6 +107,7 @@
#include <blastdef.h>
#include <ddvcreate.h>
#include <wrpsb.h>
+#include "cddutil.h"
#include <wrpsbtool.h>
/*---------------------------------------------------------------------------*/
@@ -276,8 +280,29 @@ void WRPSBSearchFoot(Boolean bAnnotOnly, Boolean bNoWrap)
/* output simple error message as HTML */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
-void WRPSBHtmlError(CharPtr cErrTxt)
+void WRPSBHtmlError(CharPtr cErrTxt, Boolean bAnnotOnly)
{
+ AsnIoPtr aip;
+ SeqAnnotPtr sap;
+ AnnotDescPtr adp;
+
+ if (bAnnotOnly) {
+ WRPSBSearchHead(NULL,NULL,TRUE,TRUE);
+ sap = SeqAnnotNew();
+ sap->type = 1;
+ sap->data = NULL;
+ adp = (AnnotDescPtr) ValNodeNew(NULL);
+ adp->choice = Annot_descr_name;
+ adp->data.ptrvalue = StringSave(cErrTxt);
+ sap->desc = adp;
+ strcpy(OutputName,GetTempName("wrpsbcl3"));
+ aip = AsnIoOpen(OutputName, "w");
+ SeqAnnotAsnWrite((SeqAnnotPtr) sap, aip, NULL);
+ AsnIoClose(aip);
+ PrintFile(OutputName);
+ RemoveTempFiles();
+ exit(1);
+ }
WRPSBSearchHead("CD-Search Error","CD-Search Error Message",FALSE,FALSE);
printf("<BR><h3>%s</h3>\n",cErrTxt);
WRPSBSearchFoot(FALSE, FALSE);
@@ -1435,16 +1460,16 @@ Boolean WRPSBCl3DisplayBlastPairList(AlignmentAbstractPtr aap,
/* need to explicitly get the subject sequence from a FASTA file (versions..)*/
/*---------------------------------------------------------------------------*/
sfp = FileOpen(aap->cSeqFile,"r");
- if (!sfp) WRPSBHtmlError("Could not find subject sequence!");
+ if (!sfp) WRPSBHtmlError("Could not find subject sequence!", FALSE);
sep = FastaToSeqEntry(sfp,FALSE);
FileClose(sfp);
- if (!sep) WRPSBHtmlError("Could not read subject sequence!");
+ if (!sep) WRPSBHtmlError("Could not read subject sequence!", FALSE);
bsp = (BioseqPtr) sep->data.ptrvalue;
/* bsp = BioseqLockById(new_id); */
subject_length = bsp->length;
if (maxsubjaln >= subject_length) {
- WRPSBHtmlError("Error in RPS-Blast alignment!");
+ WRPSBHtmlError("Error in RPS-Blast alignment!", FALSE);
}
aligned_fraction = 1.0 - aap->nmissg - aap->cmissg;
if (aap->nmissg >= 0.2 || aap->cmissg >= 0.2) {
@@ -1524,5 +1549,778 @@ static void borkPutchar( gdIOCtx* ctx, int a )
borkPutbuf(ctx, onechar, 1);
}
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+/* check whether a hit is unique, or to a CD hit somewhere else in the list */
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+static Boolean WRPSBHitIsNew(AlignmentAbstractPtr aapThis,
+ AlignmentAbstractPtr aapHead,
+ Dart_Connect *Connection,
+ Int4 *cDartFam, Int4 cDartFamNum)
+{
+ AlignmentAbstractPtr aap;
+ int Size, i;
+ unsigned Gilist[DARTSIZELIMIT];
+ char Accession[DARTSIZELIMIT][30];
+
+ if (!aapThis) return FALSE;
+ for (i=0;i<cDartFamNum;i++) {
+ if (cDartFam[i] == aapThis->pssmid) {
+ aapThis->bIsArch = TRUE;
+ return(TRUE);
+ }
+ }
+ if (Connection) {
+ if (aapThis->pssmid > 0) {
+ if (Dart_SameSim(Connection,aapThis->pssmid,Gilist,DARTSIZELIMIT,&Size)) {
+ for (i=0;i<Size;i++) {
+ if (!Dart_CDGi2Acc(Connection,Gilist[i],Accession[i],30)) {
+ Accession[i][0] = '\0';
+ }
+ }
+ }
+ } else {
+ if (Dart_Related(Connection,aapThis->cCDDid,Gilist,DARTSIZELIMIT,&Size,NULL)) {
+ for (i=0;i<Size;i++) {
+ if (!Dart_CDGi2Acc(Connection,Gilist[i],Accession[i],30)) {
+ Accession[i][0] = '\0';
+ }
+ }
+ }
+ }
+ } else {
+ Size = 0;
+ }
+
+ aap = aapHead; while (aap) {
+ if (aapThis->pssmid > -1 && aap->pssmid > -1) {
+ if (aapThis->pssmid == aap->pssmid) {
+ aapThis->colcyc = aap->colcyc;
+ return FALSE;
+ }
+ }
+ for (i=0;i<Size;i++) {
+ if (Nlm_StrCmp(Accession[i],aap->cCDDid) == 0) {
+ aapThis->colcyc = aap->colcyc;
+ return FALSE;
+ }
+ }
+ if (Nlm_StrCmp(CDDlocat,"inhouse")==0) { /* map names just for inhouse */
+ if (aapThis->cCDDid && aap->cCDDid) {
+ if (Nlm_StrCmp(aapThis->cCDDid,aap->cCDDid) == 0) {
+ aapThis->colcyc = aap->colcyc;
+ return FALSE;
+ }
+ }
+ if (Nlm_StrICmp(aapThis->cGraphId,aap->cGraphId) == 0) {
+ aapThis->colcyc = aap->colcyc;
+ return FALSE;
+ }
+ }
+ aap = aap->next;
+ }
+ return TRUE;
+}
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+/* define the indents on a block containing repeats according to the alignmt */
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+static void WRPSBIndentsViaSeqAlign(CddRepeatPtr pcdr,
+ AlignmentAbstractPtr aap,
+ Int4 iGraphWidth,
+ Int4 length)
+{
+ SeqLocPtr slp;
+ SeqIntPtr sintp;
+ Int4Ptr istarts;
+ Int4 i = 0, j, s1, s2;
+ CddExpAlignPtr pCDea;
+ DenseSegPtr dsp;
+
+ istarts = MemNew(pcdr->count * sizeof (Int4));
+ slp = (SeqLocPtr) pcdr->location->data.ptrvalue;
+ while (slp) {
+ sintp = (SeqIntPtr) slp->data.ptrvalue;
+ istarts[i] = sintp->from; i++;
+ slp = slp->next;
+ }
+
+ pCDea = CddExpAlignNew();
+ CddExpAlignAlloc(pCDea,length);
+ dsp = aap->salp->segs;
+ for (i=0;i<dsp->numseg;i++) {
+ s1 = dsp->starts[i*2];
+ s2 = dsp->starts[i*2+1];
+ if (s1 >=0 && s2>= 0) {
+ for (j=0;j<dsp->lens[i];j++) {
+ pCDea->adata[s1+j]=s2+j;
+ }
+ }
+ }
+ aap->indents = MemNew(pcdr->count * sizeof (Int4));
+ aap->nindents = 0;
+ for (i=0;i<pcdr->count;i++) {
+ for (j=0;j<length;j++) {
+ if (pCDea->adata[j] >= istarts[i]) {
+ s1 = (j * iGraphWidth) / (length - 1);
+ if (s1 > aap->gstart && s1 < aap->gstop) {
+ aap->indents[aap->nindents] = s1;
+ aap->nindents++;
+ }
+ break;
+ }
+ }
+ }
+ MemFree(istarts);
+}
+
+static CddDescPtr FindDescByPSSMid(CddDescPtr pcdd, Int4 pssmid)
+{
+ CddDescPtr pcddThis;
+ pcddThis = pcdd;
+ while(pcddThis) {
+ if (pcddThis->iPssmId == pssmid) return (pcddThis);
+ pcddThis = pcddThis->next;
+ }
+ return(NULL);
+}
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+/* fill in the Alignment Abstract Data Structure */
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+AlignmentAbstractPtr WRPSBCl3AbstractAlignment(BlastPruneSapStructPtr prune,
+ BioseqPtr query_bsp,
+ Int4 iGraphWidth,
+ Int4 *mxr,
+ Int4 iGraphMode,
+ CharPtr dbversion,
+ Boolean *bAnyPdb,
+ Dart_Connect *Connection,
+ Boolean bFull,
+ CharPtr cCDDefault,
+ CharPtr cDATApath,
+ CharPtr cCDDPrefix,
+ CharPtr cCDDPost_C,
+ CharPtr cCDDPost_O,
+ CharPtr cTREextens,
+ CharPtr cSEQextens,
+ CharPtr cOASIScgi,
+ CharPtr cCDDcgi,
+ CddDescPtr pcdd,
+ Int4 *cDartFam,
+ Int4 cDartFamNum,
+ Boolean bAnnotOnly)
+{
+ Boolean *bConflict;
+ Boolean bDbIsOasis = TRUE, found_score = FALSE;
+ Int4 maxrow = 1, i, pssmid;
+ Int4 lastcol = -1;
+ Int4 iCount = 0, replen;
+ Int4 iColValue, number, score, fullCDstart, fullCDstop, nindent;
+ Int4 *iOvrlap, *iMutual, isize;
+ AlignmentAbstractPtr aap, aapThis, aapTmp, aapHead = NULL;
+ CddDescPtr pcddThis;
+ BioseqPtr bsp;
+ CddTreePtr pcddt;
+ CddDescrPtr description;
+ CddRepeatPtr pcdr;
+ CharPtr cTemp;
+ CharPtr cCurrDesc;
+ DbtagPtr dbtp;
+ DenseSegPtr dsp;
+ ObjectIdPtr oidp;
+ ScorePtr thisScorePtr;
+ SeqAlignPtr sap;
+ SeqIdPtr sip, gi_list;
+ TxDfLineStructPtr txsp;
+ Nlm_FloatHi evalue, bit_score;
+ Char path[PATH_MAX], hpath[PATH_MAX];
+ Char buffer[BUFFER_LENGTH+1];
+ Char cDatabase[16];
+ Char cCDDid[16];
+ Char CDDidx[PATH_MAX];
+
+ if (bFull) {
+ Nlm_StrCpy(CDDidx,cDATApath);
+ Nlm_StrCat(CDDidx,"/cdd.idx");
+ *bAnyPdb = FALSE;
+ }
+/* if (Nlm_StrCmp(myargs[1].strvalue,"cdd_prop")==0) bDbIsOasis = FALSE; */
+
+ sap = prune->sap;
+ while (sap) {
+ iCount++;
+ aapThis = (AlignmentAbstractPtr)MemNew(sizeof(AlignmentAbstract));
+ aapThis->salp = sap; aapThis->pssmid = -1;
+ dsp = sap->segs;
+ for (i=0;i<dsp->numseg;i++) {
+ if (dsp->starts[2*i] > -1) {
+ aapThis->mstart = dsp->starts[2*i];
+ aapThis->nmissg = (Nlm_FloatHi) dsp->starts[2*i+1];
+ fullCDstart = aapThis->mstart - aapThis->nmissg;
+ break;
+ }
+ }
+ for (i=0;i<dsp->numseg;i++) {
+ if (dsp->starts[2*i] > -1) {
+ aapThis->mstop = dsp->starts[2*i]+dsp->lens[i]-1;
+ aapThis->cmissg = (Nlm_FloatHi) (dsp->starts[2*i+1]+dsp->lens[i]-1);
+ }
+ }
+ aapThis->score = sap->score;
+ sip = dsp->ids->next;
+ if (bFull) {
+ aapThis->gstart = (aapThis->mstart * iGraphWidth) / (query_bsp->length-1);
+ aapThis->gstop = (aapThis->mstop * iGraphWidth) / (query_bsp->length-1);
+ }
+ thisScorePtr = sap->score;
+ found_score = GetScoreAndEvalue(sap, &score, &bit_score, &evalue, &number);
+ if (evalue > 100.0 ) iColValue = 204;
+ else if (evalue > 1.0 ) iColValue = 153;
+ else if (evalue > 0.01 ) iColValue = 102;
+ else if (evalue > 0.0001) iColValue = 51;
+ else iColValue = 0;
+ if (bFull) {
+ bsp = BioseqLockById(sip);
+ if (!bsp) {
+ if (sip->choice == SEQID_GENERAL) {
+ dbtp = sip->data.ptrvalue;
+ if (Nlm_StrCmp(dbtp->db,"Cdd") == 0) {
+ oidp = dbtp->tag;
+ CddPssmIdFromAcc(&pssmid, oidp->str, CDDidx);
+ oidp = ObjectIdNew();
+ oidp->id = pssmid;
+ dbtp = DbtagNew();
+ dbtp->db = StringSave("CDD");
+ dbtp->tag = oidp;
+ sip->data.ptrvalue = dbtp;
+ bsp = BioseqLockById(sip);
+ }
+ }
+ }
+ } else bsp = NULL;
+ if (bsp) aapThis->nmissg = aapThis->nmissg/(Nlm_FloatHi)bsp->length;
+ if (bsp) {
+ fullCDstop = aapThis->mstop + bsp->length - 1 - aapThis->cmissg;
+ aapThis->cmissg = ((Nlm_FloatHi)bsp->length-1.0-aapThis->cmissg)/(Nlm_FloatHi) bsp->length;
+ }
+ txsp = (TxDfLineStructPtr) MemNew(sizeof(TxDfLineStruct));
+ txsp->segs_str = NULL;
+ txsp->segs_buflen = 0;
+ if(bsp != NULL) {
+ gi_list = GetUseThisGi(sap);
+ if (gi_list) {
+ FilterTheDefline(bsp, gi_list, buffer, BUFFER_LENGTH, &(txsp->title));
+ gi_list = SeqIdSetFree(gi_list);
+ sip = SeqIdFree(sip);
+ txsp->id = SeqIdParse(buffer);
+ } else {
+ SeqIdWrite(bsp->id, buffer, PRINTID_FASTA_LONG, BUFFER_LENGTH);
+ txsp->title = StringSave(BioseqGetTitle(bsp));
+ txsp->id = sip;
+ }
+ txsp->is_na = (bsp->mol != Seq_mol_aa);
+ } else {
+ SeqIdWrite(sip, buffer, PRINTID_FASTA_LONG, BUFFER_LENGTH);
+ txsp->title = StringSave("Unknown");
+ txsp->is_na = FALSE;
+ txsp->id = sip;
+ }
+ txsp->seqalign = sap;
+ txsp->buffer_id = StringSave(buffer);
+ txsp->score = score;
+ txsp->bit_score = bit_score;
+ txsp->evalue = evalue;
+ txsp->number = number;
+ txsp->found_score = found_score;
+ SeqAlignSegsStr(sap, 1, &txsp->segs_str, &txsp->segs_buflen, &txsp->segs_used);
+ txsp->isnew = FALSE;
+ txsp->waschecked = FALSE;
+ if(NULL != bsp) BioseqUnlock(bsp);
+ aapThis->defline = txsp;
+ isize = 2+strlen(aapThis->defline->title)+strlen(aapThis->defline->buffer_id);
+ if (isize < CDD_MAX_DESCR) isize = CDD_MAX_DESCR;
+ aapThis->long_defline = MemNew(sizeof(Char)*isize);
+ StrCpy(aapThis->long_defline, aapThis->defline->buffer_id);
+ StrCat(aapThis->long_defline," ");
+ cTemp = StringSave(txsp->buffer_id);
+ if (strncmp(cTemp,"gnl|",4)==0) {
+ strtok(cTemp,"|");
+ aapThis->cDatabase = StringSave(strtok(NULL,"|"));
+ Nlm_StrCpy(path,strtok(NULL,"|"));
+ aapThis->cCDDid = StringSave(strtok(path," "));
+ MemFree(cTemp);
+ } else WRPSBHtmlError("Could not interpret subject defline!", bAnnotOnly);
+ if (bFull) {
+ StrCat(aapThis->long_defline,aapThis->defline->title);
+ } else {
+ pcddThis = FindDescByPSSMid(pcdd,atoi(aapThis->cCDDid));
+ if (pcddThis) {
+ StrCat(aapThis->long_defline,pcddThis->cCddId);
+ StrCat(aapThis->long_defline,", ");
+ StrCat(aapThis->long_defline,pcddThis->cSourc);
+ StrCat(aapThis->long_defline,", ");
+ StrCat(aapThis->long_defline,pcddThis->cDescr);
+ aapThis->nmissg = aapThis->nmissg/(Nlm_FloatHi)pcddThis->iPssmLength;
+ fullCDstop = aapThis->mstop + pcddThis->iPssmLength - 1 - aapThis->cmissg;
+ aapThis->cmissg = ((Nlm_FloatHi)pcddThis->iPssmLength-1.0-aapThis->cmissg)/(Nlm_FloatHi)pcddThis->iPssmLength;
+ } else {
+ CddSevError("Failed to retrieve information for a PSSM-Id!");
+ }
+ }
+ aapThis->bIsProfile = FALSE;
+ if (StringICmp(aapThis->cDatabase,"Smart")==0) {
+ aapThis->red = 255;
+ aapThis->green = aapThis->blue = iColValue;
+ if (StrNCmp(aapThis->cCDDid,"smart0",6) == 0) {
+ cTemp = StringSave(txsp->title);
+ aapThis->cGraphId = StringSave(strtok(cTemp,","));
+ MemFree(cTemp);
+ } else {
+ aapThis->cGraphId = aapThis->cCDDid;
+ }
+ } else if (StringICmp(aapThis->cDatabase,"Pfam") ==0) {
+ aapThis->blue = 255;
+ aapThis->red = aapThis->green = iColValue;
+ cTemp = StringSave(txsp->title);
+ aapThis->cGraphId = StringSave(strtok(cTemp,","));
+ MemFree(cTemp);
+ } else if (StringICmp(aapThis->cDatabase,"scop1.39") ==0) {
+ aapThis->green = 255;
+ aapThis->red = aapThis->blue = iColValue;
+ aapThis->bIsProfile = TRUE;
+ aapThis->cGraphId = aapThis->cCDDid;
+ } else if (StringICmp(aapThis->cDatabase,"Load") ==0) {
+ aapThis->green = iColValue;
+ aapThis->red = aapThis->blue = 255;
+ cTemp = StringSave(aapThis->cCDDid);
+ if (strstr(cTemp,":")) {
+ strtok(cTemp,":");
+ aapThis->cGraphId = StringSave(strtok(NULL,":"));
+ } else {
+ strtok(cTemp,"_");
+ aapThis->cGraphId = StringSave(strtok(NULL,"_"));
+ }
+ MemFree(cTemp);
+ } else if (StringCmp(aapThis->cDatabase,"CDD") == 0) {
+ aapThis->pssmid = atoi(aapThis->cCDDid);
+ if (bFull) {
+ cTemp = StringSave(txsp->title);
+ aapThis->cCDDid = StringSave(strtok(cTemp,","));
+ aapThis->cGraphId = StringSave(strtok(NULL,","));
+ if (!aapThis->cGraphId) aapThis->cGraphId = StringSave("obsolete");
+ } else {
+ aapThis->cCDDid = StringSave(pcddThis->cCddId);
+ aapThis->cGraphId = StringSave(pcddThis->cSourc);
+ }
+ if (Nlm_StrNCmp(aapThis->cGraphId," ",1) == 0) aapThis->cGraphId = aapThis->cGraphId+1;
+ CddTruncStringAtFirstPunct(aapThis->cGraphId);
+ CddFillBlanksInString(aapThis->cGraphId);
+ } else if (StringCmp(aapThis->cDatabase,"Cdd") == 0) {
+ cTemp = StringSave(txsp->title);
+ if (Nlm_StrStr(cTemp,",") != NULL) {
+ if (Nlm_StrStr(cTemp,";") == NULL ||
+ Nlm_StrStr(cTemp,",") < Nlm_StrStr(cTemp,";")) {
+ aapThis->cGraphId = StringSave(strtok(cTemp,","));
+ } else aapThis->cGraphId = StringSave(strtok(cTemp,";"));
+ } else aapThis->cGraphId = StringSave(strtok(cTemp,";"));
+ } else if (StringCmp(aapThis->cDatabase,"Cog") == 0) {
+ cTemp = StringSave(txsp->title);
+ if (Nlm_StrStr(cTemp,",") != NULL) {
+ if (Nlm_StrStr(cTemp,";") == NULL ||
+ Nlm_StrStr(cTemp,",") < Nlm_StrStr(cTemp,";")) {
+ aapThis->cGraphId = StringSave(strtok(cTemp,","));
+ } else aapThis->cGraphId = StringSave(strtok(cTemp,";"));
+ } else aapThis->cGraphId = StringSave(strtok(cTemp,";"));
+ } else {
+ aapThis->green = iColValue;
+ aapThis->red = aapThis->blue = 255;
+ aapThis->cGraphId = aapThis->cCDDid;
+ }
+ aapThis->bIsArch = FALSE;
+ aapThis->bIsArchComplete = FALSE;
+ if (!bFull && NULL != cDartFam) {
+ for (i=0;i<cDartFamNum;i++) {
+ if (aapThis->pssmid == cDartFam[i]) {
+ aapThis->bIsArch = TRUE;
+ aapThis->bIsArchComplete = (aapThis->nmissg + aapThis->cmissg < 0.1);
+ break;
+ }
+ }
+ } else {
+ if (WRPSBHitIsNew(aapThis,aapHead,Connection,cDartFam,cDartFamNum)) {
+ if (!aapThis->bIsArch) {
+ aapThis->colcyc = lastcol + 1;
+ if (aapThis->colcyc >= iNcolors) {
+ aapThis->colcyc -= iNcolors;
+ }
+ lastcol = aapThis->colcyc;
+ } else {
+ aapThis->bIsArchComplete = (aapThis->nmissg + aapThis->cmissg < 0.1);
+ }
+ }
+
+/*
+ if (evalue > 0.01) {
+ aapThis->red = iDartCol[aapThis->colcyc+iNcolors][0];
+ aapThis->green = iDartCol[aapThis->colcyc+iNcolors][1];
+ aapThis->blue = iDartCol[aapThis->colcyc+iNcolors][2];
+
+ } else {
+ aapThis->red = iDartCol[aapThis->colcyc][0];
+ aapThis->green = iDartCol[aapThis->colcyc][1];
+ aapThis->blue = iDartCol[aapThis->colcyc][2];
+ }
+*/
+ if (aapThis->bIsArch) {
+ aapThis->colcyc = 255;
+ aapThis->red = 200;
+ aapThis->green = 200;
+ aapThis->blue = 200;
+ } else {
+ aapThis->red = iDartCol[aapThis->colcyc][0];
+ aapThis->green = iDartCol[aapThis->colcyc][1];
+ aapThis->blue = iDartCol[aapThis->colcyc][2];
+ }
+ sprintf(aapThis->name,"ali%d",(Int4)random());
+ aapThis->bIsOasis = bDbIsOasis;
+ if (bDbIsOasis) {
+ Nlm_StrCpy(path,cCDDPrefix);
+ if (Nlm_StrNCmp(aapThis->cCDDid,"COG",3) == 0 || Nlm_StrNCmp(aapThis->cCDDid,"KOG",3) == 0) {
+ strcat(path,cCDDefault);
+ } else strcat(path,dbversion);
+ strcat(path,cCDDPost_O);
+ Nlm_StrCpy(hpath,cOASIScgi);
+ } else {
+ Nlm_StrCpy(path,cCDDPrefix);
+ strcat(path,dbversion);
+ strcat(path,cCDDPost_C);
+ Nlm_StrCpy(hpath,cCDDcgi);
+ }
+ strcat(path,"/"); strcat(path,aapThis->cCDDid); strcat(path,cTREextens);
+ strcat(hpath,aapThis->cCDDid);
+ strcat(hpath,"&version=");
+ if (Nlm_StrNCmp(aapThis->cCDDid,"COG",3) == 0 || Nlm_StrNCmp(aapThis->cCDDid,"KOG",3) == 0) {
+ strcat(hpath,CDDefault);
+ } else strcat(hpath,dbversion);
+ aapThis->cHtmlLink = StringSave(hpath);
+/*---------------------------------------------------------------------------*/
+/* Open Cdd tree file and add description to aapThis data structure */
+/* changed to binary read to get prepared for the v1.00 rollout. Aron 6/12/00*/
+/*---------------------------------------------------------------------------*/
+ pcddt = (CddTreePtr) CddTreeReadFromFile(path,TRUE);
+ aapThis->bHasStructure = FALSE;
+ if (pcddt) {
+ aapThis->description = pcddt->description;
+ description = aapThis->description;
+ while (description) {
+ if (description->choice == CddDescr_comment) {
+ cCurrDesc = description->data.ptrvalue;
+ if (Nlm_StrCmp(cCurrDesc,"linked to 3D-structure")==0) {
+ aapThis->bHasStructure = TRUE;
+ *bAnyPdb = TRUE;
+ }
+ }
+ if (description->choice == CddDescr_repeats) {
+ pcdr = (CddRepeatPtr) description->data.ptrvalue;
+ nindent = pcdr->count - 1;
+ if (NULL == pcdr->location) {
+ replen = (fullCDstop - fullCDstart + 1) / (nindent+1);
+ aapThis->nindents = 0;
+ aapThis->indents = MemNew(nindent * sizeof(Int4));
+ for (i=0;i<nindent;i++) {
+ fullCDstop = ((fullCDstart + (i+1)*replen) * iGraphWidth) / (query_bsp->length - 1);
+ if (fullCDstop > aapThis->gstart && fullCDstop < aapThis->gstop) {
+ aapThis->indents[aapThis->nindents] = fullCDstop;
+ aapThis->nindents++;
+ }
+ }
+ } else {
+ WRPSBIndentsViaSeqAlign(pcdr,aapThis,iGraphWidth,query_bsp->length);
+ }
+ }
+ description = description->next;
+ }
+ }
+/*---------------------------------------------------------------------------*/
+/* get the file name for the FASTA-sequence file which stores the subject.. */
+/*---------------------------------------------------------------------------*/
+ aapThis->cSeqFile = MemNew(PATH_MAX*sizeof(Char));
+ if (bDbIsOasis) {
+ Nlm_StrCpy(aapThis->cSeqFile,cCDDPrefix);
+ if (Nlm_StrNCmp(aapThis->cCDDid,"COG",3) == 0 || Nlm_StrNCmp(aapThis->cCDDid,"KOG",3) == 0) {
+ strcat(aapThis->cSeqFile,cCDDefault);
+ } else {
+ strcat(aapThis->cSeqFile,dbversion);
+ }
+ strcat(aapThis->cSeqFile,cCDDPost_O);
+ } else {
+ Nlm_StrCpy(aapThis->cSeqFile,CDDPrefix); strcat(aapThis->cSeqFile,dbversion);
+ strcat(aapThis->cSeqFile,cCDDPost_C);
+ }
+ strcat(aapThis->cSeqFile,"/"); strcat(aapThis->cSeqFile,aapThis->cCDDid);
+ strcat(aapThis->cSeqFile,cSEQextens);
+ }
+/*---------------------------------------------------------------------------*/
+/* Check for overlaps and determine row number */
+/* Check for mutal overlap if condensed graphics is selected */
+/*---------------------------------------------------------------------------*/
+ iOvrlap = MemNew(maxrow*sizeof(Int4));
+ iMutual = MemNew(maxrow*sizeof(Int4));
+ for (i=0;i<maxrow;i++) iOvrlap[i]=0;
+ aapThis->row = 1; aapThis->bDrawThisOne = TRUE;
+ if (aapHead) {
+ aapTmp = aapHead;
+ while (aapTmp) {
+ if (aapTmp->bDrawThisOne) {
+ if (OverlapInterval(aapTmp->mstart,aapTmp->mstop, aapThis->mstart,aapThis->mstop))
+ iOvrlap[aapTmp->row-1] = 1;
+ if (iGraphMode == 1 || iGraphMode == 3) {
+ if (OverlapMutual(aapTmp->mstart,aapTmp->mstop,aapThis->mstart,aapThis->mstop)) {
+ iMutual[aapTmp->row-1] = 1;
+ if (aapThis->bIsArch) {
+ if (aapThis->bIsArchComplete) {
+ if (!aapTmp->bIsArch || !aapTmp->bIsArchComplete) iMutual[aapTmp->row-1] = 0;
+ }
+ } else {
+ if (aapTmp->bIsArch) iMutual[aapTmp->row-1] = 0;
+ }
+ }
+ }
+ }
+ aapTmp = aapTmp->next;
+ }
+ aapThis->row = 0;
+ for (i=0;i<maxrow;i++) {
+ if (iOvrlap[i]==0) {
+ aapThis->row = i+1;
+ break;
+ }
+ }
+ if (iGraphMode == 1 || iGraphMode == 3) for (i=0;i<maxrow;i++) {
+ if (iMutual[i]==1) {
+ aapThis->bDrawThisOne = FALSE;
+ break;
+ }
+ }
+ if (aapThis->row == 0) aapThis->row = maxrow+1;
+ }
+ MemFree(iMutual);
+ MemFree(iOvrlap);
+ if (aapThis->row > maxrow) maxrow = aapThis->row;
+
+ aapThis->next = NULL;
+
+ if (aapHead==NULL) {
+ aapHead = aapThis;
+ aap = aapHead;
+ } else {
+ aap->next = aapThis;
+ aap = aapThis;
+ }
+/*
+ if (txsp) {
+ txsp->buffer_id = MemFree(txsp->buffer_id);
+ txsp->title = MemFree(txsp->title);
+ txsp->segs_str = MemFree(txsp->segs_str);
+ txsp = MemFree(txsp);
+ }
+*/
+ sap = sap->next;
+ }
+ if (bFull) *mxr = maxrow;
+ return(aapHead);
+}
+
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+SeqAnnotPtr WRPSBCl3SeqAnnot(AlignmentAbstractPtr aapIn, FILE *table,
+ Boolean bSeqAlign, Boolean bRetSeqAnnot)
+{
+ AsnIoPtr aip;
+ AlignmentAbstractPtr aap;
+ SeqAnnotPtr sap;
+ SeqLocPtr slp;
+ SeqFeatPtr sfp, sfpHead = NULL, sfpTail = NULL;
+ DenseSegPtr dsp;
+ SeqIdPtr sipQuery;
+ SeqIntPtr sintp;
+ DbtagPtr dbtp;
+ ObjectIdPtr oidp;
+ Char dupstr[PATH_MAX];
+ CharPtr part1, rest, thispart;
+ UserObjectPtr uop;
+ UserFieldPtr ufp, ufpTail;
+ Nlm_FloatHi evalue, bit_score;
+ Int4 score, number, i, icnt;
+ Boolean found_score;
+ AnnotDescPtr adp, adp2;
+ DatePtr dp;
+ SeqAlignPtr salpTail = NULL, salpHead = NULL;
+
+ sap = SeqAnnotNew();
+ if (bSeqAlign) {
+ sap->type = 2; /* Sequence Alignment */
+ } else sap->type = 1; /* feature table */
+ adp = (AnnotDescPtr) ValNodeNew(NULL);
+ adp->choice = Annot_descr_name;
+ adp->data.ptrvalue = StringSave("CDDSearch");
+ sap->desc = adp;
+ adp2 = (AnnotDescPtr) ValNodeNew(NULL);
+ dp = DateCurr();
+ adp2->choice = Annot_descr_create_date;
+ adp2->data.ptrvalue = dp;
+ adp->next = adp2;
+ aap = aapIn;
+ while (aap) {
+ if (aap->bDrawThisOne) {
+ sfp = SeqFeatNew();
+ if (bSeqAlign) {
+ if (!salpHead) {
+ salpHead = aap->salp;
+ } else salpTail->next = aap->salp;
+ salpTail = aap->salp;
+ salpTail->next = NULL;
+ } else {
+ sfp->data.choice = 9;
+ strncpy(dupstr,aap->long_defline,PATH_MAX);
+ part1 = strtok(dupstr," ");
+ if (part1) {
+ rest = dupstr + strlen(part1) + 1;
+ } else {
+ rest = StringSave(aap->long_defline);
+ }
+ icnt = 0;
+ for (i=0;i<Nlm_StrLen(rest);i++) {
+ if (rest[i] == ',') icnt++;
+ if (icnt > 1) break;
+ }
+ if (icnt > 1) {
+ i = i+2;
+ } else i = 0;
+ thispart = &rest[i];
+ for (i=0;i<Nlm_StrLen(thispart);i++) {
+ if (thispart[i] == '.' || thispart[i] == ';') {
+ thispart[i] = '\0';
+ break;
+ }
+ }
+ sfp->data.value.ptrvalue = StringSave(thispart);
+ sfp->comment = StringSave(aap->cGraphId); /* comment is short name */
+ if (aap->nmissg >= 0.2 || aap->cmissg >= 0.2) sfp->partial = TRUE;
+ dsp = aap->salp->segs;
+ sipQuery = dsp->ids;
+ slp = (SeqLocPtr) ValNodeNew(NULL); slp->choice = SEQLOC_INT;
+ sintp=SeqIntNew(); sintp->from = aap->mstart; sintp->to = aap->mstop;
+ sintp->id = SeqIdDup(sipQuery); slp->data.ptrvalue = sintp;
+ sfp->location = slp;
+ if (sfp->partial) {
+ SetSeqLocPartial(sfp->location, aap->nmissg >= 0.2, aap->cmissg >= 0.2);
+ }
+ uop = UserObjectNew();
+ oidp = ObjectIdNew();
+ oidp->str = StringSave("cddScoreData");
+ uop->type = oidp;
+ ufp = UserFieldNew();
+ oidp = ObjectIdNew();
+ oidp->str = StringSave("definition");
+ ufp->label = oidp;
+ ufp->choice = 1;
+ ufp->data.ptrvalue = StringSave(aap->cCDDid);
+ uop->data = ufp;
+ ufpTail = ufp;
+ ufp = UserFieldNew();
+ oidp = ObjectIdNew();
+ oidp->str = StringSave("short_name");
+ ufp->label = oidp;
+ ufp->choice = 1;
+ ufp->data.ptrvalue = StringSave(aap->cGraphId);
+ ufpTail->next = ufp;
+ ufpTail = ufp;
+ found_score = GetScoreAndEvalue(aap->salp, &score, &bit_score, &evalue, &number);
+ if (found_score) {
+ ufp = UserFieldNew();
+ oidp = ObjectIdNew();
+ oidp->str = StringSave("score");
+ ufp->label = oidp;
+ ufp->choice = 2;
+ ufp->data.intvalue = score;
+ ufpTail->next = ufp;
+ ufpTail = ufp;
+ ufp = UserFieldNew();
+ oidp = ObjectIdNew();
+ oidp->str = StringSave("evalue");
+ ufp->label = oidp;
+ ufp->choice = 3;
+ ufp->data.realvalue = evalue;
+ ufpTail->next = ufp;
+ ufpTail = ufp;
+ ufp = UserFieldNew();
+ oidp = ObjectIdNew();
+ oidp->str = StringSave("bit_score");
+ ufp->label = oidp;
+ ufp->choice = 3;
+ ufp->data.realvalue = bit_score;
+ ufpTail->next = ufp;
+ ufpTail = ufp;
+ }
+ sfp->ext = uop;
+ dbtp = DbtagNew();
+ dbtp->db = StringSave(aap->cDatabase);
+ oidp = ObjectIdNew();
+ oidp->id = aap->pssmid;
+ dbtp->tag = oidp;
+ sfp->dbxref = ValNodeNew(NULL);
+ sfp->dbxref->data.ptrvalue = dbtp;
+ if (!sfpHead) {
+ sfpHead = sfp;
+ } else {
+ sfpTail->next = sfp;
+ }
+ sfpTail = sfp;
+ }
+ }
+ aap = aap->next;
+ }
+ if (bSeqAlign) {
+ sap->data = salpHead;
+ } else sap->data = sfpHead;
+ if (bRetSeqAnnot) return(sap);
+ strcpy(OutputName,GetTempName("wrpsbcl3"));
+ aip = AsnIoOpen(OutputName, "w");
+ SeqAnnotAsnWrite((SeqAnnotPtr) sap, aip, NULL);
+ AsnIoClose(aip);
+ PrintFile(OutputName);
+ RemoveTempFiles();
+ return(NULL);
+}
+
+AlignmentAbstractPtr AlignmentAbstractSetDestruct(AlignmentAbstractPtr aap)
+{
+ AlignmentAbstractPtr aapThis, aapNext, aapHead;
+
+ aapThis = aap; aapHead = aap;
+ while (aapThis) {
+ aapNext = aapThis->next;
+ aapThis->long_defline = MemFree(aapThis->long_defline);
+ aapThis->cCDDid = MemFree(aapThis->cCDDid);
+ aapThis->cGraphId = MemFree(aapThis->cGraphId);
+ aapThis->cDatabase = MemFree(aapThis->cDatabase);
+ if (aapThis->defline) {
+ aapThis->defline->buffer_id = MemFree(aapThis->defline->buffer_id);
+ aapThis->defline->title = MemFree(aapThis->defline->title);
+ aapThis->defline->segs_str = MemFree(aapThis->defline->segs_str);
+ aapThis->defline = MemFree(aapThis->defline);
+ }
+ aapThis = (AlignmentAbstractPtr) MemFree(aapThis);
+ aapThis = aapNext;
+ }
+ return(aapHead);
+}
diff --git a/biostruc/cdd/wrpsbtool.h b/biostruc/cdd/wrpsbtool.h
index 28c39d90..78c6437e 100644
--- a/biostruc/cdd/wrpsbtool.h
+++ b/biostruc/cdd/wrpsbtool.h
@@ -1,4 +1,4 @@
-/* $Id: wrpsbtool.h,v 1.10 2003/10/07 21:16:57 bauer Exp $
+/* $Id: wrpsbtool.h,v 1.11 2003/11/19 14:34:32 bauer Exp $
*===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Initial Version Creation Date: 4/19/2000
*
-* $Revision: 1.10 $
+* $Revision: 1.11 $
*
* File Description:
* header for WWW-RPS BLAST tools
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: wrpsbtool.h,v $
+* Revision 1.11 2003/11/19 14:34:32 bauer
+* changes to support SeqAnnot export
+*
* Revision 1.10 2003/10/07 21:16:57 bauer
* support generation of Sequence Annotation from CD-Search results
*
@@ -94,6 +97,18 @@
#define DDV_COLOR_MAX 33
#include <gd_io.h>
+#include "dart.h"
+
+#define CDD_MAX_DESCR 3072
+
+typedef struct cdddesc {
+ Int4 iPssmId;
+ Char cCddId[PATH_MAX];
+ Char cDescr[CDD_MAX_DESCR];
+ Char cSourc[PATH_MAX];
+ Int4 iPssmLength;
+ struct cdddesc PNTR next;
+} CddDesc, PNTR CddDescPtr;
typedef struct borkIOCtx {
gdIOCtx ctx;
@@ -109,7 +124,7 @@ static void freeBorkCtx(gdIOCtx *ctx);
Boolean OverlapInterval(Int4 from1, Int4 to1, Int4 from2, Int4 to2);
void WRPSBSearchHead(CharPtr title, CharPtr banner, Boolean bAnnotOnly, Boolean bNoWrap);
void WRPSBSearchFoot(Boolean bAnnotOnly, Boolean bNoWrap);
- void WRPSBHtmlError(CharPtr cErrTxt);
+ void WRPSBHtmlError(CharPtr cErrTxt, Boolean bAnnotOnly);
Int4 max(Int4 i1, Int4 i2);
Int4 min(Int4 i1, Int4 i2);
Boolean print_score_eonly(FloatHi evalue, CharPtr buf);
@@ -134,3 +149,38 @@ static void DDV_InitDefSAPdispStyles_BLAST(DDV_Disp_OptPtr
static Boolean DDV_DisplayNewBLAST(SeqAlignPtr sap, ValNodePtr mask,Int4Ptr PNTR matrix,Uint4 disp_format,Pointer disp_data,FILE *fp);
Boolean WRPSBDisplayBlastPairList(AlignmentAbstractPtr aap,ValNodePtr mask, FILE *fp,Boolean is_na, Uint4 tx_option,Uint1 ColorSchema,RPSBlastOptionsPtr rpsbop);
Boolean WRPSBCl3DisplayBlastPairList(AlignmentAbstractPtr aap,ValNodePtr mask, FILE *fp,Boolean is_na, Uint4 tx_option,Uint1 ColorSchema,BioseqPtr query_bsp, CharPtr dbversion, CharPtr urlcgi);
+static Boolean WRPSBHitIsNew(AlignmentAbstractPtr aapThis,
+ AlignmentAbstractPtr aapHead,
+ Dart_Connect *Connection,
+ Int4 *cDartFam,
+ Int4 cDartFamNum);
+static void WRPSBIndentsViaSeqAlign(CddRepeatPtr pcdr,
+ AlignmentAbstractPtr aap,
+ Int4 iGraphWidth,
+ Int4 length);
+ AlignmentAbstractPtr WRPSBCl3AbstractAlignment(BlastPruneSapStructPtr prune,
+ BioseqPtr query_bsp,
+ Int4 iGraphWidth,
+ Int4 *mxr,
+ Int4 iGraphMode,
+ CharPtr dbversion,
+ Boolean *bAnyPdb,
+ Dart_Connect *Connection,
+ Boolean bFull,
+ CharPtr cCDDefault,
+ CharPtr cDATApath,
+ CharPtr cCDDPrefix,
+ CharPtr cCDDPost_C,
+ CharPtr cCDDPost_O,
+ CharPtr cTREextens,
+ CharPtr cSEQextens,
+ CharPtr cOASIScgi,
+ CharPtr cCDDcgi,
+ CddDescPtr pcdd,
+ Int4 *cDartFam,
+ Int4 cDartFamNum,
+ Boolean bAnnotOnly);
+ SeqAnnotPtr WRPSBCl3SeqAnnot(AlignmentAbstractPtr aapIn, FILE *table,
+ Boolean bSeqAlign, Boolean bRetSeqAnnot);
+ AlignmentAbstractPtr AlignmentAbstractSetDestruct(AlignmentAbstractPtr aap);
+
diff --git a/biostruc/mmdbapi1.c b/biostruc/mmdbapi1.c
index 28251534..bd60d93d 100644
--- a/biostruc/mmdbapi1.c
+++ b/biostruc/mmdbapi1.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 03/14/95
*
-* $Revision: 6.43 $
+* $Revision: 6.44 $
*
* File Description:
*
@@ -44,6 +44,9 @@
* 95/08/30 C. Hogue Minor changes.
*
* $Log: mmdbapi1.c,v $
+* Revision 6.44 2003/12/03 02:11:28 kans
+* added defines missing from Mac OS 10.3 headers
+*
* Revision 6.43 2002/05/10 16:33:18 chenj
* fix bugs in fnPBSFtoPSA
*
@@ -289,6 +292,16 @@ NLM_EXTERN void VnpHeapSort PROTO ((ValNodePtr PNTR vnp, int (LIBCALLBACK *compa
#include <matrix.h>
#include "prunebsc.h"
+/* Missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+#ifdef __MWERKS__
+#ifdef OS_UNIX_DARWIN
+#ifndef __SCHAR_MAX__
+#define __SCHAR_MAX__ 127
+#endif
+#endif
+#endif
+/* End missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+
PMBD LIBCALL NewMBD(void)
{
PMBD pmbdNew = NULL;
@@ -2691,7 +2704,7 @@ void LIBCALLBACK DoReverseTransform(PFB pfbThis, Int4 iModel, Int4 iIndex, Point
FloatLoPtr pflvData = NULL;
FloatLoPtrPtr ppflmData = NULL;
FloatLoPtrPtr ppflm = NULL;
- FloatLo flX, flY, flZ;
+ /* FloatLo flX, flY, flZ; */
Int2 i, j;
if (IsAtomNode(pfbThis))
diff --git a/biostruc/mmdbapi2.c b/biostruc/mmdbapi2.c
index e83075b9..8b405510 100644
--- a/biostruc/mmdbapi2.c
+++ b/biostruc/mmdbapi2.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 07/24/95
*
-* $Revision: 6.8 $
+* $Revision: 6.9 $
*
* File Description:
*
@@ -44,6 +44,9 @@
* 95/08/30 C. Hogue Moved globals into mmdbapi2.c.
*
* $Log: mmdbapi2.c,v $
+* Revision 6.9 2003/12/03 02:11:28 kans
+* added defines missing from Mac OS 10.3 headers
+*
* Revision 6.8 2000/08/22 19:47:33 lewisg
* fix GetMMFromMSDBySeqId
*
@@ -159,6 +162,16 @@
#include <mmdbapi2.h>
#include <sequtil.h>
+/* Missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+#ifdef __MWERKS__
+#ifdef OS_UNIX_DARWIN
+#ifndef __SCHAR_MAX__
+#define __SCHAR_MAX__ 127
+#endif
+#endif
+#endif
+/* End missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+
CharPtr NCBIstdaaUC = "-ABCDEFGHIKLMNPQRSTVWXYZU*";
CharPtr NCBI4naUC = "-ACMGRSVTUWYHKDBN";
CharPtr NCBI4naLC = "-acmgrsvtuwyhkdbn";
diff --git a/biostruc/objmmdb3.h b/biostruc/objmmdb3.h
index a986a812..7467fd24 100644
--- a/biostruc/objmmdb3.h
+++ b/biostruc/objmmdb3.h
@@ -627,7 +627,7 @@ NLM_EXTERN RealValuePtr LIBCALL RealValueAsnRead PROTO (( AsnIoPtr, AsnTypePtr))
NLM_EXTERN Boolean LIBCALL RealValueAsnWrite PROTO (( RealValuePtr , AsnIoPtr, AsnTypePtr));
typedef ValNodePtr MovePtr;
-typedef ValNode Move;
+typedef ValNode Move_t;
#define Move_rotate 1
#define Move_translate 2
diff --git a/biostruc/strimprt.h b/biostruc/strimprt.h
index f2996877..bf52646b 100644
--- a/biostruc/strimprt.h
+++ b/biostruc/strimprt.h
@@ -28,7 +28,7 @@
*
* Version Creation Date: Circa 1994
*
-* $Revision: 6.0 $
+* $Revision: 6.1 $
*
* File Description: General Header For Extra MMDB Defines
*
@@ -38,6 +38,9 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: strimprt.h,v $
+* Revision 6.1 2003/12/09 15:55:32 bauer
+* renamed Ascii and Binart to BIOSTRUC_ASCII and BIOSTRUC_BINARY
+*
* Revision 6.0 1997/08/25 18:11:53 madden
* Revision changed to 6.0
*
@@ -74,8 +77,8 @@
#define ResidueGraphPtr_biostruc 2
#define ResidueGraphPtr_standard_graphs 3
-#define Ascii 0
-#define Binary 1
+#define BIOSTRUC_ASCII 0
+#define BIOSTRUC_BINARY 1
#define PDBSECS 0
#define NCBISECS 1
diff --git a/checkout.date b/checkout.date
index 7ead1f7b..4cc36caa 100644
--- a/checkout.date
+++ b/checkout.date
@@ -1 +1 @@
-Wed Oct 29 10:58:05 EST 2003
+Sun Feb 1 10:12:30 EST 2004
diff --git a/connect/ncbi_buffer.c b/connect/ncbi_buffer.c
index 1ef34823..404f97c1 100644
--- a/connect/ncbi_buffer.c
+++ b/connect/ncbi_buffer.c
@@ -1,4 +1,4 @@
-/* $Id: ncbi_buffer.c,v 6.12 2003/05/14 03:49:53 lavr Exp $
+/* $Id: ncbi_buffer.c,v 6.13 2003/12/05 17:31:04 ucko Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -60,6 +60,7 @@ typedef struct SBufChunkTag {
typedef struct BUF_tag {
size_t chunk_size; /* this is actually a chunk size unit */
SBufChunk* list;
+ SBufChunk* last;
} BUF_struct;
@@ -71,7 +72,7 @@ extern size_t BUF_SetChunkSize(BUF* pBuf, size_t chunk_size)
*pBuf = (BUF_struct*) malloc(sizeof(BUF_struct));
if ( !*pBuf )
return 0;
- (*pBuf)->list = 0;
+ (*pBuf)->list = (*pBuf)->last = 0;
}
/* and set the min. mem. chunk size */
@@ -125,8 +126,7 @@ extern int/*bool*/ BUF_Write(BUF* pBuf, const void* data, size_t size)
return 0 /* false */;
/* find the last allocated chunk */
- for (pTail = (*pBuf)->list; pTail && pTail->next; pTail = pTail->next)
- continue;
+ pTail = (*pBuf)->last;
/* write to an unfilled space of the last allocated chunk, if any */
if (pTail && pTail->size != pTail->alloc_size) {
@@ -153,6 +153,7 @@ extern int/*bool*/ BUF_Write(BUF* pBuf, const void* data, size_t size)
pTail->next = pChunk;
else
(*pBuf)->list = pChunk;
+ (*pBuf)->last = pChunk;
}
return 1 /* true */;
}
@@ -178,6 +179,9 @@ extern int/*bool*/ BUF_PushBack(BUF* pBuf, const void* data, size_t size)
pChunk->n_skip = pChunk->size = pChunk->alloc_size;
pChunk->next = (*pBuf)->list;
(*pBuf)->list = pChunk;
+ if ( !(*pBuf)->last ) {
+ (*pBuf)->last = pChunk;
+ }
}
/* write data */
@@ -258,6 +262,9 @@ extern size_t BUF_Read(BUF buf, void* data, size_t size)
size_t n_avail = pHead->size - pHead->n_skip;
if (n_todo >= n_avail) { /* discard the whole chunk */
buf->list = pHead->next;
+ if ( !buf->list ) {
+ buf->last = 0;
+ }
free(pHead);
n_todo -= n_avail;
} else { /* discard some of the chunk data */
@@ -289,6 +296,10 @@ extern void BUF_Destroy(BUF buf)
/*
* ---------------------------------------------------------------------------
* $Log: ncbi_buffer.c,v $
+ * Revision 6.13 2003/12/05 17:31:04 ucko
+ * Add a tail pointer to BUF_struct to avoid having to walk the entire
+ * list in BUF_Write.
+ *
* Revision 6.12 2003/05/14 03:49:53 lavr
* Some indentation; added comment on chunk_size being a chunk size unit
*
diff --git a/connect/ncbi_connutil.c b/connect/ncbi_connutil.c
index 8f4361bb..8e9d7089 100644
--- a/connect/ncbi_connutil.c
+++ b/connect/ncbi_connutil.c
@@ -1,4 +1,4 @@
-/* $Id: ncbi_connutil.c,v 6.60 2003/08/27 16:27:37 lavr Exp $
+/* $Id: ncbi_connutil.c,v 6.63 2004/01/14 18:52:39 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -1264,6 +1264,8 @@ static const char* s_MIME_SubType[eMIME_Unknown+1] = {
"x-www-form",
"html",
"plain",
+ "xml",
+ "xml+soap",
"x-unknown"
};
@@ -1460,22 +1462,24 @@ extern size_t HostPortToString(unsigned int host,
char* buf,
size_t buflen)
{
- char abuf[16/*sizeof("255.255.255.255")*/ + 10/*:port*/];
+ char x_buf[16/*sizeof("255.255.255.255")*/ + 8/*:port*/];
size_t n;
if (!buf || !buflen)
return 0;
if (!host)
- *abuf = 0;
- else if (SOCK_ntoa(host, abuf, sizeof(abuf)) != 0)
+ *x_buf = 0;
+ else if (SOCK_ntoa(host, x_buf, sizeof(x_buf)) != 0) {
+ *buf = 0;
return 0;
+ }
+ n = strlen(x_buf);
if (port || !host)
- sprintf(abuf + strlen(abuf), ":%hu", port);
- n = strlen(abuf);
- assert(n < sizeof(abuf));
+ n += sprintf(x_buf + n, ":%hu", port);
+ assert(n < sizeof(x_buf));
if (n >= buflen)
n = buflen - 1;
- memcpy(buf, abuf, n);
+ memcpy(buf, x_buf, n);
buf[n] = 0;
return n;
}
@@ -1484,6 +1488,15 @@ extern size_t HostPortToString(unsigned int host,
/*
* --------------------------------------------------------------------------
* $Log: ncbi_connutil.c,v $
+ * Revision 6.63 2004/01/14 18:52:39 lavr
+ * Recognize eMIME_XmlSoap and corresponding text representation "xml+soap"
+ *
+ * Revision 6.62 2004/01/07 19:23:29 lavr
+ * "xml" added as a MIME subtype
+ *
+ * Revision 6.61 2003/11/12 17:46:12 lavr
+ * HostPortToString() changed to be a little more efficient
+ *
* Revision 6.60 2003/08/27 16:27:37 lavr
* Add "Host:" tag to be able to take advantage of Apache VHosts
*
diff --git a/connect/ncbi_connutil.h b/connect/ncbi_connutil.h
index 87e6ceea..ad8ae01e 100644
--- a/connect/ncbi_connutil.h
+++ b/connect/ncbi_connutil.h
@@ -1,7 +1,7 @@
#ifndef CONNECT___NCBI_CONNUTIL__H
#define CONNECT___NCBI_CONNUTIL__H
-/* $Id: ncbi_connutil.h,v 6.33 2003/09/23 21:00:33 lavr Exp $
+/* $Id: ncbi_connutil.h,v 6.35 2004/01/14 18:51:41 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -530,6 +530,8 @@ typedef enum {
/* standard MIMEs */
eMIME_Html, /* "html" */
eMIME_Plain, /* "plain" */
+ eMIME_Xml, /* "xml" */
+ eMIME_XmlSoap, /* "xml+soap" */
/* eMIME_???, "<subtype>" here go other NCBI subtypes */
eMIME_Unknown /* "x-unknown" (an arbitrary binary data) */
} EMIME_SubType;
@@ -640,6 +642,12 @@ extern NCBI_XCONNECT_EXPORT size_t HostPortToString
/*
* --------------------------------------------------------------------------
* $Log: ncbi_connutil.h,v $
+ * Revision 6.35 2004/01/14 18:51:41 lavr
+ * +eMIME_XmlSoap
+ *
+ * Revision 6.34 2004/01/07 19:24:40 lavr
+ * Added MIME subtype eMIME_Xml
+ *
* Revision 6.33 2003/09/23 21:00:33 lavr
* Reorder included header files
*
diff --git a/connect/ncbi_http_connector.c b/connect/ncbi_http_connector.c
index 4127bb7d..848d1a06 100644
--- a/connect/ncbi_http_connector.c
+++ b/connect/ncbi_http_connector.c
@@ -1,4 +1,4 @@
-/* $Id: ncbi_http_connector.c,v 6.59 2003/10/29 14:09:08 lavr Exp $
+/* $Id: ncbi_http_connector.c,v 6.62 2003/11/26 12:57:11 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -265,8 +265,12 @@ static EIO_Status s_ConnectAndSend(SHttpConnector* uuu,int/*bool*/ drop_unread)
if (status == eIO_Success) {
assert(uuu->w_len == 0);
if (!uuu->shut_down) {
- /* 10/7/03: While this call here is perfectly legal, it could
- * cause connection severed by a buggy CISCO load-balancer.*/
+ /* 10/07/03: While this call here is perfectly legal, it could
+ * cause connection severed by a buggy CISCO load-balancer. */
+ /* 10/28/03: CISCO's beta patch for their LB shows that the
+ * problem has been fixed; no more 2'30" drops in connections
+ * that shut down for write. We still leave this commented
+ * out to allow unpatched clients work seamlessly... */
/*SOCK_Shutdown(uuu->sock, eIO_Write);*/
uuu->shut_down = 1;
}
@@ -324,7 +328,7 @@ static EIO_Status s_ReadHeader(SHttpConnector* uuu, char** redirect)
}
verify(BUF_Peek(uuu->http, header, size) == size);
header[size] = '\0';
- if (strcmp(&header[size - 4], "\r\n\r\n") == 0)
+ if (size >= 4 && strcmp(&header[size - 4], "\r\n\r\n") == 0)
break/*full header captured*/;
free(header);
@@ -408,7 +412,7 @@ static EIO_Status s_ReadHeader(SHttpConnector* uuu, char** redirect)
free(header);
/* skip & printout the content, if server error was flagged */
- if (server_error && uuu->net_info->debug_printout) {
+ if (uuu->net_info->debug_printout == eDebugPrintout_Some && server_error) {
BUF buf = 0;
char* body;
@@ -972,6 +976,14 @@ extern CONNECTOR HTTP_CreateConnectorEx
/*
* --------------------------------------------------------------------------
* $Log: ncbi_http_connector.c,v $
+ * Revision 6.62 2003/11/26 12:57:11 lavr
+ * s_ReadHeader(): check header size first before looking for end-of-header
+ *
+ * Revision 6.61 2003/11/03 17:37:42 lavr
+ * Fix previous accidental commit and provide corrent change log info:
+ * 1. Added more notes about SOCK_Shutdown() being left commented out;
+ * 2. Do not print HTTP error body if data trace mode set to "DATA".
+ *
* Revision 6.59 2003/10/29 14:09:08 lavr
* Log levels and messages changed in some error reports
*
diff --git a/connect/ncbi_sendmail.c b/connect/ncbi_sendmail.c
index 769a883e..bf3c4bc8 100644
--- a/connect/ncbi_sendmail.c
+++ b/connect/ncbi_sendmail.c
@@ -1,4 +1,4 @@
-/* $Id: ncbi_sendmail.c,v 6.19 2003/04/18 20:59:51 lavr Exp $
+/* $Id: ncbi_sendmail.c,v 6.22 2004/01/07 19:51:36 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -46,7 +46,7 @@
#define NCBI_SENDMAIL_TOOLKIT "C"
#endif
-#define MX_MAGIC_NUMBER 0xBABADEDA
+#define MX_MAGIC_NUMBER 0xBA8ADEDA
#define MX_CRLF "\r\n"
#define SMTP_READERR -1 /* Error reading from socket */
@@ -70,7 +70,7 @@ static int s_SockRead(SOCK sock, char* reply, size_t reply_len)
size_t n = 0;
int code = 0;
- if (!reply || !reply_len)
+ if (!reply || !reply_len)
return 0;
do {
@@ -82,7 +82,7 @@ static int s_SockRead(SOCK sock, char* reply, size_t reply_len)
if (m != 4)
return SMTP_REPLYERR;
- if (buf[3] == '-' || (done = isspace((unsigned char)buf[3]))) {
+ if (buf[3] == '-' || (done = isspace((unsigned char) buf[3]))) {
buf[3] = 0;
if (!code) {
if (!(code = atoi(buf)))
@@ -97,7 +97,7 @@ static int s_SockRead(SOCK sock, char* reply, size_t reply_len)
if (SOCK_Read(sock,buf,1,&m,eIO_ReadPlain) != eIO_Success || !m)
return SMTP_READERR;
- if (buf[0] != '\r' && n < reply_len)
+ if (buf[0] != '\r' && n < reply_len)
reply[n++] = buf[0];
} while (buf[0] != '\n');
@@ -116,9 +116,9 @@ static int s_SockRead(SOCK sock, char* reply, size_t reply_len)
static int/*bool*/ s_SockReadResponse(SOCK sock, int code, int alt_code,
- char* buffer, size_t buffer_len)
+ char* buf, size_t buf_size)
{
- int c = s_SockRead(sock, buffer, buffer_len);
+ int c = s_SockRead(sock, buf, buf_size);
if (c <= 0) {
const char* message = 0;
switch (c) {
@@ -145,8 +145,8 @@ static int/*bool*/ s_SockReadResponse(SOCK sock, int code, int alt_code,
break;
}
assert(message);
- strncpy0(buffer, message, buffer_len - 1);
- } else if (c == code || (alt_code && c == alt_code))
+ strncpy0(buf, message, buf_size - 1);
+ } else if (c == code || (alt_code && c == alt_code))
return 1/*success*/;
return 0/*failure*/;
}
@@ -157,10 +157,11 @@ static int/*bool*/ s_SockWrite(SOCK sock, const char* buf)
size_t len = strlen(buf);
size_t n;
- if (SOCK_Write(sock, buf, len, &n, eIO_WritePersist) != eIO_Success ||
- n != len)
- return 0/*failed*/;
- return 1/*success*/;
+ if (SOCK_Write(sock, buf, len, &n, eIO_WritePersist) == eIO_Success &&
+ n == len) {
+ return 1/*success*/;
+ }
+ return 0/*failure*/;
}
@@ -175,7 +176,7 @@ static char* s_ComposeFrom(char* buf, size_t buf_size)
if (!login_name) {
struct passwd* pwd = getpwuid(getuid());
if (!pwd) {
- if (!(login_name = getenv("USER")) &&
+ if (!(login_name = getenv("USER")) &&
!(login_name = getenv("LOGNAME"))) {
CORE_UNLOCK;
return 0;
@@ -186,6 +187,11 @@ static char* s_ComposeFrom(char* buf, size_t buf_size)
#else
/* Temporary solution for login name */
const char* login_name = "anonymous";
+# ifdef NCBI_OS_MSWIN
+ const char* user_name = getenv("USERNAME");
+ if (user_name)
+ login_name = user_name;
+# endif
#endif
strncpy0(buf, login_name, buf_size - 1);
#ifdef NCBI_OS_UNIX
@@ -204,16 +210,18 @@ static char* s_ComposeFrom(char* buf, size_t buf_size)
SSendMailInfo* SendMailInfo_Init(SSendMailInfo* info)
{
if (info) {
- info->magic_number = MX_MAGIC_NUMBER;
- info->cc = 0;
- info->bcc = 0;
+ info->magic_number = MX_MAGIC_NUMBER;
+ info->cc = 0;
+ info->bcc = 0;
if (!s_ComposeFrom(info->from, sizeof(info->from)))
- info->from[0] = 0;
- info->header = 0;
- info->mx_host = MX_HOST;
- info->mx_port = MX_PORT;
- info->mx_timeout.sec = MX_TIMEOUT;
+ info->from[0] = 0;
+ info->header = 0;
+ info->body_size = 0;
+ info->mx_host = MX_HOST;
+ info->mx_port = MX_PORT;
+ info->mx_timeout.sec = MX_TIMEOUT;
info->mx_timeout.usec = 0;
+ info->mx_no_header = 0/*false*/;
}
return info;
}
@@ -253,6 +261,62 @@ extern const char* CORE_SendMail(const char* to,
return reason; \
} while (0)
+
+static const char* s_SendRcpt(SOCK sock, const char* to,
+ char buf[], size_t buf_size,
+ const char what[],
+ const char write_error[],
+ const char proto_error[])
+{
+ char c;
+ while ((c = *to++) != 0) {
+ char quote = 0;
+ size_t k = 0;
+ if (isspace((unsigned char) c))
+ continue;
+ while (k < buf_size) {
+ if (quote) {
+ if (c == quote)
+ quote = 0;
+ } else if (c == '"' || c == '<' || c == '\'') {
+ quote = c == '<' ? '>' : c;
+ } else if (c == ',')
+ break;
+ buf[k++] = c == '\t' ? ' ' : c;
+ if (!(c = *to++))
+ break;
+ if (isspace((unsigned char) c)) {
+ while (isspace((unsigned char)(*to)))
+ to++;
+ }
+ }
+ if (k >= buf_size)
+ SENDMAIL_RETURN("Recepient address is too long");
+ buf[k] = 0;
+ if (quote) {
+ CORE_LOGF(eLOG_Warning, ("[SendMail] Ubalanced delimiters in "
+ "recepient %s for %s: \"%c\" expected",
+ buf, what, quote));
+ }
+ if (!s_SockWrite(sock, "RCPT TO: <") ||
+ !s_SockWrite(sock, buf) ||
+ !s_SockWrite(sock, ">" MX_CRLF)) {
+ SENDMAIL_RETURN(write_error);
+ }
+ if (!s_SockReadResponse(sock, 250, 251, buf, buf_size))
+ SENDMAIL_RETURN2(proto_error, buf);
+ if (!c)
+ break;
+ }
+ return 0;
+}
+
+
+#define SENDMAIL_SENDRCPT(what, list, buffer) \
+ s_SendRcpt(sock, list, buffer, sizeof(buffer), what, \
+ "Write error in RCPT (" what ") command", \
+ "Protocol error in RCPT (" what ") command")
+
#define SENDMAIL_READ_RESPONSE(code, altcode, buffer) \
s_SockReadResponse(sock, code, altcode, buffer, sizeof(buffer))
@@ -271,15 +335,17 @@ const char* CORE_SendMailEx(const char* to,
if (info->magic_number != MX_MAGIC_NUMBER)
SENDMAIL_RETURN("Invalid magic number");
- if ((!to || !*to) &&
- (!info->cc || !*info->cc) &&
- (!info->bcc || !*info->bcc))
+ if ((!to || !*to) &&
+ (!info->cc || !*info->cc) &&
+ (!info->bcc || !*info->bcc)) {
SENDMAIL_RETURN("At least one message recipient must be specified");
+ }
/* Open connection to sendmail */
if (SOCK_Create(info->mx_host, info->mx_port, &info->mx_timeout, &sock)
- != eIO_Success)
+ != eIO_Success) {
SENDMAIL_RETURN("Cannot connect to sendmail");
+ }
SOCK_SetTimeout(sock, eIO_ReadWrite, &info->mx_timeout);
/* Follow the protocol conversation, RFC821 */
@@ -288,45 +354,38 @@ const char* CORE_SendMailEx(const char* to,
if (SOCK_gethostname(buffer, sizeof(buffer)) != 0)
SENDMAIL_RETURN("Unable to get local host name");
- if (!s_SockWrite(sock, "HELO ") ||
- !s_SockWrite(sock, buffer) ||
- !s_SockWrite(sock, MX_CRLF))
+ if (!s_SockWrite(sock, "HELO ") ||
+ !s_SockWrite(sock, buffer) ||
+ !s_SockWrite(sock, MX_CRLF)) {
SENDMAIL_RETURN("Write error in HELO command");
+ }
if (!SENDMAIL_READ_RESPONSE(250, 0, buffer))
SENDMAIL_RETURN2("Protocol error in HELO command", buffer);
- if (!s_SockWrite(sock, "MAIL FROM: <") ||
- !s_SockWrite(sock, info->from) ||
- !s_SockWrite(sock, ">" MX_CRLF))
+ if (!s_SockWrite(sock, "MAIL FROM: <") ||
+ !s_SockWrite(sock, info->from) ||
+ !s_SockWrite(sock, ">" MX_CRLF)) {
SENDMAIL_RETURN("Write error in MAIL command");
+ }
if (!SENDMAIL_READ_RESPONSE(250, 0, buffer))
SENDMAIL_RETURN2("Protocol error in MAIL command", buffer);
if (to && *to) {
- if (!s_SockWrite(sock, "RCPT TO: <") ||
- !s_SockWrite(sock, to) ||
- !s_SockWrite(sock, ">" MX_CRLF))
- SENDMAIL_RETURN("Write error in RCPT (To) command");
- if (!SENDMAIL_READ_RESPONSE(250, 251, buffer))
- SENDMAIL_RETURN2("Protocol error in RCPT (To) command", buffer);
+ const char* error = SENDMAIL_SENDRCPT("To", to, buffer);
+ if (error)
+ return error;
}
if (info->cc && *info->cc) {
- if (!s_SockWrite(sock, "RCPT TO: <") ||
- !s_SockWrite(sock, info->cc) ||
- !s_SockWrite(sock, ">" MX_CRLF))
- SENDMAIL_RETURN("Write error in RCPT (Cc) command");
- if (!SENDMAIL_READ_RESPONSE(250, 251, buffer))
- SENDMAIL_RETURN2("Protocol error in RCPT (Cc) command", buffer);
+ const char* error = SENDMAIL_SENDRCPT("Cc", info->cc, buffer);
+ if (error)
+ return error;
}
if (info->bcc && *info->bcc) {
- if (!s_SockWrite(sock, "RCPT TO: <") ||
- !s_SockWrite(sock, info->bcc) ||
- !s_SockWrite(sock, ">" MX_CRLF))
- SENDMAIL_RETURN("Write error in RCPT (Bcc) command");
- if (!SENDMAIL_READ_RESPONSE(250, 251, buffer))
- SENDMAIL_RETURN2("Protocol error in RCPT (Bcc) command", buffer);
+ const char* error = SENDMAIL_SENDRCPT("Bcc", info->bcc, buffer);
+ if (error)
+ return error;
}
if (!s_SockWrite(sock, "DATA" MX_CRLF))
@@ -334,37 +393,40 @@ const char* CORE_SendMailEx(const char* to,
if (!SENDMAIL_READ_RESPONSE(354, 0, buffer))
SENDMAIL_RETURN2("Protocol error in DATA command", buffer);
- /* Follow RFC822 to compose message headers. Note that
- * 'Date:'and 'From:' are both added by sendmail automatically.
- */
- if (!s_SockWrite(sock, "Subject: ") ||
- (subject && !s_SockWrite(sock, subject)) ||
- !s_SockWrite(sock, MX_CRLF))
- SENDMAIL_RETURN("Write error in sending subject");
-
- if (to && *to) {
- if (!s_SockWrite(sock, "To: ") ||
- !s_SockWrite(sock, to) ||
+ if (!info->mx_no_header) {
+ /* Follow RFC822 to compose message headers. Note that
+ * 'Date:'and 'From:' are both added by sendmail automatically.
+ */
+ if (!s_SockWrite(sock, "Subject: ") ||
+ (subject && !s_SockWrite(sock, subject)) ||
!s_SockWrite(sock, MX_CRLF))
- SENDMAIL_RETURN("Write error in sending To");
- }
+ SENDMAIL_RETURN("Write error in sending subject");
- if (info->cc && *info->cc) {
- if (!s_SockWrite(sock, "Cc: ") ||
- !s_SockWrite(sock, info->cc) ||
- !s_SockWrite(sock, MX_CRLF))
- SENDMAIL_RETURN("Write error in sending Cc");
- }
+ if (to && *to) {
+ if (!s_SockWrite(sock, "To: ") ||
+ !s_SockWrite(sock, to) ||
+ !s_SockWrite(sock, MX_CRLF))
+ SENDMAIL_RETURN("Write error in sending To");
+ }
+
+ if (info->cc && *info->cc) {
+ if (!s_SockWrite(sock, "Cc: ") ||
+ !s_SockWrite(sock, info->cc) ||
+ !s_SockWrite(sock, MX_CRLF))
+ SENDMAIL_RETURN("Write error in sending Cc");
+ }
+ } else if (subject && *subject)
+ CORE_LOG(eLOG_Warning,"[SendMail] Subject ignored in as-is messages");
if (!s_SockWrite(sock, "X-Mailer: CORE_SendMail (NCBI "
- NCBI_SENDMAIL_TOOLKIT " Toolkit)" MX_CRLF))
+ NCBI_SENDMAIL_TOOLKIT " Toolkit)" MX_CRLF))
SENDMAIL_RETURN("Write error in sending mailer information");
assert(sizeof(buffer) > sizeof(MX_CRLF) && sizeof(MX_CRLF) >= 3);
if (info->header && *info->header) {
- int/*bool*/ newline = 0/*false*/;
size_t n = 0, m = strlen(info->header);
+ int/*bool*/ newline = 0/*false*/;
while (n < m) {
size_t k = 0;
while (k < sizeof(buffer) - sizeof(MX_CRLF)) {
@@ -373,7 +435,8 @@ const char* CORE_SendMailEx(const char* to,
k += sizeof(MX_CRLF) - 1;
newline = 1/*true*/;
} else {
- buffer[k++] = info->header[n];
+ if (info->header[n] != '\r' || !newline)
+ buffer[k++] = info->header[n];
newline = 0/*false*/;
}
if (++n >= m)
@@ -381,17 +444,19 @@ const char* CORE_SendMailEx(const char* to,
}
buffer[k] = 0;
if (!s_SockWrite(sock, buffer))
- SENDMAIL_RETURN("Write error in sending custom header");
+ SENDMAIL_RETURN("Write error while sending custom header");
}
if (!newline && !s_SockWrite(sock, MX_CRLF))
- SENDMAIL_RETURN("Write error in finalizing custom header");
+ SENDMAIL_RETURN("Write error while finalizing custom header");
}
- if (body && *body) {
+ if (body) {
+ size_t n = 0, m = info->body_size ? info->body_size : strlen(body);
int/*bool*/ newline = 0/*false*/;
- size_t n = 0, m = strlen(body);
- if (!s_SockWrite(sock, MX_CRLF))
- SENDMAIL_RETURN("Write error in sending text body delimiter");
+ if (!info->mx_no_header && m) {
+ if (!s_SockWrite(sock, MX_CRLF))
+ SENDMAIL_RETURN("Write error in message body delimiter");
+ }
while (n < m) {
size_t k = 0;
while (k < sizeof(buffer) - sizeof(MX_CRLF)) {
@@ -400,11 +465,13 @@ const char* CORE_SendMailEx(const char* to,
k += sizeof(MX_CRLF) - 1;
newline = 1/*true*/;
} else {
- if (body[n] == '.' && (newline || !n)) {
- buffer[k++] = '.';
- buffer[k++] = '.';
- } else
- buffer[k++] = body[n];
+ if (body[n] != '\r' || !newline) {
+ if (body[n] == '.' && (newline || !n)) {
+ buffer[k++] = '.';
+ buffer[k++] = '.';
+ } else
+ buffer[k++] = body[n];
+ }
newline = 0/*false*/;
}
if (++n >= m)
@@ -412,15 +479,16 @@ const char* CORE_SendMailEx(const char* to,
}
buffer[k] = 0;
if (!s_SockWrite(sock, buffer))
- SENDMAIL_RETURN("Write error in sending text body");
+ SENDMAIL_RETURN("Write error while sending message body");
}
- if ((!newline && !s_SockWrite(sock, MX_CRLF)) ||
- !s_SockWrite(sock, "." MX_CRLF))
- SENDMAIL_RETURN("Write error in finishing text body");
- } else if (!s_SockWrite(sock, MX_CRLF "." MX_CRLF))
- SENDMAIL_RETURN("Write error in finishing message");
+ if ((!newline && m && !s_SockWrite(sock, MX_CRLF))
+ || !s_SockWrite(sock, "." MX_CRLF)) {
+ SENDMAIL_RETURN("Write error while finalizing message body");
+ }
+ } else if (!s_SockWrite(sock, "." MX_CRLF))
+ SENDMAIL_RETURN("Write error while finalizing message");
if (!SENDMAIL_READ_RESPONSE(250, 0, buffer))
- SENDMAIL_RETURN2("Protocol error in sending message body", buffer);
+ SENDMAIL_RETURN2("Protocol error in sending message", buffer);
if (!s_SockWrite(sock, "QUIT" MX_CRLF))
SENDMAIL_RETURN("Write error in QUIT command");
@@ -432,6 +500,7 @@ const char* CORE_SendMailEx(const char* to,
}
#undef SENDMAIL_READ_RESPONSE
+#undef SENDMAIL_SENDRCPT
#undef SENDMAIL_RETURN2
#undef SENDMAIL_RETURN
@@ -439,6 +508,15 @@ const char* CORE_SendMailEx(const char* to,
/*
* ---------------------------------------------------------------------------
* $Log: ncbi_sendmail.c,v $
+ * Revision 6.22 2004/01/07 19:51:36 lavr
+ * Try to obtain user name from USERNAME env.var. on Windows, else fallback
+ *
+ * Revision 6.21 2003/12/09 15:38:39 lavr
+ * Take advantage of SSendMailInfo::body_size; few little makeup changes
+ *
+ * Revision 6.20 2003/12/04 14:55:09 lavr
+ * Extend API with no-header and multiple recipient capabilities
+ *
* Revision 6.19 2003/04/18 20:59:51 lavr
* Mixed up SMTP_BADCODE and SMTP_BADREPLY rearranged in order
*
diff --git a/connect/ncbi_sendmail.h b/connect/ncbi_sendmail.h
index 9d619b02..ef2f3881 100644
--- a/connect/ncbi_sendmail.h
+++ b/connect/ncbi_sendmail.h
@@ -1,7 +1,7 @@
#ifndef CONNECT___NCBI_SENDMAIL__H
#define CONNECT___NCBI_SENDMAIL__H
-/* $Id: ncbi_sendmail.h,v 6.14 2003/09/02 20:45:45 lavr Exp $
+/* $Id: ncbi_sendmail.h,v 6.16 2003/12/09 15:38:02 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -61,9 +61,11 @@ typedef struct {
const char* bcc; /* Blind carbon copy recipient(s) */
char from[1024]; /* Originator address */
const char* header; /* Custom header fields ('\n'-separated) */
+ size_t body_size; /* Message body size (if specified) */
const char* mx_host; /* Host to contact sendmail at */
short mx_port; /* Port to contact sendmail at */
STimeout mx_timeout; /* Timeout for all network transactions */
+ unsigned mx_no_header; /* Boolean whether to complete MX header */
} SSendMailInfo;
@@ -72,6 +74,20 @@ typedef struct {
* can be specified in the form "Name" <address>; recipients should
* be separated by commas. In case of address-only recipients (no "Name"
* part above), angle brackets around the address may be omitted.
+ *
+ * NOTE about message body size:
+ * If not specified (0) and by default the message body size is calculated
+ * as strlen() of passed body argument, which must be NUL-terminated.
+ * Otherwise, exactly "body_size" bytes are read from the location pointed
+ * to by "body" parameter and are sent in the message.
+ *
+ * NOTE about MX header:
+ * message header is automatically prepended to a message that has
+ * "mx_no_header" flag cleared (default). Otherwise, only "header" part
+ * (if any) is sent to the mail exchanger, and the rest of the header and
+ * the message body is passed "as is" following it.
+ * Message header separator and proper message formatting is then
+ * the caller's responsibility.
*/
@@ -95,7 +111,7 @@ extern NCBI_XCONNECT_EXPORT SSendMailInfo* SendMailInfo_Init
/* Send a simple message to recipient(s) defined in 'to',
* and having subject 'subject', which may be empty (both NULL and "" treated
* equally as empty subjects), and message body 'body' (may be NULL/empty,
- * if not empty, lines are separated by '\n').
+ * if not empty, lines are separated by '\n', must be NUL-terminated).
* Return value 0 means success; otherwise descriptive error message
* gets returned. Communicaiton parameters for connection with sendmail
* are set using default values as described in SendMailInfo_Init().
@@ -110,6 +126,8 @@ extern NCBI_XCONNECT_EXPORT const char* CORE_SendMail
* all additional parameters of the message and the communication via
* argument 'info'. In case of 'info' == NULL, the call is completely
* equivalent to CORE_SendMail().
+ * NB: Body is not neccessarily NUL-terminated if "info" contains non-default
+ * (non-zero) message body size (see SSendMailInfo::body_size above).
*/
extern NCBI_XCONNECT_EXPORT const char* CORE_SendMailEx
(const char* to,
@@ -130,6 +148,12 @@ extern NCBI_XCONNECT_EXPORT const char* CORE_SendMailEx
/*
* --------------------------------------------------------------------------
* $Log: ncbi_sendmail.h,v $
+ * Revision 6.16 2003/12/09 15:38:02 lavr
+ * +SSendMailInfo::body_size and remarks about its use
+ *
+ * Revision 6.15 2003/12/04 14:54:39 lavr
+ * Extend API with no-header and multiple recipient capabilities
+ *
* Revision 6.14 2003/09/02 20:45:45 lavr
* -<connect/connect_export.h> -- now included from <connect/ncbi_types.h>
*
diff --git a/connect/ncbi_service.c b/connect/ncbi_service.c
index 0d5eff97..2ef58545 100644
--- a/connect/ncbi_service.c
+++ b/connect/ncbi_service.c
@@ -1,4 +1,4 @@
-/* $Id: ncbi_service.c,v 6.49 2003/09/02 21:17:15 lavr Exp $
+/* $Id: ncbi_service.c,v 6.50 2004/01/30 14:37:26 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -368,31 +368,18 @@ int/*bool*/ SERV_Update(SERV_ITER iter, const char* text)
char* SERV_Print(SERV_ITER iter)
{
+ static const char client_revision[] = "Client-Revision: %hu.%hu\r\n";
static const char accepted_types[] = "Accepted-Server-Types:";
- static const char client_revision[] = "Client-Revision:";
- static const char revision[] = "$Revision: 6.49 $";
char buffer[128], *str;
TSERV_Type type, t;
size_t buflen, i;
BUF buf = 0;
/* Put client version number */
- buflen = sizeof(client_revision) - 1;
- memcpy(buffer, client_revision, buflen);
- for (i = 0; revision[i]; i++)
- if (isspace((unsigned char) revision[i]))
- break;
- while (revision[i] && buflen + 2 < sizeof(buffer)) {
- if (revision[i] == '$') {
- if (isspace((unsigned char) revision[i - 1]))
- --buflen;
- break;
- } else
- buffer[buflen++] = revision[i++];
- }
- strcpy(&buffer[buflen], "\r\n");
- assert(strlen(buffer) == buflen + 2 && buflen + 2 < sizeof(buffer));
- if (!BUF_Write(&buf, buffer, buflen + 2)) {
+ buflen = sprintf(buffer, client_revision,
+ SERV_CLIENT_REVISION_MAJOR, SERV_CLIENT_REVISION_MINOR);
+ assert(buflen < sizeof(buffer));
+ if (!BUF_Write(&buf, buffer, buflen)) {
BUF_Destroy(buf);
return 0;
}
@@ -481,6 +468,9 @@ double SERV_Preference(double pref, double gap, unsigned int n)
/*
* --------------------------------------------------------------------------
* $Log: ncbi_service.c,v $
+ * Revision 6.50 2004/01/30 14:37:26 lavr
+ * Client revision made independent of CVS revisions
+ *
* Revision 6.49 2003/09/02 21:17:15 lavr
* Clean up included headers
*
diff --git a/connect/ncbi_service.h b/connect/ncbi_service.h
index 7af3d3e2..04c4fe36 100644
--- a/connect/ncbi_service.h
+++ b/connect/ncbi_service.h
@@ -1,7 +1,7 @@
#ifndef CONNECT___NCBI_SERVICE__H
#define CONNECT___NCBI_SERVICE__H
-/* $Id: ncbi_service.h,v 6.31 2003/08/11 19:05:54 lavr Exp $
+/* $Id: ncbi_service.h,v 6.32 2004/01/30 14:37:33 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -39,6 +39,11 @@
#include <connect/ncbi_host_info.h>
+/* Revision 6.100 */
+#define SERV_CLIENT_REVISION_MAJOR 6
+#define SERV_CLIENT_REVISION_MINOR 100
+
+
/** @addtogroup ServiceSupport
*
* @{
@@ -194,6 +199,9 @@ extern NCBI_XCONNECT_EXPORT void DISP_SetMessageHook(FDISP_MessageHook);
/*
* --------------------------------------------------------------------------
* $Log: ncbi_service.h,v $
+ * Revision 6.32 2004/01/30 14:37:33 lavr
+ * Client revision made independent of CVS revisions
+ *
* Revision 6.31 2003/08/11 19:05:54 lavr
* +DISP_SetMessageHook()
*
diff --git a/connect/ncbi_socket.c b/connect/ncbi_socket.c
index ff762d0e..b9f3278a 100644
--- a/connect/ncbi_socket.c
+++ b/connect/ncbi_socket.c
@@ -1,4 +1,4 @@
-/* $Id: ncbi_socket.c,v 6.137 2003/10/27 16:45:46 ivanov Exp $
+/* $Id: ncbi_socket.c,v 6.143 2003/11/25 15:08:40 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -33,7 +33,12 @@
*
*/
-#include "ncbi_config.h"
+/* NCBI core headers
+ */
+#include "ncbi_ansi_ext.h"
+#include "ncbi_priv.h"
+/* The next header implicitly includes <connect/ncbi_socket.h> */
+#include <connect/ncbi_connutil.h>
/* OS must be specified in the command-line ("-D....") or in the conf. header
*/
@@ -123,20 +128,10 @@
#endif /* platform-specific headers (for UNIX, MSWIN, MAC) */
-/* NCBI core headers
- */
-#include "ncbi_ansi_ext.h"
-#include "ncbi_priv.h"
-/* The next header implicitly includes <connect/ncbi_socket.h> */
-#include <connect/ncbi_connutil.h>
-
-
/* Portable standard C headers
*/
#include <errno.h>
#include <stdlib.h>
-#include <string.h>
-
@@ -158,6 +153,7 @@ typedef SOCKET TSOCK_Handle;
# define SOCK_ERRNO WSAGetLastError()
# define SOCK_EINTR WSAEINTR
# define SOCK_EWOULDBLOCK WSAEWOULDBLOCK
+# define SOCK_EADDRINUSE WSAEADDRINUSE
# define SOCK_ECONNRESET WSAECONNRESET
# define SOCK_EPIPE WSAESHUTDOWN
# define SOCK_EAGAIN WSAEINPROGRESS
@@ -183,6 +179,7 @@ typedef int TSOCK_Handle;
# define SOCK_ERRNO errno
# define SOCK_EINTR EINTR
# define SOCK_EWOULDBLOCK EWOULDBLOCK
+# define SOCK_EADDRINUSE EADDRINUSE
# define SOCK_ECONNRESET ECONNRESET
# define SOCK_EPIPE EPIPE
# define SOCK_EAGAIN EAGAIN
@@ -230,6 +227,7 @@ typedef int TSOCK_Handle;
# endif /*SOCK_ERRNO*/
# define SOCK_EINTR EINTR
# define SOCK_EWOULDBLOCK EWOULDBLOCK
+# define SOCK_EADDRINUSE EADDRINUSE
# define SOCK_ECONNRESET ECONNRESET
# define SOCK_EPIPE EPIPE
# define SOCK_EAGAIN EAGAIN
@@ -281,8 +279,8 @@ typedef unsigned EBSockType;
#endif
-#define SET_LISTENING(s) ((s)->r_on_w = (unsigned) eDefault + 1)
-#define IS_LISTENING(s) ((s)->r_on_w == (unsigned) eDefault + 1)
+#define SET_LISTENING(s) ((s)->r_on_w = (unsigned) eDefault + 1)
+#define IS_LISTENING(s) ((s)->r_on_w == (unsigned) eDefault + 1)
/* Listening socket
@@ -376,16 +374,16 @@ struct SOCK_tag {
*
* 5. The following table depicts r_status and eof combinations and their
* meanings for stream sockets:
- * -------------------------------+------------------------------------------
+ * -------------------------------+--------------------------------------------
* Field |
* ---------------+---------------+ Meaning
* sock->r_status | sock->eof | (stream sockets only)
- * ---------------+---------------+------------------------------------------
+ * ---------------+---------------+--------------------------------------------
* eIO_Closed | 0 | Socket shut down for reading
* eIO_Closed | 1 | Read severely failed
* not eIO_Closed | 0 | Read completed with r_status error
- * not eIO_Closed | 1 | Read hit EOF and completed with r_status
- * ---------------+---------------+------------------------------------------
+ * not eIO_Closed | 1 | Read hit EOF (and later r_status)
+ * ---------------+---------------+--------------------------------------------
*/
@@ -400,18 +398,21 @@ static int/*bool*/ s_Initialized = 0/*false*/;
static unsigned int s_ID_Counter = 0;
/* Read-while-writing switch */
-static ESwitch s_ReadOnWrite = eOff; /* no read-on-write by default */
+static ESwitch s_ReadOnWrite = eOff; /* no read-on-write by default */
/* Reuse address flag for newly created stream sockets */
-static int/*bool*/ s_ReuseAddress = 0; /* off by default */
+static int/*bool*/ s_ReuseAddress = 0; /* off by default */
/* I/O restart on signals */
-static ESwitch s_InterruptOnSignal = eOff; /* restart I/O by default */
+static ESwitch s_InterruptOnSignal = eOff; /* restart I/O by default */
/* Data/event logging */
-static ESwitch s_Log = eOff; /* no logging by default */
+static ESwitch s_Log = eOff; /* no logging by default */
+
+/* Select restart timeout */
+static const struct timeval* s_SelectTimeout = 0; /* =0 (disabled) by default*/
-/* Flag to indicate whether API should mask SIGPIPE (during initialization) */
+/* Flag to indicate whether API should mask SIGPIPE (during initialization) */
#ifdef NCBI_OS_UNIX
static int/*bool*/ s_AllowSigPipe = 0/*false - mask SIGPIPE out*/;
#endif /*NCBI_OS_UNIX*/
@@ -620,6 +621,7 @@ static void s_DoLog
if (sock->type == eSOCK_Datagram) {
if ( !sa ) {
strcpy(head, "Datagram socket created");
+ *tail = 0;
} else {
const struct sockaddr_in* sin = (const struct sockaddr_in*) sa;
if ( !data ) {
@@ -918,7 +920,7 @@ static struct timeval* s_to2tv(const STimeout* to, struct timeval* tv)
}
-/* Switch the specified socket i/o between blocking and non-blocking mode
+/* Switch the specified socket I/O between blocking and non-blocking mode
*/
static int/*bool*/ s_SetNonblock(TSOCK_Handle sock, int/*bool*/ nonblock)
{
@@ -946,7 +948,7 @@ static int/*bool*/ s_SetReuseAddress(TSOCK_Handle x_sock, int/*bool*/ on_off)
int reuse_addr = on_off ? 1 : 0;
# endif /*NCBI_OS_MSWIN*/
return !setsockopt(x_sock, SOL_SOCKET, SO_REUSEADDR,
- (const char*) &reuse_addr, sizeof(reuse_addr));
+ (char*) &reuse_addr, sizeof(reuse_addr));
#else
return 1;
#endif /*NCBI_OS_UNIX || NCBI_OS_MSWIN*/
@@ -958,11 +960,8 @@ static EIO_Status s_Status(SOCK sock, EIO_Event direction)
assert(sock && sock->sock != SOCK_INVALID);
switch ( direction ) {
case eIO_Read:
- if (sock->type != eSOCK_Datagram) {
- return sock->r_status != eIO_Success
- ? sock->r_status : (sock->eof ? eIO_Closed : eIO_Success);
- }
- return sock->r_status;
+ return sock->type != eSOCK_Datagram && sock->eof
+ ? eIO_Closed : sock->r_status;
case eIO_Write:
return sock->w_status;
default:
@@ -974,6 +973,21 @@ static EIO_Status s_Status(SOCK sock, EIO_Event direction)
}
+/* compare 2 normialized timeval timeouts: "whether v1 is less than v2" */
+static int/*bool*/ s_Less(const struct timeval* v1, const struct timeval* v2)
+{
+ if (!v1)
+ return 0;
+ if (!v2)
+ return !!v1;
+ if (v1->tv_sec > v2->tv_sec)
+ return 0;
+ if (v1->tv_sec < v2->tv_sec)
+ return 1;
+ return v1->tv_usec < v2->tv_usec;
+}
+
+
/* Select on the socket I/O (multiple sockets).
* "Event" field is not considered for entries, whose "sock" field is 0,
* "revent" for those entries is always "eIO_Open". For all other entries
@@ -990,8 +1004,8 @@ static EIO_Status s_Status(SOCK sock, EIO_Event direction)
* marked for upread, then returned "revent" may also include "eIO_Read" to
* indicate that some input is available on that socket.
* If "eIO_Read" event is inquired on an array (n != 1) including stream
- * socket (n != 1) and some sockets still have connection/data pending,
- * those "revent" field may then include "eIO_Write" to indicate that
+ * socket(s) and some sockets still have connection/data pending, those
+ * "revent" field may then include "eIO_Write" to indicate that
* connection can be completed/data sent.
*
* Return eIO_Success when at least one socket is found either ready
@@ -1005,16 +1019,20 @@ static EIO_Status s_Select(size_t n,
SSOCK_Poll polls[],
const struct timeval* tv)
{
- int/*bool*/ write_only = 1;
- int/*bool*/ read_only = 1;
- int/*bool*/ ready = 0;
- int/*bool*/ bad = 0;
- fd_set r_fds, w_fds, e_fds;
- int n_fds;
- size_t i;
+ int/*bool*/ write_only = 1;
+ int/*bool*/ read_only = 1;
+ int/*bool*/ ready = 0;
+ int/*bool*/ bad = 0;
+ fd_set r_fds, w_fds, e_fds;
+ int n_fds;
+ struct timeval x_tv;
+ size_t i;
+
+ if ( tv )
+ x_tv = *tv;
for (;;) { /* (optionally) auto-resume if interrupted by a signal */
- struct timeval x_tv;
+ struct timeval xx_tv;
n_fds = 0;
FD_ZERO(&r_fds);
@@ -1031,7 +1049,8 @@ static EIO_Status s_Select(size_t n,
}
if (polls[i].event &&
(EIO_Event)(polls[i].event | eIO_ReadWrite) == eIO_ReadWrite) {
- if (polls[i].sock->sock != SOCK_INVALID) {
+ TSOCK_Handle fd = polls[i].sock->sock;
+ if (fd != SOCK_INVALID) {
int/*bool*/ ls = IS_LISTENING(polls[i].sock);
if (!ls && n != 1 && polls[i].sock->type == eSOCK_Datagram)
continue;
@@ -1044,7 +1063,7 @@ static EIO_Status s_Select(size_t n,
if (polls[i].sock->type == eSOCK_Datagram ||
polls[i].sock->w_status != eIO_Closed) {
read_only = 0;
- FD_SET(polls[i].sock->sock, &w_fds);
+ FD_SET(fd, &w_fds);
if (polls[i].sock->type == eSOCK_Datagram ||
polls[i].sock->pending)
break;
@@ -1064,7 +1083,7 @@ static EIO_Status s_Select(size_t n,
polls[i].sock->eof))
break;
write_only = 0;
- FD_SET(polls[i].sock->sock, &r_fds);
+ FD_SET(fd, &r_fds);
if (polls[i].sock->type == eSOCK_Datagram ||
polls[i].event != eIO_Read ||
polls[i].sock->w_status == eIO_Closed ||
@@ -1072,16 +1091,16 @@ static EIO_Status s_Select(size_t n,
!polls[i].sock->w_len))
break;
read_only = 0;
- FD_SET(polls[i].sock->sock, &w_fds);
+ FD_SET(fd, &w_fds);
break;
default:
/* should never get here */
assert(0);
break;
}
- FD_SET(polls[i].sock->sock, &e_fds);
- if (n_fds < (int) polls[i].sock->sock)
- n_fds = (int) polls[i].sock->sock;
+ FD_SET(fd, &e_fds);
+ if (n_fds < (int) fd)
+ n_fds = (int) fd;
} else {
polls[i].revent = eIO_Close;
ready = 1;
@@ -1098,16 +1117,28 @@ static EIO_Status s_Select(size_t n,
if ( ready )
return eIO_Success;
- if ( tv )
- x_tv = *tv;
+ if (!tv || s_Less(s_SelectTimeout, &x_tv)) {
+ if ( s_SelectTimeout ) {
+ xx_tv = *s_SelectTimeout;
+ }
+ } else
+ xx_tv = x_tv;
n_fds = select(SOCK_NFDS((TSOCK_Handle) n_fds),
write_only ? 0 : &r_fds, read_only ? 0 : &w_fds,
- &e_fds, tv ? &x_tv : 0);
+ &e_fds, tv || s_SelectTimeout ? &xx_tv : 0);
/* timeout has expired */
- if (n_fds == 0)
+ if (n_fds == 0) {
+ if ( !tv )
+ continue;
+ if ( s_Less(s_SelectTimeout, &x_tv) ) {
+ x_tv.tv_sec -= s_SelectTimeout->tv_sec;
+ x_tv.tv_usec -= s_SelectTimeout->tv_usec;
+ continue;
+ }
return eIO_Timeout;
+ }
if (n_fds > 0)
break;
@@ -1133,18 +1164,22 @@ static EIO_Status s_Select(size_t n,
n_fds = 0;
for (i = 0; i < n; i++) {
if ( polls[i].sock ) {
+ TSOCK_Handle fd = polls[i].sock->sock;
assert(polls[i].revent == eIO_Open);
- if ( FD_ISSET(polls[i].sock->sock, &r_fds) )
- polls[i].revent = eIO_Read;
- if ( FD_ISSET(polls[i].sock->sock, &w_fds) )
- polls[i].revent = (EIO_Event)(polls[i].revent | eIO_Write);
- if (!polls[i].revent && FD_ISSET(polls[i].sock->sock, &e_fds))
+ if (fd != SOCK_INVALID) {
+ if ( FD_ISSET(fd, &r_fds) )
+ polls[i].revent = eIO_Read;
+ if ( FD_ISSET(fd, &w_fds) )
+ polls[i].revent = (EIO_Event)(polls[i].revent | eIO_Write);
+ if (!polls[i].revent && FD_ISSET(fd, &e_fds))
+ polls[i].revent = eIO_Close;
+ } else
polls[i].revent = eIO_Close;
if (polls[i].revent != eIO_Open)
n_fds++;
}
}
- assert(n_fds);
+ assert(n_fds != 0);
/* success; can do I/O now */
return eIO_Success;
@@ -1153,6 +1188,21 @@ static EIO_Status s_Select(size_t n,
/******************************************************************************
+ * UTILITY
+ */
+
+extern const STimeout* SOCK_SetSelectInternalRestartTimeout(const STimeout* t)
+{
+ static struct timeval s_NewTmo;
+ static STimeout s_OldTmo;
+ const STimeout* retval = s_tv2to(s_SelectTimeout, &s_OldTmo);
+ s_SelectTimeout = s_to2tv(t, &s_NewTmo);
+ return retval;
+}
+
+
+
+/******************************************************************************
* LISTENING SOCKET
*/
@@ -1217,7 +1267,7 @@ extern EIO_Status LSOCK_CreateEx(unsigned short port,
("LSOCK#%u[%u]: [LSOCK::Create] Failed bind()",
x_id, (unsigned int) x_lsock));
SOCK_CLOSE(x_lsock);
- return eIO_Unknown;
+ return x_errno == SOCK_EADDRINUSE ? eIO_Closed : eIO_Unknown;
}
/* listen */
@@ -1278,7 +1328,6 @@ extern EIO_Status LSOCK_Accept(LSOCK lsock,
SSOCK_Poll poll;
struct timeval tv;
- assert(IS_LISTENING(lsock));
poll.sock = (SOCK) lsock;
poll.event = eIO_Read;
poll.revent = eIO_Open;
@@ -1420,7 +1469,7 @@ extern EIO_Status LSOCK_GetOSHandle(LSOCK lsock,
}
memcpy(handle, &lsock->sock, handle_size);
- return eIO_Success;
+ return lsock->sock == SOCK_INVALID ? eIO_Closed : eIO_Success;
}
@@ -1531,7 +1580,7 @@ static EIO_Status s_Connect(SOCK sock,
}
sock->sock = x_sock;
- /* set the socket i/o to non-blocking mode */
+ /* set the socket I/O to non-blocking mode */
if ( !s_SetNonblock(x_sock, 1/*true*/) ) {
CORE_LOGF(eLOG_Error, ("%s[SOCK::s_Connect] "
" Cannot set socket to non-blocking mode",
@@ -1610,11 +1659,9 @@ static EIO_Status s_Connect(SOCK sock,
sock->pending = 0/*connected*/;
/* success: do not change any timeouts */
- sock->host = x_host;
- sock->port = x_port;
- sock->n_read = 0;
- sock->n_written = 0;
- sock->w_len = BUF_Size(sock->w_buf);
+ sock->host = x_host;
+ sock->port = x_port;
+ sock->w_len = BUF_Size(sock->w_buf);
return eIO_Success;
}
@@ -1636,7 +1683,7 @@ static int s_Recv(SOCK sock,
assert(sock->type != eSOCK_Datagram && !sock->pending);
if ( !size ) {
/* internal upread use only */
- assert(peek && !buffer && sock->r_status != eIO_Closed);
+ assert(sock->r_status != eIO_Closed && !sock->eof && peek && !buffer);
n_read = 0;
} else {
/* read (or peek) from the internal buffer */
@@ -1686,7 +1733,10 @@ static int s_Recv(SOCK sock,
if (x_read <= 0) {
/* catch EOF/failure */
sock->eof = 1/*true*/;
- sock->r_status = x_read == 0 ? eIO_Success : eIO_Closed;
+ if (x_read == 0)
+ sock->r_status = eIO_Success;
+ else
+ sock->r_status = sock->w_status = eIO_Closed;
break;
}
} else {
@@ -1761,7 +1811,7 @@ static EIO_Status s_SelectStallsafe(size_t n,
if (polls[i].revent & polls[i].event)
break;
if (polls[i].revent != eIO_Open && !pending) {
- pending++;
+ pending = 1;
j = i;
}
}
@@ -1923,6 +1973,8 @@ static EIO_Status s_Send(SOCK sock,
break;
}
sock->w_status = eIO_Closed;
+ if (x_errno != SOCK_EPIPE)
+ sock->r_status = eIO_Closed;
if (sock->log == eOn || (sock->log == eDefault && s_Log == eOn))
s_DoLog(sock, eIO_Write, 0, 0, 0);
break;
@@ -2004,8 +2056,8 @@ static EIO_Status s_WritePending(SOCK sock,
addr, sizeof(addr));
CORE_LOGF_ERRNO_EX(eLOG_Error, x_errno, SOCK_STRERROR(x_errno),
("%s[SOCK::s_WritePending] Failed pending "
- "connect() to %s (%s)", s_ID(sock, _id),
- addr, IO_StatusStr(status)));
+ "connect() to %s", s_ID(sock, _id), addr));
+ sock->w_status = status;
}
return status;
}
@@ -2048,20 +2100,17 @@ static EIO_Status s_Read(SOCK sock,
*n_read = 0;
- if (size == 0)
- return s_Status(sock, eIO_Read);
-
if (sock->type == eSOCK_Datagram) {
*n_read = peek ?
BUF_Peek(sock->r_buf, buf, size) :
BUF_Read(sock->r_buf, buf, size);
- sock->r_status = *n_read ? eIO_Success : eIO_Closed;
+ sock->r_status = *n_read || !size ? eIO_Success : eIO_Closed;
return sock->r_status;
}
status = s_WritePending(sock, sock->r_timeout, 0);
- if ( sock->pending )
- return status;
+ if (sock->pending || !size)
+ return sock->pending ? status : s_Status(sock, eIO_Read);
for (;;) { /* retry if either blocked or interrupted (optional) */
/* try to read */
@@ -2189,7 +2238,7 @@ static EIO_Status s_Shutdown(SOCK sock,
x_how = SOCK_SHUTDOWN_RD;
sock->r_status = eIO_Closed;
#ifdef NCBI_OS_MSWIN
- /* see comments at the bottom of eIO_Write case */
+ /* see comments at the end of eIO_Write case */
return eIO_Success;
#endif /*NCBI_OS_MSWIN*/
break;
@@ -2244,8 +2293,8 @@ static EIO_Status s_Shutdown(SOCK sock,
if (SOCK_SHUTDOWN(sock->sock, x_how) != 0) {
int x_errno = SOCK_ERRNO;
if (
-#if defined(NCBI_OS_LINUX)/*bug in the kernel to report*/ || \
- defined(NCBI_OS_IRIX) || \
+#if defined(NCBI_OS_LINUX)/*bug in the Linux kernel to report*/ || \
+ defined(NCBI_OS_IRIX) || \
defined(NCBI_OS_OSF1)
x_errno != SOCK_ENOTCONN
#else
@@ -2466,9 +2515,11 @@ extern EIO_Status SOCK_CreateOnTopEx(const void* handle,
return eIO_Closed;
#ifdef NCBI_OS_UNIX
if (peer.sa.sa_family != AF_INET && peer.sa.sa_family != AF_UNIX)
-# if defined(NCBI_OS_BSD) || defined(NCBI_OS_DARWIN) || defined(NCBI_OS_IRIX)
+# if defined(NCBI_OS_BSD) || \
+ defined(NCBI_OS_DARWIN) || \
+ defined(NCBI_OS_IRIX)
if (peer.sa.sa_family != AF_UNSPEC/*0*/)
-# endif
+# endif /*NCBI_OS_???*/
return eIO_InvalidArg;
#else
if (peer.sa.sa_family != AF_INET)
@@ -2477,9 +2528,11 @@ extern EIO_Status SOCK_CreateOnTopEx(const void* handle,
#ifdef NCBI_OS_UNIX
if (
-# if defined(NCBI_OS_BSD) || defined(NCBI_OS_DARWIN) || defined(NCBI_OS_IRIX)
+# if defined(NCBI_OS_BSD) || \
+ defined(NCBI_OS_DARWIN) || \
+ defined(NCBI_OS_IRIX)
peer.sa.sa_family == AF_UNSPEC/*0*/ ||
-# endif
+# endif /*NCBI_OS_???*/
peer.sa.sa_family == AF_UNIX) {
if (!peer.un.sun_path[0]) {
peerlen = (SOCK_socklen_t) sizeof(peer);
@@ -2598,7 +2651,7 @@ extern EIO_Status SOCK_Reconnect(SOCK sock,
if (sock->type & eSOCK_ServerSide) {
if (!host || !*host || !port) {
CORE_LOGF(eLOG_Error, ("%s[SOCK::Reconnect] Attempt to reconnect "
- "server-side socket as client one to "
+ "server-side socket as the client one to "
"its peer address", s_ID(sock, _id)));
return eIO_InvalidArg;
}
@@ -2607,6 +2660,8 @@ extern EIO_Status SOCK_Reconnect(SOCK sock,
/* connect */
sock->id++;
+ sock->n_read = 0;
+ sock->n_written = 0;
return s_Connect(sock, host, port, timeout);
}
@@ -2619,8 +2674,7 @@ extern EIO_Status SOCK_Shutdown(SOCK sock,
if (sock->sock == SOCK_INVALID) {
CORE_LOGF(eLOG_Error, ("%s[SOCK::Shutdown] "
" Invalid socket", s_ID(sock, _id)));
- assert(0);
- return eIO_Unknown;
+ return eIO_Closed;
}
if (sock->type == eSOCK_Datagram) {
CORE_LOGF(eLOG_Error, ("%s[SOCK::Shutdown] "
@@ -2633,18 +2687,26 @@ extern EIO_Status SOCK_Shutdown(SOCK sock,
}
-extern EIO_Status SOCK_Close(SOCK sock)
+extern EIO_Status SOCK_CloseEx(SOCK sock, int/*bool*/ destroy)
{
EIO_Status status = sock->sock==SOCK_INVALID ? eIO_Success : s_Close(sock);
-
assert(sock->sock == SOCK_INVALID);
- BUF_Destroy(sock->r_buf);
- BUF_Destroy(sock->w_buf);
- free(sock);
+
+ if (destroy) {
+ BUF_Destroy(sock->r_buf);
+ BUF_Destroy(sock->w_buf);
+ free(sock);
+ }
return status;
}
+extern EIO_Status SOCK_Close(SOCK sock)
+{
+ return SOCK_CloseEx(sock, 1/*destroy*/);
+}
+
+
extern EIO_Status SOCK_Wait(SOCK sock,
EIO_Event event,
const STimeout* timeout)
@@ -2654,8 +2716,7 @@ extern EIO_Status SOCK_Wait(SOCK sock,
if (sock->sock == SOCK_INVALID) {
CORE_LOGF(eLOG_Error, ("%s[SOCK::Wait] "
" Invalid socket", s_ID(sock, _id)));
- assert(0);
- return eIO_Unknown;
+ return eIO_Closed;
}
/* check against already shutdown socket there */
@@ -2672,7 +2733,7 @@ extern EIO_Status SOCK_Wait(SOCK sock,
return eIO_Closed;
}
if ( sock->eof )
- return sock->r_status;
+ return eIO_Closed;
break;
case eIO_Write:
if (sock->type == eSOCK_Datagram)
@@ -2686,17 +2747,20 @@ extern EIO_Status SOCK_Wait(SOCK sock,
case eIO_ReadWrite:
if (sock->type == eSOCK_Datagram || BUF_Size(sock->r_buf) != 0)
return eIO_Success;
- if (sock->r_status == eIO_Closed && sock->w_status == eIO_Closed) {
- CORE_LOGF(eLOG_Warning, ("%s[SOCK::Wait(RW)] Socket shut down",
- s_ID(sock, _id)));
+ if ((sock->r_status == eIO_Closed || sock->eof) &&
+ (sock->w_status == eIO_Closed)) {
+ if (sock->r_status == eIO_Closed) {
+ CORE_LOGF(eLOG_Warning, ("%s[SOCK::Wait(RW)] "
+ "Socket shut down", s_ID(sock, _id)));
+ }
return eIO_Closed;
}
- if ( sock->eof )
- return sock->r_status;
- if (sock->r_status == eIO_Closed) {
- CORE_LOGF(eLOG_Note, ("%s[SOCK::Wait(RW)] Socket %s",
- s_ID(sock, _id), sock->eof
- ? "closed" : "shut down for reading"));
+ if (sock->r_status == eIO_Closed || sock->eof) {
+ if (sock->r_status == eIO_Closed) {
+ CORE_LOGF(eLOG_Note, ("%s[SOCK::Wait(RW)] Socket %s",
+ s_ID(sock, _id), sock->eof
+ ? "closed" : "shut down for reading"));
+ }
event = eIO_Write;
break;
}
@@ -2716,9 +2780,9 @@ extern EIO_Status SOCK_Wait(SOCK sock,
assert(sock->type != eSOCK_Datagram);
/* do wait */
{{
- struct timeval tv;
- SSOCK_Poll poll;
- EIO_Status status;
+ struct timeval tv;
+ SSOCK_Poll poll;
+ EIO_Status status;
const struct timeval* x_tv = s_to2tv(timeout, &tv);
if ((status = s_WritePending(sock, x_tv, 0)) != eIO_Success) {
@@ -2937,9 +3001,8 @@ extern EIO_Status SOCK_Read(SOCK sock,
} else {
CORE_LOGF(eLOG_Error, ("%s[SOCK::Read] Invalid socket",
s_ID(sock, _id)));
- assert(0);
x_read = 0;
- status = eIO_Unknown;
+ status = eIO_Closed;
}
if ( n_read )
@@ -2956,8 +3019,7 @@ extern EIO_Status SOCK_PushBack(SOCK sock,
char _id[32];
CORE_LOGF(eLOG_Error, ("%s[SOCK::PushBack] Invalid socket",
s_ID(sock, _id)));
- assert(0);
- return eIO_Unknown;
+ return eIO_Closed;
}
return BUF_PushBack(&sock->r_buf, buf, size) ? eIO_Success : eIO_Unknown;
@@ -3004,9 +3066,8 @@ extern EIO_Status SOCK_Write(SOCK sock,
} else {
CORE_LOGF(eLOG_Error, ("%s[SOCK::Write] Invalid socket",
s_ID(sock, _id)));
- assert(0);
x_written = 0;
- status = eIO_Unknown;
+ status = eIO_Closed;
}
if ( n_written )
@@ -3017,13 +3078,13 @@ extern EIO_Status SOCK_Write(SOCK sock,
extern EIO_Status SOCK_Abort(SOCK sock)
{
- char _id[32];
+ char _id[32];
+ EIO_Status status;
if (sock->sock == SOCK_INVALID) {
- CORE_LOGF(eLOG_Error, ("%s[SOCK::Abort] "
- " Invalid socket", s_ID(sock, _id)));
- assert(0);
- return eIO_Unknown;
+ CORE_LOGF(eLOG_Warning, ("%s[SOCK::Abort] Invalid socket",
+ s_ID(sock, _id)));
+ return eIO_Closed;
}
if (sock->type == eSOCK_Datagram) {
CORE_LOGF(eLOG_Error, ("%s[SOCK::Abort] Called for datagram socket",
@@ -3034,16 +3095,29 @@ extern EIO_Status SOCK_Abort(SOCK sock)
sock->eof = 0;
sock->w_len = 0;
+ sock->pending = 0;
sock->r_status = sock->w_status = eIO_Closed;
- return eIO_Success;
+ if (SOCK_CLOSE(sock->sock) != 0) {
+ int x_errno = SOCK_ERRNO;
+ CORE_LOGF_ERRNO_EX(eLOG_Error, x_errno, SOCK_STRERROR(x_errno),
+ ("%s[SOCK::Abort] Failed close()",
+ s_ID(sock, _id)));
+ status = eIO_Unknown;
+ } else
+ status = eIO_Success;
+ sock->sock = SOCK_INVALID;
+ return status;
}
extern EIO_Status SOCK_Status(SOCK sock,
EIO_Event direction)
{
- if (direction != eIO_Read && direction != eIO_Write)
+ if (direction != eIO_Read && direction != eIO_Write) {
+ if (direction == eIO_Open)
+ return sock->sock == SOCK_INVALID ? eIO_Closed : eIO_Success;
return eIO_InvalidArg;
+ }
return (sock->sock == SOCK_INVALID ? eIO_Closed :
sock->pending ? eIO_Timeout : s_Status(sock, direction));
@@ -3096,7 +3170,7 @@ extern EIO_Status SOCK_GetOSHandle(SOCK sock,
}
memcpy(handle, &sock->sock, handle_size);
- return eIO_Success;
+ return sock->sock == SOCK_INVALID ? eIO_Closed : eIO_Success;
}
@@ -3232,7 +3306,11 @@ extern EIO_Status DSOCK_Bind(SOCK sock, unsigned short port)
assert(0);
return eIO_InvalidArg;
}
- assert(sock->sock != SOCK_INVALID);
+ if (sock->sock == SOCK_INVALID) {
+ CORE_LOGF(eLOG_Error, ("%s[DSOCK::Bind] "
+ " Invalid socket", s_ID(sock, _id)));
+ return eIO_Closed;
+ }
/* bind */
memset(&addr, 0, sizeof(addr));
@@ -3246,7 +3324,7 @@ extern EIO_Status DSOCK_Bind(SOCK sock, unsigned short port)
int x_errno = SOCK_ERRNO;
CORE_LOGF_ERRNO_EX(eLOG_Error, x_errno, SOCK_STRERROR(x_errno),
("%s[DSOCK::Bind] Failed bind()", s_ID(sock,_id)));
- return eIO_Unknown;
+ return x_errno == SOCK_EADDRINUSE ? eIO_Closed : eIO_Unknown;
}
/* statistics & logging */
@@ -3268,7 +3346,11 @@ extern EIO_Status DSOCK_Connect(SOCK sock,
assert(0);
return eIO_InvalidArg;
}
- assert(sock->sock != SOCK_INVALID);
+ if (sock->sock == SOCK_INVALID) {
+ CORE_LOGF(eLOG_Error, ("%s[DSOCK::Connect] "
+ " Invalid socket", s_ID(sock, _id)));
+ return eIO_Closed;
+ }
/* drop all pending data */
s_WipeRBuf(sock);
@@ -3287,7 +3369,7 @@ extern EIO_Status DSOCK_Connect(SOCK sock,
}
}
if (!sock->host || !sock->port) {
- CORE_LOGF(eLOG_Error, ("%s[DSOCK::Connect] Cannot connect"
+ CORE_LOGF(eLOG_Error, ("%s[DSOCK::Connect] Cannot connect "
"to incomplete address", s_ID(sock, _id)));
return eIO_InvalidArg;
}
@@ -3306,7 +3388,7 @@ extern EIO_Status DSOCK_Connect(SOCK sock,
if (SOCK_ntoa(sock->host, addr, sizeof(addr)) != 0)
strcpy(addr, "???");
CORE_LOGF_ERRNO_EX(eLOG_Error, x_errno, SOCK_STRERROR(x_errno),
- ("%s[SOCK::Reconnect] Cannot connect"
+ ("%s[DSOCK::Connect] Cannot connect "
"datagram socket to %s:%hu", s_ID(sock, _id),
addr, ntohs(sock->port)));
return eIO_Unknown;
@@ -3339,7 +3421,11 @@ extern EIO_Status DSOCK_SendMsg(SOCK sock,
assert(0);
return eIO_InvalidArg;
}
- assert(sock->sock != SOCK_INVALID);
+ if (sock->sock == SOCK_INVALID) {
+ CORE_LOGF(eLOG_Error, ("%s[DSOCK::SendMsg] "
+ " Invalid socket", s_ID(sock, w)));
+ return eIO_Closed;
+ }
if ( datalen ) {
s_Write(sock, data, datalen, &x_msgsize);
@@ -3466,7 +3552,11 @@ extern EIO_Status DSOCK_RecvMsg(SOCK sock,
assert(0);
return eIO_InvalidArg;
}
- assert(sock->sock != SOCK_INVALID);
+ if (sock->sock == SOCK_INVALID) {
+ CORE_LOGF(eLOG_Error, ("%s[DSOCK::RecvMsg] "
+ " Invalid socket", s_ID(sock, w)));
+ return eIO_Closed;
+ }
s_WipeRBuf(sock);
if ( msglen )
@@ -3587,7 +3677,11 @@ extern EIO_Status DSOCK_WaitMsg(SOCK sock, const STimeout* timeout)
assert(0);
return eIO_InvalidArg;
}
- assert(sock->sock != SOCK_INVALID);
+ if (sock->sock == SOCK_INVALID) {
+ CORE_LOGF(eLOG_Error, ("%s[DSOCK::WaitMsg] "
+ " Invalid socket", s_ID(sock, _id)));
+ return eIO_Closed;
+ }
poll.sock = sock;
poll.event = eIO_Read;
@@ -3612,7 +3706,11 @@ extern EIO_Status DSOCK_WipeMsg(SOCK sock, EIO_Event direction)
assert(0);
return eIO_InvalidArg;
}
- assert(sock->sock != SOCK_INVALID);
+ if (sock->sock == SOCK_INVALID) {
+ CORE_LOGF(eLOG_Error, ("%s[DSOCK::Wipe] "
+ " Invalid socket", s_ID(sock, _id)));
+ return eIO_Closed;
+ }
switch (direction) {
case eIO_Read:
@@ -3643,7 +3741,11 @@ extern EIO_Status DSOCK_SetBroadcast(SOCK sock, int/*bool*/ broadcast)
assert(0);
return eIO_InvalidArg;
}
- assert(sock->sock != SOCK_INVALID);
+ if (sock->sock == SOCK_INVALID) {
+ CORE_LOGF(eLOG_Error, ("%s[DSOCK::SetBroadcast] "
+ " Invalid socket", s_ID(sock, _id)));
+ return eIO_Closed;
+ }
#if defined(NCBI_OS_UNIX) || defined(NCBI_OS_MSWIN)
/* setsockopt() is not implemented for MAC (in MIT socket emulation lib) */
@@ -3672,19 +3774,19 @@ extern EIO_Status DSOCK_SetBroadcast(SOCK sock, int/*bool*/ broadcast)
extern int/*bool*/ SOCK_IsDatagram(SOCK sock)
{
- return sock->type == eSOCK_Datagram;
+ return sock->sock != SOCK_INVALID && sock->type == eSOCK_Datagram;
}
extern int/*bool*/ SOCK_IsClientSide(SOCK sock)
{
- return sock->type == eSOCK_ClientSide;
+ return sock->sock != SOCK_INVALID && sock->type == eSOCK_ClientSide;
}
extern int/*bool*/ SOCK_IsServerSide(SOCK sock)
{
- return sock->type & eSOCK_ServerSide ? 1 : 0;
+ return sock->sock != SOCK_INVALID && (sock->type & eSOCK_ServerSide);
}
@@ -3953,6 +4055,23 @@ extern char* SOCK_gethostbyaddr(unsigned int host,
/*
* ===========================================================================
* $Log: ncbi_socket.c,v $
+ * Revision 6.143 2003/11/25 15:08:40 lavr
+ * DSOCK_Connect(): fix diag messages
+ *
+ * Revision 6.142 2003/11/24 19:21:42 lavr
+ * SOCK_SetSelectInternalRestartTimeout() to accept ptr to STimeout
+ *
+ * Revision 6.141 2003/11/18 20:19:48 lavr
+ * +SOCK_SetSelectInternalRestartTimeout() and restart impl. in s_Select()
+ *
+ * Revision 6.140 2003/11/14 13:05:23 lavr
+ * Eliminate race on socket file descriptors in s_Select() when socket aborted
+ *
+ * Revision 6.138 2003/11/12 17:49:42 lavr
+ * Implement close w/o destruction (SOCK_CloseEx()) and make
+ * corresponding provisions throughout the file.
+ * More consistent return status in SOCK and DSOCK API calls.
+ *
* Revision 6.137 2003/10/27 16:45:46 ivanov
* Use workaround for unnamed peer's UNIX sockets on DARWIN also.
*
diff --git a/connect/ncbi_socket.h b/connect/ncbi_socket.h
index 008058c4..b9019779 100644
--- a/connect/ncbi_socket.h
+++ b/connect/ncbi_socket.h
@@ -1,7 +1,7 @@
#ifndef CONNECT___NCBI_SOCKET__H
#define CONNECT___NCBI_SOCKET__H
-/* $Id: ncbi_socket.h,v 6.44 2003/10/24 16:51:11 lavr Exp $
+/* $Id: ncbi_socket.h,v 6.48 2003/11/25 15:07:12 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -255,6 +255,12 @@ extern NCBI_XCONNECT_EXPORT void SOCK_SetReuseAddress
*/
+/*
+ */
+extern NCBI_XCONNECT_EXPORT const STimeout*SOCK_SetSelectInternalRestartTimeout
+(const STimeout* timeout);
+
+
/* By default (on UNIX platforms) the SOCK API functions automagically call
* "signal(SIGPIPE, SIG_IGN)" on initialization. To prohibit this feature,
* you must call SOCK_AllowSigPipeAPI() before you call any other
@@ -428,7 +434,7 @@ extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_Reconnect
* Cannot be applied to datagram sockets (eIO_InvalidArg results).
*/
extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_Shutdown
-(SOCK sock,
+(SOCK sock, /* [in] handle of the socket to shutdown */
EIO_Event how /* [in] one of: eIO_Read, eIO_Write, eIO_ReadWrite */
);
@@ -444,6 +450,19 @@ extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_Shutdown
extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_Close(SOCK sock);
+/* Close the connection, and conditionally destroy relevant internal data.
+ * NOTE1: if eIO_Close timeout was specified (or NULL) then it blocks until
+ * either all unsent data are sent, error flagged, or the timeout
+ * expires.
+ * NOTE2: if there is output pending, that output will be flushed.
+ * NOTE3: SOCK_CloseEx(sock, 1) is equivalent to SOCK_Close(sock);
+ */
+extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_CloseEx
+(SOCK sock, /* [in] handle of the socket to close */
+ int/*bool*/ destroy /* [in] =1 to destroy handle; =0 to keep handle */
+ );
+
+
/* Block on the socket until either read/write (dep. on the "event" arg) is
* available or timeout expires (if "timeout" is NULL then assume it infinite).
* For a datagram socket, eIO_Closed is returned if the internally latched
@@ -608,11 +627,12 @@ extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_PushBack
);
-/* Return (for the specified "direction"):
+/* Return (for the specified "direction" [eIO_Open to check for closed sock]):
* eIO_Closed -- if the connection was shutdown by SOCK_Shutdown(), or
* (for "eIO_Read" only) if EOF was detected
+ * if "direction"==eIO_Open, this code means socket closed
* eIO_Unknown -- if an error was detected during the last I/O
- * eIO_InvalidArg -- if "direction" is not one of: eIO_Read, eIO_Write
+ * eIO_InvalidArg -- if "direction" is not one of: Open, Read, Write
* eIO_Timeout -- if the socket is not yet actually connected
* eIO_Success -- otherwise (incl. eIO_Timeout on last I/O)
*
@@ -620,11 +640,11 @@ extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_PushBack
* as long as there is any unread (buffered) data left.
* Thus, when you are "peeking" data instead of actually reading it,
* then this is the only "non-destructive" way to check whether EOF
- * or an error has occurred on read.
+ * or an error has actually occurred on read.
*/
extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_Status
(SOCK sock,
- EIO_Event direction /* [in] one of: eIO_Read, eIO_Write */
+ EIO_Event direction /* [in] one of: eIO_Open, eIO_Read, eIO_Write */
);
@@ -662,6 +682,7 @@ extern NCBI_XCONNECT_EXPORT EIO_Status SOCK_Write
/* If there is outstanding connection or output data pending, cancel it.
* Mark the socket as if it has been shut down for both reading and writing.
+ * Break actual connection if any was established.
* Do not attempt to send anything upon SOCK_Close().
* This call is available for stream sockets only.
*/
@@ -734,8 +755,8 @@ extern NCBI_XCONNECT_EXPORT ESwitch SOCK_SetReadOnWrite
*
* Datagram socket is created with special DSOCK_Create[Ex] calls but the
* resulting object is a SOCK handle. That is, almost all SOCK routines
- * may be applied to the handle. The only exception is SOCK_Shutdown().
- * For datagram sockets there are differences in how I/O behaves:
+ * may be applied to the handle. There are few exceptions, though.
+ * In datagram sockets I/O differs from how it is done in stream sockets:
*
* SOCK_Write() writes data into an internal message buffer, appending new
* data as they come with each SOCK_Write(). When the message is complete,
@@ -937,6 +958,18 @@ extern NCBI_XCONNECT_EXPORT char* SOCK_gethostbyaddr
/*
* ---------------------------------------------------------------------------
* $Log: ncbi_socket.h,v $
+ * Revision 6.48 2003/11/25 15:07:12 lavr
+ * SOCK_Status() to accept eIO_Open
+ *
+ * Revision 6.47 2003/11/24 19:22:24 lavr
+ * SetSelectInternalRestartTimeout() to accept ptr to STimeout
+ *
+ * Revision 6.46 2003/11/18 20:18:49 lavr
+ * +SetSelectInternalRestartTimeout()
+ *
+ * Revision 6.45 2003/11/12 17:43:08 lavr
+ * +SOCK_CloseEx()
+ *
* Revision 6.44 2003/10/24 16:51:11 lavr
* GetTimeout(eIO_ReadWrite): return the lesser of eIO_Read and eIO_Write
*
diff --git a/connect/ncbi_util.c b/connect/ncbi_util.c
index a82546fe..c52964d2 100644
--- a/connect/ncbi_util.c
+++ b/connect/ncbi_util.c
@@ -1,4 +1,4 @@
-/* $Id: ncbi_util.c,v 6.29 2003/09/02 21:05:14 lavr Exp $
+/* $Id: ncbi_util.c,v 6.31 2003/11/14 13:04:38 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -44,9 +44,6 @@
# include <time.h>
#endif
-#if defined(OS_MSWIN) && defined(COMP_METRO)
-char *_strtime( char *timestr );
-#endif
/* Static function pre-declarations to avoid C++ compiler warnings
*/
@@ -171,8 +168,7 @@ extern char* LOG_ComposeMessage
/* Pre-calculate total message length */
if ((format_flags & fLOG_DateTime) != 0) {
-#if defined(NCBI_OS_MSWIN) && !defined(COMP_METRO)
-/*Should be compiler-dependent, but C-Toolkit lacks it*/
+#ifdef NCBI_OS_MSWIN /*Should be compiler-dependent but C-Tkit lacks it*/
_strdate(&datetime[datetime_len]);
datetime_len += strlen(&datetime[datetime_len]);
datetime[datetime_len++] = ' ';
@@ -504,6 +500,12 @@ extern const char* CORE_GetPlatform(void)
/*
* ---------------------------------------------------------------------------
* $Log: ncbi_util.c,v $
+ * Revision 6.31 2003/11/14 13:04:38 lavr
+ * Little changes in comments [no code changes]
+ *
+ * Revision 6.30 2003/11/13 19:53:41 rsmith
+ * Took out metrowerks specific #ifdef's (COMP_METRO). Not needed anymore.
+ *
* Revision 6.29 2003/09/02 21:05:14 lavr
* Proper indentation of compilation conditionals
*
diff --git a/connect/ncbi_util.h b/connect/ncbi_util.h
index 28a87f5c..090a571d 100644
--- a/connect/ncbi_util.h
+++ b/connect/ncbi_util.h
@@ -1,7 +1,7 @@
#ifndef CONNECT___NCBI_UTIL__H
#define CONNECT___NCBI_UTIL__H
-/* $Id: ncbi_util.h,v 6.20 2003/10/21 11:17:17 lavr Exp $
+/* $Id: ncbi_util.h,v 6.21 2004/01/27 17:05:59 ucko Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -98,6 +98,11 @@ extern NCBI_XCONNECT_EXPORT MT_LOCK CORE_GetLOCK(void);
#define LOG_WRITE(lg, level, message) \
LOG_Write(lg, level, THIS_MODULE, THIS_FILE, __LINE__, message)
+/* AIX's <pthread.h> defines LOG_DATA to be an integer constant; we must
+ explicitly drop such definitions to avoid trouble. */
+#ifdef LOG_DATA
+# undef LOG_DATA
+#endif
#define LOG_DATA(lg, data, size, message) \
LOG_Data(lg, eLOG_Trace, THIS_MODULE, THIS_FILE, __LINE__, \
data, size, message)
@@ -244,6 +249,10 @@ extern NCBI_XCONNECT_EXPORT const char* CORE_GetPlatform(void);
/*
* ---------------------------------------------------------------------------
* $Log: ncbi_util.h,v $
+ * Revision 6.21 2004/01/27 17:05:59 ucko
+ * #undef LOG_DATA if necessary before #defining it with arguments to
+ * avoid trouble on AIX.
+ *
* Revision 6.20 2003/10/21 11:17:17 lavr
* Add location information in LOG_DATA()
*
diff --git a/connect/test/test_ncbi_connutil_misc.c b/connect/test/test_ncbi_connutil_misc.c
index a6105173..48f83bc6 100644
--- a/connect/test/test_ncbi_connutil_misc.c
+++ b/connect/test/test_ncbi_connutil_misc.c
@@ -1,4 +1,4 @@
-/* $Id: test_ncbi_connutil_misc.c,v 6.11 2002/12/13 21:20:55 lavr Exp $
+/* $Id: test_ncbi_connutil_misc.c,v 6.13 2004/01/14 18:53:09 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -235,6 +235,8 @@ static void TEST_MIME(void)
eMIME_T_NcbiData, eMIME_Unknown, eENCOD_None));
assert(s_Try_MIME("text/html",
eMIME_T_Text, eMIME_Html, eENCOD_None));
+ assert(s_Try_MIME("application/xml+soap",
+ eMIME_T_Application, eMIME_XmlSoap, eENCOD_None));
assert(!s_Try_MIME("", eMIME_T_NcbiData, eMIME_Unknown, eENCOD_Unknown));
assert(!s_Try_MIME(0, eMIME_T_NcbiData, eMIME_Unknown, eENCOD_Unknown));
}
@@ -300,6 +302,12 @@ int main(void)
/*
* ---------------------------------------------------------------------------
* $Log: test_ncbi_connutil_misc.c,v $
+ * Revision 6.13 2004/01/14 18:53:09 lavr
+ * Use "application/xml+soap" in the test case
+ *
+ * Revision 6.12 2004/01/07 19:24:03 lavr
+ * Added test for MIME content-type "application/xml"
+ *
* Revision 6.11 2002/12/13 21:20:55 lavr
* Move log to end
*
diff --git a/connect/test/test_ncbi_dsock.c b/connect/test/test_ncbi_dsock.c
index cd992fa0..1fa884bb 100644
--- a/connect/test/test_ncbi_dsock.c
+++ b/connect/test/test_ncbi_dsock.c
@@ -1,4 +1,4 @@
-/* $Id: test_ncbi_dsock.c,v 6.12 2003/10/27 19:00:32 lavr Exp $
+/* $Id: test_ncbi_dsock.c,v 6.14 2003/12/11 15:34:29 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,6 +32,7 @@
#include "../ncbi_ansi_ext.h"
#include "../ncbi_priv.h" /* CORE logging facilities */
+#include <connect/ncbi_connutil.h>
#include <connect/ncbi_socket.h>
#include <errno.h>
#include <stdlib.h>
@@ -49,6 +50,9 @@
#elif defined(NCBI_OS_IRIX)
/* This has been found experimentally on IRIX64 6.5 04101931 IP25 */
# define MAX_DGRAM_SIZE (60*1024)
+#elif defined(NCBI_OS_LINUX)
+/* Larger sizes do not seem to work everywhere */
+# define MAX_DGRAM_SIZE 65000
#else
/* This is the maximal datagram size defined by the UDP standard */
# define MAX_DGRAM_SIZE 65535
@@ -96,96 +100,102 @@ static int s_Server(int x_port)
return 1;
}
- if ((status = DSOCK_WaitMsg(server, 0/*infinite*/)) != eIO_Success) {
- CORE_LOGF(eLOG_Error, ("[Server] Error waiting on DSOCK: %s",
- IO_StatusStr(status)));
- return 1;
- }
-
- timeout.sec = 0;
- timeout.usec = 0;
- if ((status= SOCK_SetTimeout(server, eIO_Read, &timeout)) != eIO_Success) {
- CORE_LOGF(eLOG_Error, ("[Server] Error setting zero read tmo: %s",
- IO_StatusStr(status)));
- return 1;
- }
+ for (;;) {
+ if ((status = DSOCK_WaitMsg(server, 0/*infinite*/)) != eIO_Success) {
+ CORE_LOGF(eLOG_Error, ("[Server] Error waiting on DSOCK: %s",
+ IO_StatusStr(status)));
+ break;
+ }
- len = (size_t)(((double) rand()/(double) RAND_MAX)*sizeof(minibuf));
- if ((status = DSOCK_RecvMsg(server, minibuf, len, 0, &msglen,
- &peeraddr, &peerport)) != eIO_Success) {
- CORE_LOGF(eLOG_Error, ("[Server] Error reading from DSOCK: %s",
- IO_StatusStr(status)));
- return 1;
- }
- if (len > msglen)
- len = msglen;
+ timeout.sec = 0;
+ timeout.usec = 0;
+ if ((status = SOCK_SetTimeout(server, eIO_Read, &timeout))
+ != eIO_Success) {
+ CORE_LOGF(eLOG_Error, ("[Server] Error setting zero read tmo: %s",
+ IO_StatusStr(status)));
+ break;
+ }
- if (SOCK_ntoa(peeraddr, addr, sizeof(addr)) != 0)
- strcpy(addr, "<unknown>");
+ len = (size_t)(((double) rand()/(double) RAND_MAX)*sizeof(minibuf));
+ if ((status = DSOCK_RecvMsg(server, minibuf, len, 0, &msglen,
+ &peeraddr, &peerport)) != eIO_Success) {
+ CORE_LOGF(eLOG_Error, ("[Server] Error reading from DSOCK: %s",
+ IO_StatusStr(status)));
+ continue;
+ }
+ if (len > msglen)
+ len = msglen;
- CORE_LOGF(eLOG_Note, ("[Server] Message received from %s:%hu, %lu bytes",
- addr, peerport, (unsigned long) msglen));
+ if (SOCK_ntoa(peeraddr, addr, sizeof(addr)) != 0)
+ strcpy(addr, "<unknown>");
- if (!(buf = (char*) malloc(msglen ? msglen : 1))) {
- CORE_LOG_ERRNO(eLOG_Error, errno, "[Server] Cannot alloc msg buf");
- return 1;
- }
- if (len)
- memcpy(buf, minibuf, len);
+ CORE_LOGF(eLOG_Note, ("[Server] Message received from %s:%hu, "
+ "%lu bytes",
+ addr, peerport, (unsigned long) msglen));
- while (len < msglen) {
- n = (size_t)(((double) rand()/(double) RAND_MAX)*(msglen - len) + 0.5);
- if ((status = SOCK_Read(server, buf + len, n, &n, eIO_ReadPlain))
- != eIO_Success) {
- CORE_LOGF(eLOG_Error,("[Server] Error reading msg @ byte %lu: %s",
- (unsigned long) len, IO_StatusStr(status)));
- return 1;
+ if (!(buf = (char*) malloc(msglen ? msglen : 1))) {
+ CORE_LOG_ERRNO(eLOG_Error, errno,"[Server] Cannot alloc msg buf");
+ break;
}
- len += n;
- }
- assert(SOCK_Read(server, 0, 1, &n, eIO_ReadPlain) == eIO_Closed);
+ if (len)
+ memcpy(buf, minibuf, len);
+
+ while (len < msglen) {
+ n = (size_t)(((double)rand()/(double)RAND_MAX)*(msglen-len) + 0.5);
+ if ((status = SOCK_Read(server, buf + len, n, &n, eIO_ReadPlain))
+ != eIO_Success) {
+ CORE_LOGF(eLOG_Error,("[Server] Error reading msg @ byte %lu:"
+ " %s", (unsigned long) len,
+ IO_StatusStr(status)));
+ free(buf);
+ continue;
+ }
+ len += n;
+ }
+ assert(SOCK_Read(server, 0, 1, &n, eIO_ReadPlain) == eIO_Closed);
- CORE_LOG(eLOG_Note, "[Server] Bouncing the message to sender");
+ CORE_LOG(eLOG_Note, "[Server] Bouncing the message to sender");
- timeout.sec = 1;
- timeout.usec = 0;
- if ((status= SOCK_SetTimeout(server, eIO_Write, &timeout)) != eIO_Success){
- CORE_LOGF(eLOG_Error, ("[Server] Error setting write tmo: %s",
- IO_StatusStr(status)));
- return 1;
- }
+ timeout.sec = 1;
+ timeout.usec = 0;
+ if ((status = SOCK_SetTimeout(server, eIO_Write, &timeout))
+ != eIO_Success){
+ CORE_LOGF(eLOG_Error, ("[Server] Error setting write tmo: %s",
+ IO_StatusStr(status)));
+ break;
+ }
- for (len = 0; len < msglen; len += n) {
- n = (size_t)(((double) rand()/(double) RAND_MAX)*(msglen - len) + 0.5);
- if ((status = SOCK_Write(server, buf + len, n, &n, eIO_WritePlain))
- != eIO_Success) {
- CORE_LOGF(eLOG_Error,("[Server] Error writing msg @ byte %lu: %s",
- (unsigned long) len, IO_StatusStr(status)));
- return 1;
+ for (len = 0; len < msglen; len += n) {
+ n = (size_t)(((double)rand()/(double)RAND_MAX)*(msglen-len) + 0.5);
+ if ((status = SOCK_Write(server, buf + len, n, &n, eIO_WritePlain))
+ != eIO_Success) {
+ CORE_LOGF(eLOG_Error,("[Server] Error writing msg @ byte %lu:"
+ " %s", (unsigned long) len,
+ IO_StatusStr(status)));
+ break;
+ }
}
- }
- free(buf);
+ free(buf);
- if ((status = DSOCK_SendMsg(server, addr, peerport, "--Reply--", 9))
- != eIO_Success) {
- CORE_LOGF(eLOG_Error, ("[Server] Error sending to DSOCK: %s",
- IO_StatusStr(status)));
- return 1;
+ if ((status = DSOCK_SendMsg(server, addr, peerport, "--Reply--", 9))
+ != eIO_Success) {
+ CORE_LOGF(eLOG_Error, ("[Server] Error sending to DSOCK: %s",
+ IO_StatusStr(status)));
+ /*continue*/;
+ }
}
+ /* On errors control reaches here */
if ((status = SOCK_Close(server)) != eIO_Success) {
CORE_LOGF(eLOG_Error, ("[Server] Error closing DSOCK: %s",
IO_StatusStr(status)));
- return 1;
}
-
- CORE_LOG(eLOG_Note, "[Server] Completed successfully");
- return 0;
+ return 1;
}
-static int s_Client(int x_port)
+static int s_Client(int x_port, unsigned int max_try)
{
size_t msglen, n;
STimeout timeout;
@@ -193,6 +203,8 @@ static int s_Client(int x_port)
SOCK client;
unsigned short port;
char* buf;
+ unsigned long id;
+ unsigned int m;
if (x_port <= 0) {
CORE_LOG(eLOG_Error, "[Client] Port wrongly specified");
@@ -209,6 +221,9 @@ static int s_Client(int x_port)
}
msglen = (size_t)(((double)rand()/(double)RAND_MAX)*(MAX_DGRAM_SIZE - 10));
+ if (msglen < sizeof(time_t))
+ msglen = sizeof(time_t);
+
CORE_LOGF(eLOG_Note, ("[Client] Generating a message %lu bytes long",
(unsigned long) msglen));
@@ -217,42 +232,71 @@ static int s_Client(int x_port)
return 1;
}
- for (n = 0; n < msglen; n++)
+
+ for (n = sizeof(unsigned long); n < msglen; n++)
buf[n] = rand() % 0xFF;
- if ((status = DSOCK_SendMsg(client, "127.0.0.1", port, buf, msglen))
- != eIO_Success) {
- CORE_LOGF(eLOG_Error, ("[Client] Error sending to DSOCK: %s",
- IO_StatusStr(status)));
- return 1;
- }
+ id = (unsigned long) time(0);
- timeout.sec = 1;
- timeout.usec = 0;
- if ((status = SOCK_SetTimeout(client, eIO_Read, &timeout)) != eIO_Success){
- CORE_LOGF(eLOG_Error, ("[Client] Error setting read tmo: %s",
- IO_StatusStr(status)));
- return 1;
- }
+ for (m = 1; m <= max_try; m++) {
+ unsigned long tmp;
- if ((status = DSOCK_RecvMsg(client, &buf[msglen], msglen + 9, 0, &n, 0, 0))
- != eIO_Success) {
- CORE_LOGF(eLOG_Error, ("[Client] Error reading from DSOCK: %s",
- IO_StatusStr(status)));
- return 1;
- }
+ if (m != 1)
+ CORE_LOGF(eLOG_Note, ("[Client] Attempt #%u", (unsigned int) m));
+ id++;
+
+ *((unsigned long*) buf) = SOCK_htonl((unsigned long) id);
+
+ if ((status = DSOCK_SendMsg(client, "127.0.0.1", port, buf, msglen))
+ != eIO_Success) {
+ CORE_LOGF(eLOG_Error, ("[Client] Error sending to DSOCK: %s",
+ IO_StatusStr(status)));
+ return 1;
+ }
+
+ timeout.sec = 1;
+ timeout.usec = 0;
+ if ((status = SOCK_SetTimeout(client, eIO_Read, &timeout))
+ != eIO_Success) {
+ CORE_LOGF(eLOG_Error, ("[Client] Error setting read timeout: %s",
+ IO_StatusStr(status)));
+ return 1;
+ }
+
+ again:
+ if ((status = DSOCK_RecvMsg(client, &buf[msglen], msglen+9,0, &n, 0,0))
+ != eIO_Success) {
+ CORE_LOGF(eLOG_Error, ("[Client] Error reading from DSOCK: %s",
+ IO_StatusStr(status)));
+ continue;
+ }
+
+ if (n != msglen + 9) {
+ CORE_LOGF(eLOG_Error, ("[Client] Received message of wrong size: "
+ "%lu", (unsigned long) n));
+ return 1;
+ }
+
+ memcpy(&tmp, &buf[msglen], sizeof(tmp));
+ if (SOCK_ntohl(tmp) != id) {
+ m++;
+ CORE_LOGF(m < max_try ? eLOG_Warning : eLOG_Error,
+ ("[Client] Stale message received%s",
+ m <= max_try ? ", reattempting to fetch" : ""));
+ if (m <= max_try)
+ goto again;
+ break;
+ }
- if (n != msglen + 9) {
- CORE_LOGF(eLOG_Error, ("[Client] Received message of wrong size: %lu",
- (unsigned long) n));
- return 1;
- } else {
CORE_LOGF(eLOG_Note, ("[Client] Received the message back, %lu bytes",
(unsigned long) n));
+ assert(SOCK_Read(client, 0, 1, &n, eIO_ReadPlain) == eIO_Closed);
+ break;
}
- assert(SOCK_Read(client, 0, 1, &n, eIO_ReadPlain) == eIO_Closed);
+ if (m > max_try)
+ return 1;
- for (n = 0; n < msglen; n++) {
+ for (n = sizeof(unsigned long); n < msglen; n++) {
if (buf[n] != buf[msglen + n])
break;
}
@@ -285,6 +329,7 @@ static int s_Client(int x_port)
int main(int argc, const char* argv[])
{
unsigned long seed;
+ unsigned int max_try = DEF_CONN_MAX_TRY;
const char* env = getenv("CONN_DEBUG_PRINTOUT");
CORE_SetLOGFormatFlags(fLOG_None | fLOG_Level |
@@ -305,16 +350,19 @@ int main(int argc, const char* argv[])
CORE_LOGF(eLOG_Note, ("Random SEED = %lu", seed));
srand(seed);
- if (env && (strcasecmp(env, "1") == 0 ||
- strcasecmp(env, "yes") == 0 ||
- strcasecmp(env, "true") == 0 ||
- strcasecmp(env, "some") == 0 ||
- strcasecmp(env, "data") == 0)){
+ if (env && (strcasecmp(env, "1") == 0 ||
+ strcasecmp(env, "yes") == 0 ||
+ strcasecmp(env, "true") == 0 ||
+ strcasecmp(env, "some") == 0 ||
+ strcasecmp(env, "data") == 0)) {
SOCK_SetDataLoggingAPI(eOn);
}
+ if (!(env = getenv("CONN_MAX_TRY")) || !(max_try = atoi(env)))
+ max_try = DEF_CONN_MAX_TRY;
+
if (strcasecmp(argv[1], "client") == 0)
- return s_Client(argv[2] ? atoi(argv[2]) : DEFAULT_PORT);
+ return s_Client(argv[2] ? atoi(argv[2]) : DEFAULT_PORT, max_try);
if (strcasecmp(argv[1], "server") == 0)
return s_Server(argv[2] ? atoi(argv[2]) : DEFAULT_PORT);
@@ -326,6 +374,12 @@ int main(int argc, const char* argv[])
/*
* --------------------------------------------------------------------------
* $Log: test_ncbi_dsock.c,v $
+ * Revision 6.14 2003/12/11 15:34:29 lavr
+ * Lower maximal datagram size for Linux - 65535 didn't seem to work everywhere
+ *
+ * Revision 6.13 2003/12/10 17:24:16 lavr
+ * Reattempt to send/receive a datagram on I/O errors in client
+ *
* Revision 6.12 2003/10/27 19:00:32 lavr
* Limit datagram size for Darwin (which is BSD based)
*
diff --git a/connect/test/test_ncbi_http_connector.c b/connect/test/test_ncbi_http_connector.c
index 4adccbcd..cb5b3b5b 100644
--- a/connect/test/test_ncbi_http_connector.c
+++ b/connect/test/test_ncbi_http_connector.c
@@ -1,4 +1,4 @@
-/* $Id: test_ncbi_http_connector.c,v 6.13 2003/05/14 03:58:43 lavr Exp $
+/* $Id: test_ncbi_http_connector.c,v 6.14 2003/11/04 12:26:06 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -57,6 +57,7 @@ extern "C" {
}
#endif /* __cplusplus */
+/*ARGSUSED*/
static void s_REG_Get
(void* user_data,
const char* section,
@@ -141,6 +142,9 @@ int main(void)
/*
* --------------------------------------------------------------------------
* $Log: test_ncbi_http_connector.c,v $
+ * Revision 6.14 2003/11/04 12:26:06 lavr
+ * s_GetReg() marked with ARGSUSED, because user_data is not used in there
+ *
* Revision 6.13 2003/05/14 03:58:43 lavr
* Match changes in respective APIs of the tests
*
diff --git a/connect/test/test_ncbi_sendmail.c b/connect/test/test_ncbi_sendmail.c
index 0fe4d776..47f884f6 100644
--- a/connect/test/test_ncbi_sendmail.c
+++ b/connect/test/test_ncbi_sendmail.c
@@ -1,4 +1,4 @@
-/* $Id: test_ncbi_sendmail.c,v 6.9 2003/05/14 03:58:43 lavr Exp $
+/* $Id: test_ncbi_sendmail.c,v 6.11 2003/12/09 15:39:30 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -44,6 +44,11 @@
int main(void)
{
+ const char custom_body[] =
+ "Subject: Custom sized body\n"
+ "\n"
+ "Custom sized body\n"
+ "0123456789\n"; /* these 11 chars to ignore */
const char* body[] = {
"This is a simple test",
"This is a test with\n.",
@@ -62,7 +67,8 @@ int main(void)
};
const char* to[] = {
"lavr",
- "lavr@pavo"
+ "lavr@pavo",
+ " \"Anton Lavrentiev\" <lavr@pavo> , lavr, <lavr> ",
};
size_t i, j, k, n, m;
const char* mx_host;
@@ -98,10 +104,12 @@ int main(void)
CORE_LOG(eLOG_Note, "Phase 2 of 2: Testing CORE_SendMailEx");
SendMailInfo_Init(&info);
- mx_port = info.mx_port;
mx_host = info.mx_host;
+ mx_port = info.mx_port;
mx_tmo = info.mx_timeout;
+ info.mx_host = "localhost";
+
CORE_LOG(eLOG_Note, "Testing bad port");
info.mx_port = 10;
retval = CORE_SendMailEx("lavr", "CORE_SendMailEx Test", "Test", &info);
@@ -117,6 +125,7 @@ int main(void)
CORE_LOGF(eLOG_Note, ("Test passed: %s", retval));
CORE_LOG(eLOG_Note, "Testing timeout");
+ info.mx_host = "www.ncbi.nlm.nih.gov";
info.mx_timeout.sec = 5;
info.mx_port = 80;
retval = CORE_SendMailEx("lavr", "CORE_SendMailEx Test", "Test", &info);
@@ -135,7 +144,7 @@ int main(void)
CORE_LOG(eLOG_Fatal, "Test failed");
CORE_LOGF(eLOG_Note, ("Test passed: %s", retval));
- info.mx_host = mx_host;
+ info.mx_host = "localhost";
CORE_LOG(eLOG_Note, "Testing cc");
info.cc = "vakatov";
@@ -186,13 +195,41 @@ int main(void)
CORE_LOG(eLOG_Fatal, "Test failed");
CORE_LOGF(eLOG_Note, ("Test passed: %s", retval));
+ CORE_LOG(eLOG_Note, "Testing AS-IS message");
+ info.mx_no_header = 1/*true*/;
+ retval = CORE_SendMailEx("lavr",
+ "BAD SUBJECT SHOULD NOT APPEAR BUT IGNORED",
+ "From: yourself\n"
+ "To: yourself\n"
+ "Subject: AS-IS message\n"
+ "\n"
+ "AS-IS",
+ &info);
+ if (retval)
+ CORE_LOGF(eLOG_Fatal, ("Test failed: %s", retval));
+ CORE_LOG(eLOG_Note, "Test passed");
+
+ CORE_LOG(eLOG_Note, "Testing AS-IS custom sized message");
+ info.body_size = strlen(custom_body) - 11/*to ignore*/;
+ retval = CORE_SendMailEx("<lavr@pavo>",
+ "BAD SUBJECT SHOULD NOT APPEAR BUT IGNORED",
+ custom_body,
+ &info);
+ if (retval)
+ CORE_LOGF(eLOG_Fatal, ("Test failed: %s", retval));
+ CORE_LOG(eLOG_Note, "Test passed");
+
+ info.body_size = 0;
+ info.mx_no_header = 0;
+ info.mx_host = mx_host;
+
CORE_LOG(eLOG_Note, "Testing bad from");
strcpy(info.from, "blahblah@blahblah");
retval = CORE_SendMailEx("lavr", "CORE_SendMailEx Test", "Test", &info);
if (!retval)
CORE_LOG(eLOG_Error, "Test failed");
else
- CORE_LOGF(eLOG_Error, ("Test passed: %s", retval));
+ CORE_LOGF(eLOG_Note, ("Test passed: %s", retval));
CORE_LOG(eLOG_Note, "Testing bad magic");
info.magic_number = 0;
@@ -209,6 +246,12 @@ int main(void)
/*
* --------------------------------------------------------------------------
* $Log: test_ncbi_sendmail.c,v $
+ * Revision 6.11 2003/12/09 15:39:30 lavr
+ * Added new test of custom-sized message body
+ *
+ * Revision 6.10 2003/12/05 18:39:35 lavr
+ * Test multiple recipients and as-is message
+ *
* Revision 6.9 2003/05/14 03:58:43 lavr
* Match changes in respective APIs of the tests
*
diff --git a/corelib/morefile/FullPath.c b/corelib/morefile/FullPath.c
index 99c5bfb8..bb818b85 100644
--- a/corelib/morefile/FullPath.c
+++ b/corelib/morefile/FullPath.c
@@ -40,6 +40,8 @@
Institutes of Health, Bethesda, Maryland, USA.
*/
+/* C++ style comments converted to C comments by NCBI */
+
#ifndef WIN32
@@ -174,7 +176,7 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec,
pb.dirInfo.ioDrDirID = tempSpec.parID;
pb.dirInfo.ioFDirIndex = 0;
result = PBGetCatInfoSync(&pb);
- // Allow file/directory name at end of path to not exist.
+ /* Allow file/directory name at end of path to not exist. */
realResult = result;
if ( (result == noErr) || (result == fnfErr) )
{
@@ -218,7 +220,7 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec,
{
/* Return the length */
*fullPathLength = GetHandleSize(*fullPath);
- result = realResult; // return realResult in case it was fnfErr
+ result = realResult; /* return realResult in case it was fnfErr */
}
else
{
diff --git a/corelib/ncbifile.c b/corelib/ncbifile.c
index f3ff0336..45cac220 100644
--- a/corelib/ncbifile.c
+++ b/corelib/ncbifile.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/4/91
*
-* $Revision: 6.32 $
+* $Revision: 6.34 $
*
* File Description:
* portable file routines
@@ -43,6 +43,12 @@
* 11-27-94 Ostell moved includes to ncbiwin.h to avoid conflict MSC
*
* $Log: ncbifile.c,v $
+* Revision 6.34 2004/01/23 20:07:16 kans
+* fix to FileGets under Darwin, was losing last character if buffer was shorter than line being read
+*
+* Revision 6.33 2003/11/17 17:17:57 kans
+* changed C++ comments to C comments
+*
* Revision 6.32 2003/05/05 11:53:37 rsmith
* Codewarrior compiling for Win32 does not know about setmode or tempnam.
*
@@ -236,12 +242,12 @@ static char * _this_file = __FILE__;
#ifdef OS_MAC
#define INLINE_MOREFILES
-//#include "FullPath.h"
-//#include "MoreFilesExtra.h"
+/* #include "FullPath.h" */
+/* #include "MoreFilesExtra.h" */
#ifdef INLINE_MOREFILES
-// MoreFilesExtras.c
-// -----------------
+/* MoreFilesExtras.c */
+/* ----------------- */
/*
** Apple Macintosh Developer Technical Support
@@ -441,14 +447,14 @@ static OSErr MacPathname2FSSpec(const char *inPathname, FSSpec *outFSS)
return paramErr;
}
- err = HGetVol(NULL, &vRefNum, &dirID); // default volume and directory
+ err = HGetVol(NULL, &vRefNum, &dirID); /* default volume and directory */
if (err != noErr) return err;
len = strlen(inPathname);
p = strchr(inPathname, ':');
if (p == NULL) {
- // Partial pathname -- filename only
+ /* Partial pathname -- filename only */
Str31 filename;
assert(len <= 31);
c2pstrcpy(filename, inPathname);
@@ -457,21 +463,21 @@ static OSErr MacPathname2FSSpec(const char *inPathname, FSSpec *outFSS)
Str31 name;
int nameLen;
if (inPathname[0] == ':') {
- // Relative pathname including directory path
+ /* Relative pathname including directory path */
} else {
- // Absolute pathname
- //Str31 volName; // We would use Str28 if it was defined -- 27, plus 1 for ':'.
+ /* Absolute pathname */
+ /* Str31 volName; We would use Str28 if it was defined -- 27, plus 1 for ':'. */
nameLen = p - inPathname;
assert(nameLen <= 27);
name[0] = nameLen + 1;
- memcpy(name + 1, inPathname, nameLen + 1); // Copy the volume name and the colon.
+ memcpy(name + 1, inPathname, nameLen + 1); /* Copy the volume name and the colon. */
err = DetermineVRefNum(name, 0, &vRefNum);
if (err != noErr) return err;
dirID = 2;
}
- // vRefNum and dirID now specify the directory in which we should descend
- // the path pointed to by p (pointing to the first colon).
+ /* vRefNum and dirID now specify the directory in which we should descend
+ the path pointed to by p (pointing to the first colon). */
p++;
while (p != NULL && *p != '\0') {
char *q = strchr(p, ':');
@@ -493,7 +499,7 @@ static OSErr MacPathname2FSSpec(const char *inPathname, FSSpec *outFSS)
p = q + 1;
}
} else {
- q = strchr(p, '\0'); // go to end of string
+ q = strchr(p, '\0'); /* go to end of string */
nameLen = q - p;
assert(nameLen > 0);
assert(nameLen <= 31);
@@ -521,7 +527,7 @@ static OSErr MacFSSpec2FullPathname(const FSSpec *inFSS, char **outPathname)
err = FSpGetFullPath(inFSS, &fullPathLength, &h);
if (err != noErr) return err;
- assert(fullPathLength >= 2); // An absolute pathname must be at least two chars long
+ assert(fullPathLength >= 2); /* An absolute pathname must be at least two chars long */
fullPath = (char *)Nlm_Malloc(fullPathLength + 1);
if (fullPath == NULL) {
err = memFullErr;
@@ -755,7 +761,7 @@ NLM_EXTERN char * LIBCALL Nlm_FileGets (Nlm_CharPtr ptr, size_t size, FILE *fp)
ch = fgetc (fp);
count = 0;
tmp = ptr;
- while (ch != EOF && ch != '\0' && ch != '\n' && ch != '\r' && count < size - 1) {
+ while (ch != EOF && ch != '\0' && ch != '\n' && ch != '\r' && count < size - 2) {
*tmp = ch;
tmp++;
count++;
@@ -765,6 +771,10 @@ NLM_EXTERN char * LIBCALL Nlm_FileGets (Nlm_CharPtr ptr, size_t size, FILE *fp)
*tmp = '\n';
tmp++;
count++;
+ } else if (ch != EOF && ch != '\0') {
+ *tmp = ch;
+ tmp++;
+ count++;
}
*tmp = '\0';
if (count < 1)
@@ -1017,14 +1027,14 @@ NLM_EXTERN void LIBCALL Nlm_FileCreate (Nlm_CharPtr fileName, Nlm_CharPtr type,
if (fileName != NULL && fileName [0] != '\0') {
#ifdef OS_MAC
- // note: the following assumes either full pathname or that the current
- // directory is the proper location to find/create the file
+ /* note: the following assumes either full pathname or that the current
+ directory is the proper location to find/create the file */
Nlm_StringNCpy_0(temp, fileName, sizeof(temp));
Nlm_CtoPstr ( temp);
fError = FSMakeFSSpec( 0, 0, (StringPtr)temp, &spec);
- // file not found, so create it...
+ /* file not found, so create it... */
if( fError == fnfErr){
fType = Nlm_GetOSType (type, 'TEXT');
fCreator = Nlm_GetOSType (creator, ' ');
diff --git a/corelib/ncbilcl.lnx b/corelib/ncbilcl.lnx
index 6860b066..7aee6e44 100644
--- a/corelib/ncbilcl.lnx
+++ b/corelib/ncbilcl.lnx
@@ -29,7 +29,7 @@
*
* Version Creation Date: 8/1/94
*
-* $Revision: 6.8 $
+* $Revision: 6.9 $
*
* File Description:
* system dependent header
@@ -38,6 +38,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbilcl.lnx,v $
+* Revision 6.9 2004/01/21 22:31:20 ucko
+* Define PROC_X86_64 on x86-64 systems.
+*
* Revision 6.8 2002/11/22 20:05:04 lavr
* Configure HAVE_STRDUP and HAVE_STRCASECMP
*
@@ -100,6 +103,8 @@
#define PROC_SH /* ? */
#elif defined(__sparc__) || #cpu(sparc) || #cpu(sparc64) || #machine(sparc) || #machine(sparc64)
#define PROC_SPARC
+#elif defined(__x86_64__) || #cpu(x86_64)
+#define PROC_X86_64
#else
#warning Unknown processor type. Please define something appropriate.
#endif
diff --git a/corelib/ncbilcl.met b/corelib/ncbilcl.met
index 5c54087e..20a53eb1 100644
--- a/corelib/ncbilcl.met
+++ b/corelib/ncbilcl.met
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/31/94
*
-* $Revision: 6.10 $
+* $Revision: 6.11 $
*
* File Description:
* system dependent header
@@ -41,6 +41,9 @@
* ------- ---------- -----------------------------------------------------
*
* $Log: ncbilcl.met,v $
+* Revision 6.11 2003/11/07 18:32:41 rsmith
+* need pascal keyword on Mac builds.
+*
* Revision 6.10 2003/05/05 15:01:53 rsmith
* support for targeting Win32 systems with Codewarrior on Mac.
*
@@ -378,7 +381,6 @@ typedef int (FAR PASCAL *Nlm_FnPtr)();
#define far
#define huge
#define cdecl
-#define pascal
#define _pascal
#define _near
#define _far
diff --git a/corelib/ncbilcl.msw b/corelib/ncbilcl.msw
index d23ef63b..8664f8db 100644
--- a/corelib/ncbilcl.msw
+++ b/corelib/ncbilcl.msw
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/91
*
-* $Revision: 6.4 $
+* $Revision: 6.5 $
*
* File Description:
* system dependent header
@@ -39,6 +39,10 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbilcl.msw,v $
+* Revision 6.5 2003/12/24 18:37:55 vakatov
+* More consistent #define of FAR and near (as per D.Sinyakov's request).
+* Also, get rid of all WIN16-related code (it's just not supported nowdays).
+*
* Revision 6.4 2002/11/22 20:05:04 lavr
* Configure HAVE_STRDUP and HAVE_STRCASECMP
*
@@ -97,8 +101,8 @@
#error MAC applications can be built with MSVC++ compiler only
#endif
-#if !defined(WIN16) && !defined(WIN32) && !defined(_MAC)
-#error You must define one of: WIN16, WIN32, or _MAC
+#if !defined(WIN32) && !defined(_MAC)
+# error You must define one of: WIN32 or _MAC
#endif
@@ -112,36 +116,6 @@
#define WIN_MSWIN
-/*================[ Win16 ]===============*/
-#ifdef WIN16
-
-#define PLATFORM_NAME "Win16"
-#define PROC_I80X86
-
-#ifndef PASCAL
-#define PASCAL __pascal
-#define CDECL __cdecl
-#define EXPORT __export
-#endif
-
-#ifndef FAR
-#define FAR __far
-#define NEAR __near
-#endif
-
-typedef signed long Nlm_Int4, FAR * Nlm_Int4Ptr;
-typedef unsigned long Nlm_Uint4, FAR * Nlm_Uint4Ptr;
-#define Int4 Nlm_Int4
-#define Int4Ptr Nlm_Int4Ptr
-#define Uint4 Nlm_Uint4
-#define Uint4Ptr Nlm_Uint4Ptr
-#define INT4_MIN (-2147483647-1)
-#define INT4_MAX 2147483647
-#define UINT4_MAX 4294967295U
-
-#endif /* WIN16 */
-
-
/*================[ Win32 ]===============*/
#ifdef WIN32
@@ -150,6 +124,9 @@ typedef unsigned long Nlm_Uint4, FAR * Nlm_Uint4Ptr;
#ifndef FAR
#define FAR
+#endif
+
+#ifndef NEAR
#define NEAR
#endif
@@ -235,6 +212,8 @@ typedef unsigned long Nlm_Uint4, FAR * Nlm_Uint4Ptr;
#ifndef FAR
#define FAR
+#endif
+#ifndef NEAR
#define NEAR
#endif
diff --git a/corelib/ncbimisc.c b/corelib/ncbimisc.c
index 2ff56458..9abfbf7c 100644
--- a/corelib/ncbimisc.c
+++ b/corelib/ncbimisc.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 10/23/91
*
-* $Revision: 6.23 $
+* $Revision: 6.24 $
*
* File Description:
* miscellaneous functions
@@ -43,6 +43,9 @@
* 02-16-94 Epstein Retired Gestalt functions and definitions
*
* $Log: ncbimisc.c,v $
+* Revision 6.24 2003/12/03 02:10:23 kans
+* added defines missing from Mac OS 10.3 headers
+*
* Revision 6.23 2002/11/06 21:25:10 ucko
* Don't assume MIPS is IRIX, or HPPA is HP/UX; allow Linux too, for both.
*
@@ -155,6 +158,16 @@
#include <TextUtils.h>
#endif
+/* Missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+#ifdef __MWERKS__
+#ifdef OS_UNIX_DARWIN
+#ifndef __CHAR_BIT__
+#define __CHAR_BIT__ 8
+#endif
+#endif
+#endif
+/* End missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+
/*
TRIPLE_MARK is the character inserted before the thousands, millions,
billions, etc. digit positions. Change TRIPLE_MARK to a period
diff --git a/corelib/ncbistr.c b/corelib/ncbistr.c
index 2ff3b756..e9dc4349 100644
--- a/corelib/ncbistr.c
+++ b/corelib/ncbistr.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/4/91
*
-* $Revision: 6.12 $
+* $Revision: 6.13 $
*
* File Description:
* portable string routines
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbistr.c,v $
+* Revision 6.13 2003/12/03 02:10:24 kans
+* added defines missing from Mac OS 10.3 headers
+*
* Revision 6.12 2003/09/15 16:21:32 kans
* moved StringDoesHaveText from sqnutils3.c
*
@@ -161,6 +164,16 @@
#include <ncbi.h>
#include <ncbiwin.h>
+/* Missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+#ifdef __MWERKS__
+#ifdef OS_UNIX_DARWIN
+#ifndef __CHAR_BIT__
+#define __CHAR_BIT__ 8
+#endif
+#endif
+#endif
+/* End missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+
/* ClearDestString clears the destination string if the source is NULL. */
static Nlm_CharPtr NEAR Nlm_ClearDestString (Nlm_CharPtr to, size_t max)
{
diff --git a/corelib/ncbithr.c b/corelib/ncbithr.c
index 522dad84..a4cdd2d3 100644
--- a/corelib/ncbithr.c
+++ b/corelib/ncbithr.c
@@ -1,4 +1,4 @@
-/* $Id: ncbithr.c,v 6.37 2003/09/19 22:58:38 coulouri Exp $ */
+/* $Id: ncbithr.c,v 6.38 2003/12/04 18:02:43 rsmith Exp $ */
/*****************************************************************************
Name: ncbithr.c
@@ -35,6 +35,9 @@
Modification History:
-----------------------------------------------------------------------------
* $Log: ncbithr.c,v $
+* Revision 6.38 2003/12/04 18:02:43 rsmith
+* Move includes out of definition of NlmCPUNumber.
+*
* Revision 6.37 2003/09/19 22:58:38 coulouri
* NetBSD does not (yet?) have pthread_attr_setschedpolicy()
*
@@ -2562,24 +2565,26 @@ NLM_EXTERN Boolean NlmThreadsAvailable(void)
}
-NLM_EXTERN Int4 NlmCPUNumber(void)
-{
#if defined(OS_UNIX_DARWIN)
-
#include <mach/mach.h>
#include <mach/mach_host.h>
-#include <mach/host_info.h>
+#include <mach/host_info.h>
+#endif
-host_basic_info_data_t hinfo;
-mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
-kern_return_t rc;
+NLM_EXTERN Int4 NlmCPUNumber(void)
+{
+#if defined(OS_UNIX_DARWIN)
-rc=host_info( mach_host_self(), HOST_BASIC_INFO, (host_info_t) &hinfo, &hinfo_count);
+ host_basic_info_data_t hinfo;
+ mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
+ kern_return_t rc;
-if (rc!=KERN_SUCCESS)
- return -1;
+ rc=host_info( mach_host_self(), HOST_BASIC_INFO, (host_info_t) &hinfo, &hinfo_count);
+
+ if (rc != KERN_SUCCESS)
+ return -1;
-return hinfo.avail_cpus;
+ return hinfo.avail_cpus;
#elif defined(WIN32)
SYSTEM_INFO sysInfo;
diff --git a/corelib/ncbiwin.h b/corelib/ncbiwin.h
index 1b5b354c..2d070e48 100644
--- a/corelib/ncbiwin.h
+++ b/corelib/ncbiwin.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/91
*
-* $Revision: 6.8 $
+* $Revision: 6.9 $
*
* File Description:
* underlying window toolbox import
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbiwin.h,v $
+* Revision 6.9 2003/11/07 15:54:44 rsmith
+* Remove obsolete and uneeded Macintosh headers Types.h and Windows.h
+*
* Revision 6.8 2003/05/05 12:00:10 rsmith
* Change definitions before including windows.h when compiling with Codewarrior for Windows.
*
@@ -145,8 +148,10 @@
#include <Quickdraw.h>
#include <TextEdit.h>
#include <ToolUtils.h>
+/*
#include <Types.h>
#include <Windows.h>
+*/
#include <Sound.h>
#include <Folders.h>
#endif
diff --git a/corelib/tsprintf.c b/corelib/tsprintf.c
index 77bfee49..43dfaedc 100644
--- a/corelib/tsprintf.c
+++ b/corelib/tsprintf.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 07/10/96
*
-* $Revision: 6.9 $
+* $Revision: 6.10 $
*
* File Description:
* Memory- and MT-safe "sprintf()"
@@ -38,6 +38,9 @@
* --------------------------------------------------------------------------
*
* $Log: tsprintf.c,v $
+* Revision 6.10 2003/12/12 23:28:25 dondosha
+* Correction for Opteron, at suggestion from Nicolas Joly
+*
* Revision 6.9 2002/03/11 16:55:43 ivanov
* Fixed fp_count() -- error with round-up numbers
*
@@ -97,6 +100,13 @@
#include <tsprintf.h>
+#ifndef va_copy
+# ifdef __va_copy
+# define va_copy __va_copy
+# else
+# define va_copy(d,s) ((d) = (s))
+# endif
+#endif
/***********************************************************************
* INTERNAL
@@ -473,6 +483,7 @@ NLM_EXTERN const Char PNTR Nlm_TSPrintfArgs(const Char PNTR fmt, va_list args)
CharPtr temp_buf;
size_t cut_fmt;
char *x_fmt;
+ va_list save;
#ifdef OS_UNIX_PPCLINUX
/*
@@ -483,7 +494,9 @@ NLM_EXTERN const Char PNTR Nlm_TSPrintfArgs(const Char PNTR fmt, va_list args)
parsed_size = 2048;
cut_fmt = 0;
#else
- parsed_size = vsprintf_count_args(fmt, args, &cut_fmt);
+ va_copy(save, args);
+ parsed_size = vsprintf_count_args(fmt, save, &cut_fmt);
+ va_end(save);
if (parsed_size == 0)
return NULL;
#endif
diff --git a/ctools/asn_connection.c b/ctools/asn_connection.c
index b2b97d5b..9b5e0656 100644
--- a/ctools/asn_connection.c
+++ b/ctools/asn_connection.c
@@ -1,4 +1,4 @@
-/* $Id: asn_connection.c,v 1.4 2002/08/07 16:38:18 lavr Exp $
+/* $Id: asn_connection.c,v 1.5 2003/11/13 16:01:31 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -33,9 +33,6 @@
#include <connect/ncbi_service_connector.h>
#include <ctools/asn_connection.h>
#include "../connect/ncbi_priv.h"
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
#ifdef __cplusplus
@@ -174,6 +171,9 @@ CONN CreateAsnConn_Service(const char* service,
/*
* --------------------------------------------------------------------------
* $Log: asn_connection.c,v $
+ * Revision 1.5 2003/11/13 16:01:31 lavr
+ * Included headers revised
+ *
* Revision 1.4 2002/08/07 16:38:18 lavr
* EIO_ReadMethod enums changed accordingly; log moved to end
*
diff --git a/ctools/asn_connection.h b/ctools/asn_connection.h
index f3737dfc..bfeccaa7 100644
--- a/ctools/asn_connection.h
+++ b/ctools/asn_connection.h
@@ -1,7 +1,7 @@
-#ifndef NCBI_ASN_CONNECTION__H
-#define NCBI_ASN_CONNECTION__H
+#ifndef CTOOLS___ASN_CONNECTION__H
+#define CTOOLS___ASN_CONNECTION__H
-/* $Id: asn_connection.h,v 1.7 2003/04/11 17:46:29 siyan Exp $
+/* $Id: asn_connection.h,v 1.8 2003/11/13 15:58:47 lavr Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -123,6 +123,9 @@ CONN CreateAsnConn_Service
/*
* ===========================================================================
* $Log: asn_connection.h,v $
+ * Revision 1.8 2003/11/13 15:58:47 lavr
+ * Guard macro changed
+ *
* Revision 1.7 2003/04/11 17:46:29 siyan
* Added doxygen support
*
@@ -147,4 +150,4 @@ CONN CreateAsnConn_Service
* ==========================================================================
*/
-#endif /* NCBI_ASN_CONNECTION__H */
+#endif /* CTOOLS___ASN_CONNECTION__H */
diff --git a/data/lineages.txt b/data/lineages.txt
index d126aba2..0b33e23c 100644
--- a/data/lineages.txt
+++ b/data/lineages.txt
@@ -1,107 +1,78 @@
-12
-9 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Buchnera
+13
+9 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Buchnera
34 Bacteria; Proteobacteria; Deltaproteobacteria; Myxococcales; Cystobacterineae; Myxococcaceae; Myxococcus
139 Bacteria; Spirochaetes; Spirochaetales; Spirochaetaceae; Borrelia; Borrelia burgdorferi group
160 Bacteria; Spirochaetes; Spirochaetales; Spirochaetaceae; Treponema
173 Bacteria; Spirochaetes; Spirochaetales; Leptospiraceae; Leptospira
188 Bacteria; Proteobacteria; Alphaproteobacteria; Rhodospirillales; Rhodospirillaceae; Magnetospirillum
-192 Bacteria; Proteobacteria; Alphaproteobacteria; Rhodospirillales; Rhodospirillaceae; Azospirillum
197 Bacteria; Proteobacteria; Epsilonproteobacteria; Campylobacterales; Campylobacteraceae; Campylobacter
210 Bacteria; Proteobacteria; Epsilonproteobacteria; Campylobacterales; Helicobacteraceae; Helicobacter
-266 Bacteria; Proteobacteria; Alphaproteobacteria; Rhodobacterales; Rhodobacteraceae; Paracoccus
-271 Bacteria; Deinococcus-Thermus; Deinococci; Thermales; Thermaceae; Thermus
+263 Bacteria; Proteobacteria; Gammaproteobacteria; Thiotrichales; Francisellaceae; Francisella
274 Bacteria; Deinococcus-Thermus; Deinococci; Thermales; Thermaceae; Thermus
-285 Bacteria; Proteobacteria; Betaproteobacteria; Comamonadaceae; Comamonas
-287 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadaceae; Pseudomonas
-292 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiaceae; Burkholderia; Burkholderia cepacia complex
-294 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadaceae; Pseudomonas
-303 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadaceae; Pseudomonas
-305 Bacteria; Proteobacteria; Betaproteobacteria; Ralstoniaceae; Ralstonia
-316 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadaceae; Pseudomonas
-317 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadaceae; Pseudomonas
-339 Bacteria; Proteobacteria; Gammaproteobacteria; Xanthomonadaceae; Xanthomonas
-354 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadaceae; Azotobacter
-358 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium
-359 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium
+287 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadales; Pseudomonadaceae; Pseudomonas
+292 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiales; Burkholderiaceae; Burkholderia; Burkholderia cepacia complex
+294 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadales; Pseudomonadaceae; Pseudomonas
+303 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadales; Pseudomonadaceae; Pseudomonas
+305 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiales; Burkholderiaceae; Ralstonia
+316 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadales; Pseudomonadaceae; Pseudomonas
+317 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadales; Pseudomonadaceae; Pseudomonas
+339 Bacteria; Proteobacteria; Gammaproteobacteria; Xanthomonadales; Xanthomonadaceae; Xanthomonas
+354 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadales; Pseudomonadaceae; Azotobacter
+358 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium/Agrobacterium group; Agrobacterium
375 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Bradyrhizobiaceae; Bradyrhizobium
-381 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Phyllobacteriaceae; Mesorhizobium
-382 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Sinorhizobium
-384 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium
-394 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium
-408 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Methylobacteriaceae; Methylobacterium
+382 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Sinorhizobium/Ensifer group; Sinorhizobium
+384 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium/Agrobacterium group; Rhizobium
+394 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium/Agrobacterium group; Rhizobium
446 Bacteria; Proteobacteria; Gammaproteobacteria; Legionellales; Legionellaceae; Legionella
-471 Bacteria; Proteobacteria; Gammaproteobacteria; Moraxellaceae; Acinetobacter
-480 Bacteria; Proteobacteria; Gammaproteobacteria; Moraxellaceae; Moraxella
+480 Bacteria; Proteobacteria; Gammaproteobacteria; Pseudomonadales; Moraxellaceae; Moraxella
485 Bacteria; Proteobacteria; Betaproteobacteria; Neisseriales; Neisseriaceae; Neisseria
487 Bacteria; Proteobacteria; Betaproteobacteria; Neisseriales; Neisseriaceae; Neisseria
-510 Bacteria; Proteobacteria; Betaproteobacteria; Ralstoniaceae; Ralstonia
-518 Bacteria; Proteobacteria; Betaproteobacteria; Alcaligenaceae; Bordetella
-520 Bacteria; Proteobacteria; Betaproteobacteria; Alcaligenaceae; Bordetella
-542 Bacteria; Proteobacteria; Alphaproteobacteria; Sphingomonadales; Sphingomonadaceae; Zymomonas
-546 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Citrobacter
-548 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Enterobacter
-549 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Pantoea
-550 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Enterobacter
-552 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Erwinia
-554 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Pectobacterium
-556 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Pectobacterium
-562 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Escherichia
-571 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Klebsiella
-573 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Klebsiella
-584 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Proteus
-585 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Proteus
-592 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Salmonella
-601 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Salmonella
-602 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Salmonella
-615 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Serratia
-621 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Shigella
-622 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Shigella
-623 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Shigella
-624 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Shigella
-630 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Yersinia
-632 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Yersinia
-633 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Yersinia
-644 Bacteria; Proteobacteria; Gammaproteobacteria; Aeromonadaceae; Aeromonas
-666 Bacteria; Proteobacteria; Gammaproteobacteria; Vibrionaceae; Vibrio
-669 Bacteria; Proteobacteria; Gammaproteobacteria; Vibrionaceae; Vibrio
-670 Bacteria; Proteobacteria; Gammaproteobacteria; Vibrionaceae; Vibrio
-672 Bacteria; Proteobacteria; Gammaproteobacteria; Vibrionaceae; Vibrio
-714 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellaceae; Actinobacillus
-715 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellaceae; Actinobacillus
-727 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellaceae; Haemophilus
-747 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellaceae; Pasteurella
+518 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiales; Alcaligenaceae; Bordetella
+520 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiales; Alcaligenaceae; Bordetella
+529 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Brucellaceae; Ochrobactrum
+549 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Pantoea
+550 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Enterobacter
+552 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Erwinia
+554 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Pectobacterium
+562 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Escherichia
+571 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Klebsiella
+573 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Klebsiella
+602 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Salmonella
+615 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Serratia
+623 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Shigella
+630 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Yersinia
+632 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Yersinia
+644 Bacteria; Proteobacteria; Gammaproteobacteria; Aeromonadales; Aeromonadaceae; Aeromonas
+666 Bacteria; Proteobacteria; Gammaproteobacteria; Vibrionales; Vibrionaceae; Vibrio
+670 Bacteria; Proteobacteria; Gammaproteobacteria; Vibrionales; Vibrionaceae; Vibrio
+672 Bacteria; Proteobacteria; Gammaproteobacteria; Vibrionales; Vibrionaceae; Vibrio
+714 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellales; Pasteurellaceae; Actinobacillus
+715 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellales; Pasteurellaceae; Actinobacillus
+727 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellales; Pasteurellaceae; Haemophilus
+731 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellales; Pasteurellaceae; Histophilus
+747 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellales; Pasteurellaceae; Pasteurella
770 Bacteria; Proteobacteria; Alphaproteobacteria; Rickettsiales; Anaplasmataceae; Anaplasma
-777 Bacteria; Proteobacteria; Gammaproteobacteria; Legionellales; Coxiellaceae; Coxiella
-781 Bacteria; Proteobacteria; Alphaproteobacteria; Rickettsiales; Rickettsiaceae; Rickettsieae; Rickettsia; spotted fever group
782 Bacteria; Proteobacteria; Alphaproteobacteria; Rickettsiales; Rickettsiaceae; Rickettsieae; Rickettsia; typhus group
813 Bacteria; Chlamydiae; Chlamydiales; Chlamydiaceae; Chlamydia
817 Bacteria; Bacteroidetes; Bacteroides (class); Bacteroidales; Bacteroidaceae; Bacteroides
837 Bacteria; Bacteroidetes; Bacteroides (class); Bacteroidales; Porphyromonadaceae; Porphyromonas
-851 Bacteria; Fusobacteria; Fusobacteria (class); Fusobacterales; Fusobacteriaceae; Fusobacterium
-870 Bacteria; Proteobacteria; Gammaproteobacteria; Cardiobacteriaceae; Dichelobacter
-881 Bacteria; Proteobacteria; Deltaproteobacteria; Desulfovibrionales; Desulfovibrionaceae; Desulfovibrio
-915 Bacteria; Proteobacteria; Betaproteobacteria; Nitrosomonadales; Nitrosomonadaceae; Nitrosomonas
-920 Bacteria; Proteobacteria; Gammaproteobacteria; Acidithiobacillus
+851 Bacteria; Fusobacteria; Fusobacterales; Fusobacteriaceae; Fusobacterium
+876 Bacteria; Proteobacteria; Deltaproteobacteria; Desulfovibrionales; Desulfovibrionaceae; Desulfovibrio
+920 Bacteria; Proteobacteria; Gammaproteobacteria; Acidithiobacillales; Acidithiobacillaceae; Acidithiobacillus
948 Bacteria; Proteobacteria; Alphaproteobacteria; Rickettsiales; Anaplasmataceae; Anaplasma; phagocytophilum group
-1061 Bacteria; Proteobacteria; Alphaproteobacteria; Rhodobacterales; Rhodobacteraceae; Rhodobacter
1063 Bacteria; Proteobacteria; Alphaproteobacteria; Rhodobacterales; Rhodobacteraceae; Rhodobacter
1085 Bacteria; Proteobacteria; Alphaproteobacteria; Rhodospirillales; Rhodospirillaceae; Rhodospirillum
1097 Bacteria; Chlorobi; Chlorobia; Chlorobiales; Chlorobiaceae; Chlorobium
1108 Bacteria; Chloroflexi; Chloroflexales; Chloroflexaceae; Chloroflexus
1126 Bacteria; Cyanobacteria; Chroococcales; Microcystis
-1140 Bacteria; Cyanobacteria; Chroococcales; Synechococcus
-1148 Bacteria; Cyanobacteria; Chroococcales; Synechocystis
-1172 Bacteria; Cyanobacteria; Nostocales; Nostocaceae; Anabaena
1206 Bacteria; Cyanobacteria; Oscillatoriales; Trichodesmium
-1219 Bacteria; Cyanobacteria; Prochlorophytes; Prochlorococcaceae; Prochlorococcus
1245 Bacteria; Firmicutes; Lactobacillales; Leuconostoc
1247 Bacteria; Firmicutes; Lactobacillales; Oenococcus
+1265 Bacteria; Firmicutes; Clostridia; Clostridiales; Lachnospiraceae; Ruminococcus
1280 Bacteria; Firmicutes; Bacillales; Staphylococcus
1282 Bacteria; Firmicutes; Bacillales; Staphylococcus
1299 Bacteria; Deinococcus-Thermus; Deinococci; Deinococcales; Deinococcaceae; Deinococcus
-1302 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
1303 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
-1304 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
1307 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
1308 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
1309 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
@@ -109,153 +80,152 @@
1313 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
1314 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
1334 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
+1336 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
1351 Bacteria; Firmicutes; Lactobacillales; Enterococcaceae; Enterococcus
1352 Bacteria; Firmicutes; Lactobacillales; Enterococcaceae; Enterococcus
1358 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Lactococcus
-1390 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus
1392 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus; Bacillus cereus group
-1393 Bacteria; Firmicutes; Bacillales; Paenibacillaceae; Brevibacillus
1396 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus; Bacillus cereus group
-1397 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus
1402 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus
-1404 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus
-1421 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus
-1422 Bacteria; Firmicutes; Bacillales; Geobacillus
+1422 Bacteria; Firmicutes; Bacillales; Bacillaceae; Geobacillus
1423 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus
1428 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus; Bacillus cereus group
1488 Bacteria; Firmicutes; Clostridia; Clostridiales; Clostridiaceae; Clostridium
-1491 Bacteria; Firmicutes; Clostridia; Clostridiales; Clostridiaceae; Clostridium
1496 Bacteria; Firmicutes; Clostridia; Clostridiales; Clostridiaceae; Clostridium
-1501 Bacteria; Firmicutes; Clostridia; Clostridiales; Clostridiaceae; Clostridium
1502 Bacteria; Firmicutes; Clostridia; Clostridiales; Clostridiaceae; Clostridium
1515 Bacteria; Firmicutes; Clostridia; Clostridiales; Clostridiaceae; Clostridium
-1582 Bacteria; Firmicutes; Lactobacillales; Lactobacillaceae; Lactobacillus
+1575 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Micrococcineae; Microbacteriaceae; Leifsonia
+1580 Bacteria; Firmicutes; Lactobacillales; Lactobacillaceae; Lactobacillus
1584 Bacteria; Firmicutes; Lactobacillales; Lactobacillaceae; Lactobacillus
-1587 Bacteria; Firmicutes; Lactobacillales; Lactobacillaceae; Lactobacillus
1590 Bacteria; Firmicutes; Lactobacillales; Lactobacillaceae; Lactobacillus
-1599 Bacteria; Firmicutes; Lactobacillales; Lactobacillaceae; Lactobacillus
1639 Bacteria; Firmicutes; Bacillales; Listeriaceae; Listeria
1642 Bacteria; Firmicutes; Bacillales; Listeriaceae; Listeria
1718 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Corynebacterineae; Corynebacteriaceae; Corynebacterium
+1719 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Corynebacterineae; Corynebacteriaceae; Corynebacterium
1764 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Corynebacterineae; Mycobacteriaceae; Mycobacterium; Mycobacterium avium complex (MAC)
1765 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Corynebacterineae; Mycobacteriaceae; Mycobacterium; Mycobacterium tuberculosis complex
1769 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Corynebacterineae; Mycobacteriaceae; Mycobacterium
1772 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Corynebacterineae; Mycobacteriaceae; Mycobacterium
1773 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Corynebacterineae; Mycobacteriaceae; Mycobacterium; Mycobacterium tuberculosis complex
1833 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Corynebacterineae; Nocardiaceae; Rhodococcus
-1836 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Pseudonocardineae; Pseudonocardiaceae; Saccharopolyspora
-1895 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Streptomycineae; Streptomycetaceae; Streptomyces
-1901 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Streptomycineae; Streptomycetaceae; Streptomyces
1902 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Streptomycineae; Streptomycetaceae; Streptomyces
-1911 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Streptomycineae; Streptomycetaceae; Streptomyces
1916 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Streptomycineae; Streptomycetaceae; Streptomyces
-2095 Bacteria; Firmicutes; Mollicutes; Entomoplasmatales; Entomoplasmataceae
-2096 Bacteria; Firmicutes; Mollicutes; Mycoplasmataceae; Mycoplasma
+2095 Bacteria; Firmicutes; Mollicutes; Mycoplasmataceae; Mycoplasma
2097 Bacteria; Firmicutes; Mollicutes; Mycoplasmataceae; Mycoplasma
2098 Bacteria; Firmicutes; Mollicutes; Mycoplasmataceae; Mycoplasma
-2104 Bacteria; Firmicutes; Mollicutes; Mycoplasmataceae; Mycoplasma
-2107 Bacteria; Firmicutes; Mollicutes; Mycoplasmataceae; Mycoplasma
2130 Bacteria; Firmicutes; Mollicutes; Mycoplasmataceae; Ureaplasma
-2190 Archaea; Euryarchaeota; Methanococci; Methanococcales; Methanocaldococcaceae; Methanocaldococcus
-2208 Archaea; Euryarchaeota; Methanococci; Methanosarcinales; Methanosarcinaceae; Methanosarcina
-2209 Archaea; Euryarchaeota; Methanococci; Methanosarcinales; Methanosarcinaceae; Methanosarcina
-2214 Archaea; Euryarchaeota; Methanococci; Methanosarcinales; Methanosarcinaceae; Methanosarcina
+2208 Archaea; Euryarchaeota; Methanomicrobia; Methanosarcinales; Methanosarcinaceae; Methanosarcina
+2209 Archaea; Euryarchaeota; Methanomicrobia; Methanosarcinales; Methanosarcinaceae; Methanosarcina
+2214 Archaea; Euryarchaeota; Methanomicrobia; Methanosarcinales; Methanosarcinaceae; Methanosarcina
2234 Archaea; Euryarchaeota; Archaeoglobi; Archaeoglobales; Archaeoglobaceae; Archaeoglobus
2238 Archaea; Euryarchaeota; Halobacteria; Halobacteriales; Halobacteriaceae; Haloarcula
-2242 Archaea; Euryarchaeota; Halobacteria; Halobacteriales; Halobacteriaceae; Halobacterium
-2246 Archaea; Euryarchaeota; Halobacteria; Halobacteriales; Halobacteriaceae; Haloferax
+2247 Archaea; Euryarchaeota; Halobacteria; Halobacteriales; Halobacteriaceae; Halorubrum
2261 Archaea; Euryarchaeota; Thermococci; Thermococcales; Thermococcaceae; Pyrococcus
-2285 Archaea; Crenarchaeota; Thermoprotei; Sulfolobales; Sulfolobaceae; Sulfolobus
2287 Archaea; Crenarchaeota; Thermoprotei; Sulfolobales; Sulfolobaceae; Sulfolobus
-2303 Archaea; Euryarchaeota; Thermoplasmata; Thermoplasmatales; Thermoplasmataceae; Thermoplasma
-2320 Archaea; Euryarchaeota; Methanopyri; Methanopyrales; Methanopyraceae; Methanopyrus
2336 Bacteria; Thermotogae; Thermotogales; Thermotogaceae; Thermotoga
-2371 Bacteria; Proteobacteria; Gammaproteobacteria; Xanthomonadaceae; Xylella
-2711 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Sapindales; Rutaceae; Citrus
-2762 Eukaryota; Glaucocystophyceae; Cyanophoraceae; Cyanophora
-2771 Eukaryota; Rhodophyta; Bangiophyceae; Porphyridiales; Porphyridiaceae; Cyanidium
+2371 Bacteria; Proteobacteria; Gammaproteobacteria; Xanthomonadales; Xanthomonadaceae; Xylella
+2711 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Sapindales; Rutaceae; Citrus
2777 Eukaryota; Rhodophyta; Florideophyceae; Gracilariales; Gracilariaceae; Gracilaria
-2787 Eukaryota; Rhodophyta; Bangiophyceae; Bangiales; Bangiaceae; Porphyra
2788 Eukaryota; Rhodophyta; Bangiophyceae; Bangiales; Bangiaceae; Porphyra
-2839 Eukaryota; stramenopiles; Bacillariophyta; Coscinodiscophyceae; Biddulphiophycidae; Eupodiscales; Eupodiscaceae; Odontella
2850 Eukaryota; stramenopiles; Bacillariophyta; Bacillariophyceae; Bacillariophycidae; Naviculales; Phaeodactylaceae; Phaeodactylum
+2903 Eukaryota; Haptophyceae; Isochrysidales; Emiliania
+2926 Eukaryota; Alveolata; Dinophyceae; Gonyaulacales; Gonyaulacaceae; Alexandrium
+2961 Eukaryota; Alveolata; Dinophyceae; Gymnodiniales; Gymnodiniaceae; Amphidinium
+2972 Eukaryota; Alveolata; Dinophyceae; Pyrocystales; Pyrocystis
3012 Eukaryota; stramenopiles; Phaeophyceae; Fucales; Fucaceae; Fucus
-3039 Eukaryota; Euglenozoa; Euglenida; Euglenales; Euglena
3046 Eukaryota; Viridiplantae; Chlorophyta; Chlorophyceae; Volvocales; Dunaliellaceae; Dunaliella
3055 Eukaryota; Viridiplantae; Chlorophyta; Chlorophyceae; Volvocales; Chlamydomonadaceae; Chlamydomonas
-3067 Eukaryota; Viridiplantae; Chlorophyta; Chlorophyceae; Volvocales; Volvocaceae; Volvox
-3077 Eukaryota; Viridiplantae; Chlorophyta; Trebouxiophyceae; Chlorellales; Chlorellaceae; Chlorella
3190 Eukaryota; Viridiplantae; Chlorophyta; Prasinophyceae; Chlorodendrales; Chlorodendraceae; Scherffelia
3197 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Marchantiophyta; Marchantiopsida; Marchantiidae; Marchantiales; Marchantiineae; Marchantiaceae; Marchantia
3218 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Bryophyta; Bryopsida; Funariidae; Funariales; Funariaceae; Physcomitrella
3225 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Bryophyta; Bryopsida; Dicranidae; Dicranales; Ditrichaceae; Ceratodon
-3240 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Psilotophyta; Psilotales; Psilotaceae; Psilotum
+3311 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Ginkgophyta; Ginkgoales; Ginkgoaceae; Ginkgo
3329 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Coniferopsida; Coniferales; Pinaceae; Picea
-3349 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Coniferopsida; Coniferales; Pinaceae; Pinus; Pinus
-3350 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Coniferopsida; Coniferales; Pinaceae; Pinus; Pinus
+3347 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Coniferopsida; Coniferales; Pinaceae; Pinus; Pinus
3352 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Coniferopsida; Coniferales; Pinaceae; Pinus; Pinus
3357 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Coniferopsida; Coniferales; Pinaceae; Pseudotsuga
3369 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Coniferopsida; Coniferales; Cupressaceae; Cryptomeria
-3505 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fagales; Betulaceae; Betula
-3544 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllidae; Caryophyllales; Aizoaceae; Mesembryanthemum
-3562 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllidae; Caryophyllales; Chenopodiaceae; Spinacia
-3570 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllidae; Caryophyllales; Caryophyllaceae; Dianthus
-3635 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Malvales; Malvaceae; Malvoideae; Gossypium
-3654 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Cucurbitales; Cucurbitaceae; Citrullus
-3656 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Cucurbitales; Cucurbitaceae; Cucumis
-3659 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Cucurbitales; Cucurbitaceae; Cucumis
-3702 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Arabidopsis
-3707 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Brassica
-3708 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Brassica
-3711 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Brassica
-3712 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Brassica
-3726 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Raphanus
-3747 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Rosales; Rosaceae; Rosoideae; Fragaria
-3750 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Rosales; Rosaceae; Maloideae; Malus
-3755 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Rosales; Rosaceae; Amygdaloideae; Prunus
-3760 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Rosales; Rosaceae; Amygdaloideae; Prunus
-3827 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Cicereae; Cicer
-3847 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Glycine
-3873 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Genisteae; Lupinus
-3879 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Trifolieae; Medicago
-3880 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Trifolieae; Medicago
-3885 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Phaseolus
-3888 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Vicieae; Pisum
-3906 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Vicieae; Vicia
-3917 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Vigna
-3981 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Malpighiales; Euphorbiaceae; Hevea
-3983 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Malpighiales; Euphorbiaceae; Manihot
-3988 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Malpighiales; Euphorbiaceae; Ricinus
-3993 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Malpighiales; Euphorbiaceae; Euphorbia
-4039 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; campanulids; Apiales; Apiaceae; Daucus
-4043 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; campanulids; Apiales; Apiaceae; Petroselinum
-4058 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Gentianales; Apocynaceae; Rauvolfioideae; Vinceae; Catharanthus
-4072 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Capsicum
-4081 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Solanum; Lycopersicon
-4092 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Nicotiana
-4096 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Nicotiana
-4097 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Nicotiana
-4102 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Petunia
-4113 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Solanum
-4120 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Convolvulaceae; Ipomoea
-4151 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Lamiales; Antirrhinaceae; Antirrhineae; Antirrhinum
-4232 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; campanulids; Asterales; Asteraceae; Asteroideae; Heliantheae; Helianthus
-4236 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; campanulids; Asterales; Asteraceae; Lactuceae; Lactuca
+3382 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Gnetophyta; Gnetopsida; Gnetales; Gnetaceae; Gnetum
+3467 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; Ranunculales; Papaveraceae; Eschscholzioideae; Eschscholzia
+3505 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fagales; Betulaceae; Betula
+3544 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllales; Aizoaceae; Mesembryanthemum
+3562 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllales; Amaranthaceae; Spinacia
+3570 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllales; Caryophyllaceae; Dianthus
+3605 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Vitaceae; Vitis
+3634 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Malvales; Malvaceae; Malvoideae; Gossypium
+3635 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Malvales; Malvaceae; Malvoideae; Gossypium
+3641 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Malvales; Malvaceae; Byttnerioideae; Theobroma
+3649 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Caricaceae; Carica
+3654 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Cucurbitales; Cucurbitaceae; Citrullus
+3656 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Cucurbitales; Cucurbitaceae; Cucumis
+3659 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Cucurbitales; Cucurbitaceae; Cucumis
+3693 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Salicaceae; Saliceae; Populus
+3695 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Salicaceae; Saliceae; Populus
+3702 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Arabidopsis
+3707 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Brassica
+3708 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Brassica
+3711 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Brassica
+3712 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Brassica
+3726 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Raphanus
+3747 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Rosales; Rosaceae; Rosoideae; Fragaria
+3750 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Rosales; Rosaceae; Maloideae; Malus
+3755 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Rosales; Rosaceae; Amygdaloideae; Prunus
+3760 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Rosales; Rosaceae; Amygdaloideae; Prunus
+3818 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Aeschynomeneae; Arachis
+3827 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Cicereae; Cicer
+3847 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Glycine
+3870 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Genisteae; Lupinus
+3873 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Genisteae; Lupinus
+3879 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Trifolieae; Medicago
+3880 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Trifolieae; Medicago
+3885 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Phaseolus
+3886 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Phaseolus
+3888 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Vicieae; Pisum
+3895 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Robinieae; Sesbania
+3899 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Trifolieae; Trifolium
+3906 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Vicieae; Vicia
+3917 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Vigna
+3981 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Euphorbiaceae; Crotonoideae; Micrandreae; Hevea
+3983 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Euphorbiaceae; Crotonoideae; Manihoteae; Manihot
+3988 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Euphorbiaceae; Acalyphoideae; Acalypheae; Ricinus
+3993 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Euphorbiaceae; Euphorbioideae; Euphorbieae; Euphorbia
+4006 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Linaceae; Linum
+4039 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Apiales; Apiaceae; Apioideae; Scandiceae; Daucinae; Daucus
+4045 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Apiales; Apiaceae; Apioideae; apioid superclade; Apium clade; Apium
+4054 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Apiales; Araliaceae; Panax
+4072 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Capsicum
+4081 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Solanum; Lycopersicon
+4096 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Nicotiana
+4097 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Nicotiana
+4100 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Nicotiana
+4102 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Petunia
+4113 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Solanum
+4120 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Convolvulaceae; Ipomoea
+4146 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Lamiales; Oleaceae; Olea
+4151 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Lamiales; Antirrhinaceae; Antirrhineae; Antirrhinum
+4182 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Lamiales; Pedaliaceae; Sesamum
+4232 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Asterales; Asteraceae; Asteroideae; Heliantheae; Helianthus
+4236 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Asterales; Asteraceae; Cichorioideae; Cichorieae; Lactuca
4498 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Aveneae; Avena
4513 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Triticeae; Hordeum
4530 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Ehrhartoideae; Oryzeae; Oryza
+4543 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACCAD clade; Panicoideae; Paniceae; Pennisetum
+4547 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACCAD clade; Panicoideae; Andropogoneae; Saccharum
4550 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Triticeae; Secale
-4558 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACC clade; Panicoideae; Andropogoneae; Sorghum
-4560 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACC clade; Panicoideae; Andropogoneae; Sorghum
+4558 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACCAD clade; Panicoideae; Andropogoneae; Sorghum
+4560 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACCAD clade; Panicoideae; Andropogoneae; Sorghum
4565 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Triticeae; Triticum
4568 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Triticeae; Triticum
4571 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Triticeae; Triticum
4573 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Triticeae; Aegilops
-4577 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACC clade; Panicoideae; Andropogoneae; Zea
+4577 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACCAD clade; Panicoideae; Andropogoneae; Zea
4641 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Zingiberales; Musaceae; Musa
4679 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Asparagales; Alliaceae; Allium
+4682 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Asparagales; Alliaceae; Allium
+4686 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Asparagales; Asparagaceae; Asparagus
4754 Eukaryota; Fungi; Ascomycota; Pneumocystidomycetes; Pneumocystidaceae; Pneumocystis
4787 Eukaryota; stramenopiles; Oomycetes; Pythiales; Pythiaceae; Phytophthora
+4790 Eukaryota; stramenopiles; Oomycetes; Pythiales; Pythiaceae; Phytophthora
4876 Eukaryota; Fungi; Glomeromycota; Glomeromycetes; Glomerales; Glomeraceae; Glomus
4896 Eukaryota; Fungi; Ascomycota; Schizosaccharomycetes; Schizosaccharomycetales; Schizosaccharomycetaceae; Schizosaccharomyces
4905 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Pichia
@@ -272,9 +242,10 @@
5059 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; mitosporic Trichocomaceae; Aspergillus
5061 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; mitosporic Trichocomaceae; Aspergillus
5062 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; mitosporic Trichocomaceae; Aspergillus
+5068 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; mitosporic Trichocomaceae; Aspergillus
5085 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; mitosporic Trichocomaceae; Aspergillus
-5141 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Sordariales; Sordariaceae; Neurospora
-5145 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Sordariales; Lasiosphaeriaceae; Podospora
+5116 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Sordariomycetidae; Diaporthales; Valsaceae; Cryphonectria-Endothia complex; Cryphonectria
+5141 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Sordariomycetidae; Sordariales; Sordariaceae; Neurospora
5180 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Leotiomycetes; Helotiales; Sclerotiniaceae; Sclerotinia
5207 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Heterobasidiomycetes; Tremellomycetidae; Tremellales; Tremellaceae; Filobasidiella
5270 Eukaryota; Fungi; Basidiomycota; Ustilaginomycetes; Ustilaginomycetidae; Ustilaginales; Ustilaginaceae; Ustilago
@@ -283,6 +254,7 @@
5322 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Agaricales; Pleurotaceae; Pleurotus
5334 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Agaricales; Schizophyllaceae; Schizophyllum
5341 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Agaricales; Agaricaceae; Agaricus
+5346 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Agaricales; Psathyrellaceae; Coprinopsis
5457 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Sordariomycetes incertae sedis; Phyllachorales; Phyllachoraceae; Glomerella
5466 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Sordariomycetes incertae sedis; Phyllachorales; Phyllachoraceae; mitosporic Phyllachoraceae; Colletotrichum
5476 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; mitosporic Saccharomycetales; Candida
@@ -290,24 +262,20 @@
5482 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; mitosporic Saccharomycetales; Candida
5499 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Dothideomycetes et Chaetothyriomycetes incertae sedis; Mycosphaerellaceae; mitosporic Mycosphaerellaceae; Cladosporium
5501 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Onygenales; mitosporic Onygenales; Coccidioides
-5507 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreales; mitosporic Hypocreales; Fusarium; Fusarium oxysporum complex
-5514 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreales; mitosporic Hypocreales; Fusarium
-5518 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreales; Nectriaceae; Gibberella
-5530 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreales; Clavicipitaceae; mitosporic Clavicipitaceae; Metarhizium
-5544 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreales; mitosporic Hypocreales; Trichoderma
-5656 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Crithidia
+5507 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; mitosporic Hypocreales; Fusarium; Fusarium oxysporum complex
+5514 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; mitosporic Hypocreales; Fusarium
+5518 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; Nectriaceae; Gibberella
+5530 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; Clavicipitaceae; mitosporic Clavicipitaceae; Metarhizium
+5544 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; Hypocreaceae; Hypocrea
+5660 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Leishmania; Leishmania braziliensis species complex
5661 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Leishmania
5664 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Leishmania
-5665 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Leishmania
5671 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Leishmania
-5689 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Leishmania; lizard Leishmania
5691 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Trypanosoma
5693 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Trypanosoma; Schizotrypanum
5722 Eukaryota; Parabasalidea; Trichomonadida; Trichomonadidae; Trichomonadinae; Trichomonas
5741 Eukaryota; Diplomonadida; Hexamitidae; Giardiinae; Giardia
-5755 Eukaryota; Acanthamoebidae; Acanthamoeba
5759 Eukaryota; Entamoebidae; Entamoeba
-5791 Eukaryota; Mycetozoa; Myxogastria; Myxogastromycetidae; Physarida; Physarum
5802 Eukaryota; Alveolata; Apicomplexa; Coccidia; Eimeriida; Eimeriidae; Eimeria
5807 Eukaryota; Alveolata; Apicomplexa; Coccidia; Eimeriida; Cryptosporidiidae; Cryptosporidium
5811 Eukaryota; Alveolata; Apicomplexa; Coccidia; Eimeriida; Sarcocystidae; Toxoplasma
@@ -316,13 +284,14 @@
5833 Eukaryota; Alveolata; Apicomplexa; Haemosporida; Plasmodium
5855 Eukaryota; Alveolata; Apicomplexa; Haemosporida; Plasmodium
5861 Eukaryota; Alveolata; Apicomplexa; Haemosporida; Plasmodium
-5874 Eukaryota; Alveolata; Apicomplexa; Piroplasmida; Theileriidae; Theileria
+5875 Eukaryota; Alveolata; Apicomplexa; Piroplasmida; Theileriidae; Theileria
5888 Eukaryota; Alveolata; Ciliophora; Oligohymenophorea; Peniculida; Paramecium
-5908 Eukaryota; Alveolata; Ciliophora; Oligohymenophorea; Hymenostomatida; Tetrahymenina; Tetrahymena
5911 Eukaryota; Alveolata; Ciliophora; Oligohymenophorea; Hymenostomatida; Tetrahymenina; Tetrahymena
5932 Eukaryota; Alveolata; Ciliophora; Oligohymenophorea; Hymenostomatida; Ophryoglenina; Ichthyophthirius
-6035 Eukaryota; Fungi; Microsporidia; Unikaryonidae; Encephalitozoon
-6087 Eukaryota; Metazoa; Cnidaria; Hydrozoa; Hydroida; Anthomedusae; Hydridae; Hydra
+5936 Eukaryota; Alveolata; Ciliophora; Spirotrichea; Hypotrichia; Euplotida; Euplotidae; Moneuplotes
+6085 Eukaryota; Metazoa; Cnidaria; Hydrozoa; Hydroida; Anthomedusae; Hydridae; Hydra
+6100 Eukaryota; Metazoa; Cnidaria; Hydrozoa; Hydroida; Leptomedusae; Aequoreidae; Aequorea
+6161 Eukaryota; Metazoa; Platyhelminthes; Turbellaria; Seriata; Tricladida; Paludicola; Dugesiidae; Dugesia
6182 Eukaryota; Metazoa; Platyhelminthes; Trematoda; Digenea; Strigeidida; Schistosomatoidea; Schistosomatidae; Schistosoma
6183 Eukaryota; Metazoa; Platyhelminthes; Trematoda; Digenea; Strigeidida; Schistosomatoidea; Schistosomatidae; Schistosoma
6204 Eukaryota; Metazoa; Platyhelminthes; Cestoda; Eucestoda; Cyclophyllidea; Taeniidae; Taenia
@@ -331,58 +300,64 @@
6238 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Rhabditoidea; Rhabditidae; Peloderinae; Caenorhabditis
6239 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Rhabditoidea; Rhabditidae; Peloderinae; Caenorhabditis
6248 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Panagrolaimoidea; Strongyloididae; Strongyloides
+6252 Eukaryota; Metazoa; Nematoda; Chromadorea; Ascaridida; Ascaridoidea; Ascarididae; Ascaris
6253 Eukaryota; Metazoa; Nematoda; Chromadorea; Ascaridida; Ascaridoidea; Ascarididae; Ascaris
6265 Eukaryota; Metazoa; Nematoda; Chromadorea; Ascaridida; Ascaridoidea; Toxocaridae; Toxocara
6279 Eukaryota; Metazoa; Nematoda; Chromadorea; Spirurida; Filarioidea; Onchocercidae; Brugia
6282 Eukaryota; Metazoa; Nematoda; Chromadorea; Spirurida; Filarioidea; Onchocercidae; Onchocerca
6287 Eukaryota; Metazoa; Nematoda; Chromadorea; Spirurida; Filarioidea; Onchocercidae; Dirofilaria
6289 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Trichostrongyloidea; Haemonchidae; Haemonchinae; Haemonchus
+6293 Eukaryota; Metazoa; Nematoda; Chromadorea; Spirurida; Filarioidea; Onchocercidae; Wuchereria
6303 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Meloidogyninae; Meloidogyne
6304 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Meloidogyninae; Meloidogyne
6305 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Meloidogyninae; Meloidogyne
6306 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Meloidogyninae; Meloidogyne
6317 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Trichostrongyloidea; Haemonchidae; Ostertagiinae; Ostertagia
6334 Eukaryota; Metazoa; Nematoda; Enoplea; Trichocephalida; Trichinellidae; Trichinella
-6421 Eukaryota; Metazoa; Annelida; Clitellata; Hirudinida; Hirudinea; Arynchobdellida; Hirudiniformes; Hirudinidae; Hirudo
6500 Eukaryota; Metazoa; Mollusca; Gastropoda; Orthogastropoda; Apogastropoda; Heterobranchia; Euthyneura; Opisthobranchia; Anaspidea; Aplysioidea; Aplysiidae; Aplysia
-6523 Eukaryota; Metazoa; Mollusca; Gastropoda; Pulmonata; Basommatophora; Lymnaeoidea; Lymnaeidae; Lymnaea
6526 Eukaryota; Metazoa; Mollusca; Gastropoda; Pulmonata; Basommatophora; Lymnaeoidea; Planorbidae; Biomphalaria
6550 Eukaryota; Metazoa; Mollusca; Bivalvia; Pteriomorphia; Mytiloida; Mytiloidea; Mytilidae; Mytilus
+6551 Eukaryota; Metazoa; Mollusca; Bivalvia; Pteriomorphia; Mytiloida; Mytiloidea; Mytilidae; Mytilus
6565 Eukaryota; Metazoa; Mollusca; Bivalvia; Pteriomorphia; Ostreoida; Ostreoidea; Ostreidae; Crassostrea
6661 Eukaryota; Metazoa; Arthropoda; Crustacea; Branchiopoda; Anostraca; Artemiidae; Artemia
6687 Eukaryota; Metazoa; Arthropoda; Crustacea; Malacostraca; Eumalacostraca; Eucarida; Decapoda; Dendrobranchiata; Penaeoidea; Penaeidae; Penaeus
6689 Eukaryota; Metazoa; Arthropoda; Crustacea; Malacostraca; Eumalacostraca; Eucarida; Decapoda; Dendrobranchiata; Penaeoidea; Penaeidae; Litopenaeus
-6832 Eukaryota; Metazoa; Arthropoda; Crustacea; Maxillopoda; Copepoda; Harpacticoida; Harpactidae; Tigriopus
+6720 Eukaryota; Metazoa; Arthropoda; Crustacea; Malacostraca; Eumalacostraca; Eucarida; Decapoda; Pleocyemata; Astacidea; Astacoidea; Astacidae; Pacifastacus
6941 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Parasitiformes; Ixodida; Ixodidae; Boophilus
6943 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Parasitiformes; Ixodida; Ixodidae; Amblyomma
6945 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Parasitiformes; Ixodida; Ixodidae; Ixodes
-7004 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Orthopteroidea; Orthoptera; Caelifera; Acridomorpha; Acridoidea; Acrididae; Oedipodinae; Locusta
+7029 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Paraneoptera; Hemiptera; Sternorrhyncha; Aphidiformes; Aphidoidea; Aphididae; Macrosiphini; Acyrthosiphon
7038 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Paraneoptera; Hemiptera; Sternorrhyncha; Aleyrodiformes; Aleyrodoidea; Aleyrodidae; Aleyrodinae; Bemisia
-7051 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Elateriformia; Cantharoidea; Lampyridae; Luciola
7070 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Cucujiformia; Tenebrionidae; Tribolium
7091 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Lepidoptera; Glossata; Ditrysia; Bombycoidea; Bombycidae; Bombyx
7092 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Lepidoptera; Glossata; Ditrysia; Bombycoidea; Bombycidae; Bombyx
+7111 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Lepidoptera; Glossata; Ditrysia; Noctuoidea; Noctuidae; Plusiinae; Trichoplusia
7121 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Lepidoptera; Glossata; Ditrysia; Bombycoidea; Saturniidae; Saturniinae; Saturniini; Antheraea
7130 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Lepidoptera; Glossata; Ditrysia; Sphingiodea; Sphingidae; Sphinginae; Manduca
-7154 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Chironomoidea; Chironomidae; Chironominae; Chironomus
-7159 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Culicoidea; Aedes
+7159 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Culicoidea; Aedes; Stegomyia
7165 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Culicoidea; Anopheles
7173 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Culicoidea; Anopheles
-7200 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Psychodoidea; Psychodidae; Lutzomyia
+7175 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Culicoidea; Culex; Culex
+7200 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Psychodoidea; Psychodidae; Lutzomyia; Lutzomyia
7213 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Tephritoidea; Tephritidae; Ceratitis
7217 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
7226 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
7227 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
+7229 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
7234 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
7237 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
7240 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
7241 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
-7243 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
7244 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
7245 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
+7264 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
+7368 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Muscoidea; Muscidae; Haematobia
7370 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Muscoidea; Muscidae; Musca
+7394 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Hippoboscoidea; Glossinidae; Glossina
7460 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Hymenoptera; Apocrita; Aculeata; Apoidea; Apidae; Apis
7515 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Siphonaptera; Pulicidae; Pulicinae; Ctenocephalides
+7634 Eukaryota; Metazoa; Echinodermata; Eleutherozoa; Echinozoa; Echinoidea; Euechinoidea; Echinacea; Echinoida; Echinometridae; Heliocidaris
+7650 Eukaryota; Metazoa; Echinodermata; Eleutherozoa; Echinozoa; Echinoidea; Euechinoidea; Echinacea; Echinoida; Strongylocentrotidae; Hemicentrotus
7668 Eukaryota; Metazoa; Echinodermata; Eleutherozoa; Echinozoa; Echinoidea; Euechinoidea; Echinacea; Echinoida; Strongylocentrotidae; Strongylocentrotus
7719 Eukaryota; Metazoa; Chordata; Urochordata; Ascidiacea; Enterogona; Phlebobranchia; Cionidae; Ciona
7723 Eukaryota; Metazoa; Chordata; Urochordata; Ascidiacea; Stolidobranchia; Styelidae; Polyandrocarpa
@@ -390,55 +365,63 @@
7739 Eukaryota; Metazoa; Chordata; Cephalochordata; Branchiostomidae; Branchiostoma
7741 Eukaryota; Metazoa; Chordata; Cephalochordata; Branchiostomidae; Branchiostoma
7757 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Hyperoartia; Petromyzontiformes; Petromyzontidae; Petromyzon
-7782 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Chondrichthyes; Elasmobranchii; Squalea; Hypnosqualea; Pristiorajea; Batoidea; Rajiformes; Rajidae; Raja
-7792 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Chondrichthyes; Elasmobranchii; Galeomorphii; Heterodontoidea; Heterodontiformes; Heterodontidae; Heterodontus
7801 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Chondrichthyes; Elasmobranchii; Galeomorphii; Galeoidea; Orectolobiformes; Ginglymostomatidae; Ginglymostoma
-7902 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Chondrostei; Acipenseriformes; Acipenseridae; Acipenser
-7936 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Anguilliformes; Anguillidae; Anguilla
7937 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Anguilliformes; Anguillidae; Anguilla
7955 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Ostariophysi; Cypriniformes; Cyprinidae; Danio
7957 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Ostariophysi; Cypriniformes; Cyprinidae; Carassius
+7959 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Ostariophysi; Cypriniformes; Cyprinidae; Ctenopharyngodon
7962 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Ostariophysi; Cypriniformes; Cyprinidae; Cyprinus
7998 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Ostariophysi; Siluriformes; Ictaluridae; Ictalurus
8018 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Oncorhynchus
-8019 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Oncorhynchus
8022 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Oncorhynchus
+8023 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Oncorhynchus
8030 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Salmo
8032 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Salmo
+8036 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Salvelinus
8049 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Paracanthopterygii; Gadiformes; Gadidae; Gadus
8078 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Atherinomorpha; Cyprinodontiformes; Fundulidae; Fundulus
+8081 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Atherinomorpha; Cyprinodontiformes; Poeciliidae; Poecilia
8090 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Atherinomorpha; Beloniformes; Adrianichthyidae; Oryziinae; Oryzias
8128 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Labroidei; Cichlidae; Oreochromis
-8161 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Percoidei; Carangidae; Seriola
+8150 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Labroidei; Cichlidae; Tropheus
+8161 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Carangoidei; Carangidae; Seriola
+8175 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Percoidei; Sparidae; Sparus
8222 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Gobioidei; Gobiidae; Gillichthys
8245 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Scombroidei; Xiphiidae; Xiphias
8255 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Pleuronectiformes; Pleuronectoidei; Paralichthyidae; Paralichthys
8260 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Pleuronectiformes; Pleuronectoidei; Pleuronectidae; Platichthys
+8262 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Pleuronectiformes; Pleuronectoidei; Pleuronectidae; Pleuronectes
8265 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Pleuronectiformes; Pleuronectoidei; Pleuronectidae; Pseudopleuronectes
+8267 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Pleuronectiformes; Pleuronectoidei; Pleuronectidae; Hippoglossus
8296 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Amphibia; Batrachia; Caudata; Salamandroidea; Ambystomatidae; Ambystoma
8355 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Amphibia; Batrachia; Anura; Mesobatrachia; Pipoidea; Pipidae; Xenopodinae; Xenopus
8364 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Amphibia; Batrachia; Anura; Mesobatrachia; Pipoidea; Pipidae; Xenopodinae; Silurana
8400 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Amphibia; Batrachia; Anura; Neobatrachia; Ranoidea; Ranidae; Rana; Aquarana
-8496 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Crocodylidae; Alligatorinae; Alligator
-8616 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Lepidosauria; Squamata; Scleroglossa; Serpentes; Colubroidea; Elapidae; Bungarinae; Bungarus
8723 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Lepidosauria; Squamata; Scleroglossa; Serpentes; Colubroidea; Viperidae; Crotalinae; Bothrops
8801 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Palaeognathae; Struthioniformes; Struthionidae; Struthio
8839 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Anseriformes; Anatidae; Anas
8932 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Columbiformes; Columbidae; Columba
9031 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Galliformes; Phasianidae; Phasianinae; Gallus
9091 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Galliformes; Phasianidae; Phasianinae; Coturnix
-9103 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Galliformes; Meleagrididae; Meleagris
+9103 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Galliformes; Phasianidae; Meleagris
+9157 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Passeriformes; Paridae; Parus
9238 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Sphenisciformes; Spheniscidae; Pygoscelis
9258 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Monotremata; Ornithorhynchidae; Ornithorhynchus
+9315 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Metatheria; Diprotodontia; Macropodidae; Macropus
+9337 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Metatheria; Diprotodontia; Phalangeridae; Trichosurus
+9361 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Edentata; Dasypodidae; Dasypus
+9438 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Chiroptera; Microchiroptera; Molossidae; Tadarida
+9447 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Strepsirhini; Lemuridae; Lemur
9483 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Platyrrhini; Callitrichidae; Callithrix
9490 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Platyrrhini; Callitrichidae; Saguinus
+9509 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Platyrrhini; Cebidae; Atelinae; Ateles
9521 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Platyrrhini; Cebidae; Cebinae; Saimiri
9534 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Cercopithecidae; Cercopithecinae; Cercopithecus
9541 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Cercopithecidae; Cercopithecinae; Macaca
+9542 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Cercopithecidae; Cercopithecinae; Macaca
9544 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Cercopithecidae; Cercopithecinae; Macaca
9545 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Cercopithecidae; Cercopithecinae; Macaca
9555 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Cercopithecidae; Cercopithecinae; Papio
-9556 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Cercopithecidae; Cercopithecinae; Papio
9557 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Cercopithecidae; Cercopithecinae; Papio
9580 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Hylobatidae; Hylobates
9593 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Catarrhini; Hominidae; Gorilla
@@ -450,13 +433,15 @@
9644 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Carnivora; Fissipedia; Ursidae; Ursus
9660 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Carnivora; Fissipedia; Mustelidae; Mustelinae; Martes
9685 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Carnivora; Fissipedia; Felidae; Felis
-9755 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Cetacea; Odontoceti; Physeteridae; Physeter
+9720 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Carnivora; Pinnipedia; Phocidae; Phoca
+9783 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Proboscidea; Elephantidae; Elephas
9785 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Proboscidea; Elephantidae; Loxodonta
9796 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Perissodactyla; Equidae; Equus
9823 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Suina; Suidae; Sus
9838 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Tylopoda; Camelidae; Camelus
9844 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Tylopoda; Camelidae; Lama
9860 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Ruminantia; Pecora; Cervoidea; Cervidae; Cervinae; Cervus
+9870 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Ruminantia; Pecora; Cervoidea; Cervidae; Odocoileinae; Rangifer
9897 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Ruminantia; Pecora; Bovoidea; Bovidae; Aepycerotinae; Aepyceros
9913 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Ruminantia; Pecora; Bovoidea; Bovidae; Bovinae; Bos
9915 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Ruminantia; Pecora; Bovoidea; Bovidae; Bovinae; Bos
@@ -467,66 +452,31 @@
9995 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Sciuridae; Sciurinae; Marmota
10029 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Cricetinae; Cricetulus
10036 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Cricetinae; Mesocricetus
+10041 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Sigmodontinae; Peromyscus
10042 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Sigmodontinae; Peromyscus
+10047 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Gerbillinae; Meriones
10090 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Murinae; Mus
10096 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Murinae; Mus
10116 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Murinae; Rattus
+10117 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Murinae; Rattus
+10129 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Murinae; Apodemus
10141 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Hystricognathi; Caviidae; Cavia
-10243 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Orthopoxvirus
-10244 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Orthopoxvirus
10245 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Orthopoxvirus
-10255 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Orthopoxvirus
-10261 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Avipoxvirus
-10271 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Leporipoxvirus
-10273 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Leporipoxvirus
-10276 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Suipoxvirus
-10279 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Molluscipoxvirus
10298 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Simplexvirus
-10310 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Simplexvirus
-10320 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Varicellovirus
-10326 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Varicellovirus
-10331 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Varicellovirus
10335 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Varicellovirus
10345 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Varicellovirus
10359 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Betaherpesvirinae; Cytomegalovirus
-10366 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Betaherpesvirinae; Muromegalovirus
-10368 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Betaherpesvirinae; Roseolovirus
-10372 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Betaherpesvirinae
10376 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Gammaherpesvirinae; Lymphocryptovirus
-10381 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Gammaherpesvirinae; Rhadinovirus
-10385 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Gammaherpesvirinae
-10386 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Infectious laryngotracheitis-like viruses
-10390 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Marek's disease-like viruses
-10397 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Betaherpesvirinae
-10401 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Ictalurid Herpes-like viruses
10407 Viruses; Retroid viruses; Hepadnaviridae; Orthohepadnavirus
-10449 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
-10450 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
-10454 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
-10458 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
-10468 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
10497 Viruses; dsDNA viruses, no RNA stage; Asfarviridae; Asfivirus
-10506 Viruses; dsDNA viruses, no RNA stage; Phycodnaviridae; Chlorovirus
10566 Viruses; dsDNA viruses, no RNA stage; Papillomaviridae; Papillomavirus
10581 Viruses; dsDNA viruses, no RNA stage; Papillomaviridae; Papillomavirus
10632 Viruses; dsDNA viruses, no RNA stage; Polyomaviridae; Polyomavirus
10633 Viruses; dsDNA viruses, no RNA stage; Polyomaviridae; Polyomavirus
-10665 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Myoviridae; T4-like viruses
-10677 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Myoviridae; Mu-like viruses
-10710 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Siphoviridae; Lambda-like viruses
-10724 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Siphoviridae; Lambda-like viruses
-10754 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Podoviridae; P22-like viruses
-10756 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Podoviridae; phi-29-like viruses
-10759 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Podoviridae; T7-like viruses
10760 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Podoviridae; T7-like viruses
10798 Viruses; ssDNA viruses; Parvoviridae; Parvovirinae; Erythrovirus
-10821 Viruses; ssDNA viruses; Geminiviridae; Mastrevirus
-10870 Viruses; ssDNA viruses; Inoviridae; Inovirus
-10927 Viruses; dsRNA viruses; Reoviridae; Rotavirus; unclassified rotaviruses
10995 Viruses; dsRNA viruses; Birnaviridae; Avibirnavirus
-11021 Viruses; ssRNA positive-strand viruses, no DNA stage; Togaviridae; Alphavirus; EEEV complex
11034 Viruses; ssRNA positive-strand viruses, no DNA stage; Togaviridae; Alphavirus; WEEV complex
-11036 Viruses; ssRNA positive-strand viruses, no DNA stage; Togaviridae; Alphavirus; VEEV complex
11041 Viruses; ssRNA positive-strand viruses, no DNA stage; Togaviridae; Rubivirus
11047 Viruses; ssRNA positive-strand viruses, no DNA stage; Nidovirales; Arteriviridae; Arterivirus
11072 Viruses; ssRNA positive-strand viruses, no DNA stage; Flaviviridae; Flavivirus; Japanese encephalitis virus group
@@ -534,9 +484,6 @@
11099 Viruses; ssRNA positive-strand viruses, no DNA stage; Flaviviridae; Pestivirus
11103 Viruses; ssRNA positive-strand viruses, no DNA stage; Flaviviridae; Hepacivirus
11120 Viruses; ssRNA positive-strand viruses, no DNA stage; Nidovirales; Coronaviridae; Coronavirus
-11128 Viruses; ssRNA positive-strand viruses, no DNA stage; Nidovirales; Coronaviridae; Coronavirus; Group 2 species
-11138 Viruses; ssRNA positive-strand viruses, no DNA stage; Nidovirales; Coronaviridae; Coronavirus; Group 2 species
-11149 Viruses; ssRNA positive-strand viruses, no DNA stage; Nidovirales; Coronaviridae; Coronavirus; Group 1 species
11161 Viruses; ssRNA negative-strand viruses; Mononegavirales; Paramyxoviridae; Paramyxovirinae; Rubulavirus
11176 Viruses; ssRNA negative-strand viruses; Mononegavirales; Paramyxoviridae; Paramyxovirinae; Rubulavirus
11234 Viruses; ssRNA negative-strand viruses; Mononegavirales; Paramyxoviridae; Paramyxovirinae; Morbillivirus
@@ -545,18 +492,17 @@
11264 Viruses; ssRNA negative-strand viruses; Mononegavirales; Paramyxoviridae; Pneumovirinae; Metapneumovirus
11276 Viruses; ssRNA negative-strand viruses; Mononegavirales; Rhabdoviridae; Vesiculovirus
11292 Viruses; ssRNA negative-strand viruses; Mononegavirales; Rhabdoviridae; Lyssavirus
-11599 Viruses; ssRNA negative-strand viruses; Bunyaviridae; Hantavirus
-11604 Viruses; ssRNA negative-strand viruses; Bunyaviridae; Hantavirus
11660 Viruses; Retroid viruses; Retroviridae; Lentivirus; Ovine/caprine lentivirus
11665 Viruses; Retroid viruses; Retroviridae; Lentivirus; Equine lentiviruses
11673 Viruses; Retroid viruses; Retroviridae; Lentivirus; Feline lentiviruses
11676 Viruses; Retroid viruses; Retroviridae; Lentivirus; Primate lentivirus group
11709 Viruses; Retroid viruses; Retroviridae; Lentivirus; Primate lentivirus group
11723 Viruses; Retroid viruses; Retroviridae; Lentivirus; Primate lentivirus group
+11768 Viruses; Retroid viruses; Retroviridae; Gammaretrovirus
11786 Viruses; Retroid viruses; Retroviridae; Gammaretrovirus
+11827 Viruses; Retroid viruses; Retroviridae
11886 Viruses; Retroid viruses; Retroviridae; Alpharetrovirus
11966 Viruses; Retroid viruses; Retroviridae
-11978 Viruses; ssRNA positive-strand viruses, no DNA stage; Caliciviridae; Vesivirus
11983 Viruses; ssRNA positive-strand viruses, no DNA stage; Caliciviridae; Norovirus
12092 Viruses; ssRNA positive-strand viruses, no DNA stage; Picornaviridae; Hepatovirus
12111 Viruses; ssRNA positive-strand viruses, no DNA stage; Picornaviridae; Aphthovirus; Foot-and-mouth disease virus
@@ -565,236 +511,323 @@
12216 Viruses; ssRNA positive-strand viruses, no DNA stage; Potyviridae; Potyvirus
12230 Viruses; ssRNA positive-strand viruses, no DNA stage; Potyviridae; Potyvirus
12232 Viruses; ssRNA positive-strand viruses, no DNA stage; Potyviridae; Potyvirus
-12242 Viruses; ssRNA positive-strand viruses, no DNA stage; Tobamovirus
12305 Viruses; ssRNA positive-strand viruses, no DNA stage; Bromoviridae; Cucumovirus
-12455 Viruses; ssRNA negative-strand viruses; Mononegavirales; Bornaviridae; Bornavirus
12461 Viruses; ssRNA positive-strand viruses, no DNA stage; Hepatitis E-like viruses
12475 Viruses; Deltavirus
-12618 Viruses; ssDNA viruses; Circoviridae; Circovirus
12637 Viruses; ssRNA positive-strand viruses, no DNA stage; Flaviviridae; Flavivirus; Dengue virus group
-12643 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Orthopoxvirus
-12702 Viruses; ssRNA positive-strand viruses, no DNA stage; Astroviridae; Astrovirus
+12702 Viruses; ssRNA positive-strand viruses, no DNA stage; Astroviridae; Mamastrovirus
12721 Viruses; Retroid viruses; Retroviridae; Lentivirus; Primate lentivirus group
12814 Viruses; ssRNA negative-strand viruses; Mononegavirales; Paramyxoviridae; Pneumovirinae; Pneumovirus
-13443 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Gentianales; Rubiaceae; Ixoroideae; Coffeeae; Coffea
+13323 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Scombroidei; Scombridae; Acanthocybium
+13333 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; stem Magnoliophyta; Amborellaceae; Amborella
+13443 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Gentianales; Rubiaceae; Ixoroideae; Coffeeae; Coffea
+13489 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Percoidei; Moronidae; Dicentrarchus
13515 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Strepsirhini; Lemuridae; Eulemur
-13563 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Agaricales; Schizophyllaceae; Heterobasidion
+13563 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Agaricales; Schizophyllaceae; Heterobasidion; Heterobasidion annosum species complex
13616 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Metatheria; Didelphimorphia; Didelphidae; Monodelphis
13773 Archaea; Crenarchaeota; Thermoprotei; Thermoproteales; Thermoproteaceae; Pyrobaculum
-23211 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Rosales; Rosaceae; Maloideae; Pyrus
+23211 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Rosales; Rosaceae; Maloideae; Pyrus
27288 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Saccharomyces
27291 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Saccharomyces
27293 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Saccharomyces
27294 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Saccharomyces
+27337 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; mitosporic Hypocreales; Verticillium
27405 Eukaryota; Metazoa; Arthropoda; Crustacea; Malacostraca; Eumalacostraca; Eucarida; Decapoda; Dendrobranchiata; Penaeoidea; Penaeidae; Marsupenaeus
27689 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Chondrostei; Acipenseriformes; Acipenseridae; Acipenser
+27828 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Trichostrongyloidea; Cooperiidae; Cooperia
27835 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Trichostrongyloidea; Heligmonellidae; Nippostrongylinae; Nippostrongylus
+27923 Eukaryota; Metazoa; Ctenophora; Cyclocoela; Lobata; Bolinopsidae; Mnemiopsis
28037 Bacteria; Firmicutes; Lactobacillales; Streptococcaceae; Streptococcus
-28289 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Granulovirus
-28304 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Betaherpesvirinae; Muromegalovirus
-28321 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Entomopoxvirinae; Entomopoxvirus B
+28232 Bacteria; Proteobacteria; Deltaproteobacteria; Desulfuromonadales; Geobacteraceae; Geobacter
28344 Viruses; ssRNA positive-strand viruses, no DNA stage; Nidovirales; Arteriviridae; Arterivirus
-28369 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Siphoviridae
-28450 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiaceae; Burkholderia; pseudomallei group
-28451 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Klebsiella
-28526 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Solanum; Lycopersicon
+28450 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiales; Burkholderiaceae; Burkholderia; pseudomallei group
+28526 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Solanum; Lycopersicon
+28532 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Cleome
28610 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Tephritoidea; Tephritidae; Rhagoletis
-28873 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Orthopoxvirus
28875 Viruses; dsRNA viruses; Reoviridae; Rotavirus
-28901 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Salmonella
-28909 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACC clade; Chloridoideae; Cynodonteae; Cynodon
+28901 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Salmonella
+28909 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACCAD clade; Chloridoideae; Cynodonteae; Cynodon
28985 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Kluyveromyces
29058 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Lepidoptera; Glossata; Ditrysia; Noctuoidea; Noctuidae; Heliothinae; Helicoverpa
29158 Eukaryota; Metazoa; Mollusca; Bivalvia; Pteriomorphia; Mytiloida; Mytiloidea; Mytilidae; Mytilus
29159 Eukaryota; Metazoa; Mollusca; Bivalvia; Pteriomorphia; Ostreoida; Ostreoidea; Ostreidae; Crassostrea
29170 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Ancylostomatoidea; Ancylostomatidae; Ancylostomatinae; Ancylostoma
29176 Eukaryota; Alveolata; Apicomplexa; Coccidia; Eimeriida; Sarcocystidae; Neospora
-29250 Viruses; unclassified viruses
-29292 Archaea; Euryarchaeota; Thermococci; Thermococcales; Thermococcaceae; Pyrococcus
-29449 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium
+29449 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Rhizobiaceae; Rhizobium/Agrobacterium group; Rhizobium
29459 Bacteria; Proteobacteria; Alphaproteobacteria; Rhizobiales; Brucellaceae; Brucella
-29488 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Photorhabdus
+29471 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Pectobacterium
+29488 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriales; Enterobacteriaceae; Photorhabdus
+29501 Bacteria; Firmicutes; Mollicutes; Mycoplasmataceae; Mycoplasma
29518 Bacteria; Spirochaetes; Spirochaetales; Spirochaetaceae; Borrelia; Borrelia burgdorferi group
29519 Bacteria; Spirochaetes; Spirochaetales; Spirochaetaceae; Borrelia; Borrelia burgdorferi group
-29729 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Malvales; Malvaceae; Malvoideae; Gossypium
-29760 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Vitaceae; Vitis
+29546 Bacteria; Proteobacteria; Deltaproteobacteria; Desulfovibrionales; Desulfovibrionaceae; Lawsonia
+29729 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Malvales; Malvaceae; Malvoideae; Gossypium
+29730 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Malvales; Malvaceae; Malvoideae; Gossypium
+29760 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Vitaceae; Vitis
29883 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Agaricales; Tricholomataceae; Laccaria
+30286 Eukaryota; Metazoa; Chordata; Urochordata; Ascidiacea; Stolidobranchia; Molgulidae; Molgula
+30301 Eukaryota; Metazoa; Chordata; Urochordata; Ascidiacea; Stolidobranchia; Botryllidae; Botryllus
31033 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Tetraodontiformes; Tetradontoidea; Tetraodontidae; Takifugu
-31175 Eukaryota; Metazoa; Echinodermata; Eleutherozoa; Echinozoa; Echinoidea; Euechinoidea; Diadematacea; Diadematoida; Diadematidae; Diadema
-31178 Eukaryota; Metazoa; Echinodermata; Eleutherozoa; Echinozoa; Echinoidea; Euechinoidea; Echinacea; Echinoida; Echinometridae; Echinometra
+31199 Eukaryota; Metazoa; Mollusca; Bivalvia; Pteriomorphia; Pectinoida; Pectinoidea; Pectinidae; Argopecten
+31216 Eukaryota; Metazoa; Mollusca; Gastropoda; Orthogastropoda; Apogastropoda; Caenogastropoda; Sorbeoconcha; Hypsogastropoda; Littorinimorpha; Littorinoidea; Littorinidae; Littorina
31243 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Heteroderinae; Globodera
-31312 Eukaryota; Viridiplantae; Chlorophyta; Prasinophyceae; Chlorodendrales; Chlorodendraceae; Nephroselmis
-31757 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Siphoviridae; L5-like viruses
-32049 Bacteria; Cyanobacteria; Chroococcales; Synechococcus
32538 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Carnivora; Fissipedia; Felidae; Leopardus
-33169 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Eremotheciaceae; Eremothecium
-33708 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Gammaherpesvirinae
-33903 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Streptomycineae; Streptomycetaceae; Streptomyces
-34256 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Lamiales; Lamiaceae; Nepetoideae; Mentheae; Mentha
-34305 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Loteae; Lotus
+33085 Eukaryota; Entamoebidae; Entamoeba
+33169 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Eremothecium
+33178 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; mitosporic Trichocomaceae; Aspergillus
+34245 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Asterales; Asteraceae; Asteroideae; Heliantheae; Zinnia
+34256 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Lamiales; Lamiaceae; Nepetoideae; Mentheae; Mentha
+34274 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Malvales; Malvaceae; Malvoideae; Gossypium
+34317 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Myrtales; Myrtaceae; Eucalyptus
34358 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Saccharomyces
34373 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Leotiomycetes; Erysiphales; Erysiphaceae; Blumeria
34488 Eukaryota; Fungi; Zygomycota; Zygomycetes; Entomophthorales; Ancylistaceae; Conidiobolus
34506 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Panagrolaimoidea; Strongyloididae; Strongyloides
+34594 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Parasitiformes; Ixodida; Argasidae; Ornithodoros
34610 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Parasitiformes; Ixodida; Ixodidae; Amblyomma
34740 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Lepidoptera; Glossata; Ditrysia; Papilionoidea; Nymphalidae; Heliconiinae; Heliconius
34765 Eukaryota; Metazoa; Chordata; Urochordata; Appendicularia; Oikopleuridae; Oikopleura
-35250 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Marek's disease-like viruses
+34816 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Percoidei; Moronidae; Morone
+35520 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACCAD clade; Panicoideae; Paniceae; Pennisetum
35632 Eukaryota; Metazoa; Annelida; Clitellata; Oligochaeta; Haplotaxida; Lumbricina; Lumbricidae; Lumbricus
-35938 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Robinieae; Robinia
+35845 Eukaryota; Viridiplantae; Chlorophyta; Ulvophyceae; Dasycladales; Dasycladaceae; Acetabularia
+35876 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Asparagales; Iridaceae; Iris
+35883 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Convolvulaceae; Ipomoea
+35884 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Convolvulaceae; Ipomoea
+35938 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Robinieae; Robinia
36090 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Heteroderinae; Globodera
-36427 Viruses; dsRNA viruses; Reoviridae; Rotavirus
36452 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; unclassified Herpesviridae; stealth viruses
-37108 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Alphaherpesvirinae; Marek's disease-like viruses
+36596 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Rosales; Rosaceae; Amygdaloideae; Prunus
+36825 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Orthopteroidea; Phasmatodea; Euphasmida; Phyllioidea; Bacillidae; Bacillus
37293 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Platyrrhini; Cebidae; Aotinae; Aotus
37296 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Gammaherpesvirinae; Rhadinovirus
-37468 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Boletales; Sclerodermataceae; Pisolithus
-37656 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Sapindales; Rutaceae; Citrus
-37657 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllidae; Caryophyllales; Caryophyllaceae; Silene
-37665 Viruses; dsDNA viruses, no RNA stage; Phycodnaviridae; Phaeovirus
+37468 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Boletales; Sclerodermatineae; Pisolithaceae; Pisolithus
+37656 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Sapindales; Rutaceae; Citrus
+37657 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllales; Caryophyllaceae; Silene
37682 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Triticeae; Aegilops
+37690 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Sapindales; Rutaceae; Poncirus
37727 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; mitosporic Trichocomaceae; Penicillium
-39839 Viruses; ssRNA positive-strand viruses, no DNA stage; Flaviviridae; GBV-C/HGV group
+37769 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Heterobasidiomycetes; Tremellomycetidae; Tremellales; Tremellaceae; Filobasidiella
+38033 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Sordariomycetidae; Sordariales; Chaetomiaceae; Chaetomium
+38249 Eukaryota; Euglenozoa; Kinetoplastida; Trypanosomatidae; Trypanosoma
+38666 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Heteromyidae; Perognathinae; Chaetodipus
+38937 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Lepidosauria; Squamata; Iguania; Iguanidae; Polychrotinae; Anolis
+39984 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Rhizophoraceae; Bruguiera
40051 Viruses; dsRNA viruses; Reoviridae; Orbivirus
+40352 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Trichostrongyloidea; Trichostrongylidae; Trichostrongylinae; Trichostrongylus
40366 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Brachycera; Muscomorpha; Ephydroidea; Drosophilidae; Drosophila
40559 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Leotiomycetes; Helotiales; Sclerotiniaceae; Botryotinia
+40686 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Salicaceae; Saliceae; Salix
40930 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Paraneoptera; Hemiptera; Sternorrhyncha; Aphidiformes; Coccoidea; Pseudococcidae; Planococcus
-41061 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; mitosporic Trichocomaceae; Aspergillus
-41857 Viruses; ssRNA negative-strand viruses; Orthomyxoviridae; Influenza A viruses; Influenzavirus A; Influenza A virus; H3N2 subtype
-41882 Eukaryota; Viridiplantae; Streptophyta; Mesostigmatophyceae; Mesostigmatales; Mesostigmataceae; Mesostigma
+40932 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Paraneoptera; Hemiptera; Sternorrhyncha; Aphidiformes; Aphidoidea; Aphididae; Aphidini; Rhopalosiphum
+41429 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Culicoidea; Anopheles
+42156 Eukaryota; Metazoa; Nematoda; Chromadorea; Spirurida; Filarioidea; Onchocercidae; Litomosoides
+42251 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Pezizomycetes; Pezizales; Tuberaceae; Tuber
+42329 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Cycadophyta; Cycadales; Zamiaceae; Zamia
+42439 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Limnanthaceae; Limnanthes
+42677 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; Nectriaceae; Gibberella; Gibberella fujikuroi complex
42890 Eukaryota; Alveolata; Apicomplexa; Coccidia; Eimeriida; Sarcocystidae; Sarcocystis
-44015 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Glycine
-44456 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Myrtales; Onagraceae; Oenothera
+43114 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Amphibia; Batrachia; Caudata; Salamandroidea; Ambystomatidae; Ambystoma
+43425 Eukaryota; Fungi; Glomeromycota; Glomeromycetes; Glomerales; Glomeraceae; Glomus
+43928 Archaea; Euryarchaeota; Halobacteria; Halobacteriales; Halobacteriaceae; Halobaculum
+44015 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Glycine
44689 Eukaryota; Mycetozoa; Dictyosteliida; Dictyostelium
-45255 Viruses; ssRNA positive-strand viruses, no DNA stage; Flaviviridae; GBV-C/HGV group
+45249 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Arabidopsis
45464 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Trichostrongyloidea; Haemonchidae; Ostertagiinae; Teladorsagia
-45687 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Glycine
+45687 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Glycine
45929 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Pratylenchidae; Pratylenchinae; Pratylenchus
-46015 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
-46221 Viruses; ssDNA viruses; Circoviridae; Circovirus
-46242 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
-47664 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Malpighiales; Salicaceae; Populus
+45954 Eukaryota; Metazoa; Mollusca; Bivalvia; Heteroconchia; Veneroida; Dreissenoidea; Dreissenidae; Dreissena
+46761 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Amphibia; Batrachia; Caudata; Salamandroidea; Plethodontidae; Plethodon
+47247 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Loteae; Lotus
+47664 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Salicaceae; Saliceae; Populus
47834 Bacteria; Firmicutes; Mollicutes; Entomoplasmatales; Spiroplasmataceae; Spiroplasma
-48154 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Passeriformes; Sylviidae; Phylloscopus
+47853 Bacteria; Actinobacteria; Actinobacteridae; Actinomycetales; Micromonosporineae; Micromonosporaceae; Micromonospora
+48215 Eukaryota; Metazoa; Platyhelminthes; Trematoda; Digenea; Echinostomida; Echinostomata; Echinostomatidae; Echinostoma
48935 Bacteria; Proteobacteria; Alphaproteobacteria; Sphingomonadales; Sphingomonadaceae; Novosphingobium
49338 Bacteria; Firmicutes; Clostridia; Clostridiales; Peptococcaceae; Desulfitobacterium
49351 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Cephaloboidea; Cephalobidae; Zeldia
-49495 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Filicophyta; Filicopsida; Filicales; Pteridaceae; Ceratopteris
-50339 Archaea; Euryarchaeota; Thermoplasmata; Thermoplasmatales; Thermoplasmataceae; Thermoplasma
+49451 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Nicotiana
+49495 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Moniliformopses; Filicophyta; Filicopsida; Filicales; Pteridaceae; Ceratopteris
51029 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Heteroderinae; Heterodera
51031 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Ancylostomatoidea; Ancylostomatidae; Bunostominae; Necator
-51313 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
-51453 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreales; Hypocreaceae; Hypocrea
-51677 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Granulovirus
-52283 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Acariformes; Sarcoptiformes; Astigmata; Sarcoptoidea; Sarcoptidae; Sarcoptes
-53010 Viruses; ssDNA viruses; Geminiviridae; Begomovirus
+51240 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fagales; Juglandaceae; Juglans
+51453 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; Hypocreaceae; Hypocrea
+51511 Eukaryota; Metazoa; Chordata; Urochordata; Ascidiacea; Enterogona; Phlebobranchia; Cionidae; Ciona
+51657 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Kluyveromyces
+52283 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Acariformes; Sarcoptiformes; Astigmata; Psoroptidia; Sarcoptoidea; Sarcoptidae; Sarcoptes
+52714 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Pooideae; Triticeae; Leymus
+52792 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Passeriformes; Turdidae; Luscinia
53326 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Strongylida; Ancylostomatoidea; Ancylostomatidae; Ancylostomatinae; Ancylostoma
-53413 Bacteria; Proteobacteria; Gammaproteobacteria; Xanthomonadaceae; Xanthomonas
-53953 Archaea; Euryarchaeota; Thermococci; Thermococcales; Thermococcaceae; Pyrococcus
+53413 Bacteria; Proteobacteria; Gammaproteobacteria; Xanthomonadales; Xanthomonadaceae; Xanthomonas
54126 Eukaryota; Metazoa; Nematoda; Chromadorea; Diplogasterida; Neodiplogasteridae; Pristionchus
+54290 Viruses; ssRNA positive-strand viruses, no DNA stage; Flaviviridae; GBV-C/HGV group
54314 Viruses; ssRNA positive-strand viruses, no DNA stage; Flaviviridae; Pestivirus
-54672 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Malpighiales; Euphorbiaceae; Euphorbia
+54672 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Euphorbiaceae; Euphorbioideae; Euphorbieae; Euphorbia
54734 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Dothideomycetes et Chaetothyriomycetes incertae sedis; Mycosphaerellaceae; Mycosphaerella
-55188 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Sapindales; Rutaceae; Citrus
+55088 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Orthopteroidea; Phasmatodea; Euphasmida; Phyllioidea; Bacillidae; Bacillus
+55188 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Sapindales; Rutaceae; Citrus
55529 Eukaryota; Cryptophyta; Cryptomonadaceae; Guillardia
-55670 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; campanulids; Asterales; Asteraceae; Asteroideae; Heliantheae; Stevia
-56141 Eukaryota; Metazoa; Mollusca; Gastropoda; Orthogastropoda; Apogastropoda; Caenogastropoda; Sorbeoconcha; Hypsogastropoda; Littorinimorpha; Rissooidea; Pomatiopsidae; Oncomelania
-56636 Archaea; Crenarchaeota; Thermoprotei; Desulfurococcales; Desulfurococcaceae; Aeropyrum
+55670 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Asterales; Asteraceae; Asteroideae; Eupatorieae; Stevia
+55987 Viruses; ssRNA negative-strand viruses; Orthomyxoviridae; unclassified Orthomyxoviridae
57667 Viruses; Retroid viruses; Retroviridae; Lentivirus; Primate lentivirus group
-59509 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Capripoxvirus
+57870 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Orthopteroidea; Phasmatodea; Euphasmida; Phyllioidea; Bacillidae; Bacillus
+58002 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Paraneoptera; Hemiptera; Sternorrhyncha; Aphidiformes; Phylloxeroidea; Phylloxeridae; Daktulosphaira
+58031 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Cycadophyta; Cycadales; Cycadaceae; Cycas
+59479 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Chiroptera; Microchiroptera; Rhinolophidae; Rhinolophinae; Rhinolophus
+59689 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Arabidopsis
+59747 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Meloidogyninae; Meloidogyne
59777 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Lycopodiophyta; Isoetopsida; Selaginellales; Selaginellaceae; Selaginella
-62890 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Solanales; Solanaceae; Solanum; Lycopersicon
-63363 Bacteria; Aquificae; Aquificales; Aquificaceae; Aquifex
+59861 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Coregonus
+61147 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Rhizophoraceae; Kandelia
+62324 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Diptera; Nematocera; Culicoidea; Anopheles
+62890 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Solanum; Lycopersicon
+63629 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; Ehrhartoideae; Oryzeae; Oryza
63737 Bacteria; Cyanobacteria; Nostocales; Nostocaceae; Nostoc
64091 Archaea; Euryarchaeota; Halobacteria; Halobacteriales; Halobacteriaceae; Halobacterium
-64093 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Lamiales; Orobanchaceae; Rhinantheae; Triphysaria
+64093 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Lamiales; Orobanchaceae; Rhinantheae; Triphysaria
+64391 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Cucujiformia; Phytophaga; Chrysomeloidea; Chrysomelidae; Bruchinae; Bruchini; Callosobruchus
64468 Eukaryota; Metazoa; Arthropoda; Crustacea; Malacostraca; Eumalacostraca; Eucarida; Decapoda; Dendrobranchiata; Penaeoidea; Penaeidae; Litopenaeus
+64602 Archaea; Euryarchaeota; Halobacteria; Halobacteriales; Halobacteriaceae; Natrialba
+64679 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Sciuridae; Sciurinae; Tamias
+64717 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Muridae; Arvicolinae; Microtus
65661 Eukaryota; Acanthamoebidae; Acanthamoeba
66189 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Testudines; Cryptodira; Testudinoidea; Testudinidae; Geochelone
-66797 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Siphoviridae
66913 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Ostariophysi; Siluriformes; Ictaluridae; Ictalurus
67593 Eukaryota; stramenopiles; Oomycetes; Pythiales; Pythiaceae; Phytophthora
-68887 Viruses; ssDNA viruses; unclassified ssDNA viruses
+68887 Viruses; ssDNA viruses; Circoviridae; Anellovirus
+69266 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; Ericales; Ericaceae; Vaccinioideae; Vaccinieae; Vaccinium
69293 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Gasterosteiformes; Gasterosteidae; Gasterosteus
70415 Eukaryota; Metazoa; Nematoda; Enoplea; Trichocephalida; Trichuridae; Trichuris
70448 Eukaryota; Viridiplantae; Chlorophyta; Prasinophyceae; Mamiellales; Mamiellaceae; Ostreococcus
-70600 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
+70863 Bacteria; Proteobacteria; Gammaproteobacteria; Alteromonadales; Alteromonadaceae; Shewanella
+71139 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Myrtales; Myrtaceae; Eucalyptus
+71150 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Boletales; Paxilineae; Paxillaceae; Paxillus
71223 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Elateriformia; Cantharoidea; Lampyridae; Pyrocoelia
71647 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Coniferopsida; Coniferales; Pinaceae; Pinus; Pinus
-72664 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Thellungiella
-73824 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Malpighiales; Salicaceae; Populus
+72088 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Scorpaeniformes; Scorpaenoidei; Scorpaenidae; Sebastes
+73107 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Gruiformes; Otididae; Otis
+73234 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Orthopteroidea; Phasmatodea; Euphasmida; Phyllioidea; Bacillidae; Bacillus
+73275 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Asterales; Asteraceae; Asteroideae; Heliantheae; Helianthus
+73304 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Asterales; Asteraceae; Asteroideae; Heliantheae; Helianthus
+73824 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Salicaceae; Saliceae; Populus
+74081 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Lepidosauria; Squamata; Scleroglossa; Scincomorpha; Lacertoidea; Lacertidae; Podarcis
+74649 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Rosales; Rosaceae; Rosoideae; Rosa
74940 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Protacanthopterygii; Salmoniformes; Salmonidae; Oncorhynchus
-75985 Bacteria; Proteobacteria; Gammaproteobacteria; Pasteurellaceae; Mannheimia
+75846 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Anseriformes; Anatidae; Anas
+75943 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Asterales; Asteraceae; Cichorioideae; Cichorieae; Lactuca
+76149 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllales; Plumbaginaceae; Plumbago
+76340 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Percoidei; Sciaenidae; Sciaenops
76593 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Ostariophysi; Cypriniformes; Cyprinidae; Acrossocheilus
+76867 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Agaricales; Cortinariaceae; Hebeloma
+77108 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; stem Magnoliophyta; Nymphaeaceae; Nuphar
78584 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Primates; Strepsirhini; Megaladapidae; Lepilemur
79327 Eukaryota; Metazoa; Platyhelminthes; Turbellaria; Seriata; Tricladida; Paludicola; Dugesiidae; Schmidtea
+79517 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Cucujiformia; Phytophaga; Chrysomeloidea; Chrysomelidae; Chrysomelinae; Timarchini; Timarcha
79880 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus
+79923 Eukaryota; Metazoa; Platyhelminthes; Trematoda; Digenea; Opisthorchiida; Opisthorchiata; Opisthorchioidea; Opisthorchiidae; Clonorchis
80365 Eukaryota; stramenopiles; Phaeophyceae; Laminariales; Laminariaceae; Laminaria
+80379 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Solanales; Solanaceae; Capsicum
+80863 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Salicaceae; Saliceae; Populus
82528 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Asparagales; Iridaceae; Crocus
-82927 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Asteridae; lamiids; Lamiales; Acanthaceae; Acanthaceae incertae sedis; Avicennia
-83191 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Entomopoxvirinae; Entomopoxvirus B
+82927 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Lamiales; Acanthaceae; Acanthaceae incertae sedis; Avicennia
+83288 Eukaryota; Rhodophyta; Florideophyceae; Ceramiales; Ceramiaceae; Griffithsia
83558 Bacteria; Chlamydiae; Chlamydiales; Chlamydiaceae; Chlamydophila
-83560 Bacteria; Chlamydiae; Chlamydiales; Chlamydiaceae; Chlamydia
-83912 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Acariformes; Sarcoptiformes; Astigmata; Sarcoptoidea; Psoroptidae; Psoroptes
-86304 Bacteria; Proteobacteria; Gammaproteobacteria; Alteromonadaceae; Microbulbifer
-86665 Bacteria; Firmicutes; Bacillales; Bacillaceae; Bacillus
-89411 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Descurainia
+83675 Eukaryota; Alveolata; Apicomplexa; Coccidia; Eimeriida; Sarcocystidae; Neospora
+83912 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Acari; Acariformes; Sarcoptiformes; Astigmata; Psoroptidia; Sarcoptoidea; Psoroptidae; Psoroptes
+84072 Eukaryota; Metazoa; Platyhelminthes; Turbellaria; Acoelomorpha; Acoela; Sagittiferidae; Symsagittifera
+85571 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Sapindales; Rutaceae; Citrus
+86005 Bacteria; Firmicutes; Bacillales; Alicyclobacillaceae; Pasteuria
+86304 Bacteria; Proteobacteria; Gammaproteobacteria; Alteromonadales; Alteromonadaceae; Microbulbifer
+87841 Eukaryota; Metazoa; Mollusca; Gastropoda; Pulmonata; Stylommatophora; Sigmurethra; Helicoidea; Bradybaenidae; Euhadra
+89411 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Descurainia
89462 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Cetartiodactyla; Ruminantia; Pecora; Bovoidea; Bovidae; Bovinae; Bubalus
-92652 Viruses; dsDNA viruses, no RNA stage; Nimaviridae
+92652 Viruses; dsDNA viruses, no RNA stage; Nimaviridae; Whispovirus
+93678 Viruses; ssDNA viruses; Circoviridae; Anellovirus
93934 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Galliformes; Phasianidae; Phasianinae; Coturnix
-96477 Eukaryota; Viridiplantae; Streptophyta; Coleochaetales; Chaetosphaeridiaceae; Chaetosphaeridium
+94289 Eukaryota; Alveolata; Ciliophora; Spirotrichea; Stichotrichia; Stichotrichida; Oxytrichidae; Sterkiella
+94961 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Chiroptera; Microchiroptera; Mystacinidae; Mystacina
+95145 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Paracanthopterygii; Batrachoididae; Opsanus
+96939 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Vitaceae; Vitis
+97005 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Heteroderinae; Heterodera
97393 Archaea; Euryarchaeota; Thermoplasmata; Thermoplasmatales; Ferroplasmaceae; Ferroplasma
-98038 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Brassicales; Brassicaceae; Thellungiella
+98038 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids II; Brassicales; Brassicaceae; Thellungiella
99878 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Passeriformes; Sturnidae; Toxostoma
99883 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Tetraodontiformes; Tetradontoidea; Tetraodontidae; Tetraodon
-103690 Bacteria; Cyanobacteria; Nostocales; Nostocaceae; Nostoc
+100452 Eukaryota; Metazoa; Mollusca; Gastropoda; Pulmonata; Stylommatophora; Sigmurethra; Helicoidea; Hygromiidae; Candidula
+102803 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Cucujiformia; Phytophaga; Scolytidae; Ips
+103999 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Asterales; Campanulaceae; Codonopsis
105358 Eukaryota; Metazoa; Echinodermata; Eleutherozoa; Echinozoa; Echinoidea; Euechinoidea; Diadematacea; Diadematoida; Diadematidae; Diadema
-105360 Eukaryota; Metazoa; Echinodermata; Eleutherozoa; Echinozoa; Echinoidea; Euechinoidea; Diadematacea; Diadematoida; Diadematidae; Diadema
-105385 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Amphibia; Batrachia; Anura; Neobatrachia; Bufonoidea; Myobatrachidae; Limnodynastes
-107806 Bacteria; Proteobacteria; Gammaproteobacteria; Enterobacteriaceae; Buchnera
+105886 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; campanulids; Apiales; Araliaceae; Acanthopanax
+107832 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Heterobasidiomycetes; Heterobasidiomycetidae; Ceratobasidiales; Ceratobasidiaceae; Thanatephorus
+107907 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Adephaga; Dytiscidae; Colymbetinae; Colymbetini; Meladema
108098 Viruses; dsDNA viruses, no RNA stage; Adenoviridae; Mastadenovirus
108607 Eukaryota; Pelobiontida; Mastigamoebidae; Mastigamoeba
-111955 Archaea; Crenarchaeota; Thermoprotei; Sulfolobales; Sulfolobaceae; Sulfolobus
-114186 Bacteria; Proteobacteria; Gammaproteobacteria; Candidatus Carsonella
+110365 Eukaryota; Alveolata; Apicomplexa; Gregarinia; Eugregarinida; Gregarinidae; Gregarina
+112525 Eukaryota; Metazoa; Mollusca; Gastropoda; Pulmonata; Basommatophora; Lymnaeoidea; Planorbidae; Biomphalaria
+113636 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Salicaceae; Saliceae; Populus
+114524 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Saccharomyces
114525 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Saccharomyces
114526 Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes; Saccharomycetales; Saccharomycetaceae; Saccharomyces
+117187 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; Nectriaceae; Gibberella
+118799 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Adephaga; Carabidae; Carabini; Carabina; Carabus; Carabus
119072 Bacteria; Firmicutes; Clostridia; Thermoanaerobacteriales; Thermoanaerobacteriaceae; Thermoanaerobacter
-119219 Bacteria; Proteobacteria; Betaproteobacteria; Ralstoniaceae; Ralstonia
+119219 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiales; Burkholderiaceae; Ralstonia
+121225 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Paraneoptera; Phthiraptera; Anoplura; Pediculidae; Pediculus
+121759 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Onygenales; mitosporic Onygenales; Paracoccidioides
+123226 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Scorpiones; Buthida; Buthoidea; Buthidae; Mesobuthus
123792 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Rodentia; Sciurognathi; Sciuridae; Sciurinae; Tamias
126740 Bacteria; Thermotogae; Thermotogales; Thermotogaceae; Thermotoga
-126913 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllidae; Caryophyllales; Chenopodiaceae; Suaeda
-128735 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Rosales; Rosaceae; Rosoideae; Rosa
+126913 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllales; Amaranthaceae; Suaeda
+128735 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Rosales; Rosaceae; Rosoideae; Rosa
+129883 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Ostariophysi; Cypriniformes; Cyprinidae; Telestes
129951 Viruses; dsDNA viruses, no RNA stage; Adenoviridae; Mastadenovirus
-130310 Viruses; dsDNA viruses, no RNA stage; Adenoviridae; Mastadenovirus
131310 Eukaryota; Metazoa; Nematoda; Chromadorea; Rhabditida; Panagrolaimoidea; Strongyloididae; Parastrongyloides
-132475 Viruses; dsDNA viruses, no RNA stage; Poxviridae; Chordopoxvirinae; Yatapoxvirus
-132711 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACC clade; Panicoideae; Andropogoneae; Sorghum
-134537 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiaceae; Burkholderia
+132711 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; PACCAD clade; Panicoideae; Andropogoneae; Sorghum
+134537 Bacteria; Proteobacteria; Betaproteobacteria; Burkholderiales; Burkholderiaceae; Burkholderia
135974 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Passeriformes; Furnariidae; Glyphorynchus
-136966 Viruses; ssDNA viruses; unclassified ssDNA viruses
+136966 Viruses; ssDNA viruses; Circoviridae; Anellovirus
137523 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Piciformes; Picidae; Dendrocopos
138948 Viruses; ssRNA positive-strand viruses, no DNA stage; Picornaviridae; Enterovirus
138949 Viruses; ssRNA positive-strand viruses, no DNA stage; Picornaviridae; Enterovirus
138950 Viruses; ssRNA positive-strand viruses, no DNA stage; Picornaviridae; Enterovirus
138953 Viruses; ssRNA positive-strand viruses, no DNA stage; Picornaviridae; Enterovirus
-140110 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreales; Nectriaceae; Nectria
+140110 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; Nectriaceae; Nectria
145262 Archaea; Euryarchaeota; Methanobacteria; Methanobacteriales; Methanobacteriaceae; Methanothermobacter
-146786 Bacteria; Cyanobacteria; Chroococcales; Thermosynechococcus
148305 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Sordariomycetes incertae sedis; Magnaporthaceae; Magnaporthe
-148363 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
+150234 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Adephaga; Cicindelidae; Cicindela; Cicindela
+153471 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Malpighiales; Salicaceae; Saliceae; Populus
155892 Bacteria; Proteobacteria; Alphaproteobacteria; Caulobacterales; Caulobacteraceae; Caulobacter
-156889 Bacteria; Proteobacteria; magnetotactic cocci
-157791 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Vigna
-161934 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllidae; Caryophyllales; Chenopodiaceae; Beta
+156889 Bacteria; Proteobacteria; Magnetococcus
+157791 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae; Vigna
+160621 Eukaryota; Alveolata; Dinophyceae; Gonyaulacales; Lingulodinium
+161934 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllales; Amaranthaceae; Beta
162425 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; Emericella
-164405 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Rosidae; eurosids II; Myrtales; Myrtaceae; Melaleuca
-169015 Eukaryota; mixed EST libraries
-169683 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Myoviridae
-176652 Viruses; dsDNA viruses, no RNA stage; Iridoviridae; Iridovirus
-180816 Viruses; dsDNA viruses, no RNA stage; Caudovirales; Siphoviridae; Lambda-like viruses
-182710 Bacteria; Firmicutes; Bacillales; Oceanobacillus
-188763 Viruses; dsDNA viruses, no RNA stage; Herpesviridae; Betaherpesvirinae; Cytomegalovirus
-191492 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
+164405 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Myrtales; Myrtaceae; Melaleuca
+172680 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Gruiformes; Otididae; Chlamydotis
+176275 Eukaryota; Fungi; Ascomycota; Pezizomycotina; Sordariomycetes; Hypocreomycetidae; Hypocreales; Clavicipitaceae; Cordyceps
+178872 Eukaryota; Fungi; Basidiomycota; Hymenomycetes; Homobasidiomycetes; Boletales; Sclerodermatineae; Pisolithaceae; Pisolithus
+180448 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Archosauria; Aves; Neognathae; Passeriformes; Motacillidae; Motacilla
+182803 Eukaryota; Metazoa; Arthropoda; Chelicerata; Arachnida; Araneae; Araneomorphae; Entelegynae; Araneoidea; Araneidae; Araneus
+183855 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Myrtales; Myrtaceae; Eucalyptus
+186039 Eukaryota; stramenopiles; Bacillariophyta; Bacillariophyceae; Bacillariophycidae; Bacillariales; Bacillariaceae; Fragilariopsis
+189293 Eukaryota; Metazoa; Nematoda; Chromadorea; Tylenchida; Tylenchina; Tylenchoidea; Heteroderidae; Meloidogyninae; Meloidogyne
+189785 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; Caryophyllales; Tamaricaceae; Tamarix
194440 Viruses; Retroid viruses; Retroviridae; Deltaretrovirus
194441 Viruses; Retroid viruses; Retroviridae; Deltaretrovirus
-204440 Viruses; dsDNA viruses, no RNA stage; Baculoviridae; Nucleopolyhedrovirus
+197003 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Cucujiformia; Biphyllidae; Biphyllus
+197009 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Cucujiformia; Phytophaga; Anthribidae; Anthribinae; Platystomini; Platystomus
+197013 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Endopterygota; Coleoptera; Polyphaga; Cucujiformia; Phytophaga; Curculionidae; Curculioninae; Curculionini; Curculio
+197043 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Paraneoptera; Hemiptera; Euhemiptera; Membracoidea; Cicadellidae; Cicadellinae; Homalodisca
+212795 Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Actinopterygii; Neopterygii; Teleostei; Euteleostei; Neoteleostei; Acanthomorpha; Acanthopterygii; Percomorpha; Perciformes; Percoidei; Serranidae; Epinephelus
+213425 Eukaryota; Metazoa; Mollusca; Gastropoda; Orthogastropoda; Apogastropoda; Caenogastropoda; Sorbeoconcha; Hypsogastropoda; Neogastropoda; Muricoidea; Muricidae; Ocinebrellus
+216816 Bacteria; Actinobacteria; Actinobacteridae; Bifidobacteriales; Bifidobacteriaceae; Bifidobacterium
+219666 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Gentianales; Rubiaceae; Rubioideae; Spermacoceae; Hedyotis
+219667 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; asterids; lamiids; Gentianales; Rubiaceae; Rubioideae; Spermacoceae; Hedyotis
+219738 Eukaryota; Metazoa; Nematoda; Enoplea; Trichocephalida; Trichuridae; Trichuris
+221420 Eukaryota; Metazoa; Echinodermata; Eleutherozoa; Echinozoa; Holothuroidea; Aspidochirotacea; Aspidochirotida; Holothuriidae; Holothuria
+223153 Eukaryota; Alveolata; Ciliophora; Litostomatea; Trichostomatia; Vestibuliferida; Isotrichidae; Isotricha
+223852 Eukaryota; Metazoa; Arthropoda; Hexapoda; Insecta; Pterygota; Neoptera; Paraneoptera; Hemiptera; Sternorrhyncha; Aphidiformes; Aphidoidea; Aphididae; Aphidini; Toxoptera
+232323 Eukaryota; Metazoa; Tardigrada; Eutardigrada; Apochela; Hypsibiidae; Hypsibius
+241073 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Vitaceae; Vitis
+245552 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; Liliopsida; Liliales; Alstroemeriaceae; Alstroemeria
+246827 Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; eudicotyledons; core eudicots; rosids; Vitaceae; Vitis
diff --git a/data/sequin.hlp b/data/sequin.hlp
index ddeb4c26..3f5be114 100644
--- a/data/sequin.hlp
+++ b/data/sequin.hlp
@@ -5,8 +5,7 @@
<!-- if you use the following meta tags, uncomment them.
<META NAME="keywords" CONTENT="Sequin">
- <META NAME="description" CONTENT="Sequin is a stand-alone software tool developed by the NCBI for submitting and updating entries to the GenBank, EMBL, or DDBJ sequence databases. ">
--->
+ <META NAME="description" CONTENT="Sequin is a stand-alone software tool developed by the NCBI for submitting and updating entries to the GenBank, EMBL, or DDBJ sequence databases. "> -->
<link rel="stylesheet" href="ncbi_sequin.css">
@@ -2288,7 +2287,7 @@ this location.
#Region containing polycistronic transcript under the control of the same regulatory sequences.
-*ori_T
+*oriT
Origin of transfer; region of DNA where transfer is initiated during the process of conjugation or mobilization.
@@ -3442,21 +3441,42 @@ added to the sequence. Features are described in more detail in the
above section entitled
<A HREF="#Features">
Features.
-</A>
-#The seventh option, Publications, allows you to add a Publication Feature
+</A>
+#If you are submitting a set of similar sequences, you can add the same
+feature across the entire span of each by using the Batch Feature Apply
+option. The feature must span the entire nucleotide sequence of each member;
+you can not annotate specific nucleotide locations using this option (for
+this, see <A HREF="#FeaturePropagate">Feature Propagate</A>). For each
+feature, you will be prompted to designate whether the feature is 5' or 3'
+partial and whether is is on the plus or minus strand. You may also add a
+comment of other qualifier to the feature. The Add Qualifier option allows
+you to add a qualifier to an existing feature. You must specify the feature
+and qualifier in the Add Qualifier pop-up box. Source qualifiers can be added
+to all entries using the Add Source Qualifier option. Qualifiers specific to
+the CDS and gene can be added using Add CDS-Gene-Prot and RNA qualifiers using
+Add RNA Qual. In each case, a pop-up box appears with qualifier options
+appropriate for that feature.
+
+#The Batch Feature Edit function allows you to edit existing qualifiers. For
+each menu choice, a pop-up box allows you to select the feature containing the
+qualifier and the specific qualifier to be edited. You can use the
+Find/Replace text boxes to edit the information contained within the
+qualifier.
+
+#The Publications option allows you to add a Publication Feature
or Publication Descriptor to the record. Publications are described in
more detail in the above section entitled
<A HREF="#Publications">
Publications.
</A>
-#The eighth option, Descriptors, allows you to add Descriptors to the
+#The Descriptors option allows you to add Descriptors to the
record. Descriptors are described in more detail in the section
entitled
<A HREF="#Descriptors">
Descriptors,
</A>
above.
-#The ninth option Generate Definition Line, will generate a title for your
+#The Generate Defintion Line option will generate a title for your
sequence based on the information provided in the record. This option will
work
for single sequences as well as sets of sequences, and can handle complex
@@ -3946,7 +3966,7 @@ ALT="Table of Contents" ALIGN=top BORDER=2></A>
<P CLASS=medium1><B>Questions or Comments?</B>
<BR>Write to the <A HREF="mailto:info@ncbi.nlm.nih.gov">NCBI Service
Desk</A></P>
-<P CLASS=medium1>Revised October 20, 2003
+<P CLASS=medium1>Revised January 30, 2004
</CENTER>
diff --git a/data/taxlist.txt b/data/taxlist.txt
index bdc4dada..e90fc914 100644
--- a/data/taxlist.txt
+++ b/data/taxlist.txt
@@ -1,342 +1,375 @@
-12
-Acanthamoeba castellanii 1 4 INV 5755
+13
Acanthamoeba healyi 1 4 INV 65661
+Acanthocybium solandri 1 2 VRT 13323
+Acanthopanax sessiliflorus 1 1 PLN 105886
+Acetabularia acetabulum 6 1 PLN 35845
Acidithiobacillus ferrooxidans 11 0 BCT 920
-Acinetobacter calcoaceticus 11 0 BCT 471
Acipenser baerii Siberian sturgeon 1 2 VRT 27689
-Acipenser gueldenstaedtii Russian sturgeon 1 2 VRT 7902
Acrossocheilus paradoxus 1 2 VRT 76593
Actinobacillus actinomycetemcomitans 11 0 BCT 714
Actinobacillus pleuropneumoniae 11 0 BCT 715
+Acyrthosiphon pisum pea aphid 1 5 INV 7029
Aedes aegypti yellow fever mosquito 1 5 INV 7159
Aegilops speltoides 1 1 PLN 4573
Aegilops tauschii 1 1 PLN 37682
Aepyceros melampus impala 1 2 MAM 9897
+Aequorea victoria 1 4 INV 6100
Aeromonas hydrophila 11 0 BCT 644
-Aeropyrum pernix 11 0 BCT 56636
African swine fever virus 1 0 VRL 10497
Agaricus bisporus 1 4 PLN 5341
Agrobacterium tumefaciens 11 0 BCT 358
Aids-associated retrovirus 1 0 VRL 11966
Ajellomyces capsulatus 1 4 PLN 5037
-Alligator mississippiensis American alligator 1 2 VRT 8496
+Alexandrium tamarense 1 4 PLN 2926
Allium cepa onion 1 1 PLN 4679
+Allium sativum garlic 1 1 PLN 4682
+Alstroemeria peruviana 1 1 PLN 245552
Amblyomma americanum 1 5 INV 6943
Amblyomma variegatum 1 5 INV 34610
+Amborella trichopoda 1 1 PLN 13333
+Ambystoma maculatum spotted salamander 1 2 VRT 43114
Ambystoma mexicanum axolotl 1 2 VRT 8296
-Amsacta moorei entomopoxvirus 1 0 VRL 28321
-Anabaena variabilis 11 0 BCT 1172
+Amphidinium carterae 1 4 PLN 2961
Anaplasma marginale 11 0 BCT 770
Anaplasma phagocytophilum 11 0 BCT 948
+Anas fulvigula 1 2 VRT 75846
Anas platyrhynchos 1 2 VRT 8839
Ancylostoma caninum dog hookworm 1 5 INV 29170
Ancylostoma ceylanicum 1 5 INV 53326
-Anguilla anguilla European eel 1 2 VRT 7936
Anguilla japonica Japanese eel 1 2 VRT 7937
+Anolis sagrei brown anole 1 2 VRT 38937
Anopheles arabiensis 1 5 INV 7173
+Anopheles funestus 1 5 INV 62324
Anopheles gambiae African malaria mosquito 1 5 INV 7165
+Anopheles maculipennis 1 5 INV 41429
Antheraea yamamai Japanese oak silkmoth 1 5 INV 7121
Antirrhinum majus snapdragon 1 1 PLN 4151
Aotus nancymaae Ma's night monkey 1 2 PRI 37293
-Apis mellifera honeybee 1 5 INV 7460
+Apis mellifera honey bee 1 5 INV 7460
+Apium graveolens 1 1 PLN 4045
Aplysia californica California sea hare 1 5 INV 6500
-Aquifex aeolicus 11 0 BCT 63363
+Apodemus sylvaticus European woodmouse 1 2 ROD 10129
+Arabidopsis lyrata 1 1 PLN 59689
+Arabidopsis suecica 1 1 PLN 45249
Arabidopsis thaliana thale cress 1 1 PLN 3702
+Arachis hypogaea peanut 1 1 PLN 3818
+Araneus ventricosus 1 5 INV 182803
Archaeoglobus fulgidus 11 0 BCT 2234
+Argopecten irradians 1 5 INV 31199
Artemia franciscana 1 5 INV 6661
+Ascaris lumbricoides common roundworm 1 5 INV 6252
Ascaris suum pig roundworm 1 5 INV 6253
+Ashbya gossypii 1 3 PLN 33169
+Asparagus officinalis garden asparagus 1 1 PLN 4686
Aspergillus flavus 1 4 PLN 5059
Aspergillus fumigatus 1 4 PLN 5085
+Aspergillus nidulans 1 4 PLN 162425
Aspergillus niger 1 4 PLN 5061
-Aspergillus nomius 1 4 PLN 41061
Aspergillus oryzae 1 4 PLN 5062
-Autographa californica nucleopolyhedrovirus 1 0 VRL 46015
+Aspergillus terreus 1 4 PLN 33178
+Aspergillus tubingensis 1 4 PLN 5068
+Ateles geoffroyi black-handed spider monkey 1 2 PRI 9509
Avena sativa oat 1 1 PLN 4498
Avian infectious bronchitis virus 1 0 VRL 11120
Avicennia marina 1 1 PLN 82927
-Azospirillum brasilense 11 0 BCT 192
Azotobacter vinelandii 11 0 BCT 354
B19 virus 1 0 VRL 10798
-Bacillus amyloliquefaciens 11 0 BCT 1390
Bacillus anthracis 11 0 BCT 1392
+Bacillus atticus 1 5 INV 36825
Bacillus cereus 11 0 BCT 1396
-Bacillus circulans 11 0 BCT 1397
Bacillus clausii 11 0 BCT 79880
-Bacillus halodurans 11 0 BCT 86665
+Bacillus grandii 1 5 INV 55088
Bacillus licheniformis 11 0 BCT 1402
-Bacillus megaterium 11 0 BCT 1404
-Bacillus phage phi29 11 0 PHG 10756
-Bacillus sphaericus 11 0 BCT 1421
+Bacillus lynceorum 1 5 INV 73234
Bacillus subtilis 11 0 BCT 1423
Bacillus thuringiensis 11 0 BCT 1428
-Bacteriophage lambda 11 0 PHG 10710
-Bacteriophage SPBc2 11 0 PHG 66797
-Bacteriophage SPP1 11 0 PHG 10724
-Bacteriophage T3 11 0 PHG 10759
+Bacillus whitei 1 5 INV 57870
Bacteroides fragilis 11 0 BCT 817
+Beauveria bassiana 1 4 PLN 176275
Bemisia tabaci 1 5 INV 7038
Beta vulgaris 1 1 PLN 161934
Betula pendula European white birch 1 1 PLN 3505
+Bifidobacterium longum 11 0 BCT 216816
Biomphalaria glabrata bloodfluke planorb 1 5 INV 6526
+Biomphalaria pfeifferi 1 5 INV 112525
+Biphyllus lunatus 1 5 INV 197003
Bluetongue virus 1 0 VRL 40051
Blumeria graminis 1 4 PLN 34373
Bombyx mandarina wild silkworm 1 5 INV 7092
Bombyx mori domestic silkworm 1 5 INV 7091
-Bombyx mori nuclear polyhedrosis virus 1 0 VRL 10458
Boophilus microplus southern cattle tick 1 5 INV 6941
Bordetella bronchiseptica 11 0 BCT 518
Bordetella pertussis 11 0 BCT 520
-Borna disease virus 1 0 VRL 12455
Borrelia afzelii 11 0 BCT 29518
Borrelia burgdorferi Lyme disease spirochete 11 0 BCT 139
Borrelia garinii 11 0 BCT 29519
Bos indicus zebu 1 2 MAM 9915
Bos taurus cow 1 2 MAM 9913
Bothrops insularis island jararaca 1 2 VRT 8723
+Botryllus schlosseri 1 13 INV 30301
Botryotinia fuckeliana 1 4 PLN 40559
-Bovine coronavirus 1 0 VRL 11128
-Bovine herpesvirus 1 1 0 VRL 10320
-Bovine herpesvirus 4 1 0 VRL 10385
Bovine respiratory syncytial virus 1 0 VRL 11246
-Bovine rotavirus 1 0 VRL 10927
Bradyrhizobium japonicum 11 0 BCT 375
Branchiostoma belcheri 1 5 INV 7741
Branchiostoma floridae Florida lancelet 1 5 INV 7739
+Brassica campestris 1 1 PLN 3711
Brassica juncea 1 1 PLN 3707
Brassica napus rape 1 1 PLN 3708
Brassica oleracea 1 1 PLN 3712
Brassica rapa 1 1 PLN 3711
-Brevibacillus brevis 11 0 BCT 1393
Brucella melitensis 11 0 BCT 29459
Brugia malayi 1 5 INV 6279
+Bruguiera gymnorrhiza 1 1 PLN 39984
Bubalus bubalis water buffalo 1 2 MAM 89462
Buchnera aphidicola 11 0 BCT 9
-Buchnera sp. APS 11 0 BCT 107806
-Bungarus multicinctus many-banded krait 1 2 VRT 8616
Burkholderia cepacia 11 0 BCT 292
Burkholderia fungorum 11 0 BCT 134537
Burkholderia pseudomallei 11 0 BCT 28450
Caenorhabditis briggsae 1 5 INV 6238
Caenorhabditis elegans 1 5 INV 6239
Callithrix jacchus white-tufted-ear marmoset 1 2 PRI 9483
-Camelpox virus 1 0 VRL 28873
+Callosobruchus maculatus cowpea weevil 1 5 INV 64391
Camelus dromedarius Arabian camel 1 2 MAM 9838
Campylobacter jejuni 11 0 BCT 197
Candida albicans 12 4 PLN 5476
+Candida famata 1 3 PLN 4959
Candida glabrata 1 3 PLN 5478
Candida tropicalis 12 3 PLN 5482
-Candidatus Carsonella ruddii 11 0 BCT 114186
+Candidula unifasciata 1 5 INV 100452
Canis familiaris dog 1 2 MAM 9615
Capra hircus goat 1 2 MAM 9925
Caprine arthritis-encephalitis virus 1 0 VRL 11660
Capsicum annuum 1 1 PLN 4072
+Capsicum chinense 1 1 PLN 80379
+Carabus granulatus 1 5 INV 118799
Carassius auratus goldfish 1 2 VRT 7957
-Catharanthus roseus Madagascar periwinkle 1 1 PLN 4058
+Carica papaya papaya 1 1 PLN 3649
Caulobacter crescentus 11 0 BCT 155892
+Caulobacter vibrioides 11 0 BCT 155892
Cavia porcellus domestic guinea pig 1 2 ROD 10141
Ceratitis capitata Mediterranean fruit fly 1 5 INV 7213
Ceratodon purpureus 1 1 PLN 3225
Ceratopteris richardii 1 1 PLN 49495
Cercopithecus aethiops African green monkey 1 2 PRI 9534
Cervus elaphus red deer 1 2 MAM 9860
-Chaetosphaeridium globosum 1 1 PLN 96477
-Chicken anemia virus 1 0 VRL 12618
-Chimpanzee cytomegalovirus 1 0 VRL 188763
-Chironomus thummi 1 5 INV 7154
-Chlamydia muridarum 11 0 BCT 83560
+Chaetodipus intermedius rock pocket mouse 1 2 ROD 38666
+Chaetomium globosum 1 4 PLN 38033
Chlamydia trachomatis 11 0 BCT 813
Chlamydomonas reinhardtii 1 1 PLN 3055
Chlamydophila pneumoniae 11 0 BCT 83558
-Chlorella vulgaris 1 1 PLN 3077
+Chlamydotis undulata 1 2 VRT 172680
Chlorobium tepidum 11 0 BCT 1097
Chloroflexus aurantiacus 11 0 BCT 1108
Cicer arietinum chickpea 1 1 PLN 3827
+Cicindela campestris 1 5 INV 150234
Ciona intestinalis 1 13 INV 7719
-Citrobacter freundii 11 0 BCT 546
+Ciona savignyi 1 13 INV 51511
Citrullus lanatus watermelon 1 1 PLN 3654
+Citrus reticulata 1 1 PLN 85571
Citrus sinensis 1 1 PLN 2711
Citrus tristeza virus 1 0 VRL 12162
Citrus unshiu 1 1 PLN 55188
Citrus x paradisi 1 1 PLN 37656
Cladosporium fulvum 1 4 PLN 5499
+Cleome hassleriana 1 1 PLN 28532
+Clonorchis sinensis 1 9 INV 79923
Clostridium acetobutylicum 11 0 BCT 1488
-Clostridium botulinum 11 0 BCT 1491
Clostridium difficile 11 0 BCT 1496
-Clostridium pasteurianum 11 0 BCT 1501
Clostridium perfringens 11 0 BCT 1502
Clostridium thermocellum 11 0 BCT 1515
Coccidioides immitis 1 4 PLN 5501
+Codonopsis lanceolata 1 1 PLN 103999
Coffea arabica coffee 1 1 PLN 13443
+Colletotrichum gloeosporioides 1 4 PLN 5457
Colletotrichum trifolii 1 4 PLN 5466
Columba livia domestic pigeon 1 2 VRT 8932
-Comamonas testosteroni 11 0 BCT 285
Conidiobolus coronatus 1 4 PLN 34488
+Cooperia oncophora 1 5 INV 27828
+Coprinopsis cinerea 1 4 PLN 5346
+Coprinus cinereus 1 4 PLN 5346
+Cordyceps bassiana 1 4 PLN 176275
+Coregonus clupeaformis 1 2 VRT 59861
Corynebacterium glutamicum 11 0 BCT 1718
-Cotton leaf curl virus 1 0 VRL 53010
+Corynebacterium pseudotuberculosis 11 0 BCT 1719
Coturnix coturnix common quail 1 2 VRT 9091
Coturnix japonica Japanese quail 1 2 VRT 93934
-Cowpox virus 1 0 VRL 10243
-Coxiella burnetii 11 0 BCT 777
Crassostrea gigas Pacific oyster 1 5 INV 29159
Crassostrea virginica eastern oyster 1 5 INV 6565
Cricetulus griseus Chinese hamster 1 2 ROD 10029
-Crithidia fasciculata 1 4 INV 5656
Crocus sativus 1 1 PLN 82528
+Cryphonectria parasitica 1 4 PLN 5116
+Cryptococcus bacillisporus 1 4 PLN 37769
+Cryptococcus neoformans 1 4 PLN 5207
Cryptomeria japonica Japanese cedar 1 1 PLN 3369
Cryptosporidium parvum 1 4 INV 5807
Ctenocephalides felis cat flea 1 5 INV 7515
+Ctenopharyngodon idella grass carp 1 2 VRT 7959
Cucumber mosaic virus cucumber mosaic cucumovirus 1 0 VRL 12305
Cucumis melo muskmelon 1 1 PLN 3656
Cucumis sativus cucumber 1 1 PLN 3659
-Cyanidium caldarium 1 1 PLN 2771
-Cyanophora paradoxa 1 1 PLN 2762
-Cydia pomonella granulovirus 1 0 VRL 28289
+Culex pipiens house mosquito 1 5 INV 7175
+Curculio glandium 1 5 INV 197013
+Cycas rumphii 1 1 PLN 58031
Cynodon dactylon Bermuda grass 1 1 PLN 28909
Cyprinus carpio common carp 1 2 VRT 7962
+Daktulosphaira vitifoliae grape phylloxera 1 5 INV 58002
Danio rerio zebrafish 1 2 VRT 7955
+Dasypus novemcinctus nine-banded armadillo 1 2 MAM 9361
Daucus carota carrot 1 1 PLN 4039
Debaryomyces hansenii 1 3 PLN 4959
Deinococcus radiodurans 11 0 BCT 1299
+Delacroixia coronata 1 4 PLN 34488
Dendrocopos major 1 2 VRT 137523
Dengue virus 1 0 VRL 12637
Descurainia sophia 1 1 PLN 89411
Desulfitobacterium hafniense 11 0 BCT 49338
-Desulfovibrio vulgaris 11 0 BCT 881
+Desulfovibrio desulfuricans 11 0 BCT 876
Diadema antillarum 1 9 INV 105358
-Diadema savignyi 1 9 INV 105360
-Diadema setosum 1 9 INV 31175
Dianthus caryophyllus clove pink 1 1 PLN 3570
-Dichelobacter nodosus 11 0 BCT 870
+Dicentrarchus labrax European sea bass 1 2 VRT 13489
Dictyostelium discoideum 1 1 INV 44689
-Dirofilaria immitis 1 5 INV 6287
+Dirofilaria immitis dog heartworm nematode 1 5 INV 6287
+Dreissena polymorpha 1 5 INV 45954
Drosophila americana 1 5 INV 40366
Drosophila ananassae 1 5 INV 7217
+Drosophila buzzatii 1 5 INV 7264
Drosophila mauritiana 1 5 INV 7226
Drosophila melanogaster fruit fly 1 5 INV 7227
+Drosophila miranda 1 5 INV 7229
Drosophila persimilis 1 5 INV 7234
Drosophila pseudoobscura 1 5 INV 7237
Drosophila simulans 1 5 INV 7240
Drosophila subobscura 1 5 INV 7241
-Drosophila teissieri 1 5 INV 7243
Drosophila virilis 1 5 INV 7244
Drosophila yakuba 1 5 INV 7245
+Dugesia japonica 1 9 INV 6161
Dunaliella salina 1 1 PLN 3046
-Eastern equine encephalitis virus 1 0 VRL 11021
Echinococcus granulosus 1 9 INV 6210
Echinococcus multilocularis 1 9 INV 6211
-Echinometra mathaei 1 9 INV 31178
-Ectocarpus siliculosus virus 1 0 VRL 37665
-Ectromelia virus 1 0 VRL 12643
+Echinostoma paraensei 1 14 INV 48215
Eimeria tenella 1 4 INV 5802
+Elephas maximus Asiatic elephant 1 2 MAM 9783
Emericella nidulans 1 4 PLN 162425
-Encephalitozoon cuniculi 1 1 INV 6035
+Emiliania huxleyi 1 4 PLN 2903
Entamoeba histolytica 1 1 INV 5759
-Enterobacter aerogenes 11 0 BCT 548
+Entamoeba invadens 1 1 INV 33085
Enterobacter cloacae 11 0 BCT 550
-Enterobacteria phage M13 11 0 PHG 10870
-Enterobacteria phage Mu 11 0 PHG 10677
-Enterobacteria phage P22 11 0 PHG 10754
-Enterobacteria phage T4 11 0 PHG 10665
Enterobacteria phage T7 11 0 PHG 10760
Enterococcus faecalis 11 0 BCT 1351
Enterococcus faecium 11 0 BCT 1352
-Epiphyas postvittana nucleopolyhedrovirus 1 0 VRL 70600
+Epinephelus quernus Hawaiian grouper 1 2 VRT 212795
Equine arteritis virus 1 0 VRL 11047
-Equine herpesvirus 1 1 0 VRL 10326
-Equine herpesvirus 4 1 0 VRL 10331
Equine infectious anemia virus 1 0 VRL 11665
Equus caballus horse 1 2 MAM 9796
Eremothecium gossypii 1 3 PLN 33169
Erwinia amylovora 11 0 BCT 552
-Erwinia chrysanthemi 11 0 BCT 556
Escherichia coli 11 0 BCT 562
-Euglena gracilis 1 4 PLN 3039
+Eschscholzia californica California poppy 1 1 PLN 3467
+Eucalyptus globulus 1 1 PLN 34317
+Eucalyptus grandis 1 1 PLN 71139
+Eucalyptus tereticornis 1 1 PLN 183855
+Euhadra peliomphala 1 5 INV 87841
Eulemur fulvus brown lemur 1 2 PRI 13515
Euphorbia esula leafy spurge 1 1 PLN 3993
Euphorbia lagascae 1 1 PLN 54672
-Feline calicivirus 1 0 VRL 11978
Feline immunodeficiency virus 1 0 VRL 11673
+Feline leukemia virus 1 0 VRL 11768
Felis catus cat 1 2 MAM 9685
Ferroplasma acidarmanus 11 0 BCT 97393
+Filobasidiella bacillispora 1 4 PLN 37769
Filobasidiella neoformans 1 4 PLN 5207
Foot-and-mouth disease virus A 1 0 VRL 12111
Foot-and-mouth disease virus O 1 0 VRL 12118
-Fowlpox virus 1 0 VRL 10261
Fragaria x ananassa 1 1 PLN 3747
+Fragilariopsis cylindrus 1 1 PLN 186039
+Francisella tularensis 11 0 BCT 263
Fucus distichus 1 1 PLN 3012
+Fugu rubripes 1 2 VRT 31033
Fundulus heteroclitus killifish 1 2 VRT 8078
Fusarium oxysporum 1 4 PLN 5507
Fusarium sporotrichioides 1 4 PLN 5514
+Fusarium subglutinans 1 4 PLN 42677
Fusobacterium nucleatum 11 0 BCT 851
Gadus morhua Atlantic cod 1 2 VRT 8049
-Gallid herpesvirus 1 1 0 VRL 10386
-Gallid herpesvirus 2 1 0 VRL 10390
-Gallid herpesvirus 3 1 0 VRL 35250
Gallus gallus chicken 1 2 VRT 9031
Gasterosteus aculeatus three spined stickleback 1 2 VRT 69293
+GB virus C/Hepatitis G virus Hepatitis GB virus C / Hepatitis G virus 1 0 VRL 54290
Geobacillus stearothermophilus 11 0 BCT 1422
+Geobacter metallireducens 11 0 BCT 28232
Geochelone nigra 1 2 VRT 66189
Giardia intestinalis 1 0 INV 5741
+Giardia lamblia 1 0 INV 5741
+Gibberella moniliformis 1 4 PLN 117187
Gibberella zeae 1 4 PLN 5518
Gillichthys mirabilis long-jawed mudsucker 1 2 VRT 8222
Ginglymostoma cirratum nurse shark 1 2 VRT 7801
+Ginkgo biloba maidenhair tree 1 1 PLN 3311
Globodera pallida 1 5 INV 36090
Globodera rostochiensis 1 5 INV 31243
Glomerella cingulata 1 4 PLN 5457
Glomus intraradices 1 4 PLN 4876
+Glomus versiforme 1 4 PLN 43425
+Glossina morsitans 1 5 INV 7394
Glycine clandestina 1 1 PLN 45687
Glycine max soybean 1 1 PLN 3847
Glycine tomentella 1 1 PLN 44015
Glyphorynchus spirurus wedge-billed woodcreeper 1 2 VRT 135974
+Gnetum gnemon 1 1 PLN 3382
Gorilla gorilla gorilla 1 2 PRI 9593
Gossypium arboreum 1 1 PLN 29729
+Gossypium barbadense sea-island cotton 1 1 PLN 3634
+Gossypium herbaceum 1 1 PLN 34274
Gossypium hirsutum upland cotton 1 1 PLN 3635
+Gossypium raimondii 1 1 PLN 29730
Gracilaria gracilis 1 4 PLN 2777
+Gregarina niphandrodes 1 4 INV 110365
+Griffithsia japonica 1 1 PLN 83288
Guillardia theta 1 1 PLN 55529
+Haematobia irritans horn fly 1 5 INV 7368
Haemonchus contortus 1 5 INV 6289
Haemophilus influenzae 11 0 BCT 727
Haloarcula marismortui 11 0 BCT 2238
-Halobacterium salinarum 11 0 BCT 2242
Halobacterium sp. NRC-1 11 0 BCT 64091
+Halobaculum gomorrense 11 0 BCT 43928
Halocynthia roretzi 1 13 INV 7729
-Haloferax volcanii 11 0 BCT 2246
-Hantaan virus 1 0 VRL 11599
+Halorubrum lacusprofundi 11 0 BCT 2247
+Hebeloma cylindrosporum 1 4 PLN 76867
+Hedyotis centranthoides 1 1 PLN 219666
+Hedyotis terminalis 1 1 PLN 219667
Helianthus annuus common sunflower 1 1 PLN 4232
+Helianthus argophyllus 1 1 PLN 73275
+Helianthus paradoxus 1 1 PLN 73304
Helicobacter pylori 11 0 BCT 210
Heliconius melpomene 1 5 INV 34740
Helicoverpa armigera cotton bollworm 1 5 INV 29058
-Helicoverpa armigera nuclear polyhedrosis virus 1 0 VRL 51313
-Helicoverpa zea single nucleocapsid nucleopolyhedrovirus 1 0 VRL 10468
-Heliocoverpa armigera nucleopolyhedrovirus G4 1 0 VRL 148363
-Heliothis zea virus 1 1 0 VRL 29250
+Heliocidaris erythrogramma 1 9 INV 7634
+Hemicentrotus pulcherrimus 1 9 INV 7650
Hepatitis A virus 1 0 VRL 12092
Hepatitis B virus 1 0 VRL 10407
Hepatitis C virus 1 0 VRL 11103
Hepatitis D virus 1 0 VRL 12475
Hepatitis E virus 1 0 VRL 12461
-Hepatitis G virus 1 0 VRL 45255
-Hepatitis GB virus C 1 0 VRL 39839
Heterobasidion annosum 1 4 PLN 13563
Heterodera glycines 1 5 INV 51029
-Heterodontus francisci horn shark 1 2 VRT 7792
+Heterodera schachtii 1 5 INV 97005
Hevea brasiliensis Para rubber tree 1 1 PLN 3981
-Hirudo medicinalis medicinal leech 1 5 INV 6421
+Hippoglossus hippoglossus Atlantic halibut 1 2 VRT 8267
+Histophilus somni 11 0 BCT 731
+Holothuria nobilis 1 9 INV 221420
+Homalodisca coagulata glassy-winged sharpshooter 1 5 INV 197043
Homo sapiens human 1 2 PRI 9606
Hordeum vulgare 1 1 PLN 4513
Human adenovirus B 1 0 VRL 108098
Human adenovirus C 1 0 VRL 129951
-Human adenovirus D 1 0 VRL 130310
Human astrovirus 1 0 VRL 12702
+Human endogenous retrovirus 1 0 VRL 11827
Human enterovirus A 1 0 VRL 138948
Human enterovirus B 1 0 VRL 138949
Human enterovirus C 1 0 VRL 138950
Human herpesvirus 1 1 0 VRL 10298
-Human herpesvirus 2 1 0 VRL 10310
Human herpesvirus 3 1 0 VRL 10335
Human herpesvirus 4 Epstein-Barr virus 1 0 VRL 10376
Human herpesvirus 5 1 0 VRL 10359
-Human herpesvirus 6 1 0 VRL 10368
-Human herpesvirus 7 1 0 VRL 10372
Human herpesvirus 8 Kaposi's sarcoma-associated herpesvirus - Human herpesvirus 8 1 0 VRL 37296
Human immunodeficiency virus 1 0 VRL 12721
Human immunodeficiency virus 1 1 0 VRL 11676
@@ -344,77 +377,85 @@ Human immunodeficiency virus 2 1 0 VRL 11709
Human papillomavirus 1 0 VRL 10566
Human papillomavirus type 16 1 0 VRL 10581
Human respiratory syncytial virus 1 0 VRL 11250
-Hydra vulgaris 1 4 INV 6087
+Hydra magnipapillata 1 4 INV 6085
Hylobates lar common gibbon 1 2 PRI 9580
Hypocrea jecorina 1 4 PLN 51453
+Hypocrea lixii 1 4 PLN 5544
+Hypsibius dujardini 1 5 INV 232323
Ichthyophthirius multifiliis 6 4 INV 5932
-Ictalurid herpesvirus 1 1 0 VRL 10401
Ictalurus furcatus 1 2 VRT 66913
Ictalurus punctatus channel catfish 1 2 VRT 7998
Infectious bursal disease virus Gumboro virus 1 0 VRL 10995
-Influenza A virus H3N2 1 0 VRL 41857
-Invertebrate iridescent virus 6 1 0 VRL 176652
+Infectious salmon anemia virus 1 0 VRL 55987
Ipomoea batatas sweet potato 1 1 PLN 4120
+Ipomoea nil Japanese morning glory 1 1 PLN 35883
+Ipomoea trifida 1 1 PLN 35884
+Ips pini North American pine engraver 1 5 INV 102803
+Iris hollandica 1 1 PLN 35876
+Isotricha sp. BBF-2003 1 4 INV 223153
Ixodes scapularis black-legged tick 1 5 INV 6945
Japanese encephalitis virus 1 0 VRL 11072
JC virus 1 0 VRL 10632
-Klebsiella aerogenes 11 0 BCT 28451
+Juglans regia English walnut 1 1 PLN 51240
+Kandelia candel 1 1 PLN 61147
Klebsiella oxytoca 11 0 BCT 571
Klebsiella pneumoniae 11 0 BCT 573
+Kluyveromyces delphensis 1 3 PLN 51657
Kluyveromyces lactis 1 3 PLN 28985
Kluyveromyces marxianus 1 3 PLN 4911
Kluyveromyces thermotolerans 1 3 PLN 4916
Laccaria bicolor 1 4 PLN 29883
-Lactobacillus casei 11 0 BCT 1582
+Lactobacillus brevis 11 0 BCT 1580
Lactobacillus delbrueckii 11 0 BCT 1584
-Lactobacillus helveticus 11 0 BCT 1587
Lactobacillus plantarum 11 0 BCT 1590
-Lactobacillus sakei 11 0 BCT 1599
Lactococcus lactis 11 0 BCT 1358
Lactuca sativa 1 1 PLN 4236
+Lactuca serriola 1 1 PLN 75943
Lama glama llama 1 2 MAM 9844
Laminaria digitata 1 1 PLN 80365
+Lawsonia intracellularis 11 0 BCT 29546
Legionella pneumophila 11 0 BCT 446
+Leifsonia xyli 11 0 BCT 1575
+Leishmania braziliensis 1 4 INV 5660
Leishmania donovani 1 4 INV 5661
Leishmania infantum 1 4 INV 5671
Leishmania major 1 4 INV 5664
-Leishmania mexicana 1 4 INV 5665
-Leishmania tarentolae 1 4 INV 5689
+Lemur catta ring-tailed lemur 1 2 PRI 9447
Leopardus pardalis ocelot 1 2 MAM 32538
Lepilemur septentrionalis northern sportive lemur 1 2 PRI 78584
Leptospira interrogans 11 0 BCT 173
Leuconostoc mesenteroides 11 0 BCT 1245
-Limnodynastes tasmaniensis 1 2 VRT 105385
+Leymus chinensis 1 1 PLN 52714
+Limnanthes alba white meadowfoam 1 1 PLN 42439
+Lingulodinium polyedrum 1 4 PLN 160621
+Linum usitatissimum flax 1 1 PLN 4006
Listeria innocua 11 0 BCT 1642
Listeria monocytogenes 11 0 BCT 1639
+Litomosoides sigmodontis 1 5 INV 42156
Litopenaeus setiferus white shrimp 1 5 INV 64468
Litopenaeus vannamei Pacific white shrimp 1 5 INV 6689
-Locusta migratoria migratory locust 1 5 INV 7004
-Lotus japonicus 1 1 PLN 34305
+Littorina littorea 1 5 INV 31216
+Lotus corniculatus 1 1 PLN 47247
Loxodonta africana African savanna elephant 1 2 MAM 9785
-Luciola cruciata Japanese firefly 1 5 INV 7051
Lumbricus rubellus humus earthworm 1 5 INV 35632
-Lumpy skin disease virus 1 0 VRL 59509
+Lupinus albus white lupine 1 1 PLN 3870
Lupinus luteus yellow lupine 1 1 PLN 3873
+Luscinia svecica 1 2 VRT 52792
Lutzomyia longipalpis 1 5 INV 7200
Lycopersicon esculentum tomato 1 1 PLN 4081
Lycopersicon hirsutum 1 1 PLN 62890
Lycopersicon pennellii 1 1 PLN 28526
-Lymantria dispar nucleopolyhedrovirus 1 0 VRL 10449
-Lymnaea stagnalis great pond snail 1 5 INV 6523
Macaca fascicularis crab-eating macaque 1 2 PRI 9541
+Macaca fuscata Japanese macaque 1 2 PRI 9542
Macaca mulatta rhesus monkey 1 2 PRI 9544
Macaca nemestrina pig-tailed macaque 1 2 PRI 9545
+Macropus eugenii tammar wallaby 1 2 MAM 9315
Magnaporthe grisea 1 4 PLN 148305
Magnetococcus sp. MC-1 11 0 BCT 156889
Magnetospirillum magnetotacticum 11 0 BCT 188
-Maize streak virus 1 0 VRL 10821
Malus x domestica apple tree 1 1 PLN 3750
-Mamestra configurata nucleopolyhedrovirus 1 0 VRL 191492
-Mamestra configurata nucleopolyhedrovirus B 1 0 VRL 204440
Manduca sexta tobacco hornworm 1 5 INV 7130
Manihot esculenta cassava 1 1 PLN 3983
-Mannheimia haemolytica 11 0 BCT 75985
Marchantia polymorpha liverwort 1 1 PLN 3197
Marmota monax woodchuck 1 2 ROD 9995
Marsupenaeus japonicus 1 5 INV 27405
@@ -423,137 +464,144 @@ Mastigamoeba balamuthi 1 1 INV 108607
Measles virus 1 0 VRL 11234
Medicago sativa 1 1 PLN 3879
Medicago truncatula barrel medic 1 1 PLN 3880
+Meladema coriacea 1 5 INV 107907
Melaleuca alternifolia tea tree 1 1 PLN 164405
-Melanoplus sanguinipes entomopoxvirus 1 0 VRL 83191
-Meleagrid herpesvirus 1 herpesvirus of turkeys 1 0 VRL 37108
Meleagris gallopavo turkey 1 2 VRT 9103
Meloidogyne arenaria 1 5 INV 6304
+Meloidogyne chitwoodi 1 5 INV 59747
Meloidogyne hapla 1 5 INV 6305
Meloidogyne incognita southern root-knot nematode 1 5 INV 6306
Meloidogyne javanica root-knot nematode 1 5 INV 6303
+Meloidogyne paranaensis 1 5 INV 189293
Mentha x piperita peppermint 1 1 PLN 34256
+Meriones unguiculatus Mongolian gerbil 1 2 ROD 10047
Mesembryanthemum crystallinum common iceplant 1 1 PLN 3544
+Mesobuthus gibbosus 1 5 INV 123226
Mesocricetus auratus golden hamster 1 2 ROD 10036
-Mesorhizobium loti 11 0 BCT 381
-Mesostigma viride 1 1 PLN 41882
Metarhizium anisopliae 1 4 PLN 5530
-Methanocaldococcus jannaschii 11 0 BCT 2190
-Methanopyrus kandleri 11 0 BCT 2320
Methanosarcina acetivorans 11 0 BCT 2214
Methanosarcina barkeri 11 0 BCT 2208
Methanosarcina mazei 11 0 BCT 2209
Methanothermobacter thermautotrophicus 11 0 BCT 145262
-Methylobacterium extorquens 11 0 BCT 408
Microbotryum violaceum 1 4 PLN 5272
Microbulbifer degradans 11 0 BCT 86304
Microcystis aeruginosa 11 0 BCT 1126
-Molluscum contagiosum virus 1 0 VRL 10279
-Monkeypox virus 1 0 VRL 10244
-Monodelphis domestica South American short-tailed grey opossum 1 2 MAM 13616
+Micromonospora carbonacea 11 0 BCT 47853
+Microtus oeconomus tundra vole 1 2 ROD 64717
+Mnemiopsis leidyi 1 4 INV 27923
+Molgula tectiformis 1 13 INV 30286
+Moneuplotes crassus 10 4 INV 5936
+Monodelphis domestica gray short-tailed opossum 1 2 MAM 13616
Moraxella catarrhalis 11 0 BCT 480
-Mouse cytomegalovirus 1 1 0 VRL 10366
+Morone saxatilis striped sea-bass 1 2 VRT 34816
+Motacilla flava 1 2 VRT 180448
Mumps virus 1 0 VRL 11161
-Murid herpesvirus 4 1 0 VRL 33708
-Murine hepatitis virus 1 0 VRL 11138
Murine leukemia virus 1 0 VRL 11786
Mus musculus house mouse 1 2 ROD 10090
Mus spretus western wild mouse 1 2 ROD 10096
Musa acuminata 1 1 PLN 4641
Musca domestica house fly 1 5 INV 7370
-Mycobacteriophage D29 11 0 PHG 28369
Mycobacterium avium 11 0 BCT 1764
Mycobacterium bovis 11 0 BCT 1765
Mycobacterium leprae 11 0 BCT 1769
-Mycobacterium phage L5 11 0 PHG 31757
Mycobacterium smegmatis 11 0 BCT 1772
Mycobacterium tuberculosis 11 0 BCT 1773
Mycoplasma capricolum 4 0 BCT 2095
-Mycoplasma gallisepticum 4 0 BCT 2096
Mycoplasma genitalium 4 0 BCT 2097
+Mycoplasma haemofelis 4 0 BCT 29501
Mycoplasma hominis 4 0 BCT 2098
-Mycoplasma pneumoniae 4 0 BCT 2104
-Mycoplasma pulmonis 4 0 BCT 2107
Mycosphaerella graminicola 1 4 PLN 54734
+Mystacina tuberculata New Zealand lesser short-tailed bat 1 2 MAM 94961
Mytilus edulis 1 5 INV 6550
Mytilus galloprovincialis Mediterranean mussel 1 5 INV 29158
+Mytilus trossulus common blue mussel 1 5 INV 6551
Myxococcus xanthus 11 0 BCT 34
-Myxoma virus 1 0 VRL 10273
+Natrialba asiatica 11 0 BCT 64602
Necator americanus 1 5 INV 51031
Nectria haematococca 1 4 PLN 140110
Neisseria gonorrhoeae 11 0 BCT 485
Neisseria meningitidis 11 0 BCT 487
Neospora caninum 1 4 INV 29176
-Nephroselmis olivacea 1 1 PLN 31312
+Neospora hughesi 1 4 INV 83675
Neurospora crassa 1 4 PLN 5141
Newcastle disease virus 1 0 VRL 11176
-Nicotiana plumbaginifolia curled-leaved tobacco 1 1 PLN 4092
+Nicotiana attenuata 1 1 PLN 49451
+Nicotiana benthamiana 1 1 PLN 4100
Nicotiana sylvestris wood tobacco 1 1 PLN 4096
Nicotiana tabacum common tobacco 1 1 PLN 4097
Nippostrongylus brasiliensis 1 5 INV 27835
-Nitrosomonas europaea 11 0 BCT 915
Norwalk virus 1 0 VRL 11983
Nostoc punctiforme 11 0 BCT 63737
-Nostoc sp. PCC 7120 11 0 BCT 103690
Novosphingobium aromaticivorans 11 0 BCT 48935
-Oceanobacillus iheyensis 11 0 BCT 182710
-Odontella sinensis 1 1 PLN 2839
+Nuphar advena 1 1 PLN 77108
+Ochrobactrum anthropi 11 0 BCT 529
+Ocinebrellus inornatus Asian drill 1 5 INV 213425
Oenococcus oeni 11 0 BCT 1247
-Oenothera elata 1 1 PLN 44456
Oikopleura dioica 1 5 INV 34765
+Olea europaea common olive 1 1 PLN 4146
Onchocerca volvulus 1 5 INV 6282
-Oncomelania hupensis 1 5 INV 56141
Oncorhynchus keta chum salmon 1 2 VRT 8018
-Oncorhynchus kisutch coho salmon 1 2 VRT 8019
Oncorhynchus mykiss rainbow trout 1 2 VRT 8022
+Oncorhynchus nerka sockeye salmon 1 2 VRT 8023
Oncorhynchus tshawytscha Chinook salmon 1 2 VRT 74940
+Opsanus beta 1 2 VRT 95145
Oreochromis niloticus Nile tilapia 1 2 VRT 8128
-Orgyia pseudotsugata single capsid nuclear polyhedrosis virus 1 0 VRL 10450
+Ornithodoros porcinus 1 5 INV 34594
Ornithorhynchus anatinus platypus 1 2 MAM 9258
Oryctolagus cuniculus rabbit 1 2 MAM 9986
+Oryza minuta 1 1 PLN 63629
Oryza sativa 1 1 PLN 4530
Oryzias latipes Japanese medaka 1 2 VRT 8090
Ostertagia ostertagi 1 5 INV 6317
Ostreococcus tauri 1 1 PLN 70448
+Otis tarda 1 2 VRT 73107
Ovis aries sheep 1 2 MAM 9940
+Oxytricha trifallax 6 4 INV 94289
+Pacifastacus leniusculus signal crayfish 1 5 INV 6720
Pan paniscus pygmy chimpanzee 1 2 PRI 9597
Pan troglodytes chimpanzee 1 2 PRI 9598
+Panax ginseng 1 1 PLN 4054
Pantoea agglomerans 11 0 BCT 549
Papio anubis olive baboon 1 2 PRI 9555
-Papio cynocephalus yellow baboon 1 2 PRI 9556
Papio hamadryas hamadryas baboon 1 2 PRI 9557
-Paracoccus denitrificans 11 0 BCT 266
+Paracoccidioides brasiliensis 1 4 PLN 121759
Paralichthys olivaceus bastard halibut 1 2 VRT 8255
-Paramecium bursaria Chlorella virus 1 1 0 VRL 10506
Paramecium tetraurelia 6 4 INV 5888
Parastrongyloides trichosuri 1 5 INV 131310
+Parus major 1 2 VRT 9157
Pasteurella multocida 11 0 BCT 747
+Pasteuria penetrans 11 0 BCT 86005
+Paxillus involutus 1 4 PLN 71150
+Pectobacterium atrosepticum 11 0 BCT 29471
Pectobacterium carotovorum 11 0 BCT 554
+Pediculus humanus human lice 1 5 INV 121225
Penaeus monodon black tiger shrimp 1 5 INV 6687
Penicillium marneffei 1 4 PLN 37727
+Pennisetum ciliare buffelgrass 1 1 PLN 35520
+Pennisetum glaucum 1 1 PLN 4543
+Peromyscus leucopus white-footed mouse 1 2 ROD 10041
Peromyscus maniculatus deer mouse 1 2 ROD 10042
Pestivirus type 1 1 0 VRL 11099
Pestivirus type 2 1 0 VRL 54314
Petromyzon marinus sea lamprey 1 2 VRT 7757
-Petroselinum crispum parsley 1 1 PLN 4043
Petunia x hybrida 1 1 PLN 4102
Phaeodactylum tricornutum 1 1 PLN 2850
Phanerochaete chrysosporium 1 4 PLN 5306
+Phaseolus coccineus 1 1 PLN 3886
Phaseolus vulgaris 1 1 PLN 3885
+Phoca vitulina harbor seal 1 2 MAM 9720
Photorhabdus luminescens 11 0 BCT 29488
-Phylloscopus trochiloides 1 2 VRT 48154
-Physarum polycephalum slime mold 1 1 INV 5791
Physcomitrella patens 1 1 PLN 3218
-Physeter catodon sperm whale 1 2 MAM 9755
Phytophthora infestans potato late blight agent 1 1 PLN 4787
+Phytophthora nicotianae 1 1 PLN 4790
Phytophthora sojae 1 1 PLN 67593
Picea abies Norway spruce 1 1 PLN 3329
Pichia angusta 1 3 PLN 4905
Pichia farinosa 1 3 PLN 4920
Pinus pinaster 1 1 PLN 71647
-Pinus sylvestris Scots pine 1 1 PLN 3349
-Pinus sylvestris/Heterobasidion annosum 1 1 INV 169015
+Pinus radiata Monterey pine 1 1 PLN 3347
Pinus taeda loblolly pine 1 1 PLN 3352
-Pinus thunbergii Japanese black pine 1 1 PLN 3350
+Pisolithus microcarpus 1 4 PLN 178872
Pisolithus tinctorius 1 4 PLN 37468
Pisum sativum pea 1 1 PLN 3888
Planococcus lilacinus lilac mealybug 1 5 INV 40930
@@ -563,17 +611,26 @@ Plasmodium falciparum malaria parasite P. falciparum 1 4 INV 5833
Plasmodium vivax malaria parasite P. vivax 1 4 INV 5855
Plasmodium yoelii 1 4 INV 5861
Platichthys flesus European flounder 1 2 VRT 8260
+Platystomus albinus 1 5 INV 197009
+Plethodon elongatus Del Norte salamander 1 2 VRT 46761
+Pleuronectes platessa plaice 1 2 VRT 8262
Pleurotus ostreatus oyster mushroom 1 4 PLN 5322
+Plumbago zeylanica 1 1 PLN 76149
Pneumocystis carinii 1 4 PLN 4754
-Podospora anserina 1 4 PLN 5145
+Podarcis hispanica 1 2 VRT 74081
+Poecilia reticulata guppy 1 2 VRT 8081
Poliovirus 1 0 VRL 138953
Polyandrocarpa misakiensis 1 13 INV 7723
+Poncirus trifoliata 1 1 PLN 37690
Pongo pygmaeus orangutan 1 2 PRI 9600
+Populus alba x Populus glandulosa 1 1 PLN 153471
+Populus alba x Populus tremula 1 1 PLN 80863
Populus balsamifera 1 1 PLN 73824
+Populus balsamifera subsp. trichocarpa x Populus deltoides 1 1 PLN 3695
+Populus tremula 1 1 PLN 113636
Populus tremula x Populus tremuloides 1 1 PLN 47664
-Porcine circovirus 1 0 VRL 46221
+Populus tremuloides quaking aspen 1 1 PLN 3693
Porcine reproductive and respiratory syndrome virus 1 0 VRL 28344
-Porphyra purpurea 1 4 PLN 2787
Porphyra yezoensis 1 4 PLN 2788
Porphyromonas gingivalis 11 0 BCT 837
Potato virus Y 1 0 VRL 12216
@@ -581,79 +638,75 @@ Pratylenchus penetrans 1 5 INV 45929
Primate T-lymphotropic virus 1 1 0 VRL 194440
Primate T-lymphotropic virus 2 1 0 VRL 194441
Pristionchus pacificus 1 5 INV 54126
-Prochlorococcus marinus 11 0 BCT 1219
-Proteus mirabilis 11 0 BCT 584
-Proteus vulgaris 11 0 BCT 585
+Prunus armeniaca apricot 1 1 PLN 36596
Prunus dulcis almond 1 1 PLN 3755
Prunus persica peach 1 1 PLN 3760
Pseudomonas aeruginosa 11 0 BCT 287
Pseudomonas fluorescens 11 0 BCT 294
-Pseudomonas phage phiKZ 11 0 PHG 169683
Pseudomonas putida 11 0 BCT 303
Pseudomonas stutzeri 11 0 BCT 316
Pseudomonas syringae 11 0 BCT 317
Pseudopleuronectes americanus winter flounder 1 2 VRT 8265
-Pseudorabies virus 1 0 VRL 10345
Pseudotsuga menziesii Douglas fir 1 1 PLN 3357
-Psilotum nudum 1 1 PLN 3240
+Psoroptes equi var. ovis sheep scab mite 1 5 INV 83912
Psoroptes ovis sheep scab mite 1 5 INV 83912
-Puumala virus 1 0 VRL 11604
Pygoscelis adeliae Adelie penguin 1 2 VRT 9238
+Pyricularia grisea 1 4 PLN 148305
Pyrobaculum aerophilum 11 0 BCT 13773
-Pyrococcus abyssi 11 0 BCT 29292
Pyrococcus furiosus 11 0 BCT 2261
-Pyrococcus horikoshii 11 0 BCT 53953
Pyrocoelia rufa 1 5 INV 71223
+Pyrocystis lunula 1 4 PLN 2972
Pyrus communis pear 1 1 PLN 23211
-Rabbit fibroma virus 1 0 VRL 10271
Rabies virus 1 0 VRL 11292
-Raja erinacea little skate 1 2 VRT 7782
-Ralstonia eutropha 11 0 BCT 510
Ralstonia metallidurans 11 0 BCT 119219
Ralstonia solanacearum 11 0 BCT 305
Rana catesbeiana bullfrog 1 2 VRT 8400
+Rangifer tarandus reindeer 1 2 MAM 9870
Raphanus sativus radish 1 1 PLN 3726
-Rat cytomegalovirus 1 0 VRL 28304
Rattus norvegicus Norway rat 1 2 ROD 10116
+Rattus rattus black rat 1 2 ROD 10117
Respiratory syncytial virus 1 0 VRL 12814
Rhagoletis pomonella apple maggot 1 5 INV 28610
+Rhinolophus ferrumequinum greater horseshoe bat 1 2 MAM 59479
Rhizobium etli 11 0 BCT 29449
Rhizobium leguminosarum 11 0 BCT 384
-Rhizobium rhizogenes 11 0 BCT 359
+Rhizobium meliloti 11 0 BCT 382
+Rhizobium radiobacter 11 0 BCT 358
Rhizobium sp. NGR234 11 0 BCT 394
-Rhodobacter capsulatus 11 0 BCT 1061
+Rhizoctonia solani 1 4 PLN 107832
Rhodobacter sphaeroides 11 0 BCT 1063
Rhodococcus erythropolis 11 0 BCT 1833
Rhodospirillum rubrum 11 0 BCT 1085
+Rhopalosiphum padi bird cherry-oat aphid 1 5 INV 40932
Ricinus communis castor bean 1 1 PLN 3988
-Rickettsia conorii 11 0 BCT 781
Rickettsia prowazekii 11 0 BCT 782
Robinia pseudoacacia 1 1 PLN 35938
+Rosa chinensis 1 1 PLN 74649
Rosa hybrid cultivar 1 1 PLN 128735
Rotavirus A 1 0 VRL 28875
-Rotavirus C 1 0 VRL 36427
Rous sarcoma virus 1 0 VRL 11886
Rubella virus 1 0 VRL 11041
+Ruminococcus flavefaciens 11 0 BCT 1265
Saccharomyces bayanus 1 3 PLN 4931
Saccharomyces cariocanus 1 3 PLN 114526
Saccharomyces castellii 1 3 PLN 27288
Saccharomyces cerevisiae baker's yeast 1 3 PLN 4932
Saccharomyces exiguus 1 3 PLN 34358
Saccharomyces kluyveri 1 3 PLN 4934
+Saccharomyces kudriavzevii 1 3 PLN 114524
Saccharomyces mikatae 1 3 PLN 114525
Saccharomyces paradoxus 1 3 PLN 27291
Saccharomyces servazzii 1 3 PLN 27293
Saccharomyces unisporus 1 3 PLN 27294
-Saccharopolyspora erythraea 11 0 BCT 1836
+Saccharum officinarum 1 1 PLN 4547
Saguinus oedipus cotton-top tamarin 1 2 PRI 9490
Saimiri sciureus common squirrel monkey 1 2 PRI 9521
-Saimiriine herpesvirus 2 1 0 VRL 10381
+Salix viminalis osier 1 1 PLN 40686
Salmo salar Atlantic salmon 1 2 VRT 8030
Salmo trutta brown trout 1 2 VRT 8032
Salmonella enterica 11 0 BCT 28901
-Salmonella enteritidis 11 0 BCT 592
-Salmonella typhi 11 0 BCT 601
Salmonella typhimurium 11 0 BCT 602
+Salvelinus alpinus Arctic char 1 2 VRT 8036
Sarcocystis neurona 1 4 INV 42890
Sarcoptes scabiei 1 5 INV 52283
Scherffelia dubia 1 1 PLN 3190
@@ -662,16 +715,18 @@ Schistosoma mansoni 1 9 INV 6183
Schizophyllum commune 1 4 PLN 5334
Schizosaccharomyces pombe fission yeast 1 4 PLN 4896
Schmidtea mediterranea 1 9 INV 79327
+Sciaenops ocellatus 1 2 VRT 76340
Sclerotinia sclerotiorum 1 4 PLN 5180
+Sebastes mystinus 1 2 VRT 72088
Secale cereale rye 1 1 PLN 4550
Selaginella lepidophylla 1 1 PLN 59777
SEN virus 1 0 VRL 136966
Seriola quinqueradiata five-ray yellowtail 1 2 VRT 8161
Serratia marcescens 11 0 BCT 615
-Shigella boydii 11 0 BCT 621
-Shigella dysenteriae 11 0 BCT 622
+Sesamum indicum sesame 1 1 PLN 4182
+Sesbania rostrata 1 1 PLN 3895
+Shewanella oneidensis 11 0 BCT 70863
Shigella flexneri 11 0 BCT 623
-Shigella sonnei 11 0 BCT 624
Shrimp white spot syndrome virus 1 0 VRL 92652
Silene latifolia 1 1 PLN 37657
Silurana tropicalis western clawed frog 1 2 VRT 8364
@@ -684,117 +739,119 @@ Solanum tuberosum potato 1 1 PLN 4113
Sorghum bicolor sorghum 1 1 PLN 4558
Sorghum halepense 1 1 PLN 4560
Sorghum propinquum 1 1 PLN 132711
+Sparus aurata gilthead seabream 1 2 VRT 8175
+Sphingomonas aromaticivorans 11 0 BCT 48935
Spinacia oleracea spinach 1 1 PLN 3562
Spiroplasma kunkelii 4 0 BCT 47834
-Spodoptera exigua nucleopolyhedrovirus 1 0 VRL 10454
-Spodoptera litura nucleopolyhedrovirus 1 0 VRL 46242
+Sporotrichum pruinosum 1 4 PLN 5306
Staphylococcus aureus 11 0 BCT 1280
Staphylococcus epidermidis 11 0 BCT 1282
Stealth virus 1 1 0 VRL 36452
+Sterkiella histriomuscorum 6 4 INV 94289
Stevia rebaudiana 1 1 PLN 55670
Streptococcus agalactiae 11 0 BCT 1311
Streptococcus dysgalactiae 11 0 BCT 1334
-Streptococcus gordonii 11 0 BCT 1302
+Streptococcus equi 11 0 BCT 1336
Streptococcus mitis 11 0 BCT 28037
Streptococcus mutans 11 0 BCT 1309
Streptococcus oralis 11 0 BCT 1303
Streptococcus pneumoniae 11 0 BCT 1313
Streptococcus pyogenes 11 0 BCT 1314
-Streptococcus salivarius 11 0 BCT 1304
Streptococcus suis 11 0 BCT 1307
Streptococcus thermophilus 11 0 BCT 1308
-Streptomyces avermitilis 11 0 BCT 33903
-Streptomyces avidinii 11 0 BCT 1895
-Streptomyces clavuligerus 11 0 BCT 1901
Streptomyces coelicolor 11 0 BCT 1902
-Streptomyces griseus 11 0 BCT 1911
Streptomyces lividans 11 0 BCT 1916
Strongylocentrotus purpuratus 1 9 INV 7668
Strongyloides ratti 1 5 INV 34506
Strongyloides stercoralis 1 5 INV 6248
Struthio camelus ostrich 1 2 VRT 8801
-Stx2 converting bacteriophage I 11 0 PHG 180816
Suaeda maritima 1 1 PLN 126913
-Sulfolobus acidocaldarius 11 0 BCT 2285
+Suid herpesvirus 1 1 0 VRL 10345
Sulfolobus solfataricus 11 0 BCT 2287
-Sulfolobus tokodaii 11 0 BCT 111955
Sus scrofa pig 1 2 MAM 9823
-Swinepox virus 1 0 VRL 10276
+Symsagittifera roscofensis 1 5 INV 84072
Syncerus caffer African buffalo 1 2 MAM 9970
-Synechococcus sp. PCC 7002 11 0 BCT 32049
-Synechococcus sp. PCC 7942 11 0 BCT 1140
-Synechocystis sp. PCC 6803 11 0 BCT 1148
+Tadarida brasiliensis Brazilian free-tailed bat 1 2 MAM 9438
Taenia solium pork tapeworm 1 9 INV 6204
Takifugu rubripes 1 2 VRT 31033
+Tamarix androssowii 1 1 PLN 189785
+Tamias amoenus yellow-pine chipmunk 1 2 ROD 64679
Tamias ruficaudus red-tailed chipmunk 1 2 ROD 123792
Teladorsagia circumcincta 1 5 INV 45464
-Tetrahymena pyriformis 6 4 INV 5908
+Telestes souffia 1 2 VRT 129883
Tetrahymena thermophila 6 4 INV 5911
Tetraodon nigroviridis 1 2 VRT 99883
-Theileria annulata 1 4 INV 5874
+Thanatephorus cucumeris 1 4 PLN 107832
+Theileria parva 1 4 INV 5875
Thellungiella halophila 1 1 PLN 98038
-Thellungiella salsuginea 1 1 PLN 72664
+Theobroma cacao cacao 1 1 PLN 3641
Thermoanaerobacter tengcongensis 11 0 BCT 119072
-Thermoplasma acidophilum 11 0 BCT 2303
-Thermoplasma volcanium 11 0 BCT 50339
-Thermosynechococcus elongatus 11 0 BCT 146786
Thermotoga maritima 11 0 BCT 2336
Thermotoga sp. RQ2 11 0 BCT 126740
-Thermus aquaticus 11 0 BCT 271
Thermus thermophilus 11 0 BCT 274
-Tigriopus californicus 1 5 INV 6832
-Tobacco mosaic virus 1 0 VRL 12242
+Timarcha balearica 1 5 INV 79517
Toxocara canis 1 5 INV 6265
Toxoplasma gondii 1 4 INV 5811
+Toxoptera citricida brown citrus aphid 1 5 INV 223852
Toxostoma curvirostre 1 2 VRT 99878
-Transmissible gastroenteritis virus 1 0 VRL 11149
Treponema pallidum 11 0 BCT 160
Tribolium castaneum red flour beetle 1 5 INV 7070
Trichinella spiralis 1 5 INV 6334
Trichoderma harzianum 1 4 PLN 5544
+Trichoderma reesei 1 4 PLN 51453
Trichodesmium erythraeum 11 0 BCT 1206
Trichomonas vaginalis 1 0 INV 5722
+Trichoplusia ni cabbage looper 1 5 INV 7111
+Trichostrongylus vitrinus 1 5 INV 40352
+Trichosurus vulpecula silver-gray brushtail possum 1 2 MAM 9337
Trichuris muris 1 5 INV 70415
+Trichuris vulpis 1 5 INV 219738
+Trifolium repens white clover 1 1 PLN 3899
Triphysaria versicolor 1 1 PLN 64093
Triticum aestivum bread wheat 1 1 PLN 4565
Triticum monococcum 1 1 PLN 4568
Triticum turgidum 1 1 PLN 4571
+Tropheus moorii blunthead cichlid 1 2 VRT 8150
Trypanosoma brucei 1 4 INV 5691
+Trypanosoma carassii 1 4 INV 38249
Trypanosoma cruzi 1 4 INV 5693
TT virus 1 0 VRL 68887
-Tupaia herpesvirus 1 0 VRL 10397
+TTV-like mini virus 1 0 VRL 93678
+Tuber borchii whitish truffle 1 4 PLN 42251
Turkey rhinotracheitis virus 1 0 VRL 11264
Turnip mosaic virus 1 0 VRL 12230
Ureaplasma urealyticum 4 0 BCT 2130
Ursus arctos brown bear 1 2 MAM 9644
Ustilago maydis 1 4 PLN 5270
Vaccinia virus 1 0 VRL 10245
-Variola virus 1 0 VRL 10255
-Venezuelan equine encephalitis virus 1 0 VRL 11036
+Vaccinium corymbosum 1 1 PLN 69266
+Verticillium dahliae 1 4 PLN 27337
Vesicular stomatitis virus 1 0 VRL 11276
Vibrio cholerae 11 0 BCT 666
-Vibrio harveyi 11 0 BCT 669
Vibrio parahaemolyticus 11 0 BCT 670
Vibrio vulnificus 11 0 BCT 672
Vicia faba fava bean 1 1 PLN 3906
Vigna radiata 1 1 PLN 157791
Vigna unguiculata cowpea 1 1 PLN 3917
+Vitis aestivalis 1 1 PLN 3605
+Vitis hybrid cultivar 1 1 PLN 241073
+Vitis riparia 1 1 PLN 96939
+Vitis shuttleworthii 1 1 PLN 246827
Vitis vinifera 1 1 PLN 29760
-Volvox carteri 1 1 PLN 3067
West Nile virus 1 0 VRL 11082
+Wuchereria bancrofti 1 5 INV 6293
Xanthomonas axonopodis 11 0 BCT 53413
Xanthomonas campestris 11 0 BCT 339
Xenopus laevis African clawed frog 1 2 VRT 8355
-Xestia c-nigrum granulovirus 1 0 VRL 51677
+Xenopus tropicalis western clawed frog 1 2 VRT 8364
Xiphias gladius swordfish 1 2 VRT 8245
Xylella fastidiosa 11 0 BCT 2371
-Yaba-like disease virus 1 0 VRL 132475
Yarrowia lipolytica 1 3 PLN 4952
Yersinia enterocolitica 11 0 BCT 630
Yersinia pestis 11 0 BCT 632
-Yersinia pseudotuberculosis 11 0 BCT 633
+Zamia furfuracea 1 1 PLN 42329
Zea mays 1 1 PLN 4577
Zeldia punctata 1 5 INV 49351
+Zinnia elegans 1 1 PLN 34245
Zucchini yellow mosaic virus 1 0 VRL 12232
Zygosaccharomyces rouxii 1 3 PLN 4956
-Zymomonas mobilis 11 0 BCT 542
diff --git a/demo/blast_driver.c b/demo/blast_driver.c
index 8249d58f..65befc58 100644
--- a/demo/blast_driver.c
+++ b/demo/blast_driver.c
@@ -1,4 +1,4 @@
-/* $Id: blast.c,v 1.9 2003/10/23 20:15:37 dondosha Exp $
+/* $Id: blast_driver.c,v 1.16 2004/01/07 14:40:20 papadopo Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,10 +32,10 @@ Author: Ilya Dondoshansky
Contents: Main function for running BLAST
******************************************************************************
- * $Revision: 1.9 $
+ * $Revision: 1.16 $
* */
-static char const rcsid[] = "$Id: blast.c,v 1.9 2003/10/23 20:15:37 dondosha Exp $";
+static char const rcsid[] = "$Id: blast_driver.c,v 1.16 2004/01/07 14:40:20 papadopo Exp $";
#include <ncbi.h>
#include <sqnutils.h>
@@ -45,9 +45,9 @@ static char const rcsid[] = "$Id: blast.c,v 1.9 2003/10/23 20:15:37 dondosha Exp
#include <algo/blast/core/blast_message.h>
#include <algo/blast/core/blast_util.h>
#include <algo/blast/core/blast_engine.h>
-#include "blast_seqalign.h"
-#include "blast_format.h"
-#include "seqsrc_readdb.h"
+#include <algo/blast/api/blast_seqalign.h>
+#include <algo/blast/api/blast_format.h>
+#include <algo/blast/api/seqsrc_readdb.h>
#define NUMARG (sizeof(myargs)/sizeof(myargs[0]))
@@ -147,8 +147,9 @@ static Args myargs[] = {
"0", NULL, NULL, FALSE, 'y', ARG_INT, 0.0, 0, NULL},
{ "Do only ungapped alignment (always TRUE for tblastx)",/*ARG_UNGAPPED*/
"F", NULL, NULL, FALSE, 'u', ARG_BOOLEAN, 0.0, 0, NULL},
- { "Use greedy algorithm for gapped extensions", /* ARG_GREEDY */
- "F", NULL, NULL, FALSE, 'g', ARG_BOOLEAN, 0.0, 0, NULL},
+ { "Use greedy algorithm for gapped extensions:\n 0 no, 1 one-step, "
+ "2 two-step, 3 two-step with ungapped", /* ARG_GREEDY */
+ "F", NULL, NULL, FALSE, 'g', ARG_INT, 0.0, 0, NULL},
{ "Gap open penalty (default: non-affine if greedy; 5 if dyn. prog.)",
"0", NULL, NULL, FALSE, 'G', ARG_INT, 0.0, 0, NULL}, /* ARG_GAPOPEN */
{ "Gap extension penalty (default: non-affine if greedy; 2 otherwise)",
@@ -256,6 +257,14 @@ BLAST_FillOptions(LookupTableOptions* lookup_options,
if (myargs[ARG_STRIDE].intvalue)
lookup_options->scan_step = myargs[ARG_STRIDE].intvalue;
+
+ if (myargs[ARG_PHI].strvalue) {
+ lookup_options->phi_pattern = strdup(myargs[ARG_PHI].strvalue);
+ lookup_options->lut_type =
+ ((program_number == blast_type_blastn) ?
+ PHI_NA_LOOKUP : PHI_AA_LOOKUP);
+ hit_options->phi_align = TRUE;
+ }
BLAST_FillQuerySetUpOptions(query_setup_options, program_number,
myargs[ARG_FILTER].strvalue, myargs[ARG_STRAND].intvalue);
@@ -272,6 +281,25 @@ BLAST_FillOptions(LookupTableOptions* lookup_options,
BLAST_FillExtensionOptions(ext_options, program_number, greedy_extension,
myargs[ARG_XDROP].intvalue, myargs[ARG_XDROP_FINAL].intvalue);
+ if (greedy_extension) {
+ switch (myargs[ARG_GREEDY].intvalue) {
+ case 1:
+ ext_options->algorithm_type = EXTEND_GREEDY;
+ word_options->ungapped_extension = FALSE;
+ break;
+ case 2:
+ ext_options->algorithm_type = EXTEND_GREEDY_NO_TRACEBACK;
+ word_options->ungapped_extension = FALSE;
+ break;
+ case 3:
+ ext_options->algorithm_type = EXTEND_GREEDY_NO_TRACEBACK;
+ word_options->ungapped_extension = TRUE;
+ break;
+ default:
+ break;
+ }
+ }
+
BLAST_FillScoringOptions(score_options, program_number, greedy_extension,
myargs[ARG_MISMATCH].intvalue, myargs[ARG_MATCH].intvalue,
myargs[ARG_MATRIX].strvalue, myargs[ARG_GAPOPEN].intvalue,
@@ -304,10 +332,10 @@ BLAST_FillOptions(LookupTableOptions* lookup_options,
BLAST_FillEffectiveLengthsOptions(eff_len_options,
numseqs, totlen, (Int8) myargs[ARG_SEARCHSP].floatvalue);
- if (myargs[ARG_DBGENCODE].intvalue && db_options &&
- (program_number == blast_type_tblastn ||
- program_number == blast_type_tblastx)) {
- db_options->genetic_code = myargs[ARG_DBGENCODE].intvalue;
+ if (db_options && (program_number == blast_type_tblastn ||
+ program_number == blast_type_tblastx)) {
+ if (myargs[ARG_DBGENCODE].intvalue)
+ db_options->genetic_code = myargs[ARG_DBGENCODE].intvalue;
if ((status = BLAST_GeneticCodeFind(db_options->genetic_code,
&db_options->gen_code_string)))
return status;
@@ -338,13 +366,13 @@ Int2 Nlm_Main(void)
Int2 status;
QuerySetUpOptions* query_options=NULL;
BlastEffectiveLengthsOptions* eff_len_options=NULL;
- BlastMask* lcase_mask = NULL;
- BlastMask* filter_loc=NULL; /* All masking locations */
+ BlastMaskLoc* lcase_mask = NULL;
+ BlastMaskLoc* filter_loc=NULL; /* All masking locations */
SeqLoc* query_slp = NULL;
BlastScoreBlk* sbp = NULL;
FILE *infp, *outfp;
BlastQueryInfo* query_info;
- BlastResults* results = NULL;
+ BlastHSPResults* results = NULL;
Blast_Message* blast_message = NULL;
SeqAlign* seqalign;
BlastFormattingOptions* format_options;
@@ -413,6 +441,8 @@ Int2 Nlm_Main(void)
readdb_args = (ReaddbNewArgs*) malloc(sizeof(ReaddbNewArgs));
readdb_args->dbname = dbname = myargs[ARG_DB].strvalue;
readdb_args->is_protein = !db_is_na;
+ readdb_args->first_db_seq = 0;
+ readdb_args->final_db_seq = 0;
bssn_info.constructor = &ReaddbSeqSrcNew;
bssn_info.ctor_argument = (void*) readdb_args;
@@ -460,7 +490,7 @@ Int2 Nlm_Main(void)
}
if (translated_query) {
- BlastMaskDNAToProtein(&lcase_mask, query_slp);
+ BlastMaskLocDNAToProtein(&lcase_mask, query_slp);
}
status = BLAST_SetUpQuery(program_number, query_slp,
@@ -476,7 +506,7 @@ Int2 Nlm_Main(void)
if (translated_query) {
/* Filter locations were returned in protein coordinates; convert them
back to nucleotide here */
- BlastMaskProteinToDNA(&filter_loc, query_slp);
+ BlastMaskLocProteinToDNA(&filter_loc, query_slp);
}
if (status) {
@@ -490,8 +520,6 @@ Int2 Nlm_Main(void)
LookupTableWrapInit(query, lookup_options,
lookup_segments, sbp, &lookup_wrap);
- return_stats = (BlastReturnStat*) calloc(1, sizeof(BlastReturnStat));
-
if (bssp) {
BLAST_DatabaseSearchEngine(program_number, query, query_info,
bssp, sbp, score_options, lookup_wrap,
@@ -512,7 +540,7 @@ Int2 Nlm_Main(void)
/* Convert results to the SeqAlign form */
BLAST_ResultsToSeqAlign(program_number, results, query_slp, bssp,
- subject_slp, score_options, sbp, hit_options->gapped_calculation,
+ subject_slp, score_options, sbp, score_options->gapped_calculation,
&seqalign);
results = BLAST_ResultsFree(results);
@@ -530,6 +558,8 @@ Int2 Nlm_Main(void)
blast_program, query_info->num_queries, query_slp,
filter_loc, format_options, score_options->is_ooframe);
+ BlastMaskLocFree(filter_loc);
+
PrintOutputFooter(program_number, format_options, score_options, sbp,
lookup_options, word_options, ext_options, hit_options, query_info,
readdb_args, return_stats);
@@ -540,7 +570,9 @@ Int2 Nlm_Main(void)
query_slp = SeqLocSetFree(query_slp);
} /* End loop on sets of queries */
+ sfree(readdb_args);
subject = BlastSequenceBlkFree(subject);
+ subject_slp = SeqLocSetFree(subject_slp);
sfree(return_stats);
LookupTableOptionsFree(lookup_options);
BlastQuerySetUpOptionsFree(query_options);
diff --git a/demo/blastall.c b/demo/blastall.c
index 6f56f52f..41fcf1b7 100644
--- a/demo/blastall.c
+++ b/demo/blastall.c
@@ -1,6 +1,6 @@
-static char const rcsid[] = "$Id: blastall.c,v 6.135 2003/08/21 15:37:54 dondosha Exp $";
+static char const rcsid[] = "$Id: blastall.c,v 6.136 2003/11/05 22:28:06 dondosha Exp $";
-/* $Id: blastall.c,v 6.135 2003/08/21 15:37:54 dondosha Exp $
+/* $Id: blastall.c,v 6.136 2003/11/05 22:28:06 dondosha Exp $
**************************************************************************
* *
* COPYRIGHT NOTICE *
@@ -28,6 +28,9 @@ static char const rcsid[] = "$Id: blastall.c,v 6.135 2003/08/21 15:37:54 dondosh
**************************************************************************
*
* $Log: blastall.c,v $
+ * Revision 6.136 2003/11/05 22:28:06 dondosha
+ * No need to shift subsequence coordinates in tabular output, since they are already shifted in the seqalign
+ *
* Revision 6.135 2003/08/21 15:37:54 dondosha
* Corrections for out-of-frame tabular output and megablast XML output
*
@@ -1571,7 +1574,7 @@ Int2 Main (void)
BlastPrintTabularResults(curr_seqalign, query_bsp, slp,
number_of_alignments, blast_program,
!options->gapped_calculation, options->is_ooframe,
- believe_query, from, 0, global_fp, NULL, (align_view == 9));
+ believe_query, 0, 0, global_fp, NULL, (align_view == 9));
SeqAlignSetFree(curr_seqalign);
}
diff --git a/demo/copymat.c b/demo/copymat.c
index 08231e58..adbdd1e8 100644
--- a/demo/copymat.c
+++ b/demo/copymat.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: copymat.c,v 6.25 2003/05/30 17:31:09 coulouri Exp $";
+static char const rcsid[] = "$Id: copymat.c,v 6.30 2004/01/30 20:34:45 coulouri Exp $";
/*
* ===========================================================================
@@ -36,6 +36,22 @@ Contents: main routines for copymatrices program to convert
score matrices output by makematrices into a single byte-encoded file.
$Log: copymat.c,v $
+Revision 6.30 2004/01/30 20:34:45 coulouri
+fix minor nit to FileWrite call
+
+Revision 6.29 2004/01/26 19:40:48 coulouri
+* Correct buffer overrun
+* Use offset rather than pointer in LookupBackboneCell
+
+Revision 6.28 2003/11/24 18:18:47 coulouri
+Correction to previous fix for 64-bit irix
+
+Revision 6.27 2003/11/21 18:01:15 ivanov
+Added extern definition for impalaMakeFileNames()
+
+Revision 6.26 2003/11/20 15:44:32 camacho
+Tom Madden's changes to use lookup table contruction code from algo/blast.
+
Revision 6.25 2003/05/30 17:31:09 coulouri
add rcsid
@@ -107,10 +123,39 @@ Changed a little format of RPS lookup tables file.
#include <sequtil.h>
#include <seqport.h>
#include <tofasta.h>
-#include <blast.h>
-#include <blastpri.h>
-#include <posit.h>
-#include <profiles.h>
+
+#ifndef MAXLINELEN
+# define MAXLINELEN 2000
+#endif
+#ifndef MAX_NAME_LENGTH
+# define MAX_NAME_LENGTH 500
+#endif
+#ifndef PRO_ALPHABET_SIZE
+# define PRO_ALPHABET_SIZE 26
+#endif
+#ifndef SORT_THRESHOLD
+# define SORT_THRESHOLD 20
+#endif
+#ifndef RPS_MAGIC_NUMBER
+# define RPS_MAGIC_NUMBER 7702
+#endif
+/*factor used to multiply the gapped K parameter to make it
+ more accurate in most cases*/
+#ifndef PRO_K_MULTIPLIER
+# define PRO_K_MULTIPLIER 1.2
+#endif
+#include <algo/blast/core/blast_lookup.h>
+#include <algo/blast/core/blast_options.h>
+
+typedef Int4 ScoreRow[PRO_ALPHABET_SIZE];
+extern Boolean LIBCALL
+IMPALAPrintHelp PROTO((Boolean html, Int4 line_length, Char * programName,
+ FILE *outfp));
+extern void LIBCALL
+impalaMakeFileNames PROTO((Char * matrixDbName, Char * auxiliaryFileName,
+ Char * mmapFileName, Char * seqFileName,
+ Char *matrixFileName, Char * ckptFileName,
+ Char *directoryPrefix));
#define NUMARG (sizeof(myargs)/sizeof(myargs[0]))
@@ -333,6 +378,40 @@ static Int4 findTotalLength(FILE *matrixAuxiliaryFile, Int4 numProfiles,
return(totalLength);
}
+static Boolean RPSUpdateOffsets(LookupTable *lookup)
+{
+ Uint4 len;
+ Int4 index;
+ Int4 num_used;
+ Int4 offset_diff;
+
+ len = lookup->backbone_size;
+ offset_diff = lookup->wordsize - 1;
+
+ /* Walk through table, copying info into mod_lt[] */
+ for(index = 0; index < len; index++) {
+
+ if((num_used=lookup->thick_backbone[index].num_used) <= 3)
+ {
+ while (num_used > 0)
+ {
+ num_used--;
+ lookup->thick_backbone[index].payload.entries[num_used] += offset_diff;
+ }
+ }
+ else
+ {
+ while (num_used > 0)
+ {
+ num_used--;
+ lookup->overflow [ lookup->thick_backbone[index].payload.overflow_cursor + num_used] += offset_diff;
+ }
+ }
+ }
+ return TRUE;
+}
+
+
/* #define RPS_THRESHOLD 11 */
/* #define RPS_WORDSIZE 3 */
@@ -341,50 +420,44 @@ static Int4 findTotalLength(FILE *matrixAuxiliaryFile, Int4 numProfiles,
pointers relative to the start of "mod_lookup_table_memory" chunk
RPS Blast will calculate real pointers in run time using these values
*/
-Boolean RPSUpdatePointers(LookupTablePtr lookup)
+Boolean RPSUpdatePointers(LookupTable *lookup, Uint4 *new_overflow, Uint4 *new_overflow_size)
{
- ModLAEntry * mod_lt;
Uint4 len;
Int4 index;
- ModLookupPositionPtr start_address;
+ Uint4 *start_address;
long mlpp_address;
- ModLookupPositionPtr *lpp;
+ Uint4 *new_overflow_cursor;
+ Int4 *src;
+ Int4 first_hit;
+
+ len = lookup->backbone_size;
- len = lookup->array_size;
- mod_lt=lookup->mod_lt;
- start_address = (ModLookupPositionPtr) lookup->mod_lookup_table_memory;
+ start_address = new_overflow_cursor = new_overflow;
/* Walk through table, copying info into mod_lt[] */
for(index = 0; index < len; index++) {
- if(mod_lt[index].num_used <= 3)
+ if(lookup->thick_backbone[index].num_used <= 3)
continue;
-#if 1
+ src = &(lookup->overflow[lookup->thick_backbone[index].payload.overflow_cursor]);
+ MemCpy(new_overflow_cursor, &src[1], sizeof(Uint4)*(lookup->thick_backbone[index].num_used-1));
+
+ mlpp_address = (long) new_overflow_cursor;
+
+ new_overflow_cursor += lookup->thick_backbone[index].num_used-1;
+ first_hit = src[0];
- /* Taking pointer to 4/8 bytes address */
- lpp= (ModLookupPositionPtr *) &mod_lt[index].entries[1];
-
- mlpp_address = (long) *lpp;
mlpp_address -= (long) start_address;
/* Now this is new relative address - usually small */
- *lpp = (ModLookupPositionPtr) mlpp_address;
-
-#if defined(OS_UNIX_IRIX)
- if(sizeof(ModLookupPositionPtr) == 8) { /* 64bit build */
- mlpp_address = mod_lt[index].entries[1];
- mod_lt[index].entries[1] = mod_lt[index].entries[2];
- mod_lt[index].entries[2] = mlpp_address;
- }
-#endif
-
-#else
- mod_lt[index].entries[1] -= (int) start_address;
- mod_lt[index].entries[2] = 0; /* Not used */
-#endif
+ lookup->thick_backbone[index].payload.entries[1] = (Int4) mlpp_address;
+ lookup->thick_backbone[index].payload.entries[0] = first_hit;
}
+
+ *new_overflow_size = new_overflow_cursor - new_overflow;
+
return TRUE;
}
@@ -392,17 +465,24 @@ Boolean RPSUpdatePointers(LookupTablePtr lookup)
Write lookup table to the disk into file "*.loo", which will be
used memory-mapped during RPS Blast search
*/
-Boolean RPSDumpLookupTable(LookupTablePtr lookup, FILE *fd)
+Boolean RPSDumpLookupTable(LookupTable *lookup, FILE *fd)
{
+ Uint4 *new_overflow;
+ Uint4 new_overflow_size;
- RPSUpdatePointers(lookup);
+ RPSUpdateOffsets(lookup);
- FileWrite(lookup->mod_lt, sizeof(ModLAEntry), 1+lookup->array_size, fd);
- if(lookup->mod_lookup_table_size) {
- FileWrite(lookup->mod_lookup_table_memory,
- lookup->mod_lookup_table_size,
- sizeof(ModLookupPosition), fd);
- }
+ new_overflow = malloc(lookup->overflow_size*sizeof(Uint4));
+ RPSUpdatePointers(lookup, new_overflow, &new_overflow_size);
+
+ FileWrite(lookup->thick_backbone, sizeof(LookupBackboneCell), lookup->backbone_size, fd);
+ if(new_overflow_size)
+ FileWrite(new_overflow,
+ sizeof(Uint4),
+ new_overflow_size,
+ fd);
+
+ sfree(new_overflow);
return TRUE;
}
@@ -415,25 +495,63 @@ Boolean RPSCreateLookupFile(ScoreRow *combinedMatrix, Int4 numProfiles,
Int4Ptr seqlens, CharPtr filename,
Nlm_FloatHi scalingFactor)
{
- LookupTablePtr lookup;
- BlastAllWordPtr all_words;
- Int4 start, i, header_size, all_length, magicNumber;
+ BlastScoreBlk *sbp;
+ DoubleInt *double_int;
FILE *fd;
+ Int4 **posMatrix;
+ Int4 start, i, header_size, all_length, magicNumber;
Int4Ptr offsets;
- BLAST_ScorePtr PNTR posMatrix;
Int4 num_lookups;
+ ListNode *lookup_segment=NULL;
+ LookupTable *lookup;
+ LookupTableWrap* lookup_wrap_ptr=NULL;
+ LookupTableOptions* lookup_options;
+
if((fd = FileOpen(filename, "wb")) == NULL)
return FALSE;
num_lookups = 1; /* Single lookup table for all set */
- lookup = lookup_new(PRO_ALPHABET_SIZE, 3, 0);
- all_words = BlastPopulateAllWordArrays(3, PRO_ALPHABET_SIZE);
+ all_length = seqlens[numProfiles] - seqlens[0];
+
+ posMatrix = MemNew((all_length + 1) * sizeof(Int4 *));
+ for (i = 0; i < all_length; i++) {
+ posMatrix[i] = (Int4 *) &(combinedMatrix[i][0]);
+ }
+
+ /* Last row is necessary */
+ posMatrix[all_length] = MemNew(sizeof(Int4) * PRO_ALPHABET_SIZE);
+
+ for(i = 0; i < PRO_ALPHABET_SIZE; i++) {
+ posMatrix[all_length][i] = -INT2_MAX;
+ }
+
+ sbp = BlastScoreBlkNew(BLASTAA_SEQ_CODE, 1);
+ sbp->posMatrix = posMatrix;
+ LookupTableOptionsNew(blast_type_blastp, &lookup_options);
+ BLAST_FillLookupTableOptions(lookup_options, blast_type_blastp, FALSE,
+ (Int4) (myargs[3].floatvalue*scalingFactor), myargs[4].intvalue, FALSE, FALSE, TRUE); /* add last arg for psi-blast?? */
+
+
+ double_int = (DoubleInt*) calloc(1, sizeof(DoubleInt));
+ double_int->i1 = 0;
+ double_int->i2 = all_length;
+
+ ListNodeAddPointer(&lookup_segment, 0, double_int);
+
+ /* Need query for psi-blast?? where to put the PSSM? */
+ LookupTableWrapInit(NULL, lookup_options, lookup_segment, sbp, &lookup_wrap_ptr);
+
+ sbp->posMatrix = NULL;
+ sbp = BlastScoreBlkFree(sbp);
+ lookup_options = LookupTableOptionsFree(lookup_options);
+ lookup_segment = ListNodeFreeData(lookup_segment);
+
+ lookup = (LookupTable*) lookup_wrap_ptr->lut;
/* Only Uint4 maximum length for lookup file allowed in current
implementation */
-
header_size = (numProfiles+1)*sizeof(Int4) + 8*sizeof(Int4);
/* Beginning of file will be allocated for lookup offsets */
@@ -441,32 +559,11 @@ Boolean RPSCreateLookupFile(ScoreRow *combinedMatrix, Int4 numProfiles,
offsets = MemNew(sizeof(Int4) * (num_lookups + 1));
- all_length = seqlens[numProfiles] - seqlens[0];
-
- posMatrix = MemNew((all_length + 1) * sizeof(BLAST_Score *));
- for (i = 0; i < all_length; i++) {
- posMatrix[i] = (BLAST_Score *) &(combinedMatrix[i][0]);
- }
-
- /* Last row is necessary */
- posMatrix[all_length] = MemNew(sizeof(BLAST_Score) * PRO_ALPHABET_SIZE);
- for(i = 0; i < PRO_ALPHABET_SIZE; i++) {
- posMatrix[all_length][i] = -INT2_MAX;
- }
offsets[0] = ftell(fd);
start = seqlens[0]; /* 0 */
- if(BlastNewFindWordsEx(lookup, &posMatrix[start], 0, all_length,
- all_words, (Int4) (myargs[3].floatvalue*scalingFactor),
- myargs[4].intvalue, 0) < 0) {
- ErrPostEx(SEV_ERROR, 0,0, "Failure to create llokup table");
- return FALSE;
- }
-
- lookup_position_aux_destruct(lookup);
-
RPSDumpLookupTable(lookup, fd);
i = 1;
@@ -477,9 +574,9 @@ Boolean RPSCreateLookupFile(ScoreRow *combinedMatrix, Int4 numProfiles,
magicNumber = RPS_MAGIC_NUMBER;
FileWrite(&magicNumber, sizeof(Int4), 1, fd); /* header[0] */
FileWrite(&num_lookups, sizeof(Int4), 1, fd); /* header[1] */
- FileWrite(&lookup->num_pos_added, sizeof(Int4), 1, fd); /* header[2] */
- FileWrite(&lookup->num_unique_pos_added, sizeof(Int4), 1, fd); /* header[3] */
- FileWrite(&lookup->mod_lookup_table_size, sizeof(Int4), 1, fd); /* header[4] */
+ FileWrite(&lookup->neighbor_matches, sizeof(Int4), 1, fd); /* header[2] */
+ FileWrite(&lookup->neighbor_matches, sizeof(Int4), 1, fd); /* header[3] */
+ FileWrite(&lookup->overflow_size, sizeof(Int4), 1, fd); /* header[4] */
/* Now writing recorded offsets in the beginning of the file */
@@ -487,27 +584,14 @@ Boolean RPSCreateLookupFile(ScoreRow *combinedMatrix, Int4 numProfiles,
FileWrite(offsets, sizeof(Int4), num_lookups + 1, fd);
FileClose(fd);
-/* comment out for now, why is this here?
- if (scalingFactor != 1.0) {
- for(j = 0; j < all_length; j++) {
- for(i = 0; i < PRO_ALPHABET_SIZE; i++) {
- combinedMatrix[j][i] /= scalingFactor;
- }
- }
- }
-*/
-
/* Final memory cleenup */
- lookup = lookup_destruct(lookup);
-
MemFree(posMatrix[all_length]);
MemFree(posMatrix);
- BlastAllWordDestruct(all_words);
-
return TRUE;
}
+
/* -- SSH --
Create file <database_name> (without extention), which is concatenation
of all FASTA files used. Used by RPS Blast.
diff --git a/demo/debruijn.c b/demo/debruijn.c
index 732745b0..c287351c 100644
--- a/demo/debruijn.c
+++ b/demo/debruijn.c
@@ -1,72 +1,107 @@
-#include <stdio.h>
-#include <util.h>
+/* $Id: debruijn.c,v 1.3 2004/01/05 20:44:55 coulouri Exp $
+
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's offical duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government have not placed any restriction on its use or reproduction.
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* Please cite the author in any work or product based on this material.
+*
+* ===========================================================================
+
+*/
+
+static char const rcsid[] = "$Id: debruijn.c,v 1.3 2004/01/05 20:44:55 coulouri Exp $";
/*
* example driver for de Bruijn sequences.
*
* this code generates all n-mers over a protein
- * or dna alphabet. useful for creating fasta test sequences.
+ * or dna alphabet. useful for creating test sequences.
*/
-/* k = 22 */
-char proteinalphabet[] = "arndcqeghilkmfpstwyvbz";
+#include <ncbi.h>
+#include <algo/blast/core/lookup_util.h>
+
+static Args myargs[] = {
+ { "word size",
+ NULL, NULL, NULL, FALSE, 'n', ARG_INT, 0.0, 0, NULL },
+ { "alphabet\n"
+ "(supply 'ncbistdaa' or 'ncbi2na' for standard\n"
+ "alphabets, or supply your own alphabet)\n",
+ NULL, NULL, NULL, FALSE, 'a', ARG_STRING, 0.0, 0, NULL },
+};
-/* k = 4 */
-char dnaalphabet[] = "acgt";
+Uint1 ncbistdaa[] = "-abcdefghiklmnpqrstvwxyzu*";
+Uint1 ncbi2na[] = "acgt";
-int main(int argc, char *argv[])
+Int2 Main(void)
{
- int i;
- int n, k;
- char *output;
- int outputsize;
- char *alphabet;
+ Int4 i;
+ Int4 n, k;
+ Uint1 *output;
+ Int4 outputsize;
+ Uint1 *alphabet=NULL;
+
+ if ( ! GetArgs("debruijn", sizeof(myargs)/sizeof(myargs[0]), myargs) )
+ return 1;
+
+ n = myargs[0].intvalue;
- if (argc != 4)
+ if (n < 1)
{
- fprintf(stderr, "usage: %s n k prot-or-dna\n", argv[0]);
- fprintf(stderr, "where prot-or-dna = 0 for protein, 1 for dna\n");
- fprintf(stderr, "example: %s 3 22 0\n",argv[0]);
- fprintf(stderr, "example: %s 11 4 1\n",argv[0]);
- exit(1);
+ fprintf(stderr,"n must be greater than one.\n");
+ return 1;
}
-
- n = atoi(argv[1]);
- k = atoi(argv[2]);
-
- if (atoi(argv[3]) == 0)
- alphabet = proteinalphabet;
- else
- alphabet = dnaalphabet;
+ alphabet = myargs[1].strvalue;
+
+ if (strcmp("ncbistdaa", myargs[1].strvalue) == 0)
+ alphabet = ncbistdaa;
+
+ if (strcmp("ncbi2na", myargs[1].strvalue) == 0)
+ alphabet = ncbi2na;
+
+ k = strlen(alphabet);
+
/* output array needs:
* k^n bytes - to store the de Bruijn sequence
* n-1 bytes - to unwrap (see below)
* 1 byte - for the terminating NUL
*/
- outputsize = iexp(k,n) + (n-1) + 1;
- output = (char *) calloc( outputsize, sizeof(char));
+ outputsize = iexp(k,n) + (n-1);
+ output = (char *) malloc(outputsize + 1);
/* compute the (n,k) de Bruijn sequence */
debruijn(n,k,output,alphabet);
- /* but, we don't want a true cyclical de Bruijn sequence, we want
- * all words in a straight line. so we copy the first n-1 letters
+ /* We don't want a true cyclical de Bruijn sequence; we want
+ * all words in a straight line- copy the first n-1 letters
* to the end.
*/
for(i=0;i<(n-1);i++)
- output[outputsize-((n-1)+1)+i] = output[i];
-
- /* don't forget to NUL-terminate it */
+ output[outputsize-n+1+i] = output[i];
- output[outputsize-1] = '\0';
+ /* Terminate the string. */
- fprintf(stderr,"n (word size) = %d\n",n);
- fprintf(stderr,"k (alphabet size) = %d\n",k);
- fprintf(stderr,"output size = k^n + (n-1) + 1 = %d + %d + 1 = %d\n",iexp(k,n),n-1,outputsize);
- fprintf(stderr,"naive size would have been %d\n",n * iexp(k,n));
+ output[outputsize+1] = '\0';
puts(output);
diff --git a/demo/formatdb.c b/demo/formatdb.c
index 37e7a8ed..9a2143fe 100644
--- a/demo/formatdb.c
+++ b/demo/formatdb.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: formatdb.c,v 6.91 2003/10/01 18:59:56 camacho Exp $";
+static char const rcsid[] = "$Id: formatdb.c,v 6.92 2004/01/29 14:56:44 camacho Exp $";
/*****************************************************************************
@@ -32,11 +32,14 @@ static char const rcsid[] = "$Id: formatdb.c,v 6.91 2003/10/01 18:59:56 camacho
Version Creation Date: 10/01/96
- $Revision: 6.91 $
+ $Revision: 6.92 $
File Description: formats FASTA databases for use by BLAST
$Log: formatdb.c,v $
+ Revision 6.92 2004/01/29 14:56:44 camacho
+ Removed -A option, FORMATDB_VER_TEXT no longer supported
+
Revision 6.91 2003/10/01 18:59:56 camacho
Fix to creation of custom databases using a gi list and alias files when the
source database spans multiple volumes.
@@ -418,8 +421,6 @@ Args dump_args[] = {
"F", NULL, NULL, TRUE, 's', ARG_BOOLEAN, 0.0, 0, NULL},
{ "Verbose: check for non-unique string ids in the database",
"F", NULL, NULL, TRUE, 'V', ARG_BOOLEAN, 0.0, 0, NULL},
- { "Create ASN.1 structured deflines",
- "T", NULL, NULL, TRUE, 'A', ARG_BOOLEAN, 0.0, 0, NULL},
{ "Create an alias file with this name\n"
" use the gifile arg (below) if set to calculate db size\n"
" use the BLAST db specified with -i (above)",
@@ -452,7 +453,6 @@ enum {
dbsize_arg,
sparse_arg,
nonunique_arg,
- asn1_deflines_arg,
alias_fn_arg,
gifile_arg,
bin_gifile_arg,
@@ -669,9 +669,7 @@ Int2 Main(void)
dump_args[basename_arg].strvalue,
dump_args[alias_fn_arg].strvalue,
((Int8)dump_args[dbsize_arg].intvalue)*1000000, 0,
- dump_args[asn1_deflines_arg].intvalue ?
- FORMATDB_VER : FORMATDB_VER_TEXT ,
- FALSE, 0);
+ FORMATDB_VER, FALSE, 0);
if (options == NULL)
return 1;
diff --git a/demo/megablast.c b/demo/megablast.c
index 2fa5beb6..7db38590 100644
--- a/demo/megablast.c
+++ b/demo/megablast.c
@@ -1,6 +1,6 @@
-static char const rcsid[] = "$Id: megablast.c,v 6.107 2003/05/30 17:31:09 coulouri Exp $";
+static char const rcsid[] = "$Id: megablast.c,v 6.111 2004/01/27 20:47:18 dondosha Exp $";
-/* $Id: megablast.c,v 6.107 2003/05/30 17:31:09 coulouri Exp $
+/* $Id: megablast.c,v 6.111 2004/01/27 20:47:18 dondosha Exp $
**************************************************************************
* *
* COPYRIGHT NOTICE *
@@ -28,6 +28,18 @@ static char const rcsid[] = "$Id: megablast.c,v 6.107 2003/05/30 17:31:09 coulou
**************************************************************************
* $Revision 6.13$ *
* $Log: megablast.c,v $
+ * Revision 6.111 2004/01/27 20:47:18 dondosha
+ * Set no_traceback option to 2 for -D4, 1 for -D0, 0 for others
+ *
+ * Revision 6.110 2003/11/05 22:28:06 dondosha
+ * No need to shift subsequence coordinates in tabular output, since they are already shifted in the seqalign
+ *
+ * Revision 6.109 2003/10/30 17:30:49 dondosha
+ * Fixed error in previous commit - output file pointer has to be set for all cases
+ *
+ * Revision 6.108 2003/10/29 17:48:15 dondosha
+ * Added -D4 option for 2-stage greedy gapped extension with format identical to -D2
+ *
* Revision 6.107 2003/05/30 17:31:09 coulouri
* add rcsid
*
@@ -396,7 +408,8 @@ enum {
MBLAST_ENDPOINTS = 0,
MBLAST_SEGMENTS,
MBLAST_ALIGNMENTS,
- MBLAST_ALIGN_INFO
+ MBLAST_ALIGN_INFO,
+ MBLAST_DELAYED_TRACEBACK
};
static int LIBCALLBACK
@@ -912,6 +925,7 @@ Int2 Main (void)
Boolean lcase_masking;
BlastOutputPtr boutp = NULL;
MBXmlPtr mbxp = NULL;
+ Boolean traditional_formatting;
StringCpy(buf, "megablast ");
StringNCat(buf, BlastGetVersionNumber(), sizeof(buf)-StringLen(buf)-1);
@@ -947,14 +961,17 @@ Int2 Main (void)
}
align_type = BlastGetTypes(blast_program, &query_is_na, &db_is_na);
-
+ traditional_formatting =
+ (myargs[12].intvalue == MBLAST_ALIGNMENTS ||
+ myargs[12].intvalue == MBLAST_DELAYED_TRACEBACK);
+
if (myargs[15].strvalue) {
if (myargs[15].strvalue[0] == 'f' || myargs[15].strvalue[0] == 'F' ||
myargs[15].strvalue[0] == '0')
believe_query = FALSE;
else
believe_query = TRUE;
- } else if (myargs[12].intvalue == MBLAST_ALIGNMENTS &&
+ } else if (traditional_formatting &&
!myargs[14].strvalue)
believe_query = FALSE;
else
@@ -1058,9 +1075,11 @@ Int2 Main (void)
options->gifile = StringSave(myargs[22].strvalue);
if (myargs[12].intvalue == MBLAST_ENDPOINTS)
- options->no_traceback = TRUE;
+ options->no_traceback = 1;
+ else if (myargs[12].intvalue == MBLAST_DELAYED_TRACEBACK)
+ options->no_traceback = 2;
else
- options->no_traceback = FALSE;
+ options->no_traceback = 0;
options->megablast_full_deflines = (Boolean) myargs[27].intvalue;
options->perc_identity = (FloatLo) myargs[30].floatvalue;
@@ -1077,10 +1096,9 @@ Int2 Main (void)
StrCpy(prefix, "");
global_fp = outfp;
- if (myargs[12].intvalue != MBLAST_ALIGNMENTS)
- options->output = outfp;
+ options->output = outfp;
- if (myargs[12].intvalue==MBLAST_ALIGNMENTS) {
+ if (traditional_formatting) {
if (align_view < 7) {
if (html) {
fprintf(outfp, "<HTML>\n<TITLE>MEGABLAST Search Results</TITLE>\n");
@@ -1233,7 +1251,7 @@ Int2 Main (void)
}
- if (myargs[12].intvalue==MBLAST_ALIGNMENTS) {
+ if (traditional_formatting) {
dbinfo = NULL;
ka_params = NULL;
ka_params_gap = NULL;
@@ -1333,7 +1351,7 @@ Int2 Main (void)
BlastPrintTabulatedResults(seqalign,
query_bsp_array[index], NULL, number_of_alignments,
blast_program, !options->gapped_calculation,
- believe_query, options->required_start, 0,
+ believe_query, 0, 0,
global_fp, (align_view == 9));
SeqAlignSetFree(seqalign);
diff --git a/demo/rtestval.c b/demo/rtestval.c
index 6752bbe7..1a3bd194 100644
--- a/demo/rtestval.c
+++ b/demo/rtestval.c
@@ -5,7 +5,7 @@
* check for stop codons
* Check for and fix non 3.0 asn spec things
*
-* $Id: rtestval.c,v 1.10 2003/05/13 16:02:42 coulouri Exp $
+* $Id: rtestval.c,v 1.11 2003/11/14 18:07:54 kans Exp $
*
*****************************************************************************/
#include <accid1.h>
@@ -158,6 +158,10 @@ Int2 Main(void)
vsp->cutoff = (Int2)(myargs[10].intvalue);
vsp->useSeqMgrIndexes = (Boolean)(myargs[12].intvalue); /* indexed validate */
vsp->validateAlignments = (Boolean)(myargs[13].intvalue);
+ if (vsp->validateAlignments) {
+ vsp->alignFindRemoteBsp = TRUE;
+ vsp->doSeqHistAssembly = TRUE;
+ }
vsp->farIDsInAlignments = (Boolean)(myargs[13].intvalue);
vsp->alwaysRequireIsoJTA = (Boolean)(myargs[14].intvalue);
vsp->farFetchCDSproducts = (Boolean) (myargs[15].intvalue && myargs[16].intvalue);
diff --git a/demo/tbl2asn.c b/demo/tbl2asn.c
index 1b36b887..a969f40e 100644
--- a/demo/tbl2asn.c
+++ b/demo/tbl2asn.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 5/5/00
*
-* $Revision: 6.71 $
+* $Revision: 6.79 $
*
* File Description:
*
@@ -61,7 +61,7 @@
#include <simple.h>
#include <aliparse.h>
-#define TBL2ASN_APP_VER "2.5"
+#define TBL2ASN_APP_VER "2.8"
CharPtr TBL2ASN_APPLICATION = TBL2ASN_APP_VER;
@@ -162,6 +162,7 @@ static void ValidateOneFile (
if (vsp != NULL) {
vsp->useSeqMgrIndexes = TRUE;
vsp->suppressContext = TRUE;
+ vsp->seqSubmitParent = TRUE;
oldErrSev = ErrSetMessageLevel (SEV_NONE);
ValidateSeqEntry (sep, vsp);
ValidStructFree (vsp);
@@ -552,6 +553,16 @@ static OrgStuff commonOrgStuff [] = {
"PLN", 1, 1, 39947
},
{
+ "Aspergillus nidulans FGSC A4", "",
+ "Eukaryota; Fungi; Ascomycota; Pezizomycotina; Eurotiomycetes; Eurotiales; Trichocomaceae; Emericella",
+ "PLN", 1, 4, 227321
+ },
+ {
+ "environmental sequence", "",
+ "unclassified; environmental samples",
+ "UNA", 1, 2, 256318
+ },
+ {
NULL, NULL, NULL, NULL, 0, 0, 0
}
};
@@ -778,42 +789,62 @@ static BioseqPtr AttachSeqAnnotEntity (Uint2 entityID, SeqAnnotPtr sap, Boolean
return bsp;
}
-static CharPtr TrimBracketsFromString (CharPtr str)
+static CharPtr TrimBracketsFromString (CharPtr str, SqnTagPtr stp)
{
Uchar ch; /* to use 8bit characters in multibyte languages */
+ Int2 count;
CharPtr dst;
CharPtr ptr;
- if (StringHasNoText (str)) return str;
+ if (StringHasNoText (str) || stp == NULL) return str;
/* remove bracketed fields */
+ count = 0;
dst = str;
ptr = str;
ch = *ptr;
while (ch != '\0') {
if (ch == '[') {
- ptr++;
- ch = *ptr;
- while (ch != '\0' && ch != ']' && ch != '"') {
+ if (count < stp->num_tags && (! stp->used [count])) {
+ *dst = ch;
+ dst++;
ptr++;
ch = *ptr;
- }
- if (ch == '"') {
+ while (ch != '\0' && ch != ']') {
+ *dst = ch;
+ dst++;
+ ptr++;
+ ch = *ptr;
+ }
+ *dst = ch;
+ dst++;
+ ptr++;
+ ch = *ptr;
+ } else {
ptr++;
ch = *ptr;
- while (ch != '\0' && ch != '"') {
+ while (ch != '\0' && ch != ']' && ch != '"') {
+ ptr++;
+ ch = *ptr;
+ }
+ if (ch == '"') {
+ ptr++;
+ ch = *ptr;
+ while (ch != '\0' && ch != '"') {
+ ptr++;
+ ch = *ptr;
+ }
+ }
+ while (ch != '\0' && ch != ']') {
ptr++;
ch = *ptr;
}
- }
- while (ch != '\0' && ch != ']') {
ptr++;
ch = *ptr;
}
- ptr++;
- ch = *ptr;
+ count++;
} else {
*dst = ch;
dst++;
@@ -1037,16 +1068,16 @@ static void ProcessOneNuc (
}
}
- if (stp != NULL) {
- SqnTagFree (stp);
- }
-
- TrimBracketsFromString (ttl);
+ TrimBracketsFromString (ttl, stp);
if (! StringHasNoText (ttl)) {
str = StringSave (ttl);
SeqDescrAddPointer (&(bsp->descr), Seq_descr_title, (Pointer) str);
}
+ if (stp != NULL) {
+ SqnTagFree (stp);
+ }
+
ValNodeFreeData (vnp);
}
@@ -1179,6 +1210,60 @@ static void ReplaceOnePeptide (
MemFree (str2);
}
+static void ReplaceOneRNA (
+ SimpleSeqPtr ssp,
+ Boolean conflict
+)
+
+{
+ ByteStorePtr bs;
+ BioseqPtr bsp;
+ SeqIdPtr sip;
+ CharPtr str1, str2;
+
+ if (ssp == NULL || ssp->numid < 1) return;
+
+ sip = MakeSeqID (ssp->id [0]);
+ bsp = BioseqFind (sip);
+ SeqIdFree (sip);
+ if (bsp == NULL || bsp->repr != Seq_repr_raw) return;
+
+ /* remove trailing X and * */
+
+ bs = ssp->seq;
+ ssp->seqlen = BSLen (bs);
+
+ str1 = BSMerge (ssp->seq, NULL);
+ str2 = GetSequenceByBsp (bsp);
+
+ if (StringCmp (str1, str2) != 0) {
+
+ /* swap sequence byte stores */
+
+ bs = bsp->seq_data;
+ bsp->seq_data = ssp->seq;
+ ssp->seq = bs;
+ bsp->length = BSLen (bsp->seq_data);
+ bsp->seq_data_type = Seq_code_iupacna;
+
+ /*
+ mrna = SeqMgrGetRNAgivenProduct (bsp, NULL);
+ if (mrna != NULL) {
+
+ if (conflict) {
+ mrna->excpt = TRUE;
+ if (StringHasNoText (mrna->except_text)) {
+ mrna->except_text = StringSave ("RNA editing");
+ }
+ }
+ }
+ */
+ }
+
+ MemFree (str1);
+ MemFree (str2);
+}
+
static Uint2 ProcessOneAsn (
FILE* fp,
BioSourcePtr src,
@@ -2128,6 +2213,29 @@ static void ProcessOneRecord (
FileClose (fp);
}
+ /* read one or more feature tables from .rna file */
+
+ fp = OpenOneFile (directory, base, ".rna");
+ if (fp != NULL) {
+
+ /* indexing needed to find mRNA from transcript product to set RNA editing exception */
+
+ SeqMgrIndexFeatures (entityID, NULL);
+
+ while ((dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE, TRUE, TRUE, TRUE)) != NULL) {
+ if (datatype == OBJ_FASTA) {
+
+ ssp = (SimpleSeqPtr) dataptr;
+ ReplaceOneRNA (ssp, tbl->conflict);
+ SimpleSeqFree (ssp);
+
+ } else {
+ ObjMgrFree (datatype, dataptr);
+ }
+ }
+ FileClose (fp);
+ }
+
/* read one or more quality score blocks from .qvl file */
fp = OpenOneFile (directory, base, ".qvl");
@@ -2222,7 +2330,11 @@ static void ProcessOneRecord (
if (! tbl->genprodset) {
VisitFeaturesInSep (sep, NULL, ClearRnaProducts);
}
- InstantiateProteinTitles (entityID, NULL);
+ if (SeqMgrFeaturesAreIndexed (entityID)) {
+ InstantiateProteinTitles (entityID, NULL);
+ } else {
+ Message (MSG_POSTERR, "Unable to instantiate protein titles due to dropped index");
+ }
if (tbl->genprodset) {
/* need to reindex before instantiating mRNA titles */
SeqMgrIndexFeatures (entityID, NULL);
diff --git a/desktop/biosrc.c b/desktop/biosrc.c
index 5483b797..b52f139a 100644
--- a/desktop/biosrc.c
+++ b/desktop/biosrc.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.42 $
+* $Revision: 6.43 $
*
* File Description:
*
@@ -109,10 +109,10 @@ ENUM_ALIST(subsource_subtype_alist)
{"Plasmid-name", 19},
{"Plastid-name", 22},
{"Pop-variant", 17},
+ {"Rearranged", 15},
{"Segment", 24},
{"Sex", 7},
{"Subclone", 4},
- {"Rearranged", 15},
{"Tissue-lib", 18},
{"Tissue-type", 10},
{"Transgenic", 26},
diff --git a/desktop/cdrgn.c b/desktop/cdrgn.c
index f30c029e..587ced29 100644
--- a/desktop/cdrgn.c
+++ b/desktop/cdrgn.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.55 $
+* $Revision: 6.57 $
*
* File Description:
*
@@ -4696,7 +4696,7 @@ static ENUM_ALIST(rna_type_alist)
{"snRNA", 5},
{"scRNA", 6},
{"snoRNA", 7},
- {"Other RNA", 255},
+ {"misc_RNA", 255},
END_ENUM_ALIST
static Uint1 check_rna_type (Uint1 type)
@@ -4818,6 +4818,7 @@ static void RnaRefPtrToRnaPage (DialoG d, Pointer data)
rpp = (RnaPagePtr) GetObjectExtra (d);
rrp = (RnaRefPtr) data;
+
if (rpp != NULL) {
SetEnumPopup (rpp->type, rna_type_alist,
(UIEnum) check_rna_type (rrp->type));
@@ -4885,6 +4886,12 @@ static void RnaRefPtrToRnaPage (DialoG d, Pointer data)
head = NULL;
for (j = 0; j < 6; j++) {
if (trna->codon [j] < 64) {
+ /* Note - it is important to set the fourth character in the codon array to NULL
+ * because CodonForIndex only fills in the three characters of actual codon,
+ * so if you StringCpy the codon array and the NULL character is not found after
+ * the three codon characters, you will write in memory you did not intend to.
+ */
+ codon [3] = 0;
if (CodonForIndex (trna->codon [j], Seq_code_iupacna, codon)) {
StringCpy (str, (CharPtr) codon);
str [3] = '\0';
diff --git a/desktop/dlgutil1.c b/desktop/dlgutil1.c
index afa78016..9cd7b606 100644
--- a/desktop/dlgutil1.c
+++ b/desktop/dlgutil1.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.40 $
+* $Revision: 6.42 $
*
* File Description:
*
@@ -515,6 +515,7 @@ static Boolean GeneGatherFunc (GatherContextPtr gcp)
{
FeatureFormPtr ffp;
GeneGatherPtr ggp;
+ GeneRefPtr grp;
ObjMgrTypePtr omtp;
SeqFeatPtr sfp;
Char thislabel [41];
@@ -548,6 +549,22 @@ static Boolean GeneGatherFunc (GatherContextPtr gcp)
}
if (vnp != NULL) {
vnp->data.ptrvalue = StringSave (thislabel);
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ if (grp != NULL) {
+ if (grp->locus != NULL) {
+ vnp->choice = 1;
+ } else if (grp->desc != NULL) {
+ vnp->choice = 2;
+ } else if (grp->locus_tag != NULL) {
+ vnp->choice = 3;
+ } else if (grp->syn != NULL) {
+ vnp->choice = 4;
+ } else if (grp->db != NULL) {
+ vnp->choice = 5;
+ } else if (grp->maploc != NULL) {
+ vnp->choice = 6;
+ }
+ }
}
}
}
@@ -648,11 +665,21 @@ static Boolean GeneMatchFunc (GatherContextPtr gcp)
genexref = ggp->genexref;
if (genexref != NULL) {
grp = (GeneRefPtr) sfp->data.value.ptrvalue;
- if (StringICmp (genexref->locus, grp->locus) == 0) {
- ggp->val = ggp->idx;
- ggp->xrefmatch = TRUE;
- if (ffp != NULL) {
- SetValue (ffp->useGeneXref, 2);
+ if (! StringHasNoText (genexref->locus)) {
+ if (StringICmp (genexref->locus, grp->locus) == 0) {
+ ggp->val = ggp->idx;
+ ggp->xrefmatch = TRUE;
+ if (ffp != NULL) {
+ SetValue (ffp->useGeneXref, 2);
+ }
+ }
+ } else if (! StringHasNoText (genexref->locus_tag)) {
+ if (StringICmp (genexref->locus_tag, grp->locus_tag) == 0) {
+ ggp->val = ggp->idx;
+ ggp->xrefmatch = TRUE;
+ if (ffp != NULL) {
+ SetValue (ffp->useGeneXref, 2);
+ }
}
}
}
@@ -1127,7 +1154,14 @@ extern Boolean FeatFormReplaceWithoutUpdateProc (ForM f)
i--;
}
if (vnp != NULL) {
- grp = CreateNewGeneRef ((CharPtr) vnp->data.ptrvalue, NULL, NULL, FALSE);
+ if (vnp->choice == 1) {
+ grp = CreateNewGeneRef ((CharPtr) vnp->data.ptrvalue, NULL, NULL, FALSE);
+ } else if (vnp->choice == 3) {
+ grp = GeneRefNew ();
+ if (grp != NULL) {
+ grp->locus_tag = StringSave ((CharPtr) vnp->data.ptrvalue);
+ }
+ }
}
}
if (grp != NULL) {
@@ -2965,7 +2999,7 @@ static void SeqLocPtrToIntervalPage (DialoG d, Pointer data)
static Pointer IntervalPageToSeqLocPtr (DialoG d)
{
- BioseqPtr bsp;
+ BioseqPtr bsp, prev_bsp;
Char ch;
SeqLocPtr firstSlp;
Int4 from;
@@ -2992,7 +3026,7 @@ static Pointer IntervalPageToSeqLocPtr (DialoG d)
SeqIntPtr sip;
SeqLocPtr slp;
SeqPntPtr spp;
- Int2 strand;
+ Int2 strand, prev_strand;
TagListPtr tlp;
Int4 tmp;
SeqLocPtr tmploc1;
@@ -3008,6 +3042,8 @@ static Pointer IntervalPageToSeqLocPtr (DialoG d)
tlp = GetObjectExtra (ipp->ivals);
if (tlp == NULL) return NULL;
+ prev_bsp = NULL;
+ prev_strand = Seq_strand_unknown;
slp = NULL;
sfp = SeqFeatNew ();
if (sfp != NULL) {
@@ -3119,10 +3155,9 @@ static Pointer IntervalPageToSeqLocPtr (DialoG d)
if (strand > Seq_strand_both_rev) {
strand = Seq_strand_other;
}
+ prev_strand = strand;
} else {
- /*
- okay = FALSE;
- */
+ strand = prev_strand;
}
MemFree (txt);
}
@@ -3136,10 +3171,24 @@ static Pointer IntervalPageToSeqLocPtr (DialoG d)
bsp = NULL;
txt = ExtractTagListColumn ((CharPtr) vnp->data.ptrvalue, ipp->nucsOK ? 3 : 2);
if (txt != NULL) {
- if (StrToInt (txt, &val2) && val2 > 0 && val2 <= ipp->count) {
+ if (! StrToInt (txt, &val2) || val2 <= 0)
+ {
+ if (prev_bsp != NULL)
+ {
+ bsp = prev_bsp;
+ }
+ else
+ {
+ okay = FALSE;
+ }
+ }
+ else if (val2 <= ipp->count)
+ {
sep = ipp->bsptr [val2];
- if (sep != NULL && sep->choice == 1) {
+ if (sep != NULL && sep->choice == 1)
+ {
bsp = (BioseqPtr) sep->data.ptrvalue;
+ prev_bsp = bsp;
} else {
okay = FALSE;
}
diff --git a/desktop/dlgutil2.c b/desktop/dlgutil2.c
index 9e10333b..aa89ad9c 100644
--- a/desktop/dlgutil2.c
+++ b/desktop/dlgutil2.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.39 $
+* $Revision: 6.42 $
*
* File Description:
*
@@ -1297,6 +1297,10 @@ static void GeneXrefWarn (GrouP g)
{
Int2 val;
+ Boolean indexerVersion;
+
+ indexerVersion = (Boolean) (GetAppProperty ("InternalNcbiSequin") != NULL);
+ if (indexerVersion) return;
val = GetValue (g);
if (val == 2) {
@@ -1670,10 +1674,17 @@ extern Boolean FileToScrollText (TexT t, CharPtr path)
if (t != NULL && path != NULL && *path != '\0') {
len = FileLength (path);
+ max = (Int4) INT2_MAX;
#ifdef WIN_MOTIF
max = INT4_MAX;
-#else
- max = (Int4) INT2_MAX;
+#endif
+#ifdef WIN_MSWIN
+ max = INT4_MAX;
+#endif
+#ifdef WIN_MAC
+#ifdef OS_UNIX_DARWIN
+ max = INT4_MAX;
+#endif
#endif
if (len > 0 && len < max - 4) {
str = MemNew (sizeof (char) * (len + 3));
diff --git a/desktop/e2docsum.c b/desktop/e2docsum.c
index 8f502c81..00b0d6e3 100644
--- a/desktop/e2docsum.c
+++ b/desktop/e2docsum.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 10/30/01
*
-* $Revision: 6.46 $
+* $Revision: 6.47 $
*
* File Description:
*
@@ -2480,11 +2480,12 @@ static Int4Ptr GetCheckedUids (SummFormPtr sfp, Int2Ptr nump)
static void LaunchMedlineViewer (Int4 uid)
{
- Pointer dataptr;
- Uint2 datatype;
- Uint2 entityID;
- Int2 handled;
- PubmedEntryPtr pep;
+ Pointer dataptr;
+ Uint2 datatype;
+ Uint2 entityID;
+ Int2 handled;
+ MedlineEntryPtr mep;
+ PubmedEntryPtr pep;
WatchCursor ();
Update ();
@@ -2496,7 +2497,11 @@ static void LaunchMedlineViewer (Int4 uid)
return;
}
datatype = OBJ_MEDLINE_ENTRY;
- dataptr = (Pointer) (MedlineEntryPtr) pep->medent;
+ mep = (MedlineEntryPtr) pep->medent;
+ if (mep != NULL && mep->uid == 0) {
+ mep->uid = uid;
+ }
+ dataptr = (Pointer) mep;
entityID = ObjMgrRegister (datatype, dataptr);
if (dataptr == NULL || entityID == 0) {
ArrowCursor ();
diff --git a/desktop/gbfview.c b/desktop/gbfview.c
index c368cc39..e3d03dd3 100644
--- a/desktop/gbfview.c
+++ b/desktop/gbfview.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 2/5/97
*
-* $Revision: 6.70 $
+* $Revision: 6.71 $
*
* File Description:
*
@@ -568,6 +568,7 @@ typedef struct lookforids {
Boolean isNTorNW;
Boolean isNC;
Boolean isTPA;
+ Boolean isAEorCH;
} LookForIDs, PNTR LookForIDsPtr;
static void LookForSeqIDs (BioseqPtr bsp, Pointer userdata)
@@ -584,6 +585,14 @@ static void LookForSeqIDs (BioseqPtr bsp, Pointer userdata)
case SEQID_EMBL :
case SEQID_DDBJ :
lfip->isGED = TRUE;
+ tsip = (TextSeqIdPtr) sip->data.ptrvalue;
+ if (tsip != NULL) {
+ if (StringNCmp (tsip->accession, "AE", 2) == 0) {
+ lfip->isAEorCH = TRUE;
+ } else if (StringNCmp (tsip->accession, "CH", 2) == 0) {
+ lfip->isAEorCH = TRUE;
+ }
+ }
break;
case SEQID_TPG :
case SEQID_TPE :
@@ -613,7 +622,8 @@ static void LookForGEDetc (
BoolPtr isGED,
BoolPtr isNTorNW,
BoolPtr isNC,
- BoolPtr isTPA
+ BoolPtr isTPA,
+ BoolPtr isAEorCH
)
{
@@ -625,6 +635,7 @@ static void LookForGEDetc (
*isNTorNW = lfi.isNTorNW;
*isNC = lfi.isNC;
*isTPA = lfi.isTPA;
+ *isAEorCH = lfi.isAEorCH;
}
static void LookForNonLocalID (BioseqPtr bsp, Pointer userdata)
@@ -894,6 +905,7 @@ static void PopulateFlatFile (BioseqViewPtr bvp, FmtType format, FlgType flags)
FILE *fp;
Boolean hastpaaligns;
Int2 into;
+ Boolean isAEorCH;
Boolean isGED;
Boolean isNTorNW;
Boolean isNC;
@@ -964,7 +976,7 @@ static void PopulateFlatFile (BioseqViewPtr bvp, FmtType format, FlgType flags)
bsp = bvp->bsp;
entityID = ObjMgrGetEntityIDForPointer (bsp);
topsep = GetTopSeqEntryForEntityID (entityID);
- LookForGEDetc (topsep, &isGED, &isNTorNW, &isNC, &isTPA);
+ LookForGEDetc (topsep, &isGED, &isNTorNW, &isNC, &isTPA, &isAEorCH);
if ((flags & SHOW_CONTIG_FEATURES) != 0 || (flags & SHOW_CONTIG_SOURCES) != 0) {
if (isNTorNW || isTPA) {
@@ -1067,6 +1079,8 @@ static void PopulateFlatFile (BioseqViewPtr bvp, FmtType format, FlgType flags)
flags |= ONLY_NEAR_FEATURES;
} else if (isNC) {
flags |= NEAR_FEATURES_SUPPRESS;
+ } else if (isAEorCH) {
+ flags |= NEAR_FEATURES_SUPPRESS;
}
}
if (bvp->useScrollText) {
diff --git a/desktop/salogif.c b/desktop/salogif.c
index dd913e65..91a50c59 100644
--- a/desktop/salogif.c
+++ b/desktop/salogif.c
@@ -1,4 +1,4 @@
-/* $RCSfile: salogif.c,v $ $Revision: 6.3 $ $Date: 2003/07/15 14:36:31 $
+/* $RCSfile: salogif.c,v $ $Revision: 6.6 $ $Date: 2004/01/23 22:48:57 $
* ==========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -25,13 +25,22 @@
*
* Author: Jinghui Zhang
*
-* $Revision: 6.3 $
+* $Revision: 6.6 $
*
* File Description:
* The Blast Search result visualization utilities
*
* --------------------------------------------------------------------------
* $Log: salogif.c,v $
+* Revision 6.6 2004/01/23 22:48:57 jianye
+* restore seqid in PrintOneAlignmentOverview and initialize some varialbes
+*
+* Revision 6.5 2003/11/20 18:36:08 dondosha
+* Added function PrintOneAlignmentOverview to create an overview gif for one of the multiple query sequences
+*
+* Revision 6.4 2003/10/31 02:51:14 dondosha
+* Always use first seqid for master (query) sequence instead of "best" id in ModMaxAlign
+*
* Revision 6.3 2003/07/15 14:36:31 dondosha
* Added #defines for substitutes to fprintf and fflush, needed for gzip compression of Web BLAST results
*
@@ -244,7 +253,7 @@ static Boolean print_defline_for_sequence
static Boolean PrintImageMapForGlobal
(GlobalDrawPtr g_draw, Int4 pntX, Int4 pntY,
Int4 scale, CharPtr title_buf, SeqAlignPtr align,
- FILE *fp, const Char* formname)
+ FILE *fp, const Char* formname, int query_index)
{
AlignRegionPtr arp;
ValNodePtr curr;
@@ -262,7 +271,7 @@ static Boolean PrintImageMapForGlobal
if(gbp->has_fish_align == FALSE && gbp->arp_list != NULL)
{
if(retval == FALSE)
- fprintf(fp, "<map name=img_map>\n");
+ fprintf(fp, "<map name=img_map%d>\n", query_index);
for(curr = gbp->arp_list; curr != NULL; curr = curr->next)
{
arp = (AlignRegionPtr)curr->data.ptrvalue;
@@ -343,7 +352,7 @@ static Boolean alignment_is_redundant
Int4 c_len, r_len;
Boolean load;
Int2 i;
- Int4 start, stop;
+ Int4 start = 0 , stop = 0;
SeqIdPtr sip;
len = 0;
@@ -441,7 +450,7 @@ static void update_redundant_val
Int4 c_len;
Boolean load;
Int2 i;
- Int4 start, stop;
+ Int4 start = 0, stop = 0;
switch(align->segtype) {
case 3:
@@ -629,7 +638,7 @@ static SeqAlignPtr ModMaxAlign
return (*h_align);
if(*h_align == NULL || m_bsp == NULL)
return (*h_align);
- m_sip = SeqIdFindBest(m_bsp->id, 0);
+ m_sip = m_bsp->id;
val = (Uint1Ptr)MemNew((size_t)m_bsp->length * sizeof(Int1));
curr = *h_align;
@@ -684,6 +693,19 @@ NLM_EXTERN Boolean PrintAlignmentOverview
const Char* gif_name,
const Char* title)
{
+ return PrintOneAlignmentOverview(h_annot, fp, formname, href, gif_name,
+ title, 1);
+}
+
+NLM_EXTERN Boolean PrintOneAlignmentOverview
+(SeqAnnotPtr h_annot,
+ FILE* fp,
+ const Char* formname,
+ const Char* href,
+ const Char* gif_name,
+ const Char* title,
+ int query_index)
+{
SeqEntryPtr sep;
Boolean is_new_sep;
SeqAnnotPtr sap, annot, prev;
@@ -699,6 +721,7 @@ NLM_EXTERN Boolean PrintAlignmentOverview
FILE *gif_fp;
Int4 align_num;
Char title_buf[201], tmpbuf[64];
+ SeqIdPtr idtemp;
if(h_annot == NULL || fp == NULL)
return FALSE;
@@ -710,6 +733,8 @@ NLM_EXTERN Boolean PrintAlignmentOverview
if(master_bsp == NULL)
return FALSE;
bsp = master_bsp;
+ idtemp= bsp->id->next;
+ bsp->id->next = NULL;
sep = SeqEntryFind(bsp->id);
if(sep == NULL)
{
@@ -770,7 +795,8 @@ NLM_EXTERN Boolean PrintAlignmentOverview
/*print out the image map*/
if(!PrintImageMapForGlobal(g_draw, pBox.left, pBox.top, 1, title_buf,
- (SeqAlignPtr)(annot->data), fp, formname))
+ (SeqAlignPtr)(annot->data), fp, formname,
+ query_index))
printf("Fail to print the image map\n");
fflush(fp);
@@ -797,9 +823,9 @@ NLM_EXTERN Boolean PrintAlignmentOverview
ExitMuskStyles();
fprintf(fp, "<CENTER>\n");
- fprintf(fp, "<IMG WIDTH=%d HEIGHT=%d USEMAP=#img_map BORDER=1 "
+ fprintf(fp, "<IMG WIDTH=%d HEIGHT=%d USEMAP=#img_map%d ORDER=1 "
"SRC=\"%s%s\" ISMAP>",
- (int)width, (int)height, href, gif_name);
+ (int)width, (int)height, query_index, href, gif_name);
fprintf(fp, "</CENTER>\n");
fprintf(fp, "<HR>\n<PRE>\n");
@@ -829,7 +855,7 @@ NLM_EXTERN Boolean PrintAlignmentOverview
else
prev->next = NULL;
SeqAnnotFree(sap);
-
+ master_bsp->id->next = idtemp; /*restore seqid*/
BioseqUnlock(master_bsp);
return retval;
diff --git a/desktop/salogif.h b/desktop/salogif.h
index e3e4c351..8c8b086f 100644
--- a/desktop/salogif.h
+++ b/desktop/salogif.h
@@ -1,7 +1,7 @@
#ifndef SALOGIF__H
#define SALOGIF__H
-/* $RCSfile: salogif.h,v $ $Revision: 6.1 $ $Date: 2000/03/20 19:00:28 $
+/* $RCSfile: salogif.h,v $ $Revision: 6.2 $ $Date: 2003/11/20 18:36:08 $
* ==========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -33,6 +33,9 @@
*
* --------------------------------------------------------------------------
* $Log: salogif.h,v $
+* Revision 6.2 2003/11/20 18:36:08 dondosha
+* Added function PrintOneAlignmentOverview to create an overview gif for one of the multiple query sequences
+*
* Revision 6.1 2000/03/20 19:00:28 shavirin
* Initial revision in the new location.
*
@@ -71,6 +74,20 @@ NLM_EXTERN Boolean PrintAlignmentOverview
const Char* title /* title printed at the top of generated HTML output */
);
+/* Shows alignments gif image for one query
+ * from a set of multiple queries.
+ */
+NLM_EXTERN Boolean PrintOneAlignmentOverview
+(SeqAnnotPtr h_annot, /* output of blast search */
+ FILE* fp, /* file where output goes to */
+ const Char* formname, /* it is needed to specify name of embeded HTML form,
+ * create this form before if there is no one */
+ const Char* href, /* hyperlink location of the GIF file */
+ const Char* gif_name, /* GIF file name */
+ const Char* title, /* title printed at the top of generated HTML output */
+ int query_index /* Index of this query in the set of queries */
+ );
+
#ifdef __cplusplus
}
#endif
diff --git a/desktop/smdlg2.c b/desktop/smdlg2.c
index 8d237f1d..bfac9ecc 100644
--- a/desktop/smdlg2.c
+++ b/desktop/smdlg2.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 8/10/95
*
-* $Revision: 6.0 $
+* $Revision: 6.1 $
*
* File Description:
*
@@ -182,7 +182,7 @@ static void
}
static void
-/*FCN*/UpdateControls (
+/*FCN*/UpdateDlgControls (
void
){
if ( totalFeatures == 0 ){
@@ -322,7 +322,7 @@ static void
FillGroupList(TRUE);
SetGroupValue ( curGroupInd );
SaveGroupArray();
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -347,7 +347,7 @@ static void
FillGroupList(TRUE);
SetGroupValue ( curGroupInd );
SaveGroupArray();
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -382,7 +382,7 @@ static void
curFeatureInd = 0;
SetFeatValue ( curFeatureInd );
}
- UpdateControls();
+ UpdateDlgControls();
SaveGroupArray();
}
@@ -436,7 +436,7 @@ static void
SetFeatValue ( curFeatureInd );
}
SaveGroupArray();
- UpdateControls();
+ UpdateDlgControls();
}
}
@@ -457,7 +457,7 @@ static void
FillGroupList(TRUE);
SetGroupValue ( curGroupInd );
SaveGroupArray();
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -491,7 +491,7 @@ static void
curFeatureInd = 0;
SetFeatValue ( curFeatureInd );
}
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -504,7 +504,7 @@ static void
curFeatureInd = GetValue ( featList ) - 1;
}
if ( curFeatureInd > nHideFeatures ) curFeatureInd--;
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -521,7 +521,7 @@ static void
FillFeatList(TRUE);
SetFeatValue ( curFeatureInd );
SaveFeatureArray();
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -546,7 +546,7 @@ static void
FillFeatList(TRUE);
SetFeatValue ( curFeatureInd );
SaveFeatureArray();
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -581,7 +581,7 @@ static void
FillFeatList(TRUE);
SetFeatValue ( curFeatureInd );
SaveFeatureArray();
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -601,7 +601,7 @@ static void
FillFeatList(TRUE);
SetFeatValue ( curFeatureInd );
SaveFeatureArray();
- UpdateControls();
+ UpdateDlgControls();
}
static void
@@ -694,7 +694,7 @@ GrouP
FillGroupList(FALSE);
SetGroupValue (curGroupInd);
FillFeatPopup(FALSE);
- UpdateControls ();
+ UpdateDlgControls ();
return g;
}
diff --git a/desktop/smdlg3.c b/desktop/smdlg3.c
index e6100192..f51dcc48 100644
--- a/desktop/smdlg3.c
+++ b/desktop/smdlg3.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 8/10/95
*
-* $Revision: 6.0 $
+* $Revision: 6.1 $
*
* File Description:
*
@@ -319,7 +319,7 @@ static void
}
static void
-/*FCN*/UpdateControls (
+/*FCN*/UpdateDlgControls (
Boolean panel,
Boolean other
){
@@ -617,7 +617,7 @@ static void
Nlm_SetMuskCParamEd( curClass, inClipSchema[i].subClass,
inClipSchema[i].pType, inClipBoard[i] );
}
- UpdateControls(TRUE,TRUE);
+ UpdateDlgControls(TRUE,TRUE);
}
static void
@@ -702,7 +702,7 @@ static void
){
LoadFeatAr ();
FillFetureList(TRUE);
- UpdateControls(TRUE,TRUE);
+ UpdateDlgControls(TRUE,TRUE);
UpdateTools();
}
@@ -711,7 +711,7 @@ static void
LisT l
){
curExtraInd = GetValue (l) - 1;
- UpdateControls(TRUE,TRUE);
+ UpdateDlgControls(TRUE,TRUE);
UpdateTools();
}
@@ -758,7 +758,7 @@ static void
Enable ( applayButton );
}
}
- UpdateControls(TRUE,TRUE);
+ UpdateDlgControls(TRUE,TRUE);
UpdateTools();
}
@@ -782,7 +782,7 @@ static void
if ( GetStatus(b) ) val = (BigScalar)TRUE;
else val = (BigScalar)FALSE;
Nlm_SetMuskCParamEd(curClass,MSM_SEG_BORD,MSM_TRUEFALSE,val);
- UpdateControls(TRUE,FALSE);
+ UpdateDlgControls(TRUE,FALSE);
}
static void
@@ -804,7 +804,7 @@ static void
}
val = (BigScalar)(GetValue(g)-1);
Nlm_SetMuskCParamEd(curClass,MSM_FGAP,MSM_STYLE,val);
- UpdateControls(TRUE,FALSE);
+ UpdateDlgControls(TRUE,FALSE);
}
static void
@@ -846,7 +846,7 @@ static void
}
}
Nlm_SetMuskCParamEd(curClass,curSubClass,MSM_STYLE,val);
- UpdateControls(TRUE,FALSE);
+ UpdateDlgControls(TRUE,FALSE);
}
static void
@@ -882,7 +882,7 @@ static void
if ( GetStatus (orientCheckBox[curDlg]) ) val |= MSM_SEG_SHOWORIENT;
}
Nlm_SetMuskCParamEd(curClass,MSM_SEGMENT, MSM_STYLE, val);
- UpdateControls(TRUE,FALSE);
+ UpdateDlgControls(TRUE,FALSE);
UpdateTools ();
}
@@ -905,7 +905,7 @@ static void
}
val = (BigScalar)GetValue(p) * 2 + 2;
Nlm_SetMuskCParamEd(curClass,MSM_SEGMENT, MSM_HEIGHT, val);
- UpdateControls(TRUE,FALSE);
+ UpdateDlgControls(TRUE,FALSE);
}
static void
@@ -1236,7 +1236,7 @@ static GrouP
NULL );
}
curSubDlg[curDlg] = 0;
- UpdateControls (FALSE,TRUE);
+ UpdateDlgControls (FALSE,TRUE);
return gRet;
} /* End of CreateDlgFeatures () */
@@ -1308,7 +1308,7 @@ static void
Nlm_SetMuskCParamEd(curClass,curSubClass,MSM_HEIGHT,fsize);
}
}
- UpdateControls ( TRUE, TRUE );
+ UpdateDlgControls ( TRUE, TRUE );
}
static void Nlm_SetTDef (
@@ -1322,7 +1322,7 @@ static void Nlm_SetTDef (
Show ( featPopuP );
LoadFeatAr();
FillFetureList (TRUE);
- UpdateControls (TRUE,TRUE);
+ UpdateDlgControls (TRUE,TRUE);
}
UpdateTools();
}
diff --git a/doc/blast.txt b/doc/blast.txt
index 44141b4f..944b2c49 100644
--- a/doc/blast.txt
+++ b/doc/blast.txt
@@ -1,18 +1,20 @@
README for stand-alone BLAST
-$Date: 2003/06/30 16:30:18 $
+$Date: 2004/01/30 21:13:06 $
This document provides information on stand-alone BLAST. Topics covered are
setting up stand-alone BLAST, command-line options for stand-alone BLAST,
and a release history of the different versions.
+NCBI provides binaries for the following platforms:
+
Apple MacOS 9 (powerpc)
Apple MacOS X (powerpc)
DEC/Compaq/HP OSF1 5.1 (alpha)
FreeBSD 4.5 (ia32)
HP HPUX 11 (hppa, ia64)
IBM AIX 5.1 (power4, powerpc)
-Linux (kernel 2.4, glibc 2.2.4) (ia32, ia64)
+Linux (kernel 2.4, glibc 2.2.4) (ia32, ia64, amd64)
Microsoft Windows 2000 (ia32)
SGI IRIX 6.5 (mips)
Sun Solaris 7 (ia32)
diff --git a/doc/dispatcher.html b/doc/dispatcher.html
index 64955714..a7c1832f 100644
--- a/doc/dispatcher.html
+++ b/doc/dispatcher.html
@@ -392,18 +392,6 @@ Firewall Port IP Address
</pre>
<p>
-Please also note obsolescent settings that still should be provided
-but will be removed in the nearest future:
-
-<p align="center">
-<pre>
-Firewall Port IP Address
---------------------------------
- 5811 130.14.22.32
- 5812 130.14.22.31
-</pre>
-
-<p>
If your firewall is not transparent, the firewall port number
should be mapped to the same port number on the external host.
@@ -559,7 +547,7 @@ you have a question, please contact <a href="mailto:info@ncbi.nlm.nih.gov">
<p>
<hr>
<table border="0" cellspasing="0">
-<tr><td>Source: distrib/doc/dispatcher.html</td><td>$Date: 2003/09/29 15:04:00 $</td><td>$Revision: 6.23 $</td></tr>
+<tr><td>Source: distrib/doc/dispatcher.html</td><td>$Date: 2004/01/16 19:03:44 $</td><td>$Revision: 6.24 $</td></tr>
</table>
diff --git a/doc/firewall.html b/doc/firewall.html
index 763e656b..3733e603 100644
--- a/doc/firewall.html
+++ b/doc/firewall.html
@@ -48,7 +48,7 @@
<p>&nbsp;</p>
<p>
- <i>Last modified:</i> $Date: 2003/09/29 15:04:00 $<br>
+ <i>Last modified:</i> $Date: 2004/01/16 19:03:44 $<br>
<i>Latest version: </i>
<a href="http://www.ncbi.nlm.nih.gov/cpp/network/firewall.html">
http://www.ncbi.nlm.nih.gov/cpp/network/firewall.html</a>
@@ -120,17 +120,6 @@ Firewall Port IP Address
5845 130.14.22.12 (cannot be accessed from outside NCBI!)
</pre>
-Please also note obsolescent settings that still should be provided
-but will be removed in the nearest future:
-
-<p align="center">
-<pre>
-Firewall Port IP Address
---------------------------------
- 5811 130.14.22.32
- 5812 130.14.22.31
-</pre>
-
<p>
If your firewall is not transparent, the firewall port number
should be mapped to the same port number on the external host.
diff --git a/doc/formatdb.txt b/doc/formatdb.txt
index 1ef831f7..75beccdb 100644
--- a/doc/formatdb.txt
+++ b/doc/formatdb.txt
@@ -3,24 +3,24 @@ Formatdb README
Table of Contents
- Introduction
+ Introduction
- Command Line Options
+ Command Line Options
Configuration File
- Formatdb Notes/Troubleshooting
-
- A The -o option and identifiers
- B "SORTFiles failed" message
- C Formatting large FASTA files
- D Piping a database to formatdb without uncompressing
- E Creating custom databases.
- F General troubleshooting tips.
- G "SeqIdParse Failure" error
- H "FileOpen" error
+ Formatdb Notes/Troubleshooting
+
+ A The -o option and identifiers
+ B "SORTFiles failed" message
+ C Formatting large FASTA files
+ D Piping a database to formatdb without uncompressing
+ E Creating custom databases.
+ F General troubleshooting tips.
+ G "SeqIdParse Failure" error
+ H "FileOpen" error
- Appendix 1: The Files Produced by Formatdb
+ Appendix 1: The Files Produced by Formatdb
@@ -46,143 +46,133 @@ Command Line Options
A list of the command line options and the current version for formatdb may
be obtained by executing formatdb without options, as in:
- formatdb -
+ formatdb -
The formatdb options are summarized below:
formatdb 2.2.5 arguments:
- -t Title for database file [String]
- Optional
- -i Input file(s) for formatting (this parameter must be set)
- [File In]
- -l Logfile name: [File Out]
- Optional
+ -t Title for database file [String]
+ Optional
+ -i Input file(s) for formatting (this parameter must be set)
+ [File In]
+ -l Logfile name: [File Out]
+ Optional
default = formatdb.log
- -p Type of file
- T - protein
- F - nucleotide [T/F] Optional
- default = T
+ -p Type of file
+ T - protein
+ F - nucleotide [T/F] Optional
+ default = T
- -o Parse options
- T - True: Parse SeqId and create indexes.
- F - False: Do not parse SeqId. Do not create indexes.
- [T/F] Optional default = F
+ -o Parse options
+ T - True: Parse SeqId and create indexes.
+ F - False: Do not parse SeqId. Do not create indexes.
+ [T/F] Optional default = F
- If the "-o" option is TRUE (and the source database is in FASTA
- format), then the database identifiers in the FASTA definition
- line must follow the convention of the FASTA Defline Format.
- Please see section "F Note on creating custom databases"
- below.
+ If the "-o" option is TRUE (and the source database is in FASTA
+ format), then the database identifiers in the FASTA definition
+ line must follow the convention of the FASTA Defline Format.
+ Please see section "F Note on creating custom databases"
+ below.
- -a Input file is database in ASN.1 format (otherwise FASTA is expected)
- T - True,
- F - False.
- [T/F] Optional default = F
+ -a Input file is database in ASN.1 format (otherwise FASTA is expected)
+ T - True,
+ F - False.
+ [T/F] Optional default = F
- -b ASN.1 database in binary mode
- T - binary,
- F - text mode.
- [T/F] Optional default = F
+ -b ASN.1 database in binary mode
+ T - binary,
+ F - text mode.
+ [T/F] Optional default = F
- A source ASN.1 database may be represented in two formats -
- ascii text and binary. The "-b" option, if TRUE, specifies that
- input ASN.1 database is in binary format. The option is ignored
- in case of FASTA input database.
+ A source ASN.1 database may be represented in two formats -
+ ascii text and binary. The "-b" option, if TRUE, specifies that
+ input ASN.1 database is in binary format. The option is ignored
+ in case of FASTA input database.
- -e Input is a Seq-entry [T/F]
- Optional
- default = F
+ -e Input is a Seq-entry [T/F]
+ Optional
+ default = F
- A source ASN.1 database (either text ascii or binary) may
- contain a Bioseq-set or just one Bioseq. In the latter case the
- "-e" switch should be set to TRUE.
+ A source ASN.1 database (either text ascii or binary) may
+ contain a Bioseq-set or just one Bioseq. In the latter case the
+ "-e" switch should be set to TRUE.
- -n Base name for BLAST files [String]
- Optional
+ -n Base name for BLAST files [String]
+ Optional
- This options allows one to produce BLAST databases with a
- different name than that of the original FASTA file. For
- instance, one could have a file named 'ecoli.nuc.txt' and and
- format it as 'ecoli':
+ This options allows one to produce BLAST databases with a
+ different name than that of the original FASTA file. For
+ instance, one could have a file named 'ecoli.nuc.txt' and and
+ format it as 'ecoli':
- formatdb -i ecoli.nuc.txt -p F -o T -n ecoli
+ formatdb -i ecoli.nuc.txt -p F -o T -n ecoli
- uncompress -c nr.z | formatdb -i stdin -o T -n nr
+ uncompress -c nr.z | formatdb -i stdin -o T -n nr
- This can be used in situations where the original FASTA file is
- not required other than by formatdb. This can help in a
- situation where disk-space is tight.
+ This can be used in situations where the original FASTA file is
+ not required other than by formatdb. This can help in a
+ situation where disk-space is tight.
- -v Database volume size in millions of letters [Integer] Optional
- default = 0
+ -v Database volume size in millions of letters [Integer] Optional
+ default = 0
range from 0 to <NULL>
- This option breaks up large FASTA files into 'volumes' (each
- with a maximum size of 2 billion letters). As part of the
- creation of a volume formatdb writes a new type of BLAST
- database file, called an alias file, with the extension 'nal'
- or 'pal'.
+ This option breaks up large FASTA files into 'volumes' (each
+ with a maximum size of 2 billion letters). As part of the
+ creation of a volume formatdb writes a new type of BLAST
+ database file, called an alias file, with the extension 'nal'
+ or 'pal'.
- -s Create indexes limited only to accessions - sparse [T/F]
- Optional
- default = F
+ -s Create indexes limited only to accessions - sparse [T/F]
+ Optional
+ default = F
- This option limits the indices for the string identifiers (used
- by formatdb) to accessions (i.e., no locus names). This is
- especially useful for sequences sets like the EST's where the
- accession and locus names are identical. Formatdb runs faster
- and produces smaller temporary files if this option is used.
- It is strongly recommended for EST's, STS's, GSS's, and
- HTGS's.
+ This option limits the indices for the string identifiers (used
+ by formatdb) to accessions (i.e., no locus names). This is
+ especially useful for sequences sets like the EST's where the
+ accession and locus names are identical. Formatdb runs faster
+ and produces smaller temporary files if this option is used.
+ It is strongly recommended for EST's, STS's, GSS's, and
+ HTGS's.
- -A Create ASN.1 structured deflines [T/F]
- Optional
- default = T
+ -L Create an alias file with this name
+ use the gifile arg (below) if set to calculate db size
+ use the BLAST db specified with -i (above) [File Out] Optional
- This option produces a new BLAST database format (version 4).
- The BLAST programs can read this format as well as the current format.
- The program automatically identifies which version it should work
- with. This new format stores the sequence definition lines in
- a structured manner (as ASN.1), this will allow future versions of
- BLAST to better present taxonomic information as well as information
- about other resources (e.g., UniGene, LocusLink) for a database sequence.
+ This option produces a BLAST database alias file using a specified
+ database, but limiting the sequences searched to those in the GI list
+ given by the -F argument. See the section "Note on creating an alias file
+ for a GI list" for more information.
- -L Create an alias file with this name
- use the gifile arg (below) if set to calculate db size
- use the BLAST db specified with -i (above) [File Out] Optional
+ -F Gifile (file containing list of gi's) [File In] Optional
- This option produces a BLAST database alias file using a specified
- database, but limiting the sequences searched to those in the GI list
- given by the -F argument. See the section "Note on creating an alias file
- for a GI list" for more information.
+ This option can be used to specify the GI list for the alias file
+ construction (-L option above) or to produce a binary GI list if
+ the -B option (below) is set.
- -F Gifile (file containing list of gi's) [File In] Optional
+ -B Binary Gifile produced from the Gifile specified above [File Out] Optional
- This option can be used to specify the GI list for the alias file
- construction (-L option above) or to produce a binary GI list if
- the -B option (below) is set.
-
- -B Binary Gifile produced from the Gifile specified above [File Out] Optional
-
- This option specifies the name of a binary GI list file. This option should
- be used with the -F option. A text GI list may be specified with the -F
- option and the -B option will produce that GI list in binary format. The
- binary file is smaller and BLAST does not need to convert it, so it can
- be read faster.
+ This option specifies the name of a binary GI list file. This option should
+ be used with the -F option. A text GI list may be specified with the -F
+ option and the -B option will produce that GI list in binary format. The
+ binary file is smaller and BLAST does not need to convert it, so it can
+ be read faster.
Configuration File
------------------
Starting from formatdb version 4, we have added a configuration file to allow
flexibility in specifying the membership and link bits to set in the ASN.1
-defline structures. The membership bit arrays are used to help distinguish
-sequences that belong to a subset database (e.g.: pdb, swissprot) in a
-non-redundant database (e.g.: nr). The link bit arrays are used to indentify
-which sequences should have a user specified "link out" in the blast (html)
-report. These features are still under development and useful within NCBI
-only. A sample configuration file follows:
+defline structures. This feature is available by recompiling the formatdb
+binary with the following compile time flag: -DSET_ASN1_DEFLINE_BITS.
+The membership bit arrays are used to help distinguish sequences that belong
+to a subset database (e.g.: pdb, swissprot) in a non-redundant database
+(e.g.: nr). The link bit arrays are used to indentify which sequences should
+have a user specified "link out" in the blast (html) report. These features
+are still under development and useful within NCBI only. A sample
+configuration file follows:
; .formatdbrc: formatdb configuration file
;
@@ -465,6 +455,7 @@ contain at most about 4 billion bases. The new databases allows that to
be much larger.
+PLEASE NOTE THAT VERSION 3 OF THE BLAST DATABASES WILL NO LONGER BE SUPPORTED.
The new databases keep the sequence descriptors in a structured format
@@ -499,18 +490,18 @@ the identifiers for the databases from which the sequences were derived.
Database Name Identifier Syntax
- GenBank gb|accession|locus
- EMBL Data Library emb|accession|locus
- DDBJ, DNA Database of Japan dbj|accession|locus
- NBRF PIR pir||entry
- Protein Research Foundation prf||name
- SWISS-PROT sp|accession|entry name
- Brookhaven Protein Data Bank pdb|entry|chain
- Patents pat|country|number
- GenInfo Backbone Id bbs|number
- General database identifier gnl|database|identifier
- NCBI Reference Sequence ref|accession|locus
- Local Sequence identifier lcl|identifier
+ GenBank gb|accession|locus
+ EMBL Data Library emb|accession|locus
+ DDBJ, DNA Database of Japan dbj|accession|locus
+ NBRF PIR pir||entry
+ Protein Research Foundation prf||name
+ SWISS-PROT sp|accession|entry name
+ Brookhaven Protein Data Bank pdb|entry|chain
+ Patents pat|country|number
+ GenInfo Backbone Id bbs|number
+ General database identifier gnl|database|identifier
+ NCBI Reference Sequence ref|accession|locus
+ Local Sequence identifier lcl|identifier
For example, an identifier might be "gb|M73307|AGMA13GT", where the "gb" tag
@@ -682,37 +673,38 @@ BLASTDB=LabMac:blast:data
Appendix 1: The Files Produced by Formatdb
------------------------------------------
Using formatdb without the "-o T" indexing option results in three
-BLAST database files (.nhr, .nin, ,nsq). Using the "-o T" option will result in
-additional files.
-If gi's are present in the FASTA definition lines of the source file, there will
-be four additional files created (.nsd, nsi, nni, nnd). These are ISAM indices for
-mapping a sequence identifier to a particular sequence in the BLAST database If
-gi's are not use there will be only two additional files created (.nsd, .nsi).
-These files are listed below for both an example nucleotide and a protein sequence
-database. The actual sequence data is stored in the files with extension "nsq" or
-"psq". The compression ratio for these files is about 4:1 for nucleotides and 1:1
-for protein sequence source files.
-
-Extension Content Format
+BLAST database files (.nhr, .nin, ,nsq). Using the "-o T" option will result
+in additional files.
+If gi's are present in the FASTA definition lines of the source file, there
+will be four additional files created (.nsd, nsi, nni, nnd). These are
+ISAM indices for mapping a sequence identifier to a particular sequence in
+the BLAST database. If gi's are not use there will be only two additional
+files created (.nsd, .nsi).
+These files are listed below for both an example nucleotide and a protein
+sequence database. The actual sequence data is stored in the files with
+extension "nsq" or "psq". The compression ratio for these files is
+about 4:1 for nucleotides and 1:1 for protein sequence source files.
+
+Extension Content Format
---------------------------------------------
Nucleotide database formatted without "-o T"
-
-nhr deflines binary
-
-nin indices binary
+
+nhr deflines binary
+
+nin indices binary
-nsq sequence data binary
+nsq sequence data binary
Nucleotide database formatted with "-o T" add these ISAM files:
-nnd GI data binary
+nnd GI data binary
-nni GI indices binary
+nni GI indices binary
-nsd non-GI data binary
-
-nsi non-GI indices binary
+nsd non-GI data binary
+
+nsi non-GI indices binary
The formatdb index files involving deflines are small relative to the
source database due to entries such as the one below in which the
@@ -731,25 +723,25 @@ GCTTAGCCACGCCCCCACGGGACACAGCAGTGATAAAAATTAAGCTATAAACGAAAGTTCGACTAAGTCATGTTAATTTA
....16398 bp total
-Extension Content Format
+Extension Content Format
------------------------------------------
Protein database formatted without "-o T
-phr deflines binary
-
-pin indices binary
+phr deflines binary
+
+pin indices binary
-psq sequence data binary
+psq sequence data binary
Protein database formatted with "-o T" add these ISAM files:
-pnd GI data binary
+pnd GI data binary
-pni GI indices binary
+pni GI indices binary
-psd non-GI data binary
-
-psi non-GI indices binary
+psd non-GI data binary
+
+psi non-GI indices binary
The formatdb index files involving deflines are large relative to the
source database due to entries such as the one below in which the
@@ -768,4 +760,4 @@ used to extract data from the BLAST databases. Readdb is part
of the the NCBI toolkit (ftp://ftp.ncbi.nih.gov/toolbox/ncbi_tools/),
readdb.h contains a list of supported function calls.
-Last updated April 02 2001
+Last updated January 30 2004
diff --git a/doc/fwd_check.sh b/doc/fwd_check.sh
index 3bc0306e..8dc7480e 100755
--- a/doc/fwd_check.sh
+++ b/doc/fwd_check.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# $Id: fwd_check.sh,v 1.14 2003/09/29 14:04:45 lavr Exp $
+# $Id: fwd_check.sh,v 1.15 2004/01/16 19:03:45 lavr Exp $
# Author: Denis Vakatov (vakatov@ncbi,nlm.nih.gov)
# Modified: Anton Lavrentiev (lavr@ncbi.nlm.nih.gov)
#
@@ -20,8 +20,8 @@ cat <<EOF
;130.14.22.2 5859 RETIRED
;130.14.22.8 5840 RETIRED
;130.14.22.30 5810 RETIRED
-130.14.22.31 5812 OBSOLESCENT
-130.14.22.32 5811 OBSOLESCENT
+130.14.22.31 5812 RETIRED
+130.14.22.32 5811 RETIRED
130.14.22.12 5845 INTERNAL
130.14.29.112 5860 RESERVED
130.14.29.112 5861 OK
diff --git a/doc/images/seqn01.png b/doc/images/seqn01.png
index 0436eafa..11c5aba1 100644
--- a/doc/images/seqn01.png
+++ b/doc/images/seqn01.png
Binary files differ
diff --git a/doc/images/seqn02.png b/doc/images/seqn02.png
index 409423c5..1f9f82e9 100644
--- a/doc/images/seqn02.png
+++ b/doc/images/seqn02.png
Binary files differ
diff --git a/doc/images/seqn03.png b/doc/images/seqn03.png
index 4ae67e56..751776b4 100644
--- a/doc/images/seqn03.png
+++ b/doc/images/seqn03.png
Binary files differ
diff --git a/doc/images/seqn04.png b/doc/images/seqn04.png
index 2f620327..e40337e2 100644
--- a/doc/images/seqn04.png
+++ b/doc/images/seqn04.png
Binary files differ
diff --git a/doc/images/seqn05.png b/doc/images/seqn05.png
index 85349391..e85d2536 100644
--- a/doc/images/seqn05.png
+++ b/doc/images/seqn05.png
Binary files differ
diff --git a/doc/images/seqn06.png b/doc/images/seqn06.png
index 8d216689..84859cbd 100644
--- a/doc/images/seqn06.png
+++ b/doc/images/seqn06.png
Binary files differ
diff --git a/doc/images/seqn07.png b/doc/images/seqn07.png
index 9c41ff75..5a172e28 100644
--- a/doc/images/seqn07.png
+++ b/doc/images/seqn07.png
Binary files differ
diff --git a/doc/images/seqn08.png b/doc/images/seqn08.png
index adb4f3ba..bea5944a 100644
--- a/doc/images/seqn08.png
+++ b/doc/images/seqn08.png
Binary files differ
diff --git a/doc/images/seqn09.png b/doc/images/seqn09.png
index 5995f5ec..405444da 100644
--- a/doc/images/seqn09.png
+++ b/doc/images/seqn09.png
Binary files differ
diff --git a/doc/images/seqn10.png b/doc/images/seqn10.png
index 0d35480a..00556348 100644
--- a/doc/images/seqn10.png
+++ b/doc/images/seqn10.png
Binary files differ
diff --git a/doc/images/seqn11.png b/doc/images/seqn11.png
index a5dafc3d..27d86887 100644
--- a/doc/images/seqn11.png
+++ b/doc/images/seqn11.png
Binary files differ
diff --git a/doc/images/seqn12.png b/doc/images/seqn12.png
index c12857f8..32c2c1a4 100644
--- a/doc/images/seqn12.png
+++ b/doc/images/seqn12.png
Binary files differ
diff --git a/doc/images/seqn13.png b/doc/images/seqn13.png
index 77cd5ba5..3deafbaf 100644
--- a/doc/images/seqn13.png
+++ b/doc/images/seqn13.png
Binary files differ
diff --git a/doc/images/seqn14.png b/doc/images/seqn14.png
index 9ef673b6..3974a791 100644
--- a/doc/images/seqn14.png
+++ b/doc/images/seqn14.png
Binary files differ
diff --git a/doc/images/seqn15.png b/doc/images/seqn15.png
index 6bd95104..44cf7c1c 100644
--- a/doc/images/seqn15.png
+++ b/doc/images/seqn15.png
Binary files differ
diff --git a/doc/images/seqn16.png b/doc/images/seqn16.png
index 090ae0a5..54e5c201 100644
--- a/doc/images/seqn16.png
+++ b/doc/images/seqn16.png
Binary files differ
diff --git a/doc/images/seqn17.png b/doc/images/seqn17.png
index aac50041..6b192dd0 100644
--- a/doc/images/seqn17.png
+++ b/doc/images/seqn17.png
Binary files differ
diff --git a/doc/images/seqn18.png b/doc/images/seqn18.png
index 9350c0ac..2324eeb3 100644
--- a/doc/images/seqn18.png
+++ b/doc/images/seqn18.png
Binary files differ
diff --git a/doc/images/seqn19.png b/doc/images/seqn19.png
index 75dbbeb3..d6e8a0cc 100644
--- a/doc/images/seqn19.png
+++ b/doc/images/seqn19.png
Binary files differ
diff --git a/doc/images/seqn20.png b/doc/images/seqn20.png
index a9d0df70..ca8b83f8 100644
--- a/doc/images/seqn20.png
+++ b/doc/images/seqn20.png
Binary files differ
diff --git a/doc/images/seqn21.png b/doc/images/seqn21.png
index c07f458b..240aa84c 100644
--- a/doc/images/seqn21.png
+++ b/doc/images/seqn21.png
Binary files differ
diff --git a/doc/images/seqn22.png b/doc/images/seqn22.png
index d4532f07..8d595a59 100644
--- a/doc/images/seqn22.png
+++ b/doc/images/seqn22.png
Binary files differ
diff --git a/doc/man/asn2gb.1 b/doc/man/asn2gb.1
index 7986d22b..78e4d2aa 100644
--- a/doc/man/asn2gb.1
+++ b/doc/man/asn2gb.1
@@ -1,4 +1,4 @@
-.TH ASN2GB 1 2003-04-27 NCBI "NCBI Tools User's Manual"
+.TH ASN2GB 1 2003-11-10 NCBI "NCBI Tools User's Manual"
.SH NAME
asn2gb \- convert ASN.1 biological data to a GenBank-style flat format
.SH SYNOPSIS
@@ -23,12 +23,12 @@ asn2gb \- convert ASN.1 biological data to a GenBank-style flat format
[\|\fB\-s\fP\ \fIstyle\fP\|]
[\|\fB\-t\fP\ \fIN\fP\|]
[\|\fB\-u\fP\ \fIN\fP\|]
-[\|\fB\-x\fP\ \fIacc\fP\|]
+.\" [\|\fB\-x\fP\ \fIacc\fP\|] \" disabled
[\|\fB\-y\fP\ \fIN\fP\|]
.SH DESCRIPTION
-\fBasn2ff\fP converts descriptions of biological sequences from NCBI's
+\fBasn2gb\fP converts descriptions of biological sequences from NCBI's
ASN.1 format to one of several flat-file formats, and is the successor
-to \fBasn2gb\fP(1).
+to \fBasn2ff\fP(1).
.SH OPTIONS
A summary of options is included below.
.TP
@@ -182,9 +182,9 @@ Hide most imported features
Hide SNP features
.PD
.RE
-.TP
-\fB\-x\fP\ \fIacc\fP
-Accession to extract
+.\" .TP
+.\" \fB\-x\fP\ \fIacc\fP
+.\" Accession to extract
.TP
\fB\-y\fP\ \fIN\fP
Feature itemID
diff --git a/doc/man/blast.1 b/doc/man/blast.1
index 8c7ec8cf..0f58ced1 100644
--- a/doc/man/blast.1
+++ b/doc/man/blast.1
@@ -1,4 +1,4 @@
-.TH BLAST 1 2003-04-27 NCBI "NCBI Tools User's Manual"
+.TH BLAST 1 2003-11-10 NCBI "NCBI Tools User's Manual"
.SH NAME
bl2seq, blastall, blastcl3, blastpgp, impala, megablast, rpsblast, seedtop \- Basic Local Alignment Search Tool
.SH SYNOPSIS
@@ -626,7 +626,8 @@ Do not perform gapped alignment (N/A for tblastx)
Generate words for every base of the database (default is every 4th)
.TP
\fB\-h\fP\ \fIX\fP (blastpgp, impala)
-e-value threshold for inclusion in multipass model (default = 0.005)
+e-value threshold for inclusion in multipass model (default = 0.002
+for blastpgp, 0.005 for impala)
.TP
\fB\-i\fP\ \fIfilename\fP
Read (first) sequence from \fIfilename\fP (default is stdin)
diff --git a/doc/man/fastacmd.1 b/doc/man/fastacmd.1
index 588cfe33..d17795dd 100644
--- a/doc/man/fastacmd.1
+++ b/doc/man/fastacmd.1
@@ -1,4 +1,4 @@
-.TH FASTACMD 1 2003-04-27 NCBI "NCBI Tools User's Manual"
+.TH FASTACMD 1 2003-11-10 NCBI "NCBI Tools User's Manual"
.SH NAME
fastacmd \- retrieve FASTA sequences from a BLAST database
.SH SYNOPSIS
@@ -96,6 +96,21 @@ commas
.TP
\fB\-t\fP
Definition line should contain target GI only
+.SH EXIT STATUS
+.RS
+.PD 0
+.IP 0
+Completed successfully.
+.IP 1
+An error (other than those below) occurred.
+.IP 2
+The BLAST database was not found.
+.IP 3
+A search (accession, GI, or taxonomy info) failed.
+.IP 4
+No taxonomy database was found.
+.PD
+.RE
.SH AUTHOR
The National Center for Biotechnology Information.
.SH SEE ALSO
diff --git a/doc/man/tbl2asn.1 b/doc/man/tbl2asn.1
index 3798b8e0..f60ec5d5 100644
--- a/doc/man/tbl2asn.1
+++ b/doc/man/tbl2asn.1
@@ -1,4 +1,4 @@
-.TH TBL2ASN 1 2003-04-27 NCBI "NCBI Tools User's Manual"
+.TH TBL2ASN 1 2003-11-10 NCBI "NCBI Tools User's Manual"
.SH NAME
tbl2asn \- prepare a GenBank submission using an ASCII feature table
.SH SYNOPSIS
@@ -9,10 +9,13 @@ tbl2asn \- prepare a GenBank submission using an ASCII feature table
[\|\fB\-c\fP\|]
[\|\fB\-d\fP\|]
[\|\fB\-g\fP\|]
-[\|\fB\-f\fP\ \fIfilename\fP\|]
+[\|\fB\-i\fP\ \fIfilename\fP\|]
+[\|\fB\-j\fP\ \fIstr\fP\|]
[\|\fB\-k\fP\|]
+[\|\fB\-l\fP\|]
[\|\fB\-m\fP\|]
[\|\fB\-n\fP\ \fIstr\fP\|]
+[\|\fB\-o\fP\ \fIfilename\fP\|]
[\|\fB\-p\fP\ \fIstr\fP\|]
[\|\fB\-q\fP\|]
[\|\fB\-r\fP\ \fIstr\fP\|]
@@ -20,6 +23,7 @@ tbl2asn \- prepare a GenBank submission using an ASCII feature table
[\|\fB\-t\fP\ \fIfilename\fP\|]
[\|\fB\-v\fP\|]
[\|\fB\-x\fP\ \fIstr\fP\|]
+[\|\fB\-y\fP\ \fIstr\fP\|]
.SH DESCRIPTION
\fBtbl2asn\fP reads a template along with sequence and table files,
and outputs ASN.1 for submission to GenBank. Thus, the submitter does
@@ -45,21 +49,30 @@ Annotate longest ORF
\fB\-d\fP
Read FASTAs as Delta
.TP
-\fB\-f\fP\ \fIfilename\fP
-Read only this file
-.TP
\fB\-g\fP
Input is a genomic product set
.TP
+\fB\-i\fP\ \fIfilename\fP
+Single input file
+.TP
+\fB\-j\fP\ \fIstr\fP
+Source qualifiers
+.TP
\fB\-k\fP
Set conflict on mismatch
.TP
+\fB\-l\fP
+Read FASTA+Gap Alignment
+.TP
\fB\-m\fP
Allow alternative starts
.TP
\fB\-n\fP\ \fIstr\fP
Organism name
.TP
+\fB\-o\fP\ \fIfilename\fP
+Single output file
+.TP
\fB\-p\fP\ \fIstr\fP
Path to files
.TP
@@ -80,6 +93,9 @@ Validate
.TP
\fB\-x\fP\ \fIstr\fP
Suffix (default = \fB.fsa\fP)
+.TP
+\fB\-y\fP\ \fIstr\fP
+Comment
.SH AUTHOR
The National Center for Biotechnology Information.
.SH SEE ALSO
diff --git a/doc/sequin.htm b/doc/sequin.htm
index cbd52165..41267466 100644
--- a/doc/sequin.htm
+++ b/doc/sequin.htm
@@ -48,7 +48,7 @@ A Quick Guide</b>
<hr>
-<! use img src="http://www.ncbi.nlm.nih.gov/Sequin/QuickGuide/image##.gif" align=bottom>
+<! use img src="http://www.ncbi.nlm.nih.gov/Sequin/QuickGuide/image##.png" align=bottom>
<p align="left">
<font size=4>
@@ -312,7 +312,7 @@ save Sequin information templates for each sequence.
<br>
<p align="center">
-<img src="images/seqn01.gif" align=bottom alt="Welcome to Sequin form has
+<img src="images/seqn01.png" align=bottom alt="Welcome to Sequin form has
push buttons to Start New Submission, Read Existing Record, Show Help, and
Quit Program.">
<br>
@@ -348,7 +348,7 @@ to release the record immediately into the public databases.
<br>
<p align="center">
-<img src="images/seqn02.gif" align=bottom alt="Submission page defaults
+<img src="images/seqn02.png" align=bottom alt="Submission page defaults
allow immediate release of the record.">
<br>
@@ -364,7 +364,7 @@ it is not necessary to type periods after initials or suffixes.
<br>
<p align="center">
-<img src="images/seqn03.gif" align=bottom alt="Contact page has fields for
+<img src="images/seqn03.png" align=bottom alt="Contact page has fields for
contact person's Name, Phone, Fax, and Email.">
<br>
@@ -382,7 +382,7 @@ or Sr.), not academic degrees.
<br>
<p align="center">
-<img src="images/seqn04.gif" align=bottom alt="Authors page has a spreadsheet
+<img src="images/seqn04.png" align=bottom alt="Authors page has a spreadsheet
for entering an arbitrary number of authors.">
<br>
@@ -392,7 +392,7 @@ primary author.
<br>
<p align="center">
-<img src="images/seqn05.gif" align=bottom alt="Affiliation page has fields
+<img src="images/seqn05.png" align=bottom alt="Affiliation page has fields
for institutional mailing address.">
<br>
@@ -429,7 +429,7 @@ unrelated sequences, where no alignment is present or should be calculated.
<br>
<p align="center">
-<img src="images/seqn06.gif" align=bottom alt="Sequence Format form has controls
+<img src="images/seqn06.png" align=bottom alt="Sequence Format form has controls
for choosing the submission type and sequence data format.">
<br>
@@ -472,7 +472,7 @@ GenBank.)
<br>
<p align="center">
-<img src="images/seqn07.gif" align=bottom alt="Organism page has fields for
+<img src="images/seqn07.png" align=bottom alt="Organism page has fields for
Scientific Name, Location of Sequence, and Genetic Code for Translation">
<br>
@@ -522,7 +522,7 @@ The format for annotating the nucleotide FASTA definition line is shown below:
<br>
<p align="center">
-<img src="images/seqn08.gif" align=bottom alt="Nucleotide page has controls
+<img src="images/seqn08.png" align=bottom alt="Nucleotide page has controls
for Molecule, Topology, and Incomplete at 5 prime or 3 prime end.">
<br>
@@ -555,7 +555,7 @@ The format for annotating the protein FASTA definition line is shown below:
<br>
<p align="center">
-<img src="images/seqn09.gif" align=bottom alt="Proteins page has controls
+<img src="images/seqn09.png" align=bottom alt="Proteins page has controls
for Incomplete at amino or carboxy end.">
<br>
@@ -578,7 +578,7 @@ sequence after the record is constructed.
<br>
<p align="center">
-<img src="images/seqn10.gif" align=bottom alt="Annotation page has controls
+<img src="images/seqn10.png" align=bottom alt="Annotation page has controls
for adding Gene, rRNA, or CDS features to all sequences.">
<br>
@@ -621,7 +621,7 @@ the missing information manually.
<br>
<p align="center">
-<img src="images/seqn11.gif" align=bottom alt="Product form has fields for
+<img src="images/seqn11.png" align=bottom alt="Product form has fields for
Sequence ID, Title, Gene Symbol, Protein Name, and Comment.">
<br>
@@ -656,7 +656,7 @@ form.
<br>
<p align="center">
-<img src="images/seqn12.gif" align=bottom alt="Source Modifiers form has a
+<img src="images/seqn12.png" align=bottom alt="Source Modifiers form has a
spreadsheet for entering modifiers to each individual sequence.">
<br>
@@ -679,7 +679,7 @@ EMBL as the database for submission in the first form).
<br>
<p align="center">
-<img src="images/seqn13.gif" align=bottom alt="View form has controls for
+<img src="images/seqn13.png" align=bottom alt="View form has controls for
Target Sequence and Display format. Default format is GenBank flatfile.">
<br>
@@ -717,7 +717,7 @@ products are spatially related to each other.
<br>
<p align="center">
-<img src="images/seqn14.gif" align=bottom alt="Graphical view has additional
+<img src="images/seqn14.png" align=bottom alt="Graphical view has additional
controls for Style and Scale, and displays a drawing of feature locations on
the sequence coordinate.">
<br>
@@ -743,7 +743,7 @@ protein translations are shown as a series of tilde&nbsp;(~)&nbsp;characters.
<br>
<p align="center">
-<img src="images/seqn15.gif" align=bottom alt="Sequence format displays
+<img src="images/seqn15.png" align=bottom alt="Sequence format displays
feature locations on the actual sequence letters.">
<br>
@@ -822,7 +822,7 @@ large contig.
<br>
<p align="center">
-<img src="images/seqn16.gif" align=bottom alt="Update Sequence form
+<img src="images/seqn16.png" align=bottom alt="Update Sequence form
displays information on how the old and new sequences align.">
<br>
@@ -896,7 +896,7 @@ genetic codes, mismatched amino acids, and non-consensus splice sites.
<br>
<p align="center">
-<img src="images/seqn17.gif" align=bottom alt="Validator form has controls for
+<img src="images/seqn17.png" align=bottom alt="Validator form has controls for
Message verbosity, Severity, message Filter, and a display of error messages.">
<br>
@@ -960,7 +960,7 @@ tRNA, or completion of a stop codon by poly-adenylation of an mRNA.
<br>
<p align="center">
-<img src="images/seqn18.gif" align=bottom alt="Coding Region page has small
+<img src="images/seqn18.png" align=bottom alt="Coding Region page has small
folder tabs for Product, Protein, Exceptions, and Misc. Product subpage has
controls for Genetic Code, Predict Interval, and Translate Product.">
<br>
@@ -1011,7 +1011,7 @@ database staff.
<br>
<p align="center">
-<img src="images/seqn19.gif" align=bottom alt="Properties page has small
+<img src="images/seqn19.png" align=bottom alt="Properties page has small
folder tabs for General, Comment, Citations, and Cross-Refs. General page
has controls for Partial, Pseudo, Evidence, Exception, and Explanation.">
<br>
@@ -1031,7 +1031,7 @@ locations.
<br>
<p align="center">
-<img src="images/seqn20.gif" align=bottom alt="Location page has controls for
+<img src="images/seqn20.png" align=bottom alt="Location page has controls for
5 prime Partial and 3 partial Partial, and a spreadsheet for entering an arbitrary
number of intervals.">
<br>
@@ -1085,7 +1085,7 @@ both the nucleotide and protein sequences.
<br>
<p align="center">
-<img src="images/seqn21.gif" align=bottom alt="NCBI DeskTop window displays a
+<img src="images/seqn21.png" align=bottom alt="NCBI DeskTop window displays a
Venn Diagram of the internal structure of a record in the NCBI Data Model.">
<br>
@@ -1136,7 +1136,7 @@ sequence record.
<br>
<p align="center">
-<img src="images/seqn22.gif" align=bottom alt="Network Configuration form has
+<img src="images/seqn22.png" align=bottom alt="Network Configuration form has
buttons for Normal, Firewall, or No Connection.">
<br>
@@ -1477,7 +1477,7 @@ genomic records are available at
<CENTER>
<P CLASS=medium1><B>Questions or Comments?</B>
<BR>Write to the <A HREF="mailto:info@ncbi.nlm.nih.gov">NCBI Service Desk</A></P>
-<P CLASS=medium1>Revised April 14, 2003
+<P CLASS=medium1>Revised January 20, 2004
</CENTER>
diff --git a/errmsg/valid.msg b/errmsg/valid.msg
index a7923795..bc138e16 100644
--- a/errmsg/valid.msg
+++ b/errmsg/valid.msg
@@ -159,6 +159,13 @@ $^ SeqLitGapLength0, 43
A SeqLit component of a delta Bioseq can specify a gap, but it should not be a gap
of 0 length.
+$^ TpaAssmeblyProblem, 44
+Third party annotation records should have a TpaAssembly user object and a
+Seq-hist.assembly alignment for the PRIMARY block.
+
+$^ SeqLocLength, 45
+A SeqLoc component of a delta Bioseq is suspiciously small.
+
$$ SEQ_DESCR, 2
$^ BioSourceMissing, 1
@@ -334,6 +341,9 @@ A feature location should refer to the accession or gi number, not a local or ge
$^ ArchaicFeatureProduct, 14
A feature product should refer to the accession or gi number, not a local or general ID.
+$^ GraphPackagingProblem, 15
+A graph should be packaged on its bioseq, or on a set containing the Bioseq.
+
$$ SEQ_FEAT, 5
$^ InvalidForType, 1
@@ -608,6 +618,17 @@ the inheritance by overlap.
$^ UTRdoesNotAbutCDS, 66
The 5'UTR and 3'UTR features should exactly abut the CDS feature.
+$^ BadConflictFlag, 67
+The coding region conflict flag is set, but the translated product is the
+same as the instantiated product Bioseq.
+
+$^ ConflictFlagSet, 68
+The coding region conflict flag is appropriately set, but this record should
+be brought to the attention of the source database for possible correction.
+
+$^ LocusTagProblem, 69
+A gene locus_tag should be a single token, with no spaces.
+
$$ SEQ_ALIGN, 6
$^ SeqIdProblem, 1
diff --git a/link/macmet/ApplicationStationery.mcp b/link/macmet/ApplicationStationery.mcp
index 7e7b3ee3..aa77f0f5 100644
--- a/link/macmet/ApplicationStationery.mcp
+++ b/link/macmet/ApplicationStationery.mcp
Binary files differ
diff --git a/link/macmet/LibraryStationery.mcp b/link/macmet/LibraryStationery.mcp
index af6ead50..70f03339 100644
--- a/link/macmet/LibraryStationery.mcp
+++ b/link/macmet/LibraryStationery.mcp
Binary files differ
diff --git a/make/makeApps.met b/make/makeApps.met
index 469f8202..80784322 100755
--- a/make/makeApps.met
+++ b/make/makeApps.met
@@ -20,9 +20,8 @@ property pCreateMachOTargets : true
property pCreateCarbonTargets : false
property pCreateWinTargets : false
-property pCreateDebugTargets : true
property pCreateOptimizedTargets : true
-
+property pCreateDebugTargets : false
property pCreateProfiledTargets : false
-- Whether to have the projects use CVS or not.
@@ -35,7 +34,8 @@ property pShouldBuild : true
property pStationeryName : "ApplicationStationery"
-property pTargetKeyWords : "Mach-O Carbon Win32 Debug Final"
+-- the handler GetTargetSpecs should change if these do.
+property pTargetKeyWords : "Mach-O Carbon Win32 Debug Final Profile"
global gProjectData
@@ -46,19 +46,16 @@ on SimpleProjectData(projName, features)
set projName to characters 1 through 25 of projName as string
end if
- tell application "CodeWarrior IDE"
-
- if features does not contain "C" and features does not contain "C++" then
- --error "Project " & projName & "'s default language (a feature) must be C or C++."
- copy "C" to end of features
- end if
- set myFeatures to features
- return {name:projName, features:myFeatures, rsrcs:{"ncbilogo.r", "Info.plc"}, settings:Â
- {Prefix File:"", ppcProject:{}}, projLibs:Â
- {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbimmdb", "ncbitool"}, fileData:Â
- {{projPath:"demo:", fileList:{projName & ".c"}}}}
-
- end tell
+ if features does not contain "C" and features does not contain "C++" then
+ --error "Project " & projName & "'s default language (a feature) must be C or C++."
+ copy "C" to end of features
+ end if
+ set myFeatures to features
+ return {name:projName, features:myFeatures, rsrcs:{"ncbilogo.r", "Info.plc"}, settings:Â
+ {prefixFile:"", ppcProject:{}}, projLibs:Â
+ {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbimmdb", "ncbitool"}, fileData:Â
+ {{projPath:"demo:", fileList:{projName & ".c"}}}}
+
end SimpleProjectData
on AddProject(projData)
@@ -76,12 +73,12 @@ on SetProjectData()
set myName to "Sequin"
set myFeatures to {"sockets"}
set mySettings to Â
- {Prefix File:"", creator:"SEQN", ppcProject:{Preferred Heap Size:32000, Min Heap Size:6000}} Â
+ {prefixFile:"", creator:"SEQN", ppcProject:{Preferred Heap Size:32000, Min Heap Size:6000}} Â
set myRsrcs to {"sequin.r", "InfoSequin.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbicdr", "vibrant", "ncbidesk", Â
"ncbimmdb", "ncbitool", "netcli", "netentr", "ncbibls3", "ncbimla", Â
- "ncbitxc2", "ncbiid1", "vibnet"}
+ "ncbitxc2", "ncbiid1", "ncbispell", "vibnet"}
set myFiles to Â
{{projPath:"cdromlib:", fileList:{"accentr.c", "accutils.c"}}, Â
{projPath:"sequin:", fileList:{"sequin1.c", "sequin2.c", "sequin3.c", "sequin4.c", "sequin5.c", Â
@@ -93,7 +90,7 @@ on SetProjectData()
-- Entrez
set myName to "Entrez"
set myFeatures to {"sockets"}
- set mySettings to {Prefix File:"", creator:"ENTZ", ppcProject:{}}
+ set mySettings to {prefixFile:"", creator:"ENTZ", ppcProject:{}}
set myRsrcs to {"entrez.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbicdr", "vibrant", "ncbidesk", "ncbimmdb", Â
"ncbitool", "netcli", "netentr", "ncbibls3", "ncbiid1", "vibnet"}
@@ -107,7 +104,7 @@ on SetProjectData()
-- Entrez2
set myName to "Entrez2"
set myFeatures to {"sockets"}
- set mySettings to {Prefix File:"", creator:"ENTZ", ppcProject:{}}
+ set mySettings to {prefixFile:"", creator:"ENTZ", ppcProject:{}}
set myRsrcs to {"entrez.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "ncbimmdb", "ncbitool", "vibrant", "ncbidesk"}
set myFiles to Â
@@ -119,7 +116,7 @@ on SetProjectData()
-- BlastCL3
set myName to "blastcl3"
set myFeatures to {"sockets"}
- set mySettings to {Prefix File:"blastcl3.pfx", ppcProject:{}}
+ set mySettings to {prefixFile:"blastcl3.pfx", ppcProject:{}}
set myRsrcs to {"ncbilogo.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbibls3"}
set myFiles to Â
@@ -131,7 +128,7 @@ on SetProjectData()
-- Bl2seq
set myName to "bl2seq"
set myFeatures to {"sockets"}
- set mySettings to {Prefix File:"", ppcProject:{}}
+ set mySettings to {prefixFile:"", ppcProject:{}}
set myRsrcs to {"ncbilogo.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbibls3", "ncbiid1"}
set myFiles to Â
@@ -147,7 +144,7 @@ on SetProjectData()
-- Spidey
set myName to "spidey"
set myFeatures to {"sockets"}
- set mySettings to {Prefix File:"", ppcProject:{}}
+ set mySettings to {prefixFile:"", ppcProject:{}}
set myRsrcs to {"ncbilogo.r", "Info.plc"}
set myLibs to {"ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbiid1"}
set myFiles to Â
@@ -272,14 +269,11 @@ end stripVolName
on HomeDir()
tell application "Finder"
-
if my IsOSX() then
return the home as string
- -- return my stripVolName(home as string)
else
return gStartupDisk
end if
-
end tell
end HomeDir
@@ -294,15 +288,6 @@ on ModuleRoot()
return modRoot
end ModuleRoot
-on AccessRoot()
- if my IsOSX() then
- -- strip off the volume name at the front.
- return my stripVolName(gDistribRoot)
- else
- return gDistribRoot
- end if
-end AccessRoot
-
on GetMyPath()
set myPath to path to me as string
if myPath contains "Script Editor" or Â
@@ -313,7 +298,7 @@ on GetMyPath()
return gDistribRoot & "make:"
else
tell application "Finder"
- return container of myPath
+ return container of myPath as string
end tell
end if
end GetMyPath
@@ -325,9 +310,7 @@ on SetGlobals()
set gStartupDisk to startup disk as string
set gHomeDir to my HomeDir()
-
set gDistribRoot to my ModuleRoot()
- set gAccessRoot to my AccessRoot()
set gIncludeDir to gDistribRoot & "include:"
set gSourceDir to gDistribRoot
@@ -388,20 +371,35 @@ on UpdateRenameHeader(canonicalName, canonicalDir, dotHName, dotHDir)
end tell
end UpdateRenameHeader
-on SetUserPaths()
+
+on AppendAccessPath(aPath, isRecursive, isUserPath)
tell application "CodeWarrior IDE"
+ if (aPath does not end with ":") then set aPath to aPath & ":"
- set pathsToAdd to {}
- -- Put the ncbi root, recursively at the end of the user paths.
- copy {name:gAccessRoot, recursive:true, origin:absolute} to end of pathsToAdd
- Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd}
-
+ set aPath to POSIX path of aPath
+ set pathsToAdd to {{name:aPath, recursive:isRecursive, origin:root relative, root:"OS X Volume", format:Unix Path}}
+ if isUserPath then
+ Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd}
+ else
+ Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
+ end if
end tell
-end SetUserPaths
+end AppendAccessPath
-on SetSysPaths()
- -- This was all done in the Stationery project.
-end SetSysPaths
+
+on AppendPrefixFile(filename)
+ tell application "CodeWarrior IDE"
+ try -- CW ver. 8
+ Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile}
+ end try
+ try -- CW ver. 9
+ set oldtext to Get Preferences of {Prefix Text} from panel "C/C++ Preprocessor"
+ set oldtext to (Prefix Text of oldtext)
+ set prefixFileInclude to (oldtext & return & "#include \"" & filename & "\"")
+ Set Preferences of panel "C/C++ Preprocessor" to {Prefix Text:prefixFileInclude}
+ end try
+ end tell
+end AppendPrefixFile
on SetupTarget(proj, targetIndex)
@@ -419,11 +417,10 @@ on SetupTarget(proj, targetIndex)
if targetName contains "Debug" then
set targetDebug to true
- if pCreateProfiledTargets then
- set targetProfile to true
- else
- set targetProfile to false
- end if
+ set targetProfile to false
+ else if targetName contains "Profile" then
+ set targetDebug to false
+ set targetProfile to true
else -- if targeName contains "Final" then
set targetDebug to false
set targetProfile to false
@@ -465,14 +462,16 @@ on SetupTarget(proj, targetIndex)
end if
-- Debug or not.
- if not targetDebug then
- set fileNameSuffix to fileNameSuffix & "_O" -- for Optimized.
- else
+ if targetDebug then
set fileNameSuffix to fileNameSuffix & "_D"
+ else if targetProfile then
+ set fileNameSuffix to fileNameSuffix & "_P"
+ else
+ set fileNameSuffix to fileNameSuffix & "_O" -- for Optimized.
end if
-- non debug targets get different output names.
- if not targetDebug then
+ if not targetDebug and not targetProfile then
if targetAPI is "Mach-O" then
set targetFilename to projName & "OSX" -- Mach adds OSX on the end.
else
@@ -518,8 +517,12 @@ on SetupTarget(proj, targetIndex)
end try
end if
- my SetUserPaths()
- -- my SetSysPaths() -- done in the stationery project.
+
+ if targetAPI is "Mach-O" then
+ my AppendAccessPath(gDistribRoot, true, false) -- end of system paths.
+ else
+ my AppendAccessPath(gDistribRoot, true, true) -- end of user paths.
+ end if
-- Add per-project system paths.
set pathsToAdd to {}
@@ -530,7 +533,7 @@ on SetupTarget(proj, targetIndex)
Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
-- Set the appropriate prefix file.
- set prefixFile to Prefix File of projSettings
+ set prefixFile to prefixFile of projSettings
if targetAPI is "Win32" and projFeatures contains "winprefix" then
set prefixFile to "Win32Headers.pch"
else
@@ -541,13 +544,7 @@ on SetupTarget(proj, targetIndex)
end if
end if
if prefixFile is not "" then
- try -- CW ver. 8
- Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile}
- end try
- try -- CW ver. 9
- set prefixFileInclude to "#include \"" & prefixFile & "\""
- Set Preferences of panel "C/C++ Preprocessor" to {Prefix Text:prefixFileInclude}
- end try
+ my AppendPrefixFile(prefixFile)
end if
end tell
@@ -579,7 +576,7 @@ on SetupTarget(proj, targetIndex)
tell application "CodeWarrior IDE"
-- take care of debugging and profiling settings
- if targetDebug then
+ if targetDebug or targetProfile then
set the debug of every target file of target targetIndex Â
of project document 1 to true
end if
@@ -605,7 +602,9 @@ on SetupTarget(proj, targetIndex)
end if
end if
repeat with i in projLibs
- copy gLibsDir & i & fileNameSuffix & ".lib" to end of filesToAdd
+ if exists file (gLibsDir & i & fileNameSuffix & ".lib") of application "Finder" then
+ copy gLibsDir & i & fileNameSuffix & ".lib" to end of filesToAdd
+ end if
end repeat
try
@@ -687,11 +686,6 @@ on UpdateTarget(proj, targetIndex)
-- Grab the fields of our project record and store them in local variables.
set projName to proj's name
- -- mitsock library isn't needed (and won't compile) except under Carbon.
- if projName is "mitsock" and targetAPI is not "Carbon" then
- return
- end if
-
set targetName to name of target targetIndex of project document 1
set the current target of project document 1 to target targetIndex of project document 1
@@ -854,19 +848,23 @@ on GetTargetSpecs()
end if
end repeat
-- no Build files? match what the script parameters say to match.
- -- NOTE: This is dependent on pTargetKeyWords
+ -- NOTE: This is dependent on pTargetKeyWords and the target names in the stationery.
if (count items of targetSpecs) is 0 then
- if pCreateDebugTargets or pCreateOptimizedTargets then
- if pCreateDebugTargets and pCreateOptimizedTargets then
- set debugspec to ""
- else if pCreateDebugTargets then
- set debugspec to "Debug"
- else if pCreateOptimizedTargets then
- set debugspec to "Final"
- end if
- if pCreateMachOTargets then copy ("Mach-O" & " " & debugspec) to end of targetSpecs
- if pCreateCarbonTargets then copy ("Carbon" & " " & debugspec) to end of targetSpecs
- if pCreateWinTargets then copy ("Win32" & " " & debugspec) to end of targetSpecs
+ set debugspec to ""
+ if pCreateDebugTargets then
+ if pCreateMachOTargets then copy ("Mach-O Debug") to end of targetSpecs
+ if pCreateCarbonTargets then copy ("Carbon Debug") to end of targetSpecs
+ if pCreateWinTargets then copy ("Win32 Debug") to end of targetSpecs
+ end if
+ if pCreateProfiledTargets then
+ if pCreateMachOTargets then copy ("Mach-O Profile") to end of targetSpecs
+ if pCreateCarbonTargets then copy ("Carbon Profile") to end of targetSpecs
+ if pCreateWinTargets then copy ("Win32 Profile") to end of targetSpecs
+ end if
+ if pCreateOptimizedTargets then
+ if pCreateMachOTargets then copy ("Mach-O Final") to end of targetSpecs
+ if pCreateCarbonTargets then copy ("Carbon Final") to end of targetSpecs
+ if pCreateWinTargets then copy ("Win32 Final") to end of targetSpecs
end if
end if
return targetSpecs
@@ -904,7 +902,6 @@ on BuildProject(projName, targetSpecs)
if the name of window 1 is "Project Messages" then
close first window -- "close window 1" becomes "Close Window 1" (different event)
end if
-
repeat with i from 1 to (count targets of project document 1)
-- do we want to build this target?
set thisTarget to name of target i of project document 1
diff --git a/make/makeLibs.met b/make/makeLibs.met
index 8cef04df..6debd3ad 100755
--- a/make/makeLibs.met
+++ b/make/makeLibs.met
@@ -14,15 +14,15 @@ property pSaveContinueOnErrors : false
-- Whether to recreate existing project files.
property pAlwaysCreateProjects : false
+
-- Which targets to build.
-- All of the targets are populated all the time. These affect what is compiled & built.
property pCreateMachOTargets : true
property pCreateCarbonTargets : false
property pCreateWinTargets : false
-property pCreateDebugTargets : true
property pCreateOptimizedTargets : true
-
+property pCreateDebugTargets : false
property pCreateProfiledTargets : false
-- Whether to have the projects use CVS or not.
@@ -34,13 +34,12 @@ property pShouldBuild : true
property pStationeryName : "LibraryStationery"
-- the handler GetTargetSpecs should change if these do.
-property pTargetKeyWords : "Mach-O Carbon Win32 Debug Final"
+property pTargetKeyWords : "Mach-O Carbon Win32 Debug Final Profile"
global gStartupDisk
global gHomeDir
global gDistribRoot
-global gAccessRoot
global gProjectsDir
global gSourceDir
global gIncludeDir
@@ -55,18 +54,15 @@ on ProjectData(projName, features, aFileData)
set projName to characters 1 through 25 of projName as string
end if
- tell application "CodeWarrior IDE"
-
- if features does not contain "C" and features does not contain "C++" then
- copy "C" to end of features
- end if
- set myFeatures to features
-
- return {name:projName, features:myFeatures, rsrcs:{}, settings:Â
- {Prefix File:"", ppcProject:{}}, projLibs:{}, sysPaths:{}, fileData:Â
- aFileData}
-
- end tell
+ if features does not contain "C" and features does not contain "C++" then
+ copy "C" to end of features
+ end if
+ set myFeatures to features
+
+ return {name:projName, features:myFeatures, rsrcs:{}, settings:Â
+ {prefixFile:"", ppcProject:{}}, projLibs:{}, sysPaths:{}, fileData:Â
+ aFileData}
+
end ProjectData
on AddProject(projData)
@@ -115,7 +111,7 @@ end mkFileDataExceptFiles
on DataPlusPrefixFile(dataRec, prefix)
tell application "CodeWarrior IDE"
- set the Prefix File of dataRec's settings to prefix
+ set the prefixFile of dataRec's settings to prefix
return dataRec
end tell
@@ -140,8 +136,8 @@ end EndsWith
on SetProjectData()
- -- Not Okay under Mach-O
- --AddSimpleProject("mitsock", {}, "connect:mitsock")
+ -- Only needed for Carbon
+ AddSimpleProject("mitsock", {}, "connect:mitsock")
AddProject(ProjectData("ncbi", {"winprefix"}, {Â
mkFileDataExceptFiles("corelib:", {"drwnflpt.c", "drwnfspc.c", "drwnmfls.c", "ncbiargs.c", "ncbimain.c"}), Â
@@ -156,6 +152,8 @@ on SetProjectData()
mkFileData("api:"), Â
mkFileDataExceptFiles("ddv:", {"ddvmain.c"})}))
+ AddSimpleProject("vibrant", {"winprefix"}, "vibrant")
+
AddSimpleProjectExceptFiles("ncbicdr", {}, "cdromlib", {"acccn3ds.c", "accentr.c", "accmmdbs.c", "accutils.c"})
AddSimpleProjectExceptFiles("ncbidesk", {}, "desktop", {"sdisplay.c"})
@@ -199,8 +197,6 @@ on SetProjectData()
mkFileDataExceptFiles("network:taxon1:taxon2:", {"txcproc.c"}), Â
mkFileDataExceptFiles("network:taxon1:common:", {"checkid.c"})}), "tax2.pfx"))
- AddSimpleProject("vibrant", {"winprefix"}, "vibrant")
-
AddSimpleProjectListFiles("ncbiconn", {"winprefix"}, "connect", Â
{"ncbi_buffer", "ncbi_socket", "ncbi_core", "ncbi_core_c", "ncbi_util", "ncbi_priv", Â
"ncbi_ansi_ext", "ncbi_connection", "ncbi_connector", "ncbi_connutil", Â
@@ -211,6 +207,12 @@ on SetProjectData()
AddSimpleProjectExceptFiles("netcli", {}, "network:nsclilib", {"ni_encr.c", "ni_list.c", "ni_lib.c"})
+ AddSimpleProject("ncbispell", {}, "network:spell:client")
+
+ AddSimpleProject("ncbiblast", {}, "algo:blast:core")
+
+ AddSimpleProject("ncbiblastapi", {}, "algo:blast:api")
+
end SetProjectData
--
@@ -267,15 +269,6 @@ on ModuleRoot()
return modRoot
end ModuleRoot
-on AccessRoot()
- if my IsOSX() then
- -- strip off the volume name at the front.
- return my stripVolName(gDistribRoot)
- else
- return gDistribRoot
- end if
-end AccessRoot
-
on GetMyPath()
set myPath to path to me as string
if myPath contains "Script Editor" or Â
@@ -299,7 +292,6 @@ on SetGlobals()
set gStartupDisk to startup disk as string
set gHomeDir to my HomeDir()
set gDistribRoot to my ModuleRoot()
- set gAccessRoot to my AccessRoot()
set gIncludeDir to gDistribRoot & "include:"
set gSourceDir to gDistribRoot
@@ -369,20 +361,35 @@ on CopyHeaders()
end tell
end CopyHeaders
-on SetUserPaths()
+
+on AppendAccessPath(aPath, isRecursive, isUserPath)
tell application "CodeWarrior IDE"
+ if (aPath does not end with ":") then set aPath to aPath & ":"
- set pathsToAdd to {}
- -- Put the ncbi root, recursively at the end of the user paths.
- copy {name:gAccessRoot, recursive:true, origin:absolute} to end of pathsToAdd
- Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd}
-
+ set aPath to POSIX path of aPath
+ set pathsToAdd to {{name:aPath, recursive:isRecursive, origin:root relative, root:"OS X Volume", format:Unix Path}}
+ if isUserPath then
+ Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd}
+ else
+ Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
+ end if
end tell
-end SetUserPaths
+end AppendAccessPath
-on SetSysPaths()
- -- This was all done in the Stationery project.
-end SetSysPaths
+
+on AppendPrefixFile(filename)
+ tell application "CodeWarrior IDE"
+ try -- CW ver. 8
+ Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile}
+ end try
+ try -- CW ver. 9
+ set oldtext to Get Preferences of {Prefix Text} from panel "C/C++ Preprocessor"
+ set oldtext to (Prefix Text of oldtext)
+ set prefixFileInclude to (oldtext & return & "#include \"" & filename & "\"")
+ Set Preferences of panel "C/C++ Preprocessor" to {Prefix Text:prefixFileInclude}
+ end try
+ end tell
+end AppendPrefixFile
on SetupTarget(proj, targetIndex)
@@ -400,11 +407,10 @@ on SetupTarget(proj, targetIndex)
if targetName contains "Debug" then
set targetDebug to true
- if pCreateProfiledTargets then
- set targetProfile to true
- else
- set targetProfile to false
- end if
+ set targetProfile to false
+ else if targetName contains "Profile" then
+ set targetDebug to false
+ set targetProfile to true
else -- if targeName contains "Final" then
set targetDebug to false
set targetProfile to false
@@ -451,10 +457,12 @@ on SetupTarget(proj, targetIndex)
end if
-- Debug or not.
- if not targetDebug then
- set targetFilename to targetFilename & "_O" -- for Optimized.
- else
+ if targetDebug then
set targetFilename to targetFilename & "_D"
+ else if targetProfile then
+ set targetFilename to targetFilename & "_P"
+ else
+ set targetFilename to targetFilename & "_O" -- for Optimized.
end if
set targetFilename to targetFilename & ".lib"
@@ -479,8 +487,12 @@ on SetupTarget(proj, targetIndex)
Set Preferences of panel targetPanelName to ppcProject of projSettings
end if
- my SetUserPaths()
- -- my SetSysPaths() -- done in the stationery project.
+
+ if targetAPI is "Mach-O" then
+ my AppendAccessPath(gDistribRoot, true, false) -- end of system paths.
+ else
+ my AppendAccessPath(gDistribRoot, true, true) -- end of user paths.
+ end if
-- Add per-project system paths.
set pathsToAdd to {}
@@ -491,7 +503,7 @@ on SetupTarget(proj, targetIndex)
Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd}
-- Set the appropriate prefix file.
- set prefixFile to Prefix File of projSettings
+ set prefixFile to prefixFile of projSettings
if targetAPI is "Win32" and projFeatures contains "winprefix" then
set prefixFile to "Win32Headers.pch"
else
@@ -502,13 +514,7 @@ on SetupTarget(proj, targetIndex)
end if
end if
if prefixFile is not "" then
- try -- CW ver. 8
- Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile}
- end try
- try -- CW ver. 9
- set prefixFileInclude to "#include \"" & prefixFile & "\""
- Set Preferences of panel "C/C++ Preprocessor" to {Prefix Text:prefixFileInclude}
- end try
+ my AppendPrefixFile(prefixFile)
end if
end tell
@@ -540,7 +546,7 @@ on SetupTarget(proj, targetIndex)
tell application "CodeWarrior IDE"
-- take care of debugging and profiling settings
- if targetDebug then
+ if targetDebug or targetProfile then
set the debug of every target file of target targetIndex Â
of project document 1 to true
end if
@@ -572,6 +578,7 @@ on SetupTarget(proj, targetIndex)
end tell
end SetupTarget
+
on GetTargetFiles(i)
tell application "CodeWarrior IDE"
-- get the target
@@ -789,19 +796,23 @@ on GetTargetSpecs()
end if
end repeat
-- no Build files? match what the script parameters say to match.
- -- NOTE: This is dependent on pTargetKeyWords
+ -- NOTE: This is dependent on pTargetKeyWords and the target names in the stationery.
if (count items of targetSpecs) is 0 then
- if pCreateDebugTargets or pCreateOptimizedTargets then
- if pCreateDebugTargets and pCreateOptimizedTargets then
- set debugspec to ""
- else if pCreateDebugTargets then
- set debugspec to "Debug"
- else if pCreateOptimizedTargets then
- set debugspec to "Final"
- end if
- if pCreateMachOTargets then copy ("Mach-O" & " " & debugspec) to end of targetSpecs
- if pCreateCarbonTargets then copy ("Carbon" & " " & debugspec) to end of targetSpecs
- if pCreateWinTargets then copy ("Win32" & " " & debugspec) to end of targetSpecs
+ set debugspec to ""
+ if pCreateDebugTargets then
+ if pCreateMachOTargets then copy ("Mach-O Debug") to end of targetSpecs
+ if pCreateCarbonTargets then copy ("Carbon Debug") to end of targetSpecs
+ if pCreateWinTargets then copy ("Win32 Debug") to end of targetSpecs
+ end if
+ if pCreateProfiledTargets then
+ if pCreateMachOTargets then copy ("Mach-O Profile") to end of targetSpecs
+ if pCreateCarbonTargets then copy ("Carbon Profile") to end of targetSpecs
+ if pCreateWinTargets then copy ("Win32 Profile") to end of targetSpecs
+ end if
+ if pCreateOptimizedTargets then
+ if pCreateMachOTargets then copy ("Mach-O Final") to end of targetSpecs
+ if pCreateCarbonTargets then copy ("Carbon Final") to end of targetSpecs
+ if pCreateWinTargets then copy ("Win32 Final") to end of targetSpecs
end if
end if
return targetSpecs
diff --git a/make/makeall.dos b/make/makeall.dos
index aa41aa90..b3fc1690 100644
--- a/make/makeall.dos
+++ b/make/makeall.dos
@@ -1,4 +1,4 @@
-# $Id: makeall.dos,v 6.158 2003/01/07 22:11:29 lavr Exp $
+# $Id: makeall.dos,v 6.159 2003/11/28 15:19:09 camacho Exp $
##################################################
### Makefile for non-network-based libraries + asntool
#####
@@ -106,7 +106,7 @@ OBJ23 = +csim.obj +db_slist.obj +dust.obj +falign.obj +g_any.obj \
+urkutil.obj +urkpcc.obj +urkptpf.obj \
+urkepi.obj +urkfltr.obj +urkdust.obj +urksigu.obj +seg.obj \
+urkbias.obj +urkcnsrt.obj +urktree.obj +pseed3.obj +pattern1.obj \
- +impatool.obj +posit2.obj +newkar.obj +mbalign.obj \
+ +impatool.obj +posit2.obj +mbalign.obj \
+vecscrn.obj +mblast.obj +rpsutil.obj +kappa.obj \
+xmlblast.obj +bxmlobj.obj +dotseq.obj +spidey.obj +motif.obj
diff --git a/make/makeall.met b/make/makeall.met
deleted file mode 100644
index 524441cb..00000000
--- a/make/makeall.met
+++ /dev/null
@@ -1 +0,0 @@
--- C libs -- -- -- Properties -- property pUsingCPlusPlus : false property pProjectFileExtension : ".mcp" -- Whether to recreate existing project files. property pAlwaysCreateProjects : false -- Which targets to create. -- If these are changed you must recreate the project files. There is no direct effect on building. property pCreateBlueTargets : true -- 'Blue' was codename for System 7, here it means pre-Carbon. property pCreateCarbonTargets : true property pCreateDebugTargets : true property pCreateProfiledTargets : false property pCreateOptimizedTargets : true -- Whether to compile everything. property pShouldBuild : true property pDirsToCreate : { {relPath:"", name:"include"},  {relPath:"", name:"lib"}} property pLinkExecutables : false -- -- Routines specific to this project -- on ProjectData(projName, features, fileData) if (count characters of projName) > 18 then set projName to characters 1 through 18 of projName as string end if tell application "CodeWarrior IDE" if features does not contain "C" and features does not contain "C++" then --error "Project " & projName & "'s default language (a feature) must be C or C++." copy "C" to end of features end if set myFeatures to features --copy "BNDL" to end of myFeatures return {name:projName, features:myFeatures, rsrcs:{}, settings: {Prefix File:"", ppcProject:{}}, projLibs:{}, sysPaths:{}, fileData: fileData} end tell end ProjectData on SimpleProjectData(projName, features, section, fileList) set myPath to section & ":" return ProjectData(projName, features, {{projPath:myPath, fileList:fileList}}) end SimpleProjectData on AddSimpleProject(projName, features, section, fileList) AddProject(SimpleProjectData(projName, features, section, fileList)) end AddSimpleProject on DataPlusPrefixFile(dataRec, prefix) tell application "CodeWarrior IDE" set the Prefix File of dataRec's settings to prefix return dataRec end tell end DataPlusPrefixFile on SetProjectData() AddSimpleProject("mitsock", {}, "connect:mitsock",  {"OTSocketInternal", "OTErrno", "OTSockets", "OTidle", "OTNetdbServices", "OTnetdb"}) AddProject(ProjectData("ncbi", {}, {  {projPath:"corelib:", fileList:{ "ncbibs", "ncbienv", "ncbierr", "ncbifile", "ncbimath", "ncbimem", "ncbimisc",  "ncbimsg", "ncbiprop", "ncbisgml", "ncbistr", "ncbitime", "ncbilang", "gifgen",  "togif", "ncbithr", "tsprintf", "tree", "wwwutils", "matrix", "binary", "regex"}},   {projPath:"corelib:morefile:", fileList:{ "FullPath", "FSpCompat", "MoreFilesX"}},   {projPath:"connect:", fileList:{ "ncbibuf", "ncbisock", "connection", "urlquery"}},   {projPath:"ctools:", fileList:{ "asn_connection"}},   {projPath:"asnlib:", fileList:{ "asnbufo", "asndebin", "asnenbin", "asngen", "asngenob", "asnio", "asnlex",  "asnlext", "asnout", "asnprint", "asntypes"}}})) AddSimpleProject("ncbiconn", {}, "connect",  {"ncbi_buffer", "ncbi_socket", "ncbi_core", "ncbi_core_c", "ncbi_util", "ncbi_priv",  "ncbi_ansi_ext", "ncbi_connection", "ncbi_connector", "ncbi_connutil",  "ncbi_file_connector", "ncbi_host_info.c", "ncbi_http_connector",  "ncbi_memory_connector", "ncbi_server_info", "ncbi_service",  "ncbi_service_connector", "ncbi_dispd", "ncbi_lbsmd_stub",  "ncbi_socket_connector", "ncbi_sendmail"}) AddProject(ProjectData("ncbiobj", {}, {  {projPath:"object:", fileList:{ "objacces", "objalign", "objall", "objbibli", "objblock", "objcode", "objfdef",  "objfeat", "objgen", "objloc", "objmdrs", "objmedli", "objproj",  "objprt", "objpub", "objpubme", "objres", "objseq", "objsset", "objalignloc",  "objsub", "objgbseq", "objtseq"}},   {projPath:"access:", fileList:{ "objent2", "ent2api", "pmfapi", "qblastapi", "vecscnapi", "objmim",  "mimapi"}},   {projPath:"api:", fileList:{ "asn2ff1", "asn2ff2", "asn2ff3", "asn2ff4", "asn2ff5", "asn2ff6", "asn2gnbk", "codon",  "edutil", "ffprint", "findrepl", "ftusrstr", "gather", "gbfeat", "gbftglob", "gbparint",  "jzcoll", "jzmisc", "lsqfetch", "maputil", "mconsist", "objmgr", "prtutil", "satutil",  "seqmgr", "seqport", "sequtil", "simple", "sqnutil1", "sqnutil2", "sqnutil3",  "subutil", "tofasta", "tofile", "tomedlin", "utilpars", "utilpub", "salpstat",  "salpedit", "valid", "alignmgr", "alignmgr2", "aliparse", "aliread", "alignval",  "wprint", "salpacc", "salprop", "salsap", "salstruc", "salutil", "udvseq", "blocks",  "pgppop", "samutil", "ddvcolor", "viewmgr", "jsavlt", "needleman", "fdlobj", "txalign"}},   {projPath:"ddv:", fileList:{ "ddvcreate"}}})) AddSimpleProject("ncbicdr", {}, "cdromlib",  {"casn", "cdconfig", "cdentrez", "cdnewlib", "cdromlib", "objentr"}) AddSimpleProject("vibrant", {}, "vibrant",  {"ncbidraw", "vibbutns", "vibextra", "vibfiles", "vibforms", "vibgroup", "viblists",  "vibmenus", "vibprmpt", "vibsbars", "vibslate", "vibtexts", "vibutils",  "vibwndws", "document", "drawing", "mapping", "palette", "picture", "table",  "viewer", "diagnost", "image", "pictur3d", "prim3d1", "prim3d2", "prim3d3",  "prim3d4", "prim3d5", "viewer3d", "vibmouse", "imagelst", "treeview", "shim3d",  "odlbox"}) AddSimpleProject("ncbidesk", {}, "desktop",  {"asn2graphic", "biosrc", "bspview", "cdrgn", "dlgutil1", "dlgutil2", "dotmatrx", "drawseq",  "e2trmlst", "e2docsum", "fea2seg", "fstyle", "glbpic", "gbfview", "gphview", "gphdraw",  "gxydraw", "gtrdraw", "seqpanel", "ingengraph", "ingenext", "ingenwin", "import", "layout", "mapgene",  "medview", "prtgene", "pubdesc", "saldist", "saled", "salfiles", "salpanel", "salparam",  "salsa", "seqsub", "seqfltr", "seqgraph", "seqgrphx", "seqmtrx", "seqpcc", "seqanal",  "aacomp", "seqscrl", "smdlg1", "smdlg2", "smdlg3", "smtools", "styleman", "stylemui",  "vsm", "vsmfile", "vsmutil", "udvgraph", "udvopen", "udvpanel", "salogif",  "dotvibrant"}) AddSimpleProject("ddvlib", {}, "ddv",  {"ddvclick", "ddvgraph", "ddvopen", "ddvpanel"}) AddSimpleProject("ncbitool", {}, "tools",  {"csim", "db_slist", "dust", "falign", "g_any", "pobutil", "stsutil", "sec", "sim2",  "sim3", "sim4", "simutil", "slist", "suggadj", "suggest", "suggslp", "tfuns",  "toasn3", "toporg", "blast", "blastconcat", "blastutl", "blastool", "splutil", "actutils",  "gapxdrop", "bandalg0", "bandalg1", "bandalg2", "bandalg3", "bandalg4", "bandalg5",  "bandalgn", "blastkar", "lookup", "posit", "readdb", "ncbisam", "ncbisort", "salign",  "salptool", "urkutil", "urkpcc", "urkptpf", "urkepi", "urkfltr", "urkdust",  "urksigu", "seg", "urkbias", "urkcnsrt", "urktree", "pattern1", "pseed3",  "impatool", "posit2", "newkar", "mbalign", "mblast", "vecscrn",  "rpsutil", "kappa", "xmlblast", "bxmlobj", "dotseq", "spidey", "motif"}) AddProject(DataPlusPrefixFile(ProjectData("ncbimmdb", {}, {  {projPath:"biostruc:", fileList:{ "corematx", "dvncode", "objmmdb1", "objmmdb2", "objmmdb3", "mmdbapi",  "mmdbapi1", "mmdbapi2", "mmdbapi3", "mmdbapi4", "mmdbentr", "vastsubs",  "prunebsc"}},   {projPath:"object:", fileList:{ "objmime"}},   {projPath:"access:", fileList:{ "strucapi"}},   {projPath:"biostruc:cn3d:", fileList:{ "objcn3d"}},   {projPath:"biostruc:cdd:", fileList:{ "objcdd", "cddutil", "cddposutil",  "thrdalgs", "thrdatd", "thrdbwfi", "thrdcpal",  "thrdcpll", "thrdcprl", "thrdcxei", "thrddgri", "thrdrsmp",  "thrdsal0", "thrdsalr", "thrdsalu", "thrdsgoi", "thrdslo0",  "thrdslor", "thrdslou", "thrdspci", "thrdspea", "thrdspel",  "thrdspni", "thrdttb0", "thrdttbi", "thrdzsc"}}}), "gif.pfx")) AddSimpleProject("ncbiNacc", {}, "cdromlib",  {"accentr", "accutils", "accmmdbs", "acccn3ds"}) AddSimpleProject("netentr", {}, "network:entrez:client",  {"netentr", "netlib", "objneten"}) AddSimpleProject("netcli", {}, "network:nsclilib",  {"ncbicli", "ncbiurl", "ni_disp", "ni_encrs", "ni_service", "ni_error", "ni_lib_",  "ni_macdv", "ni_msg", "ni_www", "ni_debug"}) AddSimpleProject("ncbibls3", {}, "network:blast3:client",  {"netblap3", "objblst3"}) AddSimpleProject("ncbiid1", {}, "network:id1arch",  {"id1gen", "id1arch", "accid1"}) AddSimpleProject("ncbimla", {}, "network:medarch:client",  {"medarch", "medutil", "objmla"}) AddProject(DataPlusPrefixFile(ProjectData("ncbitxc2", {}, {  {projPath:"network:taxon1:taxon2:", fileList:{ "parttree", "taxcs", "tc2proc", "txcdproc"}},   {projPath:"network:taxon1:common:", fileList:{ "objtax1", "taxutil"}}}), "tax2.pfx")) AddSimpleProject("vibnet", {}, "network:vibnet",  {"netcnfg", "trmlst", "docsum"}) end SetProjectData -- -- Global variables -- global gStartupDisk global gHomeDir global gMWroot global gMWCWfolder global gMacLibs global gStubLibs global gPPCLibs global gMSLPPCLibs global gDistribRoot global gAccessRoot global gProjectsDir global gSourceDir global gIncludeDir global gLibsDir global gRsrcsDir global gOutputDir global gSourcePath global gIncludePath global gLibsPath global gRsrcsPath global gProjectData on CopyHeaders() tell application "Finder" set corelibFolder to folder (gDistribRoot & "corelib") my UpdateRenameHeader("ncbilcl.met", corelibFolder, "ncbilcl.h", "") end tell end CopyHeaders on AddProject(projData) copy projData to end of gProjectData end AddProject on ResolveAlias(pathname) tell application "Finder" --if the last character of pathname is ":" then error "Don't use a trailing colon with ResolveAlias." if exists folder pathname then return pathname & ":" if exists alias file pathname then return the original item of alias file pathname as string error "The folder (or alias) '" & pathname & "' doesn't exist." end tell end ResolveAlias on IsOSX() tell application "Finder" set vers to the version as text if second character of vers is equal to "." then set vers to "0" & vers end if return vers > 10 or vers = 10 end tell end IsOSX on HomeDir() tell application "Finder" if my IsOSX() then -- return the home as string set hm to home as string set wd to words of hm set rs to rest of wd set text item delimiters of AppleScript to ":" set nw to (rs as string) & ":" set text item delimiters of AppleScript to "" return nw else return gStartupDisk end if end tell end HomeDir on CToolkitRoot() try set modRoot to ResolveAlias(gMWroot & "ncbi") on error try set modRoot to ResolveAlias(gStartupDisk & gHomeDir & "ncbi") end try end try return modRoot end CToolkitRoot on CPlusPlusToolkitRoot() try set modRoot to ResolveAlias(gMWroot & "cxx") on error try set modRoot to ResolveAlias(gStartupDisk & gHomeDir & "cxx") end try end try return modRoot end CPlusPlusToolkitRoot on ModuleRoot() if pUsingCPlusPlus then return CPlusPlusToolkitRoot() else return CToolkitRoot() end if end ModuleRoot on AccessRoot() if my IsOSX() then set wd to words of gDistribRoot set rs to rest of wd set text item delimiters of AppleScript to ":" set nw to (rs as string) & ":" set text item delimiters of AppleScript to "" return nw else return gDistribRoot end if end AccessRoot on MWRootDir() set mwRoot to "" set mwLocations to {gStartupDisk, gStartupDisk & "Applications:", gStartupDisk & "Applications (Mac OS 9):",  gStartupDisk & gHomeDir, gStartupDisk & gHomeDir & "Applications:", gStartupDisk & gHomeDir & "Applications (Mac OS 9):"} repeat with mwVersion from 8 to 9 set dirName to "Metrowerks CodeWarrior " & mwVersion & ".0" repeat with mwLoc in mwLocations try set mwRoot to ResolveAlias(mwLoc & dirName) return mwRoot end try end repeat end repeat error "Can't find the Metrowerks CodeWarrior folder." end MWRootDir on SetGlobals() tell application "Finder" set gProjectData to {} set gStartupDisk to startup disk as string set gHomeDir to my HomeDir() set gMWroot to my MWRootDir() set gMWCWfolder to gMWroot & "Metrowerks CodeWarrior:" set gMacLibs to gMWCWfolder & "MacOS Support:Universal:Libraries:" set gStubLibs to gMacLibs & "StubLibraries:" set gPPCLibs to gMacLibs & "PPCLibraries:" set gMSLPPCLibs to gMWCWfolder & "MSL:MSL_C:MSL_MacOS:Lib:PPC:" set gDistribRoot to my ModuleRoot() set gAccessRoot to my AccessRoot() set gIncludeDir to gDistribRoot & "include:" set gIncludePath to gAccessRoot & "include:" if pUsingCPlusPlus then set gSourceDir to gDistribRoot & "src:" set gLibsDir to gDistribRoot & "compilers:mac_prj:lib:" set gOutputDir to gDistribRoot & "compilers:mac_prj:bin:" set gProjectsDir to gOutputDir else set gSourceDir to gDistribRoot set gLibsDir to gDistribRoot & "lib:" set gOutputDir to gDistribRoot & "build:" set gRsrcsDir to gDistribRoot & "link:macmet:" set gSourcePath to gAccessRoot set gLibsPath to gAccessRoot & "lib:" set gOutputPath to gAccessRoot & "build:" set gRsrcsPath to gAccessRoot & "link:macmet:" end if if pLinkExecutables then set gProjectsDir to gOutputDir else set gProjectsDir to gLibsDir end if end tell end SetGlobals on HeaderExists(header, headerDir) tell application "Finder" if headerDir is "" then set headerDir to folder gIncludeDir return exists file header of headerDir end tell end HeaderExists on IsOlderThan(fileA, fileB) tell application "Finder" return (the modification date of fileA < the modification date of fileB) end tell end IsOlderThan on UpdateRenameHeader(canonicalName, canonicalDir, dotHName, dotHDir) tell application "Finder" set needRename to (dotHName is not "") if not needRename then set dotHName to canonicalName if dotHDir is "" then set dotHDir to folder gIncludeDir -- This file is only present if the script was interrupted. if needRename and my HeaderExists(canonicalName, dotHDir) then delete file canonicalName of dotHDir end if -- The native config file. -- If it's missing, assume this is a prepared distribution and the header is already up-to-date. if not my HeaderExists(canonicalName, canonicalDir) then return set canonicalFile to file canonicalName of canonicalDir set needCopy to true if my HeaderExists(dotHName, dotHDir) then set dotHFile to file dotHName of dotHDir if my IsOlderThan(dotHFile, canonicalFile) then delete dotHFile else set needCopy to false end if end if if needCopy then duplicate canonicalFile to dotHDir if needRename then set name of file canonicalName of dotHDir to dotHName end if end tell end UpdateRenameHeader on SetDebugSettings(shouldDebug, shouldProfile) tell application "CodeWarrior IDE" if shouldDebug then (* ===== Panel PPC Global Optimizer ===== *) Set Preferences of panel "PPC Global Optimizer" to  {Optimize For:code_Speed, Level:0} (* ===== Panel PPC Linker ===== *) Set Preferences of panel "PPC Linker" to  {Generate SYM File:true  , Suppress Warnings:false} (* ===== Panel C/C++ Language ===== *) Set Preferences of panel "C/C++ Compiler" to  {Inlining:inline_none  , AutoInlining:false} else (* ==== optimized/release settings ==== *) (* ===== Panel PPC Global Optimizer ===== *) Set Preferences of panel "PPC Global Optimizer" to  {Optimize For:code_Speed, Level:4} (* ===== Panel PPC Linker ===== *) Set Preferences of panel "PPC Linker" to  {Generate SYM File:false  , Suppress Warnings:true} (* ===== Panel C/C++ Language ===== *) Set Preferences of panel "C/C++ Compiler" to  {Inlining:inline_smart  , AutoInlining:true} end if if shouldProfile then (* ===== Panel PPC Processor ===== *) Set Preferences of panel "PPC CodeGen" to  {Use Profiler:true} else (* ===== Panel PPC Processor ===== *) Set Preferences of panel "PPC CodeGen" to  {Use Profiler:false} end if end tell end SetDebugSettings on SetPreferences() tell application "CodeWarrior IDE" (* ===== Section "Target" ===== *) -- Panel "Target Settings" Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} -- Panel "PPC Target" if pLinkExecutables then Set Preferences of panel "PPC Project" to  {Project Type:standard application, SIZE Flags:22720, File Creator:"NCBI", File Type:"APPL", Preferred Size:8000, Minimum Size:5000, Stack Size:64} else Set Preferences of panel "PPC Project" to {Project Type:library} end if (* ===== Section "Language Settings" ===== *) -- Panel "C/C++ Language" Set Preferences of panel "C/C++ Compiler" to  {Activate CPlusPlus:false  , ARM Conformance:false  , Exception Handling:true  , RTTI:true  , Pool Strings:true  , Dont Reuse Strings:false  , Require Function Prototypes:true  , ANSI Strict:false  , ANSI Keywords Only:false  , Expand Trigraph Sequences:false  , MPW Newlines:false  , MPW Pointer Type Rules:false  , Enums Always Ints:false} -- Panel "C/C++ Warnings" Set Preferences of panel "C/C++ Warnings" to  {Treat Warnings As Errors:false  , Illegal Pragmas:true  , Empty Declarations:true  , Possible Errors:true  , Unused Variables:true  , Unused Arguments:false  , Extra Commas:true  , Extended Error Checking:true  , Hidden Virtual Functions:true  , Implicit Arithmetic Conversions:false  , NonInlined Functions:false  , Inconsistent Class Struct:true} (* ===== Section "Code Generation" ===== *) -- Panel "PPC Processor" Set Preferences of panel "PPC CodeGen" to  {Struct Alignment:Align_PPC  , Make Strings ReadOnly:true  , Store Data in TOC:true  , Use FMADD Instructions:false  , Use Profiler:false  , Traceback Tables:TB_Inline  , Schedule:false  , Peephole Optimizer:true} (* ===== Section "Linker" ===== *) -- Panel "PPC Linker" Set Preferences of panel "PPC Linker" to  {Generate SYM File:true  , Full Path In SYM Files:true  , Generate Link Map:false  , Link Mode:fast  , Initialization Name: "", Main Name: "__start", Termination Name:""}  -- Panel "PPC PEF" Set Preferences of panel "PPC PEF" to  {Export Symbols:none  , Old Definition:0  , Old Implementation:0  , Current Version:0  , Code Sorting:nosort  , Share Data Section:false  , Expand Uninitialized Data:false  , Fragment Name:""} (* ===== Section "Debugger" ===== *) -- Panel "Debugger Settings" Set Preferences of panel "Debugger Target" to  {Log System Messages:false} my SetPaths1() end tell end SetPreferences on SetPaths1() tell application "CodeWarrior IDE" (* ===== Panel Access Paths ===== *) -- We need to be able to move the default system compiler folder to the end of the list -- because certain files like "all.h" and "all" are defined by both Metrowerks and NCBI. -- We want to find the NCBI "all.h" first. Set Preferences of panel "Access Paths" to {System Paths:{}} -- This removes the compiler default folder Set Preferences of panel "Access Paths" to {Always Full Search:true, Convert Paths:true} end tell end SetPaths1 on SetPaths2() tell application "CodeWarrior IDE" -- Add recursive include dir AFTER source dirs to avoid major performance hit set pathsToAdd to {} -- gDistribRoot & "link:macmet:", repeat with i in {gAccessRoot, gLibsPath, gIncludePath} copy {name:i, recursive:false, origin:absolute} to end of pathsToAdd end repeat if not pUsingCPlusPlus then copy {name:gAccessRoot & "link:macmet:", recursive:true, origin:absolute} to end of pathsToAdd end if Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd} set pathsToAdd to {{name:gIncludePath, recursive:true, origin:absolute}} if not pUsingCPlusPlus then copy {name:gAccessRoot, recursive:true, origin:absolute} to end of pathsToAdd end if -- After we have added all paths, reinsert compiler default at end of list set dirsToAdd to { ":MacOS Support:",  ":MSL:"} -- if gPNGpresent ... repeat with i in dirsToAdd copy {name:i, recursive:true, origin:shell relative} to end of pathsToAdd end repeat Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd} end tell end SetPaths2 on AddFeatures(features, flags) tell application "CodeWarrior IDE" if features contains "BNDL" then Set Preferences of panel "Output Flags" to {Has Bundle:true} end if if features contains "sockets" and flags does not contain "Carbon" then set libsToAdd to { gStubLibs & "ThreadsLib",  gStubLibs & "OpenTransportLib",  gStubLibs & "OpenTptInternetLib",  gStubLibs & "InternetConfigLib",  gPPCLibs & "OpenTptInetPPC.o",  gPPCLibs & "OpenTransportAppPPC.o"} Add Files libsToAdd end if end tell end AddFeatures on SetupTarget(proj, flags) tell application "CodeWarrior IDE" -- initialize variables set projRsrcs to {} set projFeatures to {} set sysPaths to {} -- Grab the fields of our project record and store them in local variables. set projName to proj's name set projSettings to proj's settings try set projFeatures to proj's features end try try set sysPaths to proj's sysPaths end try try set projRsrcs to proj's rsrcs end try set projLibs to proj's projLibs set projFileData to proj's fileData -- Figure out what our output file and input libraries will be named. if flags contains "Carbon" then set targetAPI to "C2" else set targetAPI to "Mac" end if if flags contains "debug" then set targetDebug to "dbg" else if flags contains "profile" then set targetDebug to "prf" else set targetDebug to "" end if end if set targetName to projName & " " & targetAPI set libNameSuffix to "-" & targetAPI if targetDebug is not "" then set targetName to targetName & " " & targetDebug set libNameSuffix to libNameSuffix & "-" & targetDebug end if if pLinkExecutables then set targetFilename to targetName else set targetFilename to projName & libNameSuffix & ".lib" end if -- Make the new target, and set the current target to be it. make new target at project document 1 with properties {name:targetName} set the current target of project document 1 to the result -- Set default settings. do this BEFORE setting per-project settings! my SetPreferences() -- Set the name of the output file (the application) Set Preferences of panel "PPC Project" to {File Name:targetFilename} -- If we have any per-project override settings, set them. if (count ppcProject of projSettings) > 0 then Set Preferences of panel "PPC Project" to ppcProject of projSettings end if --Set Preferences of panel "Access Paths" to {User Paths:{{name:NCBISOURCE & projPath, origin:absolute}}} my SetPaths2() -- Add per-project system paths. set pathsToAdd to {} repeat with i in sysPaths copy {name:i, recursive:true, origin:absolute} to end of pathsToAdd end repeat if (count pathsToAdd) > 0 then  Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd} -- Set the appropriate prefix file. set prefixFile to Prefix File of projSettings if flags contains "Carbon" then if prefixFile is "" then set prefixFile to "CarbonPrefix.h" else set prefixFile to "Carbon-" & prefixFile end if end if Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile} -- Are we assuming a .c or a .cpp extension? if projFeatures contains "C++" then set fileExtension to pCPlusPlusExtension else set fileExtension to ".c" end if -- Add source files. repeat with group in projFileData set projPath to projPath of group Set Preferences of panel "Access Paths" to  {User Paths:{{name:gSourcePath & projPath, origin:absolute}}} set fileList to group's fileList set filesToAdd to {} repeat with i in fileList if i does not contain "." then set i to i & fileExtension copy gSourceDir & projPath & i to end of filesToAdd end repeat Add Files filesToAdd end repeat if flags contains "debug" or flags contains "profile" then set the debug of every target file of target (count targets of project document 1)  of project document 1 to true if flags contains "profile" then my SetDebugSettings(true, true) else my SetDebugSettings(true, false) end if else my SetDebugSettings(false, false) end if -- Add appropriate system libraries. if pLinkExecutables then if flags contains "Carbon" then if flags contains "profile" then my AddCarbonLibs(true) else my AddCarbonLibs(false) end if else if flags contains "profile" then my AddBlueLibs(true) else my AddBlueLibs(false) end if end if end if my AddFeatures(projFeatures, flags) set filesToAdd to {} -- Add user libraries. if projFeatures contains "sockets" then if projLibs does not contain "mitsock" then copy "mitsock" to beginning of projLibs end if end if repeat with i in projLibs copy gLibsDir & i & libNameSuffix & ".lib" to end of filesToAdd end repeat -- Add resources. repeat with i in projRsrcs copy gRsrcsDir & i to end of filesToAdd end repeat Add Files filesToAdd Reset File Paths end tell end SetupTarget on CreateFolders() tell application "Finder" repeat with i in pDirsToCreate set pth to relPath of i if pth is not "" then set pth to pth & ":" if not (exists folder (gDistribRoot & pth & i's name)) then make new folder at folder (gDistribRoot & pth) with properties {name:i's name} end if end repeat end tell end CreateFolders on CreateProject(proj) tell application "CodeWarrior IDE" -- This statement doesn't work, because AppleScript is broken. if proj is {} then return try get proj's name on error return end try set projFilename to proj's name & pProjectFileExtension set projPathname to gProjectsDir & projFilename if pAlwaysCreateProjects or not (exists file projPathname of application "Finder") then try close (the first project document whose name is projFilename) end try Create Project {projPathname} if pCreateBlueTargets and pCreateDebugTargets then my SetupTarget(proj, "Blue debug") end if if pCreateBlueTargets and pCreateProfiledTargets then my SetupTarget(proj, "Blue profile") end if if pCreateBlueTargets and pCreateOptimizedTargets then my SetupTarget(proj, "Blue") end if if pCreateCarbonTargets and pCreateDebugTargets then my SetupTarget(proj, "Carbon debug") end if if pCreateCarbonTargets and pCreateProfiledTargets then my SetupTarget(proj, "Carbon profile") end if if pCreateCarbonTargets and pCreateOptimizedTargets then my SetupTarget(proj, "Carbon") end if set the current target of project document 1 to target 1 of project document 1 Close Project end if end tell end CreateProject on CreateAllProjects() repeat with proj in gProjectData CreateProject(proj) end repeat end CreateAllProjects on BuildProject(projName) tell application "CodeWarrior IDE" open (gProjectsDir & projName & pProjectFileExtension) repeat with i from 2 to (count targets of project document 1) set the current target of project document 1 to target i of project document 1 Make Project -- If there were compiler warnings, then a compiler window will be in front. -- For whatever reason, this causes the next "set the current target..." to fail. -- An easy way to make the window go away without having to know if it's there or not -- is to build again, which, because everything is already compiled, finishes instantly -- and produces no warnings. --Make Project -- An even better way is to check for the window and close it. if the name of window 1 is "Errors & Warnings" then close first window -- "close window 1" becomes "Close Window 1" (different event) end if end repeat set the current target of project document 1 to target 1 of project document 1 Close Project end tell end BuildProject on BuildAllProjects() repeat with proj in gProjectData try set projName to proj's name on error set projName to "" end try -- This statement doesn't work, because AppleScript is broken. if proj is not {} then if projName is not "" then BuildProject(projName) end if end if end repeat end BuildAllProjects on SignalCompletion() beep end SignalCompletion with timeout of 60000 seconds SetGlobals() SetProjectData() CreateFolders() CopyHeaders() tell application "CodeWarrior IDE" to activate CreateAllProjects() if pShouldBuild then BuildAllProjects() end if SignalCompletion() end timeout \ No newline at end of file
diff --git a/make/makeall.unx b/make/makeall.unx
index fe7fb7d9..b4dce566 100644
--- a/make/makeall.unx
+++ b/make/makeall.unx
@@ -1,6 +1,6 @@
# makefile for asntool and ncbi core routines,
#
-# $Id: makeall.unx,v 6.215 2003/10/09 16:41:32 beloslyu Exp $
+# $Id: makeall.unx,v 6.222 2003/12/30 20:55:03 kans Exp $
#
# cdromlib data access functions, vibrant, and entrez
# SunOS with unbundled ANSI compiler [ make LCL=acc RAN=ranlib CC=acc ]
@@ -120,7 +120,8 @@ ULIB39 = libideochr.a
LIB39= $(ULIB39)
LIB39 =
LIB50 = libregexp.a
-
+LIB60 = libblast.a
+LIB61 = libblastapi.a
#
# Pseudo-dummy targets when Vibrant is not used
#
@@ -192,7 +193,8 @@ SRC2 = objacces.c objalign.c objall.c objbibli.c \
sequtil.c prtutil.c simple.c tofasta.c tofile.c tomedlin.c \
valid.c alignmgr.c aliparse.c aliread.c alignval.c sqnutil1.c sqnutil2.c sqnutil3.c \
subutil.c edutil.c asn2ff1.c asn2ff2.c asn2ff3.c asn2ff4.c \
- asn2ff5.c asn2ff6.c asn2gnbk.c ftusrstr.c gbfeat.c gbftglob.c \
+ asn2ff5.c asn2ff6.c asn2gnb1.c asn2gnb2.c asn2gnb3.c asn2gnb4.c \
+ asn2gnb5.c asn2gnb6.c ftusrstr.c gbfeat.c gbftglob.c \
gbparint.c utilpars.c utilpub.c ffprint.c wprint.c satutil.c \
seqmgr.c objmgr.c gather.c accmmdbs.c acccn3ds.c lsqfetch.c findrepl.c \
codon.c jzcoll.c jzmisc.c maputil.c mconsist.c \
@@ -252,7 +254,7 @@ SRC23 = csim.c db_slist.c dust.c falign.c g_any.c sim2.c sim3.c sim4.c \
actutils.c posit.c lookup.c readdb.c ncbisam.c ncbisort.c \
salign.c salptool.c urkutil.c urkpcc.c urkptpf.c urkepi.c \
urkfltr.c urkdust.c urksigu.c seg.c urkbias.c urkcnsrt.c urktree.c \
- pseed3.c pattern1.c impatool.c posit2.c newkar.c mbalign.c \
+ pseed3.c pattern1.c impatool.c posit2.c mbalign.c \
vecscrn.c mblast.c rpsutil.c kappa.c xmlblast.c bxmlobj.c objscoremat.c \
dotseq.c spidey.c motif.c
@@ -278,6 +280,17 @@ SRC39 = ideochrow.c humchrom_dat.c mschrom_dat.c ideochrom.c ideoorgs.c \
SRC50 = chartables.c get.c maketables.c pcre.c pcreposix.c study.c
+SRC60 = aa_ungapped.c blast_dust.c blast_engine.c blast_extend.c \
+ blast_filter.c blast_gapalign.c blast_hits.c blast_lookup.c \
+ blast_message.c blast_options.c blast_seg.c blast_seqsrc.c \
+ blast_setup.c blast_stat.c blast_traceback.c blast_util.c \
+ gapinfo.c greedy_align.c link_hsps.c lookup_wrap.c mb_lookup.c \
+ ncbi_math.c ncbi_std.c pattern.c phi_extend.c phi_lookup.c \
+ lookup_util.c
+
+SRC61 = blast_input.c blast_seq.c blast_seqalign.c seqsrc_readdb.c \
+ blast_format.c
+
# objects needed for versions of asntool and entrez
THR_OBJ = ncbithr.o
@@ -310,7 +323,8 @@ OBJ2 = objacces.o objalign.o objall.o objbibli.o \
sequtil.o prtutil.o simple.o tofasta.o tofile.o tomedlin.o \
valid.o alignmgr.o aliparse.o aliread.o alignval.o sqnutil1.o sqnutil2.o sqnutil3.o \
subutil.o edutil.o asn2ff1.o asn2ff2.o asn2ff3.o asn2ff4.o \
- asn2ff5.o asn2ff6.o asn2gnbk.o ftusrstr.o gbfeat.o gbftglob.o \
+ asn2ff5.o asn2ff6.o asn2gnb1.o asn2gnb2.o asn2gnb3.o asn2gnb4.o \
+ asn2gnb5.o asn2gnb6.o ftusrstr.o gbfeat.o gbftglob.o \
gbparint.o utilpars.o utilpub.o ffprint.o wprint.o satutil.o \
seqmgr.o objmgr.o gather.o accmmdbs.o acccn3ds.o lsqfetch.o findrepl.o \
codon.o jzcoll.o jzmisc.o maputil.o mconsist.o \
@@ -382,7 +396,7 @@ OBJ23 = csim.o db_slist.o dust.o falign.o g_any.o sim2.o sim3.o sim4.o \
actutils.o posit.o lookup.o readdb.o ncbisam.o ncbisort.o \
salign.o salptool.o urkutil.o urkpcc.o urkptpf.o urkepi.o \
urkfltr.o urkdust.o urksigu.o seg.o urkbias.o urkcnsrt.o urktree.o \
- pseed3.o pattern1.o impatool.o posit2.o newkar.o mbalign.o \
+ pseed3.o pattern1.o impatool.o posit2.o mbalign.o \
vecscrn.o mblast.o rpsutil.o kappa.o xmlblast.o bxmlobj.o objscoremat.o \
dotseq.o spidey.o motif.o
@@ -413,6 +427,18 @@ OBJ39 = ideochrow.o humchrom_dat.o mschrom_dat.o ideochrom.o ideoorgs.o \
OBJ50 = chartables.o get.o maketables.o pcre.o pcreposix.o study.o
+OBJ60 = aa_ungapped.o blast_dust.o blast_engine.o blast_extend.o \
+ blast_filter.o blast_gapalign.o blast_hits.o blast_lookup.o \
+ blast_message.o blast_options.o blast_seg.o blast_seqsrc.o \
+ blast_setup.o blast_stat.o blast_traceback.o blast_util.o \
+ gapinfo.o greedy_align.o link_hsps.o lookup_wrap.o mb_lookup.o \
+ ncbi_math.o ncbi_std.o pattern.o phi_extend.o phi_lookup.o \
+ lookup_util.o
+
+OBJ61 = blast_input.o blast_seq.o blast_seqalign.o seqsrc_readdb.o \
+ blast_format.o
+
+
# NOTE: if you enter an object file to an OBJxx greater than 30, you have to explicitly
# enter the make actions below (e.g. ddvclick.o). This is because the
# implicit make rule for opengl objects (.glo) somehow causes the default make rule for .o
@@ -430,10 +456,10 @@ ln-if-absent: ../make/ln-if-absent
nocopy : sources $(THR_OBJ) $(LIB1) $(LIB2) $(LIB3) $(DLIB4) $(DLIB400) \
$(LIB5) $(DLIB20) $(DLIB45) $(LIB22) $(LIB23) $(DLIB28) $(DLIB30) $(DLIB3000) \
- $(DLIB34) $(DLIB37) $(DLIB38) $(LIB50) $(NCBI_SHLIBS)
+ $(DLIB34) $(DLIB37) $(DLIB38) $(LIB50) $(LIB60) $(LIB61) $(NCBI_SHLIBS)
sources : $(THR_SRC) $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC20) $(SRC22) \
- $(SRC23) $(SRC28) $(SRC30) $(SRC50)
+ $(SRC23) $(SRC28) $(SRC30) $(SRC50) $(SRC60) $(SRC61)
## To clean out the directory without removing make
##
@@ -707,6 +733,12 @@ copy :
$(SRCCOPY) ../network/nsclilib/*.h ../include
$(SRCCOPY) ../network/blast3/client/*.h ../include
$(SRCCOPY) ../network/id1arch/*.h ../include
+ - mkdir -p ../include/algo/blast/core
+ $(SRCCOPY) ../algo/blast/core/*.c .
+ cp -fp ../algo/blast/core/*.h ../include/algo/blast/core
+ - mkdir -p ../include/algo/blast/api
+ $(SRCCOPY) ../algo/blast/api/*.c .
+ cp -fp ../algo/blast/api/*.h ../include/algo/blast/api
- chmod -R ug+rw,o+r .
@@ -871,6 +903,17 @@ $(LIB50) : $(OBJ50)
$(LIBCOPY) $(LIB50) $(NCBI_LIBDIR)
$(RAN) $(NCBI_LIBDIR)/$(LIB50)
+$(LIB60) : $(OBJ60)
+ - $(RM_LIB) $(LIB60)
+ $(AR) cru $(LIB60) $(OBJ60)
+ $(LIBCOPY) $(LIB60) $(NCBI_LIBDIR)
+ $(RAN) $(NCBI_LIBDIR)/$(LIB60)
+
+$(LIB61) : $(OBJ61)
+ - $(RM_LIB) $(LIB61)
+ $(AR) cru $(LIB61) $(OBJ61)
+ $(LIBCOPY) $(LIB61) $(NCBI_LIBDIR)
+ $(RAN) $(NCBI_LIBDIR)/$(LIB61)
## make asntool application
## This is ALWAYS the command line version
diff --git a/make/makeallchives b/make/makeallchives
index 2feb2847..76b97196 100755
--- a/make/makeallchives
+++ b/make/makeallchives
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: makeallchives,v 1.63 2003/06/03 16:40:51 beloslyu Exp $
+# $Id: makeallchives,v 1.68 2004/01/06 17:13:48 coulouri Exp $
#
#
# Creates all archives from a directory above 'ncbi'
@@ -92,13 +92,13 @@ EOF
;;
blast)
f="blastall blastpgp seedtop formatdb fastacmd copymat makemat \
-impala megablast blastclust rpsblast bl2seq ../doc/README.imp \
-../doc/README.bls ../doc/README.mbl ../doc/README.bcl ../doc/README.rps \
-../doc/README.formatdb ../doc/README.fastacmd ../doc/README-qm"
+impala megablast blastclust rpsblast bl2seq ../doc/impala.txt \
+../doc/blast.txt ../doc/megablast.txt ../doc/blastclust.txt ../doc/rpsblast.txt \
+../doc/formatdb.txt ../doc/fastacmd.txt ../doc/README-qm"
rm -f archive/blast/data/sequin.hlp
;;
netblast)
- f="blastcl3 ../doc/firewall.html ../doc/README.nbl"
+ f="blastcl3 ../doc/firewall.html ../doc/netblast.txt"
;;
*)
;;
@@ -265,4 +265,30 @@ do
#and remove it
rm -fr $A
done
+
+# build wwwblast archive
+
+# cd archive && cvs export -d blast -r HEAD distrib/network/wwwblast && cd ..
+
+mkdir blast
+
+cp -r ../ncbi/network/wwwblast/* blast
+
+find blast -type d -name CVS | xargs rm -rf
+find blast -type d -name Src | xargs rm -rf
+
+for file in psiblast.REAL psiblast_cs.REAL blast.REAL blast_cs.REAL wblast2.REAL wblast2_cs.REAL bl2bag.cgi nph-viewgif.cgi
+do
+cp ../ncbi/build/$file blast
+done
+
+mkdir -p blast/TmpGifs
+chmod 777 blast/TmpGifs
+chmod 666 blast/*.log
+
+tar -cpf wwwblast-$platform.tar blast
+gzip wwwblast-$platform.tar
+
+rm -rf blast
+
exit 0
diff --git a/make/makedemo.met b/make/makedemo.met
deleted file mode 100644
index 32688a12..00000000
--- a/make/makedemo.met
+++ /dev/null
@@ -1 +0,0 @@
--- C demos -- -- -- Properties -- property pUsingCPlusPlus : false property pProjectFileExtension : ".mcp" -- Whether to recreate existing project files. property pAlwaysCreateProjects : false -- Which targets to create. -- If these are changed you must recreate the project files. There is no direct effect on building. property pCreateBlueTargets : true -- 'Blue' was codename for System 7, here it means pre-Carbon. property pCreateCarbonTargets : true property pCreateDebugTargets : true property pCreateProfiledTargets : false property pCreateOptimizedTargets : true -- Whether to compile everything. property pShouldBuild : true property pDirsToCreate : {{relPath:"", name:"build"}} property pLinkExecutables : true -- -- Routines specific to this project -- on SimpleProjectData(projName, features) if (count characters of projName) > 18 then set projName to characters 1 through 18 of projName as string end if tell application "CodeWarrior IDE" if features does not contain "C" and features does not contain "C++" then --error "Project " & projName & "'s default language (a feature) must be C or C++." copy "C" to end of features end if set myFeatures to features copy "BNDL" to end of myFeatures return {name:projName, features:myFeatures, rsrcs:{"ncbilogo.r"}, settings: {Prefix File:"", ppcProject:{}}, projLibs: {"mitsock", "ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool"}, fileData: {{projPath:"demo:", fileList:{projName}}}} end tell end SimpleProjectData on AddSimpleProject(projName, features) AddProject(SimpleProjectData(projName, features)) end AddSimpleProject on SetProjectData() tell application "CodeWarrior IDE" -- Entrez set myName to "Entrez" set myFeatures to {"sockets", "BNDL"} set mySettings to {Prefix File:"net.pfx", ppcProject:{File Creator:"ENTZ"}} set myRsrcs to {"entrez.r"} set myLibs to {"mitsock", "ncbi", "ncbiconn", "ncbiobj", "ncbicdr", "vibrant", "ncbidesk", "ncbimmdb",  "ncbitool", "netcli", "netentr", "ncbibls3", "ncbiid1", "vibnet"} set myFiles to  {{projPath:"cdromlib:", fileList:{"accentr", "accutils"}},  {projPath:"demo:", fileList:{"entrez"}}} set entrezData to  {name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs: myLibs, fileData:myFiles} -- Entrez2 set myName to "Entrez2" set myFeatures to {"sockets", "BNDL"} set mySettings to {Prefix File:"net.pfx", ppcProject:{File Creator:"ENTZ"}} set myRsrcs to {"entrez.r"} set myLibs to {"mitsock", "ncbi", "ncbiconn", "ncbiobj", "ncbimmdb", "ncbitool", "vibrant", "ncbidesk"} set myFiles to  {{projPath:"demo:", fileList:{"entrez2"}}} set entrez2Data to  {name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs: myLibs, fileData:myFiles} -- Sequin set myName to "Sequin" set myFeatures to {"sockets", "BNDL"} set mySettings to  {Prefix File:"net.pfx", ppcProject: {File Creator:"SEQN", Preferred Size:32000, Minimum Size:6000}} set myRsrcs to {"sequin.r"} set myLibs to {"mitsock", "ncbi", "ncbiconn", "ncbiobj", "ncbicdr", "vibrant", "ncbidesk",  "ncbimmdb", "ncbitool", "netcli", "netentr", "ncbibls3", "ncbimla",  "ncbitxc2", "ncbiid1", "vibnet"} set myFiles to  {{projPath:"cdromlib:", fileList:{"accentr", "accutils"}},  {projPath:"sequin:", fileList:{"sequin1", "sequin2", "sequin3", "sequin4", "sequin5",  "sequin6", "sequin7", "sequin8", "sequin9", "sequinx"}}} set sequinData to  {name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs: myLibs, fileData:myFiles} -- BlastCL3 set myName to "blastcl3" set myFeatures to {"sockets", "BNDL"} set mySettings to {Prefix File:"blastcl3.pfx", ppcProject:{}} set myRsrcs to {"ncbilogo.r"} set myLibs to {"mitsock", "ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbibls3"} set myFiles to  {{projPath:"demo:", fileList:{"blastall"}}} set blastcl3Data to  {name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs: myLibs, fileData:myFiles} -- Bl2seq set myName to "bl2seq" set myFeatures to {"sockets", "BNDL"} set mySettings to {Prefix File:"net.pfx", ppcProject:{}} set myRsrcs to {"ncbilogo.r"} set myLibs to {"mitsock", "ncbi", "ncbiconn", "ncbiobj", "vibrant", "ncbitool", "netcli", "ncbibls3", "ncbiid1"} set myFiles to  {{projPath:"demo:", fileList:{"bl2seq"}}} set bl2seqData to  {name:myName, features:myFeatures, settings:mySettings, rsrcs:myRsrcs, projLibs: myLibs, fileData:myFiles} -- Impala set impalaData to my SimpleProjectData("impala", {}) set item 1 of fileList of item 1 of fileData of impalaData to "profiles" end tell AddProject(sequinData) AddProject(entrezData) AddProject(entrez2Data) AddSimpleProject("tbl2asn", {}) AddSimpleProject("formatdb", {}) AddSimpleProject("fastacmd", {}) AddProject(bl2seqData) AddSimpleProject("blastall", {}) AddSimpleProject("blastpgp", {}) AddProject(blastcl3Data) AddSimpleProject("megablast", {}) AddSimpleProject("blastclust", {}) AddSimpleProject("rpsblast", {}) AddSimpleProject("seedtop", {}) AddSimpleProject("copymat", {}) AddSimpleProject("makemat", {}) AddProject(impalaData) end SetProjectData -- -- Global variables -- global gStartupDisk global gHomeDir global gMWroot global gMWCWfolder global gMacLibs global gStubLibs global gPPCLibs global gMSLPPCLibs global gDistribRoot global gAccessRoot global gProjectsDir global gSourceDir global gIncludeDir global gLibsDir global gRsrcsDir global gOutputDir global gSourcePath global gIncludePath global gLibsPath global gRsrcsPath global gProjectData on AddProject(projData) copy projData to end of gProjectData end AddProject on ResolveAlias(pathname) tell application "Finder" --if the last character of pathname is ":" then error "Don't use a trailing colon with ResolveAlias." if exists folder pathname then return pathname & ":" if exists alias file pathname then return the original item of alias file pathname as string error "The folder (or alias) '" & pathname & "' doesn't exist." end tell end ResolveAlias on IsOSX() tell application "Finder" set vers to the version as text if second character of vers is equal to "." then set vers to "0" & vers end if return vers > 10 or vers = 10 end tell end IsOSX on HomeDir() tell application "Finder" if my IsOSX() then -- return the home as string set hm to home as string set wd to words of hm set rs to rest of wd set text item delimiters of AppleScript to ":" set nw to (rs as string) & ":" set text item delimiters of AppleScript to "" return nw else return gStartupDisk end if end tell end HomeDir on CToolkitRoot() try set modRoot to ResolveAlias(gMWroot & "ncbi") on error try set modRoot to ResolveAlias(gStartupDisk & gHomeDir & "ncbi") end try end try return modRoot end CToolkitRoot on CPlusPlusToolkitRoot() try set modRoot to ResolveAlias(gMWroot & "cxx") on error try set modRoot to ResolveAlias(gStartupDisk & gHomeDir & "cxx") end try end try return modRoot end CPlusPlusToolkitRoot on ModuleRoot() if pUsingCPlusPlus then return CPlusPlusToolkitRoot() else return CToolkitRoot() end if end ModuleRoot on AccessRoot() if my IsOSX() then set wd to words of gDistribRoot set rs to rest of wd set text item delimiters of AppleScript to ":" set nw to (rs as string) & ":" set text item delimiters of AppleScript to "" return nw else return gDistribRoot end if end AccessRoot on MWRootDir() set mwRoot to "" set mwLocations to {gStartupDisk, gStartupDisk & "Applications:", gStartupDisk & "Applications (Mac OS 9):",  gStartupDisk & gHomeDir, gStartupDisk & gHomeDir & "Applications:", gStartupDisk & gHomeDir & "Applications (Mac OS 9):"} repeat with mwVersion from 8 to 9 set dirName to "Metrowerks CodeWarrior " & mwVersion & ".0" repeat with mwLoc in mwLocations try set mwRoot to ResolveAlias(mwLoc & dirName) return mwRoot end try end repeat end repeat error "Can't find the Metrowerks CodeWarrior folder." end MWRootDir on SetGlobals() tell application "Finder" set gProjectData to {} set gStartupDisk to startup disk as string set gHomeDir to my HomeDir() set gMWroot to my MWRootDir() set gMWCWfolder to gMWroot & "Metrowerks CodeWarrior:" set gMacLibs to gMWCWfolder & "MacOS Support:Universal:Libraries:" set gStubLibs to gMacLibs & "StubLibraries:" set gPPCLibs to gMacLibs & "PPCLibraries:" set gMSLPPCLibs to gMWCWfolder & "MSL:MSL_C:MSL_MacOS:Lib:PPC:" set gDistribRoot to my ModuleRoot() set gAccessRoot to my AccessRoot() set gIncludeDir to gDistribRoot & "include:" set gIncludePath to gAccessRoot & "include:" if pUsingCPlusPlus then set gSourceDir to gDistribRoot & "src:" set gLibsDir to gDistribRoot & "compilers:mac_prj:lib:" set gOutputDir to gDistribRoot & "compilers:mac_prj:bin:" set gProjectsDir to gOutputDir else set gSourceDir to gDistribRoot set gLibsDir to gDistribRoot & "lib:" set gOutputDir to gDistribRoot & "build:" set gRsrcsDir to gDistribRoot & "link:macmet:" set gSourcePath to gAccessRoot set gLibsPath to gAccessRoot & "lib:" set gOutputPath to gAccessRoot & "build:" set gRsrcsPath to gAccessRoot & "link:macmet:" end if if pLinkExecutables then set gProjectsDir to gOutputDir else set gProjectsDir to gLibsDir end if end tell end SetGlobals on SetDebugSettings(shouldDebug, shouldProfile) tell application "CodeWarrior IDE" if shouldDebug then (* ===== Panel PPC Global Optimizer ===== *) Set Preferences of panel "PPC Global Optimizer" to  {Optimize For:code_Speed, Level:0} (* ===== Panel PPC Linker ===== *) Set Preferences of panel "PPC Linker" to  {Generate SYM File:true  , Suppress Warnings:false} (* ===== Panel C/C++ Language ===== *) Set Preferences of panel "C/C++ Compiler" to  {Inlining:inline_none  , AutoInlining:false} else (* ==== optimized/release settings ==== *) (* ===== Panel PPC Global Optimizer ===== *) Set Preferences of panel "PPC Global Optimizer" to  {Optimize For:code_Speed, Level:4} (* ===== Panel PPC Linker ===== *) Set Preferences of panel "PPC Linker" to  {Generate SYM File:false  , Suppress Warnings:true} (* ===== Panel C/C++ Language ===== *) Set Preferences of panel "C/C++ Compiler" to  {Inlining:inline_smart  , AutoInlining:true} end if if shouldProfile then (* ===== Panel PPC Processor ===== *) Set Preferences of panel "PPC CodeGen" to  {Use Profiler:true} else (* ===== Panel PPC Processor ===== *) Set Preferences of panel "PPC CodeGen" to  {Use Profiler:false} end if end tell end SetDebugSettings on SetPreferences() tell application "CodeWarrior IDE" (* ===== Section "Target" ===== *) -- Panel "Target Settings" Set Preferences of panel "Target Settings" to {Linker:"MacOS PPC Linker"} -- Panel "PPC Target" if pLinkExecutables then Set Preferences of panel "PPC Project" to  {Project Type:standard application, SIZE Flags:22720, File Creator:"NCBI", File Type:"APPL", Preferred Size:8000, Minimum Size:5000, Stack Size:64} else Set Preferences of panel "PPC Project" to {Project Type:library} end if (* ===== Section "Language Settings" ===== *) -- Panel "C/C++ Language" Set Preferences of panel "C/C++ Compiler" to  {Activate CPlusPlus:false  , ARM Conformance:false  , Exception Handling:true  , RTTI:true  , Pool Strings:true  , Dont Reuse Strings:false  , Require Function Prototypes:true  , ANSI Strict:false  , ANSI Keywords Only:false  , Expand Trigraph Sequences:false  , MPW Newlines:false  , MPW Pointer Type Rules:false  , Enums Always Ints:false} -- Panel "C/C++ Warnings" Set Preferences of panel "C/C++ Warnings" to  {Treat Warnings As Errors:false  , Illegal Pragmas:true  , Empty Declarations:true  , Possible Errors:true  , Unused Variables:true  , Unused Arguments:false  , Extra Commas:true  , Extended Error Checking:true  , Hidden Virtual Functions:true  , Implicit Arithmetic Conversions:false  , NonInlined Functions:false  , Inconsistent Class Struct:true} (* ===== Section "Code Generation" ===== *) -- Panel "PPC Processor" Set Preferences of panel "PPC CodeGen" to  {Struct Alignment:Align_PPC  , Make Strings ReadOnly:true  , Store Data in TOC:true  , Use FMADD Instructions:false  , Use Profiler:false  , Traceback Tables:TB_Inline  , Schedule:false  , Peephole Optimizer:true} (* ===== Section "Linker" ===== *) -- Panel "PPC Linker" Set Preferences of panel "PPC Linker" to  {Generate SYM File:true  , Full Path In SYM Files:true  , Generate Link Map:false  , Link Mode:fast  , Initialization Name: "", Main Name: "__start", Termination Name:""}  -- Panel "PPC PEF" Set Preferences of panel "PPC PEF" to  {Export Symbols:none  , Old Definition:0  , Old Implementation:0  , Current Version:0  , Code Sorting:nosort  , Share Data Section:false  , Expand Uninitialized Data:false  , Fragment Name:""} (* ===== Section "Debugger" ===== *) -- Panel "Debugger Settings" Set Preferences of panel "Debugger Target" to  {Log System Messages:false} my SetPaths1() end tell end SetPreferences on SetPaths1() tell application "CodeWarrior IDE" (* ===== Panel Access Paths ===== *) -- We need to be able to move the default system compiler folder to the end of the list -- because certain files like "all.h" and "all" are defined by both Metrowerks and NCBI. -- We want to find the NCBI "all.h" first. Set Preferences of panel "Access Paths" to {System Paths:{}} -- This removes the compiler default folder Set Preferences of panel "Access Paths" to {Always Full Search:true, Convert Paths:true} end tell end SetPaths1 on SetPaths2() tell application "CodeWarrior IDE" -- Add recursive include dir AFTER source dirs to avoid major performance hit set pathsToAdd to {} -- gDistribRoot & "link:macmet:", repeat with i in {gAccessRoot, gLibsPath, gIncludePath} copy {name:i, recursive:false, origin:absolute} to end of pathsToAdd end repeat if not pUsingCPlusPlus then copy {name:gAccessRoot & "link:macmet:", recursive:true, origin:absolute} to end of pathsToAdd end if Set Preferences of panel "Access Paths" to {User Paths:pathsToAdd} set pathsToAdd to {{name:gIncludePath, recursive:true, origin:absolute}} if not pUsingCPlusPlus then copy {name:gAccessRoot, recursive:true, origin:absolute} to end of pathsToAdd end if -- After we have added all paths, reinsert compiler default at end of list set dirsToAdd to { ":MacOS Support:",  ":MSL:"} -- if gPNGpresent ... repeat with i in dirsToAdd copy {name:i, recursive:true, origin:shell relative} to end of pathsToAdd end repeat Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd} end tell end SetPaths2 on SetWeakLink(libName) tell application "CodeWarrior IDE" set the weak link of  every target file of target (count targets of project document 1) of project document 1  whose path ends with ":" & libName  to true end tell end SetWeakLink on AddBlueLibs(shouldProfile) tell application "CodeWarrior IDE" set libsToAdd to { gMSLPPCLibs & "MSL C.PPC.Lib",  gMSLPPCLibs & "MSL C++.PPC.Lib",  gMSLPPCLibs & "MSL SIOUX.PPC.Lib",  gMWCWfolder & "MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib",  gMSLPPCLibs & "MSL_C_PPC.Lib",  gMSLPPCLibs & "MSL_C++_PPC.Lib",  gMSLPPCLibs & "MSL_SIOUX_PPC.Lib",  gMSLPPCLibs & "MSL_Extras_PPC.Lib",  gMWCWfolder & "MacOS Support:Libraries:Runtime:Libs:MSL_Runtime_PPC.Lib",  gStubLibs & "InterfaceLib",  gStubLibs & "AppearanceLib",  gStubLibs & "NavigationLib",  gStubLibs & "MathLib",  gStubLibs & "TextCommon",  gStubLibs & "UnicodeConverter",  gStubLibs & "UTCUtils",  gPPCLibs & "CarbonAccessors.o"} if shouldProfile then copy gMWCWfolder & "MacOS Support:Profiler:Profiler PPC:Profiler PPC.Lib" to end of libsToAdd end if Add Files libsToAdd my SetWeakLink("AppearanceLib") my SetWeakLink("NavigationLib") end tell end AddBlueLibs on AddCarbonLibs(shouldProfile) tell application "CodeWarrior IDE" set libsToAdd to { gMSLPPCLibs & "MSL C.Carbon.Lib",  gMSLPPCLibs & "MSL C++.PPC.Lib",  gMSLPPCLibs & "MSL SIOUX.Carbon.Lib",  gMWCWfolder & "MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.Lib",  gMSLPPCLibs & "MSL_C_Carbon.Lib",  gMSLPPCLibs & "MSL_C++_PPC.Lib",  gMSLPPCLibs & "MSL_SIOUX_Carbon.Lib",  gMSLPPCLibs & "MSL_Extras_Carbon.Lib",  gMWCWfolder & "MacOS Support:Libraries:Runtime:Libs:MSL_Runtime_PPC.Lib",  gStubLibs & "CarbonLib"} if shouldProfile then copy gMWCWfolder & "MacOS Support:Profiler:Profiler PPC:Profiler Carbon.Lib" to end of libsToAdd end if Add Files libsToAdd end tell end AddCarbonLibs on AddFeatures(features, flags) tell application "CodeWarrior IDE" if features contains "BNDL" then Set Preferences of panel "Output Flags" to {Has Bundle:true} end if if features contains "sockets" and flags does not contain "Carbon" then set libsToAdd to { gStubLibs & "ThreadsLib",  gStubLibs & "OpenTransportLib",  gStubLibs & "OpenTptInternetLib",  gStubLibs & "InternetConfigLib",  gPPCLibs & "OpenTptInetPPC.o",  gPPCLibs & "OpenTransportAppPPC.o"} Add Files libsToAdd end if end tell end AddFeatures on SetupTarget(proj, flags) tell application "CodeWarrior IDE" -- initialize variables set projRsrcs to {} set projFeatures to {} set sysPaths to {} -- Grab the fields of our project record and store them in local variables. set projName to proj's name set projSettings to proj's settings try set projFeatures to proj's features end try try set sysPaths to proj's sysPaths end try try set projRsrcs to proj's rsrcs end try set projLibs to proj's projLibs set projFileData to proj's fileData -- Figure out what our output file and input libraries will be named. if flags contains "Carbon" then set targetAPI to "C2" else set targetAPI to "Mac" end if if flags contains "debug" then set targetDebug to "dbg" else if flags contains "profile" then set targetDebug to "prf" else set targetDebug to "" end if end if set targetName to projName & " " & targetAPI set libNameSuffix to "-" & targetAPI if targetDebug is not "" then set targetName to targetName & " " & targetDebug set libNameSuffix to libNameSuffix & "-" & targetDebug end if if pLinkExecutables then set targetFilename to targetName else set targetFilename to projName & libNameSuffix & ".lib" end if -- Make the new target, and set the current target to be it. make new target at project document 1 with properties {name:targetName} set the current target of project document 1 to the result -- Set default settings. do this BEFORE setting per-project settings! my SetPreferences() -- Set the name of the output file (the application) Set Preferences of panel "PPC Project" to {File Name:targetFilename} -- If we have any per-project override settings, set them. if (count ppcProject of projSettings) > 0 then Set Preferences of panel "PPC Project" to ppcProject of projSettings end if --Set Preferences of panel "Access Paths" to {User Paths:{{name:NCBISOURCE & projPath, origin:absolute}}} my SetPaths2() -- Add per-project system paths. set pathsToAdd to {} repeat with i in sysPaths copy {name:i, recursive:true, origin:absolute} to end of pathsToAdd end repeat if (count pathsToAdd) > 0 then  Set Preferences of panel "Access Paths" to {System Paths:pathsToAdd} -- Set the appropriate prefix file. set prefixFile to Prefix File of projSettings if flags contains "Carbon" then if prefixFile is "" then set prefixFile to "CarbonPrefix.h" else set prefixFile to "Carbon-" & prefixFile end if end if Set Preferences of panel "C/C++ Compiler" to {Prefix File:prefixFile} -- Are we assuming a .c or a .cpp extension? if projFeatures contains "C++" then set fileExtension to pCPlusPlusExtension else set fileExtension to ".c" end if -- Add source files. repeat with group in projFileData set projPath to projPath of group Set Preferences of panel "Access Paths" to  {User Paths:{{name:gSourcePath & projPath, origin:absolute}}} set fileList to group's fileList set filesToAdd to {} repeat with i in fileList if i does not contain "." then set i to i & fileExtension copy gSourceDir & projPath & i to end of filesToAdd end repeat Add Files filesToAdd end repeat if flags contains "debug" or flags contains "profile" then set the debug of every target file of target (count targets of project document 1)  of project document 1 to true if flags contains "profile" then my SetDebugSettings(true, true) else my SetDebugSettings(true, false) end if else my SetDebugSettings(false, false) end if -- Add appropriate system libraries. if pLinkExecutables then if flags contains "Carbon" then if flags contains "profile" then my AddCarbonLibs(true) else my AddCarbonLibs(false) end if else if flags contains "profile" then my AddBlueLibs(true) else my AddBlueLibs(false) end if end if end if my AddFeatures(projFeatures, flags) set filesToAdd to {} -- Add user libraries. if projFeatures contains "sockets" then if projLibs does not contain "mitsock" then copy "mitsock" to beginning of projLibs end if end if repeat with i in projLibs copy gLibsDir & i & libNameSuffix & ".lib" to end of filesToAdd end repeat -- Add resources. repeat with i in projRsrcs copy gRsrcsDir & i to end of filesToAdd end repeat if flags contains "Carbon" then copy gRsrcsDir & "Carbon.r" to end of filesToAdd end if Add Files filesToAdd Reset File Paths end tell end SetupTarget on CreateFolders() tell application "Finder" repeat with i in pDirsToCreate set pth to relPath of i if pth is not "" then set pth to pth & ":" if not (exists folder (gDistribRoot & pth & i's name)) then make new folder at folder (gDistribRoot & pth) with properties {name:i's name} end if end repeat end tell end CreateFolders on CreateProject(proj) tell application "CodeWarrior IDE" -- This statement doesn't work, because AppleScript is broken. if proj is {} then return try get proj's name on error return end try set projFilename to proj's name & pProjectFileExtension set projPathname to gProjectsDir & projFilename if pAlwaysCreateProjects or not (exists file projPathname of application "Finder") then try close (the first project document whose name is projFilename) end try Create Project {projPathname} if pCreateBlueTargets and pCreateDebugTargets then my SetupTarget(proj, "Blue debug") end if if pCreateBlueTargets and pCreateProfiledTargets then my SetupTarget(proj, "Blue profile") end if if pCreateBlueTargets and pCreateOptimizedTargets then my SetupTarget(proj, "Blue") end if if pCreateCarbonTargets and pCreateDebugTargets then my SetupTarget(proj, "Carbon debug") end if if pCreateCarbonTargets and pCreateProfiledTargets then my SetupTarget(proj, "Carbon profile") end if if pCreateCarbonTargets and pCreateOptimizedTargets then my SetupTarget(proj, "Carbon") end if set the current target of project document 1 to target 1 of project document 1 Close Project end if end tell end CreateProject on CreateAllProjects() repeat with proj in gProjectData CreateProject(proj) end repeat end CreateAllProjects on BuildProject(projName) tell application "CodeWarrior IDE" open (gProjectsDir & projName & pProjectFileExtension) repeat with i from 2 to (count targets of project document 1) set the current target of project document 1 to target i of project document 1 Make Project -- If there were compiler warnings, then a compiler window will be in front. -- For whatever reason, this causes the next "set the current target..." to fail. -- An easy way to make the window go away without having to know if it's there or not -- is to build again, which, because everything is already compiled, finishes instantly -- and produces no warnings. --Make Project -- An even better way is to check for the window and close it. if the name of window 1 is "Errors & Warnings" then close first window -- "close window 1" becomes "Close Window 1" (different event) end if end repeat set the current target of project document 1 to target 1 of project document 1 Close Project end tell end BuildProject on BuildAllProjects() repeat with proj in gProjectData try set projName to proj's name on error set projName to "" end try -- This statement doesn't work, because AppleScript is broken. if proj is not {} then if projName is not "" then BuildProject(projName) end if end if end repeat end BuildAllProjects on SignalCompletion() beep end SignalCompletion with timeout of 60000 seconds SetGlobals() SetProjectData() CreateFolders() tell application "CodeWarrior IDE" to activate CreateAllProjects() if pShouldBuild then BuildAllProjects() end if SignalCompletion() end timeout \ No newline at end of file
diff --git a/make/makedemo.unx b/make/makedemo.unx
index 16f1fa25..5d256fea 100644
--- a/make/makedemo.unx
+++ b/make/makedemo.unx
@@ -1,6 +1,6 @@
# makefile for demo programs
#
-# $Id: makedemo.unx,v 6.64 2003/01/16 22:39:47 dondosha Exp $
+# $Id: makedemo.unx,v 6.68 2004/01/02 22:05:16 coulouri Exp $
#
# Sun with unbundled ANSI compiler [ make CC=acc ]
# Sun with Gnu C [ make CC=gcc ]
@@ -73,6 +73,8 @@ LIB20 =
LIB22 = -lncbimmdb
LIB23 = -lncbitool
LIB50 = -lregexp
+LIB60 = -lblast
+LIB61 = -lblastapi
NCBI_INCDIR = ../include
NCBI_LIBDIR = ../lib
NCBI_LINKINGLIBDIR = $(NCBI_LIBDIR)
@@ -94,20 +96,20 @@ EXE1 = testcore makeset \
getmesh indexpub getpub testobj seqtest \
dosimple asn2ff getseq getfeat checksub asndhuff \
entrcmd errhdr cdscan findspl \
- ncbisort fa2htgs fastacmd formatdb blastall blastpgp \
+ ncbisort fa2htgs fastacmd formatdb blast blastall blastpgp \
testval seedtop fmerge makemat copymat impala \
megablast vecscreen gil2bin tbl2asn blastclust rpsblast \
- asn2xml \
+ asn2xml debruijn \
test_regexp demo_regexp demo_regexp_grep
SRC1 = testcore.c makeset.c \
getmesh.c indexpub.c getpub.c testobj.c seqtest.c dosimple.c asn2ff.c \
getseq.c getfeat.c checksub.c asndhuff.c \
entrcmd.c errhdr.c cdscan.c findspl.c \
- ncbisort.c fa2htgs.c fastacmd.c formatdb.c blastall.c blastpgp.c \
- testval.c seedtop.c fmerge.c makemat.c copymat.c profiles.c \
+ ncbisort.c fa2htgs.c fastacmd.c formatdb.c blast_driver.c blastall.c \
+ blastpgp.c testval.c seedtop.c fmerge.c makemat.c copymat.c profiles.c \
megablast.c vecscreen.c gil2bin.c tbl2asn.c blastclust.c rpsblast.c \
- asn2xml.c \
+ asn2xml.c debruijn.c \
pcretest.c pcredemo.c pcregrep.c
INTERNAL = testgen
@@ -274,6 +276,13 @@ formatdb : formatdb.c
fmerge : fmerge.c
$(CC) -o fmerge $(LDFLAGS) fmerge.c $(LIB23) $(LIB2) $(LIB1) $(OTHERLIBS)
+# blast (reincarnation of blastall from algo/blast sources)
+
+blast : blast_driver.c
+ $(CC) -o blast $(LDFLAGS) blast_driver.c $(LIB61) $(LIB60) $(LIB23) $(LIB2) $(LIB1) $(OTHERLIBS)
+
+debruijn : debruijn.c
+ $(CC) -o debruijn $(LDFLAGS) debruijn.c $(LIB60) $(LIB1) $(OTHERLIBS)
# blastall
blastall : blastall.c $(THREAD_OBJ)
@@ -297,7 +306,7 @@ makemat : makemat.c $(THREAD_OBJ)
# copymat
copymat : copymat.c $(THREAD_OBJ)
- $(CC) -o copymat $(LDFLAGS) copymat.c $(THREAD_OBJ) $(LIB23) $(LIB2) $(LIB1) $(OTHERLIBS) $(THREAD_OTHERLIBS)
+ $(CC) -o copymat $(LDFLAGS) copymat.c $(THREAD_OBJ) $(LIB60) $(LIB23) $(LIB2) $(LIB1) $(OTHERLIBS) $(THREAD_OTHERLIBS)
# impala
diff --git a/make/makedis.csh b/make/makedis.csh
index 8fb5164a..e5680363 100755
--- a/make/makedis.csh
+++ b/make/makedis.csh
@@ -1,6 +1,6 @@
#!/bin/csh -f
#
-# $Id: makedis.csh,v 1.89 2003/09/05 19:22:18 beloslyu Exp $
+# $Id: makedis.csh,v 1.94 2004/01/22 19:56:15 ucko Exp $
#
## PUBLIC DOMAIN NOTICE
# National Center for Biotechnology Information
@@ -155,6 +155,9 @@ case Linux:
case "parisc":
set platform=hppalinux
breaksw
+ case "i?86":
+ set platform=linux-x86
+ breaksw
default:
set platform=linux
breaksw
@@ -312,8 +315,9 @@ else
set PNG_LIBS=""
endif
-set WWWBLAST=(psiblast.REAL psiblast_cs.REAL blast.REAL blast_cs.REAL \
-nph-viewgif.cgi wblast2_cs.REAL bl2bag.cgi)
+set VIBWWWBLAST=(psiblast.REAL psiblast_cs.REAL blast.REAL blast_cs.REAL)
+set NONVIBWWWBLAST=(nph-viewgif.cgi wblast2.REAL wblast2_cs.REAL bl2bag.cgi)
+set WWWBLAST=($VIBWWWBLAST $NONVIBWWWBLAST)
if ( "$HAVE_MOTIF" == 1 ) then
set ALL_VIB=(LIB30=libncbicn3d.a \
@@ -335,7 +339,7 @@ if ( "$HAVE_MOTIF" == 1 ) then
OGLLIBS=\"$OGL_LIBS $PNG_LIBS\" \
VIBFLAG=\"$NCBI_VIBFLAG\" \
VIB=\"Psequin Nentrez udv ddv blastcl3 \
- idfetch bl2seq asn2xml asn2gb entrez2 gbseqget \
+ idfetch bl2seq asn2gb entrez2 gbseqget \
$WWWBLAST $OGL_TARGETS\")
else if ( "$HAVE_MAC" == 1 ) then
set ALL_VIB=(LIB30=libncbicn3d.a \
@@ -357,7 +361,7 @@ else if ( "$HAVE_MAC" == 1 ) then
OGLLIBS=\"$OGL_LIBS $PNG_LIBS\" \
VIBFLAG=\"$NCBI_VIBFLAG\" \
VIB=\"Psequin udv ddv blastcl3 \
- idfetch bl2seq asn2xml asn2gb entrez2 gbseqget $WWWBLAST \")
+ idfetch bl2seq asn2gb entrez2 gbseqget $WWWBLAST \")
else # no Motif, build only ascii-based applications
set OGL_NCBI_LIBS=""
set OGL_INCLUDE=""
@@ -366,7 +370,7 @@ else # no Motif, build only ascii-based applications
set ALL_VIB=()
set DEMO_VIB=()
- set NET_VIB=(VIB=\"blastcl3 idfetch bl2seq asn2xml asn2gb $WWWBLAST \")
+ set NET_VIB=(VIB=\"blastcl3 idfetch bl2seq asn2gb $NONVIBWWWBLAST \")
endif
set CMD='make $MFLG \
@@ -464,7 +468,7 @@ else
getpub getseq gil2bin idfetch impala indexpub makemat makeset \
megablast ncbisort netentcf rpsblast seedtop seqtest sequin entrez2 \
tbl2asn test_regexp testcore testobj testval udv vecscreen Cn3D \
- $WWWBLAST )
+ blast debruijn $WWWBLAST )
if ( -x ./$i ) then
rm -f ../bin/$i
if ( $os == "Darwin" ) then
diff --git a/make/makenet.unx b/make/makenet.unx
index 44fce382..41c99e10 100644
--- a/make/makenet.unx
+++ b/make/makenet.unx
@@ -1,6 +1,6 @@
# makefile for network demo programs and network entrez
#
-# $Id: makenet.unx,v 6.159 2003/09/03 14:41:54 kans Exp $
+# $Id: makenet.unx,v 6.162 2003/12/16 19:05:13 kimelman Exp $
# test, ignore
#
# Sun with unbundled ANSI compiler [ make CC=acc RAN=ranlib ]
@@ -130,6 +130,8 @@ BLIB44 =
BLIB45 = libddvlib.a
+BLIB46 = libncbiid2.a
+
#
# Pseudo-dummy targets when Vibrant is not used
#
@@ -196,9 +198,11 @@ LIB38 = -lncbiprsn
LIB40 = -lncbitxc2
LIB41 = -lncbiid1
LIB42 = -lctutils
+LIB_PS = -lctutils -lz
LIB43 = -losutils
LIB44 = -lidload
LIB45 = -lddvlib
+LIB46 = -lncbiid2
##
## encryption of network services
@@ -331,6 +335,8 @@ SRC43 = os_mtutils.c already_running.c
SRC44 = idload_lib.c
+SRC46 = id2.c
+
#NET_LIBS_SRC = $(SRC6) $(SRC6_) $(SRC7) $(SRC8) $(SRC9)
NET_LIBS_SRC = $(SRC6) $(SRC7) $(SRC8) $(SRC9)
@@ -398,6 +404,8 @@ OBJ43 = os_mtutils.o already_running.o
OBJ44 = idload_lib.o
+OBJ46 = id2.o
+
# objects & sources needed for versions of network demo programs
OBJVCLIENT = vclient.o
@@ -523,7 +531,7 @@ S : $(BLIB16)
ES : $(BLIB17)
-others : $(BLIB11) $(BLIB12) $(BLIB13) $(BLIB19) $(BLIB25) $(BLIB27) $(BLIB35) $(BLIB36) $(BLIB38) $(BLIB40) $(NCBI_SHLIBS).alt $(BLIB41) $(BLIB42) $(BLIB43) $(BLIB44)
+others : $(BLIB11) $(BLIB12) $(BLIB13) $(BLIB19) $(BLIB25) $(BLIB27) $(BLIB35) $(BLIB36) $(BLIB38) $(BLIB40) $(NCBI_SHLIBS).alt $(BLIB41) $(BLIB42) $(BLIB43) $(BLIB44) $(BLIB46)
## To clean out the directory without removing make
@@ -598,6 +606,8 @@ copy :
-$(SRCCOPY) ../network/id0arch/client/*.c .
-$(SRCCOPY) ../network/id1arch/*.h ../include
-$(SRCCOPY) ../network/id1arch/*.c .
+ -$(SRCCOPY) ../network/id2arch/*.h ../include
+ -$(SRCCOPY) ../network/id2arch/*.c .
-$(SRCCOPY) ../network/spell/client/*.h ../include
-$(SRCCOPY) ../network/spell/client/*.c .
-$(SRCCOPY) ../network/suggest/client/*.h ../include
@@ -736,6 +746,8 @@ accid1.o: accid1.c
$(CC) $(CFLAGS) accid1.c
id1arch.o: id1arch.c
$(CC) $(CFLAGS) id1arch.c
+id2.o: id2.c
+ $(CC) $(CFLAGS) id2.c
objbl1p1.o : objbl1p1.c
$(CC) $(CFLAGS) objbl1p1.c
objbl1p2.o : objbl1p2.c
@@ -973,6 +985,11 @@ $(BLIB41) : $(OBJ41)
$(LIBCOPY) $(BLIB41) $(NCBI_LIBDIR)
$(RAN) $(NCBI_LIBDIR)/$(BLIB41)
+$(BLIB46) : $(OBJ46)
+ - rm -f $(BLIB46)
+ $(AR) cru $(BLIB46) $(OBJ46)
+ $(LIBCOPY) $(BLIB46) $(NCBI_LIBDIR)
+ $(RAN) $(NCBI_LIBDIR)/$(BLIB46)
#
# Dummy target used when Vibrant is not used
@@ -1154,7 +1171,7 @@ asn2gb : asn2gb.c
# asn2gb_psf, uses PUBSEQBioseqFetchEnable instead of PubSeqfetchEnable
# should be used only internally within NCBI.
asn2gb_psf : asn2gb.c
- $(CC) -DINTERNAL_NCBI_ASN2GB -g -o asn2gb_psf $(LDFLAGS) asn2gb.c $(LIB42) -lnlmzip $(LIB23) $(LIB2) $(LIB1) $(NCBI_SYBLIBS_CT) $(OTHERLIBS)
+ $(CC) -DINTERNAL_NCBI_ASN2GB -g -o asn2gb_psf $(LDFLAGS) asn2gb.c $(LIB_PS) $(LIB23) $(LIB2) $(LIB1) $(NCBI_SYBLIBS_CT) $(OTHERLIBS)
# gbseqget program (gbseqget)
gbseqget : gbseqget.c
@@ -1202,7 +1219,7 @@ fetchent : fetchent.c
# demo program (condense)
condense : condense.c
- $(CC) $(IN_HOUSE_CFLAGS) -o condense $(LDFLAGS) condense.c $(LIB42) $(LIB2) $(LIB1) $(NCBI_SYBLIBS_CT) -lnlmzip $(OTHERLIBS)
+ $(CC) $(IN_HOUSE_CFLAGS) -o condense $(LDFLAGS) condense.c $(LIB_PS) $(LIB2) $(LIB1) $(NCBI_SYBLIBS_CT) $(OTHERLIBS)
# test client for the id0 network service
diff --git a/make/msvc_prj/blast/blast.dsp b/make/msvc_prj/blast/blast.dsp
new file mode 100644
index 00000000..88181360
--- /dev/null
+++ b/make/msvc_prj/blast/blast.dsp
@@ -0,0 +1,293 @@
+# Microsoft Developer Studio Project File - Name="blast" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=blast - Win32 DebugDLL
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "blast.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "blast.mak" CFG="blast - Win32 DebugDLL"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "blast - Win32 DebugDLL" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugDLL"
+# PROP BASE Intermediate_Dir "DebugDLL"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugDLL"
+# PROP Intermediate_Dir "DebugDLL"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\.." /I "..\..\..\corelib" /I "..\..\..\asnstat" /I "..\..\..\asnlib" /I "..\..\..\tools" /I "..\..\..\object" /I "..\..\..\api" /I "..\..\..\ddv" /I "..\..\..\cdromlib" /I "..\..\..\biostruc" /I "..\..\..\vibrant" /I "..\..\..\desktop" /I "..\..\..\network\taxon1\common" /I "..\..\..\network\taxon1\taxon2" /I "..\..\..\network\blast3\client" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\.." /I "..\..\..\corelib" /I "..\..\..\asnstat" /I "..\..\..\asnlib" /I "..\..\..\tools" /I "..\..\..\object" /I "..\..\..\api" /I "..\..\..\ddv" /I "..\..\..\cdromlib" /I "..\..\..\biostruc" /I "..\..\..\vibrant" /I "..\..\..\desktop" /I "..\..\..\network\taxon1\common" /I "..\..\..\network\taxon1\taxon2" /I "..\..\..\network\blast3\client" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+# Begin Target
+
+# Name "blast - Win32 DebugDLL"
+# Begin Group "core"
+
+# PROP Default_Filter ""
+# Begin Group "src"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\aa_ungapped.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_dust.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_engine.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_extend.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_filter.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_gapalign.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_hits.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_lookup.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_message.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_options.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_seg.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_seqsrc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_setup.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_stat.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_traceback.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_util.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\gapinfo.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\greedy_align.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\link_hsps.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\lookup_util.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\lookup_wrap.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\mb_lookup.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\ncbi_math.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\ncbi_std.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\pattern.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\phi_extend.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\phi_lookup.c
+# End Source File
+# End Group
+# Begin Group "include"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\aa_ungapped.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_def.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_dust.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_engine.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_extend.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_filter.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_gapalign.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_hits.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_lookup.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_message.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_options.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_seg.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_seqsrc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_setup.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_stat.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_traceback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\blast_util.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\gapinfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\greedy_align.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\link_hsps.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\lnfact.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\lookup_util.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\lookup_wrap.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\mb_lookup.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\ncbi_config.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\ncbi_math.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\ncbi_std.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\pattern.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\phi_extend.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\algo\blast\core\phi_lookup.h
+# End Source File
+# End Group
+# End Group
+# End Target
+# End Project
diff --git a/make/msvc_prj/install.sh b/make/msvc_prj/install.sh
index 03b06531..0068ee4c 100644
--- a/make/msvc_prj/install.sh
+++ b/make/msvc_prj/install.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# $Id: install.sh,v 1.29 2003/10/09 18:46:48 ivanov Exp $
+# $Id: install.sh,v 1.33 2004/01/29 16:18:37 ivanov Exp $
# Authors: Denis Vakatov (vakatov@ncbi.nlm.nih.gov)
# Vladimir Ivanov (ivanov@ncbi.nlm.nih.gov)
# Anton Lavrentiev (lavr@ncbi.nlm.nih.gov)
@@ -10,7 +10,7 @@
# Cmd.-line args -- source and destination
script="$0"
builddir="${1:-//u/coremake/ncbi}"
-target="${2:-//u/coremake/public/ncbi}"
+target="${2:-//u/coremake/public/ncbi.last}"
if test -n "$3" ; then
echo "USAGE: `basename $script` [build_dir] [install_dir]"
@@ -39,11 +39,14 @@ incdir="$target"/include
srcdir="$target"/src
bindir="$target"/bin
datdir="$target"/data
+errdir="$target"/errmsg
# Alternate dirs (mirrors)
srcdir_a="$target"/altsrc
dbgdir_a="$target"/dbglib
libdir_a="$target"/lib
+datdir_a="$target"/../c/data
+errdir_a="$target"/../c/errmsg
# Check
@@ -92,9 +95,12 @@ makedir "$srcdir"/tools
makedir "$srcdir"/vibrant
makedir "$bindir" -p
makedir "$datdir" -p
+makedir "$errdir" -p
makedir "$srcdir_a" -p
makedir "$dbgdir_a" -p
makedir "$libdir_a" -p
+makedir "$datdir_a" -p
+makedir "$errdir_a" -p
# Copy files
@@ -207,6 +213,9 @@ done
# Data
cp -pr "$builddir"/data/* "$datdir"
+cp -pr "$builddir"/data/* "$datdir_a"
+cp -pr "$builddir"/errmsg/* "$errdir"
+cp -pr "$builddir"/errmsg/* "$errdir_a"
# Fill alt source tree
diff --git a/make/msvc_prj/internal/all_internal.dsp b/make/msvc_prj/internal/all_internal.dsp
new file mode 100644
index 00000000..1bc23e4f
--- /dev/null
+++ b/make/msvc_prj/internal/all_internal.dsp
@@ -0,0 +1,48 @@
+# Microsoft Developer Studio Project File - Name="all_internal" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Generic Project" 0x010a
+
+CFG=all_internal - Win32 DebugDLL
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "all_internal.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "all_internal.mak" CFG="all_internal - Win32 DebugDLL"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "all_internal - Win32 DebugDLL" (based on "Win32 (x86) Generic Project")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+MTL=midl.exe
+
+!IF "$(CFG)" == "all_internal - Win32 DebugDLL"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugDLL"
+# PROP BASE Intermediate_Dir "DebugDLL"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugDLL"
+# PROP Intermediate_Dir "DebugDLL"
+# PROP Target_Dir ""
+
+!ENDIF
+
+# Begin Target
+
+# Name "all_internal - Win32 DebugDLL"
+# End Target
+# End Project
diff --git a/make/msvc_prj/internal/smart/smartnet/smartnet.dsp b/make/msvc_prj/internal/smart/smartnet/smartnet.dsp
new file mode 100644
index 00000000..0c2104ff
--- /dev/null
+++ b/make/msvc_prj/internal/smart/smartnet/smartnet.dsp
@@ -0,0 +1,70 @@
+# Microsoft Developer Studio Project File - Name="smartnet" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=smartnet - Win32 DebugDLL
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "smartnet.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "smartnet.mak" CFG="smartnet - Win32 DebugDLL"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "smartnet - Win32 DebugDLL" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugDLL"
+# PROP BASE Intermediate_Dir "DebugDLL"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugDLL"
+# PROP Intermediate_Dir "DebugDLL"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# SUBTRACT BASE CPP /Fr
+# ADD CPP /nologo /MDd /W3 /GR /Z7 /Od /I "..\..\..\..\.." /I "..\..\..\..\..\api" /I "..\..\..\..\..\corelib" /I "..\..\..\..\..\vibrant" /I "..\..\..\..\..\internal\smart\smartnet" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+# Begin Target
+
+# Name "smartnet - Win32 DebugDLL"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\..\internal\smart\smartnet\smartnet_win32.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\..\..\internal\smart\smartnet\smartnet.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/make/msvc_prj/ncbi.dsw b/make/msvc_prj/ncbi.dsw
index 25502ae1..f5379186 100644
--- a/make/msvc_prj/ncbi.dsw
+++ b/make/msvc_prj/ncbi.dsw
@@ -293,8 +293,23 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name exe_sequin
End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "all_internal"=.\internal\all_internal.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name exe_ssequin
+ End Project Dependency
Begin Project Dependency
- Project_Dep_Name exe_sequin_ogl
+ Project_Dep_Name smartnet
End Project Dependency
}}}
@@ -377,6 +392,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name regexp
End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name blast
+ End Project Dependency
}}}
###############################################################################
@@ -398,6 +416,21 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name all_lib
End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name all_internal
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "blast"=.\blast\blast.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
}}}
###############################################################################
@@ -950,6 +983,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name ncbimain
End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name blast
+ End Project Dependency
}}}
###############################################################################
@@ -2046,9 +2082,6 @@ Package=<4>
Project_Dep_Name ncbitool
End Project Dependency
Begin Project Dependency
- Project_Dep_Name vibrant
- End Project Dependency
- Begin Project Dependency
Project_Dep_Name ncbinacc
End Project Dependency
Begin Project Dependency
@@ -2448,9 +2481,6 @@ Package=<4>
Project_Dep_Name vibnet
End Project Dependency
Begin Project Dependency
- Project_Dep_Name ncbicn3d
- End Project Dependency
- Begin Project Dependency
Project_Dep_Name netblast
End Project Dependency
Begin Project Dependency
@@ -2463,15 +2493,9 @@ Package=<4>
Project_Dep_Name ncbidesk
End Project Dependency
Begin Project Dependency
- Project_Dep_Name ddvlib
- End Project Dependency
- Begin Project Dependency
Project_Dep_Name ncbitxc2
End Project Dependency
Begin Project Dependency
- Project_Dep_Name ncbiid1
- End Project Dependency
- Begin Project Dependency
Project_Dep_Name medarch
End Project Dependency
Begin Project Dependency
@@ -2499,7 +2523,7 @@ Package=<4>
###############################################################################
-Project: "exe_sequin_ogl"=.\sequin\sequin_ogl\exe_sequin_ogl.dsp - Package Owner=<4>
+Project: "exe_ssequin"=.\sequin\ssequin\exe_ssequin.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -2508,10 +2532,10 @@ Package=<5>
Package=<4>
{{{
Begin Project Dependency
- Project_Dep_Name vibnet
+ Project_Dep_Name smartnet
End Project Dependency
Begin Project Dependency
- Project_Dep_Name ncbicn3d_ogl
+ Project_Dep_Name vibnet
End Project Dependency
Begin Project Dependency
Project_Dep_Name netblast
@@ -2526,15 +2550,9 @@ Package=<4>
Project_Dep_Name ncbidesk
End Project Dependency
Begin Project Dependency
- Project_Dep_Name ddvlib
- End Project Dependency
- Begin Project Dependency
Project_Dep_Name ncbitxc2
End Project Dependency
Begin Project Dependency
- Project_Dep_Name ncbiid1
- End Project Dependency
- Begin Project Dependency
Project_Dep_Name medarch
End Project Dependency
Begin Project Dependency
@@ -2558,6 +2576,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name ncbi
End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name ncbispel
+ End Project Dependency
}}}
###############################################################################
@@ -2721,6 +2742,18 @@ Package=<4>
###############################################################################
+Project: "ncbispel"=.\network\spell\client\ncbispel.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "ncbitool"=.\tools\ncbitool.dsp - Package Owner=<4>
Package=<5>
@@ -2793,6 +2826,18 @@ Package=<4>
###############################################################################
+Project: "smartnet"=.\internal\smart\smartnet\smartnet.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "socket_io_bouncer"=.\connect\test\socket_io_bouncer\socket_io_bouncer.dsp - Package Owner=<4>
Package=<5>
diff --git a/make/msvc_prj/network/spell/client/ncbispel.dsp b/make/msvc_prj/network/spell/client/ncbispel.dsp
new file mode 100644
index 00000000..471bad36
--- /dev/null
+++ b/make/msvc_prj/network/spell/client/ncbispel.dsp
@@ -0,0 +1,78 @@
+# Microsoft Developer Studio Project File - Name="ncbispel" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=ncbispel - Win32 DebugDLL
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ncbispel.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ncbispel.mak" CFG="ncbispel - Win32 DebugDLL"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ncbispel - Win32 DebugDLL" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugDLL"
+# PROP BASE Intermediate_Dir "DebugDLL"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugDLL"
+# PROP Intermediate_Dir "DebugDLL"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# SUBTRACT BASE CPP /Fr
+# ADD CPP /nologo /MDd /W3 /GR /Z7 /Od /I "..\..\..\..\.." /I "..\..\..\..\..\network\spell\client" /I "..\..\..\..\..\asnlib" /I "..\..\..\..\..\asnstat" /I "..\..\..\..\..\corelib" /I "..\..\..\..\..\network\nsclilib" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+# Begin Target
+
+# Name "ncbispel - Win32 DebugDLL"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\..\network\spell\client\objspell.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\..\network\spell\client\spellapi.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\..\..\network\spell\client\objspell.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\..\network\spell\client\spellapi.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/make/msvc_prj/object/ncbiobj.dsp b/make/msvc_prj/object/ncbiobj.dsp
index 80f31333..76d45955 100644
--- a/make/msvc_prj/object/ncbiobj.dsp
+++ b/make/msvc_prj/object/ncbiobj.dsp
@@ -109,7 +109,27 @@ SOURCE=..\..\..\api\asn2ff6.c
# End Source File
# Begin Source File
-SOURCE=..\..\..\api\asn2gnbk.c
+SOURCE=..\..\..\api\asn2gnb1.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\api\asn2gnb2.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\api\asn2gnb3.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\api\asn2gnb4.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\api\asn2gnb5.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\api\asn2gnb6.c
# End Source File
# Begin Source File
diff --git a/make/msvc_prj/sequin/ssequin/exe_ssequin.dsp b/make/msvc_prj/sequin/ssequin/exe_ssequin.dsp
new file mode 100644
index 00000000..09fde287
--- /dev/null
+++ b/make/msvc_prj/sequin/ssequin/exe_ssequin.dsp
@@ -0,0 +1,119 @@
+# Microsoft Developer Studio Project File - Name="exe_ssequin" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=exe_ssequin - Win32 DebugDLL
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "exe_ssequin.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "exe_ssequin.mak" CFG="exe_ssequin - Win32 DebugDLL"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "exe_ssequin - Win32 DebugDLL" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugDLL"
+# PROP BASE Intermediate_Dir "DebugDLL"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugDLL"
+# PROP Intermediate_Dir "DebugDLL"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+LIB32=link.exe -lib
+# ADD BASE CPP /nologo /MDd /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /GR /Z7 /Od /I "..\..\..\.." /I "..\..\..\..\api" /I "..\..\..\..\asnstat" /I "..\..\..\..\ddv" /I "..\..\..\..\access" /I "..\..\..\..\desktop" /I "..\..\..\..\object" /I "..\..\..\..\asnlib" /I "..\..\..\..\vibrant" /I "..\..\..\..\network\vibnet" /I "..\..\..\..\cdromlib" /I "..\..\..\..\tools" /I "..\..\..\..\connect" /I "..\..\..\..\corelib" /I "..\..\..\..\network\taxon1\taxon2" /I "..\..\..\..\network\nsclilib" /I "..\..\..\..\network\blast3\client" /I "..\..\..\..\network\taxon1\common" /I "..\..\..\..\network\medarch\client" /I "..\..\..\..\network\id1arch" /I "..\..\..\..\network\spell\client" /I "..\..\..\..\biostruc" /I "..\..\..\..\internal\smart\smartnet" /D "WIN32" /D "_DEBUG" /D "INTERNAL_NCBI_SEQUIN" /D "USE_SMARTNET" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /pdb:none /debug /machine:I386
+# ADD LINK32 oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"DebugDLL/ssequin.exe" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none /nodefaultlib
+# Begin Target
+
+# Name "exe_ssequin - Win32 DebugDLL"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\link\mswin\sequin.rc
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin1.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin10.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin2.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin3.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin4.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin5.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin6.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin7.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin8.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin9.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequinx.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\..\sequin\sequin.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/make/msvc_prj/tools/ncbitool.dsp b/make/msvc_prj/tools/ncbitool.dsp
index 3a8ddd8a..bb060556 100644
--- a/make/msvc_prj/tools/ncbitool.dsp
+++ b/make/msvc_prj/tools/ncbitool.dsp
@@ -171,10 +171,6 @@ SOURCE=..\..\..\tools\ncbisort.c
# End Source File
# Begin Source File
-SOURCE=..\..\..\tools\newkar.c
-# End Source File
-# Begin Source File
-
SOURCE=..\..\..\tools\objscoremat.c
# End Source File
# Begin Source File
diff --git a/make/readme.dos b/make/readme.dos
index 0d1855f6..7a1ff79c 100644
--- a/make/readme.dos
+++ b/make/readme.dos
@@ -1,4 +1,4 @@
-# $Id: readme.dos,v 6.12 2002/04/29 18:12:06 vakatov Exp $
+# $Id: readme.dos,v 6.13 2004/01/26 17:04:53 vakatov Exp $
# By Denis Vakatov, NCBI
@@ -31,6 +31,8 @@ Building the NCBI C Toolkit
"all - Win32 Release"
"all - Win32 DebugMT"
"all - Win32 ReleaseMT"
+ "all - Win32 DebugDLL"
+ "all - Win32 ReleaseDLL"
3.2) Or, you can choose to build any library(es) or application(s)
in any configuration by using either the list of
project configuration here or "ClassView" (or "FileView") frame.
diff --git a/network/blast3/client/netblap3.c b/network/blast3/client/netblap3.c
index 191d5b13..0748f819 100644
--- a/network/blast3/client/netblap3.c
+++ b/network/blast3/client/netblap3.c
@@ -34,6 +34,9 @@
*
* RCS Modification History:
* $Log: netblap3.c,v $
+* Revision 1.105 2004/01/27 20:53:12 dondosha
+* Value of no_traceback megablast option is now Uint1 instead of Boolean
+*
* Revision 1.104 2003/01/13 18:08:26 bealer
* - Replace nonstandard snprintf() function with strcpy/strcat/strlen.
*
@@ -800,7 +803,7 @@ BlastOptionsToParameters (BLAST_OptionsBlkPtr options)
parameters->smith_waterman = options->smith_waterman;
parameters->is_megablast = options->is_megablast_search;
parameters->query_lcase_mask = (ValNodePtr) options->query_lcase_mask;
- parameters->endpoint_results = options->no_traceback;
+ parameters->endpoint_results = (Boolean) options->no_traceback;
parameters->percent_identity = (FloatHi) options->perc_identity;
parameters->first_db_seq = options->first_db_seq;
parameters->final_db_seq = options->final_db_seq;
@@ -2768,7 +2771,8 @@ parametersToOptions (BlastParametersPtr parameters, CharPtr program, ValNodePtr
options->is_megablast_search = parameters->is_megablast;
options->query_lcase_mask =
(SeqLocPtr) parameters->query_lcase_mask;
- options->no_traceback = parameters->endpoint_results;
+ if (parameters->endpoint_results)
+ options->no_traceback = 1;
options->perc_identity = (FloatLo) parameters->percent_identity;
options->first_db_seq = parameters->first_db_seq;
options->final_db_seq = parameters->final_db_seq;
diff --git a/network/id1arch/idfetch.c b/network/id1arch/idfetch.c
index ce439e7a..5d9afa05 100644
--- a/network/id1arch/idfetch.c
+++ b/network/id1arch/idfetch.c
@@ -25,6 +25,12 @@
* Author Karl Sirotkin
*
$Log: idfetch.c,v $
+ Revision 1.29 2003/12/17 20:35:38 kans
+ initialize status, send NORMAL_STYLE to SeqEntrytoGnbk instead of 0 (also fixed in asn2gnbk), pass lookup flags
+
+ Revision 1.28 2003/11/19 16:35:19 yaschenk
+ relaxing ranges for -g and -c
+
Revision 1.27 2003/03/28 18:48:39 yaschenk
tuning ObjMgr, adding STREAM_SEQ_PORT_FIRST to SeqEntryToGnbk
@@ -190,14 +196,14 @@ Args myargs[] = {
2 - get SeqIds\n\t\t\t\
3 - get gi historyn (sequence change only)\n\t\t\t\
4 - get gi revision history (any change to asn.1)\n", "0","0","4",TRUE,'i',ARG_INT,0.0,0,NULL},
- {"GI id for single Entity to dump" ,"0","0","99999999",TRUE,'g',ARG_INT,0.0,0,NULL},
+ {"GI id for single Entity to dump" ,"0","0","999999999",TRUE,'g',ARG_INT,0.0,0,NULL},
{"File with list of gi's, accessions, accession.version's, fasta seqid's to dump",NULL,NULL,NULL,TRUE,'G',ARG_FILE_IN,0.0,0,NULL},
{"Max complexity:\t\
0 - get the whole blob\n\t\t\t\
1 - get the bioseq of interest\n\t\t\t\
2 - get the minimal bioseq-set containing the bioseq of interest\n\t\t\t\
3 - get the minimal nuc-prot containing the bioseq of interest\n\t\t\t\
-4 - get the minimal pub-set containing the bioseq of interest\n" ,"0","0","4",TRUE,'c',ARG_INT,0.0,0,NULL},
+4 - get the minimal pub-set containing the bioseq of interest\n" ,"0",NULL,NULL,TRUE,'c',ARG_INT,0.0,0,NULL},
{"flaTtened SeqId, format: \n \'type(name,accession,release,version)\'\n as \'5(HUMHBB)\' or \n type=accession, or \n type:number ",
NULL,NULL,NULL,TRUE,'f',ARG_STRING,0.0,0,NULL},
{"Fasta style SeqId ENCLOSED IN QUOTES:\n\t\t\t\
@@ -857,7 +863,7 @@ static Boolean ProcessOneDocSum (Int4 num, Int4Ptr uids)
static Boolean IdFetch_func(Int4 gi,CharPtr db, Int4 ent,Int2 maxplex)
{
SeqEntryPtr sep=NULL;
- Int4 status,gi_state;
+ Int4 status = 0,gi_state;
SeqIdPtr sip_ret=NULL;
SeqId si={SEQID_GI,0,0};
ID1SeqHistPtr ishp=NULL;
@@ -991,7 +997,8 @@ static Boolean IdFetch_func(Int4 gi,CharPtr db, Int4 ent,Int2 maxplex)
if(!SeqEntryToFlat(sep, fp, GENBANK_FMT, RELEASE_MODE)){
#else
AssignIDsInEntity(0,OBJ_SEQENTRY,sep);
- if(!SeqEntryToGnbk(sep,NULL,GENBANK_FMT,ENTREZ_MODE,0,SHOW_CONTIG_FEATURES|ONLY_NEAR_FEATURES,STREAM_SEQ_PORT_FIRST,0,NULL,fp)){
+ if(!SeqEntryToGnbk(sep,NULL,GENBANK_FMT,ENTREZ_MODE,0,SHOW_CONTIG_FEATURES|ONLY_NEAR_FEATURES,
+ LOOKUP_FAR_COMPONENTS|LOOKUP_FAR_LOCATIONS|LOOKUP_FAR_PRODUCTS|LOOKUP_FAR_HISTORY|STREAM_SEQ_PORT_FIRST,0,NULL,fp)){
#endif
ErrPostEx(SEV_WARNING,0,0,
"GenBank Format does not exist for this sequence ");
@@ -1004,7 +1011,8 @@ static Boolean IdFetch_func(Int4 gi,CharPtr db, Int4 ent,Int2 maxplex)
if(!SeqEntryToFlat(sep, fp, GENPEPT_FMT, RELEASE_MODE))
#else
AssignIDsInEntity(0,OBJ_SEQENTRY,sep);
- if(!SeqEntryToGnbk(sep,NULL,GENPEPT_FMT,ENTREZ_MODE,0,SHOW_CONTIG_FEATURES|ONLY_NEAR_FEATURES,STREAM_SEQ_PORT_FIRST,0,NULL,fp))
+ if(!SeqEntryToGnbk(sep,NULL,GENPEPT_FMT,ENTREZ_MODE,0,SHOW_CONTIG_FEATURES|ONLY_NEAR_FEATURES,
+ LOOKUP_FAR_COMPONENTS|LOOKUP_FAR_LOCATIONS|LOOKUP_FAR_PRODUCTS|LOOKUP_FAR_HISTORY|STREAM_SEQ_PORT_FIRST,0,NULL,fp))
#endif
{
ErrPostEx(SEV_WARNING,0,0,
diff --git a/network/id2arch/id2.asn b/network/id2arch/id2.asn
new file mode 100644
index 00000000..f85764af
--- /dev/null
+++ b/network/id2arch/id2.asn
@@ -0,0 +1,341 @@
+--$Revision: 1.6 $
+--********************************************************************
+--
+-- Network Id server network access
+-- Vasilchenko 2003
+--
+--
+--*********************************************************************
+--
+-- ID2.asn
+--
+-- messages for id server network access
+--
+--*********************************************************************
+
+NCBI-ID2Access DEFINITIONS ::=
+BEGIN
+
+IMPORTS Seq-id, Seq-loc FROM NCBI-Seqloc
+ ID2S-Chunk-Id FROM NCBI-Seq-split;
+
+
+----------------------------------------------------------------------------
+-- request types
+----------------------------------------------------------------------------
+
+ID2-Request-Packet ::= SEQUENCE OF ID2-Request
+
+
+ID2-Request ::= SEQUENCE {
+ -- request's serial number, can be used in asynchronic clients
+ -- server should copy it to corresponding field in reply
+ serial-number INTEGER OPTIONAL,
+
+ params ID2-Params OPTIONAL,
+
+ request CHOICE {
+ init NULL,
+ get-packages ID2-Request-Get-Packages,
+ string-to-gi ID2-Request-String-To-Gi,
+ seq-id-to-gi ID2-Request-Seq-id-To-Gi,
+ gi-to-tse-id ID2-Request-Gi-To-TSE-Id,
+ get-tse ID2-Request-Get-TSE,
+ reget-tse ID2-Request-ReGet-TSE,
+ get-chunks ID2S-Request-Get-Chunks
+ }
+}
+
+
+ID2-Request-Get-Packages ::= SEQUENCE {
+ -- return known packages from this list
+ -- if unset - return all known packages
+ names SEQUENCE OF VisibleString OPTIONAL,
+
+ -- return packages' names only
+ no-contents NULL OPTIONAL
+}
+
+
+ID2-Request-String-To-Gi ::= SEQUENCE {
+ -- requested sequence ID, can be any string
+ id VisibleString
+}
+
+
+ID2-Request-Seq-id-To-Gi ::= SEQUENCE {
+ -- requested sequence ID, can be any ID
+ seq-id Seq-id
+}
+
+
+ID2-Request-Gi-To-TSE-Id ::= SEQUENCE {
+ -- id can be supplied by inner request
+ gi CHOICE {
+ gi INTEGER,
+ string ID2-Request-String-To-Gi,
+ seq-id ID2-Request-Seq-id-To-Gi
+ },
+
+ -- return id of tse with sequence
+ sources SET OF VisibleString OPTIONAL,
+
+ -- return TSE-Ids with external references to this gi
+ external NULL OPTIONAL,
+
+ -- return in addition list of gis also resolving to this tse
+ current-gis NULL OPTIONAL
+}
+
+
+ID2-Request-Get-TSE ::= SEQUENCE {
+ -- id can be supplied by inner request
+ tse-id CHOICE {
+ tse-id ID2-TSE-Id,
+ gi SEQUENCE {
+ request ID2-Request-Gi-To-TSE-Id,
+
+ -- if this field is set, then server will not send
+ -- tses listed here
+ exclude-tses SET OF ID2-TSE-Id OPTIONAL
+ }
+ },
+
+ -- level of details requested immediately
+ -- server will send relevant chunks if TSE is splitted
+ details ID2-Get-TSE-Details OPTIONAL
+}
+
+
+ID2-Request-ReGet-TSE ::= SEQUENCE {
+ tse-id ID2-TSE-Id,
+
+ -- level of details requested
+ details ID2-Get-TSE-Details OPTIONAL,
+
+ -- start offset of data to get
+ offset INTEGER
+}
+
+
+ID2S-Request-Get-Chunks ::= SEQUENCE {
+ tse-id ID2-TSE-Id,
+
+ -- requests for specific chunks of splitted blob
+ chunks SET OF ID2S-Chunk-Id
+}
+
+
+ID2-Get-TSE-Details ::= SEQUENCE {
+ location Seq-loc,
+
+ seq-class-level INTEGER DEFAULT 1,
+
+ descr-level INTEGER DEFAULT 1,
+
+ descr-type-mask INTEGER DEFAULT 0,
+
+ annot-type-mask INTEGER DEFAULT 0,
+
+ feat-type-mask INTEGER DEFAULT 0,
+
+ sequence-level ENUMERATED {
+ none (0) ,
+ seq-map (1) ,
+ seq-data (2)
+ } DEFAULT none
+}
+
+
+----------------------------------------------------------------------------
+-- reply types
+----------------------------------------------------------------------------
+
+
+ID2-Reply ::= SEQUENCE {
+ -- request's serial number, copy from request
+ serial-number INTEGER OPTIONAL,
+
+ params ID2-Params OPTIONAL,
+
+ reply CHOICE {
+ init NULL,
+ get-package ID2-Reply-Get-Package,
+ -- string-to-gi ID2-Reply-String-To-Gi,
+ seq-id-to-gi ID2-Reply-Seq-id-To-Gi,
+ gi-to-tse-id ID2-Reply-Gi-To-TSE-Id,
+ get-tse ID2-Reply-Get-TSE,
+ get-tse-info ID2S-Reply-Get-TSE-Info,
+ get-chunk ID2S-Reply-Get-Chunk
+ },
+
+ error SEQUENCE OF ID2-Error OPTIONAL,
+
+ -- true if this reply is the last one for the request
+ -- false if more replies will follow
+ end-of-reply BOOLEAN
+}
+
+
+ID2-Error ::= SEQUENCE {
+ severity ENUMERATED {
+ -- nothing harmful happened
+ warning (1) ,
+
+ -- command cannot be completed this time
+ failed-command (2) ,
+
+ -- connection cannot be reused, reconnect is required
+ failed-connection (3) ,
+
+ -- server cannot be used for a while
+ failed-server (4) ,
+
+ -- resolve request gives no data
+ -- probably temporarily (see retry-delay field)
+ no-data (5) ,
+
+ -- data exists but client doesn't have permission to get it
+ restricted-data (6) ,
+
+ -- this request type is not supported by server
+ unsupported-command (7) ,
+
+ -- error in request packet, cannot retry
+ invalid-arguments (8)
+ },
+
+ -- client may retry the request after specified time in seconds
+ retry-delay INTEGER OPTIONAL,
+
+ message VisibleString OPTIONAL
+}
+
+
+ID2-Reply-Get-Package ::= SEQUENCE {
+ name VisibleString,
+
+ params ID2-Params OPTIONAL
+}
+
+
+ID2-Reply-Seq-id-To-Gi ::= SEQUENCE {
+ -- request sequence ID, copy from request
+ seq-id Seq-id,
+
+ -- gi of requested Seq-id
+ -- not set if error occured
+ gi INTEGER OPTIONAL
+}
+
+
+ID2-Reply-Gi-To-TSE-Id ::= SEQUENCE {
+ gi INTEGER,
+
+ -- source name of this tse set
+ -- "" for native tse - tse with sequence
+ source VisibleString DEFAULT "",
+
+ -- tse set with requested gi
+ -- not set if error occured
+ tses SET OF ID2-TSE-Id-Info OPTIONAL
+}
+
+
+ID2-TSE-Id-Info ::= SEQUENCE {
+ tse-id ID2-TSE-Id,
+
+ -- version of split data
+ -- (0 for non split)
+ split-version INTEGER DEFAULT 0
+}
+
+
+ID2-Reply-Get-TSE ::= SEQUENCE {
+ tse-id ID2-TSE-Id,
+
+ -- whole tse or tse skeleton
+ -- not set if error occured
+ data ID2-Reply-Data OPTIONAL
+}
+
+
+ID2S-Reply-Get-TSE-Info ::= SEQUENCE {
+ tse-id ID2-TSE-Id,
+
+ -- version of split data
+ split-version INTEGER,
+
+ -- tse split info
+ -- not set if error occured
+ info ID2-Reply-Data OPTIONAL
+}
+
+
+ID2S-Reply-Get-Chunk ::= SEQUENCE {
+ tse-id ID2-TSE-Id,
+
+ chunk-id ID2S-Chunk-Id,
+
+ -- chunk data
+ -- not set if error occured
+ data ID2-Reply-Data OPTIONAL
+}
+
+
+ID2-Reply-Data ::= SEQUENCE {
+ data-type INTEGER, -- index of negotiated types
+ -- recommended types
+ -- Seq-entry,
+ -- ID2S-Split-Info,
+ -- ID2S-Chunk
+
+ -- serialization format (ASN.1 binary, ASN.1 text)
+ data-format INTEGER, -- index of negotiated formats
+
+ -- post serialization compression (plain, gzip, etc.)
+ data-compression INTEGER, -- index of negotiated formats
+
+ -- data blob
+ data SEQUENCE OF OCTET STRING
+}
+
+
+----------------------------------------------------------------------------
+-- utility types
+----------------------------------------------------------------------------
+
+
+ID2-TSE-Id ::= SEQUENCE {
+ sat INTEGER,
+ sat-key INTEGER
+}
+
+
+ID2-Params ::= SEQUENCE OF ID2-Param
+
+
+ID2-Param ::= SEQUENCE {
+ name VisibleString,
+ value SEQUENCE OF VisibleString OPTIONAL,
+ type ENUMERATED {
+ -- no response expected
+ set-value (1) ,
+
+ -- this option is for client only
+ -- server replies with its value of param if known
+ -- server omits this param in reply if unknown to server
+ get-value (2) ,
+
+ -- no direct response expected,
+ -- but if the param or its value is not supported
+ -- an error is reported and the request is not be completed
+ force-value (3) ,
+
+ -- use named package
+ -- value should be unset
+ use-package (4)
+ } DEFAULT set-value
+}
+
+END
diff --git a/network/id2arch/id2.c b/network/id2arch/id2.c
new file mode 100644
index 00000000..8a96fe8d
--- /dev/null
+++ b/network/id2arch/id2.c
@@ -0,0 +1,8013 @@
+#include <asn.h>
+
+#define NLM_GENERATED_CODE_PROTO
+
+#include <id2map.h>
+#include <id2gen.h>
+
+static Boolean loaded = FALSE;
+
+#include <id2.h>
+
+#ifndef NLM_EXTERN_LOADS
+#define NLM_EXTERN_LOADS {}
+#endif
+
+NLM_EXTERN Boolean LIBCALL
+id2genAsnLoad(void)
+{
+
+ if ( ! loaded) {
+ NLM_EXTERN_LOADS
+
+ if ( ! AsnLoad ())
+ return FALSE;
+ loaded = TRUE;
+ }
+
+ return TRUE;
+}
+
+
+
+/**************************************************
+* Generated object loaders for Module NCBI-ID2Access
+* Generated using ASNCODE Revision: 6.0 at Dec 15, 2003 5:08 PM
+*
+**************************************************/
+
+
+/**************************************************
+*
+* ID2RequestPacketFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestPacketPtr LIBCALL
+ID2RequestPacketFree(ID2RequestPacketPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericUserSeqOfFree(ptr, (AsnOptFreeFunc) ID2RequestFree);
+ return NULL;
+}
+
+
+/**************************************************
+*
+* ID2RequestPacketAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestPacketPtr LIBCALL
+ID2RequestPacketAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2RequestPacketPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2RequestPacket ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_PACKET);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_PACKET);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ func = NULL;
+
+ ptr = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2RequestAsnRead, (AsnOptFreeFunc) ID2RequestFree);
+ if (isError && ptr == NULL) {
+ goto erret;
+ }
+
+
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2RequestPacketFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestPacketAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2RequestPacketAsnWrite(ID2RequestPacketPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST_PACKET); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) ID2RequestAsnWrite, aip, atp, ID2_REQUEST_PACKET_E);
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestPtr LIBCALL
+ID2RequestNew(void)
+{
+ ID2RequestPtr ptr = MemNew((size_t) sizeof(ID2Request));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2RequestFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestPtr LIBCALL
+ID2RequestFree(ID2RequestPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2ParamsFree(ptr -> params);
+ Request_requestFree(ptr -> Request_request);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* Request_requestFree()
+*
+**************************************************/
+static
+Request_requestPtr LIBCALL
+Request_requestFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case Request_request_get_packages:
+ ID2RequestGetPackagesFree(anp -> data.ptrvalue);
+ break;
+ case Request_request_string_to_gi:
+ ID2RequestStringToGiFree(anp -> data.ptrvalue);
+ break;
+ case Request_request_seq_id_to_gi:
+ ID2RequestSeqIdToGiFree(anp -> data.ptrvalue);
+ break;
+ case Request_request_gi_to_tse_id:
+ ID2RequestGiToTSEIdFree(anp -> data.ptrvalue);
+ break;
+ case Request_request_get_tse:
+ ID2RequestGetTSEFree(anp -> data.ptrvalue);
+ break;
+ case Request_request_reget_tse:
+ ID2RequestReGetTSEFree(anp -> data.ptrvalue);
+ break;
+ case Request_request_get_chunks:
+ ID2SRequestGetChunksFree(anp -> data.ptrvalue);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* ID2RequestAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestPtr LIBCALL
+ID2RequestAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2RequestPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2Request ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2RequestNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REQUEST_serial_number) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> serial_number = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REQUEST_params) {
+ ptr -> params = ID2ParamsAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REQUEST_request) {
+ ptr -> Request_request = Request_requestAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2RequestFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* Request_requestAsnRead()
+*
+**************************************************/
+static
+Request_requestPtr LIBCALL
+Request_requestAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError = FALSE;
+ Boolean nullIsError = FALSE;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* Request_request ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_request);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_request); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == ID2_REQUEST_request_init) {
+ choice = Request_request_init;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.boolvalue = av.boolvalue;
+ }
+ else if (atp == REQUEST_request_get_packages) {
+ choice = Request_request_get_packages;
+ func = (AsnReadFunc) ID2RequestGetPackagesAsnRead;
+ }
+ else if (atp == REQUEST_request_string_to_gi) {
+ choice = Request_request_string_to_gi;
+ func = (AsnReadFunc) ID2RequestStringToGiAsnRead;
+ }
+ else if (atp == REQUEST_request_seq_id_to_gi) {
+ choice = Request_request_seq_id_to_gi;
+ func = (AsnReadFunc) ID2RequestSeqIdToGiAsnRead;
+ }
+ else if (atp == REQUEST_request_gi_to_tse_id) {
+ choice = Request_request_gi_to_tse_id;
+ func = (AsnReadFunc) ID2RequestGiToTSEIdAsnRead;
+ }
+ else if (atp == ID2_REQUEST_request_get_tse) {
+ choice = Request_request_get_tse;
+ func = (AsnReadFunc) ID2RequestGetTSEAsnRead;
+ }
+ else if (atp == ID2_REQUEST_request_reget_tse) {
+ choice = Request_request_reget_tse;
+ func = (AsnReadFunc) ID2RequestReGetTSEAsnRead;
+ }
+ else if (atp == ID2_REQUEST_request_get_chunks) {
+ choice = Request_request_get_chunks;
+ func = (AsnReadFunc) ID2SRequestGetChunksAsnRead;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (aip -> io_failure) goto erret;
+
+ if (nullIsError && anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ aip -> io_failure = TRUE;
+ goto ret;
+}
+
+
+/**************************************************
+*
+* ID2RequestAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2RequestAsnWrite(ID2RequestPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> serial_number;
+ retval = AsnWrite(aip, ID2_REQUEST_serial_number, &av);
+ if (ptr -> params != NULL) {
+ if ( ! ID2ParamsAsnWrite(ptr -> params, aip, ID2_REQUEST_params)) {
+ goto erret;
+ }
+ }
+ if (ptr -> Request_request != NULL) {
+ if ( ! Request_requestAsnWrite(ptr -> Request_request, aip, ID2_REQUEST_request)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* Request_requestAsnWrite()
+*
+**************************************************/
+static Boolean LIBCALL
+Request_requestAsnWrite(Request_requestPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, ID2_REQUEST_request); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ case Request_request_init:
+ av.boolvalue = anp->data.boolvalue;
+ retval = AsnWrite(aip, ID2_REQUEST_request_init, &av);
+ break;
+ case Request_request_get_packages:
+ writetype = REQUEST_request_get_packages;
+ func = (AsnWriteFunc) ID2RequestGetPackagesAsnWrite;
+ break;
+ case Request_request_string_to_gi:
+ writetype = REQUEST_request_string_to_gi;
+ func = (AsnWriteFunc) ID2RequestStringToGiAsnWrite;
+ break;
+ case Request_request_seq_id_to_gi:
+ writetype = REQUEST_request_seq_id_to_gi;
+ func = (AsnWriteFunc) ID2RequestSeqIdToGiAsnWrite;
+ break;
+ case Request_request_gi_to_tse_id:
+ writetype = REQUEST_request_gi_to_tse_id;
+ func = (AsnWriteFunc) ID2RequestGiToTSEIdAsnWrite;
+ break;
+ case Request_request_get_tse:
+ writetype = ID2_REQUEST_request_get_tse;
+ func = (AsnWriteFunc) ID2RequestGetTSEAsnWrite;
+ break;
+ case Request_request_reget_tse:
+ writetype = ID2_REQUEST_request_reget_tse;
+ func = (AsnWriteFunc) ID2RequestReGetTSEAsnWrite;
+ break;
+ case Request_request_get_chunks:
+ writetype = ID2_REQUEST_request_get_chunks;
+ func = (AsnWriteFunc) ID2SRequestGetChunksAsnWrite;
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* ID2ParamsFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ParamsPtr LIBCALL
+ID2ParamsFree(ID2ParamsPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericUserSeqOfFree(ptr, (AsnOptFreeFunc) ID2ParamFree);
+ return NULL;
+}
+
+
+/**************************************************
+*
+* ID2ParamsAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ParamsPtr LIBCALL
+ID2ParamsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ParamsPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2Params ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_PARAMS);
+ } else {
+ atp = AsnLinkType(orig, ID2_PARAMS);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ func = NULL;
+
+ ptr = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2ParamAsnRead, (AsnOptFreeFunc) ID2ParamFree);
+ if (isError && ptr == NULL) {
+ goto erret;
+ }
+
+
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ParamsFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2ParamsAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ParamsAsnWrite(ID2ParamsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_PARAMS); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) ID2ParamAsnWrite, aip, atp, ID2_PARAMS_E);
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestGetPackagesNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGetPackagesPtr LIBCALL
+ID2RequestGetPackagesNew(void)
+{
+ ID2RequestGetPackagesPtr ptr = MemNew((size_t) sizeof(ID2RequestGetPackages));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2RequestGetPackagesFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGetPackagesPtr LIBCALL
+ID2RequestGetPackagesFree(ID2RequestGetPackagesPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericBaseSeqOfFree(ptr -> names ,ASNCODE_PTRVAL_SLOT);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2RequestGetPackagesAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGetPackagesPtr LIBCALL
+ID2RequestGetPackagesAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2RequestGetPackagesPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2RequestGetPackages ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_GET_PACKAGES);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_GET_PACKAGES);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2RequestGetPackagesNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REQUEST_GET_PACKAGES_names) {
+ ptr -> names = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
+ if (isError && ptr -> names == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == GET_PACKAGES_no_contents) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> no_contents = av.boolvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2RequestGetPackagesFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestGetPackagesAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2RequestGetPackagesAsnWrite(ID2RequestGetPackagesPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST_GET_PACKAGES); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ retval = AsnGenericBaseSeqOfAsnWrite(ptr -> names ,ASNCODE_PTRVAL_SLOT, aip, ID2_REQUEST_GET_PACKAGES_names, REQUEST_GET_PACKAGES_names_E);
+ av.boolvalue = ptr -> no_contents;
+ retval = AsnWrite(aip, GET_PACKAGES_no_contents, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestStringToGiNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestStringToGiPtr LIBCALL
+ID2RequestStringToGiNew(void)
+{
+ ID2RequestStringToGiPtr ptr = MemNew((size_t) sizeof(ID2RequestStringToGi));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2RequestStringToGiFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestStringToGiPtr LIBCALL
+ID2RequestStringToGiFree(ID2RequestStringToGiPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ MemFree(ptr -> id);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2RequestStringToGiAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestStringToGiPtr LIBCALL
+ID2RequestStringToGiAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2RequestStringToGiPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2RequestStringToGi ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_STRING_TO_GI);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_STRING_TO_GI);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2RequestStringToGiNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REQUEST_STRING_TO_GI_id) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> id = av.ptrvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2RequestStringToGiFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestStringToGiAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2RequestStringToGiAsnWrite(ID2RequestStringToGiPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST_STRING_TO_GI); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> id != NULL) {
+ av.ptrvalue = ptr -> id;
+ retval = AsnWrite(aip, ID2_REQUEST_STRING_TO_GI_id, &av);
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestSeqIdToGiNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestSeqIdToGiPtr LIBCALL
+ID2RequestSeqIdToGiNew(void)
+{
+ ID2RequestSeqIdToGiPtr ptr = MemNew((size_t) sizeof(ID2RequestSeqIdToGi));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2RequestSeqIdToGiFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestSeqIdToGiPtr LIBCALL
+ID2RequestSeqIdToGiFree(ID2RequestSeqIdToGiPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ SeqIdFree(ptr -> seq_id);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2RequestSeqIdToGiAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestSeqIdToGiPtr LIBCALL
+ID2RequestSeqIdToGiAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2RequestSeqIdToGiPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2RequestSeqIdToGi ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_SEQ_ID_TO_GI);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_SEQ_ID_TO_GI);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2RequestSeqIdToGiNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REQUEST_SEQ_ID_TO_GI_seq_id) {
+ ptr -> seq_id = SeqIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2RequestSeqIdToGiFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestSeqIdToGiAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2RequestSeqIdToGiAsnWrite(ID2RequestSeqIdToGiPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST_SEQ_ID_TO_GI); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> seq_id != NULL) {
+ if ( ! SeqIdAsnWrite(ptr -> seq_id, aip, ID2_REQUEST_SEQ_ID_TO_GI_seq_id)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestGiToTSEIdNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGiToTSEIdPtr LIBCALL
+ID2RequestGiToTSEIdNew(void)
+{
+ ID2RequestGiToTSEIdPtr ptr = MemNew((size_t) sizeof(ID2RequestGiToTSEId));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2RequestGiToTSEIdFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGiToTSEIdPtr LIBCALL
+ID2RequestGiToTSEIdFree(ID2RequestGiToTSEIdPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ Gi_giFree(ptr -> Gi_gi);
+ AsnGenericBaseSeqOfFree(ptr -> sources ,ASNCODE_PTRVAL_SLOT);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* Gi_giFree()
+*
+**************************************************/
+static
+Gi_giPtr LIBCALL
+Gi_giFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case Gi_gi_string:
+ ID2RequestStringToGiFree(anp -> data.ptrvalue);
+ break;
+ case Gi_gi_seq_id:
+ ID2RequestSeqIdToGiFree(anp -> data.ptrvalue);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* ID2RequestGiToTSEIdAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGiToTSEIdPtr LIBCALL
+ID2RequestGiToTSEIdAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2RequestGiToTSEIdPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2RequestGiToTSEId ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_GI_TO_TSE_ID);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_GI_TO_TSE_ID);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2RequestGiToTSEIdNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REQUEST_GI_TO_TSE_ID_gi) {
+ ptr -> Gi_gi = Gi_giAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == REQUEST_GI_TO_TSE_ID_sources) {
+ ptr -> sources = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
+ if (isError && ptr -> sources == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == REQUEST_GI_TO_TSE_ID_external) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> external = av.boolvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == GI_TO_TSE_ID_current_gis) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> current_gis = av.boolvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2RequestGiToTSEIdFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* Gi_giAsnRead()
+*
+**************************************************/
+static
+Gi_giPtr LIBCALL
+Gi_giAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError = FALSE;
+ Boolean nullIsError = FALSE;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* Gi_gi ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_GI_TO_TSE_ID_gi);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_GI_TO_TSE_ID_gi); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == ID2_REQUEST_GI_TO_TSE_ID_gi_gi) {
+ choice = Gi_gi_gi;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ else if (atp == REQUEST_GI_TO_TSE_ID_gi_string) {
+ choice = Gi_gi_string;
+ func = (AsnReadFunc) ID2RequestStringToGiAsnRead;
+ }
+ else if (atp == REQUEST_GI_TO_TSE_ID_gi_seq_id) {
+ choice = Gi_gi_seq_id;
+ func = (AsnReadFunc) ID2RequestSeqIdToGiAsnRead;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (aip -> io_failure) goto erret;
+
+ if (nullIsError && anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ aip -> io_failure = TRUE;
+ goto ret;
+}
+
+
+/**************************************************
+*
+* ID2RequestGiToTSEIdAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2RequestGiToTSEIdAsnWrite(ID2RequestGiToTSEIdPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST_GI_TO_TSE_ID); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> Gi_gi != NULL) {
+ if ( ! Gi_giAsnWrite(ptr -> Gi_gi, aip, ID2_REQUEST_GI_TO_TSE_ID_gi)) {
+ goto erret;
+ }
+ }
+ retval = AsnGenericBaseSeqOfAsnWrite(ptr -> sources ,ASNCODE_PTRVAL_SLOT, aip, REQUEST_GI_TO_TSE_ID_sources, REQUEST_GI_TO_TSE_ID_sources_E);
+ av.boolvalue = ptr -> external;
+ retval = AsnWrite(aip, REQUEST_GI_TO_TSE_ID_external, &av);
+ av.boolvalue = ptr -> current_gis;
+ retval = AsnWrite(aip, GI_TO_TSE_ID_current_gis, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* Gi_giAsnWrite()
+*
+**************************************************/
+static Boolean LIBCALL
+Gi_giAsnWrite(Gi_giPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, ID2_REQUEST_GI_TO_TSE_ID_gi); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ case Gi_gi_gi:
+ av.intvalue = anp->data.intvalue;
+ retval = AsnWrite(aip, ID2_REQUEST_GI_TO_TSE_ID_gi_gi, &av);
+ break;
+ case Gi_gi_string:
+ writetype = REQUEST_GI_TO_TSE_ID_gi_string;
+ func = (AsnWriteFunc) ID2RequestStringToGiAsnWrite;
+ break;
+ case Gi_gi_seq_id:
+ writetype = REQUEST_GI_TO_TSE_ID_gi_seq_id;
+ func = (AsnWriteFunc) ID2RequestSeqIdToGiAsnWrite;
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* ID2RequestGetTSENew()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGetTSEPtr LIBCALL
+ID2RequestGetTSENew(void)
+{
+ ID2RequestGetTSEPtr ptr = MemNew((size_t) sizeof(ID2RequestGetTSE));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* TseId_giNew()
+*
+**************************************************/
+static
+TseId_giPtr LIBCALL
+TseId_giNew(void)
+{
+ TseId_giPtr ptr = MemNew((size_t) sizeof(TseId_gi));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2RequestGetTSEFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGetTSEPtr LIBCALL
+ID2RequestGetTSEFree(ID2RequestGetTSEPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ TseId_tse_idFree(ptr -> TseId_tse_id);
+ ID2GetTSEDetailsFree(ptr -> details);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* TseId_tse_idFree()
+*
+**************************************************/
+static
+TseId_tse_idPtr LIBCALL
+TseId_tse_idFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case TseId_tse_id_tse_id:
+ ID2TSEIdFree(anp -> data.ptrvalue);
+ break;
+ case TseId_tse_id_TseId_Gi:
+ TseId_giFree(anp -> data.ptrvalue);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* TseId_giFree()
+*
+**************************************************/
+static
+TseId_giPtr LIBCALL
+TseId_giFree(TseId_giPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2RequestGiToTSEIdFree(ptr -> request);
+ AsnGenericUserSeqOfFree(ptr -> exclude_tses, (AsnOptFreeFunc) ID2TSEIdFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2RequestGetTSEAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestGetTSEPtr LIBCALL
+ID2RequestGetTSEAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2RequestGetTSEPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2RequestGetTSE ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_GET_TSE);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_GET_TSE);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2RequestGetTSENew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REQUEST_GET_TSE_tse_id) {
+ ptr -> TseId_tse_id = TseId_tse_idAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REQUEST_GET_TSE_details) {
+ ptr -> details = ID2GetTSEDetailsAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2RequestGetTSEFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* TseId_tse_idAsnRead()
+*
+**************************************************/
+static
+TseId_tse_idPtr LIBCALL
+TseId_tse_idAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError = FALSE;
+ Boolean nullIsError = FALSE;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* TseId_tse_id ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_GET_TSE_tse_id);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_GET_TSE_tse_id); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == REQUEST_GET_TSE_tse_id_tse_id) {
+ choice = TseId_tse_id_tse_id;
+ func = (AsnReadFunc) ID2TSEIdAsnRead;
+ }
+ else if (atp == ID2_REQUEST_GET_TSE_tse_id_gi) {
+ choice = TseId_tse_id_TseId_Gi;
+ func = (AsnReadFunc) TseId_giAsnRead;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (aip -> io_failure) goto erret;
+
+ if (nullIsError && anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ aip -> io_failure = TRUE;
+ goto ret;
+}
+
+
+/**************************************************
+*
+* TseId_giAsnRead()
+*
+**************************************************/
+static
+TseId_giPtr LIBCALL
+TseId_giAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ TseId_giPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* TseId_gi ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_GET_TSE_tse_id_gi);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_GET_TSE_tse_id_gi);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = TseId_giNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == GET_TSE_tse_id_gi_request) {
+ ptr -> request = ID2RequestGiToTSEIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == GET_TSE_tse_id_gi_exclude_tses) {
+ ptr -> exclude_tses = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2TSEIdAsnRead, (AsnOptFreeFunc) ID2TSEIdFree);
+ if (isError && ptr -> exclude_tses == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = TseId_giFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestGetTSEAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2RequestGetTSEAsnWrite(ID2RequestGetTSEPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST_GET_TSE); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> TseId_tse_id != NULL) {
+ if ( ! TseId_tse_idAsnWrite(ptr -> TseId_tse_id, aip, ID2_REQUEST_GET_TSE_tse_id)) {
+ goto erret;
+ }
+ }
+ if (ptr -> details != NULL) {
+ if ( ! ID2GetTSEDetailsAsnWrite(ptr -> details, aip, ID2_REQUEST_GET_TSE_details)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* TseId_tse_idAsnWrite()
+*
+**************************************************/
+static Boolean LIBCALL
+TseId_tse_idAsnWrite(TseId_tse_idPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, ID2_REQUEST_GET_TSE_tse_id); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ case TseId_tse_id_tse_id:
+ writetype = REQUEST_GET_TSE_tse_id_tse_id;
+ func = (AsnWriteFunc) ID2TSEIdAsnWrite;
+ break;
+ case TseId_tse_id_TseId_Gi:
+ writetype = ID2_REQUEST_GET_TSE_tse_id_gi;
+ func = (AsnWriteFunc) TseId_giAsnWrite;
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* TseId_giAsnWrite()
+*
+**************************************************/
+static Boolean LIBCALL
+TseId_giAsnWrite(TseId_giPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST_GET_TSE_tse_id_gi); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> request != NULL) {
+ if ( ! ID2RequestGiToTSEIdAsnWrite(ptr -> request, aip, GET_TSE_tse_id_gi_request)) {
+ goto erret;
+ }
+ }
+ AsnGenericUserSeqOfAsnWrite(ptr -> exclude_tses, (AsnWriteFunc) ID2TSEIdAsnWrite, aip, GET_TSE_tse_id_gi_exclude_tses, TSE_tse_id_gi_exclude_tses_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestReGetTSENew()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestReGetTSEPtr LIBCALL
+ID2RequestReGetTSENew(void)
+{
+ ID2RequestReGetTSEPtr ptr = MemNew((size_t) sizeof(ID2RequestReGetTSE));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2RequestReGetTSEFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestReGetTSEPtr LIBCALL
+ID2RequestReGetTSEFree(ID2RequestReGetTSEPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2TSEIdFree(ptr -> tse_id);
+ ID2GetTSEDetailsFree(ptr -> details);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2RequestReGetTSEAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2RequestReGetTSEPtr LIBCALL
+ID2RequestReGetTSEAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2RequestReGetTSEPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2RequestReGetTSE ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REQUEST_REGET_TSE);
+ } else {
+ atp = AsnLinkType(orig, ID2_REQUEST_REGET_TSE);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2RequestReGetTSENew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REQUEST_REGET_TSE_tse_id) {
+ ptr -> tse_id = ID2TSEIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REQUEST_REGET_TSE_details) {
+ ptr -> details = ID2GetTSEDetailsAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REQUEST_REGET_TSE_offset) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> offset = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2RequestReGetTSEFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2RequestReGetTSEAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2RequestReGetTSEAsnWrite(ID2RequestReGetTSEPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REQUEST_REGET_TSE); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> tse_id != NULL) {
+ if ( ! ID2TSEIdAsnWrite(ptr -> tse_id, aip, ID2_REQUEST_REGET_TSE_tse_id)) {
+ goto erret;
+ }
+ }
+ if (ptr -> details != NULL) {
+ if ( ! ID2GetTSEDetailsAsnWrite(ptr -> details, aip, ID2_REQUEST_REGET_TSE_details)) {
+ goto erret;
+ }
+ }
+ av.intvalue = ptr -> offset;
+ retval = AsnWrite(aip, ID2_REQUEST_REGET_TSE_offset, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SRequestGetChunksNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SRequestGetChunksPtr LIBCALL
+ID2SRequestGetChunksNew(void)
+{
+ ID2SRequestGetChunksPtr ptr = MemNew((size_t) sizeof(ID2SRequestGetChunks));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SRequestGetChunksFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SRequestGetChunksPtr LIBCALL
+ID2SRequestGetChunksFree(ID2SRequestGetChunksPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2TSEIdFree(ptr -> tse_id);
+ AsnGenericBaseSeqOfFree(ptr -> chunks ,ASNCODE_INTVAL_SLOT);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SRequestGetChunksAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SRequestGetChunksPtr LIBCALL
+ID2SRequestGetChunksAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SRequestGetChunksPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SRequestGetChunks ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_REQUEST_GET_CHUNKS);
+ } else {
+ atp = AsnLinkType(orig, ID2S_REQUEST_GET_CHUNKS);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SRequestGetChunksNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_REQUEST_GET_CHUNKS_tse_id) {
+ ptr -> tse_id = ID2TSEIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_REQUEST_GET_CHUNKS_chunks) {
+ ptr -> chunks = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
+ if (isError && ptr -> chunks == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SRequestGetChunksFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SRequestGetChunksAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SRequestGetChunksAsnWrite(ID2SRequestGetChunksPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_REQUEST_GET_CHUNKS); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> tse_id != NULL) {
+ if ( ! ID2TSEIdAsnWrite(ptr -> tse_id, aip, ID2S_REQUEST_GET_CHUNKS_tse_id)) {
+ goto erret;
+ }
+ }
+ retval = AsnGenericBaseSeqOfAsnWrite(ptr -> chunks ,ASNCODE_INTVAL_SLOT, aip, ID2S_REQUEST_GET_CHUNKS_chunks, REQUEST_GET_CHUNKS_chunks_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2TSEIdNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2TSEIdPtr LIBCALL
+ID2TSEIdNew(void)
+{
+ ID2TSEIdPtr ptr = MemNew((size_t) sizeof(ID2TSEId));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2TSEIdFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2TSEIdPtr LIBCALL
+ID2TSEIdFree(ID2TSEIdPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2TSEIdAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2TSEIdPtr LIBCALL
+ID2TSEIdAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2TSEIdPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2TSEId ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_TSE_ID);
+ } else {
+ atp = AsnLinkType(orig, ID2_TSE_ID);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2TSEIdNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_TSE_ID_sat) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> sat = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_TSE_ID_sat_key) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> sat_key = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2TSEIdFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2TSEIdAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2TSEIdAsnWrite(ID2TSEIdPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_TSE_ID); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> sat;
+ retval = AsnWrite(aip, ID2_TSE_ID_sat, &av);
+ av.intvalue = ptr -> sat_key;
+ retval = AsnWrite(aip, ID2_TSE_ID_sat_key, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2GetTSEDetailsNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2GetTSEDetailsPtr LIBCALL
+ID2GetTSEDetailsNew(void)
+{
+ ID2GetTSEDetailsPtr ptr = MemNew((size_t) sizeof(ID2GetTSEDetails));
+
+ ptr -> seq_class_level = 1;
+ ptr -> descr_level = 1;
+ ptr -> descr_type_mask = 0;
+ ptr -> annot_type_mask = 0;
+ ptr -> feat_type_mask = 0;
+ ptr -> sequence_level = 0;
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2GetTSEDetailsFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2GetTSEDetailsPtr LIBCALL
+ID2GetTSEDetailsFree(ID2GetTSEDetailsPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2SeqLocFree(ptr -> location);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2GetTSEDetailsAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2GetTSEDetailsPtr LIBCALL
+ID2GetTSEDetailsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2GetTSEDetailsPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2GetTSEDetails ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_GET_TSE_DETAILS);
+ } else {
+ atp = AsnLinkType(orig, ID2_GET_TSE_DETAILS);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2GetTSEDetailsNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_GET_TSE_DETAILS_location) {
+ ptr -> location = ID2SeqLocAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == TSE_DETAILS_seq_class_level) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> seq_class_level = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_GET_TSE_DETAILS_descr_level) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> descr_level = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == TSE_DETAILS_descr_type_mask) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> descr_type_mask = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == TSE_DETAILS_annot_type_mask) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> annot_type_mask = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == GET_TSE_DETAILS_feat_type_mask) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> feat_type_mask = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == GET_TSE_DETAILS_sequence_level) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> sequence_level = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2GetTSEDetailsFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2GetTSEDetailsAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2GetTSEDetailsAsnWrite(ID2GetTSEDetailsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_GET_TSE_DETAILS); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> location != NULL) {
+ if ( ! ID2SeqLocAsnWrite(ptr -> location, aip, ID2_GET_TSE_DETAILS_location)) {
+ goto erret;
+ }
+ }
+ av.intvalue = ptr -> seq_class_level;
+ retval = AsnWrite(aip, TSE_DETAILS_seq_class_level, &av);
+ av.intvalue = ptr -> descr_level;
+ retval = AsnWrite(aip, ID2_GET_TSE_DETAILS_descr_level, &av);
+ av.intvalue = ptr -> descr_type_mask;
+ retval = AsnWrite(aip, TSE_DETAILS_descr_type_mask, &av);
+ av.intvalue = ptr -> annot_type_mask;
+ retval = AsnWrite(aip, TSE_DETAILS_annot_type_mask, &av);
+ av.intvalue = ptr -> feat_type_mask;
+ retval = AsnWrite(aip, GET_TSE_DETAILS_feat_type_mask, &av);
+ av.intvalue = ptr -> sequence_level;
+ retval = AsnWrite(aip, GET_TSE_DETAILS_sequence_level, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SeqLocFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SeqLocPtr LIBCALL
+ID2SeqLocFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case ID2SeqLoc_int__:
+ ID2IntervalFree(anp -> data.ptrvalue);
+ break;
+ case ID2SeqLoc_int_set:
+ ID2PackedSeqIntsFree(anp -> data.ptrvalue);
+ break;
+ case ID2SeqLoc_whole_range:
+ ID2IdRangeFree(anp -> data.ptrvalue);
+ break;
+ case ID2SeqLoc_loc_set:
+ AsnGenericChoiceSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) ID2SeqLocFree);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* ID2SeqLocAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SeqLocPtr LIBCALL
+ID2SeqLocAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError = FALSE;
+ Boolean nullIsError = FALSE;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SeqLoc ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_SEQ_LOC);
+ } else {
+ atp = AsnLinkType(orig, ID2_SEQ_LOC); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == ID2_SEQ_LOC_whole) {
+ choice = ID2SeqLoc_whole;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ else if (atp == ID2_SEQ_LOC_int__) {
+ choice = ID2SeqLoc_int__;
+ func = (AsnReadFunc) ID2IntervalAsnRead;
+ }
+ else if (atp == ID2_SEQ_LOC_int_set) {
+ choice = ID2SeqLoc_int_set;
+ func = (AsnReadFunc) ID2PackedSeqIntsAsnRead;
+ }
+ else if (atp == ID2_SEQ_LOC_whole_range) {
+ choice = ID2SeqLoc_whole_range;
+ func = (AsnReadFunc) ID2IdRangeAsnRead;
+ }
+ else if (atp == ID2_SEQ_LOC_loc_set) {
+ choice = ID2SeqLoc_loc_set;
+ anp -> data.ptrvalue =
+ AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SeqLocAsnRead, (AsnOptFreeFunc) ID2SeqLocFree);
+ if (isError && anp -> data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (aip -> io_failure) goto erret;
+
+ if (nullIsError && anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ aip -> io_failure = TRUE;
+ goto ret;
+}
+
+
+/**************************************************
+*
+* ID2SeqLocAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SeqLocAsnWrite(ID2SeqLocPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, ID2_SEQ_LOC); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ case ID2SeqLoc_whole:
+ av.intvalue = anp->data.intvalue;
+ retval = AsnWrite(aip, ID2_SEQ_LOC_whole, &av);
+ break;
+ case ID2SeqLoc_int__:
+ writetype = ID2_SEQ_LOC_int__;
+ func = (AsnWriteFunc) ID2IntervalAsnWrite;
+ break;
+ case ID2SeqLoc_int_set:
+ writetype = ID2_SEQ_LOC_int_set;
+ func = (AsnWriteFunc) ID2PackedSeqIntsAsnWrite;
+ break;
+ case ID2SeqLoc_whole_range:
+ writetype = ID2_SEQ_LOC_whole_range;
+ func = (AsnWriteFunc) ID2IdRangeAsnWrite;
+ break;
+ case ID2SeqLoc_loc_set:
+ retval = AsnGenericChoiceSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) ID2SeqLocAsnWrite, aip, ID2_SEQ_LOC_loc_set, ID2_SEQ_LOC_loc_set_E);
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* ID2ReplyNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyPtr LIBCALL
+ID2ReplyNew(void)
+{
+ ID2ReplyPtr ptr = MemNew((size_t) sizeof(ID2Reply));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2ReplyFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyPtr LIBCALL
+ID2ReplyFree(ID2ReplyPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2ParamsFree(ptr -> params);
+ Reply_replyFree(ptr -> Reply_reply);
+ AsnGenericUserSeqOfFree(ptr -> error, (AsnOptFreeFunc) ID2ErrorFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* Reply_replyFree()
+*
+**************************************************/
+static
+Reply_replyPtr LIBCALL
+Reply_replyFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case Reply_reply_get_package:
+ ID2ReplyGetPackageFree(anp -> data.ptrvalue);
+ break;
+ case Reply_reply_seq_id_to_gi:
+ ID2ReplySeqIdToGiFree(anp -> data.ptrvalue);
+ break;
+ case Reply_reply_gi_to_tse_id:
+ ID2ReplyGiToTSEIdFree(anp -> data.ptrvalue);
+ break;
+ case Reply_reply_get_tse:
+ ID2ReplyGetTSEFree(anp -> data.ptrvalue);
+ break;
+ case Reply_reply_get_tse_info:
+ ID2SReplyGetTSEInfoFree(anp -> data.ptrvalue);
+ break;
+ case Reply_reply_get_chunk:
+ ID2SReplyGetChunkFree(anp -> data.ptrvalue);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* ID2ReplyAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyPtr LIBCALL
+ID2ReplyAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ReplyPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2Reply ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REPLY);
+ } else {
+ atp = AsnLinkType(orig, ID2_REPLY);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2ReplyNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REPLY_serial_number) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> serial_number = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_params) {
+ ptr -> params = ID2ParamsAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_reply) {
+ ptr -> Reply_reply = Reply_replyAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_error) {
+ ptr -> error = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2ErrorAsnRead, (AsnOptFreeFunc) ID2ErrorFree);
+ if (isError && ptr -> error == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_end_of_reply) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> end_of_reply = av.boolvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ReplyFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* Reply_replyAsnRead()
+*
+**************************************************/
+static
+Reply_replyPtr LIBCALL
+Reply_replyAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError = FALSE;
+ Boolean nullIsError = FALSE;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* Reply_reply ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REPLY_reply);
+ } else {
+ atp = AsnLinkType(orig, ID2_REPLY_reply); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == ID2_REPLY_reply_init) {
+ choice = Reply_reply_init;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.boolvalue = av.boolvalue;
+ }
+ else if (atp == ID2_REPLY_reply_get_package) {
+ choice = Reply_reply_get_package;
+ func = (AsnReadFunc) ID2ReplyGetPackageAsnRead;
+ }
+ else if (atp == ID2_REPLY_reply_seq_id_to_gi) {
+ choice = Reply_reply_seq_id_to_gi;
+ func = (AsnReadFunc) ID2ReplySeqIdToGiAsnRead;
+ }
+ else if (atp == ID2_REPLY_reply_gi_to_tse_id) {
+ choice = Reply_reply_gi_to_tse_id;
+ func = (AsnReadFunc) ID2ReplyGiToTSEIdAsnRead;
+ }
+ else if (atp == ID2_REPLY_reply_get_tse) {
+ choice = Reply_reply_get_tse;
+ func = (AsnReadFunc) ID2ReplyGetTSEAsnRead;
+ }
+ else if (atp == ID2_REPLY_reply_get_tse_info) {
+ choice = Reply_reply_get_tse_info;
+ func = (AsnReadFunc) ID2SReplyGetTSEInfoAsnRead;
+ }
+ else if (atp == ID2_REPLY_reply_get_chunk) {
+ choice = Reply_reply_get_chunk;
+ func = (AsnReadFunc) ID2SReplyGetChunkAsnRead;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (aip -> io_failure) goto erret;
+
+ if (nullIsError && anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ aip -> io_failure = TRUE;
+ goto ret;
+}
+
+
+/**************************************************
+*
+* ID2ReplyAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ReplyAsnWrite(ID2ReplyPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REPLY); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> serial_number;
+ retval = AsnWrite(aip, ID2_REPLY_serial_number, &av);
+ if (ptr -> params != NULL) {
+ if ( ! ID2ParamsAsnWrite(ptr -> params, aip, ID2_REPLY_params)) {
+ goto erret;
+ }
+ }
+ if (ptr -> Reply_reply != NULL) {
+ if ( ! Reply_replyAsnWrite(ptr -> Reply_reply, aip, ID2_REPLY_reply)) {
+ goto erret;
+ }
+ }
+ AsnGenericUserSeqOfAsnWrite(ptr -> error, (AsnWriteFunc) ID2ErrorAsnWrite, aip, ID2_REPLY_error, ID2_REPLY_error_E);
+ av.boolvalue = ptr -> end_of_reply;
+ retval = AsnWrite(aip, ID2_REPLY_end_of_reply, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* Reply_replyAsnWrite()
+*
+**************************************************/
+static Boolean LIBCALL
+Reply_replyAsnWrite(Reply_replyPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, ID2_REPLY_reply); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ case Reply_reply_init:
+ av.boolvalue = anp->data.boolvalue;
+ retval = AsnWrite(aip, ID2_REPLY_reply_init, &av);
+ break;
+ case Reply_reply_get_package:
+ writetype = ID2_REPLY_reply_get_package;
+ func = (AsnWriteFunc) ID2ReplyGetPackageAsnWrite;
+ break;
+ case Reply_reply_seq_id_to_gi:
+ writetype = ID2_REPLY_reply_seq_id_to_gi;
+ func = (AsnWriteFunc) ID2ReplySeqIdToGiAsnWrite;
+ break;
+ case Reply_reply_gi_to_tse_id:
+ writetype = ID2_REPLY_reply_gi_to_tse_id;
+ func = (AsnWriteFunc) ID2ReplyGiToTSEIdAsnWrite;
+ break;
+ case Reply_reply_get_tse:
+ writetype = ID2_REPLY_reply_get_tse;
+ func = (AsnWriteFunc) ID2ReplyGetTSEAsnWrite;
+ break;
+ case Reply_reply_get_tse_info:
+ writetype = ID2_REPLY_reply_get_tse_info;
+ func = (AsnWriteFunc) ID2SReplyGetTSEInfoAsnWrite;
+ break;
+ case Reply_reply_get_chunk:
+ writetype = ID2_REPLY_reply_get_chunk;
+ func = (AsnWriteFunc) ID2SReplyGetChunkAsnWrite;
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* ID2ReplyGetPackageNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGetPackagePtr LIBCALL
+ID2ReplyGetPackageNew(void)
+{
+ ID2ReplyGetPackagePtr ptr = MemNew((size_t) sizeof(ID2ReplyGetPackage));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2ReplyGetPackageFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGetPackagePtr LIBCALL
+ID2ReplyGetPackageFree(ID2ReplyGetPackagePtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ MemFree(ptr -> name);
+ ID2ParamsFree(ptr -> params);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2ReplyGetPackageAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGetPackagePtr LIBCALL
+ID2ReplyGetPackageAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ReplyGetPackagePtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2ReplyGetPackage ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REPLY_GET_PACKAGE);
+ } else {
+ atp = AsnLinkType(orig, ID2_REPLY_GET_PACKAGE);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2ReplyGetPackageNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REPLY_GET_PACKAGE_name) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> name = av.ptrvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_GET_PACKAGE_params) {
+ ptr -> params = ID2ParamsAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ReplyGetPackageFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplyGetPackageAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ReplyGetPackageAsnWrite(ID2ReplyGetPackagePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REPLY_GET_PACKAGE); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> name != NULL) {
+ av.ptrvalue = ptr -> name;
+ retval = AsnWrite(aip, ID2_REPLY_GET_PACKAGE_name, &av);
+ }
+ if (ptr -> params != NULL) {
+ if ( ! ID2ParamsAsnWrite(ptr -> params, aip, ID2_REPLY_GET_PACKAGE_params)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplySeqIdToGiNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplySeqIdToGiPtr LIBCALL
+ID2ReplySeqIdToGiNew(void)
+{
+ ID2ReplySeqIdToGiPtr ptr = MemNew((size_t) sizeof(ID2ReplySeqIdToGi));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2ReplySeqIdToGiFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplySeqIdToGiPtr LIBCALL
+ID2ReplySeqIdToGiFree(ID2ReplySeqIdToGiPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ SeqIdFree(ptr -> seq_id);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2ReplySeqIdToGiAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplySeqIdToGiPtr LIBCALL
+ID2ReplySeqIdToGiAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ReplySeqIdToGiPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2ReplySeqIdToGi ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REPLY_SEQ_ID_TO_GI);
+ } else {
+ atp = AsnLinkType(orig, ID2_REPLY_SEQ_ID_TO_GI);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2ReplySeqIdToGiNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REPLY_SEQ_ID_TO_GI_seq_id) {
+ ptr -> seq_id = SeqIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_SEQ_ID_TO_GI_gi) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> gi = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ReplySeqIdToGiFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplySeqIdToGiAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ReplySeqIdToGiAsnWrite(ID2ReplySeqIdToGiPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REPLY_SEQ_ID_TO_GI); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> seq_id != NULL) {
+ if ( ! SeqIdAsnWrite(ptr -> seq_id, aip, ID2_REPLY_SEQ_ID_TO_GI_seq_id)) {
+ goto erret;
+ }
+ }
+ av.intvalue = ptr -> gi;
+ retval = AsnWrite(aip, ID2_REPLY_SEQ_ID_TO_GI_gi, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplyGiToTSEIdNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGiToTSEIdPtr LIBCALL
+ID2ReplyGiToTSEIdNew(void)
+{
+ ID2ReplyGiToTSEIdPtr ptr = MemNew((size_t) sizeof(ID2ReplyGiToTSEId));
+
+ ptr -> source = "0";
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2ReplyGiToTSEIdFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGiToTSEIdPtr LIBCALL
+ID2ReplyGiToTSEIdFree(ID2ReplyGiToTSEIdPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ MemFree(ptr -> source);
+ AsnGenericUserSeqOfFree(ptr -> tses, (AsnOptFreeFunc) ID2TSEIdInfoFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2ReplyGiToTSEIdAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGiToTSEIdPtr LIBCALL
+ID2ReplyGiToTSEIdAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ReplyGiToTSEIdPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2ReplyGiToTSEId ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REPLY_GI_TO_TSE_ID);
+ } else {
+ atp = AsnLinkType(orig, ID2_REPLY_GI_TO_TSE_ID);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2ReplyGiToTSEIdNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REPLY_GI_TO_TSE_ID_gi) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> gi = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_GI_TO_TSE_ID_source) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> source = av.ptrvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_GI_TO_TSE_ID_tses) {
+ ptr -> tses = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2TSEIdInfoAsnRead, (AsnOptFreeFunc) ID2TSEIdInfoFree);
+ if (isError && ptr -> tses == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ReplyGiToTSEIdFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplyGiToTSEIdAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ReplyGiToTSEIdAsnWrite(ID2ReplyGiToTSEIdPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REPLY_GI_TO_TSE_ID); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> gi;
+ retval = AsnWrite(aip, ID2_REPLY_GI_TO_TSE_ID_gi, &av);
+ if (ptr -> source != NULL) {
+ av.ptrvalue = ptr -> source;
+ retval = AsnWrite(aip, ID2_REPLY_GI_TO_TSE_ID_source, &av);
+ }
+ AsnGenericUserSeqOfAsnWrite(ptr -> tses, (AsnWriteFunc) ID2TSEIdInfoAsnWrite, aip, ID2_REPLY_GI_TO_TSE_ID_tses, ID2_REPLY_GI_TO_TSE_ID_tses_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplyGetTSENew()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGetTSEPtr LIBCALL
+ID2ReplyGetTSENew(void)
+{
+ ID2ReplyGetTSEPtr ptr = MemNew((size_t) sizeof(ID2ReplyGetTSE));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2ReplyGetTSEFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGetTSEPtr LIBCALL
+ID2ReplyGetTSEFree(ID2ReplyGetTSEPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2TSEIdFree(ptr -> tse_id);
+ ID2ReplyDataFree(ptr -> data);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2ReplyGetTSEAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyGetTSEPtr LIBCALL
+ID2ReplyGetTSEAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ReplyGetTSEPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2ReplyGetTSE ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REPLY_GET_TSE);
+ } else {
+ atp = AsnLinkType(orig, ID2_REPLY_GET_TSE);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2ReplyGetTSENew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REPLY_GET_TSE_tse_id) {
+ ptr -> tse_id = ID2TSEIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_GET_TSE_data) {
+ ptr -> data = ID2ReplyDataAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ReplyGetTSEFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplyGetTSEAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ReplyGetTSEAsnWrite(ID2ReplyGetTSEPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REPLY_GET_TSE); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> tse_id != NULL) {
+ if ( ! ID2TSEIdAsnWrite(ptr -> tse_id, aip, ID2_REPLY_GET_TSE_tse_id)) {
+ goto erret;
+ }
+ }
+ if (ptr -> data != NULL) {
+ if ( ! ID2ReplyDataAsnWrite(ptr -> data, aip, ID2_REPLY_GET_TSE_data)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SReplyGetTSEInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SReplyGetTSEInfoPtr LIBCALL
+ID2SReplyGetTSEInfoNew(void)
+{
+ ID2SReplyGetTSEInfoPtr ptr = MemNew((size_t) sizeof(ID2SReplyGetTSEInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SReplyGetTSEInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SReplyGetTSEInfoPtr LIBCALL
+ID2SReplyGetTSEInfoFree(ID2SReplyGetTSEInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2TSEIdFree(ptr -> tse_id);
+ ID2ReplyDataFree(ptr -> info);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SReplyGetTSEInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SReplyGetTSEInfoPtr LIBCALL
+ID2SReplyGetTSEInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SReplyGetTSEInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SReplyGetTSEInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_REPLY_GET_TSE_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_REPLY_GET_TSE_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SReplyGetTSEInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_REPLY_GET_TSE_INFO_tse_id) {
+ ptr -> tse_id = ID2TSEIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == GET_TSE_INFO_split_version) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> split_version = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_REPLY_GET_TSE_INFO_info) {
+ ptr -> info = ID2ReplyDataAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SReplyGetTSEInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SReplyGetTSEInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SReplyGetTSEInfoAsnWrite(ID2SReplyGetTSEInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_REPLY_GET_TSE_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> tse_id != NULL) {
+ if ( ! ID2TSEIdAsnWrite(ptr -> tse_id, aip, ID2S_REPLY_GET_TSE_INFO_tse_id)) {
+ goto erret;
+ }
+ }
+ av.intvalue = ptr -> split_version;
+ retval = AsnWrite(aip, GET_TSE_INFO_split_version, &av);
+ if (ptr -> info != NULL) {
+ if ( ! ID2ReplyDataAsnWrite(ptr -> info, aip, ID2S_REPLY_GET_TSE_INFO_info)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SReplyGetChunkNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SReplyGetChunkPtr LIBCALL
+ID2SReplyGetChunkNew(void)
+{
+ ID2SReplyGetChunkPtr ptr = MemNew((size_t) sizeof(ID2SReplyGetChunk));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SReplyGetChunkFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SReplyGetChunkPtr LIBCALL
+ID2SReplyGetChunkFree(ID2SReplyGetChunkPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2TSEIdFree(ptr -> tse_id);
+ ID2ReplyDataFree(ptr -> data);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SReplyGetChunkAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SReplyGetChunkPtr LIBCALL
+ID2SReplyGetChunkAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SReplyGetChunkPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SReplyGetChunk ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_REPLY_GET_CHUNK);
+ } else {
+ atp = AsnLinkType(orig, ID2S_REPLY_GET_CHUNK);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SReplyGetChunkNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_REPLY_GET_CHUNK_tse_id) {
+ ptr -> tse_id = ID2TSEIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_REPLY_GET_CHUNK_chunk_id) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> chunk_id = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_REPLY_GET_CHUNK_data) {
+ ptr -> data = ID2ReplyDataAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SReplyGetChunkFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SReplyGetChunkAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SReplyGetChunkAsnWrite(ID2SReplyGetChunkPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_REPLY_GET_CHUNK); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> tse_id != NULL) {
+ if ( ! ID2TSEIdAsnWrite(ptr -> tse_id, aip, ID2S_REPLY_GET_CHUNK_tse_id)) {
+ goto erret;
+ }
+ }
+ av.intvalue = ptr -> chunk_id;
+ retval = AsnWrite(aip, ID2S_REPLY_GET_CHUNK_chunk_id, &av);
+ if (ptr -> data != NULL) {
+ if ( ! ID2ReplyDataAsnWrite(ptr -> data, aip, ID2S_REPLY_GET_CHUNK_data)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2ErrorNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2ErrorPtr LIBCALL
+ID2ErrorNew(void)
+{
+ ID2ErrorPtr ptr = MemNew((size_t) sizeof(ID2Error));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2ErrorFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ErrorPtr LIBCALL
+ID2ErrorFree(ID2ErrorPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ MemFree(ptr -> message);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2ErrorAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ErrorPtr LIBCALL
+ID2ErrorAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ErrorPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2Error ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_ERROR);
+ } else {
+ atp = AsnLinkType(orig, ID2_ERROR);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2ErrorNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_ERROR_severity) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> severity = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_ERROR_retry_delay) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> retry_delay = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_ERROR_message) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> message = av.ptrvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ErrorFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2ErrorAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ErrorAsnWrite(ID2ErrorPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_ERROR); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> severity;
+ retval = AsnWrite(aip, ID2_ERROR_severity, &av);
+ av.intvalue = ptr -> retry_delay;
+ retval = AsnWrite(aip, ID2_ERROR_retry_delay, &av);
+ if (ptr -> message != NULL) {
+ av.ptrvalue = ptr -> message;
+ retval = AsnWrite(aip, ID2_ERROR_message, &av);
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2TSEIdInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2TSEIdInfoPtr LIBCALL
+ID2TSEIdInfoNew(void)
+{
+ ID2TSEIdInfoPtr ptr = MemNew((size_t) sizeof(ID2TSEIdInfo));
+
+ ptr -> split_version = 0;
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2TSEIdInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2TSEIdInfoPtr LIBCALL
+ID2TSEIdInfoFree(ID2TSEIdInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2TSEIdFree(ptr -> tse_id);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2TSEIdInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2TSEIdInfoPtr LIBCALL
+ID2TSEIdInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2TSEIdInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2TSEIdInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_TSE_ID_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2_TSE_ID_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2TSEIdInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_TSE_ID_INFO_tse_id) {
+ ptr -> tse_id = ID2TSEIdAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_TSE_ID_INFO_split_version) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> split_version = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2TSEIdInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2TSEIdInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2TSEIdInfoAsnWrite(ID2TSEIdInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_TSE_ID_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> tse_id != NULL) {
+ if ( ! ID2TSEIdAsnWrite(ptr -> tse_id, aip, ID2_TSE_ID_INFO_tse_id)) {
+ goto erret;
+ }
+ }
+ av.intvalue = ptr -> split_version;
+ retval = AsnWrite(aip, ID2_TSE_ID_INFO_split_version, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplyDataNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyDataPtr LIBCALL
+ID2ReplyDataNew(void)
+{
+ ID2ReplyDataPtr ptr = MemNew((size_t) sizeof(ID2ReplyData));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2ReplyDataFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyDataPtr LIBCALL
+ID2ReplyDataFree(ID2ReplyDataPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericBaseSeqOfFree(ptr -> data ,ASNCODE_BYTEVAL_SLOT);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2ReplyDataAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ReplyDataPtr LIBCALL
+ID2ReplyDataAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ReplyDataPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2ReplyData ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_REPLY_DATA);
+ } else {
+ atp = AsnLinkType(orig, ID2_REPLY_DATA);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2ReplyDataNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_REPLY_DATA_data_type) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> data_type = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_DATA_data_format) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> data_format = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_DATA_data_compression) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> data_compression = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_REPLY_DATA_data) {
+ ptr -> data = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_BYTEVAL_SLOT, &isError);
+ if (isError && ptr -> data == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ReplyDataFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2ReplyDataAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ReplyDataAsnWrite(ID2ReplyDataPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_REPLY_DATA); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> data_type;
+ retval = AsnWrite(aip, ID2_REPLY_DATA_data_type, &av);
+ av.intvalue = ptr -> data_format;
+ retval = AsnWrite(aip, ID2_REPLY_DATA_data_format, &av);
+ av.intvalue = ptr -> data_compression;
+ retval = AsnWrite(aip, ID2_REPLY_DATA_data_compression, &av);
+ retval = AsnGenericBaseSeqOfAsnWrite(ptr -> data ,ASNCODE_BYTEVAL_SLOT, aip, ID2_REPLY_DATA_data, ID2_REPLY_DATA_data_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SSplitInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSplitInfoPtr LIBCALL
+ID2SSplitInfoNew(void)
+{
+ ID2SSplitInfoPtr ptr = MemNew((size_t) sizeof(ID2SSplitInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SSplitInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSplitInfoPtr LIBCALL
+ID2SSplitInfoFree(ID2SSplitInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericUserSeqOfFree(ptr -> bioseqs_info, (AsnOptFreeFunc) ID2SBioseqsInfoFree);
+ AsnGenericUserSeqOfFree(ptr -> chunks, (AsnOptFreeFunc) ID2SChunkInfoFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SSplitInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSplitInfoPtr LIBCALL
+ID2SSplitInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SSplitInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SSplitInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_SPLIT_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_SPLIT_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SSplitInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_SPLIT_INFO_bioseqs_info) {
+ ptr -> bioseqs_info = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SBioseqsInfoAsnRead, (AsnOptFreeFunc) ID2SBioseqsInfoFree);
+ if (isError && ptr -> bioseqs_info == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_SPLIT_INFO_chunks) {
+ ptr -> chunks = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SChunkInfoAsnRead, (AsnOptFreeFunc) ID2SChunkInfoFree);
+ if (isError && ptr -> chunks == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SSplitInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SSplitInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SSplitInfoAsnWrite(ID2SSplitInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_SPLIT_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ AsnGenericUserSeqOfAsnWrite(ptr -> bioseqs_info, (AsnWriteFunc) ID2SBioseqsInfoAsnWrite, aip, ID2S_SPLIT_INFO_bioseqs_info, ID2S_SPLIT_INFO_bioseqs_info_E);
+ AsnGenericUserSeqOfAsnWrite(ptr -> chunks, (AsnWriteFunc) ID2SChunkInfoAsnWrite, aip, ID2S_SPLIT_INFO_chunks, ID2S_SPLIT_INFO_chunks_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SBioseqsInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SBioseqsInfoPtr LIBCALL
+ID2SBioseqsInfoNew(void)
+{
+ ID2SBioseqsInfoPtr ptr = MemNew((size_t) sizeof(ID2SBioseqsInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SBioseqsInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SBioseqsInfoPtr LIBCALL
+ID2SBioseqsInfoFree(ID2SBioseqsInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2SBioseqInfoFree(ptr -> info);
+ ID2IdRangeFree(ptr -> bioseqs);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SBioseqsInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SBioseqsInfoPtr LIBCALL
+ID2SBioseqsInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SBioseqsInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SBioseqsInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_BIOSEQS_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_BIOSEQS_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SBioseqsInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_BIOSEQS_INFO_info) {
+ ptr -> info = ID2SBioseqInfoAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_BIOSEQS_INFO_bioseqs) {
+ ptr -> bioseqs = ID2IdRangeAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SBioseqsInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SBioseqsInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SBioseqsInfoAsnWrite(ID2SBioseqsInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_BIOSEQS_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> info != NULL) {
+ if ( ! ID2SBioseqInfoAsnWrite(ptr -> info, aip, ID2S_BIOSEQS_INFO_info)) {
+ goto erret;
+ }
+ }
+ if (ptr -> bioseqs != NULL) {
+ if ( ! ID2IdRangeAsnWrite(ptr -> bioseqs, aip, ID2S_BIOSEQS_INFO_bioseqs)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SChunkInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkInfoPtr LIBCALL
+ID2SChunkInfoNew(void)
+{
+ ID2SChunkInfoPtr ptr = MemNew((size_t) sizeof(ID2SChunkInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SChunkInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkInfoPtr LIBCALL
+ID2SChunkInfoFree(ID2SChunkInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericChoiceSeqOfFree(ptr -> content, (AsnOptFreeFunc) ID2SChunkContentFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SChunkInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkInfoPtr LIBCALL
+ID2SChunkInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SChunkInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SChunkInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_CHUNK_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_CHUNK_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SChunkInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_CHUNK_INFO_id) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> id = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_CHUNK_INFO_content) {
+ ptr -> content = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SChunkContentAsnRead, (AsnOptFreeFunc) ID2SChunkContentFree);
+ if (isError && ptr -> content == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SChunkInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SChunkInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SChunkInfoAsnWrite(ID2SChunkInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_CHUNK_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> id;
+ retval = AsnWrite(aip, ID2S_CHUNK_INFO_id, &av);
+ AsnGenericChoiceSeqOfAsnWrite(ptr -> content, (AsnWriteFunc) ID2SChunkContentAsnWrite, aip, ID2S_CHUNK_INFO_content, ID2S_CHUNK_INFO_content_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SBioseqInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SBioseqInfoPtr LIBCALL
+ID2SBioseqInfoNew(void)
+{
+ ID2SBioseqInfoPtr ptr = MemNew((size_t) sizeof(ID2SBioseqInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SBioseqInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SBioseqInfoPtr LIBCALL
+ID2SBioseqInfoFree(ID2SBioseqInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ ID2SSequenceSplitInfoFree(ptr -> sequence_split);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SBioseqInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SBioseqInfoPtr LIBCALL
+ID2SBioseqInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SBioseqInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SBioseqInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_BIOSEQ_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_BIOSEQ_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SBioseqInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_BIOSEQ_INFO_gap_count) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> gap_count = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == BIOSEQ_INFO_seq_map_has_ref) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> seq_map_has_ref = av.boolvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_BIOSEQ_INFO_sequence_split) {
+ ptr -> sequence_split = ID2SSequenceSplitInfoAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SBioseqInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SBioseqInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SBioseqInfoAsnWrite(ID2SBioseqInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_BIOSEQ_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> gap_count;
+ retval = AsnWrite(aip, ID2S_BIOSEQ_INFO_gap_count, &av);
+ av.boolvalue = ptr -> seq_map_has_ref;
+ retval = AsnWrite(aip, BIOSEQ_INFO_seq_map_has_ref, &av);
+ if (ptr -> sequence_split != NULL) {
+ if ( ! ID2SSequenceSplitInfoAsnWrite(ptr -> sequence_split, aip, ID2S_BIOSEQ_INFO_sequence_split)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2IdRangeNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2IdRangePtr LIBCALL
+ID2IdRangeNew(void)
+{
+ ID2IdRangePtr ptr = MemNew((size_t) sizeof(ID2IdRange));
+
+ ptr -> count = 1;
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2IdRangeFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2IdRangePtr LIBCALL
+ID2IdRangeFree(ID2IdRangePtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2IdRangeAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2IdRangePtr LIBCALL
+ID2IdRangeAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2IdRangePtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2IdRange ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_ID_RANGE);
+ } else {
+ atp = AsnLinkType(orig, ID2_ID_RANGE);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2IdRangeNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_ID_RANGE_start) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> start = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_ID_RANGE_count) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> count = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2IdRangeFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2IdRangeAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2IdRangeAsnWrite(ID2IdRangePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_ID_RANGE); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> start;
+ retval = AsnWrite(aip, ID2_ID_RANGE_start, &av);
+ av.intvalue = ptr -> count;
+ retval = AsnWrite(aip, ID2_ID_RANGE_count, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SSequenceSplitInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSequenceSplitInfoPtr LIBCALL
+ID2SSequenceSplitInfoNew(void)
+{
+ ID2SSequenceSplitInfoPtr ptr = MemNew((size_t) sizeof(ID2SSequenceSplitInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SSequenceSplitInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSequenceSplitInfoPtr LIBCALL
+ID2SSequenceSplitInfoFree(ID2SSequenceSplitInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericBaseSeqOfFree(ptr -> chunk_blocks ,ASNCODE_INTVAL_SLOT);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SSequenceSplitInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSequenceSplitInfoPtr LIBCALL
+ID2SSequenceSplitInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SSequenceSplitInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SSequenceSplitInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_SEQUENCE_SPLIT_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_SEQUENCE_SPLIT_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SSequenceSplitInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == SEQUENCE_SPLIT_INFO_block_size) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> block_size = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == SPLIT_INFO_chunk_start) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> chunk_start = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == SPLIT_INFO_chunk_blocks) {
+ ptr -> chunk_blocks = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
+ if (isError && ptr -> chunk_blocks == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SSequenceSplitInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SSequenceSplitInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SSequenceSplitInfoAsnWrite(ID2SSequenceSplitInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_SEQUENCE_SPLIT_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> block_size;
+ retval = AsnWrite(aip, SEQUENCE_SPLIT_INFO_block_size, &av);
+ av.intvalue = ptr -> chunk_start;
+ retval = AsnWrite(aip, SPLIT_INFO_chunk_start, &av);
+ retval = AsnGenericBaseSeqOfAsnWrite(ptr -> chunk_blocks ,ASNCODE_INTVAL_SLOT, aip, SPLIT_INFO_chunk_blocks, SPLIT_INFO_chunk_blocks_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SChunkContentFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkContentPtr LIBCALL
+ID2SChunkContentFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case ID2SChunkContent_seq_descr:
+ ID2SSeqDescrInfoFree(anp -> data.ptrvalue);
+ break;
+ case ID2SChunkContent_seq_annot:
+ ID2SSeqAnnotInfoFree(anp -> data.ptrvalue);
+ break;
+ case ID2SChunkContent_seq_assembly:
+ ID2SSeqAssemblyInfoFree(anp -> data.ptrvalue);
+ break;
+ case ID2SChunkContent_seq_map:
+ ID2SeqLocFree(anp -> data.ptrvalue);
+ break;
+ case ID2SChunkContent_seq_data:
+ ID2SeqLocFree(anp -> data.ptrvalue);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* ID2SChunkContentAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkContentPtr LIBCALL
+ID2SChunkContentAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError = FALSE;
+ Boolean nullIsError = FALSE;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SChunkContent ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_CHUNK_CONTENT);
+ } else {
+ atp = AsnLinkType(orig, ID2S_CHUNK_CONTENT); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == ID2S_CHUNK_CONTENT_seq_descr) {
+ choice = ID2SChunkContent_seq_descr;
+ func = (AsnReadFunc) ID2SSeqDescrInfoAsnRead;
+ }
+ else if (atp == ID2S_CHUNK_CONTENT_seq_annot) {
+ choice = ID2SChunkContent_seq_annot;
+ func = (AsnReadFunc) ID2SSeqAnnotInfoAsnRead;
+ }
+ else if (atp == ID2S_CHUNK_CONTENT_seq_assembly) {
+ choice = ID2SChunkContent_seq_assembly;
+ func = (AsnReadFunc) ID2SSeqAssemblyInfoAsnRead;
+ }
+ else if (atp == ID2S_CHUNK_CONTENT_seq_map) {
+ choice = ID2SChunkContent_seq_map;
+ func = (AsnReadFunc) ID2SeqLocAsnRead;
+ }
+ else if (atp == ID2S_CHUNK_CONTENT_seq_data) {
+ choice = ID2SChunkContent_seq_data;
+ func = (AsnReadFunc) ID2SeqLocAsnRead;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (aip -> io_failure) goto erret;
+
+ if (nullIsError && anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ aip -> io_failure = TRUE;
+ goto ret;
+}
+
+
+/**************************************************
+*
+* ID2SChunkContentAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SChunkContentAsnWrite(ID2SChunkContentPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, ID2S_CHUNK_CONTENT); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ case ID2SChunkContent_seq_descr:
+ writetype = ID2S_CHUNK_CONTENT_seq_descr;
+ func = (AsnWriteFunc) ID2SSeqDescrInfoAsnWrite;
+ break;
+ case ID2SChunkContent_seq_annot:
+ writetype = ID2S_CHUNK_CONTENT_seq_annot;
+ func = (AsnWriteFunc) ID2SSeqAnnotInfoAsnWrite;
+ break;
+ case ID2SChunkContent_seq_assembly:
+ writetype = ID2S_CHUNK_CONTENT_seq_assembly;
+ func = (AsnWriteFunc) ID2SSeqAssemblyInfoAsnWrite;
+ break;
+ case ID2SChunkContent_seq_map:
+ writetype = ID2S_CHUNK_CONTENT_seq_map;
+ func = (AsnWriteFunc) ID2SeqLocAsnWrite;
+ break;
+ case ID2SChunkContent_seq_data:
+ writetype = ID2S_CHUNK_CONTENT_seq_data;
+ func = (AsnWriteFunc) ID2SeqLocAsnWrite;
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* ID2SSeqDescrInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqDescrInfoPtr LIBCALL
+ID2SSeqDescrInfoNew(void)
+{
+ ID2SSeqDescrInfoPtr ptr = MemNew((size_t) sizeof(ID2SSeqDescrInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SSeqDescrInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqDescrInfoPtr LIBCALL
+ID2SSeqDescrInfoFree(ID2SSeqDescrInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericUserSeqOfFree(ptr -> bioseqs, (AsnOptFreeFunc) ID2IdRangeFree);
+ AsnGenericUserSeqOfFree(ptr -> bioseq_sets, (AsnOptFreeFunc) ID2IdRangeFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SSeqDescrInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqDescrInfoPtr LIBCALL
+ID2SSeqDescrInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SSeqDescrInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SSeqDescrInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_SEQ_DESCR_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_SEQ_DESCR_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SSeqDescrInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_SEQ_DESCR_INFO_type_mask) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> type_mask = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_SEQ_DESCR_INFO_bioseqs) {
+ ptr -> bioseqs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2IdRangeAsnRead, (AsnOptFreeFunc) ID2IdRangeFree);
+ if (isError && ptr -> bioseqs == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_SEQ_DESCR_INFO_bioseq_sets) {
+ ptr -> bioseq_sets = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2IdRangeAsnRead, (AsnOptFreeFunc) ID2IdRangeFree);
+ if (isError && ptr -> bioseq_sets == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SSeqDescrInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SSeqDescrInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SSeqDescrInfoAsnWrite(ID2SSeqDescrInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_SEQ_DESCR_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> type_mask;
+ retval = AsnWrite(aip, ID2S_SEQ_DESCR_INFO_type_mask, &av);
+ AsnGenericUserSeqOfAsnWrite(ptr -> bioseqs, (AsnWriteFunc) ID2IdRangeAsnWrite, aip, ID2S_SEQ_DESCR_INFO_bioseqs, ID2S_SEQ_DESCR_INFO_bioseqs_E);
+ AsnGenericUserSeqOfAsnWrite(ptr -> bioseq_sets, (AsnWriteFunc) ID2IdRangeAsnWrite, aip, ID2S_SEQ_DESCR_INFO_bioseq_sets, SEQ_DESCR_INFO_bioseq_sets_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SSeqAnnotInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqAnnotInfoPtr LIBCALL
+ID2SSeqAnnotInfoNew(void)
+{
+ ID2SSeqAnnotInfoPtr ptr = MemNew((size_t) sizeof(ID2SSeqAnnotInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SSeqAnnotInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqAnnotInfoPtr LIBCALL
+ID2SSeqAnnotInfoFree(ID2SSeqAnnotInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ MemFree(ptr -> name);
+ AsnGenericUserSeqOfFree(ptr -> feat, (AsnOptFreeFunc) ID2SFeatTypeInfoFree);
+ ID2SeqLocFree(ptr -> seq_loc);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SSeqAnnotInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqAnnotInfoPtr LIBCALL
+ID2SSeqAnnotInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SSeqAnnotInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SSeqAnnotInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_SEQ_ANNOT_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_SEQ_ANNOT_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SSeqAnnotInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_SEQ_ANNOT_INFO_name) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> name = av.ptrvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_SEQ_ANNOT_INFO_align) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> align = av.boolvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_SEQ_ANNOT_INFO_graph) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> graph = av.boolvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_SEQ_ANNOT_INFO_feat) {
+ ptr -> feat = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SFeatTypeInfoAsnRead, (AsnOptFreeFunc) ID2SFeatTypeInfoFree);
+ if (isError && ptr -> feat == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_SEQ_ANNOT_INFO_seq_loc) {
+ ptr -> seq_loc = ID2SeqLocAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SSeqAnnotInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SSeqAnnotInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SSeqAnnotInfoAsnWrite(ID2SSeqAnnotInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_SEQ_ANNOT_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> name != NULL) {
+ av.ptrvalue = ptr -> name;
+ retval = AsnWrite(aip, ID2S_SEQ_ANNOT_INFO_name, &av);
+ }
+ av.boolvalue = ptr -> align;
+ retval = AsnWrite(aip, ID2S_SEQ_ANNOT_INFO_align, &av);
+ av.boolvalue = ptr -> graph;
+ retval = AsnWrite(aip, ID2S_SEQ_ANNOT_INFO_graph, &av);
+ AsnGenericUserSeqOfAsnWrite(ptr -> feat, (AsnWriteFunc) ID2SFeatTypeInfoAsnWrite, aip, ID2S_SEQ_ANNOT_INFO_feat, ID2S_SEQ_ANNOT_INFO_feat_E);
+ if (ptr -> seq_loc != NULL) {
+ if ( ! ID2SeqLocAsnWrite(ptr -> seq_loc, aip, ID2S_SEQ_ANNOT_INFO_seq_loc)) {
+ goto erret;
+ }
+ }
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SSeqAssemblyInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqAssemblyInfoPtr LIBCALL
+ID2SSeqAssemblyInfoNew(void)
+{
+ ID2SSeqAssemblyInfoPtr ptr = MemNew((size_t) sizeof(ID2SSeqAssemblyInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SSeqAssemblyInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqAssemblyInfoPtr LIBCALL
+ID2SSeqAssemblyInfoFree(ID2SSeqAssemblyInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericUserSeqOfFree(ptr -> bioseqs, (AsnOptFreeFunc) ID2IdRangeFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SSeqAssemblyInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SSeqAssemblyInfoPtr LIBCALL
+ID2SSeqAssemblyInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SSeqAssemblyInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SSeqAssemblyInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_SEQ_ASSEMBLY_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_SEQ_ASSEMBLY_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SSeqAssemblyInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_SEQ_ASSEMBLY_INFO_bioseqs) {
+ ptr -> bioseqs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2IdRangeAsnRead, (AsnOptFreeFunc) ID2IdRangeFree);
+ if (isError && ptr -> bioseqs == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SSeqAssemblyInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SSeqAssemblyInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SSeqAssemblyInfoAsnWrite(ID2SSeqAssemblyInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_SEQ_ASSEMBLY_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ AsnGenericUserSeqOfAsnWrite(ptr -> bioseqs, (AsnWriteFunc) ID2IdRangeAsnWrite, aip, ID2S_SEQ_ASSEMBLY_INFO_bioseqs, SEQ_ASSEMBLY_INFO_bioseqs_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SFeatTypeInfoNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SFeatTypeInfoPtr LIBCALL
+ID2SFeatTypeInfoNew(void)
+{
+ ID2SFeatTypeInfoPtr ptr = MemNew((size_t) sizeof(ID2SFeatTypeInfo));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SFeatTypeInfoFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SFeatTypeInfoPtr LIBCALL
+ID2SFeatTypeInfoFree(ID2SFeatTypeInfoPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericBaseSeqOfFree(ptr -> subtypes ,ASNCODE_INTVAL_SLOT);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SFeatTypeInfoAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SFeatTypeInfoPtr LIBCALL
+ID2SFeatTypeInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SFeatTypeInfoPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SFeatTypeInfo ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_FEAT_TYPE_INFO);
+ } else {
+ atp = AsnLinkType(orig, ID2S_FEAT_TYPE_INFO);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SFeatTypeInfoNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_FEAT_TYPE_INFO_type) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> type = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_FEAT_TYPE_INFO_subtypes) {
+ ptr -> subtypes = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
+ if (isError && ptr -> subtypes == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SFeatTypeInfoFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SFeatTypeInfoAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SFeatTypeInfoAsnWrite(ID2SFeatTypeInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_FEAT_TYPE_INFO); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> type;
+ retval = AsnWrite(aip, ID2S_FEAT_TYPE_INFO_type, &av);
+ retval = AsnGenericBaseSeqOfAsnWrite(ptr -> subtypes ,ASNCODE_INTVAL_SLOT, aip, ID2S_FEAT_TYPE_INFO_subtypes, ID2S_FEAT_TYPE_INFO_subtypes_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SChunkNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkPtr LIBCALL
+ID2SChunkNew(void)
+{
+ ID2SChunkPtr ptr = MemNew((size_t) sizeof(ID2SChunk));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SChunkFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkPtr LIBCALL
+ID2SChunkFree(ID2SChunkPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericUserSeqOfFree(ptr -> data, (AsnOptFreeFunc) ID2SChunkDataFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SChunkAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkPtr LIBCALL
+ID2SChunkAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SChunkPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SChunk ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_CHUNK);
+ } else {
+ atp = AsnLinkType(orig, ID2S_CHUNK);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SChunkNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_CHUNK_data) {
+ ptr -> data = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SChunkDataAsnRead, (AsnOptFreeFunc) ID2SChunkDataFree);
+ if (isError && ptr -> data == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SChunkFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SChunkAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SChunkAsnWrite(ID2SChunkPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_CHUNK); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ AsnGenericUserSeqOfAsnWrite(ptr -> data, (AsnWriteFunc) ID2SChunkDataAsnWrite, aip, ID2S_CHUNK_data, ID2S_CHUNK_data_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SChunkDataNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkDataPtr LIBCALL
+ID2SChunkDataNew(void)
+{
+ ID2SChunkDataPtr ptr = MemNew((size_t) sizeof(ID2SChunkData));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SChunkDataFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkDataPtr LIBCALL
+ID2SChunkDataFree(ID2SChunkDataPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ Id_idFree(ptr -> Id_id);
+ AsnGenericChoiceSeqOfFree(ptr -> descrs, (AsnOptFreeFunc) SeqDescrFree);
+ AsnGenericUserSeqOfFree(ptr -> annots, (AsnOptFreeFunc) SeqAnnotFree);
+ AsnGenericUserSeqOfFree(ptr -> assembly, (AsnOptFreeFunc) SeqAlignFree);
+ AsnGenericUserSeqOfFree(ptr -> seq_map, (AsnOptFreeFunc) SeqLiteralFree);
+ AsnGenericUserSeqOfFree(ptr -> seq_data, (AsnOptFreeFunc) SeqLiteralFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* Id_idFree()
+*
+**************************************************/
+static
+Id_idPtr LIBCALL
+Id_idFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* ID2SChunkDataAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SChunkDataPtr LIBCALL
+ID2SChunkDataAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SChunkDataPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SChunkData ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_CHUNK_DATA);
+ } else {
+ atp = AsnLinkType(orig, ID2S_CHUNK_DATA);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SChunkDataNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2S_CHUNK_DATA_id) {
+ ptr -> Id_id = Id_idAsnRead(aip, atp);
+ if (aip -> io_failure) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_CHUNK_DATA_descrs) {
+ ptr -> descrs = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqDescrAsnRead, (AsnOptFreeFunc) SeqDescrFree);
+ if (isError && ptr -> descrs == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_CHUNK_DATA_annots) {
+ ptr -> annots = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAnnotAsnRead, (AsnOptFreeFunc) SeqAnnotFree);
+ if (isError && ptr -> annots == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_CHUNK_DATA_assembly) {
+ ptr -> assembly = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAlignAsnRead, (AsnOptFreeFunc) SeqAlignFree);
+ if (isError && ptr -> assembly == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_CHUNK_DATA_seq_map) {
+ ptr -> seq_map = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqLiteralAsnRead, (AsnOptFreeFunc) SeqLiteralFree);
+ if (isError && ptr -> seq_map == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2S_CHUNK_DATA_seq_data) {
+ ptr -> seq_data = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqLiteralAsnRead, (AsnOptFreeFunc) SeqLiteralFree);
+ if (isError && ptr -> seq_data == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SChunkDataFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* Id_idAsnRead()
+*
+**************************************************/
+static
+Id_idPtr LIBCALL
+Id_idAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError = FALSE;
+ Boolean nullIsError = FALSE;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* Id_id ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2S_CHUNK_DATA_id);
+ } else {
+ atp = AsnLinkType(orig, ID2S_CHUNK_DATA_id); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == ID2S_CHUNK_DATA_id_bioseq_set) {
+ choice = Id_id_bioseq_set;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ else if (atp == ID2S_CHUNK_DATA_id_gi) {
+ choice = Id_id_gi;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (aip -> io_failure) goto erret;
+
+ if (nullIsError && anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ aip -> io_failure = TRUE;
+ goto ret;
+}
+
+
+/**************************************************
+*
+* ID2SChunkDataAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SChunkDataAsnWrite(ID2SChunkDataPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2S_CHUNK_DATA); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> Id_id != NULL) {
+ if ( ! Id_idAsnWrite(ptr -> Id_id, aip, ID2S_CHUNK_DATA_id)) {
+ goto erret;
+ }
+ }
+ AsnGenericChoiceSeqOfAsnWrite(ptr -> descrs, (AsnWriteFunc) SeqDescrAsnWrite, aip, ID2S_CHUNK_DATA_descrs, ID2S_CHUNK_DATA_descrs_E);
+ AsnGenericUserSeqOfAsnWrite(ptr -> annots, (AsnWriteFunc) SeqAnnotAsnWrite, aip, ID2S_CHUNK_DATA_annots, ID2S_CHUNK_DATA_annots_E);
+ AsnGenericUserSeqOfAsnWrite(ptr -> assembly, (AsnWriteFunc) SeqAlignAsnWrite, aip, ID2S_CHUNK_DATA_assembly, ID2S_CHUNK_DATA_assembly_E);
+ AsnGenericUserSeqOfAsnWrite(ptr -> seq_map, (AsnWriteFunc) SeqLiteralAsnWrite, aip, ID2S_CHUNK_DATA_seq_map, ID2S_CHUNK_DATA_seq_map_E);
+ AsnGenericUserSeqOfAsnWrite(ptr -> seq_data, (AsnWriteFunc) SeqLiteralAsnWrite, aip, ID2S_CHUNK_DATA_seq_data, ID2S_CHUNK_DATA_seq_data_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* Id_idAsnWrite()
+*
+**************************************************/
+static Boolean LIBCALL
+Id_idAsnWrite(Id_idPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, ID2S_CHUNK_DATA_id); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ case Id_id_bioseq_set:
+ av.intvalue = anp->data.intvalue;
+ retval = AsnWrite(aip, ID2S_CHUNK_DATA_id_bioseq_set, &av);
+ break;
+ case Id_id_gi:
+ av.intvalue = anp->data.intvalue;
+ retval = AsnWrite(aip, ID2S_CHUNK_DATA_id_gi, &av);
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* ID2IntervalNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2IntervalPtr LIBCALL
+ID2IntervalNew(void)
+{
+ ID2IntervalPtr ptr = MemNew((size_t) sizeof(ID2Interval));
+
+ ptr -> length = 1;
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2IntervalFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2IntervalPtr LIBCALL
+ID2IntervalFree(ID2IntervalPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2IntervalAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2IntervalPtr LIBCALL
+ID2IntervalAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2IntervalPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2Interval ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_INTERVAL);
+ } else {
+ atp = AsnLinkType(orig, ID2_INTERVAL);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2IntervalNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_INTERVAL_gi) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> gi = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_INTERVAL_start) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> start = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_INTERVAL_length) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> length = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2IntervalFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2IntervalAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2IntervalAsnWrite(ID2IntervalPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_INTERVAL); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> gi;
+ retval = AsnWrite(aip, ID2_INTERVAL_gi, &av);
+ av.intvalue = ptr -> start;
+ retval = AsnWrite(aip, ID2_INTERVAL_start, &av);
+ av.intvalue = ptr -> length;
+ retval = AsnWrite(aip, ID2_INTERVAL_length, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2PackedSeqIntsNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2PackedSeqIntsPtr LIBCALL
+ID2PackedSeqIntsNew(void)
+{
+ ID2PackedSeqIntsPtr ptr = MemNew((size_t) sizeof(ID2PackedSeqInts));
+
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2PackedSeqIntsFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2PackedSeqIntsPtr LIBCALL
+ID2PackedSeqIntsFree(ID2PackedSeqIntsPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ AsnGenericUserSeqOfFree(ptr -> ints, (AsnOptFreeFunc) ID2SeqRangeFree);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2PackedSeqIntsAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2PackedSeqIntsPtr LIBCALL
+ID2PackedSeqIntsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2PackedSeqIntsPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2PackedSeqInts ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_PACKED_SEQ_INTS);
+ } else {
+ atp = AsnLinkType(orig, ID2_PACKED_SEQ_INTS);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2PackedSeqIntsNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_PACKED_SEQ_INTS_gi) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> gi = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_PACKED_SEQ_INTS_ints) {
+ ptr -> ints = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SeqRangeAsnRead, (AsnOptFreeFunc) ID2SeqRangeFree);
+ if (isError && ptr -> ints == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2PackedSeqIntsFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2PackedSeqIntsAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2PackedSeqIntsAsnWrite(ID2PackedSeqIntsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_PACKED_SEQ_INTS); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> gi;
+ retval = AsnWrite(aip, ID2_PACKED_SEQ_INTS_gi, &av);
+ AsnGenericUserSeqOfAsnWrite(ptr -> ints, (AsnWriteFunc) ID2SeqRangeAsnWrite, aip, ID2_PACKED_SEQ_INTS_ints, ID2_PACKED_SEQ_INTS_ints_E);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2SeqRangeNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2SeqRangePtr LIBCALL
+ID2SeqRangeNew(void)
+{
+ ID2SeqRangePtr ptr = MemNew((size_t) sizeof(ID2SeqRange));
+
+ ptr -> length = 1;
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2SeqRangeFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2SeqRangePtr LIBCALL
+ID2SeqRangeFree(ID2SeqRangePtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2SeqRangeAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2SeqRangePtr LIBCALL
+ID2SeqRangeAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2SeqRangePtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2SeqRange ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_SEQ_RANGE);
+ } else {
+ atp = AsnLinkType(orig, ID2_SEQ_RANGE);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2SeqRangeNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_SEQ_RANGE_start) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> start = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_SEQ_RANGE_length) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> length = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2SeqRangeFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2SeqRangeAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2SeqRangeAsnWrite(ID2SeqRangePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_SEQ_RANGE); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ av.intvalue = ptr -> start;
+ retval = AsnWrite(aip, ID2_SEQ_RANGE_start, &av);
+ av.intvalue = ptr -> length;
+ retval = AsnWrite(aip, ID2_SEQ_RANGE_length, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+
+/**************************************************
+*
+* ID2ParamNew()
+*
+**************************************************/
+NLM_EXTERN
+ID2ParamPtr LIBCALL
+ID2ParamNew(void)
+{
+ ID2ParamPtr ptr = MemNew((size_t) sizeof(ID2Param));
+
+ ptr -> type = 1;
+ return ptr;
+
+}
+
+
+/**************************************************
+*
+* ID2ParamFree()
+*
+**************************************************/
+NLM_EXTERN
+ID2ParamPtr LIBCALL
+ID2ParamFree(ID2ParamPtr ptr)
+{
+
+ if(ptr == NULL) {
+ return NULL;
+ }
+ MemFree(ptr -> name);
+ AsnGenericBaseSeqOfFree(ptr -> value ,ASNCODE_PTRVAL_SLOT);
+ return MemFree(ptr);
+}
+
+
+/**************************************************
+*
+* ID2ParamAsnRead()
+*
+**************************************************/
+NLM_EXTERN
+ID2ParamPtr LIBCALL
+ID2ParamAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean isError = FALSE;
+ AsnReadFunc func;
+ ID2ParamPtr ptr;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* ID2Param ::= (self contained) */
+ atp = AsnReadId(aip, amp, ID2_PARAM);
+ } else {
+ atp = AsnLinkType(orig, ID2_PARAM);
+ }
+ /* link in local tree */
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ ptr = ID2ParamNew();
+ if (ptr == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
+ goto erret;
+ }
+
+ atp = AsnReadId(aip,amp, atp);
+ func = NULL;
+
+ if (atp == ID2_PARAM_name) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> name = av.ptrvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_PARAM_value) {
+ ptr -> value = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
+ if (isError && ptr -> value == NULL) {
+ goto erret;
+ }
+ atp = AsnReadId(aip,amp, atp);
+ }
+ if (atp == ID2_PARAM_type) {
+ if ( AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ ptr -> type = av.intvalue;
+ atp = AsnReadId(aip,amp, atp);
+ }
+
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ /* end struct */
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return ptr;
+
+erret:
+ aip -> io_failure = TRUE;
+ ptr = ID2ParamFree(ptr);
+ goto ret;
+}
+
+
+
+/**************************************************
+*
+* ID2ParamAsnWrite()
+*
+**************************************************/
+NLM_EXTERN Boolean LIBCALL
+ID2ParamAsnWrite(ID2ParamPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! id2genAsnLoad()) {
+ return FALSE;
+ }
+ }
+
+ if (aip == NULL) {
+ return FALSE;
+ }
+
+ atp = AsnLinkType(orig, ID2_PARAM); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+ if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
+ goto erret;
+ }
+
+ if (ptr -> name != NULL) {
+ av.ptrvalue = ptr -> name;
+ retval = AsnWrite(aip, ID2_PARAM_name, &av);
+ }
+ retval = AsnGenericBaseSeqOfAsnWrite(ptr -> value ,ASNCODE_PTRVAL_SLOT, aip, ID2_PARAM_value, ID2_PARAM_value_E);
+ av.intvalue = ptr -> type;
+ retval = AsnWrite(aip, ID2_PARAM_type, &av);
+ if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
diff --git a/network/id2arch/id2.h b/network/id2arch/id2.h
new file mode 100644
index 00000000..affa3533
--- /dev/null
+++ b/network/id2arch/id2.h
@@ -0,0 +1,519 @@
+/***********************************************************************
+*
+**
+* Automatic header module from ASNTOOL
+*
+************************************************************************/
+
+#ifndef _ASNTOOL_
+#include <asn.h>
+#endif
+
+static char * asnfilename = "id2.h14";
+static AsnValxNode avnx[27] = {
+ {20,"set-value" ,1,0.0,&avnx[1] } ,
+ {20,"get-value" ,2,0.0,&avnx[2] } ,
+ {20,"force-value" ,3,0.0,&avnx[3] } ,
+ {20,"use-package" ,4,0.0,NULL } ,
+ {3,NULL,1,0.0,NULL } ,
+ {3,NULL,1,0.0,NULL } ,
+ {3,NULL,1,0.0,NULL } ,
+ {3,NULL,1,0.0,NULL } ,
+ {3,NULL,1,0.0,NULL } ,
+ {3,NULL,1,0.0,NULL } ,
+ {3,NULL,0,0.0,NULL } ,
+ {3,NULL,0,0.0,NULL } ,
+ {3,NULL,0,0.0,NULL } ,
+ {20,"none" ,0,0.0,&avnx[14] } ,
+ {20,"seq-map" ,1,0.0,&avnx[15] } ,
+ {20,"seq-data" ,2,0.0,NULL } ,
+ {3,NULL,0,0.0,NULL } ,
+ {1,"" ,0,0.0,NULL } ,
+ {3,NULL,0,0.0,NULL } ,
+ {20,"warning" ,1,0.0,&avnx[20] } ,
+ {20,"failed-command" ,2,0.0,&avnx[21] } ,
+ {20,"failed-connection" ,3,0.0,&avnx[22] } ,
+ {20,"failed-server" ,4,0.0,&avnx[23] } ,
+ {20,"no-data" ,5,0.0,&avnx[24] } ,
+ {20,"restricted-data" ,6,0.0,&avnx[25] } ,
+ {20,"unsupported-command" ,7,0.0,&avnx[26] } ,
+ {20,"invalid-arguments" ,8,0.0,NULL } };
+
+static AsnType atx[217] = {
+ {401, "Seq-id" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[1]} ,
+ {402, "Seq-annot" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[2]} ,
+ {403, "Seq-descr" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[3]} ,
+ {404, "Seq-literal" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[4]} ,
+ {405, "Seq-align" ,1,0,0,0,0,0,1,0,NULL,NULL,NULL,0,&atx[5]} ,
+ {406, "ID2-Request-Packet" ,1,0,0,0,0,0,0,0,NULL,&atx[18],&atx[6],0,&atx[7]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[7],NULL,0,NULL} ,
+ {407, "ID2-Request" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[8],0,&atx[11]} ,
+ {0, "serial-number" ,128,0,0,1,0,0,0,0,NULL,&atx[9],NULL,0,&atx[10]} ,
+ {302, "INTEGER" ,0,2,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {0, "params" ,128,1,0,1,0,0,0,0,NULL,&atx[11],NULL,0,&atx[22]} ,
+ {408, "ID2-Params" ,1,0,0,0,0,0,0,0,NULL,&atx[18],&atx[12],0,&atx[26]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[13],NULL,0,NULL} ,
+ {448, "ID2-Param" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[14],0,NULL} ,
+ {0, "name" ,128,0,0,0,0,0,0,0,NULL,&atx[15],NULL,0,&atx[16]} ,
+ {323, "VisibleString" ,0,26,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {0, "value" ,128,1,0,1,0,0,0,0,NULL,&atx[18],&atx[17],0,&atx[19]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[15],NULL,0,NULL} ,
+ {312, "SEQUENCE OF" ,0,16,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {0, "type" ,128,2,0,0,1,0,0,0,&avnx[4],&atx[20],&avnx[0],0,NULL} ,
+ {310, "ENUMERATED" ,0,10,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {311, "SEQUENCE" ,0,16,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {0, "request" ,128,2,0,0,0,0,0,0,NULL,&atx[42],&atx[23],0,NULL} ,
+ {0, "init" ,128,0,0,0,0,0,0,0,NULL,&atx[24],NULL,0,&atx[25]} ,
+ {305, "NULL" ,0,5,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {0, "get-packages" ,128,1,0,0,0,0,0,0,NULL,&atx[26],NULL,0,&atx[30]} ,
+ {409, "ID2-Request-Get-Packages" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[27],0,&atx[31]} ,
+ {0, "names" ,128,0,0,1,0,0,0,0,NULL,&atx[18],&atx[28],0,&atx[29]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[15],NULL,0,NULL} ,
+ {0, "no-contents" ,128,1,0,1,0,0,0,0,NULL,&atx[24],NULL,0,NULL} ,
+ {0, "string-to-gi" ,128,2,0,0,0,0,0,0,NULL,&atx[31],NULL,0,&atx[33]} ,
+ {410, "ID2-Request-String-To-Gi" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[32],0,&atx[34]} ,
+ {0, "id" ,128,0,0,0,0,0,0,0,NULL,&atx[15],NULL,0,NULL} ,
+ {0, "seq-id-to-gi" ,128,3,0,0,0,0,0,0,NULL,&atx[34],NULL,0,&atx[36]} ,
+ {411, "ID2-Request-Seq-id-To-Gi" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[35],0,&atx[37]} ,
+ {0, "seq-id" ,128,0,0,0,0,0,0,0,NULL,&atx[0],NULL,0,NULL} ,
+ {0, "gi-to-tse-id" ,128,4,0,0,0,0,0,0,NULL,&atx[37],NULL,0,&atx[48]} ,
+ {412, "ID2-Request-Gi-To-TSE-Id" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[38],0,&atx[49]} ,
+ {0, "gi" ,128,0,0,0,0,0,0,0,NULL,&atx[42],&atx[39],0,&atx[43]} ,
+ {0, "gi" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[40]} ,
+ {0, "string" ,128,1,0,0,0,0,0,0,NULL,&atx[31],NULL,0,&atx[41]} ,
+ {0, "seq-id" ,128,2,0,0,0,0,0,0,NULL,&atx[34],NULL,0,NULL} ,
+ {315, "CHOICE" ,0,-1,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {0, "sources" ,128,1,0,1,0,0,0,0,NULL,&atx[45],&atx[44],0,&atx[46]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[15],NULL,0,NULL} ,
+ {314, "SET OF" ,0,17,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {0, "external" ,128,2,0,1,0,0,0,0,NULL,&atx[24],NULL,0,&atx[47]} ,
+ {0, "current-gis" ,128,3,0,1,0,0,0,0,NULL,&atx[24],NULL,0,NULL} ,
+ {0, "get-tse" ,128,5,0,0,0,0,0,0,NULL,&atx[49],NULL,0,&atx[89]} ,
+ {413, "ID2-Request-Get-TSE" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[50],0,&atx[90]} ,
+ {0, "tse-id" ,128,0,0,0,0,0,0,0,NULL,&atx[42],&atx[51],0,&atx[59]} ,
+ {0, "tse-id" ,128,0,0,0,0,0,0,0,NULL,&atx[52],NULL,0,&atx[55]} ,
+ {416, "ID2-TSE-Id" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[53],0,&atx[60]} ,
+ {0, "sat" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[54]} ,
+ {0, "sat-key" ,128,1,0,0,0,0,0,0,NULL,&atx[9],NULL,0,NULL} ,
+ {0, "gi" ,128,1,0,0,0,0,0,0,NULL,&atx[21],&atx[56],0,NULL} ,
+ {0, "request" ,128,0,0,0,0,0,0,0,NULL,&atx[37],NULL,0,&atx[57]} ,
+ {0, "exclude-tses" ,128,1,0,1,0,0,0,0,NULL,&atx[45],&atx[58],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[52],NULL,0,NULL} ,
+ {0, "details" ,128,1,0,1,0,0,0,0,NULL,&atx[60],NULL,0,NULL} ,
+ {417, "ID2-Get-TSE-Details" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[61],0,&atx[99]} ,
+ {0, "location" ,128,0,0,0,0,0,0,0,NULL,&atx[62],NULL,0,&atx[83]} ,
+ {419, "ID2-Seq-loc" ,1,0,0,0,0,0,0,0,NULL,&atx[42],&atx[63],0,&atx[100]} ,
+ {0, "whole" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[64]} ,
+ {0, "int" ,128,1,0,0,0,0,0,0,NULL,&atx[65],NULL,0,&atx[69]} ,
+ {445, "ID2-Interval" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[66],0,&atx[70]} ,
+ {0, "gi" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[67]} ,
+ {0, "start" ,128,1,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[68]} ,
+ {0, "length" ,128,2,0,0,1,0,0,0,&avnx[5],&atx[9],NULL,0,NULL} ,
+ {0, "int-set" ,128,2,0,0,0,0,0,0,NULL,&atx[70],NULL,0,&atx[77]} ,
+ {446, "ID2-Packed-Seq-ints" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[71],0,&atx[74]} ,
+ {0, "gi" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[72]} ,
+ {0, "ints" ,128,1,0,0,0,0,0,0,NULL,&atx[45],&atx[73],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[74],NULL,0,NULL} ,
+ {447, "ID2-Seq-range" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[75],0,&atx[13]} ,
+ {0, "start" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[76]} ,
+ {0, "length" ,128,1,0,0,1,0,0,0,&avnx[6],&atx[9],NULL,0,NULL} ,
+ {0, "whole-range" ,128,3,0,0,0,0,0,0,NULL,&atx[78],NULL,0,&atx[81]} ,
+ {434, "ID2-Id-Range" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[79],0,&atx[160]} ,
+ {0, "start" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[80]} ,
+ {0, "count" ,128,1,0,0,1,0,0,0,&avnx[7],&atx[9],NULL,0,NULL} ,
+ {0, "loc-set" ,128,4,0,0,0,0,0,0,NULL,&atx[45],&atx[82],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[62],NULL,0,NULL} ,
+ {0, "seq-class-level" ,128,1,0,0,1,0,0,0,&avnx[8],&atx[9],NULL,0,&atx[84]} ,
+ {0, "descr-level" ,128,2,0,0,1,0,0,0,&avnx[9],&atx[9],NULL,0,&atx[85]} ,
+ {0, "descr-type-mask" ,128,3,0,0,1,0,0,0,&avnx[10],&atx[9],NULL,0,&atx[86]} ,
+ {0, "annot-type-mask" ,128,4,0,0,1,0,0,0,&avnx[11],&atx[9],NULL,0,&atx[87]} ,
+ {0, "feat-type-mask" ,128,5,0,0,1,0,0,0,&avnx[12],&atx[9],NULL,0,&atx[88]} ,
+ {0, "sequence-level" ,128,6,0,0,1,0,0,0,&avnx[16],&atx[20],&avnx[13],0,NULL} ,
+ {0, "reget-tse" ,128,6,0,0,0,0,0,0,NULL,&atx[90],NULL,0,&atx[94]} ,
+ {414, "ID2-Request-ReGet-TSE" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[91],0,&atx[95]} ,
+ {0, "tse-id" ,128,0,0,0,0,0,0,0,NULL,&atx[52],NULL,0,&atx[92]} ,
+ {0, "details" ,128,1,0,1,0,0,0,0,NULL,&atx[60],NULL,0,&atx[93]} ,
+ {0, "offset" ,128,2,0,0,0,0,0,0,NULL,&atx[9],NULL,0,NULL} ,
+ {0, "get-chunks" ,128,7,0,0,0,0,0,0,NULL,&atx[95],NULL,0,NULL} ,
+ {415, "ID2S-Request-Get-Chunks" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[96],0,&atx[52]} ,
+ {0, "tse-id" ,128,0,0,0,0,0,0,0,NULL,&atx[52],NULL,0,&atx[97]} ,
+ {0, "chunks" ,128,1,0,0,0,0,0,0,NULL,&atx[45],&atx[98],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[99],NULL,0,NULL} ,
+ {418, "ID2S-Chunk-Id" ,1,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[62]} ,
+ {420, "ID2-Reply" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[101],0,&atx[106]} ,
+ {0, "serial-number" ,128,0,0,1,0,0,0,0,NULL,&atx[9],NULL,0,&atx[102]} ,
+ {0, "params" ,128,1,0,1,0,0,0,0,NULL,&atx[11],NULL,0,&atx[103]} ,
+ {0, "reply" ,128,2,0,0,0,0,0,0,NULL,&atx[42],&atx[104],0,&atx[143]} ,
+ {0, "init" ,128,0,0,0,0,0,0,0,NULL,&atx[24],NULL,0,&atx[105]} ,
+ {0, "get-package" ,128,1,0,0,0,0,0,0,NULL,&atx[106],NULL,0,&atx[109]} ,
+ {421, "ID2-Reply-Get-Package" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[107],0,&atx[110]} ,
+ {0, "name" ,128,0,0,0,0,0,0,0,NULL,&atx[15],NULL,0,&atx[108]} ,
+ {0, "params" ,128,1,0,1,0,0,0,0,NULL,&atx[11],NULL,0,NULL} ,
+ {0, "seq-id-to-gi" ,128,2,0,0,0,0,0,0,NULL,&atx[110],NULL,0,&atx[113]} ,
+ {422, "ID2-Reply-Seq-id-To-Gi" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[111],0,&atx[114]} ,
+ {0, "seq-id" ,128,0,0,0,0,0,0,0,NULL,&atx[0],NULL,0,&atx[112]} ,
+ {0, "gi" ,128,1,0,1,0,0,0,0,NULL,&atx[9],NULL,0,NULL} ,
+ {0, "gi-to-tse-id" ,128,3,0,0,0,0,0,0,NULL,&atx[114],NULL,0,&atx[122]} ,
+ {423, "ID2-Reply-Gi-To-TSE-Id" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[115],0,&atx[123]} ,
+ {0, "gi" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[116]} ,
+ {0, "source" ,128,1,0,0,1,0,0,0,&avnx[17],&atx[15],NULL,0,&atx[117]} ,
+ {0, "tses" ,128,2,0,1,0,0,0,0,NULL,&atx[45],&atx[118],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[119],NULL,0,NULL} ,
+ {428, "ID2-TSE-Id-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[120],0,&atx[126]} ,
+ {0, "tse-id" ,128,0,0,0,0,0,0,0,NULL,&atx[52],NULL,0,&atx[121]} ,
+ {0, "split-version" ,128,1,0,0,1,0,0,0,&avnx[18],&atx[9],NULL,0,NULL} ,
+ {0, "get-tse" ,128,4,0,0,0,0,0,0,NULL,&atx[123],NULL,0,&atx[133]} ,
+ {424, "ID2-Reply-Get-TSE" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[124],0,&atx[134]} ,
+ {0, "tse-id" ,128,0,0,0,0,0,0,0,NULL,&atx[52],NULL,0,&atx[125]} ,
+ {0, "data" ,128,1,0,1,0,0,0,0,NULL,&atx[126],NULL,0,NULL} ,
+ {429, "ID2-Reply-Data" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[127],0,&atx[151]} ,
+ {0, "data-type" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[128]} ,
+ {0, "data-format" ,128,1,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[129]} ,
+ {0, "data-compression" ,128,2,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[130]} ,
+ {0, "data" ,128,3,0,0,0,0,0,0,NULL,&atx[18],&atx[131],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[132],NULL,0,NULL} ,
+ {304, "OCTET STRING" ,0,4,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {0, "get-tse-info" ,128,5,0,0,0,0,0,0,NULL,&atx[134],NULL,0,&atx[138]} ,
+ {425, "ID2S-Reply-Get-TSE-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[135],0,&atx[139]} ,
+ {0, "tse-id" ,128,0,0,0,0,0,0,0,NULL,&atx[52],NULL,0,&atx[136]} ,
+ {0, "split-version" ,128,1,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[137]} ,
+ {0, "info" ,128,2,0,1,0,0,0,0,NULL,&atx[126],NULL,0,NULL} ,
+ {0, "get-chunk" ,128,6,0,0,0,0,0,0,NULL,&atx[139],NULL,0,NULL} ,
+ {426, "ID2S-Reply-Get-Chunk" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[140],0,&atx[145]} ,
+ {0, "tse-id" ,128,0,0,0,0,0,0,0,NULL,&atx[52],NULL,0,&atx[141]} ,
+ {0, "chunk-id" ,128,1,0,0,0,0,0,0,NULL,&atx[99],NULL,0,&atx[142]} ,
+ {0, "data" ,128,2,0,1,0,0,0,0,NULL,&atx[126],NULL,0,NULL} ,
+ {0, "error" ,128,3,0,1,0,0,0,0,NULL,&atx[18],&atx[144],0,&atx[149]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[145],NULL,0,NULL} ,
+ {427, "ID2-Error" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[146],0,&atx[119]} ,
+ {0, "severity" ,128,0,0,0,0,0,0,0,NULL,&atx[20],&avnx[19],0,&atx[147]} ,
+ {0, "retry-delay" ,128,1,0,1,0,0,0,0,NULL,&atx[9],NULL,0,&atx[148]} ,
+ {0, "message" ,128,2,0,1,0,0,0,0,NULL,&atx[15],NULL,0,NULL} ,
+ {0, "end-of-reply" ,128,4,0,0,0,0,0,0,NULL,&atx[150],NULL,0,NULL} ,
+ {301, "BOOLEAN" ,0,1,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
+ {430, "ID2S-Split-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[152],0,&atx[154]} ,
+ {0, "bioseqs-info" ,128,0,0,1,0,0,0,0,NULL,&atx[45],&atx[153],0,&atx[166]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[154],NULL,0,NULL} ,
+ {431, "ID2S-Bioseqs-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[155],0,&atx[168]} ,
+ {0, "info" ,128,0,0,0,0,0,0,0,NULL,&atx[156],NULL,0,&atx[165]} ,
+ {433, "ID2S-Bioseq-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[157],0,&atx[78]} ,
+ {0, "gap-count" ,128,0,0,1,0,0,0,0,NULL,&atx[9],NULL,0,&atx[158]} ,
+ {0, "seq-map-has-ref" ,128,1,0,1,0,0,0,0,NULL,&atx[150],NULL,0,&atx[159]} ,
+ {0, "sequence-split" ,128,2,0,1,0,0,0,0,NULL,&atx[160],NULL,0,NULL} ,
+ {435, "ID2S-Sequence-Split-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[161],0,&atx[172]} ,
+ {0, "block-size" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[162]} ,
+ {0, "chunk-start" ,128,1,0,0,0,0,0,0,NULL,&atx[99],NULL,0,&atx[163]} ,
+ {0, "chunk-blocks" ,128,2,0,0,0,0,0,0,NULL,&atx[18],&atx[164],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[9],NULL,0,NULL} ,
+ {0, "bioseqs" ,128,1,0,0,0,0,0,0,NULL,&atx[78],NULL,0,NULL} ,
+ {0, "chunks" ,128,1,0,0,0,0,0,0,NULL,&atx[45],&atx[167],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[168],NULL,0,NULL} ,
+ {432, "ID2S-Chunk-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[169],0,&atx[156]} ,
+ {0, "id" ,128,0,0,0,0,0,0,0,NULL,&atx[99],NULL,0,&atx[170]} ,
+ {0, "content" ,128,1,0,0,0,0,0,0,NULL,&atx[45],&atx[171],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[172],NULL,0,NULL} ,
+ {436, "ID2S-Chunk-Content" ,1,0,0,0,0,0,0,0,NULL,&atx[42],&atx[173],0,&atx[174]} ,
+ {0, "seq-descr" ,128,0,0,0,0,0,0,0,NULL,&atx[174],NULL,0,&atx[180]} ,
+ {437, "ID2S-Seq-descr-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[175],0,&atx[181]} ,
+ {0, "type-mask" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[176]} ,
+ {0, "bioseqs" ,128,1,0,1,0,0,0,0,NULL,&atx[45],&atx[177],0,&atx[178]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[78],NULL,0,NULL} ,
+ {0, "bioseq-sets" ,128,2,0,1,0,0,0,0,NULL,&atx[45],&atx[179],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[78],NULL,0,NULL} ,
+ {0, "seq-annot" ,128,1,0,0,0,0,0,0,NULL,&atx[181],NULL,0,&atx[192]} ,
+ {438, "ID2S-Seq-annot-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[182],0,&atx[193]} ,
+ {0, "name" ,128,0,0,1,0,0,0,0,NULL,&atx[15],NULL,0,&atx[183]} ,
+ {0, "align" ,128,1,0,1,0,0,0,0,NULL,&atx[24],NULL,0,&atx[184]} ,
+ {0, "graph" ,128,2,0,1,0,0,0,0,NULL,&atx[24],NULL,0,&atx[185]} ,
+ {0, "feat" ,128,3,0,1,0,0,0,0,NULL,&atx[45],&atx[186],0,&atx[191]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[187],NULL,0,NULL} ,
+ {442, "ID2S-Feat-type-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[188],0,&atx[200]} ,
+ {0, "type" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[189]} ,
+ {0, "subtypes" ,128,1,0,1,0,0,0,0,NULL,&atx[45],&atx[190],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[9],NULL,0,NULL} ,
+ {0, "seq-loc" ,128,4,0,0,0,0,0,0,NULL,&atx[62],NULL,0,NULL} ,
+ {0, "seq-assembly" ,128,2,0,0,0,0,0,0,NULL,&atx[193],NULL,0,&atx[196]} ,
+ {439, "ID2S-Seq-assembly-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[194],0,&atx[197]} ,
+ {0, "bioseqs" ,128,0,0,0,0,0,0,0,NULL,&atx[45],&atx[195],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[78],NULL,0,NULL} ,
+ {0, "seq-map" ,128,3,0,0,0,0,0,0,NULL,&atx[197],NULL,0,&atx[198]} ,
+ {440, "ID2S-Seq-map-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[62],NULL,0,&atx[199]} ,
+ {0, "seq-data" ,128,4,0,0,0,0,0,0,NULL,&atx[199],NULL,0,NULL} ,
+ {441, "ID2S-Seq-data-Info" ,1,0,0,0,0,0,0,0,NULL,&atx[62],NULL,0,&atx[187]} ,
+ {443, "ID2S-Chunk" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[201],0,&atx[203]} ,
+ {0, "data" ,128,0,0,0,0,0,0,0,NULL,&atx[45],&atx[202],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[203],NULL,0,NULL} ,
+ {444, "ID2S-Chunk-Data" ,1,0,0,0,0,0,0,0,NULL,&atx[21],&atx[204],0,&atx[65]} ,
+ {0, "id" ,128,0,0,0,0,0,0,0,NULL,&atx[42],&atx[205],0,&atx[207]} ,
+ {0, "bioseq-set" ,128,0,0,0,0,0,0,0,NULL,&atx[9],NULL,0,&atx[206]} ,
+ {0, "gi" ,128,1,0,0,0,0,0,0,NULL,&atx[9],NULL,0,NULL} ,
+ {0, "descrs" ,128,1,0,1,0,0,0,0,NULL,&atx[45],&atx[208],0,&atx[209]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[2],NULL,0,NULL} ,
+ {0, "annots" ,128,2,0,1,0,0,0,0,NULL,&atx[45],&atx[210],0,&atx[211]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[1],NULL,0,NULL} ,
+ {0, "assembly" ,128,3,0,1,0,0,0,0,NULL,&atx[45],&atx[212],0,&atx[213]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[4],NULL,0,NULL} ,
+ {0, "seq-map" ,128,4,0,1,0,0,0,0,NULL,&atx[18],&atx[214],0,&atx[215]} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[3],NULL,0,NULL} ,
+ {0, "seq-data" ,128,5,0,1,0,0,0,0,NULL,&atx[18],&atx[216],0,NULL} ,
+ {0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[3],NULL,0,NULL} };
+
+static AsnModule ampx[1] = {
+ { "NCBI-ID2Access" , "id2.h14",&atx[0],NULL,NULL,0,0} };
+
+static AsnValxNodePtr avn = avnx;
+static AsnTypePtr at = atx;
+static AsnModulePtr amp = ampx;
+
+
+
+/**************************************************
+*
+* Defines for Module NCBI-ID2Access
+*
+**************************************************/
+
+#define ID2_REQUEST_PACKET &at[5]
+#define ID2_REQUEST_PACKET_E &at[6]
+
+#define ID2_REQUEST &at[7]
+#define ID2_REQUEST_serial_number &at[8]
+#define ID2_REQUEST_params &at[10]
+#define ID2_REQUEST_request &at[22]
+#define ID2_REQUEST_request_init &at[23]
+#define REQUEST_request_get_packages &at[25]
+#define REQUEST_request_string_to_gi &at[30]
+#define REQUEST_request_seq_id_to_gi &at[33]
+#define REQUEST_request_gi_to_tse_id &at[36]
+#define ID2_REQUEST_request_get_tse &at[48]
+#define ID2_REQUEST_request_reget_tse &at[89]
+#define ID2_REQUEST_request_get_chunks &at[94]
+
+#define ID2_PARAMS &at[11]
+#define ID2_PARAMS_E &at[12]
+
+#define ID2_REQUEST_GET_PACKAGES &at[26]
+#define ID2_REQUEST_GET_PACKAGES_names &at[27]
+#define REQUEST_GET_PACKAGES_names_E &at[28]
+#define GET_PACKAGES_no_contents &at[29]
+
+#define ID2_REQUEST_STRING_TO_GI &at[31]
+#define ID2_REQUEST_STRING_TO_GI_id &at[32]
+
+#define ID2_REQUEST_SEQ_ID_TO_GI &at[34]
+#define ID2_REQUEST_SEQ_ID_TO_GI_seq_id &at[35]
+
+#define ID2_REQUEST_GI_TO_TSE_ID &at[37]
+#define ID2_REQUEST_GI_TO_TSE_ID_gi &at[38]
+#define ID2_REQUEST_GI_TO_TSE_ID_gi_gi &at[39]
+#define REQUEST_GI_TO_TSE_ID_gi_string &at[40]
+#define REQUEST_GI_TO_TSE_ID_gi_seq_id &at[41]
+#define REQUEST_GI_TO_TSE_ID_sources &at[43]
+#define REQUEST_GI_TO_TSE_ID_sources_E &at[44]
+#define REQUEST_GI_TO_TSE_ID_external &at[46]
+#define GI_TO_TSE_ID_current_gis &at[47]
+
+#define ID2_REQUEST_GET_TSE &at[49]
+#define ID2_REQUEST_GET_TSE_tse_id &at[50]
+#define REQUEST_GET_TSE_tse_id_tse_id &at[51]
+#define ID2_REQUEST_GET_TSE_tse_id_gi &at[55]
+#define GET_TSE_tse_id_gi_request &at[56]
+#define GET_TSE_tse_id_gi_exclude_tses &at[57]
+#define TSE_tse_id_gi_exclude_tses_E &at[58]
+#define ID2_REQUEST_GET_TSE_details &at[59]
+
+#define ID2_REQUEST_REGET_TSE &at[90]
+#define ID2_REQUEST_REGET_TSE_tse_id &at[91]
+#define ID2_REQUEST_REGET_TSE_details &at[92]
+#define ID2_REQUEST_REGET_TSE_offset &at[93]
+
+#define ID2S_REQUEST_GET_CHUNKS &at[95]
+#define ID2S_REQUEST_GET_CHUNKS_tse_id &at[96]
+#define ID2S_REQUEST_GET_CHUNKS_chunks &at[97]
+#define REQUEST_GET_CHUNKS_chunks_E &at[98]
+
+#define ID2_TSE_ID &at[52]
+#define ID2_TSE_ID_sat &at[53]
+#define ID2_TSE_ID_sat_key &at[54]
+
+#define ID2_GET_TSE_DETAILS &at[60]
+#define ID2_GET_TSE_DETAILS_location &at[61]
+#define TSE_DETAILS_seq_class_level &at[83]
+#define ID2_GET_TSE_DETAILS_descr_level &at[84]
+#define TSE_DETAILS_descr_type_mask &at[85]
+#define TSE_DETAILS_annot_type_mask &at[86]
+#define GET_TSE_DETAILS_feat_type_mask &at[87]
+#define GET_TSE_DETAILS_sequence_level &at[88]
+
+#define ID2S_CHUNK_ID &at[99]
+
+#define ID2_SEQ_LOC &at[62]
+#define ID2_SEQ_LOC_whole &at[63]
+#define ID2_SEQ_LOC_int &at[64]
+#define ID2_SEQ_LOC_int_set &at[69]
+#define ID2_SEQ_LOC_whole_range &at[77]
+#define ID2_SEQ_LOC_loc_set &at[81]
+#define ID2_SEQ_LOC_loc_set_E &at[82]
+
+#define ID2_REPLY &at[100]
+#define ID2_REPLY_serial_number &at[101]
+#define ID2_REPLY_params &at[102]
+#define ID2_REPLY_reply &at[103]
+#define ID2_REPLY_reply_init &at[104]
+#define ID2_REPLY_reply_get_package &at[105]
+#define ID2_REPLY_reply_seq_id_to_gi &at[109]
+#define ID2_REPLY_reply_gi_to_tse_id &at[113]
+#define ID2_REPLY_reply_get_tse &at[122]
+#define ID2_REPLY_reply_get_tse_info &at[133]
+#define ID2_REPLY_reply_get_chunk &at[138]
+#define ID2_REPLY_error &at[143]
+#define ID2_REPLY_error_E &at[144]
+#define ID2_REPLY_end_of_reply &at[149]
+
+#define ID2_REPLY_GET_PACKAGE &at[106]
+#define ID2_REPLY_GET_PACKAGE_name &at[107]
+#define ID2_REPLY_GET_PACKAGE_params &at[108]
+
+#define ID2_REPLY_SEQ_ID_TO_GI &at[110]
+#define ID2_REPLY_SEQ_ID_TO_GI_seq_id &at[111]
+#define ID2_REPLY_SEQ_ID_TO_GI_gi &at[112]
+
+#define ID2_REPLY_GI_TO_TSE_ID &at[114]
+#define ID2_REPLY_GI_TO_TSE_ID_gi &at[115]
+#define ID2_REPLY_GI_TO_TSE_ID_source &at[116]
+#define ID2_REPLY_GI_TO_TSE_ID_tses &at[117]
+#define ID2_REPLY_GI_TO_TSE_ID_tses_E &at[118]
+
+#define ID2_REPLY_GET_TSE &at[123]
+#define ID2_REPLY_GET_TSE_tse_id &at[124]
+#define ID2_REPLY_GET_TSE_data &at[125]
+
+#define ID2S_REPLY_GET_TSE_INFO &at[134]
+#define ID2S_REPLY_GET_TSE_INFO_tse_id &at[135]
+#define GET_TSE_INFO_split_version &at[136]
+#define ID2S_REPLY_GET_TSE_INFO_info &at[137]
+
+#define ID2S_REPLY_GET_CHUNK &at[139]
+#define ID2S_REPLY_GET_CHUNK_tse_id &at[140]
+#define ID2S_REPLY_GET_CHUNK_chunk_id &at[141]
+#define ID2S_REPLY_GET_CHUNK_data &at[142]
+
+#define ID2_ERROR &at[145]
+#define ID2_ERROR_severity &at[146]
+#define ID2_ERROR_retry_delay &at[147]
+#define ID2_ERROR_message &at[148]
+
+#define ID2_TSE_ID_INFO &at[119]
+#define ID2_TSE_ID_INFO_tse_id &at[120]
+#define ID2_TSE_ID_INFO_split_version &at[121]
+
+#define ID2_REPLY_DATA &at[126]
+#define ID2_REPLY_DATA_data_type &at[127]
+#define ID2_REPLY_DATA_data_format &at[128]
+#define ID2_REPLY_DATA_data_compression &at[129]
+#define ID2_REPLY_DATA_data &at[130]
+#define ID2_REPLY_DATA_data_E &at[131]
+
+#define ID2S_SPLIT_INFO &at[151]
+#define ID2S_SPLIT_INFO_bioseqs_info &at[152]
+#define ID2S_SPLIT_INFO_bioseqs_info_E &at[153]
+#define ID2S_SPLIT_INFO_chunks &at[166]
+#define ID2S_SPLIT_INFO_chunks_E &at[167]
+
+#define ID2S_BIOSEQS_INFO &at[154]
+#define ID2S_BIOSEQS_INFO_info &at[155]
+#define ID2S_BIOSEQS_INFO_bioseqs &at[165]
+
+#define ID2S_CHUNK_INFO &at[168]
+#define ID2S_CHUNK_INFO_id &at[169]
+#define ID2S_CHUNK_INFO_content &at[170]
+#define ID2S_CHUNK_INFO_content_E &at[171]
+
+#define ID2S_BIOSEQ_INFO &at[156]
+#define ID2S_BIOSEQ_INFO_gap_count &at[157]
+#define BIOSEQ_INFO_seq_map_has_ref &at[158]
+#define ID2S_BIOSEQ_INFO_sequence_split &at[159]
+
+#define ID2_ID_RANGE &at[78]
+#define ID2_ID_RANGE_start &at[79]
+#define ID2_ID_RANGE_count &at[80]
+
+#define ID2S_SEQUENCE_SPLIT_INFO &at[160]
+#define SEQUENCE_SPLIT_INFO_block_size &at[161]
+#define SPLIT_INFO_chunk_start &at[162]
+#define SPLIT_INFO_chunk_blocks &at[163]
+#define SPLIT_INFO_chunk_blocks_E &at[164]
+
+#define ID2S_CHUNK_CONTENT &at[172]
+#define ID2S_CHUNK_CONTENT_seq_descr &at[173]
+#define ID2S_CHUNK_CONTENT_seq_annot &at[180]
+#define ID2S_CHUNK_CONTENT_seq_assembly &at[192]
+#define ID2S_CHUNK_CONTENT_seq_map &at[196]
+#define ID2S_CHUNK_CONTENT_seq_data &at[198]
+
+#define ID2S_SEQ_DESCR_INFO &at[174]
+#define ID2S_SEQ_DESCR_INFO_type_mask &at[175]
+#define ID2S_SEQ_DESCR_INFO_bioseqs &at[176]
+#define ID2S_SEQ_DESCR_INFO_bioseqs_E &at[177]
+#define ID2S_SEQ_DESCR_INFO_bioseq_sets &at[178]
+#define SEQ_DESCR_INFO_bioseq_sets_E &at[179]
+
+#define ID2S_SEQ_ANNOT_INFO &at[181]
+#define ID2S_SEQ_ANNOT_INFO_name &at[182]
+#define ID2S_SEQ_ANNOT_INFO_align &at[183]
+#define ID2S_SEQ_ANNOT_INFO_graph &at[184]
+#define ID2S_SEQ_ANNOT_INFO_feat &at[185]
+#define ID2S_SEQ_ANNOT_INFO_feat_E &at[186]
+#define ID2S_SEQ_ANNOT_INFO_seq_loc &at[191]
+
+#define ID2S_SEQ_ASSEMBLY_INFO &at[193]
+#define ID2S_SEQ_ASSEMBLY_INFO_bioseqs &at[194]
+#define SEQ_ASSEMBLY_INFO_bioseqs_E &at[195]
+
+#define ID2S_SEQ_MAP_INFO &at[197]
+
+#define ID2S_SEQ_DATA_INFO &at[199]
+
+#define ID2S_FEAT_TYPE_INFO &at[187]
+#define ID2S_FEAT_TYPE_INFO_type &at[188]
+#define ID2S_FEAT_TYPE_INFO_subtypes &at[189]
+#define ID2S_FEAT_TYPE_INFO_subtypes_E &at[190]
+
+#define ID2S_CHUNK &at[200]
+#define ID2S_CHUNK_data &at[201]
+#define ID2S_CHUNK_data_E &at[202]
+
+#define ID2S_CHUNK_DATA &at[203]
+#define ID2S_CHUNK_DATA_id &at[204]
+#define ID2S_CHUNK_DATA_id_bioseq_set &at[205]
+#define ID2S_CHUNK_DATA_id_gi &at[206]
+#define ID2S_CHUNK_DATA_descrs &at[207]
+#define ID2S_CHUNK_DATA_descrs_E &at[208]
+#define ID2S_CHUNK_DATA_annots &at[209]
+#define ID2S_CHUNK_DATA_annots_E &at[210]
+#define ID2S_CHUNK_DATA_assembly &at[211]
+#define ID2S_CHUNK_DATA_assembly_E &at[212]
+#define ID2S_CHUNK_DATA_seq_map &at[213]
+#define ID2S_CHUNK_DATA_seq_map_E &at[214]
+#define ID2S_CHUNK_DATA_seq_data &at[215]
+#define ID2S_CHUNK_DATA_seq_data_E &at[216]
+
+#define ID2_INTERVAL &at[65]
+#define ID2_INTERVAL_gi &at[66]
+#define ID2_INTERVAL_start &at[67]
+#define ID2_INTERVAL_length &at[68]
+
+#define ID2_PACKED_SEQ_INTS &at[70]
+#define ID2_PACKED_SEQ_INTS_gi &at[71]
+#define ID2_PACKED_SEQ_INTS_ints &at[72]
+#define ID2_PACKED_SEQ_INTS_ints_E &at[73]
+
+#define ID2_SEQ_RANGE &at[74]
+#define ID2_SEQ_RANGE_start &at[75]
+#define ID2_SEQ_RANGE_length &at[76]
+
+#define ID2_PARAM &at[13]
+#define ID2_PARAM_name &at[14]
+#define ID2_PARAM_value &at[16]
+#define ID2_PARAM_value_E &at[17]
+#define ID2_PARAM_type &at[19]
diff --git a/network/id2arch/id2gen.h b/network/id2arch/id2gen.h
new file mode 100644
index 00000000..c17237b4
--- /dev/null
+++ b/network/id2arch/id2gen.h
@@ -0,0 +1,968 @@
+#ifndef _id2gen_
+#define _id2gen_
+
+#undef NLM_EXTERN
+#ifdef NLM_IMPORT
+#define NLM_EXTERN NLM_IMPORT
+#else
+#define NLM_EXTERN extern
+#endif
+
+
+#ifdef __cplusplus
+extern "C" { /* } */
+#endif
+
+
+/**************************************************
+*
+* Generated objects for Module NCBI-ID2Access
+* Generated using ASNCODE Revision: 6.0 at Dec 15, 2003 5:08 PM
+*
+**************************************************/
+
+NLM_EXTERN Boolean LIBCALL
+id2genAsnLoad PROTO((void));
+
+
+/**************************************************
+*
+* ID2RequestPacket
+*
+**************************************************/
+typedef struct struct_ID2Request ID2RequestPacket;
+typedef struct struct_ID2Request PNTR ID2RequestPacketPtr;
+#define ID2RequestPacketNew() ID2RequestNew()
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+NLM_EXTERN ID2RequestPacketPtr LIBCALL ID2RequestPacketFree PROTO ((ID2RequestPacketPtr ));
+NLM_EXTERN ID2RequestPacketPtr LIBCALL ID2RequestPacketNew PROTO (( void ));
+NLM_EXTERN ID2RequestPacketPtr LIBCALL ID2RequestPacketAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2RequestPacketAsnWrite PROTO (( ID2RequestPacketPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
+* ID2Request
+*
+**************************************************/
+typedef struct struct_ID2_Request {
+ struct struct_ID2_Request PNTR next;
+ Int4 serial_number;
+ struct struct_ID2_Param PNTR params;
+ ValNodePtr Request_request;
+} ID2Request, PNTR ID2RequestPtr;
+
+
+NLM_EXTERN ID2RequestPtr LIBCALL ID2RequestFree PROTO ((ID2RequestPtr ));
+NLM_EXTERN ID2RequestPtr LIBCALL ID2RequestNew PROTO (( void ));
+NLM_EXTERN ID2RequestPtr LIBCALL ID2RequestAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2RequestAsnWrite PROTO (( ID2RequestPtr , AsnIoPtr, AsnTypePtr));
+
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+typedef ValNodePtr Request_requestPtr;
+typedef ValNode Request_request;
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+#define Request_request_init 1
+#define Request_request_get_packages 2
+#define Request_request_string_to_gi 3
+#define Request_request_seq_id_to_gi 4
+#define Request_request_gi_to_tse_id 5
+#define Request_request_get_tse 6
+#define Request_request_reget_tse 7
+#define Request_request_get_chunks 8
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+static Request_requestPtr LIBCALL Request_requestFree PROTO ((Request_requestPtr ));
+static Request_requestPtr LIBCALL Request_requestAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+static Boolean LIBCALL Request_requestAsnWrite PROTO (( Request_requestPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
+* ID2Params
+*
+**************************************************/
+typedef struct struct_ID2Param ID2Params;
+typedef struct struct_ID2Param PNTR ID2ParamsPtr;
+#define ID2ParamsNew() ID2ParamNew()
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+NLM_EXTERN ID2ParamsPtr LIBCALL ID2ParamsFree PROTO ((ID2ParamsPtr ));
+NLM_EXTERN ID2ParamsPtr LIBCALL ID2ParamsNew PROTO (( void ));
+NLM_EXTERN ID2ParamsPtr LIBCALL ID2ParamsAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ParamsAsnWrite PROTO (( ID2ParamsPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
+* ID2RequestGetPackages
+*
+**************************************************/
+typedef struct struct_ID2_Request_Get_Packages {
+ ValNodePtr names;
+ Uint1 no_contents;
+} ID2RequestGetPackages, PNTR ID2RequestGetPackagesPtr;
+
+
+NLM_EXTERN ID2RequestGetPackagesPtr LIBCALL ID2RequestGetPackagesFree PROTO ((ID2RequestGetPackagesPtr ));
+NLM_EXTERN ID2RequestGetPackagesPtr LIBCALL ID2RequestGetPackagesNew PROTO (( void ));
+NLM_EXTERN ID2RequestGetPackagesPtr LIBCALL ID2RequestGetPackagesAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2RequestGetPackagesAsnWrite PROTO (( ID2RequestGetPackagesPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2RequestStringToGi
+*
+**************************************************/
+typedef struct struct_ID2_Request_String_To_Gi {
+ CharPtr id;
+} ID2RequestStringToGi, PNTR ID2RequestStringToGiPtr;
+
+
+NLM_EXTERN ID2RequestStringToGiPtr LIBCALL ID2RequestStringToGiFree PROTO ((ID2RequestStringToGiPtr ));
+NLM_EXTERN ID2RequestStringToGiPtr LIBCALL ID2RequestStringToGiNew PROTO (( void ));
+NLM_EXTERN ID2RequestStringToGiPtr LIBCALL ID2RequestStringToGiAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2RequestStringToGiAsnWrite PROTO (( ID2RequestStringToGiPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2RequestSeqIdToGi
+*
+**************************************************/
+typedef struct struct_ID2_Request_Seq_id_To_Gi {
+ ValNodePtr seq_id;
+} ID2RequestSeqIdToGi, PNTR ID2RequestSeqIdToGiPtr;
+
+
+NLM_EXTERN ID2RequestSeqIdToGiPtr LIBCALL ID2RequestSeqIdToGiFree PROTO ((ID2RequestSeqIdToGiPtr ));
+NLM_EXTERN ID2RequestSeqIdToGiPtr LIBCALL ID2RequestSeqIdToGiNew PROTO (( void ));
+NLM_EXTERN ID2RequestSeqIdToGiPtr LIBCALL ID2RequestSeqIdToGiAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2RequestSeqIdToGiAsnWrite PROTO (( ID2RequestSeqIdToGiPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2RequestGiToTSEId
+*
+**************************************************/
+typedef struct struct_ID2_Request_Gi_To_TSE_Id {
+ ValNodePtr Gi_gi;
+ ValNodePtr sources;
+ Uint1 external;
+ Uint1 current_gis;
+} ID2RequestGiToTSEId, PNTR ID2RequestGiToTSEIdPtr;
+
+
+NLM_EXTERN ID2RequestGiToTSEIdPtr LIBCALL ID2RequestGiToTSEIdFree PROTO ((ID2RequestGiToTSEIdPtr ));
+NLM_EXTERN ID2RequestGiToTSEIdPtr LIBCALL ID2RequestGiToTSEIdNew PROTO (( void ));
+NLM_EXTERN ID2RequestGiToTSEIdPtr LIBCALL ID2RequestGiToTSEIdAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2RequestGiToTSEIdAsnWrite PROTO (( ID2RequestGiToTSEIdPtr , AsnIoPtr, AsnTypePtr));
+
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+typedef ValNodePtr Gi_giPtr;
+typedef ValNode Gi_gi;
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+#define Gi_gi_gi 1
+#define Gi_gi_string 2
+#define Gi_gi_seq_id 3
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+static Gi_giPtr LIBCALL Gi_giFree PROTO ((Gi_giPtr ));
+static Gi_giPtr LIBCALL Gi_giAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+static Boolean LIBCALL Gi_giAsnWrite PROTO (( Gi_giPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
+* ID2RequestGetTSE
+*
+**************************************************/
+typedef struct struct_ID2_Request_Get_TSE {
+ ValNodePtr TseId_tse_id;
+ struct struct_ID2_Get_TSE_Details PNTR details;
+} ID2RequestGetTSE, PNTR ID2RequestGetTSEPtr;
+
+
+NLM_EXTERN ID2RequestGetTSEPtr LIBCALL ID2RequestGetTSEFree PROTO ((ID2RequestGetTSEPtr ));
+NLM_EXTERN ID2RequestGetTSEPtr LIBCALL ID2RequestGetTSENew PROTO (( void ));
+NLM_EXTERN ID2RequestGetTSEPtr LIBCALL ID2RequestGetTSEAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2RequestGetTSEAsnWrite PROTO (( ID2RequestGetTSEPtr , AsnIoPtr, AsnTypePtr));
+
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+typedef ValNodePtr TseId_tse_idPtr;
+typedef ValNode TseId_tse_id;
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+#define TseId_tse_id_tse_id 1
+#define TseId_tse_id_TseId_Gi 2
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+static TseId_tse_idPtr LIBCALL TseId_tse_idFree PROTO ((TseId_tse_idPtr ));
+static TseId_tse_idPtr LIBCALL TseId_tse_idAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+static Boolean LIBCALL TseId_tse_idAsnWrite PROTO (( TseId_tse_idPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
+* TseId_gi
+*
+**************************************************/
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+typedef struct struct_TseId_Gi {
+ struct struct_ID2_Request_Gi_To_TSE_Id PNTR request;
+ struct struct_ID2_TSE_Id PNTR exclude_tses;
+} TseId_gi, PNTR TseId_giPtr;
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+static TseId_giPtr LIBCALL TseId_giFree PROTO ((TseId_giPtr ));
+static TseId_giPtr LIBCALL TseId_giNew PROTO (( void ));
+static TseId_giPtr LIBCALL TseId_giAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+static Boolean LIBCALL TseId_giAsnWrite PROTO (( TseId_giPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
+* ID2RequestReGetTSE
+*
+**************************************************/
+typedef struct struct_ID2_Request_ReGet_TSE {
+ struct struct_ID2_TSE_Id PNTR tse_id;
+ struct struct_ID2_Get_TSE_Details PNTR details;
+ Int4 offset;
+} ID2RequestReGetTSE, PNTR ID2RequestReGetTSEPtr;
+
+
+NLM_EXTERN ID2RequestReGetTSEPtr LIBCALL ID2RequestReGetTSEFree PROTO ((ID2RequestReGetTSEPtr ));
+NLM_EXTERN ID2RequestReGetTSEPtr LIBCALL ID2RequestReGetTSENew PROTO (( void ));
+NLM_EXTERN ID2RequestReGetTSEPtr LIBCALL ID2RequestReGetTSEAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2RequestReGetTSEAsnWrite PROTO (( ID2RequestReGetTSEPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SRequestGetChunks
+*
+**************************************************/
+typedef struct struct_ID2S_Request_Get_Chunks {
+ struct struct_ID2_TSE_Id PNTR tse_id;
+ ValNodePtr chunks;
+} ID2SRequestGetChunks, PNTR ID2SRequestGetChunksPtr;
+
+
+NLM_EXTERN ID2SRequestGetChunksPtr LIBCALL ID2SRequestGetChunksFree PROTO ((ID2SRequestGetChunksPtr ));
+NLM_EXTERN ID2SRequestGetChunksPtr LIBCALL ID2SRequestGetChunksNew PROTO (( void ));
+NLM_EXTERN ID2SRequestGetChunksPtr LIBCALL ID2SRequestGetChunksAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SRequestGetChunksAsnWrite PROTO (( ID2SRequestGetChunksPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2TSEId
+*
+**************************************************/
+typedef struct struct_ID2_TSE_Id {
+ struct struct_ID2_TSE_Id PNTR next;
+ Int4 sat;
+ Int4 sat_key;
+} ID2TSEId, PNTR ID2TSEIdPtr;
+
+
+NLM_EXTERN ID2TSEIdPtr LIBCALL ID2TSEIdFree PROTO ((ID2TSEIdPtr ));
+NLM_EXTERN ID2TSEIdPtr LIBCALL ID2TSEIdNew PROTO (( void ));
+NLM_EXTERN ID2TSEIdPtr LIBCALL ID2TSEIdAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2TSEIdAsnWrite PROTO (( ID2TSEIdPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2GetTSEDetails
+*
+**************************************************/
+typedef struct struct_ID2_Get_TSE_Details {
+ ValNodePtr location;
+ Int4 seq_class_level;
+ Int4 descr_level;
+ Int4 descr_type_mask;
+ Int4 annot_type_mask;
+ Int4 feat_type_mask;
+ Uint2 sequence_level;
+ /* following #defines are for enumerated type, not used by object loaders */
+#define ID2_Get_TSE_Details_sequence_level_none 0
+#define ID2_Get_TSE_Details_sequence_level_seq_map 1
+#define ID2_Get_TSE_Details_sequence_level_seq_data 2
+
+} ID2GetTSEDetails, PNTR ID2GetTSEDetailsPtr;
+
+
+NLM_EXTERN ID2GetTSEDetailsPtr LIBCALL ID2GetTSEDetailsFree PROTO ((ID2GetTSEDetailsPtr ));
+NLM_EXTERN ID2GetTSEDetailsPtr LIBCALL ID2GetTSEDetailsNew PROTO (( void ));
+NLM_EXTERN ID2GetTSEDetailsPtr LIBCALL ID2GetTSEDetailsAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2GetTSEDetailsAsnWrite PROTO (( ID2GetTSEDetailsPtr , AsnIoPtr, AsnTypePtr));
+
+typedef ValNodePtr ID2SeqLocPtr;
+typedef ValNode ID2SeqLoc;
+#define ID2SeqLoc_whole 1
+#define ID2SeqLoc_int__ 2
+#define ID2SeqLoc_int_set 3
+#define ID2SeqLoc_whole_range 4
+#define ID2SeqLoc_loc_set 5
+
+
+NLM_EXTERN ID2SeqLocPtr LIBCALL ID2SeqLocFree PROTO ((ID2SeqLocPtr ));
+NLM_EXTERN ID2SeqLocPtr LIBCALL ID2SeqLocAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SeqLocAsnWrite PROTO (( ID2SeqLocPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2Reply
+*
+**************************************************/
+typedef struct struct_ID2_Reply {
+ Int4 serial_number;
+ struct struct_ID2_Param PNTR params;
+ ValNodePtr Reply_reply;
+ struct struct_ID2_Error PNTR error;
+ Uint1 end_of_reply;
+} ID2Reply, PNTR ID2ReplyPtr;
+
+
+NLM_EXTERN ID2ReplyPtr LIBCALL ID2ReplyFree PROTO ((ID2ReplyPtr ));
+NLM_EXTERN ID2ReplyPtr LIBCALL ID2ReplyNew PROTO (( void ));
+NLM_EXTERN ID2ReplyPtr LIBCALL ID2ReplyAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ReplyAsnWrite PROTO (( ID2ReplyPtr , AsnIoPtr, AsnTypePtr));
+
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+typedef ValNodePtr Reply_replyPtr;
+typedef ValNode Reply_reply;
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+#define Reply_reply_init 1
+#define Reply_reply_get_package 2
+#define Reply_reply_seq_id_to_gi 3
+#define Reply_reply_gi_to_tse_id 4
+#define Reply_reply_get_tse 5
+#define Reply_reply_get_tse_info 6
+#define Reply_reply_get_chunk 7
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+static Reply_replyPtr LIBCALL Reply_replyFree PROTO ((Reply_replyPtr ));
+static Reply_replyPtr LIBCALL Reply_replyAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+static Boolean LIBCALL Reply_replyAsnWrite PROTO (( Reply_replyPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
+* ID2ReplyGetPackage
+*
+**************************************************/
+typedef struct struct_ID2_Reply_Get_Package {
+ CharPtr name;
+ struct struct_ID2_Param PNTR params;
+} ID2ReplyGetPackage, PNTR ID2ReplyGetPackagePtr;
+
+
+NLM_EXTERN ID2ReplyGetPackagePtr LIBCALL ID2ReplyGetPackageFree PROTO ((ID2ReplyGetPackagePtr ));
+NLM_EXTERN ID2ReplyGetPackagePtr LIBCALL ID2ReplyGetPackageNew PROTO (( void ));
+NLM_EXTERN ID2ReplyGetPackagePtr LIBCALL ID2ReplyGetPackageAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ReplyGetPackageAsnWrite PROTO (( ID2ReplyGetPackagePtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2ReplySeqIdToGi
+*
+**************************************************/
+typedef struct struct_ID2_Reply_Seq_id_To_Gi {
+ ValNodePtr seq_id;
+ Int4 gi;
+} ID2ReplySeqIdToGi, PNTR ID2ReplySeqIdToGiPtr;
+
+
+NLM_EXTERN ID2ReplySeqIdToGiPtr LIBCALL ID2ReplySeqIdToGiFree PROTO ((ID2ReplySeqIdToGiPtr ));
+NLM_EXTERN ID2ReplySeqIdToGiPtr LIBCALL ID2ReplySeqIdToGiNew PROTO (( void ));
+NLM_EXTERN ID2ReplySeqIdToGiPtr LIBCALL ID2ReplySeqIdToGiAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ReplySeqIdToGiAsnWrite PROTO (( ID2ReplySeqIdToGiPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2ReplyGiToTSEId
+*
+**************************************************/
+typedef struct struct_ID2_Reply_Gi_To_TSE_Id {
+ Int4 gi;
+ CharPtr source;
+ struct struct_ID2_TSE_Id_Info PNTR tses;
+} ID2ReplyGiToTSEId, PNTR ID2ReplyGiToTSEIdPtr;
+
+
+NLM_EXTERN ID2ReplyGiToTSEIdPtr LIBCALL ID2ReplyGiToTSEIdFree PROTO ((ID2ReplyGiToTSEIdPtr ));
+NLM_EXTERN ID2ReplyGiToTSEIdPtr LIBCALL ID2ReplyGiToTSEIdNew PROTO (( void ));
+NLM_EXTERN ID2ReplyGiToTSEIdPtr LIBCALL ID2ReplyGiToTSEIdAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ReplyGiToTSEIdAsnWrite PROTO (( ID2ReplyGiToTSEIdPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2ReplyGetTSE
+*
+**************************************************/
+typedef struct struct_ID2_Reply_Get_TSE {
+ struct struct_ID2_TSE_Id PNTR tse_id;
+ struct struct_ID2_Reply_Data PNTR data;
+} ID2ReplyGetTSE, PNTR ID2ReplyGetTSEPtr;
+
+
+NLM_EXTERN ID2ReplyGetTSEPtr LIBCALL ID2ReplyGetTSEFree PROTO ((ID2ReplyGetTSEPtr ));
+NLM_EXTERN ID2ReplyGetTSEPtr LIBCALL ID2ReplyGetTSENew PROTO (( void ));
+NLM_EXTERN ID2ReplyGetTSEPtr LIBCALL ID2ReplyGetTSEAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ReplyGetTSEAsnWrite PROTO (( ID2ReplyGetTSEPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SReplyGetTSEInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Reply_Get_TSE_Info {
+ struct struct_ID2_TSE_Id PNTR tse_id;
+ Int4 split_version;
+ struct struct_ID2_Reply_Data PNTR info;
+} ID2SReplyGetTSEInfo, PNTR ID2SReplyGetTSEInfoPtr;
+
+
+NLM_EXTERN ID2SReplyGetTSEInfoPtr LIBCALL ID2SReplyGetTSEInfoFree PROTO ((ID2SReplyGetTSEInfoPtr ));
+NLM_EXTERN ID2SReplyGetTSEInfoPtr LIBCALL ID2SReplyGetTSEInfoNew PROTO (( void ));
+NLM_EXTERN ID2SReplyGetTSEInfoPtr LIBCALL ID2SReplyGetTSEInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SReplyGetTSEInfoAsnWrite PROTO (( ID2SReplyGetTSEInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SReplyGetChunk
+*
+**************************************************/
+typedef struct struct_ID2S_Reply_Get_Chunk {
+ struct struct_ID2_TSE_Id PNTR tse_id;
+ Int4 chunk_id;
+ struct struct_ID2_Reply_Data PNTR data;
+} ID2SReplyGetChunk, PNTR ID2SReplyGetChunkPtr;
+
+
+NLM_EXTERN ID2SReplyGetChunkPtr LIBCALL ID2SReplyGetChunkFree PROTO ((ID2SReplyGetChunkPtr ));
+NLM_EXTERN ID2SReplyGetChunkPtr LIBCALL ID2SReplyGetChunkNew PROTO (( void ));
+NLM_EXTERN ID2SReplyGetChunkPtr LIBCALL ID2SReplyGetChunkAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SReplyGetChunkAsnWrite PROTO (( ID2SReplyGetChunkPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2Error
+*
+**************************************************/
+typedef struct struct_ID2_Error {
+ struct struct_ID2_Error PNTR next;
+ Uint2 severity;
+ /* following #defines are for enumerated type, not used by object loaders */
+#define ID2_Error_severity_warning 1
+#define ID2_Error_severity_failed_command 2
+#define ID2_Error_severity_failed_connection 3
+#define ID2_Error_severity_failed_server 4
+#define ID2_Error_severity_no_data 5
+#define ID2_Error_severity_restricted_data 6
+#define ID2_Error_severity_unsupported_command 7
+#define ID2_Error_severity_invalid_arguments 8
+
+ Int4 retry_delay;
+ CharPtr message;
+} ID2Error, PNTR ID2ErrorPtr;
+
+
+NLM_EXTERN ID2ErrorPtr LIBCALL ID2ErrorFree PROTO ((ID2ErrorPtr ));
+NLM_EXTERN ID2ErrorPtr LIBCALL ID2ErrorNew PROTO (( void ));
+NLM_EXTERN ID2ErrorPtr LIBCALL ID2ErrorAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ErrorAsnWrite PROTO (( ID2ErrorPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2TSEIdInfo
+*
+**************************************************/
+typedef struct struct_ID2_TSE_Id_Info {
+ struct struct_ID2_TSE_Id_Info PNTR next;
+ struct struct_ID2_TSE_Id PNTR tse_id;
+ Int4 split_version;
+} ID2TSEIdInfo, PNTR ID2TSEIdInfoPtr;
+
+
+NLM_EXTERN ID2TSEIdInfoPtr LIBCALL ID2TSEIdInfoFree PROTO ((ID2TSEIdInfoPtr ));
+NLM_EXTERN ID2TSEIdInfoPtr LIBCALL ID2TSEIdInfoNew PROTO (( void ));
+NLM_EXTERN ID2TSEIdInfoPtr LIBCALL ID2TSEIdInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2TSEIdInfoAsnWrite PROTO (( ID2TSEIdInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2ReplyData
+*
+**************************************************/
+typedef struct struct_ID2_Reply_Data {
+ Int4 data_type;
+ Int4 data_format;
+ Int4 data_compression;
+ ValNodePtr data;
+} ID2ReplyData, PNTR ID2ReplyDataPtr;
+
+
+NLM_EXTERN ID2ReplyDataPtr LIBCALL ID2ReplyDataFree PROTO ((ID2ReplyDataPtr ));
+NLM_EXTERN ID2ReplyDataPtr LIBCALL ID2ReplyDataNew PROTO (( void ));
+NLM_EXTERN ID2ReplyDataPtr LIBCALL ID2ReplyDataAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ReplyDataAsnWrite PROTO (( ID2ReplyDataPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SSplitInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Split_Info {
+ struct struct_ID2S_Bioseqs_Info PNTR bioseqs_info;
+ struct struct_ID2S_Chunk_Info PNTR chunks;
+} ID2SSplitInfo, PNTR ID2SSplitInfoPtr;
+
+
+NLM_EXTERN ID2SSplitInfoPtr LIBCALL ID2SSplitInfoFree PROTO ((ID2SSplitInfoPtr ));
+NLM_EXTERN ID2SSplitInfoPtr LIBCALL ID2SSplitInfoNew PROTO (( void ));
+NLM_EXTERN ID2SSplitInfoPtr LIBCALL ID2SSplitInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SSplitInfoAsnWrite PROTO (( ID2SSplitInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SBioseqsInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Bioseqs_Info {
+ struct struct_ID2S_Bioseqs_Info PNTR next;
+ struct struct_ID2S_Bioseq_Info PNTR info;
+ struct struct_ID2_Id_Range PNTR bioseqs;
+} ID2SBioseqsInfo, PNTR ID2SBioseqsInfoPtr;
+
+
+NLM_EXTERN ID2SBioseqsInfoPtr LIBCALL ID2SBioseqsInfoFree PROTO ((ID2SBioseqsInfoPtr ));
+NLM_EXTERN ID2SBioseqsInfoPtr LIBCALL ID2SBioseqsInfoNew PROTO (( void ));
+NLM_EXTERN ID2SBioseqsInfoPtr LIBCALL ID2SBioseqsInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SBioseqsInfoAsnWrite PROTO (( ID2SBioseqsInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SChunkInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Chunk_Info {
+ struct struct_ID2S_Chunk_Info PNTR next;
+ Int4 id;
+ ValNodePtr content;
+} ID2SChunkInfo, PNTR ID2SChunkInfoPtr;
+
+
+NLM_EXTERN ID2SChunkInfoPtr LIBCALL ID2SChunkInfoFree PROTO ((ID2SChunkInfoPtr ));
+NLM_EXTERN ID2SChunkInfoPtr LIBCALL ID2SChunkInfoNew PROTO (( void ));
+NLM_EXTERN ID2SChunkInfoPtr LIBCALL ID2SChunkInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SChunkInfoAsnWrite PROTO (( ID2SChunkInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SBioseqInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Bioseq_Info {
+ Int4 gap_count;
+ Uint1 seq_map_has_ref;
+ struct struct_ID2S_Sequence_Split_Info PNTR sequence_split;
+} ID2SBioseqInfo, PNTR ID2SBioseqInfoPtr;
+
+
+NLM_EXTERN ID2SBioseqInfoPtr LIBCALL ID2SBioseqInfoFree PROTO ((ID2SBioseqInfoPtr ));
+NLM_EXTERN ID2SBioseqInfoPtr LIBCALL ID2SBioseqInfoNew PROTO (( void ));
+NLM_EXTERN ID2SBioseqInfoPtr LIBCALL ID2SBioseqInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SBioseqInfoAsnWrite PROTO (( ID2SBioseqInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2IdRange
+*
+**************************************************/
+typedef struct struct_ID2_Id_Range {
+ struct struct_ID2_Id_Range PNTR next;
+ Int4 start;
+ Int4 count;
+} ID2IdRange, PNTR ID2IdRangePtr;
+
+
+NLM_EXTERN ID2IdRangePtr LIBCALL ID2IdRangeFree PROTO ((ID2IdRangePtr ));
+NLM_EXTERN ID2IdRangePtr LIBCALL ID2IdRangeNew PROTO (( void ));
+NLM_EXTERN ID2IdRangePtr LIBCALL ID2IdRangeAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2IdRangeAsnWrite PROTO (( ID2IdRangePtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SSequenceSplitInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Sequence_Split_Info {
+ Int4 block_size;
+ Int4 chunk_start;
+ ValNodePtr chunk_blocks;
+} ID2SSequenceSplitInfo, PNTR ID2SSequenceSplitInfoPtr;
+
+
+NLM_EXTERN ID2SSequenceSplitInfoPtr LIBCALL ID2SSequenceSplitInfoFree PROTO ((ID2SSequenceSplitInfoPtr ));
+NLM_EXTERN ID2SSequenceSplitInfoPtr LIBCALL ID2SSequenceSplitInfoNew PROTO (( void ));
+NLM_EXTERN ID2SSequenceSplitInfoPtr LIBCALL ID2SSequenceSplitInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SSequenceSplitInfoAsnWrite PROTO (( ID2SSequenceSplitInfoPtr , AsnIoPtr, AsnTypePtr));
+
+typedef ValNodePtr ID2SChunkContentPtr;
+typedef ValNode ID2SChunkContent;
+#define ID2SChunkContent_seq_descr 1
+#define ID2SChunkContent_seq_annot 2
+#define ID2SChunkContent_seq_assembly 3
+#define ID2SChunkContent_seq_map 4
+#define ID2SChunkContent_seq_data 5
+
+
+NLM_EXTERN ID2SChunkContentPtr LIBCALL ID2SChunkContentFree PROTO ((ID2SChunkContentPtr ));
+NLM_EXTERN ID2SChunkContentPtr LIBCALL ID2SChunkContentAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SChunkContentAsnWrite PROTO (( ID2SChunkContentPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SSeqDescrInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Seq_descr_Info {
+ Int4 type_mask;
+ struct struct_ID2_Id_Range PNTR bioseqs;
+ struct struct_ID2_Id_Range PNTR bioseq_sets;
+} ID2SSeqDescrInfo, PNTR ID2SSeqDescrInfoPtr;
+
+
+NLM_EXTERN ID2SSeqDescrInfoPtr LIBCALL ID2SSeqDescrInfoFree PROTO ((ID2SSeqDescrInfoPtr ));
+NLM_EXTERN ID2SSeqDescrInfoPtr LIBCALL ID2SSeqDescrInfoNew PROTO (( void ));
+NLM_EXTERN ID2SSeqDescrInfoPtr LIBCALL ID2SSeqDescrInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SSeqDescrInfoAsnWrite PROTO (( ID2SSeqDescrInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SSeqAnnotInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Seq_annot_Info {
+ CharPtr name;
+ Uint1 align;
+ Uint1 graph;
+ struct struct_ID2S_Feat_type_Info PNTR feat;
+ ValNodePtr seq_loc;
+} ID2SSeqAnnotInfo, PNTR ID2SSeqAnnotInfoPtr;
+
+
+NLM_EXTERN ID2SSeqAnnotInfoPtr LIBCALL ID2SSeqAnnotInfoFree PROTO ((ID2SSeqAnnotInfoPtr ));
+NLM_EXTERN ID2SSeqAnnotInfoPtr LIBCALL ID2SSeqAnnotInfoNew PROTO (( void ));
+NLM_EXTERN ID2SSeqAnnotInfoPtr LIBCALL ID2SSeqAnnotInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SSeqAnnotInfoAsnWrite PROTO (( ID2SSeqAnnotInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SSeqAssemblyInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Seq_assembly_Info {
+ struct struct_ID2_Id_Range PNTR bioseqs;
+} ID2SSeqAssemblyInfo, PNTR ID2SSeqAssemblyInfoPtr;
+
+
+NLM_EXTERN ID2SSeqAssemblyInfoPtr LIBCALL ID2SSeqAssemblyInfoFree PROTO ((ID2SSeqAssemblyInfoPtr ));
+NLM_EXTERN ID2SSeqAssemblyInfoPtr LIBCALL ID2SSeqAssemblyInfoNew PROTO (( void ));
+NLM_EXTERN ID2SSeqAssemblyInfoPtr LIBCALL ID2SSeqAssemblyInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SSeqAssemblyInfoAsnWrite PROTO (( ID2SSeqAssemblyInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SSeqMapInfo
+*
+**************************************************/
+#define ID2SSeqMapInfo ValNode
+#define ID2SSeqMapInfoPtr ValNodePtr
+#define ID2SSeqMapInfoFree ValNodeFree
+#define ID2SSeqMapInfoNew ValNodeNew
+#define ID2SSeqMapInfoAsnRead ValNodeAsnRead
+#define ID2SSeqMapInfoAsnWrite ValNodeAsnWrite
+
+
+/**************************************************
+*
+* ID2SSeqDataInfo
+*
+**************************************************/
+#define ID2SSeqDataInfo ValNode
+#define ID2SSeqDataInfoPtr ValNodePtr
+#define ID2SSeqDataInfoFree ValNodeFree
+#define ID2SSeqDataInfoNew ValNodeNew
+#define ID2SSeqDataInfoAsnRead ValNodeAsnRead
+#define ID2SSeqDataInfoAsnWrite ValNodeAsnWrite
+
+
+/**************************************************
+*
+* ID2SFeatTypeInfo
+*
+**************************************************/
+typedef struct struct_ID2S_Feat_type_Info {
+ struct struct_ID2S_Feat_type_Info PNTR next;
+ Int4 type;
+ ValNodePtr subtypes;
+} ID2SFeatTypeInfo, PNTR ID2SFeatTypeInfoPtr;
+
+
+NLM_EXTERN ID2SFeatTypeInfoPtr LIBCALL ID2SFeatTypeInfoFree PROTO ((ID2SFeatTypeInfoPtr ));
+NLM_EXTERN ID2SFeatTypeInfoPtr LIBCALL ID2SFeatTypeInfoNew PROTO (( void ));
+NLM_EXTERN ID2SFeatTypeInfoPtr LIBCALL ID2SFeatTypeInfoAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SFeatTypeInfoAsnWrite PROTO (( ID2SFeatTypeInfoPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SChunk
+*
+**************************************************/
+typedef struct struct_ID2S_Chunk {
+ struct struct_ID2S_Chunk_Data PNTR data;
+} ID2SChunk, PNTR ID2SChunkPtr;
+
+
+NLM_EXTERN ID2SChunkPtr LIBCALL ID2SChunkFree PROTO ((ID2SChunkPtr ));
+NLM_EXTERN ID2SChunkPtr LIBCALL ID2SChunkNew PROTO (( void ));
+NLM_EXTERN ID2SChunkPtr LIBCALL ID2SChunkAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SChunkAsnWrite PROTO (( ID2SChunkPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SChunkData
+*
+**************************************************/
+typedef struct struct_ID2S_Chunk_Data {
+ struct struct_ID2S_Chunk_Data PNTR next;
+ ValNodePtr Id_id;
+ ValNodePtr descrs;
+ struct struct_Seq_annot PNTR annots;
+ struct struct_Seq_align PNTR assembly;
+ struct struct_Seq_literal PNTR seq_map;
+ struct struct_Seq_literal PNTR seq_data;
+} ID2SChunkData, PNTR ID2SChunkDataPtr;
+
+
+NLM_EXTERN ID2SChunkDataPtr LIBCALL ID2SChunkDataFree PROTO ((ID2SChunkDataPtr ));
+NLM_EXTERN ID2SChunkDataPtr LIBCALL ID2SChunkDataNew PROTO (( void ));
+NLM_EXTERN ID2SChunkDataPtr LIBCALL ID2SChunkDataAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SChunkDataAsnWrite PROTO (( ID2SChunkDataPtr , AsnIoPtr, AsnTypePtr));
+
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+typedef ValNodePtr Id_idPtr;
+typedef ValNode Id_id;
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+#define Id_id_bioseq_set 1
+#define Id_id_gi 2
+
+#ifdef NLM_GENERATED_CODE_PROTO
+
+static Id_idPtr LIBCALL Id_idFree PROTO ((Id_idPtr ));
+static Id_idPtr LIBCALL Id_idAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+static Boolean LIBCALL Id_idAsnWrite PROTO (( Id_idPtr , AsnIoPtr, AsnTypePtr));
+
+#endif /* NLM_GENERATED_CODE_PROTO */
+
+
+
+/**************************************************
+*
+* ID2Interval
+*
+**************************************************/
+typedef struct struct_ID2_Interval {
+ Int4 gi;
+ Int4 start;
+ Int4 length;
+} ID2Interval, PNTR ID2IntervalPtr;
+
+
+NLM_EXTERN ID2IntervalPtr LIBCALL ID2IntervalFree PROTO ((ID2IntervalPtr ));
+NLM_EXTERN ID2IntervalPtr LIBCALL ID2IntervalNew PROTO (( void ));
+NLM_EXTERN ID2IntervalPtr LIBCALL ID2IntervalAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2IntervalAsnWrite PROTO (( ID2IntervalPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2PackedSeqInts
+*
+**************************************************/
+typedef struct struct_ID2_Packed_Seq_ints {
+ Int4 gi;
+ struct struct_ID2_Seq_range PNTR ints;
+} ID2PackedSeqInts, PNTR ID2PackedSeqIntsPtr;
+
+
+NLM_EXTERN ID2PackedSeqIntsPtr LIBCALL ID2PackedSeqIntsFree PROTO ((ID2PackedSeqIntsPtr ));
+NLM_EXTERN ID2PackedSeqIntsPtr LIBCALL ID2PackedSeqIntsNew PROTO (( void ));
+NLM_EXTERN ID2PackedSeqIntsPtr LIBCALL ID2PackedSeqIntsAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2PackedSeqIntsAsnWrite PROTO (( ID2PackedSeqIntsPtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2SeqRange
+*
+**************************************************/
+typedef struct struct_ID2_Seq_range {
+ struct struct_ID2_Seq_range PNTR next;
+ Int4 start;
+ Int4 length;
+} ID2SeqRange, PNTR ID2SeqRangePtr;
+
+
+NLM_EXTERN ID2SeqRangePtr LIBCALL ID2SeqRangeFree PROTO ((ID2SeqRangePtr ));
+NLM_EXTERN ID2SeqRangePtr LIBCALL ID2SeqRangeNew PROTO (( void ));
+NLM_EXTERN ID2SeqRangePtr LIBCALL ID2SeqRangeAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2SeqRangeAsnWrite PROTO (( ID2SeqRangePtr , AsnIoPtr, AsnTypePtr));
+
+
+
+/**************************************************
+*
+* ID2Param
+*
+**************************************************/
+typedef struct struct_ID2_Param {
+ struct struct_ID2_Param PNTR next;
+ CharPtr name;
+ ValNodePtr value;
+ Uint2 type;
+ /* following #defines are for enumerated type, not used by object loaders */
+#define ID2_Param_type_set_value 1
+#define ID2_Param_type_get_value 2
+#define ID2_Param_type_force_value 3
+#define ID2_Param_type_use_package 4
+
+} ID2Param, PNTR ID2ParamPtr;
+
+
+NLM_EXTERN ID2ParamPtr LIBCALL ID2ParamFree PROTO ((ID2ParamPtr ));
+NLM_EXTERN ID2ParamPtr LIBCALL ID2ParamNew PROTO (( void ));
+NLM_EXTERN ID2ParamPtr LIBCALL ID2ParamAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+NLM_EXTERN Boolean LIBCALL ID2ParamAsnWrite PROTO (( ID2ParamPtr , AsnIoPtr, AsnTypePtr));
+
+#ifdef __cplusplus
+/* { */ }
+#endif
+
+#endif /* _id2gen_ */
+
+#undef NLM_EXTERN
+#ifdef NLM_EXPORT
+#define NLM_EXTERN NLM_EXPORT
+#else
+#define NLM_EXTERN
+#endif
+
diff --git a/network/id2arch/id2map.h b/network/id2arch/id2map.h
new file mode 100644
index 00000000..937324db
--- /dev/null
+++ b/network/id2arch/id2map.h
@@ -0,0 +1,10 @@
+#include <objsset.h>
+
+#define NLM_EXTERN_LOADS {if (! SeqSetAsnLoad())return FALSE; \
+ }
+#define struct_Seq_hist seqhist
+#define SeqLiteralAsnRead SeqLitAsnRead
+#define SeqLiteralAsnWrite SeqLitAsnWrite
+#define SeqLiteralFree SeqLitFree
+#define struct_ID2Param struct_ID2_Param
+#define ID2_SEQ_LOC_int__ ID2_SEQ_LOC_int
diff --git a/network/nsclilib/readme b/network/nsclilib/readme
index c68748ad..2e716917 100644
--- a/network/nsclilib/readme
+++ b/network/nsclilib/readme
@@ -87,9 +87,9 @@ Value:
| SRV_PROXY_HOST:5859 --> 130.14.22.2:5859 RETIRED -- DO NOT USE!
| SRV_PROXY_HOST:5840 --> 130.14.22.8:5840 RETIRED -- DO NOT USE!
| SRV_PROXY_HOST:5810 --> 130.14.22.30:5810 RETIRED -- DO NOT USE!
+| SRV_PROXY_HOST:5812 --> 130.14.22.31:5812 RETIRED -- DO NOT USE!
+| SRV_PROXY_HOST:5811 --> 130.14.22.32:5811 RETIRED -- DO NOT USE!
| SRV_PROXY_HOST:5845 --> 130.14.22.12:5845 INTERNAL
-| SRV_PROXY_HOST:5812 --> 130.14.22.31:5812 OBSOLESCENT
-| SRV_PROXY_HOST:5811 --> 130.14.22.32:5811 OBSOLESCENT
| SRV_PROXY_HOST:5850..5860 --> 130.14.29.112:5850..5860
|
| NOTE: It's pretty rare (if ever) when you have to use
@@ -189,4 +189,4 @@ Solaris or IRIX. Then, the client must run on the host that:
a) belongs to one of NCBI subnets and
b) has "lbdaemon"(load-balance daemon) application running on it.
-$Date: 2003/09/29 15:05:10 $
+$Date: 2004/01/16 19:03:45 $
diff --git a/network/spell/client/objspell.c b/network/spell/client/objspell.c
new file mode 100644
index 00000000..5c7a496b
--- /dev/null
+++ b/network/spell/client/objspell.c
@@ -0,0 +1,425 @@
+/*
+*
+*
+* RCS Modification History:
+* $Log: objspell.c,v $
+* Revision 6.0 1997/08/25 18:40:24 madden
+* Revision changed to 6.0
+*
+* Revision 4.0 1995/07/26 13:55:42 ostell
+* force revision to 4.0
+*
+ * Revision 1.2 1995/05/17 17:59:51 epstein
+ * add RCS log revision history
+ *
+*/
+
+#include <asn.h>
+
+#define NLM_GENERATED_CODE_PROTO
+
+#include "objspell.h"
+
+static Boolean loaded = FALSE;
+
+#include "spell.h"
+
+#ifndef NLM_EXTERN_LOADS
+#define NLM_EXTERN_LOADS {}
+#endif
+
+static Boolean
+objspellAsnLoad(void)
+{
+
+ if ( ! loaded) {
+ NLM_EXTERN_LOADS
+
+ if ( ! AsnLoad ())
+ return FALSE;
+ loaded = TRUE;
+ }
+
+ return TRUE;
+}
+
+
+
+/**************************************************
+* Generated object loaders for Module NCBI-SPELL
+*
+**************************************************/
+
+
+/**************************************************
+*
+* SpellRequestFree()
+*
+**************************************************/
+
+SpellRequestPtr LIBCALL
+SpellRequestFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case SpellRequest_spelltext:
+ MemFree(anp -> data.ptrvalue);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* SpellRequestAsnRead()
+*
+**************************************************/
+
+SpellRequestPtr LIBCALL
+SpellRequestAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! objspellAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* SpellRequest ::= (self contained) */
+ atp = AsnReadId(aip, amp, SPELL_REQUEST);
+ } else {
+ atp = AsnLinkType(orig, SPELL_REQUEST); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == SPELL_REQUEST_init) {
+ choice = SpellRequest_init;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ else if (atp == SPELL_REQUEST_spelltext) {
+ choice = SpellRequest_spelltext;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.ptrvalue = av.ptrvalue;
+ }
+ else if (atp == SPELL_REQUEST_fini) {
+ choice = SpellRequest_fini;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ goto ret;
+}
+
+
+/**************************************************
+*
+* SpellRequestAsnWrite()
+*
+**************************************************/
+Boolean LIBCALL
+SpellRequestAsnWrite(SpellRequestPtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! objspellAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, SPELL_REQUEST); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ av.intvalue = anp->data.intvalue;
+ switch (anp->choice)
+ {
+ case SpellRequest_init:
+ retval = AsnWrite(aip, SPELL_REQUEST_init, &av);
+ break;
+ case SpellRequest_spelltext:
+ retval = AsnWrite(aip, SPELL_REQUEST_spelltext, &av);
+ break;
+ case SpellRequest_fini:
+ retval = AsnWrite(aip, SPELL_REQUEST_fini, &av);
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
+
+
+/**************************************************
+*
+* SpellResponseFree()
+*
+**************************************************/
+
+SpellResponsePtr LIBCALL
+SpellResponseFree(ValNodePtr anp)
+{
+ Pointer pnt;
+
+ if (anp == NULL) {
+ return NULL;
+ }
+
+ pnt = anp->data.ptrvalue;
+ switch (anp->choice)
+ {
+ default:
+ break;
+ case SpellResponse_spelltext:
+ AsnGenericBaseSeqOfFree((ValNodePtr) pnt,ASNCODE_PTRVAL_SLOT);
+ break;
+ }
+ return MemFree(anp);
+}
+
+
+/**************************************************
+*
+* SpellResponseAsnRead()
+*
+**************************************************/
+
+SpellResponsePtr LIBCALL
+SpellResponseAsnRead(AsnIoPtr aip, AsnTypePtr orig)
+{
+ DataVal av;
+ AsnTypePtr atp;
+ ValNodePtr anp;
+ Uint1 choice;
+ Boolean isError;
+ AsnReadFunc func;
+
+ if (! loaded)
+ {
+ if (! objspellAsnLoad()) {
+ return NULL;
+ }
+ }
+
+ if (aip == NULL) {
+ return NULL;
+ }
+
+ if (orig == NULL) { /* SpellResponse ::= (self contained) */
+ atp = AsnReadId(aip, amp, SPELL_RESPONSE);
+ } else {
+ atp = AsnLinkType(orig, SPELL_RESPONSE); /* link in local tree */
+ }
+ if (atp == NULL) {
+ return NULL;
+ }
+
+ anp = ValNodeNew(NULL);
+ if (anp == NULL) {
+ goto erret;
+ }
+ if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
+ goto erret;
+ }
+
+ func = NULL;
+
+ atp = AsnReadId(aip, amp, atp); /* find the choice */
+ if (atp == NULL) {
+ goto erret;
+ }
+ if (atp == SPELL_RESPONSE_error) {
+ choice = SpellResponse_error;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ else if (atp == SPELL_RESPONSE_init) {
+ choice = SpellResponse_init;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ else if (atp == SPELL_RESPONSE_spelltext) {
+ choice = SpellResponse_spelltext;
+ anp -> data.ptrvalue =
+ AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
+ if (isError && anp -> data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+ else if (atp == SPELL_RESPONSE_fini) {
+ choice = SpellResponse_fini;
+ if (AsnReadVal(aip, atp, &av) <= 0) {
+ goto erret;
+ }
+ anp->data.intvalue = av.intvalue;
+ }
+ anp->choice = choice;
+ if (func != NULL)
+ {
+ anp->data.ptrvalue = (* func)(aip, atp);
+ if (anp->data.ptrvalue == NULL) {
+ goto erret;
+ }
+ }
+
+ret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return anp;
+
+erret:
+ anp = MemFree(anp);
+ goto ret;
+}
+
+
+/**************************************************
+*
+* SpellResponseAsnWrite()
+*
+**************************************************/
+Boolean LIBCALL
+SpellResponseAsnWrite(SpellResponsePtr anp, AsnIoPtr aip, AsnTypePtr orig)
+
+{
+ DataVal av;
+ AsnTypePtr atp, writetype = NULL;
+ Pointer pnt;
+ AsnWriteFunc func = NULL;
+ Boolean retval = FALSE;
+
+ if (! loaded)
+ {
+ if (! objspellAsnLoad())
+ return FALSE;
+ }
+
+ if (aip == NULL)
+ return FALSE;
+
+ atp = AsnLinkType(orig, SPELL_RESPONSE); /* link local tree */
+ if (atp == NULL) {
+ return FALSE;
+ }
+
+ if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
+
+ av.ptrvalue = (Pointer)anp;
+ if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
+ goto erret;
+ }
+
+ pnt = anp->data.ptrvalue;
+ av.intvalue = anp->data.intvalue;
+ switch (anp->choice)
+ {
+ case SpellResponse_error:
+ retval = AsnWrite(aip, SPELL_RESPONSE_error, &av);
+ break;
+ case SpellResponse_init:
+ retval = AsnWrite(aip, SPELL_RESPONSE_init, &av);
+ break;
+ case SpellResponse_spelltext:
+ retval = AsnGenericBaseSeqOfAsnWrite((Pointer) pnt,ASNCODE_PTRVAL_SLOT, aip, SPELL_RESPONSE_spelltext, SPELL_RESPONSE_spelltext_E); break;
+ case SpellResponse_fini:
+ retval = AsnWrite(aip, SPELL_RESPONSE_fini, &av);
+ break;
+ }
+ if (writetype != NULL) {
+ retval = (* func)(pnt, aip, writetype); /* write it out */
+ }
+ if (!retval) {
+ goto erret;
+ }
+ retval = TRUE;
+
+erret:
+ AsnUnlinkType(orig); /* unlink local tree */
+ return retval;
+}
diff --git a/network/spell/client/objspell.h b/network/spell/client/objspell.h
new file mode 100644
index 00000000..607d3c6d
--- /dev/null
+++ b/network/spell/client/objspell.h
@@ -0,0 +1,57 @@
+/*
+*
+*
+* RCS Modification History:
+* $Log: objspell.h,v $
+* Revision 6.0 1997/08/25 18:40:26 madden
+* Revision changed to 6.0
+*
+* Revision 4.0 1995/07/26 13:55:42 ostell
+* force revision to 4.0
+*
+ * Revision 1.2 1995/05/17 17:59:53 epstein
+ * add RCS log revision history
+ *
+*/
+
+#ifndef _objspell_
+#define _objspell_
+
+#ifdef __cplusplus
+extern "C" { /* } */
+#endif
+
+
+/**************************************************
+*
+* Generated objects for Module NCBI-SPELL
+*
+**************************************************/
+typedef ValNodePtr SpellRequestPtr;
+typedef ValNode SpellRequest;
+#define SpellRequest_init 1
+#define SpellRequest_spelltext 2
+#define SpellRequest_fini 3
+
+
+SpellRequestPtr LIBCALL SpellRequestFree PROTO ((SpellRequestPtr ));
+SpellRequestPtr LIBCALL SpellRequestAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+Boolean LIBCALL SpellRequestAsnWrite PROTO (( SpellRequestPtr , AsnIoPtr, AsnTypePtr));
+
+typedef ValNodePtr SpellResponsePtr;
+typedef ValNode SpellResponse;
+#define SpellResponse_error 1
+#define SpellResponse_init 2
+#define SpellResponse_spelltext 3
+#define SpellResponse_fini 4
+
+
+SpellResponsePtr LIBCALL SpellResponseFree PROTO ((SpellResponsePtr ));
+SpellResponsePtr LIBCALL SpellResponseAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
+Boolean LIBCALL SpellResponseAsnWrite PROTO (( SpellResponsePtr , AsnIoPtr, AsnTypePtr));
+
+#ifdef __cplusplus
+/* { */ }
+#endif
+
+#endif
diff --git a/network/spell/client/spell.asn b/network/spell/client/spell.asn
new file mode 100644
index 00000000..af69260e
--- /dev/null
+++ b/network/spell/client/spell.asn
@@ -0,0 +1,27 @@
+--
+--********************************************************************
+--
+-- Spell checker for MEDLINE
+-- Jonathan Epstein
+-- June 1994
+--
+--
+--********************************************************************
+
+NCBI-SPELL DEFINITIONS ::=
+BEGIN
+
+Spell-request ::= CHOICE {
+ init NULL ,
+ spelltext VisibleString ,
+ fini NULL
+}
+
+Spell-response ::= CHOICE {
+ error INTEGER ,
+ init NULL ,
+ spelltext SEQUENCE OF VisibleString ,
+ fini NULL
+}
+
+END
diff --git a/network/spell/client/spellapi.c b/network/spell/client/spellapi.c
new file mode 100644
index 00000000..42fadaad
--- /dev/null
+++ b/network/spell/client/spellapi.c
@@ -0,0 +1,453 @@
+/*
+*
+*
+* RCS Modification History:
+* $Log: spellapi.c,v $
+* Revision 6.1 1998/02/03 16:51:12 shavirin
+* Removed some memory leaks.
+*
+* Revision 6.0 1997/08/25 18:40:31 madden
+* Revision changed to 6.0
+*
+* Revision 4.0 1995/07/26 13:55:42 ostell
+* force revision to 4.0
+*
+ * Revision 1.7 1995/05/31 21:12:10 ostell
+ * added SpellCheckData() to return user supplied data ptr and eliminate
+ * the need for global static variables by calling functions
+ *
+ * Revision 1.6 1995/05/17 17:59:56 epstein
+ * add RCS log revision history
+ *
+*/
+
+#include <ncbinet.h>
+#include "spellapi.h"
+#include "objspell.h"
+
+static SpellResponsePtr NetSpellReadAsn PROTO((void));
+static Boolean ReestablishNetSpell PROTO((void));
+static Boolean NetInit PROTO((void));
+static Boolean ForceNetInit PROTO((void));
+static Boolean NetFini PROTO((void));
+static Boolean GenericReestablishNet PROTO((CharPtr svcName, Boolean showErrs));
+static NI_HandPtr svcp = NULL;
+static AsnIoPtr asnin = NULL;
+static AsnIoPtr asnout = NULL;
+SpellRequestPtr sprp;
+SpellResponsePtr spbp;
+static Boolean num_attached = 0;
+static Boolean reallyFinal = TRUE;
+static NI_DispatcherPtr dispatcher;
+static Boolean (*myNetInit) PROTO((void));
+
+
+
+
+/*****************************************************************************
+*
+* SpellInit ()
+*
+*****************************************************************************/
+
+Boolean SpellInit (void)
+
+{
+ DataVal av;
+
+ myNetInit = SpellInit;
+
+ if (! NetInit())
+ return FALSE;
+
+ svcp = NI_GenericGetService(dispatcher, NULL, "SPELL", "Spell", TRUE);
+ if (svcp == NULL)
+ {
+ ErrPostEx(SEV_ERROR, 0, 0, "NI_ServiceGet [%s] (%s)", ni_errlist[ni_errno], ni_errtext);
+ SpellFini();
+ return FALSE;
+ }
+
+ asnin = svcp->raip;
+ asnout = svcp->waip;
+
+ /**********************************************************/
+
+ sprp = ValNodeNew(NULL);
+ sprp->choice = SpellRequest_init;
+ SpellRequestAsnWrite (sprp, asnout, NULL);
+ AsnIoReset(asnout);
+ SpellRequestFree (sprp);
+
+ if ((spbp = NetSpellReadAsn()) == NULL)
+ {
+ return FALSE;
+ }
+ else
+ {
+ spbp->data.ptrvalue = NULL;
+ SpellResponseFree (spbp);
+ return TRUE;
+ }
+}
+
+/*****************************************************************************
+*
+* SpellFini ()
+*
+*****************************************************************************/
+
+static Boolean s_SpellFini (void)
+
+{
+ Boolean retval = TRUE;
+
+ if (asnout != NULL && asnin != NULL)
+ {
+ sprp = ValNodeNew(NULL);
+ sprp->choice = SpellRequest_fini;
+ SpellRequestAsnWrite (sprp, asnout, NULL);
+ AsnIoReset(asnout);
+ SpellRequestFree (sprp);
+
+ if ((spbp = NetSpellReadAsn()) == NULL)
+ {
+ retval = FALSE;
+ }
+ else
+ {
+ spbp->data.ptrvalue = NULL;
+ SpellResponseFree (spbp);
+ retval = TRUE;
+ }
+ }
+
+ NetFini();
+ return retval;
+}
+
+/* the only thing done here is to suppress errors */
+
+Boolean SpellFini (void)
+
+{
+ short erract;
+ ErrDesc err;
+ Boolean retval;
+
+ ErrGetOpts(&erract, NULL);
+ ErrSetOpts(ERR_IGNORE, 0);
+ ErrFetch(&err);
+
+ retval = s_SpellFini();
+
+ ErrSetOpts(erract, 0);
+ ErrFetch(&err);
+
+ return retval;
+}
+
+static ValNodePtr
+s_SpellCheck(CharPtr str)
+{
+ SpellRequestPtr sprp;
+ ValNodePtr retval;
+
+ sprp = ValNodeNew(NULL);
+ sprp->choice = SpellRequest_spelltext;
+ sprp->data.ptrvalue = str;
+ SpellRequestAsnWrite(sprp, asnout, NULL);
+ AsnIoReset(asnout);
+ sprp->data.ptrvalue = NULL;
+
+ if ((spbp = NetSpellReadAsn()) == NULL )
+ return NULL;
+
+ if (spbp->choice != SpellResponse_spelltext)
+ {
+ SpellResponseFree( sprp );
+ return NULL;
+ }
+ retval = (ValNodePtr) spbp->data.ptrvalue;
+ spbp->data.ptrvalue = NULL;
+
+ SpellResponseFree(sprp);
+ SpellResponseFree(spbp);
+
+ return retval;
+}
+
+int SpellCheck(CharPtr str, void (*CallBack)(CharPtr))
+{
+ Int4 i;
+ short erract;
+ ErrDesc err;
+ ValNodePtr vnp = NULL;
+ ValNodePtr v;
+ int retval = 0;
+ CharPtr p;
+ CharPtr str2;
+
+ if (str == NULL)
+ return 0;
+
+ /* convert the string, converting characters which may not appear in */
+ /* a VisibleString to blanks */
+ str2 = StringSave(str);
+ for (p = str2; *p; p++)
+ {
+ if (*p < ' ' || *p >= 0x7f)
+ *p = ' ';
+ }
+
+ for (i = 0; i < SPELL_SERV_RETRIES; i++)
+ {
+ if (i > 0)
+ {
+ if (! ReestablishNetSpell())
+ break;
+ }
+
+ ErrGetOpts(&erract, NULL);
+ ErrSetOpts(ERR_IGNORE, 0);
+ ErrFetch(&err);
+
+ vnp = s_SpellCheck(str2);
+
+ ErrSetOpts(erract, 0);
+ if (! ErrFetch(&err))
+ break; /* success */
+ }
+
+ for (v = vnp; v != NULL; v = v->next)
+ {
+ if (CallBack != NULL)
+ CallBack((CharPtr) v->data.ptrvalue);
+ retval++;
+ }
+ ValNodeFreeData(vnp);
+
+ MemFree(str2);
+
+ return retval;
+}
+
+int SpellCheckData(CharPtr str, void (*CallBack)(CharPtr, Pointer), Pointer userdata)
+{
+ Int4 i;
+ short erract;
+ ErrDesc err;
+ ValNodePtr vnp = NULL;
+ ValNodePtr v;
+ int retval = 0;
+ CharPtr p;
+ CharPtr str2;
+
+ if (str == NULL)
+ return 0;
+
+ /* convert the string, converting characters which may not appear in */
+ /* a VisibleString to blanks */
+ str2 = StringSave(str);
+ for (p = str2; *p; p++)
+ {
+ if (*p < ' ' || *p >= 0x7f)
+ *p = ' ';
+ }
+
+ for (i = 0; i < SPELL_SERV_RETRIES; i++)
+ {
+ if (i > 0)
+ {
+ if (! ReestablishNetSpell())
+ break;
+ }
+
+ ErrGetOpts(&erract, NULL);
+ ErrSetOpts(ERR_IGNORE, 0);
+ ErrFetch(&err);
+
+ vnp = s_SpellCheck(str2);
+
+ ErrSetOpts(erract, 0);
+ if (! ErrFetch(&err))
+ break; /* success */
+ }
+
+ for (v = vnp; v != NULL; v = v->next)
+ {
+ if (CallBack != NULL)
+ CallBack((CharPtr) v->data.ptrvalue, userdata);
+ retval++;
+ }
+ ValNodeFreeData(vnp);
+
+ return retval;
+}
+
+int StringInMedline(CharPtr String, void (*CallBack)(CharPtr))
+{
+ int retval;
+
+ if (! SpellInit())
+ {
+ return 0;
+ }
+ retval = SpellCheck(String, CallBack);
+ SpellFini();
+
+ return retval;
+}
+
+
+/*****************************************************************************
+*
+* NetSpellReadAsn ()
+*
+*****************************************************************************/
+
+static SpellResponsePtr NetSpellReadAsn(void)
+{
+ SpellResponsePtr spbp;
+ short erract;
+ ErrDesc err;
+
+ ErrGetOpts(&erract, NULL);
+ ErrSetOpts(ERR_IGNORE, 0);
+ ErrFetch(&err); /* clear any pending error */
+
+ spbp = SpellResponseAsnRead(asnin, NULL);
+
+ if (ErrFetch(&err))
+ {
+ ErrPost(CTX_UNKNOWN, 1, "Null message read from server");
+ }
+ ErrSetOpts(erract, 0);
+
+ return spbp;
+}
+
+/*****************************************************************************
+*
+* ReestablishNetSpell ()
+*
+*****************************************************************************/
+
+static Boolean ReestablishNetSpell(void)
+{
+ return GenericReestablishNet("Spell", TRUE);
+}
+
+/*****************************************************************************
+*
+* GenericReestablishNet ()
+*
+*****************************************************************************/
+
+static Boolean GenericReestablishNet(CharPtr svcName, Boolean showErrs)
+{
+ Handle mon = NULL;
+ Boolean retval;
+ CharPtr buf;
+
+ buf = MemNew(2 * StrLen(svcName) + 60);
+
+ if (showErrs) {
+ sprintf (buf, "Re-establishing %s Service", svcName);
+ mon = MonitorStrNew(buf, 40);
+ sprintf (buf, "Requesting %s service", svcName);
+ MonitorStrValue(mon, buf);
+ }
+ NetFini();
+ retval = TRUE;
+
+ if (! myNetInit())
+ {
+ sprintf (buf, "%s get failed; re-contacting dispatcher", svcName);
+ MonitorStrValue(mon, buf);
+ retval = FALSE;
+ if (ForceNetInit())
+ { /* successfully established contact w/dispatcher */
+ sprintf (buf, "%s get failed; re-requesting %s service",
+ svcName, svcName);
+ MonitorStrValue(mon, buf);
+ retval = myNetInit();
+ }
+ else {
+ ErrPost(CTX_UNKNOWN, 1, "Unable to re-contact dispatcher");
+ if (showErrs) {
+ ErrShow();
+ }
+ }
+ }
+
+ MonitorFree(mon);
+
+ if (! retval )
+ {
+ sprintf (buf, "Unable to re-establish %s service", svcName);
+ ErrPost(CTX_UNKNOWN, 1, buf);
+ if (showErrs) {
+ ErrShow();
+ }
+ }
+
+ MemFree(buf);
+ return retval;
+}
+
+/*****************************************************************************
+*
+* NetInit ()
+*
+*****************************************************************************/
+
+static Boolean
+NetInit(void)
+{
+ if (num_attached++ > 0)
+ return TRUE;
+
+ return ((dispatcher = NI_GenericInit(NULL, NULL, TRUE, NULL, 0)) != NULL);
+}
+
+
+/*****************************************************************************
+*
+* ForceNetInit ()
+*
+*****************************************************************************/
+
+static Boolean ForceNetInit(void)
+{
+ Boolean retval;
+
+ reallyFinal = FALSE;
+ num_attached = 0; /* force re-attempt to contact dispatcher */
+ retval = NetInit();
+ reallyFinal = TRUE;
+
+ return retval;
+}
+
+/*****************************************************************************
+*
+* NetFini ()
+*
+*****************************************************************************/
+
+static Boolean NetFini(void)
+{
+ if (num_attached > 0)
+ num_attached--;
+
+ if (num_attached == 0)
+ {
+ NI_ServiceDisconnect(svcp);
+ svcp = NULL;
+ NI_EndServices (dispatcher);
+ dispatcher = NULL;
+ }
+
+ return TRUE;
+}
diff --git a/network/spell/client/spellapi.h b/network/spell/client/spellapi.h
new file mode 100644
index 00000000..6c2ce0e5
--- /dev/null
+++ b/network/spell/client/spellapi.h
@@ -0,0 +1,27 @@
+/*
+*
+*
+* RCS Modification History:
+* $Log: spellapi.h,v $
+* Revision 6.0 1997/08/25 18:40:34 madden
+* Revision changed to 6.0
+*
+* Revision 4.0 1995/07/26 13:55:42 ostell
+* force revision to 4.0
+*
+ * Revision 1.3 1995/05/31 21:12:10 ostell
+ * added SpellCheckData() to return user supplied data ptr and eliminate
+ * the need for global static variables by calling functions
+ *
+ * Revision 1.2 1995/05/17 17:59:58 epstein
+ * add RCS log revision history
+ *
+*/
+
+Boolean SpellInit PROTO((void));
+Boolean SpellFini PROTO((void));
+int SpellCheck PROTO((CharPtr String, void (*CallBack)(CharPtr)));
+int SpellCheckData PROTO((CharPtr String, void (*CallBack)(CharPtr,Pointer), Pointer userdata));
+int StringInMedline PROTO((CharPtr String, void (*CallBack)(CharPtr)));
+
+#define SPELL_SERV_RETRIES 2
diff --git a/network/spell/server/fmspell.c b/network/spell/server/fmspell.c
new file mode 100644
index 00000000..ce5e21c4
--- /dev/null
+++ b/network/spell/server/fmspell.c
@@ -0,0 +1,136 @@
+/* $Id: fmspell.c,v 1.1 1998/02/24 21:01:22 shavirin Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government have not placed any restriction on its use or reproduction.
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* Please cite the author in any work or product based on this material.
+*
+* ===========================================================================
+*
+* File Name: $RCSfile: fmspell.c,v $
+*
+* Author: Sergei Shavirin
+*
+* Initial Version Creation Date: 02/24/1998
+*
+* $Revision: 1.1 $
+*
+* File Description:
+* Database formatter for NCBI SPELL Service
+*
+* $Log: fmspell.c,v $
+* Revision 1.1 1998/02/24 21:01:22 shavirin
+* Initial revision
+*
+*
+* ==========================================================================
+*/
+
+#include <ncbi.h>
+#include <ncbisort.h>
+#include <ncbisam.h>
+
+#define NUMARG 3
+
+Args fmspell_args[NUMARG] = {
+ { "Input file name for spell database",
+ "termlist", NULL, NULL, FALSE, 'd', ARG_STRING, 0.0, 0, NULL},
+ {"Input file anme for stop words",
+ "stopwords", NULL,NULL,FALSE,'s',ARG_FILE_IN, 0.0,0,NULL},
+ {"Logfile name:",
+ "fmspell.log", NULL,NULL,TRUE,'l',ARG_FILE_OUT, 0.0,0,NULL}
+};
+
+#define DB_filename (CharPtr) fmspell_args[0].strvalue
+#define STOP_filename (CharPtr) fmspell_args[1].strvalue
+#define LogFileName (CharPtr) fmspell_args[2].strvalue
+
+static Boolean FMSpellCreateIndex(CharPtr db_name)
+{
+ SORTObjectPtr sop;
+ Char filenamebuf[FILENAME_MAX], DBName[FILENAME_MAX];
+ Char ext1[8], ext2[8], ext3[8], ext4[8];
+ FILE *fd_out;
+ CharPtr files;
+ ISAMErrorCode error;
+ ISAMObjectPtr isamp;
+
+ /* object for unique sorting */
+
+ if((sop = SORTObjectNew(NULL, '\0', 0,
+ FALSE, TRUE)) == NULL) {
+ ErrPostEx(SEV_ERROR, 0, 0, "Failed to create SORT Object");
+ return FALSE;
+ }
+
+ sprintf(filenamebuf, "%s.tmp", db_name);
+
+ if((fd_out = FileOpen(filenamebuf, "w")) == NULL)
+ return FALSE;
+
+ files = db_name;
+
+ SORTFiles(&files, 1, fd_out, sop);
+ SORTObjectFree(sop);
+
+ FileClose(fd_out);
+ FileRename(filenamebuf, db_name);
+
+ sprintf(filenamebuf, "%s.idx", db_name);
+
+ if((isamp = ISAMObjectNew(ISAMString, db_name,
+ filenamebuf)) == NULL) {
+ ErrPostEx(SEV_ERROR, 0, 0, "Creating of ISAM object failed");
+ return FALSE;
+ }
+
+ if((error = ISAMMakeIndex(isamp, 0)) != ISAMNoError) {
+ ErrPostEx(SEV_ERROR, 0, 0, "Creating of index failed with "
+ "error code %ld\n", (long) error);
+ ISAMObjectFree(isamp);
+ return FALSE;
+ }
+
+ ISAMObjectFree(isamp);
+
+ return TRUE;
+}
+
+Int2 Main(void)
+{
+
+ if ( !GetArgs ("fmspell", NUMARG, fmspell_args) ) {
+ return -1;
+ }
+ if ( !ErrSetLog (LogFileName) ) {
+ ErrShow();
+ } else {
+ ErrSetOpts (ERR_CONTINUE, ERR_LOG_ON);
+ }
+
+ if(!FMSpellCreateIndex(DB_filename))
+ return 1;
+
+ if(!FMSpellCreateIndex(STOP_filename))
+ return 1;
+
+ ErrPostEx(SEV_INFO, 0, 0, "Formating finished successfuly");
+
+ return 0;
+}
diff --git a/network/spell/server/spellsrv.c b/network/spell/server/spellsrv.c
new file mode 100644
index 00000000..fcc169d2
--- /dev/null
+++ b/network/spell/server/spellsrv.c
@@ -0,0 +1,414 @@
+/* $Id: spellsrv.c,v 1.2 1998/02/25 19:33:01 shavirin Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government have not placed any restriction on its use or reproduction.
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* Please cite the author in any work or product based on this material.
+*
+* ===========================================================================
+*
+* File Name: $RCSfile: spellsrv.c,v $
+*
+* Author: Sergei Shavirin
+*
+* Initial Version Creation Date: 02/24/1998
+*
+* $Revision: 1.2 $
+*
+* File Description:
+* Main file for NCBI SPELL Service
+*
+* $Log: spellsrv.c,v $
+* Revision 1.2 1998/02/25 19:33:01 shavirin
+* Added additional filtering of words.
+*
+*
+* ==========================================================================
+*/
+#include <ncbi.h>
+#include <ncbinet.h>
+#include <objspell.h>
+#include <ncbisam.h>
+
+#define SPELL_MAX_WORD_SIZE 512
+#define NUMARG 5
+
+#define IS_VALID(c) (isalnum(c) || ((c) == '-') || ((c) == '+') || ((c) == '_') || ((c) == '&') || ((c) == '\'') || ((c) == '`'))
+
+Args spellsrv_args[NUMARG] = {
+ { "Input file name for spell database",
+ "termlist", NULL, NULL, TRUE, 't', ARG_STRING, 0.0, 0, NULL},
+ {"Input file anme for stop words",
+ "stopwords", NULL,NULL, TRUE,'s',ARG_FILE_IN, 0.0,0,NULL},
+ {"Logfile name:",
+ "/dev/null", NULL,NULL,TRUE,'l',ARG_FILE_OUT, 0.0,0,NULL},
+ {"Debug mode",
+ NULL, NULL,NULL,TRUE,'d',ARG_BOOLEAN, 0.0,0,NULL},
+ {"Standalone mode",
+ NULL, NULL,NULL,TRUE,'z',ARG_BOOLEAN, 0.0,0,NULL}
+};
+
+#define DB_filename (CharPtr) spellsrv_args[0].strvalue
+#define STOP_filename (CharPtr) spellsrv_args[1].strvalue
+#define LogFileName (CharPtr) spellsrv_args[2].strvalue
+#define DebugMode (CharPtr) spellsrv_args[3].intvalue
+#define StandAlone (CharPtr) spellsrv_args[4].intvalue
+
+typedef struct SPELLData
+{
+ ISAMObjectPtr term_isamp;
+ ISAMObjectPtr stop_isamp;
+} SPELLData, PNTR SPELLDataPtr;
+
+Boolean SPELLSendResponse(Pointer ptr, AsnIoPtr asnout, Int4 error)
+{
+ SpellResponsePtr srp;
+
+ srp = ValNodeNew(NULL);
+
+ if (error != NULL) {
+ srp->choice = SpellResponse_error;
+ srp->data.intvalue = error;
+ } else {
+ srp->choice = SpellResponse_spelltext;
+ srp->data.ptrvalue = ptr;
+ }
+
+ SpellResponseAsnWrite(srp, asnout, NULL);
+
+ srp->data.ptrvalue = NULL;
+ SpellResponseFree(srp);
+}
+
+static Int4 SPELLFindWord(SPELLDataPtr spellp, CharPtr word)
+{
+ Uint4 index;
+ ISAMErrorCode error;
+
+ if((error = SISAMSearch(spellp->stop_isamp, word, 0, NULL,
+ NULL, &index)) < 0) {
+ ErrPostEx(SEV_FATAL, 0, 0, "Failed to search string index "
+ "ISAM Error code is %d\n", error);
+ return error;
+ }
+
+ /* If word found in "stopwords" - skip main search */
+
+ if(error == ISAMNoError)
+ return 1;
+
+ if((error = SISAMSearch(spellp->term_isamp, word, 0, NULL,
+ NULL, &index)) < 0) {
+ ErrPostEx(SEV_FATAL, 0, 0, "Failed to search string index "
+ "ISAM Error code is %d\n", error);
+ return error;
+ }
+
+ if(error == ISAMNoError)
+ return 1;
+
+ return 0;
+}
+
+static void SPELLGetWord(CharPtr word, CharPtr line, Int4 wordsize)
+{
+ Int4 x = 0, y = 0;
+
+ /* Looking for alphanumeric in the beginning of the word */
+
+ for(x = 0; line[x] && !isalnum(line[x]); x++)
+ continue;
+
+ while(TRUE && y < wordsize) {
+ if(!(word[y] = line[x]))
+ break;
+ if(!IS_VALID(line[x]))
+ break;
+ ++y; ++x;
+ }
+
+ word[y] = '\0';
+
+ while(line[x] && !isalnum(line[x])) ++x;
+
+ for(y=0;(line[y] = line[x]);++x,++y);
+}
+
+Boolean SPELLFixWord(CharPtr word)
+{
+ Int4 i, len;
+
+ StrLower(word);
+ len = StringLen(word);
+
+ /* Testing for all numerics and accessions */
+
+ if(len == 1)
+ return FALSE;
+
+ if(isdigit(*word)) {
+ for(i = 1; i < len; i++) {
+ if(!(isdigit(word[i]) || ispunct(word[i])))
+ break;
+ }
+
+ if(i == len) return FALSE; /* This is number */
+
+ }
+
+ /* Testing, that this is 6 length accession */
+
+ if(len == 6 && isalpha(word[0])) {
+ for(i = 1; i < len; i++) {
+ if(!isdigit(word[i]))
+ break;
+ }
+
+ if (i == len) return FALSE; /* This is accession */
+
+ }
+
+ if(len == 8 && isalpha(word[0]) && isalpha(word[1])) {
+ for(i = 2; i < len; i++) {
+ if(!isdigit(word[i])) {
+ break;
+ }
+ }
+
+ if (i == len) return FALSE; /* This is accession */
+
+ }
+
+ return TRUE;
+}
+
+static ValNodePtr SPELLCheckString(SPELLDataPtr spellp, CharPtr string)
+{
+ Int4 len, i, result;
+ Char word[SPELL_MAX_WORD_SIZE];
+ CharPtr p, chptr, strtmp;
+ ValNodePtr head = NULL, vnp, vnp_l;
+
+ chptr = strtmp = StringSave(string);
+
+ /* Some usefull filtering */
+
+ for (p = strtmp; *p; p++) {
+ if (*p < ' ' || *p >= 0x7f)
+ *p = ' ';
+ }
+
+ /* Removing punctuation in the end of the string */
+
+ do {
+ SPELLGetWord(word, strtmp, SPELL_MAX_WORD_SIZE);
+
+ if(!SPELLFixWord(word)) /* FALSE will filter the word */
+ continue;
+
+ if((result = SPELLFindWord(spellp, word)) == 0) { /* not found */
+ if(head == NULL) {
+ head = ValNodeNew(NULL);
+ head->data.ptrvalue = StringSave(word);
+ vnp_l = head;
+ } else {
+ vnp = ValNodeNew(NULL);
+ vnp->data.ptrvalue = StringSave(word);
+ vnp_l->next = vnp;
+ vnp_l = vnp;
+ }
+ } else if(result < 0) {
+ break;
+ } else {
+ continue;
+ }
+ } while (*strtmp != NULLB);
+
+ MemFree(chptr);
+
+ return head;
+}
+
+static SPELLDataPtr SPELLInit(CharPtr db_name, CharPtr stop_name)
+{
+ SPELLDataPtr spellp;
+ Char buffer[PATH_MAX], buffer1[PATH_MAX];
+ CharPtr path;
+
+ spellp = MemNew(sizeof(SPELLData));
+
+ if((path = getenv("SPELLCHECKDIR")) == NULL)
+ path = ".";
+
+ /* Initializing termlist */
+
+
+ sprintf(buffer1, "%s/%s", path, db_name);
+ sprintf(buffer, "%s/%s.idx", path, db_name);
+
+ if(FileLength(buffer) != 0 && FileLength(buffer1) != 0) {
+ if((spellp->term_isamp = ISAMObjectNew(ISAMString,
+ buffer1, buffer)) == NULL) {
+ ErrPostEx(SEV_ERROR, 993, 1, "Failed to create SISAM object");
+ return NULL;
+ }
+ } else {
+ ErrPostEx(SEV_ERROR, 993, 1,
+ "Database or index term files do not exists");
+ return NULL;
+ }
+ /* Initializing stopwords list */
+
+ sprintf(buffer1, "%s/%s", path, stop_name);
+ sprintf(buffer, "%s/%s.idx", path, stop_name);
+ if(FileLength(buffer) != 0 && FileLength(buffer1) != 0) {
+ if((spellp->stop_isamp = ISAMObjectNew(ISAMString,
+ buffer1, buffer)) == NULL) {
+ ErrPostEx(SEV_ERROR, 993, 1, "Failed to create SISAM object");
+ return NULL;
+ }
+ } else {
+ ErrPostEx(SEV_ERROR, 993, 1,
+ "Database or index term files do not exists");
+ return NULL;
+ }
+
+ return spellp;
+}
+static void SPELLFree(SPELLDataPtr spellp)
+{
+ ISAMObjectFree(spellp->term_isamp);
+ ISAMObjectFree(spellp->stop_isamp);
+
+ MemFree(spellp);
+ return;
+}
+
+Int2 Main(void)
+{
+ SpellRequestPtr splrp;
+ SpellResponsePtr splbp;
+ Boolean done = FALSE;
+ short erract;
+ ErrDesc err;
+ NI_HandPtr hp;
+ Char buf[100];
+ AsnIoPtr asnin;
+ AsnIoPtr asnout;
+ int read_timeout;
+ SPELLDataPtr spellp;
+ ValNodePtr vnp;
+
+ if (!GetArgs ("spellsrv", NUMARG, spellsrv_args) ) {
+ return -1;
+ }
+ if (!ErrSetLog (LogFileName) ) {
+ ErrShow();
+ } else {
+ ErrSetOpts (ERR_CONTINUE, ERR_LOG_ON);
+ }
+
+ if((spellp = SPELLInit(DB_filename, STOP_filename)) == NULL)
+ return 1;
+
+ if (!StandAlone && !DebugMode) {
+ NI_ServerACK();
+
+ hp = NI_OpenASNIO();
+
+ /* this read-timeout is effectively an idle timeout for */
+ /* the server process; the process will terminate upon */
+ /* read-timeout */
+ GetAppParam("NCBI", "NET_SERV", "SERV_INACT_TIMER", "10",
+ buf, sizeof buf);
+ read_timeout = atoi(buf) * 60; /* param is minutes */
+ MsgSetReadTimeout(hp, read_timeout);
+
+ asnin = hp->raip;
+ asnout = hp->waip;
+ } else if (StandAlone) {
+ asnin = AsnIoNew(ASNIO_BIN_IN, stdin, NULL, NULL, NULL);
+ asnout = AsnIoNew(ASNIO_BIN_OUT, stdout, NULL, NULL, NULL);
+ } else {
+ asnin = AsnIoOpen("spellserv.inp", "r");
+ asnout = AsnIoOpen("spellserv.out", "w");
+ }
+
+ while (!done) {
+ /* encountering EOF on reading is a "normal" occurrence, */
+ /* and does not merit an error message */
+ ErrGetOpts(&erract, NULL);
+ ErrSetOpts(ERR_IGNORE, 0);
+ ErrFetch(&err); /* clear any pending error, which can be ignored */
+
+ splrp = SpellRequestAsnRead(asnin, NULL);
+
+ if (ErrFetch(&err))
+ {
+ done = TRUE;
+ Message(MSG_POST, "Error encountered on AsnReadId %d", err);
+ break; /* client terminated */
+ }
+ ErrSetOpts(erract, 0);
+
+ if (splrp == NULL)
+ {
+ done = TRUE;
+ Message(MSG_POST, "Null AsnReadId");
+ break; /* client terminated */
+ }
+
+ switch (splrp->choice) {
+
+ case SpellRequest_init:
+
+ splbp = ValNodeNew(NULL);
+ splbp->choice = SpellResponse_init;
+ splbp->data.ptrvalue = NULL;
+ SpellResponseAsnWrite (splbp, asnout, NULL);
+ SpellResponseFree (splbp);
+ splrp->data.ptrvalue = NULL;
+ break;
+
+ case SpellRequest_spelltext:
+
+ vnp = SPELLCheckString(spellp, (CharPtr) splrp->data.ptrvalue);
+ SPELLSendResponse((Pointer) vnp, asnout, 0);
+ break;
+
+ case SpellRequest_fini:
+
+ done = TRUE;
+ splbp = ValNodeNew(NULL);
+ splbp->choice = SpellResponse_fini;
+ splbp->data.ptrvalue = NULL;
+
+ SpellResponseAsnWrite (splbp, asnout, NULL);
+ SpellResponseFree (splbp);
+ splrp->data.ptrvalue = NULL;
+ break;
+ }
+
+ AsnIoReset (asnout);
+ SpellRequestFree (splrp);
+ }
+
+ AsnIoClose (asnin);
+ AsnIoClose (asnout);
+}
diff --git a/network/taxon1/taxon2/txcdproc.c b/network/taxon1/taxon2/txcdproc.c
index 2aab690f..f8055068 100644
--- a/network/taxon1/taxon2/txcdproc.c
+++ b/network/taxon1/taxon2/txcdproc.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 07/15/97
*
-* $Revision: 1.15 $
+* $Revision: 1.16 $
*
* File Description:
* API for Taxonomy service
@@ -44,6 +44,9 @@
*
* RCS Modification History:
* $Log: txcdproc.c,v $
+* Revision 1.16 2003/11/04 17:13:58 soussov
+* adds NetFini() call if service can not start properly
+*
* Revision 1.15 2003/06/12 16:46:25 soussov
* changes severity for AsnRead failures
*
@@ -215,6 +218,7 @@ static Boolean TaxServInit(void)
Taxon1ReqFree (taxrp);
if((taxbp = NetTaxArchReadAsn()) == NULL) {
+ NetFini();
return FALSE;
}
else {
diff --git a/network/vibnet/docsum.c b/network/vibnet/docsum.c
index e2b282a0..be09ca80 100644
--- a/network/vibnet/docsum.c
+++ b/network/vibnet/docsum.c
@@ -29,13 +29,16 @@
*
* Version Creation Date: 9/13/96
*
-* $Revision: 6.55 $
+* $Revision: 6.56 $
*
* File Description:
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: docsum.c,v $
+* Revision 6.56 2003/12/02 20:42:06 kans
+* fixed sprintf calls in SetDefaultFailureMessae
+*
* Revision 6.55 2002/11/06 21:30:57 ucko
* ChangeViewerLinkData: when extracting a string from vnp->data, use
* ptrvalue rather than intvalue (which may be the wrong width)
@@ -672,16 +675,16 @@ static CharPtr SetDefaultFailureMessage (SummFormPtr sfp, Int2 item, CharPtr pre
} else if (sfp->simple != NULL && sfp->uids == NULL) {
ssp = sfp->simple [item - 1];
if (ssp == NULL) {
- sprintf ("%sIncorrect seq-entry for database %s", prefix, dbname);
+ sprintf (tmp, "%sIncorrect seq-entry for database %s", prefix, dbname);
} else {
StringCpy (buf, "?");
if (ssp->numid > 0 && ssp->bestid < ssp->numid) {
StringNCpy_0 (buf, ssp->id [ssp->bestid], sizeof (buf));
}
- sprintf ("%sProblem with sequence %s in %s database", prefix, buf, dbname);
+ sprintf (tmp, "%sProblem with sequence %s in %s database", prefix, buf, dbname);
}
} else {
- sprintf ("%sInternal confusion for database %s", prefix, dbname);
+ sprintf (tmp, "%sInternal confusion for database %s", prefix, dbname);
}
return StringSave (tmp);
}
diff --git a/network/wwwblast/Src/Makefile b/network/wwwblast/Src/Makefile
index 8ea0c4c3..62186b24 100644
--- a/network/wwwblast/Src/Makefile
+++ b/network/wwwblast/Src/Makefile
@@ -14,10 +14,9 @@ THREAD_LIBS = -lpthread
#NCBI_OTHERLIBS += -lposix4 -lresolv -lsocket -lrpcsvc -lnsl -lgen
# Solaris Sparc
#NCBI_OTHERLIBS += -lposix4 -lresolv -lsocket -lrpcsvc -lnsl
-# Darwin
+# MacOS
#NCBI_OTHERLIBS = -lc
#THREAD_LIBS =
-#DEFINE = -DDARWIN
#
CC=cc
@@ -46,6 +45,8 @@ DEBUG_FLAG = -g
#OPTIMIZED compilation
LIBS = $(NCBI_LIBDIR)
DEBUG_FLAG = -O
+# For MacOS, use the following line:
+#DEBUG_FLAG = -O2 -g
OBJ_FILES = wwwbutl.c $(LIBS)/ncbithr.o
@@ -60,49 +61,58 @@ INCDIR = -I. -I$(NCBI_INCDIR)
#BLASTQUE = /home/dondosha/BlastQueue
#INCDIR = -I$(BLASTQUE)/Client -I$(BLASTQUE)/ASN.1 -I. -I$(NCBI_INCDIR)
+CFLAGS = -c $(DEBUG_FLAG) $(INCDIR)
+#For MacOS, add the following line:
+#CFLAGS += -no-cpp-precomp -Wno-long-double
+
# For standalone model
-CFLAGS= $(DEBUG_FLAG) $(INCDIR)
+LDFLAGS = $(DEBUG_FLAG) $(INCDIR)
+#For MacOS, add the following line:
+#LDFLAGS += -framework CoreServices
# Use client/server for gi/accession lookups
-CFLAGS_CS = $(DEBUG_FLAG) $(INCDIR) -DNCBI_ENTREZ_CLIENT
+LDFLAGS_CS = $(DEBUG_FLAG) $(INCDIR) -DNCBI_ENTREZ_CLIENT
+#For MacOS, add the following line:
+#LDFLAGS_CS += -framework CoreServices
# For full NCBI Client-server model
-#CFLAGS_FCS= -c $(DEBUG_FLAG) $(INCDIR) -DNCBI_CLIENT_SERVER
+#CFLAGS += -DNCBI_CLIENT_SERVER
+#LDFLAGS_CS += -DNCBI_CLIENT_SERVER
.c.o: Makefile
- $(CC) -c $(CFLAGS) $<
+ $(CC) $(CFLAGS) $<
all: psiblast.REAL psiblast_cs.REAL blast.REAL blast_cs.REAL nph-viewgif.cgi wblast2.REAL wblast2_cs.REAL bl2bag.cgi
blast.REAL: wwwblast.c $(OBJ_FILES) Makefile
- $(CC) $(CFLAGS) wwwblast.c $(OBJ_FILES) \
+ $(CC) $(LDFLAGS) wwwblast.c $(OBJ_FILES) \
-L$(LIBS) $(ALL_LIBS) -o ./blast.REAL
mv ./blast.REAL ..
blast_cs.REAL: wwwblast.c $(OBJ_FILES) Makefile
- $(CC) $(CFLAGS_CS) wwwblast.c $(OBJ_FILES) \
+ $(CC) $(LDFLAGS_CS) wwwblast.c $(OBJ_FILES) \
-L$(LIBS) $(ALL_LIBS_CS) -o ./blast_cs.REAL
mv ./blast_cs.REAL ..
psiblast.REAL: psiblast.o $(OBJ_FILES) Makefile
- $(CC) $(CFLAGS) psiblast.o $(OBJ_FILES) \
+ $(CC) $(LDFLAGS) psiblast.o $(OBJ_FILES) \
-L$(LIBS) $(ALL_LIBS) -o ./psiblast.REAL
mv ./psiblast.REAL ../psiblast.REAL
psiblast_cs.REAL: psiblast.o $(OBJ_FILES) Makefile
- $(CC) $(CFLAGS_CS) psiblast.o $(OBJ_FILES) \
+ $(CC) $(LDFLAGS_CS) psiblast.o $(OBJ_FILES) \
-L$(LIBS) $(ALL_LIBS_CS) -o ./psiblast_cs.REAL
mv ./psiblast_cs.REAL ../psiblast_cs.REAL
nph-viewgif.cgi: viewgif.o
$(CC) viewgif.o -o nph-viewgif.cgi
mv nph-viewgif.cgi ..
wblast2.REAL : wblast2.c
- $(CC) $(CFLAGS) $(BL2_DEFINE) wblast2.c \
+ $(CC) $(LDFLAGS) $(BL2_DEFINE) wblast2.c \
-L$(LIBS) $(BL2_LIBS) -o ./wblast2.REAL
mv wblast2.REAL ..
wblast2_cs.REAL : wblast2.c $(BL2_OBJ)
- $(CC) $(CFLAGS_CS) $(BL2_DEFINE) wblast2.c $(BL2_OBJ) \
+ $(CC) $(LDFLAGS_CS) $(BL2_DEFINE) wblast2.c $(BL2_OBJ) \
-L$(LIBS) $(BL2_LIBS_CS) -o ./wblast2_cs.REAL
mv wblast2_cs.REAL ..
bl2bag.cgi : bl2bag.o
- $(CC) bl2bag.o -L$(LIBS) -lncbi -lm -o bl2bag.cgi
+ $(CC) $(LDFLAGS) bl2bag.o -L$(LIBS) -lncbi -lm -o bl2bag.cgi
mv bl2bag.cgi ..
xml:
diff --git a/network/wwwblast/Src/XML/Makefile b/network/wwwblast/Src/XML/Makefile
index 8e2d221c..ddfc14c4 100644
--- a/network/wwwblast/Src/XML/Makefile
+++ b/network/wwwblast/Src/XML/Makefile
@@ -24,7 +24,7 @@ LDFLAGS = -I./ -I$(INCPATH) $(OPTFLAGS) -L$(LIBPATH) $(VIBFLAG) $(NEWASN2FF) -g
bxmlobj.c: $(NCBI_ASNALL) blstxml.asn
$(ASNTOOL) -m blstxml.asn -M $(NCBI_ASNALL) -B bxmlobj -G -w100 -Z
$(ASNTOOL) -m blstxml.asn -o blstxml.h -w 100 -Z
- $(ASNTOOL) -m blstxml.asn -X NCBI_BlastOutput.mod
+# $(ASNTOOL) -m blstxml.asn -X NCBI_BlastOutput.mod
# mv bxmlobj.c ..
# mv blstxml.h ..
# mv bxmlobj.h ..
diff --git a/network/wwwblast/Src/psiblast.c b/network/wwwblast/Src/psiblast.c
index c192d0a3..b316a80e 100644
--- a/network/wwwblast/Src/psiblast.c
+++ b/network/wwwblast/Src/psiblast.c
@@ -1,4 +1,4 @@
-/* $Id: psiblast.c,v 1.3 2003/07/15 19:57:11 coulouri Exp $
+/* $Id: psiblast.c,v 1.4 2003/11/21 17:51:32 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,12 +29,15 @@
*
* Initial Version Creation Date: 04/21/2000
*
-* $Revision: 1.3 $
+* $Revision: 1.4 $
*
* File Description:
* WWW PSI BLAST Main file
*
* $Log: psiblast.c,v $
+* Revision 1.4 2003/11/21 17:51:32 dondosha
+* Minor bug fix
+*
* Revision 1.3 2003/07/15 19:57:11 coulouri
* use sigaction()
*
@@ -349,7 +352,7 @@ Int2 Main (void)
}
fprintf(stdout, "<FORM NAME=\"PSI_BLAST\" METHOD=\"POST\" "
- "ACTION=\"%s/step%d\" ENCTYPE= \"multipart/form-data\">\n",
+ "ACTION=\"%s?step%d\" ENCTYPE= \"multipart/form-data\">\n",
getenv("SCRIPT_NAME") == NULL ? "" : getenv("SCRIPT_NAME"),
/* WWWGetPort(theInfo->info), */ psidata->StepNumber);
diff --git a/network/wwwblast/Src/wblast2.c b/network/wwwblast/Src/wblast2.c
index e0270302..95fbbf20 100644
--- a/network/wwwblast/Src/wblast2.c
+++ b/network/wwwblast/Src/wblast2.c
@@ -1,4 +1,4 @@
-/* $Id: wblast2.c,v 1.7 2003/07/14 18:43:17 dondosha Exp $
+/* $Id: wblast2.c,v 1.8 2003/12/19 18:12:37 coulouri Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -27,12 +27,15 @@
*
* Initial Creation Date: 10/23/2000
*
-* $Revision: 1.7 $
+* $Revision: 1.8 $
*
* File Description:
* BLAST 2 Sequences CGI program
*
* $Log: wblast2.c,v $
+* Revision 1.8 2003/12/19 18:12:37 coulouri
+* fix name collision in aix
+*
* Revision 1.7 2003/07/14 18:43:17 dondosha
* Changed Entrez references syntax
*
@@ -452,7 +455,7 @@ static Boolean run_status;
/* Flag to indicate which signals were received */
static Uint8 sigflag = 0;
/* set of signal masks */
-static Uint8 sigmask[64];
+static Uint8 wb2_sigmask[64];
#define WBLAST2_SEARCH 0
#define WBLAST2_FORMAT 1
@@ -463,7 +466,7 @@ void PrepareSigmask(void)
{
int ii;
for( ii = 0; ii < 64; ii++ ) {
- sigmask[ii] = 1 << ii;
+ wb2_sigmask[ii] = 1 << ii;
}
}
@@ -472,7 +475,7 @@ static int GetSignal()
{
int ii;
for( ii = 0; ii < 64; ii++ ) {
- if( sigflag & sigmask[ii] ) {
+ if( sigflag & wb2_sigmask[ii] ) {
break;
}
}
@@ -483,7 +486,7 @@ static int GetSignal()
/** set signal flag */
static void sighandler(int sig)
{
- sigflag |= sigmask[sig];
+ sigflag |= wb2_sigmask[sig];
}
static void Blast2SeqMainPage(CharPtr warning, CharPtr seq1, CharPtr seq2, CharPtr one, CharPtr two, ValNodePtr error, Boolean is_prot, BLAST_OptionsBlkPtr options, Int2 mtrx, Int4 from, Int4 to, Int4 ffrom, Int4 tto, Int2 filter, Int2 pagecount) {
diff --git a/network/wwwblast/Src/wwwblast.c b/network/wwwblast/Src/wwwblast.c
index 9582e926..504c6527 100644
--- a/network/wwwblast/Src/wwwblast.c
+++ b/network/wwwblast/Src/wwwblast.c
@@ -1,4 +1,4 @@
-/* $Id: wwwblast.c,v 1.8 2003/06/04 16:12:51 dondosha Exp $
+/* $Id: wwwblast.c,v 1.13 2004/01/16 17:35:20 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,12 +29,27 @@
*
* Initial Creation Date: 03/15/2000
*
-* $Revision: 1.8 $
+* $Revision: 1.13 $
*
* File Description:
* Standalone WWW Blast CGI program.
*
* $Log: wwwblast.c,v $
+* Revision 1.13 2004/01/16 17:35:20 dondosha
+* Fixed mouseover problems
+*
+* Revision 1.12 2003/11/20 22:19:35 dondosha
+* Pass www_root_path to the PrintDefLines... function
+*
+* Revision 1.11 2003/11/20 20:10:52 dondosha
+* Decide whether to print header only after the output type is determined
+*
+* Revision 1.10 2003/11/20 19:10:33 dondosha
+* Do not print progress messages if XML output requested
+*
+* Revision 1.9 2003/11/05 22:40:28 dondosha
+* Do not shift coordinates for tabular output if query is a subsequence - they are already shifted in the seqalign
+*
* Revision 1.8 2003/06/04 16:12:51 dondosha
* Set db genetic code for formatting
*
@@ -179,6 +194,19 @@ static int LIBCALLBACK WWWTickCallback(Int4 sequence_number,
return 1;
}
+
+/* Callback in case of XML output should not print anything to the stdout */
+static int LIBCALLBACK WWWXMLTickCallback(Int4 sequence_number,
+ Int4 number_of_positive_hits)
+{
+ if(!TestSTDOut()) {
+ return -1;
+ }
+ fflush(stdout);
+
+ return 1;
+}
+
static Int4 get_number_alignment(SeqAlignPtr align)
{
Int4 num = 0;
@@ -378,10 +406,11 @@ TraditionalBlastReportEngineWithImage(SeqLocPtr slp, BioseqPtr bsp, BlastNet3Hpt
theInfo->number_of_alignments,
program,
!theInfo->options->gapped_calculation,
- FALSE, SeqLocStart(slp), 0, stdout,
+ FALSE, 0, 0, stdout,
(theInfo->align_view == HitTableWithHeader));
SeqAlignSetFree(seqalign);
} else {
+ Int4 query_number = 1;
while (seqalign) {
if (!options->is_megablast_search)
next_seqalign = NULL;
@@ -430,7 +459,7 @@ TraditionalBlastReportEngineWithImage(SeqLocPtr slp, BioseqPtr bsp, BlastNet3Hpt
seqannot->data = seqalign;
if(theInfo->show_overview) {
- Char f_name[64], title[1024], href[64];
+ Char f_name[64], title[1024], href[64], form_name[16];
Int4 align_num;
sprintf(f_name, "%ld%ld.gif", (long)random(), (long)getpid());
@@ -443,18 +472,23 @@ TraditionalBlastReportEngineWithImage(SeqLocPtr slp, BioseqPtr bsp, BlastNet3Hpt
"</H3>\n", theInfo->www_root_path, (long)align_num);
/* Open HTML form */
- fprintf(stdout, "<FORM NAME=\"BLASTFORM\">\n");
+ sprintf(form_name, "BLASTFORM%ld", query_number);
+ fprintf(stdout, "<FORM NAME=\"%s\">\n", form_name);
fflush(stdout);
- PrintAlignmentOverview(seqannot, stdout,
- "BLASTFORM", href, f_name, title);
+ PrintOneAlignmentOverview(seqannot, stdout, form_name, href, f_name,
+ title, query_number);
+ ++query_number;
}
prune = BlastPruneHitsFromSeqAlign(seqalign, theInfo->number_of_descriptions, NULL);
ObjMgrSetHold();
init_buff_ex(85);
- PrintDefLinesFromSeqAlignEx2(prune->sap, 80, stdout, theInfo->print_options, FIRST_PASS, NULL, theInfo->number_of_descriptions, database, theInfo->www_blast_type);
+ PrintDefLinesFromSeqAlignWithPath(prune->sap, 80, stdout,
+ theInfo->print_options, FIRST_PASS, NULL,
+ theInfo->number_of_descriptions, database,
+ theInfo->www_blast_type, theInfo->www_root_path);
free_buff();
prune = BlastPruneHitsFromSeqAlign(seqalign, theInfo->number_of_alignments, prune);
@@ -504,7 +538,7 @@ TraditionalBlastReportEngineWithImage(SeqLocPtr slp, BioseqPtr bsp, BlastNet3Hpt
if (seqannot)
seqannot = SeqAnnotFree(seqannot);
seqalign = next_seqalign;
- fprintf(stdout, "<PRE>\n");
+ fprintf(stdout, "<PRE>\n</form>\n");
}
} /* End if not hit table */
if (!done) { /* seqalign == NULL */
@@ -768,6 +802,8 @@ Boolean WWWBlastDoSearch(WWWBlastInfoPtr theInfo)
Boolean tabular_output = (theInfo->align_view == HitTable ||
theInfo->align_view == HitTableWithHeader);
MBXmlPtr mbxp = NULL;
+ int LIBCALLBACK (*callback)(Int4, Int4);
+ Int4 query_number;
if(theInfo == NULL)
return FALSE;
@@ -805,8 +841,12 @@ Boolean WWWBlastDoSearch(WWWBlastInfoPtr theInfo)
other_returns = NULL;
error_returns = NULL;
- if(!theInfo->xml_output)
+ if(!theInfo->xml_output) {
printf("</PRE>\n");
+ callback = WWWTickCallback;
+ } else {
+ callback = WWWXMLTickCallback;
+ }
if (!is_megablast) {
if (SeqIdComp(SeqLocId(lcase_mask), SeqLocId(query_slp)) ==
@@ -817,15 +857,15 @@ Boolean WWWBlastDoSearch(WWWBlastInfoPtr theInfo)
lcase_mask = lcase_mask->next;
}
if (query_slp) {
- seqalign = BioseqBlastEngineByLocEx(query_slp, theInfo->program, theInfo->database, options, &other_returns, &error_returns, WWWTickCallback, NULL, theInfo->gi_list, theInfo->gi_list_total);
+ seqalign = BioseqBlastEngineByLocEx(query_slp, theInfo->program, theInfo->database, options, &other_returns, &error_returns, callback, NULL, theInfo->gi_list, theInfo->gi_list_total);
} else {
- seqalign = BioseqBlastEngineEx(theInfo->fake_bsp, theInfo->program, theInfo->database, options, &other_returns, &error_returns, WWWTickCallback, NULL, theInfo->gi_list, theInfo->gi_list_total);
+ seqalign = BioseqBlastEngineEx(theInfo->fake_bsp, theInfo->program, theInfo->database, options, &other_returns, &error_returns, callback, NULL, theInfo->gi_list, theInfo->gi_list_total);
}
} else {
if (options->no_traceback)
- seqalignp = BioseqMegaBlastEngineByLoc(query_slp, theInfo->program, theInfo->database, options, &other_returns, &error_returns, WWWTickCallback, NULL, theInfo->gi_list, theInfo->gi_list_total, AppendMegaBlastHit);
+ seqalignp = BioseqMegaBlastEngineByLoc(query_slp, theInfo->program, theInfo->database, options, &other_returns, &error_returns, callback, NULL, theInfo->gi_list, theInfo->gi_list_total, AppendMegaBlastHit);
else
- seqalignp = BioseqMegaBlastEngineByLoc(query_slp, theInfo->program, theInfo->database, options, &other_returns, &error_returns, WWWTickCallback, NULL, theInfo->gi_list, theInfo->gi_list_total, NULL);
+ seqalignp = BioseqMegaBlastEngineByLoc(query_slp, theInfo->program, theInfo->database, options, &other_returns, &error_returns, callback, NULL, theInfo->gi_list, theInfo->gi_list_total, NULL);
}
if(!theInfo->xml_output)
@@ -904,6 +944,7 @@ Boolean WWWBlastDoSearch(WWWBlastInfoPtr theInfo)
}
ReadDBBioseqSetDbGeneticCode(theInfo->options->db_genetic_code);
+ query_number = 1;
for (index=0; !done; index++) {
if (is_megablast)
@@ -943,8 +984,8 @@ Boolean WWWBlastDoSearch(WWWBlastInfoPtr theInfo)
query_slp, theInfo->number_of_alignments,
theInfo->program,
!theInfo->options->gapped_calculation, FALSE,
- (query_slp ? SeqLocStart(query_slp) : 0), 0,
- stdout, (theInfo->align_view == HitTableWithHeader));
+ 0, 0, stdout,
+ (theInfo->align_view == HitTableWithHeader));
} else {
seqannot = SeqAnnotNew();
seqannot->type = 2;
@@ -969,7 +1010,7 @@ Boolean WWWBlastDoSearch(WWWBlastInfoPtr theInfo)
/* Now printing nice gif with alignment overview */
if(theInfo->show_overview) {
- Char f_name[64], title[1024], href[64];
+ Char f_name[64], title[1024], href[64], form_name[16];
Int4 align_num;
sprintf(f_name, "%ld%ld.gif", (long)random(), (long)getpid());
@@ -984,19 +1025,21 @@ Boolean WWWBlastDoSearch(WWWBlastInfoPtr theInfo)
/* Open HTML form */
- fprintf(stdout, "<FORM NAME=\"BLASTFORM\">\n");
+ sprintf(form_name, "BLASTFORM%ld", query_number);
+ fprintf(stdout, "<FORM NAME=\"%s\">\n", form_name);
fflush(stdout);
- PrintAlignmentOverview(seqannot, stdout,
- "BLASTFORM", href, f_name, title);
+ PrintOneAlignmentOverview(seqannot, stdout, form_name, href,
+ f_name, title, query_number);
+ ++query_number;
}
prune = BlastPruneHitsFromSeqAlign(seqalign, theInfo->number_of_descriptions, NULL);
ObjMgrSetHold();
init_buff_ex(85);
- PrintDefLinesFromSeqAlignEx2(prune->sap, 80, stdout,
+ PrintDefLinesFromSeqAlignWithPath(prune->sap, 80, stdout,
theInfo->print_options, FIRST_PASS, NULL, -1,
- NULL, theInfo->www_blast_type);
+ NULL, theInfo->www_blast_type, theInfo->www_root_path);
free_buff();
prune = BlastPruneHitsFromSeqAlign(seqalign, theInfo->number_of_alignments, prune);
@@ -1080,6 +1123,7 @@ Boolean WWWBlastDoSearch(WWWBlastInfoPtr theInfo)
}
if(!theInfo->xml_output && seqannot != NULL)
seqannot = SeqAnnotFree(seqannot);
+ fprintf(stdout, "</form>\n");
}
matrix = BLAST_MatrixDestruct(matrix);
@@ -1184,7 +1228,7 @@ static void WWWBlastPrintTopHeader(WWWBlastInfoPtr theInfo)
fprintf(stdout, "<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#0000FF\" "
"VLINK=\"#660099\" ALINK=\"#660099\">\n");
- fprintf(stdout, "<map name=img_map1>\n");
+ fprintf(stdout, "<map name=img_map0>\n");
fprintf(stdout, "<area shape=rect coords=2,1,48,21 "
"href=\"http://www.ncbi.nlm.nih.gov\">\n");
fprintf(stdout, "<area shape=rect coords=385,1,435,21 "
@@ -1194,7 +1238,7 @@ static void WWWBlastPrintTopHeader(WWWBlastInfoPtr theInfo)
fprintf(stdout, "<area shape=rect coords=487,1,508,21 "
"href=\"%s/blast/docs/blast_help.html\">\n", theInfo->www_root_path);
fprintf(stdout, "</map>\n");
- fprintf(stdout, "<IMG USEMAP=#img_map1 WIDTH=509 HEIGHT=22 "
+ fprintf(stdout, "<IMG USEMAP=#img_map0 WIDTH=509 HEIGHT=22 "
"SRC=\"%s/blast/images/blast_results.gif\" ISMAP> \n",
theInfo->www_root_path);
}
@@ -1241,14 +1285,14 @@ Int2 Main(void)
if((theInfo = WWWBlastReadArgs(NULL)) == NULL)
return 1;
- if (!theInfo->xml_output)
- WWWBlastPrintTopHeader(theInfo);
-
/* Read options into structure */
if(!WWWCreateSearchOptions(theInfo)) {
return 1;
}
+ if (!theInfo->xml_output)
+ WWWBlastPrintTopHeader(theInfo);
+
/* validate them */
if(!WWWValidateOptions(theInfo)) {
return 1;
diff --git a/network/wwwblast/Src/wwwbutl.c b/network/wwwblast/Src/wwwbutl.c
index 9f734288..94387037 100644
--- a/network/wwwblast/Src/wwwbutl.c
+++ b/network/wwwblast/Src/wwwbutl.c
@@ -1,4 +1,4 @@
-/* $Id: wwwbutl.c,v 1.18 2003/08/13 14:35:33 dondosha Exp $
+/* $Id: wwwbutl.c,v 1.21 2004/01/16 17:35:20 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,12 +29,21 @@
*
* Initial Version Creation Date: 04/21/2000
*
-* $Revision: 1.18 $
+* $Revision: 1.21 $
*
* File Description:
* WWW BLAST/PSI/PHI utilities
*
* $Log: wwwbutl.c,v $
+* Revision 1.21 2004/01/16 17:35:20 dondosha
+* Fixed mouseover problems
+*
+* Revision 1.20 2003/11/20 22:19:35 dondosha
+* Pass www_root_path to the PrintDefLines... function
+*
+* Revision 1.19 2003/11/20 19:10:01 dondosha
+* Never print header for XML output
+*
* Revision 1.18 2003/08/13 14:35:33 dondosha
* When no percent identity cutoff, default value for mismatch penalty is -3 for blastn
*
@@ -1920,7 +1929,7 @@ static void PrintRequestHeader(WWWBlastInfoPtr theInfo)
printf("</HEAD>\n");
printf("<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#0000FF\" "
"VLINK=\"#660099\" ALINK=\"#660099\">\n");
- fprintf(stdout, "<map name=img_map1>\n");
+ fprintf(stdout, "<map name=img_map0>\n");
fprintf(stdout, "<area shape=rect coords=2,1,48,21 "
"href=\"http://www.ncbi.nlm.nih.gov\">\n");
fprintf(stdout, "<area shape=rect coords=385,1,435,21 "
@@ -1930,7 +1939,7 @@ static void PrintRequestHeader(WWWBlastInfoPtr theInfo)
fprintf(stdout, "<area shape=rect coords=487,1,508,21 "
"href=\"%s/blast/docs/blast_help.html\">\n", theInfo->www_root_path);
fprintf(stdout, "</map>\n");
- fprintf(stdout, "<IMG USEMAP=#img_map1 WIDTH=509 HEIGHT=22 "
+ fprintf(stdout, "<IMG USEMAP=#img_map0 WIDTH=509 HEIGHT=22 "
"SRC=\"%s/blast/images/psi_blast.gif\" ISMAP> \n",
theInfo->www_root_path);
printf("<BR><BR><PRE>\n");
@@ -2336,7 +2345,9 @@ BLASTPrintDataPtr PSIBlastSearch(WWWBlastInfoPtr theInfo)
if(theInfo == NULL)
return NULL;
- PrintRequestHeader(theInfo);
+ if (!theInfo->xml_output)
+ PrintRequestHeader(theInfo);
+
print_data = (BLASTPrintDataPtr) MemNew(sizeof(BLASTPrintData));
psidata = MemNew(sizeof(PSIData));
@@ -2480,7 +2491,9 @@ BLASTPrintDataPtr PHIBlastSearch(WWWBlastInfoPtr theInfo)
if(theInfo == NULL)
return NULL;
- PrintRequestHeader(theInfo);
+ if (!theInfo->xml_output)
+ PrintRequestHeader(theInfo);
+
print_data = (BLASTPrintDataPtr) MemNew(sizeof(BLASTPrintData));
psidata = MemNew(sizeof(PSIData));
@@ -2742,8 +2755,11 @@ the alignment was checked on the previous iteration \
fflush(stdout);
print_options += TXALIGN_CHECK_BOX_CHECKED;
- PrintDefLinesFromSeqAlignEx(GoodSeqAlignments, 80, stdout, print_options, FIRST_PASS, marks, theInfo->number_of_descriptions);
-
+ PrintDefLinesFromSeqAlignWithPath(GoodSeqAlignments, 80, stdout,
+ print_options, FIRST_PASS, marks,
+ theInfo->number_of_descriptions, theInfo->database,
+ theInfo->www_blast_type, theInfo->www_root_path);
+
print_options -= TXALIGN_CHECK_BOX_CHECKED;
if (print_data->psidata->StepNumber == 0)
@@ -2757,7 +2773,11 @@ the alignment was checked on the previous iteration \
"Sequences with pattern at position %d and E-value WORSE than threshold</FONT></b></CENTER>\n",
SeqLocStart(seqloc)+1);
- PrintDefLinesFromSeqAlignEx(BadSeqAlignments, 80, stdout, print_options, FIRST_PASS, &marks[countGood], theInfo->number_of_descriptions - countGood);
+ PrintDefLinesFromSeqAlignWithPath(BadSeqAlignments, 80, stdout,
+ print_options, FIRST_PASS, &marks[countGood],
+ theInfo->number_of_descriptions - countGood,
+ theInfo->database, theInfo->www_blast_type,
+ theInfo->www_root_path);
}
marks = MemFree(marks);
@@ -2979,8 +2999,9 @@ the alignment was checked on the previous iteration \
printf(" (bits) Value\n\n");
}
- PrintDefLinesFromSeqAlignEx(GoodSeqAlignments, 80, stdout,
- print_options, FIRST_PASS, marks, theInfo->number_of_descriptions);
+ PrintDefLinesFromSeqAlignWithPath(GoodSeqAlignments, 80, stdout,
+ print_options, FIRST_PASS, marks, theInfo->number_of_descriptions,
+ theInfo->database, theInfo->www_blast_type, theInfo->www_root_path);
print_options -= TXALIGN_CHECK_BOX_CHECKED;
@@ -2995,7 +3016,10 @@ the alignment was checked on the previous iteration \
printf("<HR><CENTER><b><FONT color=\"green\">"
"Sequences with E-value WORSE than threshold </FONT></b></CENTER>\n");
- PrintDefLinesFromSeqAlignEx(BadSeqAlignments, 80, stdout, print_options, FIRST_PASS, &marks[countGood], theInfo->number_of_descriptions - countGood);
+ PrintDefLinesFromSeqAlignWithPath(BadSeqAlignments, 80, stdout,
+ print_options, FIRST_PASS, &marks[countGood],
+ theInfo->number_of_descriptions - countGood, theInfo->database,
+ theInfo->www_blast_type, theInfo->www_root_path);
}
if (theInfo->number_of_descriptions) {
diff --git a/network/wwwblast/readme.html b/network/wwwblast/readme.html
index 114e70a2..c23b298f 100644
--- a/network/wwwblast/readme.html
+++ b/network/wwwblast/readme.html
@@ -1,4 +1,4 @@
-<!-- $Id: readme.html,v 1.9 2003/06/24 21:53:54 dondosha Exp $ -->
+<!-- $Id: readme.html,v 1.11 2004/01/30 22:29:05 dondosha Exp $ -->
<HTML>
<HEAD>
<TITLE>Introduction to the Standalone WWW Blast server</TITLE>
@@ -29,12 +29,34 @@
</UL>
<H3><A NAME="Inroduction">Introduction</A> </H3>
-<P>This standalone WWW BLAST server suite of programs was designed similar to the regular NCBI BLAST server and such command-line NCBI BLAST programs like "blastall", "blastpgp", "rpsblast" and "megablast". It incorporates most features, which exist in NCBI BLAST programs and should be relatively easy to use. This server does not support any request queuing and load balancing. As soon as the user hits a "Search" button, BLAST starts immediately if entered information is valid. So, this server is not intended to handle large load, which may exist in public service. Such queueing and loadbalancing however may be implemented using such products as Load Sharing Facility - "LSF" from <a href="http://www.platform.com">Platform Computing Corporation</a>. Interface to "LSF" was implemented in NCBI, however this was not included in this suite. Standalone server assumes that users have their own BLAST or RPS-BLAST database(s), that should be searched and want to have a simple WWW interface to such search. It is STRONLY recommended that user has experience in installation and running standalone NCBI BLAST programs. </P>
-<P>After files are uncompressed, server is ready to be used immediately. Any customizations to the program are welcomed and may be done by experienced programmers using source code, which is also provided. <P>Recompilation of the server executables requires that programmer has compiled NCBI toolkit libraries. This toolkit can be downloaded from the NCBI FTP web site: <A HREF="ftp://ftp.ncbi.nih.gov/toolbox/ncbi_tools/README.htm">ftp://ftp.ncbi.nih.gov</A> <BR>After the NCBI toolkit is compiled, user needs to edit the Makefile in the blast/Src directory, and define the NCBI variable in the top line of the Makefile, so it points to the root directory where the NCBI toolkit is located.</P>
+<P>This standalone WWW BLAST server suite of programs was designed similar to the regular NCBI BLAST server and such command-line NCBI BLAST programs like "blastall", "blastpgp", "rpsblast" and "megablast". It incorporates most features, which exist in NCBI BLAST programs and should be relatively easy to use. This server does not support any request queuing and load balancing. As soon as the user hits a "Search" button, BLAST starts immediately if entered information is valid. So, this server is not intended to handle large load, which may exist in public service. Such queueing and loadbalancing however may be implemented using such products as Load Sharing Facility - "LSF" from <a href="http://www.platform.com">Platform Computing Corporation</a>. Interface to "LSF" was implemented in NCBI, however this was not included in this suite. Standalone server assumes that users have their own BLAST or RPS-BLAST database(s), that should be searched and want to have a simple WWW interface to such search. It is STRONLY recommended that user have experience in installation and running standalone NCBI BLAST programs. </P>
+<P>After files are uncompressed, server is ready to be used immediately. Any customizations to the program are welcomed. The source code for WWW BLAST is now part of the NCBI C toolkit, which can be downloaded from the NCBI FTP web site: <A HREF="ftp://ftp.ncbi.nih.gov/toolbox/ncbi_tools/README.htm">ftp://ftp.ncbi.nih.gov</A> <BR>The compilation of the NCBI C toolkit includes the WWW BLAST executables. The files in the C toolkit most relevant for the WWW BLAST executables are: wwwblast.c, wwwbutl.c, psiblast.c, wblast2.c.</P>
<H3><A NAME="Whatsnew">What's new in this revision?</A></H3>
<TABLE BORDER=1>
<TR VALIGN=top>
+<TD> February 2, 2004
+<TD>
+<UL>
+<LI> All source code moved to the NCBI C toolkit.
+<LI> Mouseover feature fixed in graphical overview.
+<LI> All binaries synchronized with the latest NCBI C toolkit release. All future
+releases will be automatically synchronized with future toolkit releases.
+<LI> Recompilation procedure changed. WWW BLAST binaries are now compiled as part
+of the C toolkit.
+</UL>
+</TR>
+<TR VALIGN=top>
+<TD> November 21, 2003
+<TD>
+<UL>
+<LI> Fixed a bug with absent images on PSI-BLAST iterations.
+<LI> Removed header and progress messages from XML output.
+<LI> All binaries recompiled with the newest version of the NCBI C toolkit libra
+ries.
+</UL>
+</TR>
+<TR VALIGN=top>
<TD> May 9, 2003
<TD>
<UL>
diff --git a/network/wwwblast/readme.txt b/network/wwwblast/readme.txt
index a4d89b55..690f1dd8 100644
--- a/network/wwwblast/readme.txt
+++ b/network/wwwblast/readme.txt
@@ -41,25 +41,38 @@ Platform Computing Corporation <http://www.platform.com>. Interface to
"LSF" was implemented in NCBI, however this was not included in this
suite. Standalone server assumes that users have their own BLAST or
RPS-BLAST database(s), that should be searched and want to have a simple
-WWW interface to such search. It is STRONLY recommended that user has
+WWW interface to such search. It is STRONLY recommended that user have
experience in installation and running standalone NCBI BLAST programs.
After files are uncompressed, server is ready to be used immediately.
-Any customizations to the program are welcomed and may be done by
-experienced programmers using source code, which is also provided.
-
-Recompilation of the server executables requires that programmer has
-compiled NCBI toolkit libraries. This toolkit can be downloaded from the
-NCBI FTP web site: ftp://ftp.ncbi.nih.gov
+Any customizations to the program are welcomed. The source code for WWW
+BLAST is now part of the NCBI C toolkit, which can be downloaded from
+the NCBI FTP web site: ftp://ftp.ncbi.nih.gov
<ftp://ftp.ncbi.nih.gov/toolbox/ncbi_tools/README.htm>
-After the NCBI toolkit is compiled, user needs to edit the Makefile in
-the blast/Src directory, and define the NCBI variable in the top line of
-the Makefile, so it points to the root directory where the NCBI toolkit
-is located.
+The compilation of the NCBI C toolkit includes the WWW BLAST
+executables. The files in the C toolkit most relevant for the WWW BLAST
+executables are: wwwblast.c, wwwbutl.c, psiblast.c, wblast2.c.
What's new in this revision?
+February 2, 2004
+
+ * All source code moved to the NCBI C toolkit.
+ * Mouseover feature fixed in graphical overview.
+ * All binaries synchronized with the latest NCBI C toolkit release.
+ All future releases will be automatically synchronized with future
+ toolkit releases.
+ * Recompilation procedure changed. WWW BLAST binaries are now
+compiled as part of the C toolkit.
+
+November 21, 2003
+
+ * Fixed a bug with absent images on PSI-BLAST iterations.
+ * Removed header and progress messages from XML output.
+ * All binaries recompiled with the newest version of the NCBI C
+toolkit libra ries.
+
May 9, 2003
* Cleaned the Makefile for recompiling the sources.
@@ -487,10 +500,10 @@ the description of a configuration file.
Server configuration file and logfile
Default configuration file is "blast.rc" and logfile "wwwblast.log".
-Setting tag BLAST_TYPE to specific value may change these names.
-This is useful if few different search input pages use the same CGI
-search engine, but significantly different by content and priorities. A
-sample configuration file comes with this distribution:
+Setting tag BLAST_TYPE to specific value may change these names. This is
+useful if few different search input pages use the same CGI search
+engine, but significantly different by content and priorities. A sample
+configuration file comes with this distribution:
This file will set how many CPUs will be used in the BLAST search and
what databases may be used with what programs. Logfile currently stores
diff --git a/object/objfeat.c b/object/objfeat.c
index d96ffedf..b25f3944 100644
--- a/object/objfeat.c
+++ b/object/objfeat.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 4/1/91
*
-* $Revision: 6.20 $
+* $Revision: 6.21 $
*
* File Description: Object manager for module NCBI-SeqFeat
*
@@ -2923,9 +2923,10 @@ NLM_EXTERN OrgRefPtr LIBCALL OrgRefFree (OrgRefPtr orp)
if (orp == NULL)
return (OrgRefPtr)NULL;
- MemFree(orp->taxname);
- MemFree(orp->common);
+ orp->taxname = MemFree(orp->taxname);
+ orp->common = MemFree(orp->common);
ValNodeFreeData(orp->mod);
+ orp->mod = NULL;
anp = orp->db;
while (anp != NULL)
{
@@ -2934,8 +2935,11 @@ NLM_EXTERN OrgRefPtr LIBCALL OrgRefFree (OrgRefPtr orp)
MemFree(anp);
anp = next;
}
+ orp->db = NULL;
ValNodeFreeData(orp->syn);
+ orp->syn = NULL;
OrgNameFree(orp->orgname);
+ orp->orgname = NULL;
return (OrgRefPtr)MemFree(orp);
}
diff --git a/object/objtseq.c b/object/objtseq.c
index 93c7e3b2..d3be5e56 100644
--- a/object/objtseq.c
+++ b/object/objtseq.c
@@ -473,6 +473,10 @@ NLM_EXTERN TSeqPtr BioseqToTSeq (BioseqPtr bsp)
case SEQID_DDBJ:
case SEQID_EMBL:
case SEQID_SWISSPROT:
+ case SEQID_OTHER:
+ case SEQID_TPG:
+ case SEQID_TPE:
+ case SEQID_TPD:
SeqIdWrite(sip, buf, PRINTID_TEXTID_ACC_VER, 250);
tsp->accver = StringSave(buf);
break;
@@ -580,6 +584,10 @@ static TSeqPtr BioseqToMiniTSeq (BioseqPtr bsp)
case SEQID_DDBJ:
case SEQID_EMBL:
case SEQID_SWISSPROT:
+ case SEQID_OTHER:
+ case SEQID_TPG:
+ case SEQID_TPE:
+ case SEQID_TPD:
SeqIdWrite(sip, buf, PRINTID_TEXTID_ACC_VER, 250);
tsp->accver = StringSave(buf);
break;
diff --git a/platform/ibm_auto.ncbi.mk b/platform/ibm_auto.ncbi.mk
index b4e1dc53..cdb519e8 100644
--- a/platform/ibm_auto.ncbi.mk
+++ b/platform/ibm_auto.ncbi.mk
@@ -1,5 +1,5 @@
#
-# $Id: ibm_auto.ncbi.mk,v 1.8 2003/05/22 18:22:14 beloslyu Exp $
+# $Id: ibm_auto.ncbi.mk,v 1.9 2004/01/09 19:01:51 beloslyu Exp $
#
# Initial version ddas@us.ibm.com 08/19/1999
# Replace r6k with ibm_auto or ibm_pwr3: cpsosa@us.ibm.com Jun-2001
@@ -13,7 +13,7 @@
NCBI_DEFAULT_LCL = ibm
NCBI_MAKE_SHELL = /bin/sh
NCBI_AR = ar
-NCBI_CC = xlc_r
+NCBI_CC = xlc_r -qlanglvl=stdc99
NCBI_CFLAGS1 = -c -qcpluscmt
NCBI_LDFLAGS1 = -bmaxdata:0x40000000 -bmaxstack:0x10000000 -DPOSIX_THREADS_AVAIL -D_LARGE_FILES
NCBI_OPTFLAG = -O3 -qmaxmem=-1 -qarch=auto -qcache=auto -DPOSIX_THREADS_AVAIL -D_LARGE_FILES
diff --git a/platform/ibm_auto64.ncbi.mk b/platform/ibm_auto64.ncbi.mk
index 7c1620af..bf265848 100644
--- a/platform/ibm_auto64.ncbi.mk
+++ b/platform/ibm_auto64.ncbi.mk
@@ -1,5 +1,5 @@
#
-# $Id: ibm_auto64.ncbi.mk,v 1.2 2003/05/22 18:22:14 beloslyu Exp $
+# $Id: ibm_auto64.ncbi.mk,v 1.3 2004/01/09 19:01:51 beloslyu Exp $
#
# Initial version ddas@us.ibm.com 08/19/1999
# Replace r6k with ibm_auto or ibm_pwr3: cpsosa@us.ibm.com Jun-2001
@@ -13,7 +13,7 @@
NCBI_DEFAULT_LCL = ibm
NCBI_MAKE_SHELL = /bin/sh
NCBI_AR = ar -X 64
-NCBI_CC = xlc_r -q64
+NCBI_CC = xlc_r -q64 -qlanglvl=stdc99
NCBI_CFLAGS1 = -c -qcpluscmt
NCBI_LDFLAGS1 = -D_LARGE_FILES
NCBI_OPTFLAG = -O3 -qmaxmem=-1 -qarch=auto -qcache=auto -DPOSIX_THREADS_AVAIL -D_LARGE_FILES
diff --git a/platform/linux-x86.ncbi.mk b/platform/linux-x86.ncbi.mk
new file mode 100644
index 00000000..9225b73a
--- /dev/null
+++ b/platform/linux-x86.ncbi.mk
@@ -0,0 +1,51 @@
+#
+# $Id: linux-x86.ncbi.mk,v 1.31 2004/01/09 18:47:22 beloslyu Exp $
+#
+NCBI_DEFAULT_LCL = lnx
+NCBI_MAKE_SHELL = /bin/sh
+#warning, the flags -D__USE_FILE_OFFSET64 -D__USE_LARGEFILE64 will allow
+#you to work with large (>4Gb) files only if you have glibc version >= 2.1
+#NCBI_CC = gcc -pipe -D__USE_FILE_OFFSET64 -D__USE_LARGEFILE64
+#it appears the flags above do not work anymore with newer libc,
+#the new flags should work. Dima. 08/23/01
+NCBI_AR=ar
+NCBI_CC = gcc -pipe -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
+NCBI_CFLAGS1 = -c
+NCBI_LDFLAGS1 = -O3 -mcpu=pentiumpro
+NCBI_OPTFLAG = -O3 -mcpu=pentiumpro
+NCBI_BIN_MASTER = /home/coremake/ncbi/bin
+NCBI_BIN_COPY = /home/coremake/ncbi/bin
+NCBI_INCDIR = /home/coremake/ncbi/include
+NCBI_LIBDIR = /home/coremake/ncbi/lib
+NCBI_ALTLIB = /home/coremake/ncbi/altlib
+#will work only when you have Motif installed!
+NCBI_VIBFLAG = -I/usr/X11R6/include -L/usr/X11R6/lib -DWIN_MOTIF
+NCBI_VIBLIBS = -lXmu -lXm -lXt -lSM -lICE -lXext -lXp -lX11 -ldl
+#warning! If you have only dynamic version of Motif or Lesstif
+#you should delete -Wl,-Bstatic sentence from the next line:
+NCBI_DISTVIBLIBS = -L/usr/X11R6/lib -lXmu -lXm -lXt -lSM -lICE -lXext -lXp -lX11 -ldl
+NCBI_OTHERLIBS = -lm
+NCBI_RANLIB = ranlib
+# Used by makedis.csh
+NCBI_MT_OTHERLIBS = -lpthread
+NCBI_OTHERLIBS_MT = $(NCBI_MT_OTHERLIBS) -lm
+NCBI_THREAD_OBJ = ncbithr.o
+NETENTREZVERSION = 2.02c2ASN1SPEC6
+
+# uncomment OPENGL_TARGETS to build OpenGL apps; do not change
+# OPENGL_NCBI_LIBS! However, may need to set
+# OPENGL_INCLUDE and OPENGL_LIBS to suit local environment
+# OPENGL_TARGETS = Cn3D
+OPENGL_NCBI_LIBS = LIB400=libvibrantOGL.a LIB3000=libncbicn3dOGL.a
+OPENGL_INCLUDE = -I/usr/X11R6/include
+OPENGL_LIBS = -L/usr/X11R6/lib -lGL -lGLU
+NCBI_OGLLIBS = -L/usr/X11R6/lib -lGL -lGLU
+
+# uncomment (and change appropriately) these lines to build PNG
+# output support into Cn3D (OpenGL version only)
+#LIBPNG_DIR = /home/paul/Programs/libpng
+#ZLIB_DIR = /home/paul/Programs/zlib
+
+NCBI_LBSM_SRC = ncbi_lbsmd_stub.c
+NCBI_LBSM_OBJ = ncbi_lbsmd_stub.o
+
diff --git a/platform/linux.ncbi.mk b/platform/linux.ncbi.mk
index 1dd7e390..c93b99c8 100644
--- a/platform/linux.ncbi.mk
+++ b/platform/linux.ncbi.mk
@@ -1,20 +1,18 @@
#
-# $Id: linux.ncbi.mk,v 1.29 2003/05/07 17:40:12 beloslyu Exp $
+# $Id: linux.ncbi.mk,v 1.32 2004/01/22 19:51:42 ucko Exp $
#
NCBI_DEFAULT_LCL = lnx
NCBI_MAKE_SHELL = /bin/sh
#warning, the flags -D__USE_FILE_OFFSET64 -D__USE_LARGEFILE64 will allow
#you to work with large (>4Gb) files only if you have glibc version >= 2.1
#NCBI_CC = gcc -pipe -D__USE_FILE_OFFSET64 -D__USE_LARGEFILE64
-#it appears the flags above do not working anymore with newer libc,
+#it appears the flags above do not work anymore with newer libc,
#the new flags should work. Dima. 08/23/01
NCBI_AR=ar
NCBI_CC = gcc -pipe -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
NCBI_CFLAGS1 = -c
-NCBI_LDFLAGS1 = -O2
-NCBI_OPTFLAG = -O2
-#untested, try on your own risk on Linux/Intel
-#NCBI_OPTFLAG = -O3 -march=pentiumpro -funroll-loops
+NCBI_LDFLAGS1 = -O3
+NCBI_OPTFLAG = -O3
NCBI_BIN_MASTER = /home/coremake/ncbi/bin
NCBI_BIN_COPY = /home/coremake/ncbi/bin
NCBI_INCDIR = /home/coremake/ncbi/include
diff --git a/platform/netbsd.ncbi.mk b/platform/netbsd.ncbi.mk
index 44feb899..64b976d2 100644
--- a/platform/netbsd.ncbi.mk
+++ b/platform/netbsd.ncbi.mk
@@ -1,5 +1,5 @@
#
-# $Id: netbsd.ncbi.mk,v 1.8 2003/05/07 17:40:12 beloslyu Exp $
+# $Id: netbsd.ncbi.mk,v 1.9 2003/11/17 16:05:41 coulouri Exp $
#
# That platform is not supported and is contributed to NCBI by
# Brook Milligan <brook@trillium.NMSU.Edu>
@@ -9,8 +9,8 @@ NCBI_MAKE_SHELL = /bin/sh
NCBI_AR=ar
NCBI_CC = gcc -pipe
NCBI_CFLAGS1 = -c
-NCBI_LDFLAGS1 = -O
-NCBI_OPTFLAG = -O
+NCBI_LDFLAGS1 = -O2
+NCBI_OPTFLAG = -O2
NCBI_BIN_MASTER = /home/coremake/ncbi/bin
NCBI_BIN_COPY = /home/coremake/ncbi/bin
NCBI_INCDIR = /home/coremake/ncbi/include
diff --git a/sequin/sequin.h b/sequin/sequin.h
index 44ab2770..c3b73d01 100644
--- a/sequin/sequin.h
+++ b/sequin/sequin.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.99 $
+* $Revision: 6.118 $
*
* File Description:
*
@@ -165,6 +165,7 @@ extern void EditFeatureStrand (IteM i);
extern void PrefixAuthorityWithOrganism (IteM i);
extern void UpdateFastaSet (IteM i);
extern void SeqLocAdjustByOffset (SeqLocPtr slp, Int4 offset);
+extern SeqLocPtr SeqLocWholeNew (BioseqPtr bsp);
extern SeqFeatPtr SeqFeatCopy (SeqFeatPtr sfp);
extern SeqLocPtr SeqLocReplaceLocalID (SeqLocPtr slp,
SeqIdPtr new_sip);
@@ -215,6 +216,21 @@ extern Boolean HasZeroLengthSequence (ForM newForm);
extern Boolean SequencesFormHasProteins (ForM f);
extern Boolean SequencesFormHasTooManyNucleotides (ForM f);
+extern void AppendOrReplaceString (
+ CharPtr PNTR string_loc,
+ CharPtr new_value,
+ Boolean PNTR asked_question,
+ Boolean PNTR do_replace,
+ Boolean PNTR use_semicolon
+);
+
+extern void ConsolidateOrganismNotes (IteM i);
+extern void ConsolidateLikeModifiersWithSemicolons (IteM i);
+extern void ConsolidateLikeModifiersWithoutSemicolons (IteM i);
+
+extern void ExtendPartialFeatures (IteM i);
+extern void TrimOrganismName (IteM i);
+
extern void ConfirmSequencesFormParsing (ForM f, FormActnFunc putItAllTogether);
extern ForM CreateHelpForm (Int2 left, Int2 top, CharPtr title,
@@ -282,6 +298,8 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp);
extern void SetupNewFeaturesMenu (MenU m, BaseFormPtr bfp);
extern void SetupNewDescriptorsMenu (MenU m, BaseFormPtr bfp);
extern void SetupNewPublicationsMenu (MenU m, BaseFormPtr bfp);
+extern void SetupBatchApplyMenu (MenU s, BaseFormPtr bfp);
+extern void SetupBatchEditMenu (MenU s, BaseFormPtr bfp);
extern MenU CreateAnalysisMenu (WindoW w, BaseFormPtr bfp, Boolean bspviewOK, Boolean docsumOK);
extern void SetupSequinFilters (void);
extern void SetupBioseqPageList (void);
@@ -294,6 +312,7 @@ extern void SequinCheckSocketsProc (void);
extern Int4 MySeqEntryToAsn3 (SeqEntryPtr sep, Boolean strip, Boolean correct, Boolean force);
extern void ValSeqEntryForm (ForM f);
+extern void ValSeqEntryFormEx (ForM f, Boolean doAligns);
extern void InitSequinExtras (void);
extern void FiniSequinExtras (void);
@@ -356,6 +375,7 @@ extern void VectorScreenProc (IteM i);
extern void GenerateAutomaticDefLinesCommon (IteM i, Boolean addMods, Boolean smartMods, ButtoN b);
extern void ForceTaxonFixupBtn (IteM i, ButtoN b);
extern void CommonAddOrgOrModsToDefLines (IteM i, Int2 orgmod, Int2 subsource, ButtoN b);
+extern void PrefixDefLines (IteM i);
extern void MRnaFromCdsProc (Uint2 entityID);
extern void BioseqViewFormToolBar (GrouP h);
extern Boolean DoBuildContig (void);
@@ -391,6 +411,7 @@ extern void SimplePowerBlastProc (IteM i);
extern CharPtr MergeValNodeStrings (ValNodePtr list, Boolean useReturn);
extern CharPtr JustSaveStringFromText (TexT t);
+extern void CommonApplyToAllProc (BaseFormPtr bfp, Int2 type);
extern void ApplyTitle (IteM i);
extern void ApplyCDS (IteM i);
extern void ApplyRRNA (IteM i);
@@ -399,6 +420,7 @@ extern void LoadTPAAccessionNumbersFromFile (IteM i);
extern void LoadSecondaryAccessionNumbersFromFile (IteM i);
extern void LoadHistoryAccessionNumbersFromFile (IteM i);
extern void LoadOrganismModifierTable (IteM i);
+extern void LoadFeatureQualifierTable (IteM i);
extern void RemoveRNA (IteM i);
extern void ConvertRNA (IteM i);
@@ -421,6 +443,7 @@ extern void AutoParseFeatureTableProc (IteM i);
extern void RecomputeSuggest (IteM i);
extern void RetranslateCdRegionsNoStop (IteM i);
extern void RetranslateCdRegionsDoStop (IteM i);
+extern void RetranslateCdRegionsNoStopExceptEndCompleteCDS (IteM i);
extern void AddGlobalCodeBreak (IteM i);
extern void CorrectCDSGenCodes (IteM i);
/* extern void CorrectCDSStartCodon (IteM i); */
@@ -432,7 +455,16 @@ extern void GenerateAutoDefLinesWithMods (IteM i);
extern void GenerateAutoDefLinesSmartMods (IteM i);
extern void testAutoDef (IteM i);
extern void testAutoDefWithOptions (IteM i);
-extern void AutoDefBaseFormCommon (BaseFormPtr bfp, Boolean use_form);
+extern void AutoDefWithoutModifiers (IteM i);
+extern void AutoDefBaseFormCommon (BaseFormPtr bfp, Boolean use_form, Boolean use_modifiers);
+extern void AutoDefToolBtn (ButtoN b);
+extern void AutoDefOptionsToolBtn (ButtoN b);
+
+extern void RemoveDefLinesToolBtn (ButtoN b);
+extern void FindStringProcToolBtn (ButtoN b);
+extern void ParseLocalIDToSourceToolBtn (ButtoN b);
+extern void ResolveExistingLocalIDsToolBtn (ButtoN b);
+extern void GroupExplodeToolBtn (ButtoN b);
extern void EditEvidenceFlag (IteM i);
extern void EditExceptionFlag (IteM i);
@@ -454,9 +486,13 @@ extern void SelectBioseq (IteM i);
extern void FuseFeature (IteM i);
+extern void MakeExonsFromCDSIntervals (IteM i);
+extern void MakeExonsFromMRNAIntervals (IteM i);
+
extern Int2 LIBCALLBACK CreateDeleteByTextWindow (Pointer data);
extern void ParseAsnOrFlatfileToAnywhere (IteM i);
extern void ParseCommentToAnywhere (IteM i);
+extern void ParseLocalIDToAnywhere (IteM i);
extern void RemoveTextInsideString (IteM i);
extern void RemoveTextOutsideString (IteM i);
@@ -581,7 +617,30 @@ typedef struct sequencesform {
Int2 currConfirmCount;
} SequencesForm, PNTR SequencesFormPtr;
+typedef int (LIBCALLBACK *CompareFunc) (Nlm_VoidPtr, Nlm_VoidPtr);
+
+extern int LIBCALLBACK CompareImpFeatEnumFieldAssoc (VoidPtr ptr1, VoidPtr ptr2);
+extern int LIBCALLBACK CompareFeatureValNodeStrings (VoidPtr ptr1, VoidPtr ptr2);
+
+extern ValNodePtr InsertMostUsedFeatureValNodes (ValNodePtr old_list);
+
+extern void SortEnumFieldAssocPtrArray (EnumFieldAssocPtr alist, CompareFunc compar);
+
+extern ValNodePtr FindExactStringInStrings ( ValNodePtr strings, CharPtr value);
+
+extern EnumFieldAssocPtr InsertMostUsedFeatureEnumFieldAssoc (
+ EnumFieldAssocPtr alist
+);
+
+extern ValNodePtr BuildFeatureValNodeList (
+ Boolean prefer_most_used,
+ CharPtr wild_card_name,
+ Int4 wild_card_value,
+ Boolean skip_unusual,
+ Boolean skip_import
+);
+extern void SetTaxNameAndRemoveTaxRef (OrgRefPtr orp, CharPtr taxname);
#ifdef __cplusplus
}
diff --git a/sequin/sequin1.c b/sequin/sequin1.c
index 7d0b9236..693b038e 100644
--- a/sequin/sequin1.c
+++ b/sequin/sequin1.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.409 $
+* $Revision: 6.430 $
*
* File Description:
*
@@ -120,12 +120,10 @@ static char *time_of_compilation = "now";
#include <taxutil.h>
#ifdef USE_SPELL
-#ifdef WIN_MOTIF
#include <spellapi.h>
#endif
-#endif
-#define SEQ_APP_VER "5.00"
+#define SEQ_APP_VER "5.15"
#ifndef CODECENTER
static char* sequin_version_binary = "Sequin Indexer Services Version " SEQ_APP_VER " " __DATE__ " " __TIME__;
@@ -207,6 +205,7 @@ static IteM findGeneItem = NULL;
static IteM findProtItem = NULL;
static IteM findPosItem = NULL;
static IteM validateItem = NULL;
+static MenU validateMenu = NULL;
static IteM spellItem = NULL;
static IteM vectorScreenItem = NULL;
static IteM powerBlastItem = NULL;
@@ -274,6 +273,8 @@ static Boolean dirsubMode = FALSE;
static MenU newDescMenu = NULL;
static MenU newFeatMenu = NULL;
static MenU newPubMenu = NULL;
+static MenU batchApplyMenu = NULL;
+static MenU batchEditMenu = NULL;
static MenU specialMenu = NULL;
static MenU analysisMenu = NULL;
static Boolean initialFormsActive = FALSE;
@@ -386,7 +387,7 @@ static Boolean OkayToWriteTheEntity (Uint2 entityID, ForM f)
{
Boolean allRawOrSeg = TRUE;
- MsgAnswer ans;
+ MsgAnswer ans = ANS_OK;
Int2 errors;
Int2 j;
ErrSev oldErrSev;
@@ -405,7 +406,7 @@ static Boolean OkayToWriteTheEntity (Uint2 entityID, ForM f)
}
}
WatchCursor ();
- Update ();
+ Update ();
vsp = ValidStructNew ();
if (vsp != NULL) {
/*SetChecklistValue (checklistForm, 6);*/
@@ -418,6 +419,11 @@ static Boolean OkayToWriteTheEntity (Uint2 entityID, ForM f)
}
oldErrSev = ErrSetMessageLevel (SEV_MAX);
vsp->validateAlignments = TRUE;
+ vsp->alignFindRemoteBsp = TRUE;
+ vsp->doSeqHistAssembly = FALSE;
+ for (j = 0; j < 6; j++) {
+ vsp->errors [j] = 0;
+ }
ValidateSeqEntry (sep, vsp);
ErrSetMessageLevel (oldErrSev);
ErrClear ();
@@ -432,13 +438,12 @@ static Boolean OkayToWriteTheEntity (Uint2 entityID, ForM f)
errors += vsp->errors [j];
}
}
- ValidStructFree (vsp);
UseWindow ((WindoW) f);
if (errors > 0) {
ArrowCursor ();
Update ();
if (subtoolMode || smartnetMode) {
- ans = Message (MSG_OKC, "%s\nFatal %d, Error %d, Warning %d, Info %d\n%s",
+ ans = Message (MSG_OKC, "%s\nReject %d, Error %d, Warning %d, Info %d\n%s",
"Submission failed validation test with:",
(int) vsp->errors [4], (int) vsp->errors [3],
(int) vsp->errors [2], (int) vsp->errors [1],
@@ -446,14 +451,15 @@ static Boolean OkayToWriteTheEntity (Uint2 entityID, ForM f)
} else {
ans = Message (MSG_OKC, validFailMsg);
}
- if (ans != ANS_OK) {
- /*SetChecklistValue (checklistForm, 5);*/
- return FALSE;
- }
}
+ ValidStructFree (vsp);
}
ArrowCursor ();
Update ();
+ if (ans != ANS_OK) {
+ /*SetChecklistValue (checklistForm, 5);*/
+ return FALSE;
+ }
return TRUE;
}
@@ -1250,7 +1256,7 @@ static void SmartnetDoneFunc (BaseFormPtr bfp)
/* reset update date in smart mode if GenBank or RefGene, and not HTGS */
- SeqMgrExploreBioseqs (entityID, 0, (Pointer) resetUpdateDate, AllGenBankOrRefSeq, TRUE, TRUE, TRUE);
+ SeqMgrExploreBioseqs (bfp->input_entityID, 0, (Pointer) &resetUpdateDate, AllGenBankOrRefSeq, TRUE, TRUE, TRUE);
if (/* ans == ANS_YES */ resetUpdateDate) {
SeqEntryExplore (sep, NULL, RemoveUpdateDates);
sdp = CreateNewDescriptor (sep, Seq_descr_update_date);
@@ -1433,6 +1439,11 @@ static void ProcessDoneButton (ForM f)
}
oldErrSev = ErrSetMessageLevel (SEV_MAX);
vsp->validateAlignments = TRUE;
+ vsp->alignFindRemoteBsp = TRUE;
+ vsp->doSeqHistAssembly = FALSE;
+ for (j = 0; j < 6; j++) {
+ vsp->errors [j] = 0;
+ }
ValidateSeqEntry (sep, vsp);
ErrSetMessageLevel (oldErrSev);
ErrClear ();
@@ -1463,7 +1474,12 @@ static void ProcessDoneButton (ForM f)
vsp->suppressContext = ShouldSetSuppressContext ();
oldErrHook = ErrSetHandler (ValidErrHook);
oldErrSev = ErrSetMessageLevel (SEV_NONE);
- vsp->validateAlignments = TRUE;
+ vsp->validateAlignments = TRUE;
+ vsp->alignFindRemoteBsp = TRUE;
+ vsp->doSeqHistAssembly = FALSE;
+ for (j = 0; j < 6; j++) {
+ vsp->errors [j] = 0;
+ }
ValidateSeqEntry (sep, vsp);
ErrSetMessageLevel (oldErrSev);
ErrSetHandler (oldErrHook);
@@ -1574,7 +1590,7 @@ static void Cn3DWinShowProc (IteM i)
#endif
*/
-extern void ValSeqEntryForm (ForM f)
+extern void ValSeqEntryFormEx (ForM f, Boolean doAligns)
{
Boolean allRawOrSeg = TRUE;
@@ -1613,15 +1629,22 @@ extern void ValSeqEntryForm (ForM f)
}
HideValidateDoc ();
vsp->suppressContext = ShouldSetSuppressContext ();
- vsp->validateAlignments = TRUE;
- vsp->farIDsInAlignments = (Boolean) (subtoolMode || smartnetMode || dirsubMode);
- if (GetSequinAppParam ("SETTINGS", "VALIDATEFARALIGNIDS", NULL, str, sizeof (str))) {
- if (StringICmp (str, "TRUE") == 0) {
- vsp->farIDsInAlignments = TRUE;
+ if (doAligns) {
+ vsp->validateAlignments = TRUE;
+ vsp->alignFindRemoteBsp = TRUE;
+ vsp->doSeqHistAssembly = TRUE;
+ vsp->farIDsInAlignments = (Boolean) (subtoolMode || smartnetMode || dirsubMode);
+ if (GetSequinAppParam ("SETTINGS", "VALIDATEFARALIGNIDS", NULL, str, sizeof (str))) {
+ if (StringICmp (str, "TRUE") == 0) {
+ vsp->farIDsInAlignments = TRUE;
+ }
}
}
oldErrHook = ErrSetHandler (ValidErrHook);
oldErrSev = ErrSetMessageLevel (SEV_NONE);
+ for (j = 0; j < 6; j++) {
+ vsp->errors [j] = 0;
+ }
ValidateSeqEntry (sep, vsp);
ErrSetMessageLevel (oldErrSev);
ErrSetHandler (oldErrHook);
@@ -1647,6 +1670,12 @@ extern void ValSeqEntryForm (ForM f)
}
}
+extern void ValSeqEntryForm (ForM f)
+
+{
+ ValSeqEntryFormEx (f, TRUE);
+}
+
static void ValSeqEntryProc (IteM i)
{
@@ -1662,8 +1691,22 @@ static void ValSeqEntryProc (IteM i)
}
}
+static void ValSeqEntryProcNoAln (IteM i)
+
+{
+ BaseFormPtr bfp;
+
+#ifdef WIN_MAC
+ bfp = (BaseFormPtr) currentFormDataPtr;
+#else
+ bfp = (BaseFormPtr) GetObjectExtra (i);
+#endif
+ if (bfp != NULL) {
+ ValSeqEntryFormEx (bfp->form, FALSE);
+ }
+}
+
#ifdef USE_SPELL
-#ifdef WIN_MOTIF
static void SpellCheckTheForm (ForM f)
{
@@ -1715,6 +1758,9 @@ static void SpellCheckTheForm (ForM f)
vsp->suppressContext = ShouldSetSuppressContext ();
oldErrHook = ErrSetHandler (ValidErrHook);
oldErrSev = ErrSetMessageLevel (SEV_NONE);
+ for (j = 0; j < 6; j++) {
+ vsp->errors [j] = 0;
+ }
ValidateSeqEntry (sep, vsp);
ErrSetMessageLevel (oldErrSev);
ErrSetHandler (oldErrHook);
@@ -1759,7 +1805,6 @@ static void SpellCheckSeqEntryProc (IteM i)
}
}
#endif
-#endif
extern Int4 MySeqEntryToAsn3Ex (SeqEntryPtr sep, Boolean strip, Boolean correct, Boolean force, Boolean dotaxon);
extern Int4 MySeqEntryToAsn3 (SeqEntryPtr sep, Boolean strip, Boolean correct, Boolean force)
@@ -3266,10 +3311,13 @@ static void BioseqViewFormActivated (WindoW w)
(HANDLE) newDescMenu,
(HANDLE) newFeatMenu,
(HANDLE) newPubMenu,
+ (HANDLE) batchApplyMenu,
+ (HANDLE) batchEditMenu,
(HANDLE) prepareItem,
- (HANDLE) validateItem,
(HANDLE) edithistoryitem,
NULL);
+ Enable (validateItem);
+ Enable (validateMenu);
Enable (aluItem);
Enable (submitItem);
Enable (specialMenu);
@@ -3552,8 +3600,9 @@ static void MacDeactProc (WindoW w)
(HANDLE) newDescMenu,
(HANDLE) newFeatMenu,
(HANDLE) newPubMenu,
+ (HANDLE) batchApplyMenu,
+ (HANDLE) batchEditMenu,
(HANDLE) prepareItem,
- (HANDLE) validateItem,
(HANDLE) editsequenceitem,
(HANDLE) editseqalignitem,
(HANDLE) editseqsubitem,
@@ -3564,6 +3613,8 @@ static void MacDeactProc (WindoW w)
(HANDLE) featPropItem,
(HANDLE) updalignitem,
NULL);
+ Disable (validateItem);
+ Disable (validateMenu);
Disable (aluItem);
Disable (submitItem);
Disable (vectorScreenItem);
@@ -4218,10 +4269,9 @@ static void AcceptChangeTargetProc (ButtoN b)
cfp = (ChangeTargetFormPtr) GetObjectExtra (b);
if (cfp == NULL) return;
- Hide (cfp->form);
GetTitle (cfp->seqid, str, sizeof (str));
SetBioseqViewTarget (cfp->base, str);
- Remove (cfp->form);
+ SetTitle (cfp->seqid, "");
}
static void ChangeTargetMessageProc (ForM f, Int2 mssg)
@@ -4415,7 +4465,7 @@ static void PreferencesProc (IteM i)
SetGroupSpacing (g, 10, 10);
pfp->prefs = CreateEntrezPrefsDialog (g, NULL);
c = HiddenGroup (g, 2, 0, NULL);
- b = PushButton (c, "Accept", AcceptPrefsProc);
+ b = DefaultButton (c, "Accept", AcceptPrefsProc);
SetObjectExtra (b, pfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) pfp->prefs, (HANDLE) c, NULL);
@@ -5929,7 +5979,7 @@ static void CommonAddSeq (IteM i, Int2 type)
orp = OrgRefNew ();
biop->org = orp;
if (orp != NULL) {
- orp->taxname = StringSave (str);
+ SetTaxNameAndRemoveTaxRef (orp, StringSave (str));
}
vnp = CreateNewDescriptor (sep, Seq_descr_source);
if (vnp != NULL) {
@@ -5944,7 +5994,7 @@ static void CommonAddSeq (IteM i, Int2 type)
orp = OrgRefNew ();
biop->org = orp;
if (orp != NULL) {
- orp->taxname = StringSave (tax);
+ SetTaxNameAndRemoveTaxRef (orp, tax);
}
vnp = CreateNewDescriptor (sep, Seq_descr_source);
if (vnp != NULL) {
@@ -6093,7 +6143,6 @@ static void UpdateSeqWithAcc (IteM i)
BaseFormPtr bfp;
BioseqPtr bsp;
SeqEntryPtr sep;
- SeqEntryPtr source_sep = NULL;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -6115,7 +6164,6 @@ static void ExtendSeqWithAcc (IteM i)
BaseFormPtr bfp;
BioseqPtr bsp;
SeqEntryPtr sep;
- SeqEntryPtr source_sep = NULL;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -6394,15 +6442,21 @@ static void BioseqViewFormMenus (WindoW w)
i = CommandItem (m, "Find by Position...", FindPosProc);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (m);
- i = CommandItem (m, "Validate.../ V", ValSeqEntryProc);
- SetObjectExtra (i, bfp, NULL);
+ if (indexerVersion) {
+ sub = SubMenu (m, "Validate/ V");
+ i = CommandItem (sub, "Validate Record/ R", ValSeqEntryProc);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (sub, "Validate no Alignments/ A", ValSeqEntryProcNoAln);
+ SetObjectExtra (i, bfp, NULL);
+ } else {
+ i = CommandItem (m, "Validate/ V", ValSeqEntryProc);
+ SetObjectExtra (i, bfp, NULL);
+ }
#ifdef USE_SPELL
-#ifdef WIN_MOTIF
SeparatorItem (m);
i = CommandItem (m, "Spell Check...", SpellCheckSeqEntryProc);
SetObjectExtra (i, bfp, NULL);
#endif
-#endif
/*#ifdef USE_BLAST*/
if (useBlast) {
/*
@@ -6447,8 +6501,10 @@ static void BioseqViewFormMenus (WindoW w)
sub = SubMenu (m, "Font Selection");
i = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
SetObjectExtra (i, bfp, NULL);
+ /*
SeparatorItem (m);
CreateLegendItem (m, bfp);
+ */
}
/*#ifdef EXTRA_SERVICES*/
@@ -6484,6 +6540,11 @@ static void BioseqViewFormMenus (WindoW w)
m = PulldownMenu (w, "Annotate/ A");
SetupNewFeaturesMenu (m, bfp);
SeparatorItem (m);
+ sub = SubMenu (m, "Batch Feature Apply");
+ SetupBatchApplyMenu (sub, bfp);
+ sub = SubMenu (m, "Batch Feature Edit");
+ SetupBatchEditMenu (sub, bfp);
+ SeparatorItem (m);
sub = SubMenu (m, "Publications");
SetupNewPublicationsMenu (sub, bfp);
SeparatorItem (m);
@@ -6498,8 +6559,10 @@ static void BioseqViewFormMenus (WindoW w)
sub = SubMenu (m, "Font Selection");
i = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
SetObjectExtra (i, bfp, NULL);
+ /*
SeparatorItem (m);
CreateLegendItem (m, bfp);
+ */
SeparatorItem (m);
sub = SubMenu (m, "Layout Override");
CreateNewLayoutMenu (sub, bfp);
@@ -8186,15 +8249,11 @@ static void SetupDesktop (void)
medviewprocs.createMenus = MedlineViewFormMenus;
#endif
medviewprocs.showAsnPage = TRUE;
-#ifdef WIN_MOTIF
if (indexerVersion) {
medviewprocs.useScrollText = TRUE;
} else {
medviewprocs.useScrollText = FALSE;
}
-#else
- medviewprocs.useScrollText = FALSE;
-#endif
medviewprocs.handleMessages = SequinMedlineFormMessage;
medviewprocs.makeControls = DoMakeMedViewerLinkControls;
SetAppProperty ("MedlineDisplayForm", &medviewprocs);
@@ -8222,6 +8281,11 @@ static void SetupDesktop (void)
seqviewprocs.createToolBar = BioseqViewFormToolBar; /* now in separate window */
}
#endif
+#ifdef WIN_MSWIN
+ if (indexerVersion) {
+ seqviewprocs.createToolBar = BioseqViewFormToolBar; /* now in separate window */
+ }
+#endif
/*#ifdef INTERNAL_NCBI_SEQUIN*/
if (indexerVersion) {
seqviewprocs.allowScrollText = TRUE;
@@ -8289,15 +8353,11 @@ static void SetupDesktop (void)
#ifdef WIN_MAC
txtviewprocs.activateForm = TextViewProcFormActivated;
#endif
-#ifdef WIN_MOTIF
if (indexerVersion) {
txtviewprocs.useScrollText = TRUE;
} else {
txtviewprocs.useScrollText = FALSE;
}
-#else
- txtviewprocs.useScrollText = FALSE;
-#endif
SetAppProperty ("TextDisplayForm", &txtviewprocs);
SetAppProperty ("HelpMessageProc", (Pointer) ProcessHelpMessage);
@@ -9095,13 +9155,17 @@ static void SetupMacMenus (void)
findProtItem = CommandItem (m, "Find by Protein...", FindProtProc);
findPosItem = CommandItem (m, "Find by Position...", FindPosProc);
SeparatorItem (m);
- validateItem = CommandItem (m, "Validate...", ValSeqEntryProc);
+ if (indexerVersion) {
+ validateMenu = SubMenu (m, "Validate");
+ CommandItem (validateMenu, "Validate Record/ V", ValSeqEntryProc);
+ CommandItem (validateMenu, "Validate no Alignments", ValSeqEntryProcNoAln);
+ } else {
+ validateItem = CommandItem (m, "Validate", ValSeqEntryProc);
+ }
#ifdef USE_SPELL
-#ifdef WIN_MOTIF
SeparatorItem (m);
spellItem = CommandItem (m, "Spell Check...", SpellCheckSeqEntryProc);
#endif
-#endif
/*#ifdef USE_BLAST*/
if (useBlast) {
/*
@@ -9142,8 +9206,10 @@ static void SetupMacMenus (void)
docsumfontItem = CommandItem (sub, "DocSum Font...", DocSumFontChangeProc);
}
displayfontItem = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
+ /*
SeparatorItem (m);
legendItem = CreateLegendItem (m, NULL);
+ */
SeparatorItem (m);
sub = SubMenu (m, "Query Style");
queryChoice = CreateQueryTypeChoice (sub, NULL);
@@ -9201,6 +9267,11 @@ static void SetupMacMenus (void)
newFeatMenu = PulldownMenu (NULL, "Annotate");
SetupNewFeaturesMenu (newFeatMenu, NULL);
SeparatorItem (newFeatMenu);
+ batchApplyMenu = SubMenu (newFeatMenu, "Batch Feature Apply");
+ SetupBatchApplyMenu (batchApplyMenu, NULL);
+ batchEditMenu = SubMenu (newFeatMenu, "Batch Feature Edit");
+ SetupBatchEditMenu (batchEditMenu, NULL);
+ SeparatorItem (newFeatMenu);
newPubMenu = SubMenu (newFeatMenu, "Publications");
SetupNewPublicationsMenu (newPubMenu, NULL);
SeparatorItem (newFeatMenu);
@@ -10261,7 +10332,6 @@ static VoidPtr LIBCALLBACK DumbUserDataFree (VoidPtr Pointer)
static void SMCancelAllEdit(void)
{
ObjMgrPtr omp;
- ObjMgrDataPtr tmp;
OMUserDataPtr omudp;
Int2 num;
SMUserDataPtr sm_usr_data = NULL;
@@ -10307,7 +10377,7 @@ static Int4 SMReadBioseqObj(VoidPtr data, CharPtr buffer, Int4 length, Int4 fd)
Int4 headlen;
BioseqPtr bsp;
BioseqSetPtr bssp = NULL, bssp2;
- SeqEntryPtr sep = NULL, sep1, sep2, oldsep;
+ SeqEntryPtr sep = NULL, sep1, sep2;
ObjMgrData omdata;
ObjMgrDataPtr omdptop = NULL;
Uint2 parenttype = 0;
@@ -10497,10 +10567,9 @@ static Int4 SMWriteBioseqObj(VoidPtr bio_data,
VoidPtr data)
{
ByteStorePtr bsp;
- Nlm_BSUnitPtr bsup;
AsnIoBSPtr aibp;
CharPtr buffer;
- Int4 length, totlen, bytes =0;
+ Int4 length, totlen;
bsp = BSNew(1024);
@@ -10583,7 +10652,6 @@ Int2 Main (void)
*/
OMUserDataPtr omudp;
PaneL p;
- Int2 procval = OM_MSG_RET_NOPROC;
CharPtr ptr;
SeqEntryPtr sep;
Int4 smartPort = 0;
@@ -10732,6 +10800,16 @@ Int2 Main (void)
entrezMode = TRUE;
else if (StringCmp (argv[i], "-h") == 0)
nohelpMode = TRUE;
+#ifdef USE_SMARTNET
+ else if (StringNCmp (argv[i], "-z", 2) == 0) {
+ smartnetMode = TRUE;
+ dirsubMode = TRUE;
+ if(*(argv[i]+2) != NULLB)
+ smartPort = atoi(argv[i]+2);
+ else
+ smartPort = SM_SERVER_PORT;
+ }
+#endif
}
}}
#endif
@@ -11079,6 +11157,13 @@ Int2 Main (void)
CleanupSequin ();
return 0;
} else {
+ if (! nohelpMode) {
+ SetTitle (w, "Creating help window");
+ if (helpForm == NULL) {
+ helpForm = CreateHelpForm (-95, -5, "Sequin Help", "sequin.hlp",
+ HideHelpForm, HelpActivateProc);
+ }
+ }
SendHelpScrollMessage (helpForm, "Editing the Record", NULL);
}
ObjMgrSetOptions (OM_OPT_FREE_IF_NO_VIEW, subtoolEntityID);
@@ -11164,16 +11249,19 @@ Int2 Main (void)
} else if (startupForm != NULL) {
Show (startupForm);
Select (startupForm);
- if (! nohelpMode) {
- Show (helpForm);
- SendHelpScrollMessage (helpForm, "Introduction", NULL);
- }
Update ();
initSubmitForm = CreateInitSubmitterForm (-5, -67, "Submitting Authors",
GetFormat, BackToStartup,
SubmitBlockActivateProc);
formatForm = CreateFormatForm (-5, -67, "Sequence Format",
GetOrgAndSeq, BackToSubmitter, FormatActivateProc);
+ if (! nohelpMode) {
+ Update ();
+ Show (helpForm);
+ Select (helpForm);
+ Update ();
+ SendHelpScrollMessage (helpForm, "Introduction", NULL);
+ }
} else {
Message (MSG_FATAL, "Unable to create window.");
CleanupSequin ();
diff --git a/sequin/sequin10.c b/sequin/sequin10.c
index 4104e09c..580381de 100644
--- a/sequin/sequin10.c
+++ b/sequin/sequin10.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 9/3/2003
*
-* $Revision: 1.154 $
+* $Revision: 1.197 $
*
* File Description:
*
@@ -48,7 +48,8 @@
#include <explore.h>
#include <edutil.h>
#include <tofasta.h>
-
+#include <gbftdef.h>
+#include <gbfeat.h>
/* The matchFunction functions are used to identify features that meet
* specific requirements, usually that the feature is of a particular type.
@@ -154,7 +155,7 @@ static ValNodePtr FindStringInStrings (
/* This function finds the first item in "strings" that is identical to
* "value".
*/
-static ValNodePtr FindExactStringInStrings (
+extern ValNodePtr FindExactStringInStrings (
ValNodePtr strings,
CharPtr value
)
@@ -304,6 +305,7 @@ typedef struct organismdescriptionmodifiers {
Boolean keep_paren;
Boolean exclude_sp;
Int4 clone_isolate_HIV_rule_num;
+ Boolean use_modifiers;
} OrganismDescriptionModifiers, PNTR OrganismDescriptionModifiersPtr;
/* This is a list of the modifiers that are of interest */
/* Note that if you modify the DefLineModifiers array, */
@@ -342,6 +344,7 @@ static ModifierItemGlobalData DefLineModifiers[] = {
{ "Isolation-source" , FALSE, SUBSRC_isolation_source , FALSE },
{ "Lab-host" , FALSE, SUBSRC_lab_host , FALSE },
{ "Map" , FALSE, SUBSRC_map , FALSE },
+ { "Old-lineage" , TRUE , ORGMOD_old_lineage , FALSE },
{ "Old-name" , TRUE , ORGMOD_old_name , FALSE },
{ "Pathovar" , TRUE , ORGMOD_pathovar , FALSE },
{ "Plasmid-name" , FALSE, SUBSRC_plasmid_name , TRUE },
@@ -354,7 +357,7 @@ static ModifierItemGlobalData DefLineModifiers[] = {
{ "Serovar" , TRUE , ORGMOD_serovar , FALSE },
{ "Sex" , FALSE, SUBSRC_sex , FALSE },
{ "Specific-host" , TRUE , ORGMOD_nat_host , FALSE },
- { "Specimen-voucher" , TRUE , ORGMOD_specimen_voucher , FALSE },
+ { "Specimen voucher" , TRUE , ORGMOD_specimen_voucher , FALSE },
{ "Strain" , TRUE , ORGMOD_strain , FALSE },
{ "Subclone" , FALSE, SUBSRC_subclone , FALSE },
{ "Subgroup" , TRUE , ORGMOD_subgroup , FALSE },
@@ -404,6 +407,7 @@ typedef enum {
DEFLINE_POS_Isolation_source,
DEFLINE_POS_Lab_host,
DEFLINE_POS_Map,
+ DEFLINE_POS_Old_lineage,
DEFLINE_POS_Old_name,
DEFLINE_POS_Pathovar,
DEFLINE_POS_Plasmid_name,
@@ -455,9 +459,7 @@ static void CountModifiersProc (
)
{
ModifierItemLocalPtr ItemList;
- OrgRefPtr orp;
OrgModPtr mod;
- OrgNamePtr onp;
SubSourcePtr ssp;
Int2 i;
Boolean found_this_modifier;
@@ -465,18 +467,13 @@ static void CountModifiersProc (
if (biop == NULL) return;
ItemList = (ModifierItemLocalPtr) userdata;
- orp = biop->org;
- if (orp == NULL) return;
-
- onp = orp->orgname;
- if (onp == NULL) return;
-
for (i=0; i < NumDefLineModifiers; i++)
{
found_this_modifier = FALSE;
if (DefLineModifiers[i].isOrgMod)
{
- mod = onp->mod;
+ if ( biop->org == NULL || biop->org->orgname == NULL) continue;
+ mod = biop->org->orgname->mod;
while (mod != NULL
&& mod->subtype != DefLineModifiers[i].subtype)
{
@@ -652,21 +649,16 @@ static void AddQualToBioSrcDescPtr (
Int2 feature_index
)
{
- OrgRefPtr orp;
OrgModPtr mod;
- OrgNamePtr onp;
SubSourcePtr ssp;
if (bsdp == NULL) return;
if (bsdp->biop == NULL) return;
- orp = bsdp->biop->org;
- if (orp == NULL) return;
- onp = orp->orgname;
- if (onp == NULL) return;
if (DefLineModifiers[feature_index].isOrgMod)
{
- mod = onp->mod;
+ if (bsdp->biop->org == NULL || bsdp->biop->org->orgname == NULL) return;
+ mod = bsdp->biop->org->orgname->mod;
while (mod != NULL
&& mod->subtype != DefLineModifiers[feature_index].subtype)
{
@@ -1116,8 +1108,11 @@ static void BuildTaxOrgGroupList (
ogp->num_organisms ++;
}
}
- prevOgp = ogp;
- ogp = ogp->next;
+ if (cmpval < 0)
+ {
+ prevOgp = ogp;
+ ogp = ogp->next;
+ }
}
if (cmpval != 0)
{
@@ -1140,18 +1135,55 @@ static void BuildTaxOrgGroupList (
}
}
+typedef struct bestsortdata {
+ Int4 feature_index;
+ Boolean all_unique;
+ Boolean all_present;
+ Boolean is_unique;
+} BestSortData, PNTR BestSortPtr;
+
+static Boolean Index1FoundBeforeIndex2 (
+ Int4 index1,
+ Int4 index2,
+ ValNodePtr list
+)
+{
+ ValNodePtr vnp;
+ BestSortPtr bsp;
+ for (vnp = list; vnp != NULL; vnp = vnp->next)
+ {
+ if ((bsp = vnp->data.ptrvalue) == NULL)
+ {
+ continue;
+ }
+ if (bsp->feature_index == index1) return TRUE;
+ if (bsp->feature_index == index2) return FALSE;
+ }
+ return FALSE;
+}
+
/* This function determines whether or not we should try adding this modifier
* to our combination. If we've already tried it and not added it to the list,
* there's no reason to try adding it again.
*/
-static Boolean okToTryAddingQual (
+static Boolean OkToTryAddingQual (
ModifierCombinationPtr m,
ModifierItemLocalPtr ItemList,
+ ValNodePtr available_modifiers_list,
Int2 feature_index
)
{
ValNodePtr vnp;
+ /* if feature_index indicates a value we don't use for best combos, skip */
+ if (feature_index == DEFLINE_POS_Old_name
+ || feature_index == DEFLINE_POS_Old_lineage
+ || feature_index == DEFLINE_POS_Dosage
+ || feature_index == DEFLINE_POS_Map)
+ {
+ return FALSE;
+ }
+
if (m == NULL) return TRUE;
/* if feature_index is lower than anything else on list (other than */
@@ -1162,13 +1194,111 @@ static Boolean okToTryAddingQual (
if (feature_index == m->modifier_indices->data.intvalue)
return FALSE;
if (! ItemList[m->modifier_indices->data.intvalue].required &&
- feature_index < m->modifier_indices->data.intvalue)
+ Index1FoundBeforeIndex2 (feature_index,
+ m->modifier_indices->data.intvalue,
+ available_modifiers_list))
+ {
return FALSE;
+ }
vnp = vnp->next;
}
return TRUE;
}
+static ValNodePtr GetListOfAvailableModifiers ( ModifierItemLocalPtr ItemList)
+{
+ ValNodePtr vnp, head;
+ Int2 feature_index;
+ BestSortPtr bsp;
+
+ head = NULL;
+ for (feature_index = 0; feature_index < NumDefLineModifiers; feature_index++)
+ {
+ if ( ItemList[feature_index].any_present)
+ {
+ bsp = (BestSortPtr) MemNew (sizeof (BestSortData));
+ if (bsp == NULL) return NULL;
+ bsp->feature_index = feature_index;
+ bsp->all_unique = ItemList[feature_index].all_unique;
+ bsp->all_present = ItemList[feature_index].all_present;
+ bsp->is_unique = ItemList[feature_index].is_unique;
+ vnp = ValNodeNew (head);
+ if (vnp == NULL) return NULL;
+ vnp->data.ptrvalue = bsp;
+ if (head == NULL) head = vnp;
+ }
+ }
+ return head;
+}
+
+static Int4 DefLineQualSortOrder [] = {
+ DEFLINE_POS_Transgenic,
+ DEFLINE_POS_Plasmid_name,
+ DEFLINE_POS_Endogenous_virus_name,
+ DEFLINE_POS_Strain,
+ DEFLINE_POS_Clone,
+ DEFLINE_POS_Isolate,
+ DEFLINE_POS_Haplotype,
+ DEFLINE_POS_Cultivar,
+ DEFLINE_POS_Specimen_voucher,
+ DEFLINE_POS_Ecotype,
+ DEFLINE_POS_Type,
+ DEFLINE_POS_Serotype,
+ DEFLINE_POS_Authority,
+ DEFLINE_POS_Breed
+};
+
+static int LIBCALLBACK SortByImportanceAndPresence (
+ VoidPtr ptr1,
+ VoidPtr ptr2
+)
+{
+ ValNodePtr vnp1;
+ ValNodePtr vnp2;
+ BestSortPtr bsp1, bsp2;
+ Int4 num_defline_qual_sort_order, index;
+
+ if (ptr1 == NULL && ptr2 == NULL) return 0;
+
+ if (ptr1 == NULL && ptr2 != NULL) return -1;
+ if (ptr1 != NULL && ptr2 == NULL) return 1;
+
+ vnp1 = *((ValNodePtr PNTR) ptr1);
+ vnp2 = *((ValNodePtr PNTR) ptr2);
+ if (vnp1 == NULL || vnp2 == NULL) return 0;
+ if (vnp1->data.ptrvalue == NULL || vnp2->data.ptrvalue == NULL) return 0;
+
+ bsp1 = vnp1->data.ptrvalue;
+ bsp2 = vnp2->data.ptrvalue;
+ if (bsp1->feature_index == bsp2->feature_index) return 0;
+
+ if (bsp1->all_present && bsp1->all_unique
+ && (! bsp2->all_present || ! bsp2->all_unique))
+ {
+ return -1;
+ }
+ if (bsp2->all_present && bsp2->all_unique
+ && (! bsp1->all_present || ! bsp1->all_unique))
+ {
+ return 1;
+ }
+
+ if ( ! bsp1->is_unique && bsp2->is_unique) return -1;
+ if ( ! bsp2->is_unique && bsp1->is_unique) return 1;
+
+ num_defline_qual_sort_order = sizeof (DefLineQualSortOrder) / sizeof (Int4);
+ for (index = 0; index < num_defline_qual_sort_order; index++)
+ {
+ if (bsp1->feature_index == DefLineQualSortOrder [ index ]) return -1;
+ if (bsp2->feature_index == DefLineQualSortOrder [ index ]) return 1;
+ }
+
+ if (bsp1->feature_index > bsp2->feature_index) return 1;
+ if (bsp1->feature_index < bsp2->feature_index) return -1;
+ return 0;
+}
+
+
/* The function FindBestCombo tries to find the best combination of modifiers
* to create unique organism descriptions. This is accomplished by
* creating a list of required modifiers, and then creating a list of
@@ -1202,7 +1332,9 @@ static ModifierCombinationPtr FindBestCombo(
ModifierCombinationPtr mc_list, start_of_expand, best_found, end_of_list;
ModifierCombinationPtr next_start_of_expand, m, newm;
Int4 num_to_expand, next_num_to_expand;
- Int2 i, feature_index;
+ Int2 i;
+ ValNodePtr available_modifier_list, vnp;
+ BestSortPtr bsp;
best_found = NULL;
@@ -1214,12 +1346,17 @@ static ModifierCombinationPtr FindBestCombo(
mc_list = NewModifierCombo (group_list);
if (mc_list == NULL) return NULL;
+ available_modifier_list = GetListOfAvailableModifiers (ItemList);
+
/* next, add in any required qualifiers */
- for (feature_index = 0; feature_index < NumDefLineModifiers; feature_index++)
+ for (vnp = available_modifier_list; vnp != NULL; vnp = vnp->next)
{
- if (ItemList[feature_index].required)
+ bsp = vnp->data.ptrvalue;
+ if (bsp == NULL) return NULL;
+ if (ItemList[bsp->feature_index].required)
{
- AddQualToModifierCombo (mc_list, ItemList + feature_index, feature_index);
+ AddQualToModifierCombo (mc_list, ItemList + bsp->feature_index,
+ bsp->feature_index);
}
}
if (mc_list->max_orgs_in_group == 1)
@@ -1229,6 +1366,8 @@ static ModifierCombinationPtr FindBestCombo(
return best_found;
}
+ available_modifier_list = SortValNode (available_modifier_list,
+ SortByImportanceAndPresence);
start_of_expand = mc_list;
end_of_list = mc_list;
num_to_expand = 1;
@@ -1239,16 +1378,19 @@ static ModifierCombinationPtr FindBestCombo(
for (i=0; i < num_to_expand && start_of_expand != NULL; i++)
{
/* try adding qualifiers */
- for (feature_index = 0;
- feature_index < NumDefLineModifiers && best_found == NULL;
- feature_index++)
- {
- if ( ItemList[feature_index].any_present
- && okToTryAddingQual (start_of_expand, ItemList, feature_index))
+ for (vnp = available_modifier_list;
+ vnp != NULL && best_found == NULL;
+ vnp = vnp->next)
+ {
+ bsp = vnp->data.ptrvalue;
+ if (bsp == NULL) return NULL;
+ if (OkToTryAddingQual (start_of_expand, ItemList,
+ available_modifier_list,
+ bsp->feature_index))
{
newm = CopyModifierCombo (start_of_expand);
- AddQualToModifierCombo (newm, ItemList + feature_index,
- feature_index);
+ AddQualToModifierCombo (newm, ItemList + bsp->feature_index,
+ bsp->feature_index);
if (start_of_expand->num_groups >= newm->num_groups)
{
/* situation didn't get better, don't bother to add this one */
@@ -1297,7 +1439,13 @@ static ModifierCombinationPtr FindBestCombo(
best_found = m;
}
else if (m->num_unique_orgs == best_found->num_unique_orgs
- && m->num_groups < best_found->num_groups)
+ && m->num_groups > best_found->num_groups)
+ {
+ best_found = m;
+ }
+ else if (m->num_unique_orgs == best_found->num_unique_orgs
+ && m->num_groups == best_found->num_groups
+ && m->num_mods < best_found->num_groups)
{
best_found = m;
}
@@ -1324,9 +1472,43 @@ static ModifierCombinationPtr FindBestCombo(
return best_found;
}
+/* create combo with the specified modifiers */
+static ModifierCombinationPtr CreateComboFromModList (
+ ModifierItemLocalPtr modList
+)
+{
+ ModifierCombinationPtr m;
+ Int4 feature_index;
+
+ m = NewModifierCombo (NULL);
+ if (m == NULL) return NULL;
+ for (feature_index = 0; feature_index < NumDefLineModifiers; feature_index++)
+ {
+ if (modList[feature_index].any_present && modList [feature_index].required)
+ {
+ AddQualToModifierCombo (m, modList + feature_index, feature_index);
+ }
+ }
+ return m;
+}
+
+
/* This is the callback function for sorting the modifier list. It
* implements an order specified by the indexers.
*/
+static Int4 DefLineQualPresentationOrder [] = {
+ DEFLINE_POS_Transgenic,
+ DEFLINE_POS_Strain,
+ DEFLINE_POS_Isolate,
+ DEFLINE_POS_Cultivar,
+ DEFLINE_POS_Specimen_voucher,
+ DEFLINE_POS_Ecotype,
+ DEFLINE_POS_Type,
+ DEFLINE_POS_Serotype,
+ DEFLINE_POS_Authority,
+ DEFLINE_POS_Breed
+};
+
static int LIBCALLBACK SortByImportance (
VoidPtr ptr1,
VoidPtr ptr2
@@ -1334,6 +1516,8 @@ static int LIBCALLBACK SortByImportance (
{
ValNodePtr vnp1;
ValNodePtr vnp2;
+ Int4 num_defline_qual_sort_order, index;
+
if (ptr1 == NULL && ptr2 == NULL) return 0;
if (ptr1 == NULL && ptr2 != NULL) return -1;
@@ -1343,24 +1527,82 @@ static int LIBCALLBACK SortByImportance (
vnp2 = *((ValNodePtr PNTR) ptr2);
if (vnp1 == NULL || vnp2 == NULL) return 0;
if (vnp1->data.intvalue == vnp2->data.intvalue) return 0;
- /* transgenic is first, if present */
- if (vnp1->data.intvalue == DEFLINE_POS_Transgenic) return -1;
- if (vnp2->data.intvalue == DEFLINE_POS_Transgenic) return 1;
- /* plasmid is first, if present, unless transgenic is present */
- if (vnp1->data.intvalue == DEFLINE_POS_Plasmid_name) return -1;
- if (vnp2->data.intvalue == DEFLINE_POS_Plasmid_name) return 1;
- /* endogenous virus is first, if present, unless plasmid or transgenic is first */
- if (vnp1->data.intvalue == DEFLINE_POS_Endogenous_virus_name) return -1;
- if (vnp2->data.intvalue == DEFLINE_POS_Endogenous_virus_name) return 1;
- /* strain is next most important */
- if (vnp1->data.intvalue == DEFLINE_POS_Strain) return -1;
- if (vnp2->data.intvalue == DEFLINE_POS_Strain) return 1;
- /* clone is next most important */
- if (vnp1->data.intvalue == DEFLINE_POS_Clone) return -1;
- if (vnp2->data.intvalue == DEFLINE_POS_Clone) return 1;
- /* isolate is next most important */
- if (vnp1->data.intvalue == DEFLINE_POS_Isolate) return -1;
- if (vnp2->data.intvalue == DEFLINE_POS_Isolate) return 1;
+
+ num_defline_qual_sort_order = sizeof (DefLineQualPresentationOrder) / sizeof (Int4);
+ for (index = 0; index < num_defline_qual_sort_order; index++)
+ {
+ if (vnp1->data.intvalue == DefLineQualPresentationOrder [ index ]) return -1;
+ if (vnp2->data.intvalue == DefLineQualPresentationOrder [ index ]) return 1;
+ }
+
+ if ((vnp1->data.intvalue < 0 || vnp1->data.intvalue > NumDefLineModifiers)
+ && (vnp2->data.intvalue < 0 || vnp2->data.intvalue > NumDefLineModifiers))
+ {
+ return 0;
+ }
+ if (vnp1->data.intvalue < 0 || vnp1->data.intvalue > NumDefLineModifiers)
+ {
+ return 1;
+ }
+ if (vnp2->data.intvalue < 0 || vnp2->data.intvalue > NumDefLineModifiers)
+ {
+ return -1;
+ }
+
+ if (DefLineModifiers [ vnp1->data.intvalue].isOrgMod
+ && (! DefLineModifiers [ vnp2->data.intvalue].isOrgMod
+ || vnp2->data.intvalue == DEFLINE_POS_Plasmid_name
+ || vnp2->data.intvalue == DEFLINE_POS_Endogenous_virus_name))
+ {
+ return -1;
+ }
+ if (DefLineModifiers [ vnp2->data.intvalue].isOrgMod
+ && (! DefLineModifiers [ vnp1->data.intvalue].isOrgMod
+ || vnp1->data.intvalue == DEFLINE_POS_Plasmid_name
+ || vnp1->data.intvalue == DEFLINE_POS_Endogenous_virus_name))
+ {
+ return 1;
+ }
+
+ if (vnp1->data.intvalue == DEFLINE_POS_Plasmid_name)
+ {
+ return -1;
+ }
+ if (vnp2->data.intvalue == DEFLINE_POS_Plasmid_name)
+ {
+ return 1;
+ }
+
+ if (vnp1->data.intvalue == DEFLINE_POS_Endogenous_virus_name)
+ {
+ return -1;
+ }
+ if (vnp2->data.intvalue == DEFLINE_POS_Endogenous_virus_name)
+ {
+ return 1;
+ }
+
+ if (! DefLineModifiers [ vnp1->data.intvalue].isOrgMod
+ && vnp2->data.intvalue == DEFLINE_POS_Clone)
+ {
+ return 1;
+ }
+ if (! DefLineModifiers [ vnp2->data.intvalue].isOrgMod
+ && vnp1->data.intvalue == DEFLINE_POS_Clone)
+ {
+ return -1;
+ }
+
+ if (! DefLineModifiers [ vnp1->data.intvalue].isOrgMod
+ && vnp2->data.intvalue == DEFLINE_POS_Haplotype)
+ {
+ return 1;
+ }
+ if (! DefLineModifiers [ vnp2->data.intvalue].isOrgMod
+ && vnp1->data.intvalue == DEFLINE_POS_Haplotype)
+ {
+ return -1;
+ }
if (vnp1->data.intvalue > vnp2->data.intvalue) return 1;
if (vnp1->data.intvalue < vnp2->data.intvalue) return -1;
@@ -1513,6 +1755,17 @@ static void AddModifierLabel (
{
StringCpy (modifier_text, "endogenous virus");
}
+ else if (feature_index == DEFLINE_POS_Specimen_voucher)
+ {
+ if (use_labels)
+ {
+ StringCpy (modifier_text, "voucher");
+ }
+ else
+ {
+ modifier_text [0] = 0;
+ }
+ }
else if (use_labels || feature_index == DEFLINE_POS_Transgenic
|| feature_index == DEFLINE_POS_Plasmid_name)
{
@@ -1721,8 +1974,6 @@ static CharPtr GetOrganismDescription (
Char modifier_text [256];
ValNodePtr strings;
BioSourcePtr biop;
- OrgRefPtr orp;
- OrgNamePtr onp;
OrgModPtr mod;
SubSourcePtr ssp;
ValNodePtr modifier_indices;
@@ -1730,6 +1981,8 @@ static CharPtr GetOrganismDescription (
Int2 feature_index;
CharPtr org_desc;
CharPtr cp;
+ Int4 no_semicolon_len;
+ Int4 label_len;
biop = NULL;
strings = NULL;
@@ -1756,21 +2009,23 @@ static CharPtr GetOrganismDescription (
ValNodeAddStr (&strings, 0, StringSave (taxName));
- orp = biop->org;
- if (orp == NULL) return NULL;
- onp = orp->orgname;
- if (onp == NULL) return NULL;
modifier_indices = CopyModifierIndices (m->modifier_indices);
AddHIVModifierIndices (&modifier_indices, biop, modList, taxName,
odmp->clone_isolate_HIV_rule_num);
modifier_indices = SortValNode (modifier_indices, SortByImportance);
- vnp = modifier_indices;
- while (vnp != NULL && (odmp->max_mods == -99 || odmp->max_mods > 0))
+ for (vnp = modifier_indices;
+ vnp != NULL && (odmp->max_mods == -99 || odmp->max_mods > 0);
+ vnp = vnp->next)
{
feature_index = vnp->data.intvalue;
- if (DefLineModifiers[feature_index].isOrgMod)
+ if (! odmp->use_modifiers && !DefLineModifiers[feature_index].default_required)
+ {
+ /* do nothing */
+ }
+ else if (DefLineModifiers[feature_index].isOrgMod)
{
- mod = onp->mod;
+ if (biop->org == NULL || biop->org->orgname == NULL) continue;
+ mod = biop->org->orgname->mod;
while (mod != NULL
&& mod->subtype != DefLineModifiers[feature_index].subtype)
{
@@ -1778,20 +2033,32 @@ static CharPtr GetOrganismDescription (
}
if ( UseOrgModifier (mod, taxName))
{
+ no_semicolon_len = StringCSpn (mod->subname, ";");
+
if (mod->subtype == ORGMOD_nat_host)
{
sprintf (modifier_text, "from ");
+ if (no_semicolon_len > sizeof (modifier_text) - 6)
+ {
+ no_semicolon_len = sizeof (modifier_text) - 6;
+ }
StringNCpy (modifier_text + 5, mod->subname,
- sizeof (modifier_text) - 6);
- modifier_text[sizeof (modifier_text) - 1] = 0;
+ no_semicolon_len);
+ modifier_text[no_semicolon_len + 5] = 0;
}
else
{
AddModifierLabel (odmp->use_labels, feature_index, modifier_text);
if (modifier_text[0] != 0)
StringCat (modifier_text, " ");
+ label_len = StringLen (modifier_text);
+ if (no_semicolon_len > sizeof (modifier_text) - label_len - 1)
+ {
+ no_semicolon_len = sizeof (modifier_text) - label_len - 1;
+ }
StringNCat (modifier_text, mod->subname,
- sizeof (modifier_text) - StringLen (modifier_text) - 1);
+ no_semicolon_len);
+ modifier_text [ no_semicolon_len + label_len] = 0;
}
ValNodeCopyStr( &strings, 0, modifier_text);
if (odmp->max_mods != -99)
@@ -1806,6 +2073,7 @@ static CharPtr GetOrganismDescription (
}
if (ssp != NULL)
{
+ no_semicolon_len = StringCSpn (ssp->name, ";");
AddModifierLabel (odmp->use_labels, feature_index, modifier_text);
if (ssp->subtype == SUBSRC_transgenic)
{
@@ -1814,8 +2082,12 @@ static CharPtr GetOrganismDescription (
else if (ssp->subtype == SUBSRC_country)
{
sprintf (modifier_text, "from ");
- StringNCpy (modifier_text + 5, ssp->name, sizeof (modifier_text) - 6);
- modifier_text[sizeof (modifier_text) - 1] = 0;
+ if (no_semicolon_len > sizeof (modifier_text) - 6)
+ {
+ no_semicolon_len = sizeof (modifier_text) - 6;
+ }
+ StringNCpy (modifier_text + 5, ssp->name, no_semicolon_len);
+ modifier_text[5 + no_semicolon_len] = 0;
cp = StringChr (modifier_text, ':');
if (cp != NULL) *cp = 0;
}
@@ -1825,15 +2097,19 @@ static CharPtr GetOrganismDescription (
{
if (modifier_text[0] != 0)
StringCat (modifier_text, " ");
- StringNCat (modifier_text, ssp->name,
- sizeof (modifier_text) - StringLen (modifier_text) - 1);
+ label_len = StringLen (modifier_text);
+ if (no_semicolon_len > sizeof (modifier_text) - 1 - label_len)
+ {
+ no_semicolon_len = sizeof (modifier_text) - 1 - label_len;
+ }
+ StringNCat (modifier_text, ssp->name, no_semicolon_len);
+ modifier_text [ no_semicolon_len + label_len ] = 0;
}
ValNodeCopyStr( &strings, 0, modifier_text);
if (odmp->max_mods != -99)
odmp->max_mods --;
}
}
- vnp = vnp->next;
}
org_desc = MergeValNodeStrings (strings, FALSE);
ValNodeFreeData (strings);
@@ -2290,8 +2566,9 @@ static CharPtr GetInsertionSequenceDescription (
{
GBQualPtr gbqual;
- if (sfp == NULL) return NULL;
+ if (sfp == NULL || sfp->qual == NULL) return NULL;
+ gbqual = sfp->qual;
while (gbqual != NULL && StringCmp (gbqual->qual, "insertion_seq") != 0)
{
gbqual = gbqual->next;
@@ -2376,7 +2653,7 @@ static Boolean LIBCALLBACK IsControlRegion (
if (sfp == NULL
|| sfp->idx.subtype != FEATDEF_misc_feature
|| sfp->comment == NULL
- || StringCmp (sfp->comment, "control region") != 0)
+ || StringNCmp (sfp->comment, "control region", StringLen ("control region")) != 0)
{
return FALSE;
}
@@ -2730,6 +3007,33 @@ static CharPtr GetNoncodingProductFeatProduct (
return productname;
}
+static Boolean LIBCALLBACK IsMiscFeat (
+ SeqFeatPtr sfp
+)
+{
+ if ( sfp == NULL
+ || sfp->idx.subtype != FEATDEF_misc_feature
+ || sfp->comment == NULL)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static Boolean LIBCALLBACK IsOperon (
+ SeqFeatPtr sfp
+)
+{
+ if (sfp == NULL
+ || sfp->idx.subtype != FEATDEF_operon)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static Boolean IsRecognizedFeature (
SeqFeatPtr sfp
)
@@ -2756,7 +3060,9 @@ static Boolean IsRecognizedFeature (
|| IsIntergenicSpacer (sfp)
|| IsTransposon (sfp)
|| IsNoncodingProductFeat (sfp)
- || IsPromoter (sfp))
+ || IsPromoter (sfp)
+ || IsMiscFeat (sfp)
+ || IsOperon (sfp))
{
return TRUE;
}
@@ -3004,7 +3310,7 @@ static MatchRulePtr InitializeGroupingRules()
if (grouping_rules == NULL) return NULL;
grouping_rules[0].is_item = IsExon;
- grouping_rules[0].num_match_rules = 6;
+ grouping_rules[0].num_match_rules = 7;
grouping_rules[0].match_rules = MemNew (grouping_rules[0].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[0].match_rules == NULL) return NULL;
@@ -3014,9 +3320,10 @@ static MatchRulePtr InitializeGroupingRules()
grouping_rules[0].match_rules[3] = IsmRNA;
grouping_rules[0].match_rules[4] = IsGene;
grouping_rules[0].match_rules[5] = IsEndogenousVirusSourceFeature;
+ grouping_rules[0].match_rules[6] = IsOperon;
grouping_rules[1].is_item = IsIntron;
- grouping_rules[1].num_match_rules = 6;
+ grouping_rules[1].num_match_rules = 7;
grouping_rules[1].match_rules = MemNew (grouping_rules[1].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[1].match_rules == NULL) return NULL;
@@ -3026,9 +3333,10 @@ static MatchRulePtr InitializeGroupingRules()
grouping_rules[1].match_rules[3] = IsDloop;
grouping_rules[1].match_rules[4] = IsGene;
grouping_rules[1].match_rules[5] = IsEndogenousVirusSourceFeature;
+ grouping_rules[1].match_rules[6] = IsOperon;
grouping_rules[2].is_item = IsPromoter;
- grouping_rules[2].num_match_rules = 4;
+ grouping_rules[2].num_match_rules = 5;
grouping_rules[2].match_rules = MemNew (grouping_rules[2].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[2].match_rules == NULL) return NULL;
@@ -3036,9 +3344,10 @@ static MatchRulePtr InitializeGroupingRules()
grouping_rules[2].match_rules[1] = IsmRNA;
grouping_rules[2].match_rules[2] = IsGene;
grouping_rules[2].match_rules[3] = IsEndogenousVirusSourceFeature;
+ grouping_rules[2].match_rules[4] = IsOperon;
grouping_rules[3].is_item = IsCDS;
- grouping_rules[3].num_match_rules = 4;
+ grouping_rules[3].num_match_rules = 5;
grouping_rules[3].match_rules = MemNew (grouping_rules[3].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[3].match_rules == NULL) return NULL;
@@ -3046,18 +3355,20 @@ static MatchRulePtr InitializeGroupingRules()
grouping_rules[3].match_rules[1] = IsInsertionSequence;
grouping_rules[3].match_rules[2] = IsTransposon;
grouping_rules[3].match_rules[3] = IsEndogenousVirusSourceFeature;
+ grouping_rules[3].match_rules[4] = IsOperon;
grouping_rules[4].is_item = IsInsertionSequence;
- grouping_rules[4].num_match_rules = 3;
+ grouping_rules[4].num_match_rules = 4;
grouping_rules[4].match_rules = MemNew (grouping_rules[4].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[4].match_rules == NULL) return NULL;
grouping_rules[4].match_rules[0] = IsTransposon;
grouping_rules[4].match_rules[1] = IsInsertionSequence;
grouping_rules[4].match_rules[2] = IsEndogenousVirusSourceFeature;
+ grouping_rules[4].match_rules[3] = IsOperon;
grouping_rules[5].is_item = Is3UTR;
- grouping_rules[5].num_match_rules = 4;
+ grouping_rules[5].num_match_rules = 5;
grouping_rules[5].match_rules = MemNew (grouping_rules[5].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[5].match_rules == NULL) return NULL;
@@ -3065,9 +3376,10 @@ static MatchRulePtr InitializeGroupingRules()
grouping_rules[5].match_rules[1] = IsmRNA;
grouping_rules[5].match_rules[2] = IsGene;
grouping_rules[5].match_rules[3] = IsEndogenousVirusSourceFeature;
+ grouping_rules[5].match_rules[4] = IsOperon;
grouping_rules[6].is_item = Is5UTR;
- grouping_rules[6].num_match_rules = 4;
+ grouping_rules[6].num_match_rules = 5;
grouping_rules[6].match_rules = MemNew (grouping_rules[6].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[6].match_rules == NULL) return NULL;
@@ -3075,9 +3387,10 @@ static MatchRulePtr InitializeGroupingRules()
grouping_rules[6].match_rules[1] = IsmRNA;
grouping_rules[6].match_rules[2] = IsGene;
grouping_rules[6].match_rules[3] = IsEndogenousVirusSourceFeature;
+ grouping_rules[6].match_rules[4] = IsOperon;
grouping_rules[7].is_item = IsLTR;
- grouping_rules[7].num_match_rules = 4;
+ grouping_rules[7].num_match_rules = 5;
grouping_rules[7].match_rules = MemNew (grouping_rules[7].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[7].match_rules == NULL) return NULL;
@@ -3085,33 +3398,37 @@ static MatchRulePtr InitializeGroupingRules()
grouping_rules[7].match_rules[1] = IsmRNA;
grouping_rules[7].match_rules[2] = IsGene;
grouping_rules[7].match_rules[3] = IsEndogenousVirusSourceFeature;
+ grouping_rules[7].match_rules[4] = IsOperon;
grouping_rules[8].is_item = IsGene;
- grouping_rules[8].num_match_rules = 3;
+ grouping_rules[8].num_match_rules = 4;
grouping_rules[8].match_rules = MemNew (grouping_rules[8].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[8].match_rules == NULL) return NULL;
grouping_rules[8].match_rules[0] = IsTransposon;
grouping_rules[8].match_rules[1] = IsInsertionSequence;
grouping_rules[8].match_rules[2] = IsEndogenousVirusSourceFeature;
+ grouping_rules[8].match_rules[3] = IsOperon;
grouping_rules[9].is_item = IsTransposon;
- grouping_rules[9].num_match_rules = 3;
+ grouping_rules[9].num_match_rules = 4;
grouping_rules[9].match_rules = MemNew (grouping_rules[9].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[9].match_rules == NULL) return NULL;
grouping_rules[9].match_rules[0] = IsTransposon;
grouping_rules[9].match_rules[1] = IsInsertionSequence;
grouping_rules[9].match_rules[2] = IsEndogenousVirusSourceFeature;
+ grouping_rules[9].match_rules[3] = IsOperon;
grouping_rules[10].is_item = IsNoncodingProductFeat;
- grouping_rules[10].num_match_rules = 3;
+ grouping_rules[10].num_match_rules = 4;
grouping_rules[10].match_rules = MemNew (grouping_rules[10].num_match_rules
* sizeof (matchFunction));
if (grouping_rules[10].match_rules == NULL) return NULL;
grouping_rules[10].match_rules[0] = IsTransposon;
grouping_rules[10].match_rules[1] = IsInsertionSequence;
grouping_rules[10].match_rules[2] = IsEndogenousVirusSourceFeature;
+ grouping_rules[10].match_rules[3] = IsOperon;
return grouping_rules;
}
@@ -3748,6 +4065,10 @@ static CharPtr GetFeatureTypeWord (
{
return StringSave ("5' UTR");
}
+ else if (IsOperon (sfp))
+ {
+ return StringSave ("operon");
+ }
else if (biomol == MOLECULE_TYPE_GENOMIC)
{
if (IsPseudo (sfp))
@@ -3785,6 +4106,10 @@ static CharPtr GetFeatureTypeWord (
return StringSave ("precursor RNA");
}
}
+ else if (biomol == MOLECULE_TYPE_OTHER_GENETIC_MATERIAL)
+ {
+ return StringSave ("gene");
+ }
return StringSave ("");
}
@@ -3865,7 +4190,7 @@ static CharPtr GetProductName (
{
if ( IstRNA (cds) )
{
- protein_name = MemNew ( StringLen (context.label) + 5);
+ protein_name = MemNew ( StringLen (context.label) + 6);
if ( protein_name == NULL) return NULL;
sprintf (protein_name, "tRNA-%s", context.label);
return protein_name;
@@ -4038,6 +4363,7 @@ static void FindGeneProducts (
}
if (productfcp != NULL)
{
+ fcp->is_alt_spliced = productfcp->is_alt_spliced;
if (productfcp->feature_label_data.productname != NULL)
{
fcp->feature_label_data.productname =
@@ -4261,6 +4587,7 @@ static CharPtr GetGenericInterval (
LabelClauses (featlist, biomol, bsp);
ListClauses (featlist, &strings, FALSE, suppress_final_and);
subfeatlist = MergeValNodeStrings (strings, FALSE);
+ ValNodeFreeData (strings);
len += StringLen (subfeatlist) + 7;
}
@@ -5050,6 +5377,123 @@ static void ReplaceRNAClauses (
DeleteFeatureClauses (clause_list);
}
+/* If we are applying a different rule for misc_feats, we need to recalculate
+ * their descriptions.
+ */
+static void RenameMiscFeats (ValNodePtr clause_list, Uint1 biomol)
+{
+ ValNodePtr vnp, featlist;
+ FeatureClausePtr fcp, featlistclause;
+ SeqFeatPtr sfp;
+ Int4 name_len;
+
+ for (vnp = clause_list; vnp != NULL; vnp = vnp->next)
+ {
+ if (vnp->choice != DEFLINE_CLAUSEPLUS || vnp->data.ptrvalue == NULL)
+ {
+ continue;
+ }
+ fcp = vnp->data.ptrvalue;
+ for (featlist = fcp->featlist; featlist != NULL; featlist = featlist->next)
+ {
+ if ( featlist->data.ptrvalue == NULL)
+ {
+ continue;
+ }
+ if (featlist->choice == DEFLINE_CLAUSEPLUS)
+ {
+ featlistclause = featlist->data.ptrvalue;
+ RenameMiscFeats (featlistclause->featlist, biomol);
+ continue;
+ }
+ if (featlist->choice != DEFLINE_FEATLIST)
+ {
+ continue;
+ }
+ sfp = featlist->data.ptrvalue;
+ if (sfp->idx.subtype != FEATDEF_misc_feature
+ || sfp->comment == NULL
+ || IsIntergenicSpacer (sfp)
+ || IsControlRegion (sfp))
+ {
+ continue;
+ }
+ if (fcp->feature_label_data.description != NULL)
+ {
+ fcp->feature_label_data.description
+ = MemFree (fcp->feature_label_data.description);
+ }
+ name_len = StringCSpn (sfp->comment, ";");
+ fcp->feature_label_data.description = MemNew (name_len * sizeof (Char));
+ if (fcp->feature_label_data.description == NULL) return;
+ StringNCpy (fcp->feature_label_data.description, sfp->comment, name_len);
+ fcp->feature_label_data.description [ name_len ] = 0;
+ fcp->feature_label_data.typeword =
+ MemFree (fcp->feature_label_data.typeword);
+ if (biomol == MOLECULE_TYPE_GENOMIC)
+ {
+ fcp->feature_label_data.typeword = StringSave ("genomic sequence");
+ }
+ else if (biomol == MOLECULE_TYPE_MRNA)
+ {
+ fcp->feature_label_data.typeword = StringSave ("mRNA sequence");
+ }
+ else
+ {
+ fcp->feature_label_data.typeword = StringSave ("sequence");
+ }
+
+ fcp->interval = MemFree (fcp->interval);
+ fcp->interval = "";
+ }
+ }
+}
+
+static void RemoveUnwantedMiscFeats (
+ ValNodePtr PNTR clause_list,
+ Boolean delete_now
+)
+{
+ ValNodePtr vnp, featlist;
+ FeatureClausePtr fcp, featlistclause;
+ SeqFeatPtr sfp;
+
+ for (vnp = *clause_list; vnp != NULL; vnp = vnp->next)
+ {
+ if (vnp->choice != DEFLINE_CLAUSEPLUS || vnp->data.ptrvalue == NULL)
+ {
+ continue;
+ }
+ fcp = vnp->data.ptrvalue;
+ for (featlist = fcp->featlist; featlist != NULL; featlist = featlist->next)
+ {
+ if ( featlist->data.ptrvalue == NULL)
+ {
+ continue;
+ }
+ if (featlist->choice == DEFLINE_CLAUSEPLUS)
+ {
+ featlistclause = featlist->data.ptrvalue;
+ RemoveUnwantedMiscFeats (&(featlistclause->featlist), FALSE);
+ continue;
+ }
+ if (featlist->choice != DEFLINE_FEATLIST)
+ {
+ continue;
+ }
+ sfp = featlist->data.ptrvalue;
+ if ( sfp->idx.subtype == FEATDEF_misc_feature
+ && ! IsNoncodingProductFeat (sfp)
+ && ! IsControlRegion (sfp)
+ && ! IsIntergenicSpacer (sfp))
+ {
+ fcp->delete_me = TRUE;
+ }
+ }
+ }
+ DeleteFeatureClauses (clause_list);
+}
+
/* When a feature is on the minus strand, the clauses are listed by
* sequence indexing in reverse biological order - we reverse the subclauses
* for the feature in order to have them listed in the definition line
@@ -5460,15 +5904,21 @@ static void AutoDef_AddEnding (
StringCat (str, ".");
last_string = *strings;
- while (last_string->next != NULL) last_string = last_string->next;
- new_data_len = StringLen (last_string->data.ptrvalue) + StringLen (str) + 1;
- new_data = (CharPtr) MemNew (new_data_len);
- if (new_data == NULL) return;
- StringCpy (new_data, last_string->data.ptrvalue);
- StringCat (new_data, str);
- MemFree (last_string->data.ptrvalue);
- last_string->data.ptrvalue = new_data;
-
+ if (last_string == NULL)
+ {
+ ValNodeAddStr (strings, 0, StringSave ( str));
+ }
+ else
+ {
+ while (last_string->next != NULL) last_string = last_string->next;
+ new_data_len = StringLen (last_string->data.ptrvalue) + StringLen (str) + 1;
+ new_data = (CharPtr) MemNew (new_data_len);
+ if (new_data == NULL) return;
+ StringCpy (new_data, last_string->data.ptrvalue);
+ StringCat (new_data, str);
+ MemFree (last_string->data.ptrvalue);
+ last_string->data.ptrvalue = new_data;
+ }
}
static Boolean LastIntervalChangeBeforeEnd (
@@ -5812,7 +6262,7 @@ static void ListClauses (
}
}
- clause_len = StringLen (thisclause->feature_label_data.description);
+ clause_len = StringLen (thisclause->feature_label_data.description) + 1;
/* we need to place a comma between the description and the type word
* when the description ends with "precursor" and the type word
@@ -5864,7 +6314,8 @@ static void ListClauses (
if (print_and)
StringCat (clause_string, "and ");
if (thisclause->feature_label_data.is_typeword_first && print_typeword
- && thisclause->feature_label_data.typeword != NULL)
+ && thisclause->feature_label_data.typeword != NULL
+ && ! StringHasNoText (thisclause->feature_label_data.typeword))
{
StringCat (clause_string, thisclause->feature_label_data.typeword);
if (typeword_is_plural)
@@ -5881,7 +6332,8 @@ static void ListClauses (
}
}
if (! thisclause->feature_label_data.is_typeword_first && print_typeword
- && thisclause->feature_label_data.typeword != NULL)
+ && thisclause->feature_label_data.typeword != NULL
+ && ! StringHasNoText (thisclause->feature_label_data.typeword))
{
if (thisclause->feature_label_data.description != NULL)
StringCat (clause_string, " ");
@@ -5904,6 +6356,7 @@ static void ListClauses (
{
if (print_semicolon
&& (thisclause->interval == NULL
+ || StringHasNoText(thisclause->interval)
|| thisclause->interval[StringLen (thisclause->interval)] != ';'))
{
new_interval = MemNew (StringLen (thisclause->interval) + 2);
@@ -5920,7 +6373,8 @@ static void ListClauses (
MemFree (thisclause->interval);
thisclause->interval = new_interval;
}
- if (thisclause->interval != NULL)
+ if (thisclause->interval != NULL
+ && !StringHasNoText (thisclause->interval))
{
ValNodeAddStr (strings, 0, StringSave (thisclause->interval));
}
@@ -5932,22 +6386,16 @@ static void ListClauses (
}
}
-static Uint1 GetMoleculeType (
- BioseqPtr bsp
-)
+static Uint1 GetMoleculeType
+(BioseqPtr bsp,
+ Uint2 entityID)
{
SeqDescPtr sdp;
MolInfoPtr mip;
+ SeqMgrDescContext dcontext;
if (bsp == NULL) return MOLECULE_TYPE_GENOMIC;
- sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, NULL);
- if (sdp == NULL)
- {
- for (sdp = bsp->descr;
- sdp != NULL && sdp->choice != Seq_descr_molinfo;
- sdp = sdp->next)
- {}
- }
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
if (sdp == NULL) return MOLECULE_TYPE_GENOMIC;
mip = (MolInfoPtr) sdp->data.ptrvalue;
if (mip == NULL) return MOLECULE_TYPE_GENOMIC;
@@ -6201,6 +6649,7 @@ typedef struct deflinefeaturerequestlist {
Boolean suppress_alt_splice_phrase;
Boolean remove_subfeatures;
DefLineType feature_list_type;
+ Int4 misc_feat_parse_rule;
} DeflineFeatureRequestList, PNTR DeflineFeatureRequestListPtr;
static void InitFeatureRequests (
@@ -6216,6 +6665,7 @@ static void InitFeatureRequests (
feature_requests->suppress_alt_splice_phrase = FALSE;
feature_requests->remove_subfeatures = FALSE;
feature_requests->feature_list_type = DEFLINE_USE_FEATURES;
+ feature_requests->misc_feat_parse_rule = 2;
}
static Boolean RemoveCondition (
@@ -6443,6 +6893,48 @@ static void DeleteSubfeatures (
}
}
+static void DeleteOperonSubfeatures (
+ ValNodePtr PNTR feature_list,
+ Boolean delete_now
+)
+{
+ ValNodePtr clause, featlist;
+ FeatureClausePtr clause_fcp, fcp;
+
+ if (feature_list == NULL) return;
+ for (clause = *feature_list; clause != NULL; clause = clause->next)
+ {
+ if (clause->choice != DEFLINE_CLAUSEPLUS
+ || (clause_fcp = clause->data.ptrvalue) == NULL
+ || clause_fcp->featlist == NULL)
+ {
+ continue;
+ }
+ if (clause_fcp->featlist->choice == DEFLINE_FEATLIST
+ && IsOperon (clause_fcp->featlist->data.ptrvalue))
+ {
+ for (featlist = clause_fcp->featlist->next;
+ featlist != NULL;
+ featlist = featlist->next)
+ {
+ if (featlist->choice == DEFLINE_CLAUSEPLUS
+ && (fcp = featlist->data.ptrvalue) != NULL)
+ {
+ fcp->delete_me = TRUE;
+ }
+ }
+ }
+ else
+ {
+ DeleteSubfeatures ( &(clause_fcp->featlist), FALSE);
+ }
+ }
+ if (delete_now)
+ {
+ DeleteFeatureClauses (feature_list);
+ }
+}
+
static void RemoveFeats (
ValNodePtr list,
matchFunction itemmatch
@@ -6957,6 +7449,7 @@ FeatureClausePtr NewFeatureClause (
)
{
FeatureClausePtr fcp;
+ Boolean partial5, partial3;
fcp = (FeatureClausePtr) MemNew (sizeof (FeatureClauseData));
if (fcp == NULL) return NULL;
@@ -6975,8 +7468,10 @@ FeatureClausePtr NewFeatureClause (
fcp->is_unknown = FALSE;
fcp->grp = NULL;
if (sfp == NULL) return fcp;
+ CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
fcp->slp = SeqLocMerge (bsp, sfp->location, NULL,
FALSE, TRUE, FALSE);
+ SetSeqLocPartial (fcp->slp, partial5, partial3);
if (sfp->data.choice == SEQFEAT_GENE)
{
@@ -7051,121 +7546,6 @@ static void ExtractSegmentClauses (
ValNodePtr PNTR segment_clauses
);
-static void CraftDefinitionLineForSeqEntryAndFeatureList (
- BioseqPtr bsp,
- Uint1 molecule_type,
- SeqEntryPtr sep,
- ValNodePtr PNTR feature_list,
- Boolean isSegment,
- ValNodePtr PNTR seg_feature_list,
- Int2 product_flag,
- ModifierCombinationPtr m,
- ModifierItemLocalPtr modList,
- OrganismDescriptionModifiersPtr odmp,
- DeflineFeatureRequestList PNTR feature_requests
-)
-{
- ValNodePtr strings, clause;
- CharPtr str, tmp_str;
- ValNodePtr tmp_feat_list;
-
- strings = NULL;
- str = GetOrganismDescription (bsp, modList, m, odmp);
- if (str == NULL) return;
- str[0] = toupper (str [0]);
-
- if (feature_requests->feature_list_type == DEFLINE_USE_FEATURES
- && ( ! isSegment || (seg_feature_list != NULL && *seg_feature_list != NULL)))
- {
- ValNodeAddStr (&strings, 0, str);
-
- GroupmRNAs (feature_list, bsp);
-
- /* genes are added to other clauses */
- GroupGenes (feature_list);
-
- if (! feature_requests->suppress_alt_splice_phrase)
- {
- /* find alt-spliced CDSs */
- FindAltSplices (*feature_list, bsp);
- }
-
- GroupAltSplicedExons (feature_list, bsp, TRUE);
-
- /* now group clauses */
- GroupAllClauses ( feature_list, bsp );
-
- ExpandAltSplicedExons (*feature_list, bsp);
-
- FindGeneProducts (*feature_list, bsp);
-
- if (seg_feature_list != NULL && *seg_feature_list != NULL)
- {
- tmp_feat_list = NULL;
- ExtractSegmentClauses ( *seg_feature_list, *feature_list, &tmp_feat_list);
- FreeListElement (*feature_list);
- *feature_list = tmp_feat_list;
- }
-
- /* remove exons and other unwanted features */
- RemoveUnwantedFeatures (feature_list, bsp, isSegment, feature_requests);
-
- RemoveGenesMentionedElsewhere (feature_list, *feature_list, TRUE);
-
- if (feature_requests->remove_subfeatures)
- {
- DeleteSubfeatures (feature_list, TRUE);
- }
-
- CountUnknownGenes (feature_list, bsp);
-
- ReplaceRNAClauses (feature_list, bsp);
-
- /* take any exons on the minus strand */
- /* and reverse their order within the clause */
- ReverseClauses (feature_list, IsExon);
-
- RenameExonSequences ( feature_list, bsp, TRUE);
-
- LabelClauses (*feature_list, molecule_type, bsp);
-
- ConsolidateClauses (feature_list, bsp, molecule_type, TRUE);
-
- /* this allows genes to be listed together even if they are from */
- /* separate sequences */
-/* SmashTallClauses (feature_list, TRUE); */
-
- clause = *feature_list;
- ListClauses (clause, &strings, TRUE, FALSE);
-
- AutoDef_AddEnding (clause, &strings, bsp,
- product_flag);
-
- str = MergeValNodeStrings (strings, FALSE);
- ValNodeFreeData (strings);
- }
- else if ( feature_requests->feature_list_type == DEFLINE_COMPLETE_SEQUENCE)
- {
- tmp_str = MemNew (StringLen (str) + 30);
- if (tmp_str == NULL) return;
- StringCpy (tmp_str, str);
- StringCat (tmp_str, ", complete sequence.");
- MemFree (str);
- str = tmp_str;
- }
- else if ( feature_requests->feature_list_type == DEFLINE_COMPLETE_GENOME)
- {
- tmp_str = MemNew (StringLen (str) + 30);
- if (tmp_str == NULL) return;
- StringCpy (tmp_str, str);
- StringCat (tmp_str, ", complete genome.");
- MemFree (str);
- str = tmp_str;
- }
-
- ReplaceDefinitionLine (sep, str);
-}
-
static Boolean FeatureIsOnSegment (
SeqFeatPtr sfp,
ValNodePtr segment_features
@@ -7224,6 +7604,7 @@ static FeatureClausePtr CopyMatchingClauses (
FeatureClausePtr new_fcp, copy_clause;
ValNodePtr featlist, new_feat;
Boolean found_feat_on_segment;
+ Boolean partial5, partial3;
new_fcp = (FeatureClausePtr) MemNew (sizeof (FeatureClauseData));
if (new_fcp == NULL) return NULL;
@@ -7240,8 +7621,10 @@ static FeatureClausePtr CopyMatchingClauses (
new_fcp->allelename = StringSave (fcp->allelename);
new_fcp->interval = StringSave (fcp->interval);
new_fcp->is_alt_spliced = fcp->is_alt_spliced;
+ CheckSeqLocForPartial (fcp->slp, &partial5, &partial3);
new_fcp->slp = SeqLocMerge (BioseqFindFromSeqLoc (fcp->slp), fcp->slp, NULL,
FALSE, TRUE, FALSE);
+ SetSeqLocPartial (new_fcp->slp, partial5, partial3);
new_fcp->grp = fcp->grp;
new_fcp->delete_me = FALSE;
new_fcp->clause_info_only = fcp->clause_info_only;
@@ -7351,12 +7734,54 @@ typedef struct segmentdeflinedata {
Int2 product_flag;
} SegmentDefLineData, PNTR SegmentDefLinePtr;
-static Boolean LIBCALLBACK GetFeatsOnSeg (
+typedef struct segmentdeflinefeatureclausedata {
+ BioseqPtr parent_bsp;
+ ValNodePtr parent_feature_list;
+ Uint1 molecule_type;
+ DeflineFeatureRequestList PNTR feature_requests;
+ Int2 product_flag;
+ ValNodePtr PNTR list;
+} SegmentDefLineFeatureClauseData, PNTR SegmentDefLineFeatureClausePtr;
+
+typedef struct deflinefeatclause {
+ SeqEntryPtr sep;
+ BioseqPtr bsp;
+ CharPtr clauselist;
+} DefLineFeatClauseData, PNTR DefLineFeatClausePtr;
+
+static void DefLineFeatClauseListFree (ValNodePtr vnp)
+{
+ DefLineFeatClausePtr deflist;
+
+ if (vnp == NULL) return;
+ DefLineFeatClauseListFree (vnp->next);
+ vnp->next = NULL;
+ deflist = vnp->data.ptrvalue;
+ if (deflist != NULL)
+ {
+ MemFree (deflist->clauselist);
+ MemFree (deflist);
+ }
+ ValNodeFree (vnp);
+}
+
+static CharPtr BuildFeatureClauses (
+ BioseqPtr bsp,
+ Uint1 molecule_type,
+ SeqEntryPtr sep,
+ ValNodePtr PNTR feature_list,
+ Boolean isSegment,
+ ValNodePtr PNTR seg_feature_list,
+ Int2 product_flag,
+ DeflineFeatureRequestList PNTR feature_requests
+);
+
+static Boolean LIBCALLBACK GetFeatureClauseForSeg (
SeqLocPtr slp,
SeqMgrSegmentContextPtr context
)
{
- SegmentDefLinePtr sdlp;
+ SegmentDefLineFeatureClausePtr sdlp;
ValNodePtr clause, tmp_parent_list;
FeatureClausePtr fcp, new_fcp;
Int2 idx;
@@ -7366,9 +7791,10 @@ static Boolean LIBCALLBACK GetFeatsOnSeg (
BioseqPtr bsp;
Uint2 entityID;
SeqLocPtr loc;
+ DefLineFeatClausePtr deflist;
if (slp == NULL || context == NULL) return FALSE;
- sdlp = (SegmentDefLinePtr) context->userdata;
+ sdlp = (SegmentDefLineFeatureClausePtr) context->userdata;
sip = SeqLocId (slp);
@@ -7418,31 +7844,144 @@ static Boolean LIBCALLBACK GetFeatsOnSeg (
tmp_parent_list = NULL;
CopyFeatureList (NULL, sdlp->parent_feature_list, &tmp_parent_list);
- CraftDefinitionLineForSeqEntryAndFeatureList (
- sdlp->parent_bsp,
+ deflist = (DefLineFeatClausePtr) MemNew (sizeof (DefLineFeatClauseData));
+ if (deflist == NULL) return TRUE;
+ deflist->sep = SeqMgrGetSeqEntryForData (bsp);
+ deflist->bsp = bsp;
+ deflist->clauselist = BuildFeatureClauses (sdlp->parent_bsp,
sdlp->molecule_type,
SeqMgrGetSeqEntryForData (bsp),
&tmp_parent_list,
TRUE,
&segment_feature_list,
sdlp->product_flag,
- sdlp->m, sdlp->modList, sdlp->odmp,
sdlp->feature_requests);
+ vnp = ValNodeNew (*(sdlp->list));
+ if (vnp == NULL) return TRUE;
+ if (*(sdlp->list) == NULL) *(sdlp->list) = vnp;
+ vnp->data.ptrvalue = deflist;
FreeListElement (tmp_parent_list);
FreeListElement (segment_feature_list);
return TRUE;
}
-
-static void BuildDefinitionLine (
+static CharPtr BuildFeatureClauses (
+ BioseqPtr bsp,
+ Uint1 molecule_type,
+ SeqEntryPtr sep,
+ ValNodePtr PNTR feature_list,
+ Boolean isSegment,
+ ValNodePtr PNTR seg_feature_list,
+ Int2 product_flag,
+ DeflineFeatureRequestList PNTR feature_requests
+)
+{
+ ValNodePtr strings = NULL;
+ ValNodePtr clause;
+ CharPtr str = NULL;
+ ValNodePtr tmp_feat_list;
+
+ if (feature_requests->feature_list_type == DEFLINE_USE_FEATURES
+ && ( ! isSegment || (seg_feature_list != NULL && *seg_feature_list != NULL)))
+ {
+ GroupmRNAs (feature_list, bsp);
+
+ /* genes are added to other clauses */
+ GroupGenes (feature_list);
+
+ if (! feature_requests->suppress_alt_splice_phrase)
+ {
+ /* find alt-spliced CDSs */
+ FindAltSplices (*feature_list, bsp);
+ }
+
+ GroupAltSplicedExons (feature_list, bsp, TRUE);
+
+ /* now group clauses */
+ GroupAllClauses ( feature_list, bsp );
+
+ ExpandAltSplicedExons (*feature_list, bsp);
+
+ FindGeneProducts (*feature_list, bsp);
+
+ if (seg_feature_list != NULL && *seg_feature_list != NULL)
+ {
+ tmp_feat_list = NULL;
+ ExtractSegmentClauses ( *seg_feature_list, *feature_list, &tmp_feat_list);
+ FreeListElement (*feature_list);
+ *feature_list = tmp_feat_list;
+ }
+
+ /* remove exons and other unwanted features */
+ RemoveUnwantedFeatures (feature_list, bsp, isSegment, feature_requests);
+
+ RemoveGenesMentionedElsewhere (feature_list, *feature_list, TRUE);
+
+ if (feature_requests->remove_subfeatures)
+ {
+ DeleteSubfeatures (feature_list, TRUE);
+ }
+
+ DeleteOperonSubfeatures (feature_list, TRUE);
+
+ CountUnknownGenes (feature_list, bsp);
+
+ if (feature_requests->misc_feat_parse_rule == 1)
+ {
+ RenameMiscFeats (*feature_list, molecule_type);
+ }
+ else
+ {
+ RemoveUnwantedMiscFeats (feature_list, TRUE);
+ }
+
+ ReplaceRNAClauses (feature_list, bsp);
+
+ /* take any exons on the minus strand */
+ /* and reverse their order within the clause */
+ ReverseClauses (feature_list, IsExon);
+
+ RenameExonSequences ( feature_list, bsp, TRUE);
+
+ LabelClauses (*feature_list, molecule_type, bsp);
+
+ ConsolidateClauses (feature_list, bsp, molecule_type, TRUE);
+
+ /* this allows genes to be listed together even if they are from */
+ /* separate sequences */
+/* SmashTallClauses (feature_list, TRUE); */
+
+ clause = *feature_list;
+ ListClauses (clause, &strings, TRUE, FALSE);
+
+ AutoDef_AddEnding (clause, &strings, bsp,
+ product_flag);
+
+ str = MergeValNodeStrings (strings, FALSE);
+ ValNodeFreeData (strings);
+ }
+ else if ( feature_requests->feature_list_type == DEFLINE_COMPLETE_SEQUENCE)
+ {
+ str = StringSave (", complete sequence.");
+ }
+ else if ( feature_requests->feature_list_type == DEFLINE_COMPLETE_GENOME)
+ {
+ str = StringSave (", complete genome.");
+ }
+ else
+ {
+ str = StringSave ("");
+ }
+ return str;
+}
+
+static void BuildDefLineFeatClauseList (
SeqEntryPtr sep,
Uint2 entityID,
DeflineFeatureRequestList PNTR feature_requests,
- ModifierCombinationPtr m,
- ModifierItemLocalPtr modList,
- OrganismDescriptionModifiersPtr odmp,
- Int2 product_flag
+ Int2 product_flag,
+ ValNodePtr PNTR list
)
{
BioseqSetPtr bssp;
@@ -7450,9 +7989,12 @@ static void BuildDefinitionLine (
ValNodePtr head;
Uint1 molecule_type;
SeqEntryPtr nsep;
- SegmentDefLineData sdld;
+ SegmentDefLineFeatureClauseData sdld;
+ DefLineFeatClausePtr deflist;
+ ValNodePtr vnp;
+
+ if (sep == NULL || list == NULL) return;
- if (sep == NULL) return;
if ( IS_Bioseq_set (sep))
{
bssp = (BioseqSetPtr) sep->data.ptrvalue;
@@ -7461,8 +8003,8 @@ static void BuildDefinitionLine (
{
for (sep = bssp->seq_set; sep != NULL; sep = sep->next)
{
- BuildDefinitionLine (sep, entityID, feature_requests, m, modList,
- odmp, product_flag);
+ BuildDefLineFeatClauseList (sep, entityID, feature_requests,
+ product_flag, list);
}
return;
}
@@ -7477,24 +8019,29 @@ static void BuildDefinitionLine (
bsp->seq_ext != NULL && bsp->seq_ext_type == 1)
{
sdld.parent_bsp = bsp;
- sdld.molecule_type = GetMoleculeType (bsp);
+ sdld.molecule_type = GetMoleculeType (bsp, entityID);
sdld.parent_feature_list = GetFeatureList (bsp);
sdld.feature_requests = feature_requests;
- sdld.m = m;
- sdld.modList = modList;
- sdld.odmp = odmp;
sdld.product_flag = product_flag;
- SeqMgrExploreSegments (bsp, (Pointer) &sdld, GetFeatsOnSeg);
- CraftDefinitionLineForSeqEntryAndFeatureList (
- bsp,
+ sdld.list = list;
+ SeqMgrExploreSegments (bsp, (Pointer) &sdld, GetFeatureClauseForSeg);
+ deflist = (DefLineFeatClausePtr) MemNew (sizeof (DefLineFeatClauseData));
+ if (deflist == NULL) return;
+ deflist->sep = SeqMgrGetSeqEntryForData (bsp),
+ deflist->bsp = bsp;
+ deflist->clauselist = BuildFeatureClauses (bsp,
sdld.molecule_type,
SeqMgrGetSeqEntryForData (bsp),
&sdld.parent_feature_list,
FALSE,
NULL,
product_flag,
- m, modList, odmp, feature_requests);
+ feature_requests);
+ vnp = ValNodeNew (*list);
+ if (vnp == NULL) return;
+ if (*list == NULL) *list = vnp;
+ vnp->data.ptrvalue = deflist;
FreeListElement (sdld.parent_feature_list);
return;
}
@@ -7507,22 +8054,59 @@ static void BuildDefinitionLine (
bsp = (BioseqPtr) sep->data.ptrvalue;
if (bsp == NULL) return;
if ( SpecialHandlingForSpecialTechniques (bsp)) return;
- molecule_type = GetMoleculeType (bsp);
+ molecule_type = GetMoleculeType (bsp, entityID);
head = GetFeatureList (bsp);
- CraftDefinitionLineForSeqEntryAndFeatureList (
- bsp,
- molecule_type,
- SeqMgrGetSeqEntryForData (bsp),
- &head,
- FALSE,
- NULL,
- product_flag,
- m, modList, odmp, feature_requests);
+ deflist = (DefLineFeatClausePtr) MemNew (sizeof (DefLineFeatClauseData));
+ if (deflist == NULL) return;
+ deflist->sep = SeqMgrGetSeqEntryForData (bsp),
+ deflist->bsp = bsp;
+ deflist->clauselist = BuildFeatureClauses (bsp,
+ molecule_type,
+ SeqMgrGetSeqEntryForData (bsp),
+ &head,
+ FALSE,
+ NULL,
+ product_flag,
+ feature_requests);
+ vnp = ValNodeNew (*list);
+ if (vnp == NULL) return;
+ if (*list == NULL) *list = vnp;
+ vnp->data.ptrvalue = deflist;
FreeListElement (head);
}
+static Boolean AreFeatureClausesUnique (ValNodePtr list)
+{
+ ValNodePtr vnp1, vnp2;
+ DefLineFeatClausePtr deflist1, deflist2;
+
+ for (vnp1 = list; vnp1 != NULL && vnp1->next != NULL; vnp1 = vnp1->next)
+ {
+ deflist1 = vnp1->data.ptrvalue;
+ if (deflist1 == NULL || deflist1->clauselist == NULL) return FALSE;
+
+ for (vnp2 = vnp1->next; vnp2 != NULL; vnp2 = vnp2->next)
+ {
+ deflist2 = vnp2->data.ptrvalue;
+ if (deflist2 == NULL || deflist2->clauselist == NULL
+ || StringCmp (deflist1->clauselist, deflist2->clauselist) == 0)
+ {
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}
+
+static void BuildDefinitionLinesFromFeatureClauseLists (
+ ValNodePtr list,
+ ModifierItemLocalPtr modList,
+ ModifierCombinationPtr m,
+ OrganismDescriptionModifiers odmp
+);
+
typedef struct deflineformdata {
FEATURE_FORM_BLOCK
@@ -7542,6 +8126,7 @@ typedef struct deflineformdata {
ButtoN remove_subfeatures;
PopuP featurePopup;
GrouP featureOptsGrp;
+ PopuP misc_feat_parse_rule;
} DefLineFormData, PNTR DefLineFormPtr;
static void DefLineFormMessageProc (ForM f, Int2 mssg)
@@ -7619,6 +8204,7 @@ static void DoAutoDefLine (ButtoN b)
OrganismDescriptionModifiers odmp;
Int2 product_flag, feature_list_type;
Int4 i;
+ ValNodePtr defline_clauses = NULL;
dlfp = GetObjectExtra (b);
if (b == NULL) return;
@@ -7629,6 +8215,7 @@ static void DoAutoDefLine (ButtoN b)
odmp.use_labels = GetStatus (dlfp->use_labels);
odmp.keep_paren = GetStatus (dlfp->keep_paren);
odmp.exclude_sp = GetStatus (dlfp->exclude_sp);
+ odmp.use_modifiers = TRUE;
if (dlfp->clone_isolate_HIV_rule_num == NULL)
{
@@ -7694,6 +8281,9 @@ static void DoAutoDefLine (ButtoN b)
dlfp->feature_requests.remove_subfeatures =
GetStatus (dlfp->remove_subfeatures);
+ dlfp->feature_requests.misc_feat_parse_rule =
+ GetValue (dlfp->misc_feat_parse_rule);
+
odmp.max_mods = GetValue (dlfp->modLimit);
if (odmp.max_mods > 1)
{
@@ -7718,8 +8308,14 @@ static void DoAutoDefLine (ButtoN b)
SeqEntrySetScope (sep);
- BuildDefinitionLine (sep, dlfp->input_entityID, &dlfp->feature_requests,
- m, dlfp->modList, &odmp, product_flag);
+ BuildDefLineFeatClauseList (sep, dlfp->input_entityID,
+ &dlfp->feature_requests,
+ product_flag,
+ &defline_clauses);
+
+ BuildDefinitionLinesFromFeatureClauseLists (defline_clauses, dlfp->modList,
+ m, odmp);
+ DefLineFeatClauseListFree (defline_clauses);
ClearProteinTitlesInNucProts (dlfp->input_entityID, NULL);
InstantiateProteinTitles (dlfp->input_entityID, NULL);
ArrowCursor ();
@@ -8000,13 +8596,32 @@ static GrouP CreateDefLineFormFeatureListPopuP (
return q;
}
+
+static void SetMiscFeatRuleEnable (Handle a)
+{
+ DefLineFormPtr dlfp;
+
+ if (a == NULL || ( dlfp = (DefLineFormPtr) GetObjectExtra (a)) == NULL)
+ {
+ return;
+ }
+ if (dlfp->feature_requests.items != NULL
+ && GetStatus (dlfp->feature_requests.items[RemovableNoncodingProductFeat].keep_request))
+ {
+ Enable (dlfp->misc_feat_parse_rule);
+ }
+ else
+ {
+ Disable (dlfp->misc_feat_parse_rule);
+ }
+}
static GrouP CreateDefLineFormFeatureOptionsGroup (
GrouP h,
DefLineFormPtr dlfp
)
{
- GrouP p, q, g;
+ GrouP p, q, g, r;
Int4 i;
p = HiddenGroup (h, -1, 0, NULL);
@@ -8032,10 +8647,19 @@ static GrouP CreateDefLineFormFeatureOptionsGroup (
if (i != RemovableCDS)
{
dlfp->feature_requests.items[i].keep_request =
- CheckBox (g, remove_items[i].group_name, NULL);
+ CheckBox (g, remove_items[i].group_name,
+ (BtnActnProc) SetMiscFeatRuleEnable);
+ SetObjectExtra (dlfp->feature_requests.items[i].keep_request, dlfp, NULL);
SetStatus (dlfp->feature_requests.items[i].keep_request, FALSE);
}
}
+ r = HiddenGroup (p, 2, 0, NULL);
+ StaticPrompt (r, "Misc Feat Parse Rule", 0, dialogTextHeight, programFont, 'l');
+ dlfp->misc_feat_parse_rule = PopupList (r, TRUE, NULL);
+ PopupItem (dlfp->misc_feat_parse_rule, "Product is comment before first semicolon");
+ PopupItem (dlfp->misc_feat_parse_rule, "Look for Noncoding Product Features");
+ SetValue (dlfp->misc_feat_parse_rule, 2);
+ Disable (dlfp->misc_feat_parse_rule);
AlignObjects (ALIGN_CENTER, (HANDLE) q,
(HANDLE) dlfp->featureOptsGrp, NULL);
@@ -8043,6 +8667,7 @@ static GrouP CreateDefLineFormFeatureOptionsGroup (
(HANDLE) dlfp->suppress_alt_splice_phrase,
(HANDLE) dlfp->remove_subfeatures,
(HANDLE) g,
+ (HANDLE) r,
NULL);
return p;
@@ -8118,7 +8743,7 @@ static void CreateDefLineForm (
}
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoAutoDefLine);
+ b = DefaultButton (c, "Accept", DoAutoDefLine);
SetObjectExtra (b, dlfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -8148,15 +8773,57 @@ static void CreateDefLineForm (
Update ();
}
-extern void AutoDefBaseFormCommon (BaseFormPtr bfp, Boolean use_form)
+static void BuildDefinitionLinesFromFeatureClauseLists (
+ ValNodePtr list,
+ ModifierItemLocalPtr modList,
+ ModifierCombinationPtr m,
+ OrganismDescriptionModifiers odmp
+)
{
- SeqEntryPtr sep;
+ ValNodePtr vnp;
+ DefLineFeatClausePtr defline_featclause;
+ CharPtr org_desc, tmp_str;
+
+ for (vnp = list; vnp != NULL; vnp = vnp->next)
+ {
+ if (vnp->data.ptrvalue != NULL)
+ {
+ defline_featclause = vnp->data.ptrvalue;
+ org_desc = GetOrganismDescription (defline_featclause->bsp,
+ modList, m, &odmp);
+ tmp_str = (CharPtr) MemNew ( StringLen (org_desc) + StringLen (defline_featclause->clauselist) + 2);
+ if (tmp_str == NULL) return;
+ StringCpy (tmp_str, org_desc);
+ if (defline_featclause->clauselist != NULL
+ && defline_featclause->clauselist [0] != ','
+ && defline_featclause->clauselist [0] != '.'
+ && defline_featclause->clauselist [0] != 0)
+ {
+ StringCat (tmp_str, " ");
+ }
+ StringCat (tmp_str, defline_featclause->clauselist);
+ tmp_str [0] = toupper (tmp_str [0]);
+ ReplaceDefinitionLine (defline_featclause->sep, tmp_str);
+ MemFree (org_desc);
+ }
+ }
+}
+
+extern void AutoDefBaseFormCommon (
+ BaseFormPtr bfp,
+ Boolean use_form,
+ Boolean use_modifiers
+)
+{
+ SeqEntryPtr sep;
DeflineFeatureRequestList feature_requests;
ModifierItemLocalPtr modList;
ModifierCombinationPtr m;
OrganismDescriptionModifiers odmp;
Int4 index;
+ ValNodePtr defline_clauses = NULL;
+ if (bfp == NULL) return;
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
if (sep == NULL) return;
@@ -8166,9 +8833,9 @@ extern void AutoDefBaseFormCommon (BaseFormPtr bfp, Boolean use_form)
if (modList == NULL) return;
SetRequiredModifiers (modList);
CountModifiers (modList, sep);
- m = FindBestCombo (sep, modList);
if (use_form)
{
+ m = FindBestCombo (sep, modList);
AddBestComboModifiersToModList ( m, modList);
CreateDefLineForm (bfp, modList, &feature_requests);
}
@@ -8182,9 +8849,22 @@ extern void AutoDefBaseFormCommon (BaseFormPtr bfp, Boolean use_form)
odmp.keep_paren = TRUE;
odmp.exclude_sp = TRUE;
odmp.clone_isolate_HIV_rule_num = clone_isolate_HIV_rule_want_both;
+ odmp.use_modifiers = use_modifiers;
ClearProteinTitlesInNucProts (bfp->input_entityID, NULL);
- BuildDefinitionLine (sep, bfp->input_entityID, &feature_requests, m,
- modList, &odmp, 0);
+ BuildDefLineFeatClauseList (sep, bfp->input_entityID, &feature_requests,
+ 0, &defline_clauses);
+ if ( AreFeatureClausesUnique (defline_clauses))
+ {
+ m = CreateComboFromModList (modList);
+ }
+ else
+ {
+ m = FindBestCombo (sep, modList);
+ }
+
+ BuildDefinitionLinesFromFeatureClauseLists (defline_clauses, modList,
+ m, odmp);
+ DefLineFeatClauseListFree (defline_clauses);
if (modList != NULL)
{
for (index=0; index < NumDefLineModifiers; index++)
@@ -8202,7 +8882,7 @@ extern void AutoDefBaseFormCommon (BaseFormPtr bfp, Boolean use_form)
FreeModifierCombo (m);
}
-static void AutoDefCommon (IteM i, Boolean use_form)
+static void AutoDefCommon (IteM i, Boolean use_form, Boolean use_modifiers)
{
BaseFormPtr bfp;
@@ -8212,34 +8892,57 @@ static void AutoDefCommon (IteM i, Boolean use_form)
bfp = GetObjectExtra (i);
#endif
if (bfp == NULL || bfp->input_entityID == 0) return;
- AutoDefBaseFormCommon (bfp, use_form);
+ AutoDefBaseFormCommon (bfp, use_form, use_modifiers);
}
extern void testAutoDef (IteM i)
{
- AutoDefCommon (i, FALSE);
+ AutoDefCommon (i, FALSE, TRUE);
}
extern void testAutoDefWithOptions (IteM i)
{
- AutoDefCommon (i, TRUE);
+ AutoDefCommon (i, TRUE, TRUE);
+}
+
+extern void AutoDefWithoutModifiers (IteM i)
+{
+ AutoDefCommon (i, FALSE, FALSE);
+}
+
+extern void AutoDefToolBtn (ButtoN b)
+{
+ BaseFormPtr bfp;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+ AutoDefBaseFormCommon (bfp, FALSE, TRUE);
+}
+
+extern void AutoDefOptionsToolBtn (ButtoN b)
+{
+ BaseFormPtr bfp;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+ AutoDefBaseFormCommon (bfp, TRUE, TRUE);
}
-typedef struct orgmodlinedata {
+typedef struct tablelinedata {
Int4 num_parts;
ValNodePtr parts;
-} OrgModLineData, PNTR OrgModLinePtr;
+} TableLineData, PNTR TableLinePtr;
-static OrgModLinePtr MakeOrgModData (CharPtr line)
+static TableLinePtr MakeTableData (CharPtr line)
{
- OrgModLinePtr omlp;
+ TableLinePtr tlp;
CharPtr p_start, p_end;
Int4 plen;
Boolean found_end;
if (line == NULL) return NULL;
- omlp = MemNew (sizeof (OrgModLineData));
- if (omlp == NULL) return NULL;
+ tlp = MemNew (sizeof (TableLineData));
+ if (tlp == NULL) return NULL;
p_start = line;
found_end = FALSE;
while (*p_start != 0 && !found_end)
@@ -8247,6 +8950,11 @@ static OrgModLinePtr MakeOrgModData (CharPtr line)
plen = StringCSpn (p_start, "\t\n");
if (plen == 0)
{
+ if (tlp->num_parts > 0)
+ {
+ ValNodeAddStr (&tlp->parts, 0, StringSave (""));
+ tlp->num_parts ++;
+ }
p_start++;
continue;
}
@@ -8260,55 +8968,36 @@ static OrgModLinePtr MakeOrgModData (CharPtr line)
*p_end = 0;
}
TrimSpacesAroundString (p_start);
- ValNodeAddStr (&omlp->parts, 0, StringSave (p_start));
- omlp->num_parts ++;
+ ValNodeAddStr (&tlp->parts, 0, StringSave (p_start));
+ tlp->num_parts ++;
if (!found_end)
{
p_start = p_end + 1;
}
}
- if (omlp->num_parts == 0)
+ if (tlp->num_parts == 0)
{
- MemFree (omlp);
+ MemFree (tlp);
return NULL;
}
- return omlp;
+ return tlp;
}
-static void CleanUpOrgModData (ValNodePtr vnp)
+static void CleanUpTableData (ValNodePtr vnp)
{
- OrgModLinePtr omlp;
+ TableLinePtr tlp;
if (vnp == NULL) return;
- CleanUpOrgModData (vnp->next);
+ CleanUpTableData (vnp->next);
vnp->next = NULL;
- omlp = vnp->data.ptrvalue;
- if (omlp != NULL)
+ tlp = vnp->data.ptrvalue;
+ if (tlp != NULL)
{
- ValNodeFreeData (omlp->parts);
+ ValNodeFreeData (tlp->parts);
}
ValNodeFree (vnp);
}
-static void CombineOrganismModLines (OrgModLinePtr omlp1, OrgModLinePtr omlp2)
-{
- ValNodePtr vnp;
-
- if (omlp1->parts == NULL)
- {
- omlp1->parts = omlp2->parts;
- omlp1->num_parts = omlp2->num_parts;
- MemFree (omlp2);
- return;
- }
- for (vnp = omlp1->parts; vnp->next != NULL; vnp = vnp->next)
- {}
- vnp->next = omlp2->parts;
- omlp1->num_parts = omlp1->num_parts + omlp2->num_parts;
- MemFree (omlp2);
- return;
-}
-
typedef struct orgmodlineformdata {
Int4 column_number;
CharPtr value_string;
@@ -8326,6 +9015,7 @@ typedef struct orgmodloadformdata {
Int4 num_line_forms;
Uint2 entityID;
ButtoN accept_button;
+
} OrgModLoadFormData, PNTR OrgModLoadFormPtr;
static void SetFormModsAcceptButton (Handle a)
@@ -8359,7 +9049,7 @@ static void SetFormModsAcceptButton (Handle a)
}
else if (GetValue (form_data->line_forms [column_index].action_choice) == 1
&& GetValue (form_data->line_forms [column_index].match_choice) > 0
- && GetValue (form_data->line_forms [column_index].match_choice) < 4)
+ && GetValue (form_data->line_forms [column_index].match_choice) < 5)
{
have_action = TRUE;
}
@@ -8414,8 +9104,9 @@ static void BuildOrgModLineForm (
PopupItem (omlfp->match_choice, "Accession");
PopupItem (omlfp->match_choice, "Local ID");
PopupItem (omlfp->match_choice, "Organism Taxonomy Name");
+ PopupItem (omlfp->match_choice, "TMSMART ID");
PopupItem (omlfp->match_choice, "None");
- SetValue (omlfp->match_choice, 4);
+ SetValue (omlfp->match_choice, 5);
/* list of organism modifiers */
omlfp->apply_choice = SingleList (g, 5, 8,
@@ -8439,7 +9130,7 @@ static void CleanupOrgModLoadForm (
form_data = (OrgModLoadFormPtr)data;
if (form_data == NULL) return;
MemFree (form_data->line_forms);
- CleanUpOrgModData (form_data->line_list);
+ CleanUpTableData (form_data->line_list);
StdCleanupFormProc (g, data);
}
@@ -8554,7 +9245,7 @@ static void ApplyTableModsByTaxName (BioSourcePtr biop, Pointer userdata)
OrgModLoadFormPtr form_data;
Int4 column_index, part_index;
ValNodePtr line, part;
- OrgModLinePtr omlp;
+ TableLinePtr tlp;
Boolean found_org;
form_data = (OrgModLoadFormPtr) userdata;
@@ -8572,9 +9263,9 @@ static void ApplyTableModsByTaxName (BioSourcePtr biop, Pointer userdata)
{
for (line = form_data->line_list; line != NULL; line = line->next)
{
- omlp = line->data.ptrvalue;
- if (omlp == NULL) continue;
- part = omlp->parts;
+ tlp = line->data.ptrvalue;
+ if (tlp == NULL) continue;
+ part = tlp->parts;
for (part_index = 0;
part_index < column_index && part != NULL;
part_index ++)
@@ -8584,7 +9275,7 @@ static void ApplyTableModsByTaxName (BioSourcePtr biop, Pointer userdata)
if (part != NULL
&& StringCmp (part->data.ptrvalue, biop->org->taxname) == 0)
{
- ApplyQualsToOrg (biop, omlp->parts, form_data);
+ ApplyQualsToOrg (biop, tlp->parts, form_data);
found_org = TRUE;
}
}
@@ -8592,18 +9283,69 @@ static void ApplyTableModsByTaxName (BioSourcePtr biop, Pointer userdata)
}
}
+static Boolean HasExtraAccession (
+ CharPtr acc_str,
+ GBBlockPtr gbp)
+{
+ ValNodePtr vnp;
+ if (acc_str == NULL || gbp == NULL) return FALSE;
+ for (vnp = gbp->extra_accessions;
+ vnp != NULL && StringCmp (acc_str, vnp->data.ptrvalue) != 0;
+ vnp = vnp->next)
+ {}
+ if (vnp != NULL)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static Boolean IDListHasValue (
+ CharPtr id,
+ SeqIdPtr list,
+ Boolean only_local,
+ Boolean look_for_tmsmart)
+{
+ SeqIdPtr sip;
+ Char acc_str [256];
+ Int4 match_len;
+
+ for (sip = list; sip != NULL; sip = sip->next)
+ {
+ if ((! only_local && sip->choice != SEQID_LOCAL)
+ || (only_local && sip->choice == SEQID_LOCAL))
+ {
+ SeqIdWrite (sip, acc_str, PRINTID_REPORT, sizeof (acc_str));
+ if (look_for_tmsmart)
+ {
+ if (StringNCmp (acc_str, "TMSMART:", 8) == 0
+ && StringCmp (id, acc_str + 8) == 0)
+ {
+ return TRUE;
+ }
+ } else {
+ match_len = StringCSpn (acc_str, ".");
+ if (match_len > 0 && StringNCmp (id, acc_str, match_len) == 0)
+ {
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
static void ApplyTableModsByAccessionNumber (BioseqPtr bsp, Pointer userdata)
{
OrgModLoadFormPtr form_data;
SeqDescrPtr sdp;
GBBlockPtr gbp;
Int4 column_index, part_index;
- ValNodePtr vnp;
BioSourcePtr biop;
ValNodePtr line, part;
- OrgModLinePtr omlp;
- SeqIdPtr sip;
- Char acc_str [256];
+ TableLinePtr tlp;
+ Boolean use_local_id;
+ Boolean look_for_tmsmart;
+ Int4 match_choice;
form_data = (OrgModLoadFormPtr) userdata;
if (form_data == NULL || bsp == NULL) return;
@@ -8622,50 +9364,39 @@ static void ApplyTableModsByAccessionNumber (BioseqPtr bsp, Pointer userdata)
column_index < form_data->num_line_forms;
column_index ++)
{
+ match_choice = GetValue (form_data->line_forms[column_index].match_choice);
if (GetValue (form_data->line_forms[column_index].action_choice) == 1
- && (GetValue (form_data->line_forms[column_index].match_choice) == 1
- || GetValue (form_data->line_forms[column_index].match_choice) == 2))
+ && (match_choice == 1 || match_choice == 2 || match_choice == 4))
{
+ if (match_choice == 1 || match_choice == 4) {
+ use_local_id = FALSE;
+ } else {
+ use_local_id = TRUE;
+ }
+ if (match_choice == 4) {
+ look_for_tmsmart = TRUE;
+ } else {
+ look_for_tmsmart = FALSE;
+ }
+
for (line = form_data->line_list; line != NULL; line = line->next)
{
- omlp = line->data.ptrvalue;
- if (omlp == NULL) continue;
- part = omlp->parts;
+ tlp = line->data.ptrvalue;
+ if (tlp == NULL) continue;
+ part = tlp->parts;
for (part_index = 0;
part_index < column_index && part != NULL;
part_index ++)
{
part = part->next;
}
- if (part != NULL)
+ if (part != NULL
+ && ( IDListHasValue ( part->data.ptrvalue,
+ bsp->id, use_local_id, look_for_tmsmart)
+ || (! use_local_id &&
+ HasExtraAccession ( part->data.ptrvalue, gbp))))
{
- if (GetValue (form_data->line_forms[column_index].match_choice) == 1)
- {
- if (gbp != NULL)
- {
- for (vnp = gbp->extra_accessions;
- vnp != NULL
- && StringCmp (part->data.ptrvalue, vnp->data.ptrvalue) != 0;
- vnp = vnp->next)
- {}
- if (vnp != NULL)
- {
- ApplyQualsToOrg (biop, omlp->parts, form_data);
- }
- }
- }
- for (sip = bsp->id; sip != NULL; sip = sip->next)
- {
- if ((GetValue (form_data->line_forms[column_index].match_choice) == 1 && sip->choice != SEQID_LOCAL)
- || (GetValue (form_data->line_forms[column_index].match_choice) == 2 && sip->choice == SEQID_LOCAL))
- {
- SeqIdWrite (sip, acc_str, PRINTID_REPORT, sizeof (acc_str));
- if (StringCmp (part->data.ptrvalue, acc_str) == 0)
- {
- ApplyQualsToOrg (biop, omlp->parts, form_data);
- }
- }
- }
+ ApplyQualsToOrg (biop, tlp->parts, form_data);
}
}
}
@@ -8691,35 +9422,23 @@ static void DoAcceptFormMods (ButtoN b)
Remove (form_data->form);
}
-extern void LoadOrganismModifierTable (IteM i)
+static ValNodePtr ReadTableData (void)
{
- BaseFormPtr bfp;
Char path [PATH_MAX];
FILE *fp;
Char str [8192];
size_t len = 8192;
- ValNodePtr line_list;
Int4 max_columns;
ValNodePtr header_line;
+ ValNodePtr line_list;
+ TableLinePtr tlp;
ValNodePtr vnp;
- OrgModLinePtr omlp;
- WindoW w;
- GrouP h, g, c;
- OrgModLoadFormPtr form_data;
- Int4 index;
-
-#ifdef WIN_MAC
- bfp = currentFormDataPtr;
-#else
- bfp = GetObjectExtra (i);
-#endif
- if (bfp == NULL) return;
path [0] = '\0';
- if (! GetInputFileName (path, sizeof (path), NULL, "TEXT")) return;
+ if (! GetInputFileName (path, sizeof (path), NULL, "TEXT")) return NULL;
fp = FileOpen (path, "r");
- if (fp == NULL) return;
+ if (fp == NULL) return NULL;
line_list = NULL;
max_columns = 0;
@@ -8727,16 +9446,16 @@ extern void LoadOrganismModifierTable (IteM i)
ReadLine (fp, str, len);
while (Nlm_fileDone)
{
- omlp = MakeOrgModData (str);
- if (omlp != NULL)
+ tlp = MakeTableData (str);
+ if (tlp != NULL)
{
vnp = ValNodeNew (line_list);
- if (vnp == NULL) return;
+ if (vnp == NULL) return NULL;
if (line_list == NULL) line_list = vnp;
- vnp->data.ptrvalue = omlp;
- if (omlp->num_parts > max_columns)
+ vnp->data.ptrvalue = tlp;
+ if (tlp->num_parts > max_columns)
{
- max_columns = omlp->num_parts;
+ max_columns = tlp->num_parts;
header_line = vnp;
}
}
@@ -8755,6 +9474,36 @@ extern void LoadOrganismModifierTable (IteM i)
ValNodeFreeData (line_list);
line_list = NULL;
}
+ return header_line;
+}
+
+extern void LoadOrganismModifierTable (IteM i)
+{
+ BaseFormPtr bfp;
+ ValNodePtr header_line;
+ ValNodePtr vnp;
+ TableLinePtr tlp;
+ WindoW w;
+ GrouP h, g, c;
+ OrgModLoadFormPtr form_data;
+ Int4 index;
+ Int4 max_columns;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+
+ header_line = ReadTableData ();
+ if (header_line == NULL || header_line->data.ptrvalue == NULL) return;
+ tlp = header_line->data.ptrvalue;
+ max_columns = 0;
+ for (vnp = tlp->parts; vnp != NULL; vnp = vnp->next)
+ {
+ max_columns ++;
+ }
form_data = MemNew (sizeof (OrgModLoadFormData));
if (form_data == NULL) return;
@@ -8772,8 +9521,8 @@ extern void LoadOrganismModifierTable (IteM i)
h = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
g = HiddenGroup (h, 3, 0, NULL);
- omlp = header_line->data.ptrvalue;
- vnp = omlp->parts;
+ tlp = header_line->data.ptrvalue;
+ vnp = tlp->parts;
for (index = 0; index < max_columns; index++)
{
BuildOrgModLineForm (vnp->data.ptrvalue, index, g,
@@ -8782,7 +9531,7 @@ extern void LoadOrganismModifierTable (IteM i)
}
c = HiddenGroup (h, 4, 0, NULL);
- form_data->accept_button = PushButton (c, "Accept", DoAcceptFormMods);
+ form_data->accept_button = DefaultButton (c, "Accept", DoAcceptFormMods);
SetObjectExtra (form_data->accept_button, form_data, NULL);
Disable (form_data->accept_button);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -8794,3 +9543,1430 @@ extern void LoadOrganismModifierTable (IteM i)
Update ();
}
+typedef struct qualifierselect {
+ LisT gene_quals;
+ LisT cds_quals;
+ LisT import_quals;
+} QualifierSelectData, PNTR QualifierSelectPtr;
+
+typedef struct featurequalloadformdata {
+ FEATURE_FORM_BLOCK
+
+ ValNodePtr line_list;
+ ValNodePtr featlist;
+ Int4 num_feats;
+ Uint2 entityID;
+ LisT feature_type;
+ QualifierSelectData match_qual;
+ QualifierSelectData apply_qual;
+ PopuP sequence_id_type;
+ PopuP sequence_column;
+ PopuP feature_column;
+ PopuP apply_column;
+ GrouP seq_group;
+ GrouP match_group;
+ GrouP apply_group;
+ Boolean asked_about_replace;
+ Boolean do_replace;
+ Boolean use_semicolon;
+ ButtoN accept_button;
+} FeatureQualLoadFormData, PNTR FeatureQualLoadFormPtr;
+
+static void CleanupFeatureQualLoadForm (
+ GraphiC g,
+ VoidPtr data
+)
+{
+ FeatureQualLoadFormPtr form_data;
+
+ form_data = (FeatureQualLoadFormPtr)data;
+ if (form_data == NULL) return;
+ CleanUpTableData (form_data->line_list);
+ StdCleanupFormProc (g, data);
+}
+
+typedef struct qualifierlistdata {
+ CharPtr item_name;
+} QualifierListData, PNTR QualifierListPtr;
+
+static Int4 GetSubtypeFromOffsetInFeatureList (Int4 list_offset,
+ ValNodePtr list)
+{
+ ValNodePtr vnp;
+
+ if (list == NULL || list_offset < 1) return -1;
+
+ vnp = list;
+ while (vnp != NULL && list_offset > 1)
+ {
+ list_offset --;
+ vnp = vnp->next;
+ }
+ if (list_offset > 1) return -1;
+ return vnp->choice;
+}
+
+static void ShowQualifierListBySubtype (QualifierSelectPtr qsp, Int4 feature_subtype)
+{
+ if (feature_subtype == -1) {
+ Hide (qsp->gene_quals);
+ Hide (qsp->cds_quals);
+ Hide (qsp->import_quals);
+ } else if (feature_subtype == FEATDEF_GENE) {
+ Show (qsp->gene_quals);
+ Hide (qsp->cds_quals);
+ Hide (qsp->import_quals);
+ } else if (feature_subtype == FEATDEF_CDS) {
+ Hide (qsp->gene_quals);
+ Show (qsp->cds_quals);
+ Hide (qsp->import_quals);
+ } else {
+ Hide (qsp->gene_quals);
+ Hide (qsp->cds_quals);
+ Show (qsp->import_quals);
+ }
+}
+
+static void ShowQualifierLists (FeatureQualLoadFormPtr form_data)
+{
+ Int4 feature_offset, feature_subtype;
+
+ if (form_data == NULL) return;
+
+ feature_offset = GetValue (form_data->feature_type);
+ feature_subtype = GetSubtypeFromOffsetInFeatureList (feature_offset,
+ form_data->featlist);
+ ShowQualifierListBySubtype (&(form_data->match_qual), feature_subtype);
+ ShowQualifierListBySubtype (&(form_data->apply_qual), feature_subtype);
+}
+
+static QualifierListData GeneTableQualifiers [] = {
+ { "allele"},
+ { "locus" },
+ { "locus_tag"},
+ { "description"},
+ { "product"}
+};
+
+#define NUM_GENE_TABLE_QUALIFIERS 5
+
+static QualifierListData ProtTableQualifiers [] = {
+ { "product"},
+ { "description"},
+ { "comment"}
+};
+
+#define NUM_PROT_TABLE_QUALIFIERS 3
+
+/* check the appropriate list box for qualifier type,
+ * keeping in mind that the first item is always "none"
+ */
+static Int4 GetQualSelectBySubtype (QualifierSelectPtr qsp, Int4 feature_subtype)
+{
+ Int4 qual_choice = -1;
+
+ if (feature_subtype == -1) {
+ qual_choice = -1;
+ } else if (feature_subtype == FEATDEF_GENE) {
+ qual_choice = GetValue (qsp->gene_quals);
+ if (qual_choice < 2
+ || qual_choice > NUM_GENE_TABLE_QUALIFIERS + 2) {
+ qual_choice = -1;
+ } else {
+ qual_choice = qual_choice - 1;
+ }
+ } else if (feature_subtype == FEATDEF_CDS) {
+ qual_choice = GetValue (qsp->cds_quals);
+ if (qual_choice < 2
+ || qual_choice > NUM_PROT_TABLE_QUALIFIERS + 2) {
+ qual_choice = -1;
+ } else {
+ qual_choice = qual_choice - 1;
+ }
+ } else {
+ qual_choice = GetValue (qsp->import_quals);
+ if (qual_choice < 2
+ || qual_choice > ParFlat_TOTAL_GBQUAL + 2) {
+ qual_choice = -1;
+ } else {
+ qual_choice = qual_choice - 1;
+ }
+ }
+ return qual_choice;
+
+}
+
+static void SetFeatureQualAcceptButton (Handle a)
+{
+ FeatureQualLoadFormPtr form_data;
+ Boolean have_feature_select_column;
+ Boolean have_feature_qual_select_column;
+ Int4 feature_select_choice;
+ Int4 apply_qual_choice;
+ Int4 match_qual_choice;
+ Int4 feature_subtype;
+ Boolean seqid_select_ok;
+ Int4 seqid_select_type;
+ Int4 seqid_select_column;
+
+ form_data = GetObjectExtra (a);
+ if (form_data == NULL) return;
+
+ ShowQualifierLists (form_data);
+ have_feature_qual_select_column = FALSE;
+ have_feature_select_column = FALSE;
+ seqid_select_ok = FALSE;
+
+ feature_select_choice = GetValue (form_data->feature_type);
+ if ( feature_select_choice > 0 && feature_select_choice < form_data->num_feats)
+ {
+ have_feature_select_column = TRUE;
+ }
+
+ feature_subtype = GetSubtypeFromOffsetInFeatureList (feature_select_choice,
+ form_data->featlist);
+
+ apply_qual_choice = GetQualSelectBySubtype (&(form_data->apply_qual),
+ feature_subtype);
+ if (apply_qual_choice != -1)
+ {
+ have_feature_qual_select_column = TRUE;
+ }
+
+ /* if a column is selected for a sequence identifier, must select type */
+ /* if a column is not selected for a sequence identifier, must not select type */
+ seqid_select_type = GetValue (form_data->sequence_id_type);
+ seqid_select_column = GetValue (form_data->sequence_column);
+ if (seqid_select_type == 1 || seqid_select_type == 2) {
+ if (seqid_select_column > 0) {
+ seqid_select_ok = TRUE;
+ }
+ } else {
+ seqid_select_ok = TRUE;
+ }
+
+ /* if the feature column is not specified, must not have match qualifier */
+ /* and must have sequence ID */
+ /* if the feature column is specified, must have match qualifier */
+ match_qual_choice = GetQualSelectBySubtype (&(form_data->match_qual),
+ feature_subtype);
+ if (GetValue (form_data->feature_column) < 1)
+ {
+ if (match_qual_choice != -1)
+ {
+ have_feature_select_column = FALSE;
+ }
+ else if (seqid_select_column < 1)
+ {
+ have_feature_select_column = FALSE;
+ }
+ } else {
+ if (match_qual_choice == -1)
+ {
+ have_feature_select_column = FALSE;
+ }
+ }
+
+ if (GetValue (form_data->apply_column) < 1) {
+ have_feature_qual_select_column = FALSE;
+ }
+
+ if ( have_feature_select_column && have_feature_qual_select_column
+ && seqid_select_ok)
+ {
+ Enable (form_data->accept_button);
+ }
+ else
+ {
+ Disable (form_data->accept_button);
+ }
+}
+
+static Boolean ProductNameMatches (
+ SeqLocPtr slp,
+ BioseqPtr bsp,
+ CharPtr pString
+)
+{
+ SeqFeatPtr sfp;
+ SeqMgrFeatContext fcontext;
+
+ if (slp == NULL || bsp == NULL || pString == NULL) return FALSE;
+
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &fcontext);
+ while (sfp != NULL)
+ {
+ if ( IsLocAInBonSameStrand (sfp->location, slp)
+ && StringStr ( fcontext.label, pString) != NULL)
+ {
+ return TRUE;
+ }
+ sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_CDREGION, 0, &fcontext);
+ }
+ return FALSE;
+}
+
+static Boolean GeneHasThisQualifier (
+ SeqFeatPtr sfp,
+ Uint2 entityID,
+ CharPtr pString,
+ Int2 popup_offset
+)
+{
+ BioseqPtr bsp;
+ GeneRefPtr grp;
+
+ if (sfp == NULL || pString == NULL) return FALSE;
+ if (popup_offset < 1 || popup_offset > NUM_GENE_TABLE_QUALIFIERS) return FALSE;
+
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ if (grp == NULL) return FALSE;
+
+ if ( StringCmp (GeneTableQualifiers [popup_offset - 1].item_name, "allele") == 0) {
+ if (StringCmp (pString, grp->allele) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if ( StringCmp (GeneTableQualifiers [popup_offset - 1].item_name, "locus") == 0) {
+ if (StringCmp (pString, grp->locus) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if ( StringCmp (GeneTableQualifiers [popup_offset - 1].item_name, "locus_tag") == 0) {
+ if (StringCmp (pString, grp->locus_tag) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if ( StringCmp (GeneTableQualifiers [popup_offset - 1].item_name, "description") == 0) {
+ if (StringCmp (pString, grp->desc) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else if ( StringCmp (GeneTableQualifiers [popup_offset - 1].item_name, "product") == 0)
+ {
+ bsp = GetBioseqGivenSeqLoc (sfp->location, entityID);
+ return ProductNameMatches (sfp->location, bsp, pString);
+ }
+ return FALSE;
+}
+
+static Boolean ProteinHasThisQualifier (
+ SeqFeatPtr sfp,
+ CharPtr pString,
+ Int2 popup_offset
+)
+{
+ ProtRefPtr prp;
+
+ if (sfp == NULL || sfp->data.choice != SEQFEAT_PROT || pString == NULL
+ || popup_offset < 1 || popup_offset > NUM_PROT_TABLE_QUALIFIERS)
+ {
+ return FALSE;
+ }
+
+ prp = sfp->data.value.ptrvalue;
+ if (prp == NULL) return FALSE;
+
+ if (StringCmp (ProtTableQualifiers [ popup_offset - 1].item_name, "product") == 0)
+ {
+ if (prp->name != NULL
+ && StringStr (prp->name->data.ptrvalue, pString) != NULL)
+ {
+ return TRUE;
+ }
+ } else if (StringCmp (ProtTableQualifiers [popup_offset - 1].item_name, "description") == 0) {
+ if (StringStr (prp->desc, pString) != NULL)
+ {
+ return TRUE;
+ }
+ } else if (StringCmp (ProtTableQualifiers [popup_offset - 1].item_name, "comment") == 0) {
+ if (StringStr (sfp->comment, pString) != NULL)
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static Boolean CDSHasThisQualifier (
+ SeqFeatPtr sfp,
+ Uint2 entityID,
+ CharPtr pString,
+ Int2 popup_offset
+)
+{
+ SeqFeatPtr protein;
+
+ if (sfp == NULL || pString == NULL) return FALSE;
+
+ if (StringCmp (ProtTableQualifiers [popup_offset - 1].item_name, "comment") == 0) {
+ if (StringStr (sfp->comment, pString) != NULL)
+ {
+ return TRUE;
+ }
+ }
+ else
+ {
+ protein = FindBestProtein (entityID, sfp->product);
+ if (protein == NULL) return FALSE;
+ return ProteinHasThisQualifier (protein, pString, popup_offset);
+ }
+ return FALSE;
+}
+
+static Boolean FeatureHasThisQualifier (
+ SeqFeatPtr sfp,
+ Uint2 entityID,
+ CharPtr pString,
+ Int2 popup_offset
+)
+{
+ Int2 qualval;
+ GBQualPtr gbqual;
+
+ if (popup_offset < 1) return FALSE;
+ if (sfp == NULL || pString == NULL) return FALSE;
+
+ if (sfp->idx.subtype == FEATDEF_GENE)
+ {
+ return GeneHasThisQualifier (sfp, entityID, pString, popup_offset);
+ }
+ else if (sfp->idx.subtype == FEATDEF_CDS)
+ {
+ return CDSHasThisQualifier (sfp, entityID, pString, popup_offset);
+ }
+ else
+ {
+ for (gbqual = sfp->qual; gbqual != NULL; gbqual = gbqual->next)
+ {
+ qualval = GBQualNameValid (gbqual->qual);
+ if (qualval > -1 && qualval == popup_offset -1)
+ {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+static CharPtr GetDataForColumnOffset (ValNodePtr column_data, Int4 offset)
+{
+ ValNodePtr vnp;
+
+ for (vnp = column_data; vnp != NULL && offset > 1; vnp = vnp->next)
+ {
+ offset --;
+ }
+ if (offset > 1 || vnp == NULL) {
+ return NULL;
+ } else {
+ return vnp->data.ptrvalue;
+ }
+}
+
+static Boolean ApplyQualToThisFeature (
+ SeqFeatPtr sfp,
+ ValNodePtr parts,
+ FeatureQualLoadFormPtr form_data
+)
+{
+ Int4 column_index;
+ CharPtr val;
+ Int4 subtype;
+ Int4 popup_offset;
+
+ if (sfp == NULL || parts == NULL || form_data == NULL) return FALSE;
+
+ column_index = GetValue (form_data->feature_column);
+ subtype = GetSubtypeFromOffsetInFeatureList (
+ GetValue (form_data->feature_type), form_data->featlist);
+ val = GetDataForColumnOffset (parts, column_index);
+
+ if (val != NULL && sfp->idx.subtype == subtype)
+ {
+ popup_offset = GetQualSelectBySubtype (&(form_data->match_qual),
+ subtype);
+ if (popup_offset < 1
+ || FeatureHasThisQualifier (sfp, form_data->entityID, val, popup_offset))
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+typedef struct featurequaltabledata {
+ ValNodePtr parts;
+ FeatureQualLoadFormPtr form_data;
+} FeatureQualTableData, PNTR FeatureQualTablePtr;
+
+static void ApplyOneQualToProt (
+ SeqFeatPtr sfp,
+ Int2 popup_offset,
+ CharPtr pString,
+ Boolean PNTR asked_about_replace,
+ Boolean PNTR do_replace,
+ Boolean PNTR use_semicolon)
+{
+ ProtRefPtr prp;
+ CharPtr cp;
+
+ if (sfp == NULL || sfp->data.choice != SEQFEAT_PROT || pString == NULL
+ || popup_offset < 1 || popup_offset > NUM_PROT_TABLE_QUALIFIERS
+ || asked_about_replace == NULL
+ || do_replace == NULL
+ || use_semicolon == NULL)
+ {
+ return;
+ }
+
+ prp = sfp->data.value.ptrvalue;
+ if (prp == NULL) return;
+
+ if (StringCmp (ProtTableQualifiers [ popup_offset - 1].item_name, "product") == 0)
+ {
+ if (prp->name == NULL)
+ {
+ ValNodeAddStr (&prp->name, 0, StringSave (pString));
+ }
+ else
+ {
+ cp = prp->name->data.ptrvalue;
+ AppendOrReplaceString (&cp, pString,
+ asked_about_replace, do_replace, use_semicolon);
+ prp->name->data.ptrvalue = cp;
+ }
+ } else if (StringCmp (ProtTableQualifiers [popup_offset - 1].item_name, "description") == 0) {
+ AppendOrReplaceString (&(prp->desc), pString,
+ asked_about_replace, do_replace, use_semicolon);
+ } else if (StringCmp (ProtTableQualifiers [popup_offset - 1].item_name, "comment") == 0) {
+ AppendOrReplaceString (&(sfp->comment), pString,
+ asked_about_replace, do_replace, use_semicolon);
+ }
+}
+
+static void ApplyOneQualToCDS (
+ SeqFeatPtr sfp,
+ Uint2 entityID,
+ Int2 feat_qual_choice,
+ CharPtr pString,
+ Boolean PNTR asked_about_replace,
+ Boolean PNTR do_replace,
+ Boolean PNTR use_semicolon)
+{
+ SeqFeatPtr protein;
+
+ if (sfp == NULL || pString == NULL
+ || asked_about_replace == NULL
+ || do_replace == NULL
+ || use_semicolon == NULL)
+ {
+ return;
+ }
+
+ if (StringCmp (ProtTableQualifiers [feat_qual_choice - 1].item_name, "comment") == 0) {
+ AppendOrReplaceString (&(sfp->comment), pString,
+ asked_about_replace, do_replace, use_semicolon);
+ }
+ else
+ {
+ protein = FindBestProtein (entityID, sfp->product);
+ if (protein == NULL) return;
+ ApplyOneQualToProt (protein, feat_qual_choice, pString,
+ asked_about_replace, do_replace, use_semicolon);
+ }
+}
+
+static void ApplyGeneProductName (
+ SeqLocPtr slp,
+ Uint2 entityID,
+ CharPtr pString,
+ Boolean PNTR asked_about_replace,
+ Boolean PNTR do_replace,
+ Boolean PNTR use_semicolon)
+{
+ SeqFeatPtr sfp;
+ SeqMgrFeatContext fcontext;
+ Int4 prot_popup_offset;
+ BioseqPtr bsp;
+
+ if (slp == NULL || pString == NULL
+ || asked_about_replace == NULL
+ || do_replace == NULL
+ || use_semicolon == NULL)
+ {
+ return;
+ }
+
+ bsp = GetBioseqGivenSeqLoc (slp, entityID);
+ if (bsp == NULL) return;
+
+ for (prot_popup_offset = 0;
+ prot_popup_offset < NUM_PROT_TABLE_QUALIFIERS
+ && StringCmp (ProtTableQualifiers [prot_popup_offset].item_name, "product") != 0;
+ prot_popup_offset ++)
+ {}
+ if (prot_popup_offset >= NUM_PROT_TABLE_QUALIFIERS) return;
+
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &fcontext);
+ while (sfp != NULL)
+ {
+ if ( IsLocAInBonSameStrand (sfp->location, slp))
+ {
+ ApplyOneQualToCDS (sfp, entityID, prot_popup_offset + 1, pString,
+ asked_about_replace, do_replace, use_semicolon);
+ }
+ sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_CDREGION, 0, &fcontext);
+ }
+}
+
+static void ApplyOneQualToGene (
+ SeqFeatPtr sfp,
+ Uint2 entityID,
+ Int2 feat_qual_choice,
+ CharPtr pString,
+ Boolean PNTR asked_about_replace,
+ Boolean PNTR do_replace,
+ Boolean PNTR use_semicolon)
+{
+ GeneRefPtr grp;
+
+ if (sfp == NULL
+ || sfp->idx.subtype != FEATDEF_GENE
+ || feat_qual_choice < 1
+ || feat_qual_choice > NUM_GENE_TABLE_QUALIFIERS
+ || pString == NULL
+ || asked_about_replace == NULL
+ || do_replace == NULL
+ || use_semicolon == NULL)
+ {
+ return;
+ }
+
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ if (grp == NULL) return;
+
+ if (StringCmp ( GeneTableQualifiers [feat_qual_choice - 1].item_name,
+ "allele") == 0) {
+ AppendOrReplaceString (&(grp->allele), pString,
+ asked_about_replace, do_replace, use_semicolon);
+ } else if (StringCmp ( GeneTableQualifiers [feat_qual_choice - 1].item_name,
+ "locus") == 0) {
+ AppendOrReplaceString (&(grp->locus), pString,
+ asked_about_replace, do_replace, use_semicolon);
+ } else if (StringCmp ( GeneTableQualifiers [feat_qual_choice - 1].item_name,
+ "locus_tag") == 0) {
+ AppendOrReplaceString (&(grp->locus_tag), pString,
+ asked_about_replace, do_replace, use_semicolon);
+ } else if (StringCmp ( GeneTableQualifiers [feat_qual_choice - 1].item_name,
+ "description") == 0) {
+ AppendOrReplaceString (&(grp->desc), pString,
+ asked_about_replace, do_replace, use_semicolon);
+ } else if (StringCmp (GeneTableQualifiers [feat_qual_choice - 1].item_name,
+ "product") == 0) {
+ ApplyGeneProductName (sfp->location, entityID, pString,
+ asked_about_replace, do_replace, use_semicolon);
+ }
+}
+
+static void ApplyOneQualToImportFeature (
+ SeqFeatPtr sfp,
+ Int2 feat_qual_choice,
+ CharPtr pString,
+ Boolean PNTR asked_about_replace,
+ Boolean PNTR do_replace,
+ Boolean PNTR use_semicolon)
+{
+ GBQualPtr gbqual;
+
+ if (sfp == NULL
+ || feat_qual_choice < 1
+ || feat_qual_choice > ParFlat_TOTAL_GBQUAL
+ || pString == NULL
+ || asked_about_replace == NULL
+ || do_replace == NULL
+ || use_semicolon == NULL)
+ {
+ return;
+ }
+
+ gbqual = sfp->qual;
+ while (gbqual != NULL
+ && StringCmp (gbqual->qual,
+ ParFlat_GBQual_names [feat_qual_choice - 1].name) != 0)
+ {
+ gbqual = gbqual->next;
+ }
+
+ if (gbqual == NULL)
+ {
+ gbqual = GBQualNew ();
+ if (gbqual == NULL) return;
+ gbqual->qual = StringSave ( ParFlat_GBQual_names [feat_qual_choice - 1].name);
+ gbqual->val = StringSave ( pString );
+ gbqual->next = sfp->qual;
+ sfp->qual = gbqual;
+ }
+ else
+ {
+ AppendOrReplaceString (&(gbqual->val), pString,
+ asked_about_replace, do_replace, use_semicolon);
+ }
+}
+
+static void ApplyOneQualToFeature (
+ SeqFeatPtr sfp,
+ Uint2 entityID,
+ Int2 feat_qual_choice,
+ CharPtr pString,
+ Boolean PNTR asked_about_replace,
+ Boolean PNTR do_replace,
+ Boolean PNTR use_semicolon)
+{
+ if (sfp == NULL || pString == NULL
+ || asked_about_replace == NULL
+ || do_replace == NULL
+ || use_semicolon == NULL)
+ {
+ return;
+ }
+
+ switch (sfp->idx.subtype)
+ {
+ case FEATDEF_GENE :
+ ApplyOneQualToGene (sfp, entityID, feat_qual_choice, pString,
+ asked_about_replace, do_replace, use_semicolon);
+ break;
+ case FEATDEF_CDS :
+ ApplyOneQualToCDS (sfp, entityID, feat_qual_choice, pString,
+ asked_about_replace, do_replace, use_semicolon);
+ break;
+ default :
+ ApplyOneQualToImportFeature (sfp, feat_qual_choice, pString,
+ asked_about_replace, do_replace, use_semicolon);
+ break;
+ }
+}
+
+static CharPtr GetImpFeatKeyFromSubtype (Uint2 subtype)
+{
+ FeatDefPtr curr;
+ Uint1 key;
+ CharPtr label;
+
+ curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
+ while (curr != NULL) {
+ if (key == subtype)
+ {
+ return curr->typelabel;
+ }
+ curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
+ }
+ return NULL;
+}
+
+static void ApplyQualsToFeaturesOnBsp (BioseqPtr bsp,
+ FeatureQualLoadFormPtr form_data,
+ ValNodePtr parts)
+{
+ SeqFeatPtr sfp;
+ SeqMgrFeatContext fcontext;
+ Boolean found_feature = FALSE;
+ Int4 subtype;
+ Int4 column_index;
+ Int2 qualval;
+ Int2 matchval;
+ CharPtr val;
+ ImpFeatPtr ifp;
+
+ subtype = GetSubtypeFromOffsetInFeatureList (
+ GetValue (form_data->feature_type),
+ form_data->featlist);
+ column_index = GetValue (form_data->apply_column);
+ val = GetDataForColumnOffset (parts, column_index);
+ qualval = GetQualSelectBySubtype (&(form_data->apply_qual), subtype);
+ if (subtype == -1 || val == NULL || column_index < 1 || qualval < 1) {
+ /* do nothing */
+ }
+ else
+ {
+ sfp = SeqMgrGetNextFeature (bsp, NULL, 0, 0, &fcontext);
+ while (sfp != NULL)
+ {
+ if ( ApplyQualToThisFeature (sfp, parts, form_data))
+ {
+ found_feature = TRUE;
+ ApplyOneQualToFeature (sfp, form_data->entityID, qualval, val,
+ &(form_data->asked_about_replace),
+ &(form_data->do_replace),
+ &(form_data->use_semicolon));
+ }
+ sfp = SeqMgrGetNextFeature (bsp, sfp, 0, 0, &fcontext);
+ }
+
+ /* only want to create new features if no feature matching qualifier
+ * was specified and no feature was found */
+ matchval = GetQualSelectBySubtype (&(form_data->match_qual), subtype);
+
+ if (! found_feature && matchval == -1)
+ {
+ if (subtype == FEATDEF_CDS)
+ {
+ sfp = CreateNewFeatureOnBioseq (bsp, SEQFEAT_CDREGION, NULL);
+ if (sfp == NULL) return;
+ sfp->data.value.ptrvalue = CdRegionNew ();
+ } else if (subtype == FEATDEF_GENE) {
+ sfp = CreateNewFeatureOnBioseq (bsp, SEQFEAT_GENE, NULL);
+ if (sfp == NULL) return;
+ sfp->data.value.ptrvalue = GeneRefNew ();
+ } else {
+ ifp = ImpFeatNew ();
+ if (ifp == NULL) return;
+ sfp = CreateNewFeatureOnBioseq (bsp, SEQFEAT_IMP, NULL);
+ if (sfp == NULL) return;
+ ifp->key = StringSave ( GetImpFeatKeyFromSubtype (subtype));
+ sfp->data.value.ptrvalue = ifp;
+ }
+ SeqMgrIndexFeatures (0, (Pointer) bsp);
+ ApplyOneQualToFeature (sfp, form_data->entityID, qualval, val,
+ &(form_data->asked_about_replace),
+ &(form_data->do_replace),
+ &(form_data->use_semicolon));
+ }
+ }
+}
+
+static void ApplyTableQuals (BioseqPtr bsp, Pointer userdata)
+{
+ FeatureQualLoadFormPtr form_data;
+ SeqDescrPtr sdp;
+ GBBlockPtr gbp;
+ Int4 column_index;
+ ValNodePtr line;
+ TableLinePtr tlp;
+ Boolean use_local_id;
+ FeatureQualTableData fqtd;
+ Int2 seq_match_choice;
+ CharPtr idval;
+
+ form_data = (FeatureQualLoadFormPtr) userdata;
+ if (form_data == NULL || bsp == NULL) return;
+
+ gbp = NULL;
+ sdp = BioseqGetSeqDescr (bsp, Seq_descr_genbank, NULL);
+ if (sdp != NULL)
+ {
+ gbp = sdp->data.ptrvalue;
+ }
+
+ seq_match_choice = GetValue (form_data->sequence_id_type);
+ if (seq_match_choice == 1) {
+ use_local_id = FALSE;
+ }
+
+ fqtd.form_data = form_data;
+ if (seq_match_choice == 1 || seq_match_choice == 2)
+ {
+ column_index = GetValue (form_data->sequence_column);
+
+ for (line = form_data->line_list; line != NULL; line = line->next)
+ {
+ tlp = line->data.ptrvalue;
+ if (tlp == NULL) continue;
+ idval = GetDataForColumnOffset (tlp->parts, column_index);
+ if (idval != NULL
+ && ( IDListHasValue ( idval,
+ bsp->id, use_local_id, FALSE)
+ || (! use_local_id &&
+ HasExtraAccession ( idval, gbp))))
+ {
+ fqtd.parts = tlp->parts;
+ ApplyQualsToFeaturesOnBsp (bsp, form_data, tlp->parts);
+ }
+ }
+ } else {
+ for (line = form_data->line_list; line != NULL; line = line->next)
+ {
+ tlp = line->data.ptrvalue;
+ if (tlp == NULL) continue;
+ fqtd.parts = tlp->parts;
+ ApplyQualsToFeaturesOnBsp (bsp, form_data, tlp->parts);
+ }
+ }
+}
+
+static void DoAcceptFeatureQuals (ButtoN b)
+{
+ FeatureQualLoadFormPtr form_data;
+ SeqEntryPtr sep;
+
+ form_data = GetObjectExtra (b);
+ if (form_data == NULL) return;
+
+ sep = GetTopSeqEntryForEntityID (form_data->entityID);
+ if (sep == NULL) return;
+
+ VisitBioseqsInSep (sep, form_data, ApplyTableQuals);
+ Update ();
+ ObjMgrSetDirtyFlag (form_data->entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, form_data->entityID, 0, 0);
+ Remove (form_data->form);
+}
+
+static PopuP BuildColumnSelector ( GrouP g,
+ FeatureQualLoadFormPtr parent_form,
+ ValNodePtr parts )
+{
+ PopuP p;
+ ValNodePtr this_part;
+
+ if (g == NULL || parts == NULL) return NULL;
+
+ p = PopupList (g, TRUE, (PupActnProc) SetFeatureQualAcceptButton);
+ for (this_part = parts; this_part != NULL; this_part = this_part->next)
+ {
+ if (this_part->data.ptrvalue != NULL)
+ {
+ PopupItem (p, this_part->data.ptrvalue);
+ }
+ }
+ SetObjectExtra (p, parent_form, NULL);
+ return p;
+}
+
+static void BuildQualifierSelect ( GrouP parent,
+ FeatureQualLoadFormPtr parent_form,
+ ValNodePtr parts,
+ QualifierSelectPtr qsp )
+{
+ GrouP g;
+ Int4 listheight = 4;
+ Int4 listwidth = 13;
+ Int4 j;
+
+ if (parent_form == NULL || parts == NULL || qsp == NULL)
+ {
+ return;
+ }
+
+ g = HiddenGroup (parent, 0, 0, NULL);
+
+ qsp->gene_quals = SingleList (g, listwidth, listheight,
+ (LstActnProc) SetFeatureQualAcceptButton);
+ SetObjectExtra (qsp->gene_quals, parent_form, NULL);
+ ListItem (qsp->gene_quals, "None");
+ for (j=0; j < NUM_GENE_TABLE_QUALIFIERS; j++) {
+ ListItem (qsp->gene_quals, GeneTableQualifiers [j].item_name);
+ }
+ SetValue (qsp->gene_quals, 1);
+
+ qsp->cds_quals = SingleList (g, listwidth, listheight,
+ (LstActnProc) SetFeatureQualAcceptButton);
+ SetObjectExtra (qsp->cds_quals, parent_form, NULL);
+ ListItem (qsp->cds_quals, "None");
+ for (j=0; j < NUM_PROT_TABLE_QUALIFIERS; j++) {
+ ListItem (qsp->cds_quals, ProtTableQualifiers [j].item_name);
+ }
+ SetValue (qsp->cds_quals, 1);
+
+ qsp->import_quals = SingleList (g, listwidth, listheight,
+ (LstActnProc) SetFeatureQualAcceptButton);
+ SetObjectExtra (qsp->import_quals, parent_form, NULL);
+ ListItem (qsp->import_quals, "None");
+ for (j = 0; j < ParFlat_TOTAL_GBQUAL; j++) {
+ ListItem (qsp->import_quals, ParFlat_GBQual_names [j].name);
+ }
+ SetValue (qsp->import_quals, 1);
+}
+
+static void BuildSequenceSelect ( GrouP parent,
+ FeatureQualLoadFormPtr parent_form,
+ ValNodePtr parts )
+{
+ if (parent == NULL || parent_form == NULL || parts == NULL) return;
+
+ parent_form->seq_group = NormalGroup ( parent, 0, 2, "Sequence", programFont, NULL);
+ StaticPrompt (parent_form->seq_group, "Identifier Type", 0, popupMenuHeight, programFont, 'l');
+ parent_form->sequence_id_type = PopupList (parent_form->seq_group, TRUE, (PupActnProc) SetFeatureQualAcceptButton);
+ PopupItem (parent_form->sequence_id_type, "Accession");
+ PopupItem (parent_form->sequence_id_type, "Local ID");
+ PopupItem (parent_form->sequence_id_type, "None");
+ SetObjectExtra (parent_form->sequence_id_type, parent_form, NULL);
+ SetValue (parent_form->sequence_id_type, 3);
+
+ StaticPrompt (parent_form->seq_group, "Column", 0, popupMenuHeight, programFont, 'l');
+ parent_form->sequence_column = BuildColumnSelector ( parent_form->seq_group, parent_form, parts);
+}
+
+static void BuildFeatureSelect ( GrouP parent,
+ FeatureQualLoadFormPtr parent_form,
+ ValNodePtr parts )
+{
+ Int4 listheight = 4;
+ ValNodePtr vnp;
+
+ if (parent == NULL || parent_form == NULL || parts == NULL) return;
+
+ parent_form->match_group = NormalGroup ( parent, 0, 2,
+ "Feature to Edit", programFont, NULL);
+ StaticPrompt (parent_form->match_group, "Feature type", 0,
+ popupMenuHeight, programFont, 'l');
+ parent_form->feature_type = SingleList (parent_form->match_group,
+ 9, listheight,
+ (LstActnProc) SetFeatureQualAcceptButton);
+ SetObjectExtra (parent_form->feature_type, parent_form, NULL);
+ for (vnp = parent_form->featlist; vnp != NULL; vnp = vnp->next)
+ {
+ ListItem (parent_form->feature_type, (CharPtr) vnp->data.ptrvalue);
+ }
+
+ StaticPrompt (parent_form->match_group, "Qualifier to match", 0, popupMenuHeight, programFont, 'l');
+ BuildQualifierSelect ( parent_form->match_group, parent_form, parts, &(parent_form->match_qual));
+
+ StaticPrompt (parent_form->match_group, "Column", 0, popupMenuHeight, programFont, 'l');
+ parent_form->feature_column = BuildColumnSelector ( parent_form->match_group, parent_form, parts);
+
+}
+
+static void BuildFeatureApply ( GrouP parent,
+ FeatureQualLoadFormPtr parent_form,
+ ValNodePtr parts )
+{
+ if (parent == NULL || parent_form == NULL || parts == NULL) return;
+
+ parent_form->apply_group = NormalGroup ( parent, 0, 2, "Qualifier to Edit", programFont, NULL);
+
+ StaticPrompt (parent_form->apply_group, "Qualifier Name", 0, popupMenuHeight, programFont, 'l');
+ BuildQualifierSelect ( parent_form->apply_group, parent_form, parts, &(parent_form->apply_qual));
+
+ StaticPrompt (parent_form->apply_group, "Column", 0, popupMenuHeight, programFont, 'l');
+ parent_form->apply_column = BuildColumnSelector ( parent_form->apply_group, parent_form, parts);
+
+}
+
+extern void LoadFeatureQualifierTable (IteM i)
+{
+ BaseFormPtr bfp;
+ ValNodePtr header_line;
+ ValNodePtr vnp;
+ TableLinePtr tlp;
+ WindoW w;
+ GrouP h, c;
+ FeatureQualLoadFormPtr form_data;
+ Int4 max_columns;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+
+ header_line = ReadTableData ();
+ if (header_line == NULL || header_line->data.ptrvalue == NULL) return;
+ tlp = header_line->data.ptrvalue;
+ max_columns = 0;
+ for (vnp = tlp->parts; vnp != NULL; vnp = vnp->next)
+ {
+ max_columns ++;
+ }
+
+ form_data = MemNew (sizeof (FeatureQualLoadFormData));
+ if (form_data == NULL) return;
+ form_data->asked_about_replace = FALSE;
+ form_data->do_replace = FALSE;
+ form_data->use_semicolon = FALSE;
+ form_data->entityID = bfp->input_entityID;
+ form_data->line_list = header_line;
+ form_data->featlist = BuildFeatureValNodeList (TRUE, NULL, 0, TRUE, FALSE);
+ form_data->num_feats = 0;
+ for (vnp = form_data->featlist; vnp != NULL; vnp = vnp->next)
+ {
+ form_data->num_feats ++;
+ }
+
+ /* now create a dialog to display values */
+ w = FixedWindow (-50, -33, -10, -10, "Table Conversion", StdCloseWindowProc);
+ SetObjectExtra (w, form_data, CleanupFeatureQualLoadForm);
+ form_data->form = (ForM) w;
+
+ h = HiddenGroup (w, -1, 0, NULL);
+ SetGroupSpacing (h, 10, 10);
+
+ BuildSequenceSelect ( h, form_data, tlp->parts);
+ BuildFeatureSelect (h, form_data, tlp->parts);
+ BuildFeatureApply (h, form_data, tlp->parts);
+ ShowQualifierLists (form_data);
+
+ c = HiddenGroup (h, 4, 0, NULL);
+ form_data->accept_button = DefaultButton (c, "Accept", DoAcceptFeatureQuals);
+ SetObjectExtra (form_data->accept_button, form_data, NULL);
+ Disable (form_data->accept_button);
+ PushButton (c, "Cancel", StdCancelButtonProc);
+
+ AlignObjects (ALIGN_CENTER,
+ (HANDLE) form_data->seq_group,
+ (HANDLE) form_data->match_group,
+ (HANDLE) form_data->apply_group,
+ (HANDLE) c, NULL);
+
+ RealizeWindow (w);
+ Show (w);
+ Update ();
+}
+
+typedef struct prefixformdata {
+ FEATURE_FORM_BLOCK
+
+ ModifierItemLocalPtr modList;
+ PopuP PNTR popup_list;
+ ButtoN add_org_name;
+ ButtoN use_labels;
+} PrefixFormData, PNTR PrefixFormPtr;
+
+static void CleanupPrefixForm (
+ GraphiC g,
+ VoidPtr data
+)
+
+{
+ PrefixFormPtr pfp;
+ Int4 i;
+
+ pfp = (PrefixFormPtr) data;
+ if (pfp != NULL) {
+ if (pfp->modList != NULL)
+ {
+ for (i=0; i < NumDefLineModifiers; i++)
+ {
+ ValNodeFree (pfp->modList[i].values_seen);
+ }
+ MemFree (pfp->modList);
+ }
+ if (pfp->popup_list != NULL)
+ {
+ MemFree (pfp->popup_list);
+ }
+ }
+ StdCleanupFormProc (g, data);
+}
+
+static Int4 GetDefLineModifierPopupIndex (
+ Int4 popup_index,
+ ModifierItemLocalPtr modList
+)
+{
+ Int4 index;
+ Int4 want_index;
+
+ want_index = 0;
+ for (index = 0;
+ index < NumDefLineModifiers && want_index < popup_index;
+ index++)
+ {
+ if (modList [index].any_present)
+ {
+ want_index ++;
+ }
+ }
+ if (index >= NumDefLineModifiers || index == 0
+ || want_index < popup_index)
+ {
+ return -1;
+ }
+ return index - 1;
+}
+
+static void AddPrefixesToOneDefLine (
+ PrefixFormPtr pfp,
+ BioseqPtr bsp,
+ SeqEntryPtr sep
+)
+{
+ BioSourcePtr biop;
+ SeqDescrPtr sdp;
+ ValNodePtr strings;
+ Int4 index;
+ Int4 qual_index;
+ Int4 popup_choice;
+ CharPtr new_defline;
+ Char taxName [196];
+ Char modifier_text [256];
+ OrgRefPtr orp;
+ OrgNamePtr onp;
+ OrgModPtr mod;
+ SubSourcePtr ssp;
+ CharPtr org_desc;
+ CharPtr cp;
+ SeqMgrDescContext dcontext;
+ Boolean use_labels;
+ Int4 no_semicolon_len;
+
+ if (bsp == NULL || pfp == NULL
+ || pfp->popup_list == NULL
+ || pfp->modList == NULL
+ || (biop = GetBiopForBsp (bsp)) == NULL)
+ {
+ return;
+ }
+
+ if (biop->org == NULL) return;
+ if (biop->org->taxname == NULL) return;
+ StringNCpy (taxName, biop->org->taxname, sizeof (taxName) - 1);
+ taxName [ sizeof (taxName) - 1] = 0;
+
+ strings = NULL;
+ CleanUpTaxName (taxName, TRUE);
+ if (GetStatus (pfp->add_org_name))
+ {
+ ValNodeCopyStr( &strings, 0, taxName);
+ }
+
+ use_labels = GetStatus (pfp->use_labels);
+
+ orp = biop->org;
+ if (orp == NULL) return;
+ onp = orp->orgname;
+ if (onp == NULL) return;
+ for (index = 0; index < NumDefLineModifiers; index ++)
+ {
+ if (pfp->popup_list [ index] != NULL
+ && (popup_choice = GetValue (pfp->popup_list [ index])) > 0)
+ {
+ qual_index = GetDefLineModifierPopupIndex (popup_choice, pfp->modList);
+ if (qual_index < 0 || qual_index >= NumDefLineModifiers) continue;
+ if (DefLineModifiers[qual_index].isOrgMod)
+ {
+ mod = onp->mod;
+ while (mod != NULL
+ && mod->subtype != DefLineModifiers[qual_index].subtype)
+ {
+ mod = mod->next;
+ }
+ if ( UseOrgModifier (mod, taxName))
+ {
+ no_semicolon_len = StringCSpn (mod->subname, ";");
+ if (mod->subtype == ORGMOD_nat_host)
+ {
+ sprintf (modifier_text, "from ");
+ if (no_semicolon_len > sizeof (modifier_text) - 6) {
+ no_semicolon_len = sizeof (modifier_text) - 6;
+ }
+ StringNCpy (modifier_text + 5, mod->subname, no_semicolon_len);
+ modifier_text[sizeof (modifier_text) - 1] = 0;
+ }
+ else
+ {
+ AddModifierLabel (use_labels, qual_index, modifier_text);
+ if (modifier_text[0] != 0)
+ StringCat (modifier_text, " ");
+ if (no_semicolon_len > sizeof (modifier_text) - StringLen (modifier_text) - 1) {
+ no_semicolon_len = sizeof (modifier_text) - StringLen (modifier_text) - 1;
+ }
+ StringNCat (modifier_text, mod->subname, no_semicolon_len);
+ modifier_text[sizeof (modifier_text) - 1] = 0;
+ }
+ ValNodeCopyStr( &strings, 0, modifier_text);
+ }
+ } else {
+ ssp = biop->subtype;
+ while (ssp != NULL
+ && ssp->subtype != DefLineModifiers[qual_index].subtype)
+ {
+ ssp = ssp->next;
+ }
+ if (ssp != NULL)
+ {
+ no_semicolon_len = StringCSpn (ssp->name, ";");
+ AddModifierLabel (use_labels, qual_index, modifier_text);
+ if (ssp->subtype == SUBSRC_country)
+ {
+ sprintf (modifier_text, "from ");
+ if (no_semicolon_len > sizeof (modifier_text) - 6) {
+ no_semicolon_len = sizeof (modifier_text) - 6;
+ }
+ StringNCpy (modifier_text + 5, ssp->name, no_semicolon_len);
+ modifier_text[sizeof (modifier_text) - 1] = 0;
+ cp = StringChr (modifier_text, ':');
+ if (cp != NULL) *cp = 0;
+ }
+ else if (ssp->name != NULL
+ && (ssp->subtype != SUBSRC_plasmid_name
+ || StringCmp (ssp->name, "unnamed") != 0))
+ {
+ if (modifier_text[0] != 0)
+ StringCat (modifier_text, " ");
+ if (no_semicolon_len > sizeof (modifier_text) - StringLen (modifier_text) - 1) {
+ no_semicolon_len = sizeof (modifier_text) - StringLen (modifier_text) - 1;
+ }
+
+ StringNCat (modifier_text, ssp->name, no_semicolon_len);
+ modifier_text[sizeof (modifier_text) - 1] = 0;
+ }
+ ValNodeCopyStr( &strings, 0, modifier_text);
+ }
+ }
+ }
+ }
+ org_desc = MergeValNodeStrings (strings, FALSE);
+ ValNodeFreeData (strings);
+
+ sdp = SeqEntryGetSeqDescr (sep, Seq_descr_title, NULL);
+ if (sdp == NULL) {
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_title, &dcontext);
+ if (sdp == NULL) return;
+ cp = (CharPtr) sdp->data.ptrvalue;
+ if (cp == NULL) return;
+ sdp = SeqDescrAdd (&(bsp->descr));
+ if (sdp == NULL) return;
+ sdp->choice = Seq_descr_title;
+ sdp->data.ptrvalue = StringSave (cp);
+ }
+ if (sdp == NULL) return;
+ if (StringHasNoText (sdp->data.ptrvalue)) return;
+ new_defline = MemNew ((StringLen (org_desc)
+ + StringLen (sdp->data.ptrvalue) + 4) * sizeof (Char));
+ if (new_defline == NULL) return;
+ StringCpy (new_defline, org_desc);
+ StringCat (new_defline, " ");
+ StringCat (new_defline, sdp->data.ptrvalue);
+ MemFree (sdp->data.ptrvalue);
+ sdp->data.ptrvalue = new_defline;
+ ObjMgrSetDirtyFlag (pfp->input_entityID, TRUE);
+}
+
+static void AddPrefixesToDefLines (PrefixFormPtr pfp, SeqEntryPtr sep)
+{
+ BioseqSetPtr bssp;
+ if (pfp == NULL || sep == NULL) return;
+ if (IS_Bioseq_set (sep)) {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL && (bssp->_class == 7 ||
+ (IsPopPhyEtcSet (bssp->_class)))) {
+ for (sep = bssp->seq_set; sep != NULL; sep = sep->next) {
+ AddPrefixesToDefLines (pfp, sep);
+ }
+ return;
+ }
+ }
+ if (! IS_Bioseq (sep)) return;
+ AddPrefixesToOneDefLine (pfp, sep->data.ptrvalue, sep);
+}
+
+static void DoPrefixDefLines (ButtoN b)
+{
+ PrefixFormPtr pfp;
+ SeqEntryPtr sep;
+
+ pfp = GetObjectExtra (b);
+ if (pfp == NULL) return;
+
+ Hide (pfp->form);
+ WatchCursor ();
+ Update ();
+ sep = GetTopSeqEntryForEntityID (pfp->input_entityID);
+ if (sep == NULL) return;
+ AddPrefixesToDefLines (pfp, sep);
+
+ ArrowCursor ();
+ Update ();
+ ObjMgrSetDirtyFlag (pfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, pfp->input_entityID, 0, 0);
+}
+
+extern void PrefixDefLines (IteM i)
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+ ModifierItemLocalPtr modList;
+ Int4 index;
+ WindoW w;
+ GrouP h, g, k;
+ Int4 popup_index, item_index, listed_index;
+ GrouP c;
+ ButtoN b;
+ PrefixFormPtr pfp;
+ Char label [256];
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL || bfp->input_entityID == 0) return;
+
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+
+ modList = MemNew (NumDefLineModifiers * sizeof (ModifierItemLocalData));
+ if (modList == NULL) return;
+ CountModifiers (modList, sep);
+
+ pfp = MemNew (sizeof (PrefixFormData));
+ if (pfp == NULL) return;
+ pfp->input_entityID = bfp->input_entityID;
+ pfp->modList = modList;
+ pfp->popup_list = MemNew (sizeof (PopuP) * NumDefLineModifiers);
+ if (pfp->popup_list == NULL) return;
+
+ w = FixedWindow (-50, -33, -10, -10, "Definition Line Prefixes",
+ StdCloseWindowProc);
+ SetObjectExtra (w, pfp, CleanupPrefixForm);
+ pfp->form = (ForM) w;
+
+ h = HiddenGroup (w, -1, 0, NULL);
+ SetGroupSpacing (h, 10, 10);
+ g = HiddenGroup (h, 4, 0, NULL);
+ for (index = 0; index < NumDefLineModifiers; index++)
+ {
+ pfp->popup_list [index] = NULL;
+ }
+ popup_index = 0;
+ for (index = 0; index < NumDefLineModifiers; index++)
+ {
+ if (modList [ index].any_present)
+ {
+ k = HiddenGroup (g, 2, 0, NULL);
+ sprintf (label, "%d", popup_index + 1);
+ StaticPrompt (k, label, 0, popupMenuHeight, programFont, 'l');
+ pfp->popup_list[popup_index] = PopupList (k, TRUE, NULL);
+ listed_index = 0;
+ for (item_index = 0; item_index < NumDefLineModifiers; item_index ++)
+ {
+ if (modList [item_index].any_present)
+ {
+ PopupItem (pfp->popup_list[popup_index],
+ DefLineModifiers[item_index].name);
+ listed_index ++;
+ }
+ }
+ PopupItem (pfp->popup_list[popup_index], "Ignore");
+ listed_index++;
+ SetValue (pfp->popup_list[popup_index], listed_index);
+ popup_index ++;
+ }
+ }
+
+ pfp->add_org_name = CheckBox (h, "Prefix with taxonomy name", NULL);
+ SetStatus (pfp->add_org_name, TRUE);
+ pfp->use_labels = CheckBox (h, "Use modifier labels", NULL);
+ SetStatus (pfp->use_labels, TRUE);
+
+ c = HiddenGroup (h, 4, 0, NULL);
+ b = DefaultButton (c, "Accept", DoPrefixDefLines);
+ SetObjectExtra (b, pfp, NULL);
+ PushButton (c, "Cancel", StdCancelButtonProc);
+
+ AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) pfp->add_org_name,
+ (HANDLE) pfp->use_labels,
+ (HANDLE) c, NULL);
+ RealizeWindow (w);
+ Show (w);
+ Update ();
+
+}
+
diff --git a/sequin/sequin2.c b/sequin/sequin2.c
index 1447b8da..76e76662 100644
--- a/sequin/sequin2.c
+++ b/sequin/sequin2.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.146 $
+* $Revision: 6.155 $
*
* File Description:
*
@@ -1942,7 +1942,7 @@ static void LetUserFixNucleotideInfo (SequencesFormPtr sqfp)
MultiLinePrompt (fnfp->pptGrp, sourceModMsg, 25 * stdCharWidth, programFont);
c = HiddenGroup (h, 2, 0, NULL);
- b = PushButton (c, "OK", AcceptNucleotideFixup);
+ b = DefaultButton (c, "OK", AcceptNucleotideFixup);
SetObjectExtra (b, fnfp, NULL);
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) fnfp->modGrp,
@@ -2367,7 +2367,7 @@ static void LetUserFixProteinInfo (SequencesFormPtr sqfp)
}
c = HiddenGroup (w, 2, 0, NULL);
- acceptBtn = PushButton (c, "OK", AcceptThisFixup);
+ acceptBtn = DefaultButton (c, "OK", AcceptThisFixup);
SetObjectExtra (acceptBtn, fpfp, NULL);
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, (HANDLE) fpfp->orf, NULL);
@@ -2699,7 +2699,7 @@ extern Boolean ProcessOneNucleotideTitle (Int2 seqPackage, DialoG genbio, PopuP
biop->org = orp;
if (orp != NULL) {
TrimSpacesAroundString (str);
- orp->taxname = StringSave (str);
+ SetTaxNameAndRemoveTaxRef (orp, StringSave (str));
if (masterbiop != NULL) {
masterorp = masterbiop->org;
if (masterorp != NULL) {
@@ -2729,7 +2729,7 @@ extern Boolean ProcessOneNucleotideTitle (Int2 seqPackage, DialoG genbio, PopuP
orp = OrgRefNew ();
biop->org = orp;
if (orp != NULL) {
- orp->taxname = StringSave (masterorp->taxname);
+ SetTaxNameAndRemoveTaxRef (orp, StringSave (masterorp->taxname));
orp->common = StringSave (masterorp->common);
masteronp = masterorp->orgname;
if (masteronp != NULL) {
@@ -2952,7 +2952,7 @@ extern Boolean ProcessOneNucleotideTitle (Int2 seqPackage, DialoG genbio, PopuP
orp = OrgRefNew ();
biop->org = orp;
if (orp != NULL) {
- orp->taxname = StringSave (masterorp->taxname);
+ SetTaxNameAndRemoveTaxRef (orp, StringSave (masterorp->taxname));
orp->common = StringSave (masterorp->common);
onp = orp->orgname;
if (onp == NULL) {
@@ -6969,7 +6969,7 @@ extern void LoadTPAAccessionNumbersFromFile (
}
if (need_seqid)
{
- seqid_len = StringCSpn (str, " ");
+ seqid_len = StringCSpn (str, " \t");
if (seqid_len > 0)
{
StringNCpy (seqid, str, seqid_len);
@@ -6991,7 +6991,7 @@ extern void LoadTPAAccessionNumbersFromFile (
found_end = FALSE;
while (*cp != 0)
{
- if (*cp == ' ' || *cp == ',')
+ if (*cp == ' ' || *cp == ',' || *cp == '\t')
{
cp++;
}
@@ -7108,6 +7108,38 @@ static void AddHistory (
}
}
+static Boolean DoIDsMatch (CharPtr seqid, BioseqPtr bsp, Boolean AllowLocal)
+{
+ Char str [128];
+ Int4 seqid_len;
+ SeqIdPtr sip;
+
+ if (bsp == NULL) return FALSE;
+
+ SeqIdWrite (bsp->id, str, PRINTID_REPORT, sizeof (str));
+ seqid_len = StringCSpn (str, ".");
+ if (seqid_len > 0)
+ {
+ str [ seqid_len ] = 0;
+ }
+ if (StringCmp (str, seqid) == 0) return TRUE;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next)
+ {
+ if (sip->choice == SEQID_LOCAL && AllowLocal)
+ {
+ SeqIdWrite (bsp->id, str, PRINTID_REPORT, sizeof (str));
+ seqid_len = StringCSpn (str, ".");
+ if (seqid_len > 0)
+ {
+ str [ seqid_len ] = 0;
+ }
+ if (StringCmp (str, seqid) == 0) return TRUE;
+ }
+ }
+ return FALSE;
+}
+
static Boolean AddAccessionToGenbankBlock (
CharPtr seqid,
ValNodePtr acc_list,
@@ -7117,10 +7149,8 @@ static Boolean AddAccessionToGenbankBlock (
{
BioseqPtr bsp;
BioseqSetPtr bssp;
- Int4 seqid_len;
GBBlockPtr gbp;
ValNodePtr last_one;
- Char str [128];
SeqDescrPtr sdp;
if (seqid == NULL || acc_list == NULL
@@ -7145,13 +7175,7 @@ static Boolean AddAccessionToGenbankBlock (
bsp = (BioseqPtr) sep->data.ptrvalue;
if (bsp == NULL) return FALSE;
- SeqIdWrite (bsp->id, str, PRINTID_REPORT, sizeof (str));
- seqid_len = StringCSpn (str, ".");
- if (seqid_len > 0)
- {
- str [ seqid_len ] = 0;
- }
- if (StringCmp (str, seqid) != 0) return FALSE;
+ if (! DoIDsMatch (seqid, bsp, TRUE)) return FALSE;
sdp = BioseqGetSeqDescr (bsp, Seq_descr_genbank, NULL);
@@ -7321,3 +7345,393 @@ extern void LoadHistoryAccessionNumbersFromFile (
LoadSecondaryAccessionNumbersPlusHistFromFile (i, TRUE);
}
+/* This section of code is used for managing lists of features.
+ * Sometimes the features will be displayed alphabetically, sometimes
+ * they will be displayed alphabetically with a list of the most used features
+ * also appearing at the top of the list.
+ */
+
+/* This is used to compare feature names with the special alphabetical order */
+static int CompareFeatureNames (CharPtr cp1, CharPtr cp2)
+{
+ /* NULL name goes at the end */
+ if (cp1 == NULL && cp2 == NULL) return 0;
+ if (cp1 == NULL) return 1;
+ if (cp2 == NULL) return -1;
+
+ /* starts with a space goes at the beginning */
+ if (cp1 [0] == ' ' && cp2 [0] == ' ') return 0;
+ if (cp1 [0] == ' ') return -1;
+ if (cp2 [0] == ' ') return 1;
+
+ /* Is "All" or [ALL FEATURES] goes at the beginning */
+ if ((StringCmp (cp1, "All") == 0
+ || StringCmp (cp1, "[ALL FEATURES]") == 0)
+ && (StringCmp (cp2, "All") == 0
+ || StringCmp (cp2, "[ALL FEATURES]") == 0))
+ {
+ return 0;
+ }
+ if (StringCmp (cp1, "All") == 0
+ || StringCmp (cp1, "[ALL FEATURES]") == 0)
+ {
+ return -1;
+ }
+ if (StringCmp (cp2, "All") == 0
+ || StringCmp (cp2, "[ALL FEATURES]") == 0)
+ {
+ return 1;
+ }
+
+ /* starts with a number -> goes at the end */
+ if (cp1 [0] >= '0' && cp1 [0] <= '9'
+ && cp2 [0] >= '0' && cp2 [0] <= '9')
+ {
+ return StringICmp (cp1, cp2);
+ }
+ if (cp1 [0] >= '0' && cp1 [0] <= '9')
+ {
+ return 1;
+ }
+ if (cp2 [0] >= '0' && cp2 [0] <= '9')
+ {
+ return -1;
+ }
+
+ /* starts with a tilde or dash - sort with other tildes, put before numbers after alphas */
+ if (cp1 [0] == '~' && cp2 [0] == '~')
+ {
+ return StringICmp (cp1 + 1, cp2 + 1);
+ }
+ if (cp1 [0] == '~') return 1;
+ if (cp2 [0] == '~') return -1;
+
+ if (cp1 [0] == '-' && cp2 [0] == '-')
+ {
+ return StringICmp (cp1 + 1, cp2 + 1);
+ }
+ if (cp1 [0] == '-') return 1;
+ if (cp2 [0] == '-') return -1;
+
+ return StringICmp (cp1, cp2);
+}
+
+extern int LIBCALLBACK CompareFeatureValNodeStrings (VoidPtr ptr1, VoidPtr ptr2)
+{
+ ValNodePtr vnp1, vnp2;
+
+ if (ptr1 == NULL || ptr2 == NULL) return 0;
+
+ vnp1 = *((ValNodePtr PNTR) ptr1);
+ vnp2 = *((ValNodePtr PNTR) ptr2);
+
+ if (vnp1 == NULL || vnp2 == NULL) return 0;
+
+ return CompareFeatureNames (vnp1->data.ptrvalue, vnp2->data.ptrvalue);
+}
+
+extern int LIBCALLBACK CompareImpFeatEnumFieldAssoc (VoidPtr ptr1, VoidPtr ptr2)
+{
+ ValNodePtr vnp1, vnp2;
+ EnumFieldAssocPtr ap1, ap2;
+
+ if (ptr1 == NULL || ptr2 == NULL) return 0;
+
+ vnp1 = *((ValNodePtr PNTR) ptr1);
+ vnp2 = *((ValNodePtr PNTR) ptr2);
+ if (vnp1 == NULL || vnp2 == NULL) return 0;
+
+ ap1 = (EnumFieldAssocPtr) vnp1->data.ptrvalue;
+ ap2 = (EnumFieldAssocPtr) vnp2->data.ptrvalue;
+ if (ap1 == NULL || ap2 == NULL) return 0;
+
+ return CompareFeatureNames (ap1->name, ap2->name);
+}
+
+CharPtr MostUsedFeatureList[] = {
+ "CDS",
+ "exon",
+ "Gene",
+ "intron",
+ "mRNA",
+ "rRNA",
+ "RNA"
+};
+
+extern ValNodePtr InsertMostUsedFeatureValNodes (ValNodePtr old_list)
+{
+ ValNodePtr new_list, new_item, old_item;
+ Int4 index;
+
+ new_list = NULL;
+ for (index = 0;
+ index < sizeof (MostUsedFeatureList) / sizeof (CharPtr);
+ index ++)
+ {
+ old_item = FindExactStringInStrings ( old_list, MostUsedFeatureList [index])
+;
+ if (old_item == NULL) continue;
+ new_item = ValNodeNew ( new_list);
+ if (new_item == NULL) return old_list;
+ new_item->choice = old_item->choice;
+ new_item->data.ptrvalue = StringSave (MostUsedFeatureList [index]);
+ if (new_list == NULL) new_list = new_item;
+ }
+ if (new_item != NULL)
+ {
+ if (old_list != NULL &&
+ ( StringCmp (old_list->data.ptrvalue, "All") == 0
+ || StringCmp (old_list->data.ptrvalue, "[ALL FEATURES]") == 0))
+ {
+ new_item->next = old_list->next;
+ old_list->next = new_list;
+ new_list = old_list;
+ }
+ else
+ {
+ new_item->next = old_list;
+ }
+ }
+ else
+ {
+ new_list = old_list;
+ }
+ return new_list;
+}
+
+static EnumFieldAssocPtr FindEnumFieldAssoc (
+ EnumFieldAssocPtr alist,
+ CharPtr findStr
+)
+{
+ EnumFieldAssocPtr ap;
+
+ for (ap = alist; ap != NULL && ap->name != NULL; ap++)
+ {
+ if (StringCmp (ap->name, findStr) == 0) return ap;
+ }
+ return NULL;
+}
+
+static void CopyEnumFieldAssoc (EnumFieldAssocPtr ap1, EnumFieldAssocPtr ap2)
+{
+ if (ap1 == NULL || ap2 == NULL) return;
+
+ ap1->name = StringSave (ap2->name);
+ ap1->value = ap2->value;
+}
+
+extern EnumFieldAssocPtr InsertMostUsedFeatureEnumFieldAssoc (
+ EnumFieldAssocPtr alist
+)
+{
+ Int4 num_total_fields, index, new_index;
+ EnumFieldAssocPtr ap, new_alist, old_ap;
+
+ num_total_fields = sizeof (MostUsedFeatureList) / sizeof (CharPtr);
+
+ for (ap = alist; ap != NULL && ap->name != NULL; ap++)
+ {
+ num_total_fields ++;
+ }
+ /* need the last null field */
+ num_total_fields ++;
+
+ new_alist = MemNew (num_total_fields * sizeof (EnumFieldAssoc));
+ if (new_alist == NULL) return alist;
+
+ /* copy the first item if wildcard */
+ if (StringCmp (alist->name, "[ALL FEATURES]") == 0)
+ {
+ CopyEnumFieldAssoc (new_alist, alist);
+ new_index = 1;
+ }
+ else
+ {
+ new_index = 0;
+ }
+
+ for (index = 0;
+ index < sizeof (MostUsedFeatureList) / sizeof (CharPtr);
+ index ++)
+ {
+ old_ap = FindEnumFieldAssoc (alist, MostUsedFeatureList [index]);
+ if (old_ap == NULL) continue;
+ CopyEnumFieldAssoc (new_alist + new_index++, old_ap);
+ }
+
+ for (ap = alist; ap != NULL && ap->name != NULL; ap++)
+ {
+ CopyEnumFieldAssoc (new_alist + new_index ++, ap);
+ }
+ /* copy over the last null field */
+ if (ap != NULL)
+ {
+ CopyEnumFieldAssoc (new_alist + new_index ++, ap);
+ }
+ return new_alist;
+
+}
+
+extern void SortEnumFieldAssocPtrArray (EnumFieldAssocPtr alist, CompareFunc compar)
+{
+ ValNodePtr head, vnp;
+ EnumFieldAssocPtr ap;
+ Int4 index;
+
+ /* first, create ValNode list so we can sort the data */
+ head = NULL;
+ for (ap = alist; ap != NULL && ap->name != NULL; ap++)
+ {
+ vnp = ValNodeNew (head);
+ if (vnp == NULL) return;
+ vnp->data.ptrvalue = MemNew (sizeof (EnumFieldAssoc));
+ if (vnp->data.ptrvalue == NULL) return;
+ MemCpy (vnp->data.ptrvalue, ap, sizeof (EnumFieldAssoc));
+ if (head == NULL) head = vnp;
+ }
+
+ /* Now sort the ValNode list */
+ head = SortValNode (head, compar);
+
+ /* Now repopulate the EnumFieldAssoc list */
+ index = 0;
+ for (vnp = head; vnp != NULL; vnp = vnp->next)
+ {
+ MemCpy (alist + index++, vnp->data.ptrvalue, sizeof (EnumFieldAssoc));
+ }
+
+ /* And free the ValNode list */
+ ValNodeFreeData (head);
+}
+
+static Uint2 UnusualFeatureTypes [] = {
+ FEATDEF_ORG,
+ FEATDEF_mutation,
+ FEATDEF_site_ref,
+ FEATDEF_gap,
+ FEATDEF_NON_STD_RESIDUE,
+ FEATDEF_NUM
+};
+
+extern ValNodePtr BuildFeatureValNodeList (
+ Boolean prefer_most_used,
+ CharPtr wild_card_name,
+ Int4 wild_card_value,
+ Boolean skip_unusual,
+ Boolean skip_import
+)
+{
+ FeatDefPtr curr;
+ ValNodePtr head, vnp;
+ Uint1 key;
+ CharPtr label = NULL;
+ Uint2 subtype;
+ Int4 index;
+ Boolean skip;
+ Char str [256];
+
+ head = NULL;
+ curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
+ while (curr != NULL) {
+ skip = FALSE;
+ if (skip_unusual)
+ {
+ for (index = 0;
+ ! skip && index < sizeof ( UnusualFeatureTypes ) / sizeof (Uint2);
+ index ++)
+ {
+ if (curr->featdef_key == UnusualFeatureTypes [ index ]) skip = TRUE;
+ }
+ }
+ if (key != FEATDEF_BAD && ! skip) {
+
+ subtype = curr->featdef_key;
+ if (subtype != FEATDEF_misc_RNA &&
+ subtype != FEATDEF_precursor_RNA &&
+ subtype != FEATDEF_mat_peptide &&
+ subtype != FEATDEF_sig_peptide &&
+ subtype != FEATDEF_transit_peptide &&
+ subtype != FEATDEF_Imp_CDS)
+ {
+ StringNCpy_0 (str, curr->typelabel, sizeof (str) - 1);
+ }
+ else if (! skip_import)
+ {
+ StringNCpy_0 (str, curr->typelabel, sizeof (str) - 10);
+ StringCat (str, "_imp");
+ }
+ else
+ {
+ skip = TRUE;
+ }
+ if (! skip)
+ {
+ vnp = ValNodeNew (head);
+ if (head == NULL) {
+ head = vnp;
+ }
+ if (vnp != NULL) {
+ vnp->choice = subtype;
+ vnp->data.ptrvalue = StringSave (str);
+ }
+ }
+ }
+ curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
+ }
+ if (head != NULL) {
+ head = SortValNode (head, CompareFeatureValNodeStrings);
+ head = InsertMostUsedFeatureValNodes (head);
+ if (wild_card_name != NULL)
+ {
+ vnp = ValNodeNew (NULL);
+ if (vnp != NULL) {
+ vnp->choice = wild_card_value;
+ vnp->data.ptrvalue = StringSave (wild_card_name);
+ vnp->next = head;
+ head = vnp;
+ }
+ }
+ }
+ return head;
+}
+
+extern void SetTaxNameAndRemoveTaxRef (OrgRefPtr orp, CharPtr taxname)
+{
+ ValNodePtr vnp, next;
+ ValNodePtr PNTR prev;
+ DbtagPtr dbt;
+ Boolean remove_taxrefs;
+
+ if (orp == NULL) return;
+
+ if ( taxname == NULL || orp->taxname == NULL
+ || StringCmp (taxname, orp->taxname) != 0)
+ {
+ remove_taxrefs = TRUE;
+ }
+ MemFree (orp->taxname);
+ orp->taxname = taxname;
+
+ if (! remove_taxrefs) return;
+
+ orp->common = MemFree (orp->common);
+
+ vnp = orp->db;
+ if (vnp == NULL) return;
+ prev = (ValNodePtr PNTR) &(orp->db);
+ while (vnp != NULL) {
+ next = vnp->next;
+ dbt = (DbtagPtr) vnp->data.ptrvalue;
+ if (dbt != NULL && StringICmp ((CharPtr) dbt->db, "taxon") == 0) {
+ *prev = vnp->next;
+ vnp->next = NULL;
+ DbtagFree (dbt);
+ ValNodeFree (vnp);
+ } else {
+ prev = (ValNodePtr PNTR) &(vnp->next);
+ }
+ vnp = next;
+ }
+}
+
diff --git a/sequin/sequin3.c b/sequin/sequin3.c
index b8d5ef57..bc951a19 100644
--- a/sequin/sequin3.c
+++ b/sequin/sequin3.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.302 $
+* $Revision: 6.347 $
*
* File Description:
*
@@ -49,6 +49,7 @@
#include <import.h>
#include <gather.h>
#include <asn2gnbk.h>
+#include <asn2gnbp.h>
#include <edutil.h>
#include <gbfeat.h>
#include <gbftdef.h>
@@ -1087,19 +1088,30 @@ static ValNodePtr RemoveDbxrefList (ValNodePtr vnp)
return NULL;
}
-static void DoRemoveGeneDbxrefs (SeqFeatPtr sfp, Pointer userdata)
+static void DoRemoveDbxrefs (SeqFeatPtr sfp, Pointer userdata)
{
GeneRefPtr grp;
+ Uint1 feattype;
- if (sfp->data.choice != SEQFEAT_GENE) return;
+ if (sfp == NULL) return;
+
+ if (userdata != NULL && (feattype = *(Uint1 PNTR)userdata) != sfp->data.choice) return;
sfp->dbxref = RemoveDbxrefList (sfp->dbxref);
+ if (sfp->data.choice != SEQFEAT_GENE) return;
grp = (GeneRefPtr) sfp->data.value.ptrvalue;
if (grp == NULL) return;
grp->db = RemoveDbxrefList (grp->db);
}
-static void RemoveGeneDbxrefs (IteM i)
+static void DoRemoveBioSourceDbxrefs (BioSourcePtr biop, Pointer userdata)
+{
+ if (biop == NULL || biop->org == NULL) return;
+
+ biop->org->db = RemoveDbxrefList (biop->org->db);
+}
+
+static void RemoveDbxrefsCommon (IteM i, Uint1 PNTR subtype)
{
BaseFormPtr bfp;
@@ -1113,11 +1125,42 @@ static void RemoveGeneDbxrefs (IteM i)
if (bfp == NULL) return;
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
if (sep == NULL) return;
- VisitFeaturesInSep (sep, NULL, DoRemoveGeneDbxrefs);
+ VisitFeaturesInSep (sep, subtype, DoRemoveDbxrefs);
+ if (subtype == NULL)
+ {
+ VisitBioSourcesInSep (sep, NULL, DoRemoveBioSourceDbxrefs);
+ }
ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
+static void RemoveGeneDbxrefs (IteM i)
+{
+ Uint1 subtype = SEQFEAT_GENE;
+ RemoveDbxrefsCommon (i, &subtype);
+}
+
+static void RemoveRNADbxrefs (IteM i)
+
+{
+ Uint1 subtype = SEQFEAT_RNA;
+
+ RemoveDbxrefsCommon (i, &subtype);
+}
+
+static void RemoveCDSDbxrefs (IteM i)
+
+{
+ Uint1 subtype = FEATDEF_CDS;
+ RemoveDbxrefsCommon (i, &subtype);
+}
+
+static void RemoveAllDbxrefs (IteM i)
+
+{
+ RemoveDbxrefsCommon (i, NULL);
+}
+
static void RemoveCDDRegions (IteM i)
{
@@ -1234,9 +1277,10 @@ static void LastDitchLookup (BioSourcePtr biop)
if (ssp != NULL) {
ssp->subtype = 255;
ssp->name = orp->taxname;
+ orp->taxname = NULL;
ssp->next = biop->subtype;
biop->subtype = ssp;
- orp->taxname = StringSave (orgname);
+ SetTaxNameAndRemoveTaxRef (orp, StringSave (orgname));
}
}
@@ -1958,7 +2002,7 @@ static Boolean AlistMessage (EnumFieldAssocPtr al, UIEnumPtr val, UIEnum dflt, C
InitEnumPopup (alistBoxPopup, al, NULL);
SetEnumPopup (alistBoxPopup, al, dflt);
c = HiddenGroup (g, 2, 0, NULL);
- PushButton (c, "Accept", AcceptAlistMessage);
+ DefaultButton (c, "Accept", AcceptAlistMessage);
PushButton (c, "Cancel", CancelAlistMessage);
AlignObjects (ALIGN_CENTER, (HANDLE) ppt, (HANDLE) alistBoxPopup, (HANDLE) c, NULL);
RealizeWindow (w);
@@ -2229,7 +2273,7 @@ static void MultiTransformProc (IteM i, Uint2 targettype)
}
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoMultiTransform);
+ b = DefaultButton (c, "Accept", DoMultiTransform);
SetObjectExtra (b, mfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -3603,7 +3647,7 @@ static void ZapRBSGene (SeqFeatPtr sfp, Pointer userdata)
if (sfp->idx.subtype != FEATDEF_RBS) return;
grp = SeqMgrGetGeneXref (sfp);
- if (grp != NULL) return;
+ if (grp != NULL && (! SeqMgrGeneIsSuppressed (grp))) return;
gene = SeqMgrGetOverlappingGene (sfp->location, &gcontext);
if (gene == NULL) return;
diff = SeqLocAinB (sfp->location, gene->location);
@@ -3945,6 +3989,7 @@ static void CopyBankitComments (IteM i)
}
static ENUM_ALIST(molinfo_biomol_alist)
+ {"Any", 254},
{" ", 0},
{"Genomic DNA or RNA", 1},
{"Precursor RNA", 2},
@@ -3963,6 +4008,7 @@ static ENUM_ALIST(molinfo_biomol_alist)
END_ENUM_ALIST
static ENUM_ALIST(molinfo_tech_alist)
+ {"Any", 254},
{" ", 0},
{"Standard", 1},
{"EST", 2},
@@ -3988,6 +4034,7 @@ static ENUM_ALIST(molinfo_tech_alist)
END_ENUM_ALIST
static ENUM_ALIST(molinfo_complete_alist)
+ {"Any", 254},
{" ", 0},
{"Complete", 1},
{"Partial", 2},
@@ -3998,6 +4045,7 @@ static ENUM_ALIST(molinfo_complete_alist)
END_ENUM_ALIST
static ENUM_ALIST(mol_alist)
+{"Any", Seq_mol_other - 1},
{" ", 0},
{"DNA", Seq_mol_dna},
{"RNA", Seq_mol_rna},
@@ -4007,6 +4055,7 @@ static ENUM_ALIST(mol_alist)
END_ENUM_ALIST
static ENUM_ALIST(topology_alist)
+{"Any", 254},
{" ", 0},
{"Linear", TOPOLOGY_LINEAR},
{"Circular", TOPOLOGY_CIRCULAR},
@@ -4015,6 +4064,7 @@ static ENUM_ALIST(topology_alist)
END_ENUM_ALIST
static ENUM_ALIST(strand_alist)
+{"Any", 254},
{" ", Seq_strand_unknown},
{"Single", Seq_strand_plus},
{"Double", Seq_strand_minus},
@@ -4023,15 +4073,122 @@ static ENUM_ALIST(strand_alist)
{"Other", Seq_strand_other},
END_ENUM_ALIST
+static ValNodePtr MakeValNodeListFromEnum ( EnumFieldAssocPtr al)
+{
+ EnumFieldAssocPtr efap;
+ ValNodePtr list;
+
+ efap = al;
+ list = NULL;
+ while (efap->name != NULL)
+ {
+ ValNodeAddStr (&list, efap->value, StringSave (efap->name));
+ efap ++;
+ }
+ return list;
+}
+
+static void ReplaceValNodeString (ValNodePtr list, CharPtr find, CharPtr repl)
+{
+ ValNodePtr vnp;
+
+ if (list == NULL || find == NULL || repl == NULL) return;
+
+ for (vnp = list; vnp != NULL; vnp = vnp->next)
+ {
+ if (StringCmp (vnp->data.ptrvalue, find) == 0)
+ {
+ MemFree (vnp->data.ptrvalue);
+ vnp->data.ptrvalue = StringSave (repl);
+ }
+ }
+}
+
+static void InitValNodePopup (ValNodePtr list, PopuP p)
+{
+ ValNodePtr vnp;
+
+ for (vnp = list; vnp != NULL; vnp = vnp->next)
+ {
+ if (vnp->data.ptrvalue != NULL)
+ {
+ PopupItem (p, vnp->data.ptrvalue);
+ }
+ }
+}
+
+static Int2 GetValNodePopup (PopuP p, ValNodePtr list)
+{
+ ValNodePtr vnp;
+ Int2 popupval;
+
+ popupval = GetValue (p);
+ if (popupval == 0)
+ {
+ return -1;
+ }
+ for (vnp = list; vnp != NULL && popupval > 1; vnp = vnp->next)
+ {
+ if (vnp->data.ptrvalue != NULL)
+ {
+ popupval --;
+ }
+ }
+ if (popupval > 1 || vnp == NULL) return -1;
+ return vnp->choice;
+}
+
+static void SetValNodePopupValue (ValNodePtr list, PopuP p, CharPtr val)
+{
+ ValNodePtr vnp;
+ Int2 popupval;
+
+ popupval = 1;
+ for (vnp = list; vnp != NULL; vnp = vnp->next)
+ {
+ if (vnp->data.ptrvalue != NULL)
+ {
+ if (StringCmp (vnp->data.ptrvalue, val) == 0)
+ {
+ SetValue (p, popupval);
+ }
+ popupval ++;
+ }
+ }
+}
+
typedef struct molinfoblock {
PopuP moltype;
+ ValNodePtr moltype_values;
PopuP technique;
+ ValNodePtr technique_values;
PopuP complete;
+ ValNodePtr complete_values;
PopuP molPopup;
+ ValNodePtr mol_values;
PopuP topologyPopup;
+ ValNodePtr topology_values;
PopuP strandPopup;
+ ValNodePtr strand_values;
} MolInfoBlock, PNTR MolInfoBlockPtr;
+static void FreeMolInfoBlockData (MolInfoBlockPtr mibp)
+{
+ if (mibp == NULL) return;
+ ValNodeFreeData (mibp->moltype_values);
+ mibp->moltype_values = NULL;
+ ValNodeFreeData (mibp->technique_values);
+ mibp->technique_values = NULL;
+ ValNodeFreeData (mibp->complete_values);
+ mibp->complete_values = NULL;
+ ValNodeFreeData (mibp->mol_values);
+ mibp->mol_values = NULL;
+ ValNodeFreeData (mibp->topology_values);
+ mibp->topology_values = NULL;
+ ValNodeFreeData (mibp->strand_values);
+ mibp->strand_values = NULL;
+}
+
typedef struct molinfoedit {
DESCRIPTOR_FORM_BLOCK
SeqEntryPtr sep;
@@ -4047,7 +4204,20 @@ static CharPtr labels [] = {
"Class", "Topology", "Strand", NULL
};
-static void CreateMolInfoBlock (MolInfoBlockPtr mibp, GrouP h)
+static void SetupMolInfoBlockPopup (GrouP g, PopuP PNTR p, ValNodePtr PNTR v,
+ EnumFieldAssocPtr al, Boolean IsTo)
+{
+ *p = PopupList (g, TRUE, NULL);
+ *v = MakeValNodeListFromEnum ( al );
+ if (IsTo)
+ {
+ ReplaceValNodeString (*v, "Any", "No change");
+ }
+ InitValNodePopup (*v, *p);
+ SetValue (*p, 1);
+}
+
+static void CreateMolInfoBlock (MolInfoBlockPtr mibp, GrouP h, Boolean IsTo)
{
GrouP g;
@@ -4061,31 +4231,50 @@ static void CreateMolInfoBlock (MolInfoBlockPtr mibp, GrouP h)
g = HiddenGroup (h, -2, 0, NULL);
StaticPrompt (g, "Molecule", wid, popupMenuHeight, programFont, 'l');
- mibp->moltype = PopupList (g, TRUE, NULL);
- InitEnumPopup (mibp->moltype, molinfo_biomol_alist, NULL);
- SetEnumPopup (mibp->moltype, molinfo_biomol_alist, 0);
+ SetupMolInfoBlockPopup (g, &(mibp->moltype), &(mibp->moltype_values),
+ molinfo_biomol_alist, IsTo);
StaticPrompt (g, "Technique", wid, popupMenuHeight, programFont, 'l');
- mibp->technique = PopupList (g, TRUE, NULL);
- InitEnumPopup (mibp->technique, molinfo_tech_alist, NULL);
- SetEnumPopup (mibp->technique, molinfo_tech_alist, 0);
+ SetupMolInfoBlockPopup (g, &(mibp->technique), &(mibp->technique_values),
+ molinfo_tech_alist, IsTo);
StaticPrompt (g, "Completedness", wid, popupMenuHeight, programFont, 'l');
- mibp->complete = PopupList (g, TRUE, NULL);
- InitEnumPopup (mibp->complete, molinfo_complete_alist, NULL);
- SetEnumPopup (mibp->complete, molinfo_complete_alist, 0);
+ SetupMolInfoBlockPopup (g, &(mibp->complete), &(mibp->complete_values),
+ molinfo_complete_alist, IsTo);
StaticPrompt (g, "Class", wid, popupMenuHeight, programFont, 'l');
- mibp->molPopup = PopupList (g, TRUE, NULL);
- InitEnumPopup (mibp->molPopup, mol_alist, NULL);
+ SetupMolInfoBlockPopup (g, &(mibp->molPopup), &(mibp->mol_values),
+ mol_alist, IsTo);
StaticPrompt (g, "Topology", wid, popupMenuHeight, programFont, 'l');
- mibp->topologyPopup = PopupList (g, TRUE, NULL);
- InitEnumPopup (mibp->topologyPopup, topology_alist, NULL);
+ SetupMolInfoBlockPopup (g, &(mibp->topologyPopup), &(mibp->topology_values),
+ topology_alist, IsTo);
StaticPrompt (g, "Strand", wid, popupMenuHeight, programFont, 'l');
- mibp->strandPopup = PopupList (g, TRUE, NULL);
- InitEnumPopup (mibp->strandPopup, strand_alist, NULL);
+ SetupMolInfoBlockPopup (g, &(mibp->strandPopup), &(mibp->strand_values),
+ strand_alist, IsTo);
+}
+
+static void SetMolInfoBlockWildCard ( MolInfoBlockPtr mibp )
+{
+ if (mibp == NULL) return;
+ SetValue (mibp->moltype, 1);
+ SetEnumPopup (mibp->technique, molinfo_tech_alist, 0);
+ SetEnumPopup (mibp->complete, molinfo_complete_alist, 0);
+ SetValue (mibp->molPopup, 1);
+ SetValue (mibp->topologyPopup, 1);
+ SetValue (mibp->strandPopup, 1);
+}
+
+static void SetMolInfoBlockDefault ( MolInfoBlockPtr mibp )
+{
+ if (mibp == NULL) return;
+ SetEnumPopup (mibp->moltype, molinfo_biomol_alist, 0);
+ SetEnumPopup (mibp->technique, molinfo_tech_alist, 0);
+ SetEnumPopup (mibp->complete, molinfo_complete_alist, 0);
+ SetEnumPopup (mibp->molPopup, mol_alist, 0);
+ SetEnumPopup (mibp->topologyPopup, topology_alist, 0);
+ SetEnumPopup (mibp->strandPopup, strand_alist, 0);
}
static void EditMolInfoCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
@@ -4095,7 +4284,6 @@ static void EditMolInfoCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, In
MolInfoEditPtr miep;
MolInfoPtr mip;
ValNodePtr sdp;
- UIEnum val;
if (mydata == NULL) return;
if (sep == NULL || sep->data.ptrvalue == NULL) return;
@@ -4110,22 +4298,34 @@ static void EditMolInfoCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, In
bsp = (BioseqPtr) sep->data.ptrvalue;
if ((ISA_na (bsp->mol) && miep->nucsOK) ||
(ISA_aa (bsp->mol) && miep->protsOK)) {
- if (GetEnumPopup (miep->from.molPopup, mol_alist, &val) &&
- bsp->mol == (Uint1) val) {
- if (GetEnumPopup (miep->to.molPopup, mol_alist, &val)) {
- bsp->mol = (Uint1) val;
+ if ((Uint1)GetValNodePopup (miep->from.molPopup,
+ miep->from.mol_values) == bsp->mol
+ || GetValue (miep->from.molPopup) == 1)
+ {
+ if (GetValue (miep->to.molPopup) != 1)
+ {
+ bsp->mol = (Uint1) GetValNodePopup (miep->to.molPopup,
+ miep->to.mol_values);
}
}
- if (GetEnumPopup (miep->from.strandPopup, strand_alist, &val) &&
- bsp->strand == (Uint1) val) {
- if (GetEnumPopup (miep->to.strandPopup, strand_alist, &val)) {
- bsp->strand = (Uint1) val;
+ if ((Uint1)GetValNodePopup (miep->from.strandPopup,
+ miep->to.strand_values) == bsp->strand
+ || GetValue (miep->from.strandPopup) == 1)
+ {
+ if (GetValue (miep->to.strandPopup) != 1)
+ {
+ bsp->strand = (Uint1) GetValNodePopup (miep->to.strandPopup,
+ miep->to.strand_values);
}
}
- if (GetEnumPopup (miep->from.topologyPopup, topology_alist, &val) &&
- bsp->topology == (Uint1) val) {
- if (GetEnumPopup (miep->to.topologyPopup, topology_alist, &val)) {
- bsp->topology = (Uint1) val;
+ if ((Uint1) GetValNodePopup (miep->from.topologyPopup,
+ miep->from.topology_values) == bsp->topology
+ || GetValue (miep->from.topologyPopup) == 1)
+ {
+ if (GetValue (miep->to.topologyPopup) != 1)
+ {
+ bsp->topology = (Uint1) GetValNodePopup (miep->to.topologyPopup,
+ miep->to.topology_values);
}
}
sdp = bsp->descr;
@@ -4137,28 +4337,40 @@ static void EditMolInfoCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, In
}
sdp = bssp->descr;
} else {
- return;
+ return;
}
while (sdp != NULL) {
if (sdp->choice == Seq_descr_molinfo && sdp->data.ptrvalue != NULL) {
mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (GetEnumPopup (miep->from.moltype, molinfo_biomol_alist, &val) &&
- mip->biomol == (Uint1) val) {
- if (GetEnumPopup (miep->to.moltype, molinfo_biomol_alist, &val)) {
- mip->biomol = (Uint1) val;
+ if ((Uint2) GetValNodePopup (miep->from.moltype,
+ miep->from.moltype_values) == mip->biomol
+ || GetValue (miep->from.moltype) == 1)
+ {
+ if ( GetValue (miep->to.moltype) != 1)
+ {
+ mip->biomol = (Uint1) GetValNodePopup (miep->to.moltype,
+ miep->to.moltype_values);
}
}
- if (GetEnumPopup (miep->from.technique, molinfo_tech_alist, &val) &&
- mip->tech == (Uint1) val) {
- if (GetEnumPopup (miep->to.technique, molinfo_tech_alist, &val)) {
- mip->tech = (Uint1) val;
+ if ((Uint1) GetValNodePopup (miep->from.technique,
+ miep->from.technique_values) == mip->tech
+ || GetValue (miep->from.technique) == 1)
+ {
+ if ( GetValue (miep->to.technique) != 1)
+ {
+ mip->tech = (Uint1) GetValNodePopup (miep->to.technique,
+ miep->to.technique_values);
}
}
- if (GetEnumPopup (miep->from.complete, molinfo_complete_alist, &val) &&
- mip->completeness == (Uint1) val) {
- if (GetEnumPopup (miep->to.complete, molinfo_complete_alist, &val)) {
- mip->completeness = (Uint1) val;
+ if ((Uint1) GetValNodePopup (miep->from.complete,
+ miep->from.complete_values) == mip->completeness
+ || GetValue (miep->from.complete) == 1)
+ {
+ if ( GetValue (miep->to.complete) != 1)
+ {
+ mip->completeness = (Uint1) GetValNodePopup (miep->to.complete,
+ miep->to.complete_values);
}
}
}
@@ -4181,6 +4393,8 @@ static void DoProcessEditMolInfo (ButtoN b)
miep->nucsOK = (Boolean) (val == 1 || val == 2);
miep->protsOK = (Boolean) (val == 1 || val == 3);
SeqEntryExplore (miep->sep, (Pointer) miep, EditMolInfoCallback);
+ FreeMolInfoBlockData (&(miep->from));
+ FreeMolInfoBlockData (&(miep->to));
ArrowCursor ();
Update ();
ObjMgrSetDirtyFlag (miep->input_entityID, TRUE);
@@ -4225,18 +4439,18 @@ static void EditMolInfoFields (IteM i)
RadioButton (miep->constraint, "All Sequences");
RadioButton (miep->constraint, "Nucleotides");
RadioButton (miep->constraint, "Proteins");
- SetValue (miep->constraint, 1);
+ SetValue (miep->constraint, 2);
g = HiddenGroup (w, 2, 0, NULL);
h = HiddenGroup (g, 0, 2, NULL);
StaticPrompt (h, "From", 0, 0, programFont, 'c');
- CreateMolInfoBlock (&miep->from, h);
+ CreateMolInfoBlock (&miep->from, h, FALSE);
h = HiddenGroup (g, 0, 2, NULL);
StaticPrompt (h, "To", 0, 0, programFont, 'c');
- CreateMolInfoBlock (&miep->to, h);
+ CreateMolInfoBlock (&miep->to, h, TRUE);
c = HiddenGroup (w, 2, 0, NULL);
- b = PushButton (c, "Accept", DoProcessEditMolInfo);
+ b = DefaultButton (c, "Accept", DoProcessEditMolInfo);
SetObjectExtra (b, miep, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) k, (HANDLE) g, (HANDLE) c, NULL);
@@ -4245,13 +4459,78 @@ static void EditMolInfoFields (IteM i)
Update ();
}
+static void RibosomalRNAToGenomicDNAVisitFunc (
+ BioseqPtr bsp,
+ Pointer userdata
+)
+{
+ SeqDescrPtr sdp;
+ MolInfoPtr mip;
+ SeqMgrDescContext dcontext;
+
+ if (bsp == NULL) return;
+
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_molinfo, &dcontext);
+ if (sdp == NULL
+ || sdp->choice != Seq_descr_molinfo
+ || sdp->data.ptrvalue == NULL)
+ {
+ return;
+ }
+ mip = (MolInfoPtr) sdp->data.ptrvalue;
+ if (mip->biomol == MOLECULE_TYPE_RRNA)
+ {
+ mip->biomol = MOLECULE_TYPE_GENOMIC;
+ bsp->mol = MOLECULE_CLASS_DNA;
+ bsp->strand = 0;
+ bsp->topology = 0;
+ }
+}
+
+static void RibosomalRNAToGenomicDNA (BaseFormPtr bfp)
+{
+ SeqEntryPtr sep;
+
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+
+ VisitBioseqsInSep (sep, NULL, RibosomalRNAToGenomicDNAVisitFunc);
+
+ Update ();
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
+
+static void RibosomalRNAToGenomicDNAMenuItem (IteM i)
+{
+ BaseFormPtr bfp;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+
+ RibosomalRNAToGenomicDNA (bfp);
+}
+
+static void RibosomalRNAToGenomicDNAToolBtn (ButtoN b)
+{
+ BaseFormPtr bfp;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+
+ RibosomalRNAToGenomicDNA (bfp);
+}
+
static void DoApplyMolInfo (SeqEntryPtr sep, MolInfoEditPtr miep)
{
BioseqPtr bsp;
BioseqSetPtr bssp;
MolInfoPtr mip;
- UIEnum val;
ValNodePtr vnp;
if (sep == NULL || sep->data.ptrvalue == NULL || miep == NULL) return;
@@ -4274,14 +4553,20 @@ static void DoApplyMolInfo (SeqEntryPtr sep, MolInfoEditPtr miep)
bsp = (BioseqPtr) sep->data.ptrvalue;
if ((ISA_na (bsp->mol) && miep->nucsOK) ||
(ISA_aa (bsp->mol) && miep->protsOK)) {
- if (GetEnumPopup (miep->to.molPopup, mol_alist, &val) && val > 0) {
- bsp->mol = (Uint1) val;
+ if ( GetValue (miep->to.molPopup) != 1)
+ {
+ bsp->mol = (Uint1) GetValNodePopup (miep->to.molPopup,
+ miep->to.mol_values);
}
- if (GetEnumPopup (miep->to.strandPopup, strand_alist, &val) && val > 0) {
- bsp->strand = (Uint1) val;
+ if ( GetValue (miep->to.strandPopup) != 1)
+ {
+ bsp->strand = (Uint1) GetValNodePopup (miep->to.strandPopup,
+ miep->to.strand_values);
}
- if (GetEnumPopup (miep->to.topologyPopup, topology_alist, &val) && val > 0) {
- bsp->topology = (Uint1) val;
+ if (GetValue (miep->to.topologyPopup) != 1)
+ {
+ bsp->topology = (Uint1) GetValNodePopup (miep->to.topologyPopup,
+ miep->to.topology_values);
}
} else return;
} else if (IS_Bioseq_set (sep)) {
@@ -4295,14 +4580,20 @@ static void DoApplyMolInfo (SeqEntryPtr sep, MolInfoEditPtr miep)
vnp = CreateNewDescriptor (sep, Seq_descr_molinfo);
if (vnp != NULL) {
vnp->data.ptrvalue = (Pointer) mip;
- if (GetEnumPopup (miep->to.moltype, molinfo_biomol_alist, &val)) {
- mip->biomol = (Uint1) val;
+ if ( GetValue (miep->to.moltype) != 1)
+ {
+ mip->biomol = (Uint1) GetValNodePopup (miep->to.moltype,
+ miep->to.moltype_values);
}
- if (GetEnumPopup (miep->to.technique, molinfo_tech_alist, &val)) {
- mip->tech = (Uint1) val;
+ if ( GetValue (miep->to.technique) != 1)
+ {
+ mip->tech = (Uint1) GetValNodePopup (miep->to.technique,
+ miep->to.technique_values);
}
- if (GetEnumPopup (miep->to.complete, molinfo_complete_alist, &val)) {
- mip->completeness = (Uint1) val;
+ if ( GetValue (miep->to.complete) != 1)
+ {
+ mip->completeness = (Uint1) GetValNodePopup (miep->to.complete,
+ miep->to.complete_values);
}
}
}
@@ -4322,6 +4613,7 @@ static void DoProcessApplyMolInfo (ButtoN b)
miep->nucsOK = (Boolean) (val == 1);
miep->protsOK = (Boolean) (val == 2);
DoApplyMolInfo (miep->sep, miep);
+ FreeMolInfoBlockData (&miep->to);
ArrowCursor ();
Update ();
ObjMgrSetDirtyFlag (miep->input_entityID, TRUE);
@@ -4369,10 +4661,10 @@ static void ApplyMolInfo (IteM i)
g = HiddenGroup (w, 2, 0, NULL);
h = HiddenGroup (g, 0, 2, NULL);
- CreateMolInfoBlock (&miep->to, h);
+ CreateMolInfoBlock (&miep->to, h, TRUE);
c = HiddenGroup (w, 2, 0, NULL);
- b = PushButton (c, "Accept", DoProcessApplyMolInfo);
+ b = DefaultButton (c, "Accept", DoProcessApplyMolInfo);
SetObjectExtra (b, miep, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) k, (HANDLE) g, (HANDLE) c, NULL);
@@ -4634,7 +4926,7 @@ static ForM CreateBioseqSetEditForm (BioseqSetPtr bssp, Uint2 entityID)
}
c = HiddenGroup (w, 2, 0, NULL);
- b = PushButton (c, "Accept", AcceptBioseqSetEditProc);
+ b = DefaultButton (c, "Accept", AcceptBioseqSetEditProc);
SetObjectExtra (b, bsfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) h, (HANDLE) c, NULL);
@@ -4671,6 +4963,273 @@ extern Int2 LIBCALLBACK BioseqSetEditFunc (Pointer data)
}
/*#ifdef EXTRA_SERVICES*/
+static CharPtr ReadALine (CharPtr str, size_t size, FILE *fp)
+
+{
+ Char ch;
+ CharPtr ptr;
+ CharPtr rsult;
+
+ if (str == NULL || size < 1 || fp == NULL) return NULL;
+ *str = '\0';
+ rsult = FileGets (str, size, fp);
+ if (rsult != NULL) {
+ ptr = str;
+ ch = *ptr;
+ while (ch != '\0' && ch != '\n' && ch != '\r') {
+ ptr++;
+ ch = *ptr;
+ }
+ *ptr = '\0';
+ }
+ return rsult;
+}
+
+static ValNodePtr UniqueAndCountValNodeCS (ValNodePtr list)
+
+{
+ Int4 count;
+ ValNodePtr curr;
+ CharPtr last;
+ size_t len;
+ ValNodePtr next;
+ Pointer PNTR prev;
+ CharPtr str;
+ CharPtr tmp;
+ ValNodePtr vnp;
+
+ if (list == NULL) return NULL;
+ last = (CharPtr) list->data.ptrvalue;
+ vnp = list->next;
+ if (vnp == NULL) return list;
+ prev = (Pointer PNTR) &(list->next);
+ count = 1;
+ curr = list;
+ while (vnp != NULL) {
+ next = vnp->next;
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (StringCmp (last, str) == 0) {
+ vnp->next = NULL;
+ *prev = next;
+ ValNodeFreeData (vnp);
+ count++;
+ } else {
+ len = StringLen (last) + 20;
+ tmp = (CharPtr) MemNew (len);
+ if (tmp != NULL) {
+ sprintf (tmp, "%6ld %s", (long) count, last);
+ curr->data.ptrvalue = MemFree (curr->data.ptrvalue);
+ curr->data.ptrvalue = tmp;
+ }
+ last = (CharPtr) vnp->data.ptrvalue;
+ prev = (Pointer PNTR) &(vnp->next);
+ count = 1;
+ curr = vnp;
+ }
+ vnp = next;
+ }
+ len = StringLen (last) + 20;
+ tmp = (CharPtr) MemNew (len);
+ if (tmp != NULL) {
+ sprintf (tmp, "%6ld %s", (long) count, last);
+ curr->data.ptrvalue = MemFree (curr->data.ptrvalue);
+ curr->data.ptrvalue = tmp;
+ }
+
+ return list;
+}
+
+static int LIBCALLBACK SortVnpByStringCS (VoidPtr ptr1, VoidPtr ptr2)
+
+{
+ CharPtr str1;
+ CharPtr str2;
+ ValNodePtr vnp1;
+ ValNodePtr vnp2;
+
+ if (ptr1 != NULL && ptr2 != NULL) {
+ vnp1 = *((ValNodePtr PNTR) ptr1);
+ vnp2 = *((ValNodePtr PNTR) ptr2);
+ if (vnp1 != NULL && vnp2 != NULL) {
+ str1 = (CharPtr) vnp1->data.ptrvalue;
+ str2 = (CharPtr) vnp2->data.ptrvalue;
+ if (str1 != NULL && str2 != NULL) {
+ return StringCmp (str1, str2);
+ }
+ }
+ }
+ return 0;
+}
+
+static int LIBCALLBACK SortVnpByChoiceAndStringCS (VoidPtr ptr1, VoidPtr ptr2)
+
+{
+ CharPtr str1;
+ CharPtr str2;
+ ValNodePtr vnp1;
+ ValNodePtr vnp2;
+
+ if (ptr1 != NULL && ptr2 != NULL) {
+ vnp1 = *((ValNodePtr PNTR) ptr1);
+ vnp2 = *((ValNodePtr PNTR) ptr2);
+ if (vnp1 != NULL && vnp2 != NULL) {
+ str1 = (CharPtr) vnp1->data.ptrvalue;
+ str2 = (CharPtr) vnp2->data.ptrvalue;
+ if (str1 != NULL && str2 != NULL) {
+ if (vnp1->choice > vnp2->choice) {
+ return 1;
+ } else if (vnp1->choice < vnp2->choice) {
+ return -1;
+ }
+ return StringCmp (str1, str2);
+ }
+ }
+ }
+ return 0;
+}
+
+static ValNodePtr SortFlatFile (ValNodePtr head, Boolean reverse, Boolean byblock)
+
+{
+ ValNodePtr next;
+ ValNodePtr tail = NULL;
+ ValNodePtr vnp;
+
+ if (head == NULL) return NULL;
+
+ if (byblock) {
+ head = ValNodeSort (head, SortVnpByChoiceAndStringCS);
+ } else {
+ head = ValNodeSort (head, SortVnpByStringCS);
+ }
+ if (reverse) {
+ for (vnp = head; vnp != NULL; vnp = next) {
+ next = vnp->next;
+ vnp->next = tail;
+ tail = vnp;
+ }
+ head = tail;
+ } else {
+ head = UniqueAndCountValNodeCS (head);
+ }
+
+ return head;
+}
+
+static void CaptureFFLine (CharPtr str, Pointer userdata, BlockType blocktype)
+
+{
+ Char ch;
+ CharPtr copy;
+ ValNodePtr PNTR head;
+ CharPtr ptr;
+ CharPtr tmp;
+ ValNodePtr vnp;
+
+ head = (ValNodePtr PNTR) userdata;
+ copy = StringSaveNoNull (str);
+ if (copy == NULL) return;
+
+ ptr = copy;
+ tmp = StringChr (ptr, '\n');
+ while (tmp != NULL) {
+ ch = *tmp;
+ *tmp = '\0';
+ vnp = ValNodeCopyStr (NULL, (Uint1) blocktype, ptr);
+ if (*head == NULL) {
+ *head = vnp;
+ } else {
+ vnp->next = *head;
+ *head = vnp;
+ }
+ *tmp = ch;
+ tmp++;
+ ptr = tmp;
+ tmp = StringChr (ptr, '\n');
+ }
+
+ MemFree (copy);
+}
+
+static void SUCCommonProc (IteM i, Boolean reverse, Boolean byblock, ButtoN b)
+
+{
+ BaseFormPtr bfp;
+ FILE *fp;
+ ValNodePtr head = NULL;
+ ErrSev level;
+ Boolean okay;
+ SeqEntryPtr oldscope;
+ Char path [PATH_MAX];
+ SeqEntryPtr sep;
+ CharPtr str;
+ ValNodePtr vnp;
+ XtraBlock xtra;
+
+ if (b != NULL) {
+ bfp = GetObjectExtra (b);
+ } else {
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ }
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+ WatchCursor ();
+ Update ();
+ MemSet ((Pointer) &xtra, 0, sizeof (XtraBlock));
+ xtra.ffwrite = CaptureFFLine;
+ xtra.userdata = (Pointer) &head;
+ level = ErrSetMessageLevel (SEV_MAX);
+ oldscope = SeqEntrySetScope (sep);
+ okay = SeqEntryToGnbk (sep, NULL, GENBANK_FMT, SEQUIN_MODE, NORMAL_STYLE, 0, 0, 0, &xtra, NULL);
+ SeqEntrySetScope (oldscope);
+ ErrSetMessageLevel (level);
+ if (okay) {
+ head = SortFlatFile (head, FALSE, byblock);
+ if (reverse) {
+ head = SortFlatFile (head, TRUE, FALSE);
+ }
+ TmpNam (path);
+ fp = FileOpen (path, "w");
+ if (fp != NULL) {
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ fprintf (fp, "%s\n", str);
+ }
+ FileClose (fp);
+ }
+ LaunchGeneralTextViewer (path, "Sort Unique Count");
+ FileRemove (path);
+ ValNodeFreeData (head);
+ }
+ ArrowCursor ();
+ Update ();
+}
+
+static void SUCProc (IteM i)
+
+{
+ SUCCommonProc (i, FALSE, FALSE, NULL);
+}
+
+static void SUCRProc (IteM i)
+
+{
+ SUCCommonProc (i, TRUE, FALSE, NULL);
+}
+
+static void SUCBProc (IteM i)
+
+{
+ SUCCommonProc (i, FALSE, TRUE, NULL);
+}
+/*#endif*/
+
+#if 0
#ifdef OS_UNIX
extern void SUCCommonProc (IteM i, Boolean reverse, ButtoN b);
extern void SUCCommonProc (IteM i, Boolean reverse, ButtoN b)
@@ -4737,7 +5296,7 @@ static void SUCRProc (IteM i)
SUCCommonProc (i, TRUE, NULL);
}
#endif
-/*#endif*/
+#endif
/*#ifdef INTERNAL_NCBI_SEQUIN*/
/*#ifdef NEW_TAXON_SERVICE*/
@@ -4755,37 +5314,28 @@ static void SUCRProc (IteM i)
* Then add version number to top of each file
*/
-static void WriteTaxNode (CharPtr sci, CharPtr com, CharPtr syn,
- Int4 gc, Int4 mgc, CharPtr div,
- Int4 taxID, FILE *fout)
+static Boolean WriteTaxNode (CharPtr sci, CharPtr com, CharPtr syn,
+ Int4 gc, Int4 mgc, CharPtr div,
+ Int4 taxID, FILE *fout)
{
Char str [256];
- if (fout == NULL) return;
+ if (fout == NULL) return FALSE;
if (sci != NULL && sci [0] != '\0') {
if (div == NULL || div [0] == '\0') div = "???";
if (com != NULL && com [0] != '\0') {
sprintf (str, "%s\t%s\t%ld\t%ld\t%s\t%ld\n", sci, com,
(long) gc, (long) mgc, div, (long) taxID);
fprintf (fout, "%s", str);
- /*
- sprintf (str, "%s\tC\t%s\t%ld\t%ld\t%s\t%ld\n", com, sci,
- (long) gc, (long) mgc, div, (long) taxID);
- fprintf (fout, "%s", str);
- */
- /*
- } else if (syn != NULL && syn [0] != '\0') {
- sprintf (str, "%s\tC\t%s\t%ld\t%ld\t%s\t%ld\n", syn, sci,
- (long) gc, (long) mgc, div, (long) taxID);
- fprintf (fout, "%s", str);
- */
} else {
sprintf (str, "%s\t\t%ld\t%ld\t%s\t%ld\n", sci,
(long) gc, (long) mgc, div, (long) taxID);
fprintf (fout, "%s", str);
}
+ return TRUE;
}
+ return FALSE;
}
static void WriteLineage (Int4 taxID, CharPtr lineage, FILE *fout)
@@ -4800,6 +5350,7 @@ static void ProcessTaxNode (CharPtr orgname, FILE *fout1, FILE *fout2)
{
Int4 gc;
Int4 mgc;
+ OrgModPtr omp;
OrgNamePtr onp;
OrgRefPtr orp;
Int4 taxID;
@@ -4822,10 +5373,18 @@ static void ProcessTaxNode (CharPtr orgname, FILE *fout1, FILE *fout2)
if (onp != NULL) {
gc = onp->gcode;
mgc = onp->mgcode;
- WriteLineage (taxID, onp->lineage, fout2);
}
- WriteTaxNode (orp->taxname, orp->common, NULL, gc,
- mgc, tdp->div, taxID, fout1);
+ if (WriteTaxNode (orp->taxname, orp->common, NULL, gc, mgc, tdp->div, taxID, fout1)) {
+ if (onp != NULL) {
+ WriteLineage (taxID, onp->lineage, fout2);
+ for (omp = onp->mod; omp != NULL; omp = omp->next) {
+ if (omp->subtype == ORGMOD_gb_anamorph ||
+ omp->subtype == ORGMOD_gb_synonym) {
+ WriteTaxNode (omp->subname, orp->common, NULL, gc, mgc, tdp->div, taxID, fout1);
+ }
+ }
+ }
+ }
/*
vnp = orp->syn;
while (vnp != NULL) {
@@ -5251,7 +5810,7 @@ static void ProcessPub (IteM i, Int2 type)
}
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoProcessPub);
+ b = DefaultButton (c, "Accept", DoProcessPub);
SetObjectExtra (b, pfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -5422,6 +5981,242 @@ static void RemoveSeqHistAssembly (IteM i)
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
+static void LeaveFirstAssemblyProc (BioseqPtr bsp, Pointer userdata)
+
+{
+ SeqHistPtr hist;
+ SeqAlignPtr next;
+ SeqAlignPtr sap;
+
+ hist = bsp->hist;
+ if (hist == NULL) return;
+ sap = hist->assembly;
+ if (sap == NULL) return;
+ next = sap->next;
+ if (next == NULL) return;
+ sap->next = NULL;
+ SeqAlignFree (next);
+}
+
+static void LeaveFirstSeqHistAssembly (IteM i)
+
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+ VisitBioseqsInSep (sep, NULL, LeaveFirstAssemblyProc);
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
+
+static void FindTPAAccns (SeqDescrPtr sdp, Pointer userdata)
+
+{
+ UserFieldPtr curr;
+ ValNodePtr PNTR head;
+ ObjectIdPtr oip;
+ CharPtr str;
+ UserFieldPtr ufp;
+ UserObjectPtr uop;
+ ValNodePtr vnp;
+
+ if (sdp == NULL || sdp->choice != Seq_descr_user) return;
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ if (uop == NULL) return;
+ oip = uop->type;
+ if (oip == NULL) return;
+ if (StringCmp (oip->str, "TpaAssembly") != 0) return;
+ head = (ValNodePtr PNTR) userdata;
+ if (head == NULL) return;
+ for (curr = uop->data; curr != NULL; curr = curr->next) {
+ if (curr->choice != 11) continue;
+ for (ufp = curr->data.ptrvalue; ufp != NULL; ufp = ufp->next) {
+ if (ufp->choice != 1) continue;
+ oip = ufp->label;
+ if (oip == NULL || StringICmp (oip->str, "accession") != 0) continue;
+ str = (CharPtr) ufp->data.ptrvalue;
+ if (StringHasNoText (str)) continue;
+ vnp = ValNodeCopyStr (NULL, 0, str);
+ vnp->next = *head;
+ *head = vnp;
+ }
+ }
+}
+
+typedef struct streamfsa {
+ FILE *fp;
+ Char buf [128];
+ Int2 idx;
+ Int2 maxlen;
+} StreamFsa, PNTR StreamFsaPtr;
+
+static void LIBCALLBACK FsaStreamProc (
+ CharPtr sequence,
+ Pointer userdata
+)
+
+{
+ Char ch;
+ StreamFsaPtr sfp;
+
+ if (StringHasNoText (sequence) || userdata == NULL) return;
+ sfp = (StreamFsaPtr) userdata;
+
+ ch = *sequence;
+ while (ch != '\0') {
+ sfp->buf [sfp->idx] = ch;
+ (sfp->idx)++;
+
+ if (sfp->idx >= sfp->maxlen) {
+ sfp->buf [sfp->idx] = '\0';
+ fprintf (sfp->fp, "%s\n", sfp->buf);
+ sfp->idx = 0;
+ }
+
+ sequence++;
+ ch = *sequence;
+ }
+}
+
+static void StreamFastaForBsp (BioseqPtr bsp, FILE *fp)
+
+{
+ Char id [41];
+ StreamFsa sf;
+
+ if (bsp == NULL || fp == NULL) return;
+
+ id [0] = '\0';
+ SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
+ fprintf (fp, ">%s\n", id);
+
+ MemSet ((Pointer) &sf, 0, sizeof (StreamFsa));
+ sf.fp = fp;
+ sf.idx = 0;
+ sf.maxlen = 60;
+ SeqPortStream (bsp, TRUE, (Pointer) &sf, FsaStreamProc);
+
+ if (sf.idx > 0) {
+ sf.buf [sf.idx] = '\0';
+ fprintf (fp, "%s\n", sf.buf);
+ }
+}
+
+static void CreateTPABlastDB (IteM i)
+
+{
+ BaseFormPtr bfp;
+ BioseqPtr bsp;
+ FILE *fp;
+ ValNodePtr head = NULL;
+ Char path [PATH_MAX];
+ SeqEntryPtr sep;
+ SeqIdPtr sip;
+ CharPtr str;
+ ValNodePtr vnp;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+ VisitDescriptorsInSep (sep, (Pointer) &head, FindTPAAccns);
+ if (head == NULL) return;
+ head = ValNodeSort (head, SortVnpByString);
+ head = UniqueValNode (head);
+ if (! GetOutputFileName (path, sizeof (path), NULL)) return;
+ fp = FileOpen (path, "w");
+ if (fp == NULL) return;
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ str = (CharPtr) vnp->data.ptrvalue;
+ if (StringHasNoText (str)) continue;
+ Message (MSG_POST, "Making DB for %s", str);
+ sip = SeqIdFromAccessionDotVersion (str);
+ bsp = BioseqLockById (sip);
+ StreamFastaForBsp (bsp, fp);
+ BioseqUnlock (bsp);
+ }
+ FileClose (fp);
+ ValNodeFreeData (head);
+}
+
+static void FindBioseqForHist (SeqIdPtr sip, Pointer userdata)
+
+{
+ BioseqPtr bsp;
+ BioseqPtr PNTR bspp;
+
+ bsp = BioseqFindCore (sip);
+ if (bsp == NULL) return;
+ bspp = (BioseqPtr PNTR) userdata;
+ *bspp = bsp;
+}
+
+static void AttachSapToHistory (SeqAlignPtr sap)
+
+{
+ BioseqPtr bsp = NULL;
+ SeqHistPtr shp;
+
+ VisitSeqIdsInSeqAlign (sap, (Pointer) &bsp, FindBioseqForHist);
+ if (bsp == NULL) return;
+ shp = SeqHistNew ();
+ shp->assembly = sap;
+ bsp->hist = shp;
+}
+
+static void ReadSeqHistAssembly (IteM i)
+
+{
+ BaseFormPtr bfp;
+ Pointer dataptr;
+ Uint2 datatype;
+ FILE *fp;
+ Char path [PATH_MAX];
+ SeqAlignPtr salp;
+ SeqAnnotPtr sap;
+ SeqEntryPtr sep;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+ if (! GetInputFileName (path, sizeof (path), "", "TEXT")) return;
+ fp = FileOpen (path, "r");
+ if (fp == NULL) return;
+
+ while ((dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE, FALSE, TRUE, FALSE)) != NULL) {
+ if (datatype == OBJ_SEQANNOT) {
+ sap = (SeqAnnotPtr) dataptr;
+ if (sap != NULL && sap->type == 2) {
+ salp = (SeqAlignPtr) sap->data;
+ sap->data = NULL;
+ AttachSapToHistory (salp);
+ SeqAnnotFree (sap);
+ }
+ }
+ }
+
+ FileClose (fp);
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
+
typedef struct recondata {
BioseqPtr prod;
SeqFeatPtr cds;
@@ -5931,6 +6726,179 @@ static void LogLocation (SeqMgrFeatContextPtr context, FILE *fp)
}
}
+typedef struct correctgeneformdata {
+ FEATURE_FORM_BLOCK
+
+ ButtoN setIntervalBtn;
+ ButtoN setStrandBtn;
+ Boolean setInterval;
+ Boolean setStrand;
+ SeqEntryPtr sep;
+} CorrectGeneFormData, PNTR CorrectGeneFormPtr;
+
+typedef struct genesforcdsdata {
+ SeqFeatPtr cds;
+ ValNodePtr gene_list;
+} GenesForCDSData, PNTR GenesForCDSPtr;
+
+static void FindGenesForCDS (SeqFeatPtr sfp, Pointer userdata)
+{
+ GenesForCDSPtr gfc;
+ ValNodePtr vnp;
+
+ gfc = (GenesForCDSPtr) userdata;
+
+ if (gfc == NULL || sfp == NULL || sfp->idx.subtype != FEATDEF_GENE) return;
+
+ if (SeqLocAinB (gfc->cds->location, sfp->location) > -1
+ || SeqLocAinB (sfp->location, gfc->cds->location) > -1)
+ {
+ vnp = ValNodeNew (gfc->gene_list);
+ if (vnp == NULL) return;
+ vnp->data.ptrvalue = sfp;
+ if (gfc->gene_list == NULL)
+ {
+ gfc->gene_list = vnp;
+ }
+ }
+}
+
+static void SetSeqLocStrand (SeqLocPtr location, Uint2 strand)
+{
+ SeqLocPtr slp;
+ SeqIntPtr sip;
+ SeqPntPtr spp;
+
+ slp = SeqLocFindNext (location, NULL);
+ while (slp != NULL)
+ {
+ if (slp == NULL || slp->data.ptrvalue == NULL)
+ {
+ slp = SeqLocFindNext (location, slp);
+ continue;
+ }
+ if (slp->choice == SEQLOC_INT)
+ {
+ sip = (SeqIntPtr)slp->data.ptrvalue;
+ sip->strand = strand;
+ }
+ else if (slp->choice == SEQLOC_PNT)
+ {
+ spp = (SeqPntPtr)slp->data.ptrvalue;
+ spp->strand = strand;
+ }
+ slp = SeqLocFindNext (location, slp);
+ }
+}
+
+static void CorrectOneCDSGene (SeqFeatPtr sfp, Pointer userdata)
+{
+ CorrectGeneFormPtr cgp;
+ GenesForCDSData gfc;
+ SeqFeatPtr gene;
+ SeqLocPtr slp;
+ BioseqPtr bsp;
+
+ if (sfp == NULL || (cgp = (CorrectGeneFormPtr)userdata) == NULL) return;
+
+ gfc.cds = sfp;
+ gfc.gene_list = NULL;
+ VisitFeaturesInSep (cgp->sep, &gfc, FindGenesForCDS);
+
+ if (gfc.gene_list == NULL) return;
+ if (gfc.gene_list->next != NULL
+ || gfc.gene_list->data.ptrvalue == NULL)
+ {
+ ValNodeFree (gfc.gene_list);
+ return;
+ }
+
+ gene = gfc.gene_list->data.ptrvalue;
+ if (cgp->setInterval)
+ {
+ bsp = BioseqFindFromSeqLoc (sfp->location);
+ slp = SeqLocMerge (bsp, sfp->location, NULL, FALSE, TRUE, FALSE);
+ SeqLocFree (gene->location);
+ gene->location = slp;
+ }
+ if (cgp->setStrand)
+ {
+ SetSeqLocStrand (gene->location, SeqLocStrand (sfp->location));
+ }
+
+ ValNodeFree (gfc.gene_list);
+}
+
+static void CorrectGenesForCDSs (ButtoN b)
+{
+ CorrectGeneFormPtr cgp;
+
+ cgp = GetObjectExtra (b);
+ if (cgp == NULL) return;
+
+ Hide (cgp->form);
+ WatchCursor ();
+ Update ();
+
+ cgp->setStrand = GetStatus (cgp->setStrandBtn);
+ cgp->setInterval = GetStatus (cgp->setIntervalBtn);
+ cgp->sep = GetTopSeqEntryForEntityID (cgp->input_entityID);
+ VisitFeaturesInSep (cgp->sep, cgp, CorrectOneCDSGene);
+ ObjMgrSetDirtyFlag (cgp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, cgp->input_entityID, 0, 0);
+ ArrowCursor ();
+ Update ();
+
+}
+
+static void CorrectGenes (IteM i)
+{
+ BaseFormPtr bfp;
+ CorrectGeneFormPtr cgp;
+ WindoW w;
+ GrouP g, c;
+ ButtoN b;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+
+ cgp = MemNew (sizeof (CorrectGeneFormData));
+ if (cgp == NULL) return;
+
+ w = FixedWindow (-50, -33, -20, -10, "Correct Genes for CDSs",
+ StdCloseWindowProc);
+ SetObjectExtra (w, cgp, StdCleanupFormProc);
+ cgp->form = (ForM) w;
+
+ cgp->input_entityID = bfp->input_entityID;
+ cgp->input_itemID = bfp->input_itemID;
+ cgp->input_itemtype = bfp->input_itemtype;
+
+ g = HiddenGroup (w, -1, 0, NULL);
+ SetGroupSpacing (g, 10, 10);
+ cgp->setIntervalBtn = CheckBox (g, "Set gene interval to match CDS", NULL);
+ SetStatus (cgp->setIntervalBtn, TRUE);
+ cgp->setStrandBtn = CheckBox (g, "Set gene strand to match CDS", NULL);
+ SetStatus (cgp->setStrandBtn, TRUE);
+
+ c = HiddenGroup (g, 2, 0, NULL);
+ b = DefaultButton(c, "Accept", CorrectGenesForCDSs);
+ SetObjectExtra(b, cgp, NULL);
+ PushButton (c, "Cancel", StdCancelButtonProc);
+
+ AlignObjects (ALIGN_CENTER,
+ (HANDLE) cgp->setIntervalBtn,
+ (HANDLE) cgp->setStrandBtn,
+ (HANDLE) c, NULL);
+ RealizeWindow(w);
+ Show(w);
+ Update();
+}
+
static void ResetAllGenes (SeqEntryPtr sep,
Boolean doMinus, Boolean doPlus, FILE *fp)
{
@@ -5944,6 +6912,8 @@ static void ResetAllGenes (SeqEntryPtr sep,
BioseqPtr bsp;
SeqLocPtr slp;
SeqLocPtr tmpslp;
+ Boolean cds_partial5, cds_partial3;
+ Boolean partial5, partial3;
if (sep == NULL) return;
if ( IS_Bioseq_set (sep))
@@ -5968,6 +6938,8 @@ static void ResetAllGenes (SeqEntryPtr sep,
if (fcontext.strand != Seq_strand_minus && !doPlus)
continue;
slp = NULL;
+ partial3 = FALSE;
+ partial5 = FALSE;
/* look for next feature, starting right after the gene */
/* an overlapping CDS won't occur before the gene in the indexing */
cds = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &cdscontext);
@@ -5979,6 +6951,9 @@ static void ResetAllGenes (SeqEntryPtr sep,
&& cdscontext.strand != Seq_strand_minus))
&& SeqLocAinB (cds->location, gene->location) > -1)
{
+ CheckSeqLocForPartial (cds->location, &cds_partial5, &cds_partial3);
+ partial5 |= cds_partial5;
+ partial3 |= cds_partial3;
tmpslp = SeqLocMerge (bsp, cds->location, slp, TRUE, TRUE, FALSE);
if (tmpslp == NULL) return;
SeqLocFree (slp);
@@ -5990,6 +6965,7 @@ static void ResetAllGenes (SeqEntryPtr sep,
if (slp != NULL)
{
+ SetSeqLocPartial (slp, partial5, partial3);
if (fp != NULL
&& (SeqLocStart (gene->location) != SeqLocStart (slp)
|| SeqLocStop (gene->location) != SeqLocStop (slp)))
@@ -6598,7 +7574,7 @@ static void ExtendGeneReg (IteM i)
Disable (egfp->LogUnextendedEvents);
c = HiddenGroup (g, 2, 0, NULL);
- b = PushButton(c, "Accept", DoExtendGene);
+ b = DefaultButton(c, "Accept", DoExtendGene);
SetObjectExtra(b, egfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -6678,6 +7654,31 @@ static void ResynchronizePeptidePartials (IteM i)
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
+static void UnsetPartialForTruncatedProteins (SeqFeatPtr sfp, Pointer userdata)
+{
+ Boolean partial5, partial3;
+
+ if (sfp == NULL) return;
+ CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
+ SetSeqLocPartial (sfp->location, partial5, FALSE);
+}
+
+static void UnsetCDSPartialForTruncatedProteins (SeqFeatPtr sfp, Pointer userdata)
+{
+ Boolean partial5, partial3;
+ BioseqPtr product_bsp, prot_bsp;
+
+ if (sfp == NULL || sfp->data.choice != SEQFEAT_CDREGION
+ || sfp->location == NULL) return;
+ if ((prot_bsp = (BioseqPtr)userdata) == NULL) return;
+
+ product_bsp = BioseqFindFromSeqLoc (sfp->product);
+ if (product_bsp == prot_bsp) {
+ CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
+ SetSeqLocPartial (sfp->location, partial5, FALSE);
+ }
+}
+
static void TruncProtsCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
{
@@ -6686,6 +7687,8 @@ static void TruncProtsCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int
Int4 i;
Int2 residue;
SeqPortPtr spp;
+ Boolean found_stop;
+ SeqEntryPtr topsep;
if (! IS_Bioseq (sep)) return;
bsp = (BioseqPtr) sep->data.ptrvalue;
@@ -6693,6 +7696,8 @@ static void TruncProtsCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int
if (! ISA_aa (bsp->mol)) return;
if (bsp->repr != Seq_repr_raw && bsp->repr != Seq_repr_const) return;
+ topsep = (SeqEntryPtr) mydata;
+
bs = BSNew (1000);
if (bs == NULL) return;
spp = SeqPortNew (bsp, 0, -1, 0, Seq_code_ncbieaa);
@@ -6705,12 +7710,21 @@ static void TruncProtsCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int
i++;
residue = SeqPortGetResidue (spp);
}
+ if (residue == '*') {
+ found_stop = TRUE;
+ } else {
+ found_stop = FALSE;
+ }
SeqPortFree (spp);
bsp->seq_data = BSFree (bsp->seq_data);
bsp->seq_data = bs;
bsp->length = BSLen (bs);
bsp->seq_data_type = Seq_code_ncbieaa;
+ if (found_stop) {
+ VisitFeaturesOnBsp (bsp, NULL, UnsetPartialForTruncatedProteins);
+ VisitFeaturesInSep (topsep, bsp, UnsetCDSPartialForTruncatedProteins);
+ }
}
static void TruncProtsAtStops (IteM i)
@@ -6727,7 +7741,7 @@ static void TruncProtsAtStops (IteM i)
if (bfp == NULL) return;
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
if (sep == NULL) return;
- SeqEntryExplore (sep, NULL, TruncProtsCallback);
+ SeqEntryExplore (sep, sep, TruncProtsCallback);
ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
@@ -6794,6 +7808,27 @@ static void TrimProtFeatLengths (IteM i)
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
+static void FixProtsAndCDSsBasedOnStopCodons (IteM i, Boolean fix_genes)
+{
+ TruncProtsAtStops (i);
+ TrimProtFeatLengths (i);
+ RecomputeSuggest (i);
+ RetranslateCdRegionsNoStop (i);
+ if (fix_genes) {
+ DoGeneReset (i);
+ }
+}
+
+static void FixProtsAndCDSsBasedOnStopCodonsFixGenes (IteM i)
+{
+ FixProtsAndCDSsBasedOnStopCodons (i, TRUE);
+}
+
+static void FixProtsAndCDSsBasedOnStopCodonsNoFixGenes (IteM i)
+{
+ FixProtsAndCDSsBasedOnStopCodons (i, FALSE);
+}
+
static void TrimNucsCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
{
@@ -6829,6 +7864,21 @@ static void TrimNsFromNucs (IteM i)
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
+static void TrimNsFromNucsToolBtn (ButtoN b)
+
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+
+ if (b == NULL) return;
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+ SeqEntryExplore (sep, (Pointer) sep, TrimNucsCallback);
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
static Boolean s_NextQualifies (SeqFeatPtr sfp,
BioseqPtr bsp,
Int2 level,
@@ -7181,7 +8231,7 @@ static void ToolBtn2 (ButtoN b)
bfp = (BaseFormPtr) GetObjectExtra (b);
if (bfp == NULL) return;
- AutoDefBaseFormCommon (bfp, FALSE);
+ AutoDefBaseFormCommon (bfp, FALSE, TRUE);
}
/*
@@ -7288,15 +8338,11 @@ static void ToolBtn9 (ButtoN b)
WatchCursor ();
Update ();
GatherProcLaunch (OMPROC_EDIT, FALSE, bfp->input_entityID, bfp->input_itemID,
- bfp->input_itemtype, OBJ_SEQFEAT, FEATDEF_COMMENT, 0, 0);
+ bfp->input_itemtype, OBJ_SEQFEAT, FEATDEF_misc_feature, 0, 0);
ArrowCursor ();
Update ();
}
-#ifdef WIN_MOTIF
-extern void SUCCommonProc (IteM i, Boolean reverse, ButtoN b);
-#endif
-
static void ToolBtn10 (ButtoN b)
{
@@ -7305,9 +8351,7 @@ static void ToolBtn10 (ButtoN b)
bfp = (BaseFormPtr) GetObjectExtra (b);
if (bfp == NULL) return;
-#ifdef WIN_MOTIF
- SUCCommonProc (NULL, FALSE, b);
-#endif
+ SUCCommonProc (NULL, FALSE, TRUE, b);
}
static void ToolBtn11 (ButtoN b)
@@ -7536,6 +8580,8 @@ static ButtoN SqnPushButton (GrouP prnt, CharPtr title, BtnActnProc actn, BaseFo
return b;
}
+static void FixCapitalizationToolBtn (ButtoN b);
+
extern void BioseqViewFormToolBar (GrouP h)
{
@@ -7545,28 +8591,56 @@ extern void BioseqViewFormToolBar (GrouP h)
bfp = (BaseFormPtr) GetObjectExtra (h);
if (bfp == NULL) return;
g = HiddenGroup (h, 1, 0, NULL);
- SqnPushButton (g, "Save", ToolBtn1, bfp);
- SqnPushButton (g, "Auto_Def", ToolBtn2, bfp);
- if (useTaxon) {
- /* SqnPushButton (g, "Tax_Fix", ToolBtn3, bfp); */
- SqnPushButton (g, "Tax_Fix/Clean_Up", ToolBtn3, bfp);
- }
- SqnPushButton (g, "Def_Org", ToolBtn4, bfp);
- SqnPushButton (g, "CDS", ToolBtn5, bfp);
- SqnPushButton (g, "rRNA", ToolBtn6, bfp);
- SqnPushButton (g, "mRna_CDS", ToolBtn7, bfp);
- SqnPushButton (g, "ORF_Find", ToolBtn8, bfp);
- SqnPushButton (g, "misc_feat", ToolBtn9, bfp);
-#ifdef WIN_MOTIF
- SqnPushButton (g, "SUC", ToolBtn10, bfp);
-#endif
- SqnPushButton (g, "sub_affil", ToolBtn11, bfp);
- SqnPushButton (g, "sub_add", ToolBtn12, bfp);
- SqnPushButton (g, "cit-sub-upd", ToolBtn16, bfp);
- SqnPushButton (g, "del_GBbck", ToolBtn13, bfp);
- SqnPushButton (g, "rem_prot_titles", ToolBtn17, bfp);
- SqnPushButton (g, "Validate", ToolBtn14, bfp);
- SqnPushButton (g, "Desktop", ToolBtn15, bfp);
+ if (indexerVersion)
+ {
+ SqnPushButton (g, "Auto_Def", AutoDefToolBtn, bfp);
+ SqnPushButton (g, "Auto_Def Options", AutoDefOptionsToolBtn, bfp);
+ if (useTaxon) {
+ SqnPushButton (g, "Tax_Fix/Clean_Up", ToolBtn3, bfp);
+ }
+ SqnPushButton (g, "CDS", ToolBtn5, bfp);
+ SqnPushButton (g, "rRNA", ToolBtn6, bfp);
+ SqnPushButton (g, "misc_feat", ToolBtn9, bfp);
+ SqnPushButton (g, "mRna_CDS", ToolBtn7, bfp);
+ SqnPushButton (g, "ORF_Find", ToolBtn8, bfp);
+ SqnPushButton (g, "SUC", ToolBtn10, bfp);
+ SqnPushButton (g, "rRNA->DNA", RibosomalRNAToGenomicDNAToolBtn, bfp);
+ SqnPushButton (g, "Fix Caps", FixCapitalizationToolBtn, bfp);
+ SqnPushButton (g, "Remove DefLines", RemoveDefLinesToolBtn, bfp);
+ SqnPushButton (g, "Trim Ns", TrimNsFromNucsToolBtn, bfp);
+ SqnPushButton (g, "Find ASN.1", FindStringProcToolBtn, bfp);
+ SqnPushButton (g, "Local ID->Src", ParseLocalIDToSourceToolBtn, bfp);
+ SqnPushButton (g, "Fix Local IDs", ResolveExistingLocalIDsToolBtn, bfp);
+ SqnPushButton (g, "Group Explode", GroupExplodeToolBtn, bfp);
+ SqnPushButton (g, "cit-sub-upd", ToolBtn16, bfp);
+ SqnPushButton (g, "del_GBbck", ToolBtn13, bfp);
+ SqnPushButton (g, "rem_prot_titles", ToolBtn17, bfp);
+ SqnPushButton (g, "Validate", ToolBtn14, bfp);
+ SqnPushButton (g, "Desktop", ToolBtn15, bfp);
+ }
+ else
+ {
+ SqnPushButton (g, "Save", ToolBtn1, bfp);
+ SqnPushButton (g, "Auto_Def", ToolBtn2, bfp);
+ if (useTaxon) {
+ /* SqnPushButton (g, "Tax_Fix", ToolBtn3, bfp); */
+ SqnPushButton (g, "Tax_Fix/Clean_Up", ToolBtn3, bfp);
+ }
+ SqnPushButton (g, "Def_Org", ToolBtn4, bfp);
+ SqnPushButton (g, "CDS", ToolBtn5, bfp);
+ SqnPushButton (g, "rRNA", ToolBtn6, bfp);
+ SqnPushButton (g, "mRna_CDS", ToolBtn7, bfp);
+ SqnPushButton (g, "ORF_Find", ToolBtn8, bfp);
+ SqnPushButton (g, "misc_feat", ToolBtn9, bfp);
+ SqnPushButton (g, "SUC", ToolBtn10, bfp);
+ SqnPushButton (g, "sub_affil", ToolBtn11, bfp);
+ SqnPushButton (g, "sub_add", ToolBtn12, bfp);
+ SqnPushButton (g, "cit-sub-upd", ToolBtn16, bfp);
+ SqnPushButton (g, "del_GBbck", ToolBtn13, bfp);
+ SqnPushButton (g, "rem_prot_titles", ToolBtn17, bfp);
+ SqnPushButton (g, "Validate", ToolBtn14, bfp);
+ SqnPushButton (g, "Desktop", ToolBtn15, bfp);
+ }
}
static void MakeToolBarWindow (IteM i)
@@ -7959,7 +9033,7 @@ static ForM CreateGetNWindow (CdsDelFormPtr cdfp)
c = HiddenGroup (w, 4, 0, NULL);
SetGroupSpacing (c, 10, 2);
- b = PushButton (c, "Accept", RemoveNthCDS_AcceptCallback);
+ b = DefaultButton (c, "Accept", RemoveNthCDS_AcceptCallback);
SetObjectExtra (b, cdfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) j, (HANDLE) c, NULL);
@@ -8349,6 +9423,7 @@ static void FixCapitalizationInTitle (CharPtr PNTR pTitle)
static void FixCapitalizationInAuthor (AuthorPtr pAuthor)
{
NameStdPtr pNameStandard;
+ CharPtr cp;
if (pAuthor == NULL)
return;
@@ -8359,6 +9434,11 @@ static void FixCapitalizationInAuthor (AuthorPtr pAuthor)
{
FixCapitalizationInElement (&(pNameStandard->names[0]), FALSE, FALSE);
FixCapitalizationInElement (&(pNameStandard->names[1]), FALSE, FALSE);
+ /* Set initials to all caps */
+ for (cp = pNameStandard->names[4]; cp != NULL && *cp != 0; cp++)
+ {
+ *cp = toupper (*cp);
+ }
}
}
@@ -8367,6 +9447,7 @@ static void FixCapitalizationInAuthor (AuthorPtr pAuthor)
#define FIX_PUB_TITLE_CAPITALIZATION 4
#define FIX_PUB_AFFIL_CAPITALIZATION 8
#define FIX_SELECTED 16
+#define FIX_ALL 32
static void FixPubdesc (PubdescPtr pdp, Pointer userdata)
{
@@ -8396,7 +9477,7 @@ static void FixPubdesc (PubdescPtr pdp, Pointer userdata)
case PUB_Gen :
cgp = (CitGenPtr) vnp->data.ptrvalue;
if( !(cgp->cit != NULL && StringCmp(cgp->cit, "unpublished") != 0)
- && !(iType & FIX_SELECTED) ) return;
+ && !((iType & FIX_SELECTED) || (iType & FIX_ALL)) ) return;
alp = cgp->authors;
title = &(cgp->title);
break;
@@ -8406,7 +9487,7 @@ static void FixPubdesc (PubdescPtr pdp, Pointer userdata)
title = NULL;
break;
case PUB_Article :
- if( ! (iType & FIX_SELECTED)) return;
+ if ( !((iType & FIX_SELECTED) || (iType & FIX_ALL)) ) return;
cap = (CitArtPtr) vnp->data.ptrvalue;
alp = cap->authors;
if(cap->title != NULL)
@@ -8416,7 +9497,7 @@ static void FixPubdesc (PubdescPtr pdp, Pointer userdata)
break;
case PUB_Book :
case PUB_Man :
- if( ! (iType & FIX_SELECTED)) return;
+ if ( !((iType & FIX_SELECTED) || (iType & FIX_ALL)) ) return;
cbp = (CitBookPtr) vnp->data.ptrvalue;
alp = cbp->authors;
if(cbp->title != NULL)
@@ -8425,7 +9506,7 @@ static void FixPubdesc (PubdescPtr pdp, Pointer userdata)
}
break;
case PUB_Patent :
- if( ! (iType & FIX_SELECTED)) return;
+ if ( !((iType & FIX_SELECTED) || (iType & FIX_ALL)) ) return;
cpp = (CitPatPtr) vnp->data.ptrvalue;
alp = cpp->authors;
title = &(cpp->title);
@@ -8483,9 +9564,8 @@ static void FixPubdesc (PubdescPtr pdp, Pointer userdata)
}
/* This function is used to apply fixes to citations */
-static void FixPubs (IteM i, Int4 iType)
+static void FixPubs (BaseFormPtr bfp, Int4 iType)
{
- BaseFormPtr bfp;
SeqEntryPtr sep;
SelStructPtr sel;
SeqFeatPtr sfp;
@@ -8494,14 +9574,16 @@ static void FixPubs (IteM i, Int4 iType)
SeqMgrDescContext dcontext;
PubdescPtr pdp;
-#ifdef WIN_MAC
- bfp = currentFormDataPtr;
-#else
- bfp = GetObjectExtra (i);
-#endif
if (bfp == NULL) return;
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
- sel = ObjMgrGetSelected ();
+ if (iType & FIX_ALL)
+ {
+ sel = NULL;
+ }
+ else
+ {
+ sel = ObjMgrGetSelected ();
+ }
if(sel == NULL)
{
VisitPubdescsInSep (sep, (Pointer)iType, FixPubdesc);
@@ -8540,24 +9622,50 @@ static void FixPubs (IteM i, Int4 iType)
Update ();
}
+static void FixPubsMenuItem (IteM i, Int4 iType)
+{
+ BaseFormPtr bfp;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+
+ if (bfp == NULL) return;
+ FixPubs (bfp, iType);
+}
+
+static void FixCapitalizationToolBtn (ButtoN b)
+{
+ BaseFormPtr bfp;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+ FixPubs (bfp, FIX_PUB_AUTHOR_CAPITALIZATION
+ | FIX_PUB_TITLE_CAPITALIZATION
+ | FIX_PUB_AFFIL_CAPITALIZATION
+ | FIX_ALL);
+}
+
static void FixNameOrder (IteM i)
{
- FixPubs (i, FIX_AUTHOR_NAME_ORDER);
+ FixPubsMenuItem (i, FIX_AUTHOR_NAME_ORDER);
}
static void FixAuthorCapitalization (IteM i)
{
- FixPubs (i, FIX_PUB_AUTHOR_CAPITALIZATION);
+ FixPubsMenuItem (i, FIX_PUB_AUTHOR_CAPITALIZATION);
}
static void FixTitleCapitalization (IteM i)
{
- FixPubs (i, FIX_PUB_TITLE_CAPITALIZATION);
+ FixPubsMenuItem (i, FIX_PUB_TITLE_CAPITALIZATION);
}
static void FixAffiliationCapitalization (IteM i)
{
- FixPubs (i, FIX_PUB_AFFIL_CAPITALIZATION);
+ FixPubsMenuItem (i, FIX_PUB_AFFIL_CAPITALIZATION);
}
extern void LookupAllPubs (IteM i);
@@ -8610,6 +9718,8 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
#endif
i = CommandItem (x, "Default Options", testAutoDef);
SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (x, "No Modifiers", AutoDefWithoutModifiers);
+ SetObjectExtra (i, bfp, NULL);
i = CommandItem (x, "Select Options...", testAutoDefWithOptions);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
@@ -8628,6 +9738,8 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
SetObjectExtra (i, bfp, NULL);
i = CommandItem (x, "Cultivar", AddCultivarToDefLines);
SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (x, "List", PrefixDefLines);
+ SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
i = CommandItem (s, "Parse Def Line to Source", ParseDefToSource);
SetObjectExtra (i, bfp, NULL);
@@ -8657,6 +9769,9 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Append Modifier to Organism", AddModToOrg);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
+ i = CommandItem (s, "Trim Organism Name", TrimOrganismName);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
i = CommandItem (s, "Prefix Authority with Organism", PrefixAuthorityWithOrganism);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Parse Trinomial into Subspecies", ParseTrinomial);
@@ -8669,6 +9784,18 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Clear Source Focus", ClearSourceFocus);
SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
+ i = CommandItem (s, "Consolidate Organism Notes", ConsolidateOrganismNotes);
+ SetObjectExtra (i, bfp, NULL);
+ x = SubMenu (s, "Consolidate Like Modifiers");
+ i = CommandItem (x, "With semicolons", ConsolidateLikeModifiersWithSemicolons);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (x, "Without semicolons", ConsolidateLikeModifiersWithoutSemicolons);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
+ i = CommandItem (s, "Load Organism Modifiers from File",
+ LoadOrganismModifierTable);
+ SetObjectExtra (i, bfp, NULL);
s = SubMenu (m, "Apply/ A");
i = CommandItem (s, "Add CDS", ApplyCDS);
@@ -8742,9 +9869,6 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Remove ALL Gene Xrefs", RemoveAllGeneXrefs);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
- i = CommandItem (s, "Remove Gene Db_xrefs", RemoveGeneDbxrefs);
- SetObjectExtra (i, bfp, NULL);
- SeparatorItem (s);
i = CommandItem (s, "Remove CDD Regions", RemoveCDDRegions);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Remove CDD Alignments", RemoveCDDAligns);
@@ -8777,6 +9901,15 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Clear Gene Pseudo", ClearGenePseudo);
SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
+ i = CommandItem (s, "Remove Gene Db_xrefs", RemoveGeneDbxrefs);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Remove RNA Db_xrefs", RemoveRNADbxrefs);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Remove CDS Db_xrefs", RemoveCDSDbxrefs);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Remove ALL Db_xrefs", RemoveAllDbxrefs);
+ SetObjectExtra (i, bfp, NULL);
if (indexerVersion) {
SeparatorItem (s);
i = CommandItem (s, "Remove Local IDs from Bioseqs", RemoveLocalIDs);
@@ -8802,6 +9935,7 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
SeparatorItem (s);
i = CommandItem (s, "Convert Source Qual", ConvertSource);
SetObjectExtra (i, bfp, NULL);
+
i = CommandItem (s, "Convert CDS-Gene-Prot", ConvertCDSet);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Convert RNA Qual", ConvertRNA);
@@ -8829,6 +9963,18 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
+ i = CommandItem (s, "Parse Text from Local ID", ParseLocalIDToAnywhere);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
+
+ i = CommandItem (s, "Load Secondary Accession Numbers From File",
+ LoadSecondaryAccessionNumbersFromFile);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Load History Accession Numbers From File",
+ LoadHistoryAccessionNumbersFromFile);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
+
i = CommandItem (s, "BankIt Comment to Comment Descriptor", CopyBankitComments);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
@@ -8845,6 +9991,9 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Protein Description to Second Name", ProtDescToSecondName);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
+ i = CommandItem (s, "Change Ribosomal RNA to Genomic DNA", RibosomalRNAToGenomicDNAMenuItem);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
i = CommandItem (s, "Transform to Bond", TransformToBond);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Transform to Site", TransformToSite);
@@ -8879,10 +10028,24 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Edit Feature Strand", EditFeatureStrand);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
+ i = CommandItem (s, "Extend Partial Features", ExtendPartialFeatures);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
i = CommandItem (s, "Extend Gene", ExtendGeneReg);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Reset Genes to CDSs", DoGeneReset);
SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Correct Genes for CDSs", CorrectGenes);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
+ i = CommandItem (s, "Make Exons from CDS Intervals", MakeExonsFromCDSIntervals);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Make Exons from mRNA Intervals", MakeExonsFromMRNAIntervals);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
+ i = CommandItem (s, "Load Feature Qualifiers from File",
+ LoadFeatureQualifierTable);
+ SetObjectExtra (i, bfp, NULL);
if (indexerVersion) {
SeparatorItem (s);
i = CommandItem (s, "Edit Locus", EditLocusProc);
@@ -8975,14 +10138,18 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Process Oligonucleotide PCR Primers", ParseInOligoPrimers);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
- i = CommandItem (s, "Parse Table of Features", AutoParseFeatureTableProc);
+ x = SubMenu (s, "Adjust Proteins and CDSs for Stop Codons");
+ i = CommandItem (x, "With Gene Reset", FixProtsAndCDSsBasedOnStopCodonsFixGenes);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (x, "Without Gene Reset", FixProtsAndCDSsBasedOnStopCodonsNoFixGenes);
SetObjectExtra (i, bfp, NULL);
- SeparatorItem (s);
x = SubMenu (s, "Retranslate Coding Regions");
i = CommandItem (x, "Obey Stop Codon", RetranslateCdRegionsNoStop);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (x, "Ignore Stop Codon", RetranslateCdRegionsDoStop);
SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (x, "Ignore Stop Codon Except at End of Complete CDS", RetranslateCdRegionsNoStopExceptEndCompleteCDS);
+ SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Retranscribe mRNA Products", ReprocessmRNAProducts);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Regenerate Peptide Products", ReprocessPeptideProducts);
@@ -9033,8 +10200,15 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Infer Seq-Hist from Delta", CreateSeqHistDelta);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
+ i = CommandItem (s, "Read Seq-Hist Assembly BLASTs", ReadSeqHistAssembly);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Create TPA BLAST Database", CreateTPABlastDB);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
i = CommandItem (s, "Remove Seq-Hist Assembly", RemoveSeqHistAssembly);
SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Leave First TPA Assembly", LeaveFirstSeqHistAssembly);
+ SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
i = CommandItem (s, "Add Gaps of 100 to HTGS Deltas", AddDelta100Gaps);
SetObjectExtra (i, bfp, NULL);
@@ -9051,16 +10225,6 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Load TPA Accession Numbers From File",
LoadTPAAccessionNumbersFromFile);
SetObjectExtra (i, bfp, NULL);
- i = CommandItem (s, "Load Secondary Accession Numbers From File",
- LoadSecondaryAccessionNumbersFromFile);
- SetObjectExtra (i, bfp, NULL);
- i = CommandItem (s, "Load History Accession Numbers From File",
- LoadHistoryAccessionNumbersFromFile);
- SetObjectExtra (i, bfp, NULL);
- SeparatorItem (s);
- i = CommandItem (s, "Load Organism Modifiers from File",
- LoadOrganismModifierTable);
- SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
}
i = CommandItem (s, "Raw Sequence with Ns to Delta Sequence", RawSeqToDeltaSeq);
@@ -9116,23 +10280,60 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
}
if (extraServices) {
SeparatorItem (s);
- i = CommandItem (s, "Make ToolBar Window", MakeToolBarWindow);
+ i = CommandItem (s, "Make ToolBar Window/ T", MakeToolBarWindow);
SetObjectExtra (i, bfp, NULL);
}
-#ifdef OS_UNIX
SeparatorItem (m);
i = CommandItem (m, "Sort Unique Count/ U", SUCProc);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (m, "Sort Unique Count Resorted/ N", SUCRProc);
SetObjectExtra (i, bfp, NULL);
-#endif
+ i = CommandItem (m, "Sort Unique Count By Group", SUCBProc);
+ SetObjectExtra (i, bfp, NULL);
/*#ifdef INTERNAL_NCBI_SEQUIN*/
/*#ifdef NEW_TAXON_SERVICE*/
- /*
+/*
SeparatorItem (m);
i = CommandItem (m, "Prepare TaxList", PrepareTaxListProc);
- */
+*/
/*#endif*/
/*#endif*/
}
+extern void SetupBatchApplyMenu (MenU s, BaseFormPtr bfp)
+
+{
+ IteM i;
+
+ i = CommandItem (s, "Add CDS", ApplyCDS);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Add RNA", ApplyRRNA);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Add other Feature", ApplyImpFeat);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Add Qualifier", AddQualifier);
+ SetObjectExtra (i, bfp, NULL);
+ SeparatorItem (s);
+ i = CommandItem (s, "Add Source Qual", AddSource);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Add CDS-Gene-Prot", AddCDSet);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Add RNA Qual", AddRNA);
+ SetObjectExtra (i, bfp, NULL);
+}
+
+extern void SetupBatchEditMenu (MenU s, BaseFormPtr bfp)
+
+{
+ IteM i;
+
+ i = CommandItem (s, "Edit Qualifiers", EditQualifier);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Edit Source Qual", EditSource);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Edit CDS-Gene-Prot", EditCDSet);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Edit RNA Qual", EditRNA);
+ SetObjectExtra (i, bfp, NULL);
+}
+
diff --git a/sequin/sequin4.c b/sequin/sequin4.c
index 0e73b5b8..5af827b9 100644
--- a/sequin/sequin4.c
+++ b/sequin/sequin4.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 6/28/96
*
-* $Revision: 6.185 $
+* $Revision: 6.200 $
*
* File Description:
*
@@ -1069,56 +1069,79 @@ static void SqnCleanUpSegGap (SeqAlignPtr sap)
return;
}
+static void NoMoreSegGapForOneAlignment (SeqAlignPtr sap, Pointer userdata)
+{
+ SeqAlignPtr salp;
+
+ salp = sap;
+ while (salp != NULL)
+ {
+ if (salp->saip != NULL)
+ {
+ SeqAlignIndexFree(salp->saip);
+ salp->saip = NULL;
+ } else {
+ AlnMgr2IndexSingleChildSeqAlign(salp); /* make sure it's dense-seg */
+ SeqAlignIndexFree(salp->saip);
+ salp->saip = NULL;
+ }
+ SqnCleanUpSegGap(salp);
+ AlnMgr2IndexSingleChildSeqAlign(salp);
+ salp = salp->next;
+ }
+}
+
+
static Int2 LIBCALLBACK NoMoreSegGap (Pointer data)
{
OMProcControlPtr ompcp;
- SeqAlignPtr salp, sap;
+ SeqAlignPtr sap;
SeqAnnotPtr sanp;
ompcp = (OMProcControlPtr) data;
if (ompcp == NULL || ompcp->proc == NULL) return OM_MSG_RET_ERROR;
switch (ompcp->input_itemtype) {
case OBJ_SEQALIGN :
+ sap = (SeqAlignPtr) ompcp->input_data;
+ if (sap == NULL)
+ {
+ return OM_MSG_RET_ERROR;
+ }
+ else
+ {
+ NoMoreSegGapForOneAlignment (sap, NULL);
+ }
break;
case OBJ_SEQANNOT :
+ sanp = (SeqAnnotPtr) ompcp->input_data;
+ if (sanp->type != 2)
+ {
+ return OM_MSG_RET_ERROR;
+ }
+ else if ((sap = (SeqAlignPtr)(sanp->data)) == NULL)
+ {
+ return OM_MSG_RET_ERROR;
+ }
+ else
+ {
+ NoMoreSegGapForOneAlignment (sap, NULL);
+ }
+ break;
+ case OBJ_BIOSEQ :
+ VisitAlignmentsOnBsp (ompcp->input_data, NULL, NoMoreSegGapForOneAlignment);
+ break;
+ case OBJ_BIOSEQSET :
+ VisitAlignmentsInSet (ompcp->input_data, NULL, NoMoreSegGapForOneAlignment);
break;
case 0 :
return OM_MSG_RET_ERROR;
+ break;
default :
return OM_MSG_RET_ERROR;
+ break;
}
- if (ompcp->input_data == NULL) return OM_MSG_RET_ERROR;
- sap = NULL;
- if (ompcp->input_itemtype == OBJ_SEQALIGN)
- sap = (SeqAlignPtr) ompcp->input_data;
- else
- {
- sanp = (SeqAnnotPtr) ompcp->input_data;
- if (sanp->type == 2)
- sap = (SeqAlignPtr)(sanp->data);
- }
- if (sap == NULL) return OM_MSG_RET_ERROR;
- salp = sap;
- while (salp != NULL)
- {
- if (salp->saip != NULL)
- {
- SeqAlignIndexFree(salp->saip);
- salp->saip = NULL;
- } else
- {
- AlnMgr2IndexSingleChildSeqAlign(salp); /* make sure it's dense-seg */
- SeqAlignIndexFree(salp->saip);
- salp->saip = NULL;
- }
- SqnCleanUpSegGap(salp);
- AlnMgr2IndexSingleChildSeqAlign(salp);
- salp = salp->next;
- }
-
ObjMgrSetDirtyFlag (ompcp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, ompcp->input_entityID, 0, 0);
-
return OM_MSG_RET_DONE;
}
@@ -2051,8 +2074,49 @@ static Int2 LIBCALLBACK GroupExplodeFunc (Pointer data)
return OM_MSG_RET_ERROR;
}
+extern void GroupExplodeToolBtn (ButtoN b)
+{
+ BaseFormPtr bfp;
+ SelStructPtr ssp;
+ Boolean isDirty = FALSE;
+ SeqEntryPtr sep;
+ SeqFeatPtr sfp;
+ SeqMgrFeatContext context;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+
+ ssp = ObjMgrGetSelected();
+ while (NULL != ssp) {
+ if (ssp->itemtype == OBJ_SEQFEAT)
+ {
+ sep = GetTopSeqEntryForEntityID (ssp->entityID);
+
+ sfp = SeqMgrGetDesiredFeature (ssp->entityID, NULL, ssp->itemID, 0, NULL, &context);
+ if (sfp != NULL && ExplodeGroup (sep, sfp))
+ {
+ isDirty = TRUE;
+ }
+ }
+ ssp = ssp->next;
+ }
+
+ /* If any actual exploding was done then */
+ /* force an update to be done. */
+
+ if (isDirty)
+ {
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID,
+ bfp->input_itemID, bfp->input_itemtype);
+ }
+}
+
static Boolean MakeExonsAndIntronsFromFeature (SeqEntryPtr sep, BioseqPtr bsp,
- SeqLocPtr location, SeqFeatPtr putafterhere)
+ SeqLocPtr location,
+ SeqFeatPtr putafterhere,
+ Boolean MakeIntrons,
+ Int4 first_exon_number)
{
SeqFeatPtr curr;
@@ -2070,6 +2134,9 @@ static Boolean MakeExonsAndIntronsFromFeature (SeqEntryPtr sep, BioseqPtr bsp,
Uint1 strand;
Int4 tmp;
Boolean partial5, partial3;
+ GBQualPtr gbqual;
+ Int4 part_number;
+ Char number_text [256];
if (sep == NULL || bsp == NULL || location == NULL || putafterhere == NULL) return FALSE;
putbeforehere = putafterhere->next;
@@ -2078,6 +2145,7 @@ static Boolean MakeExonsAndIntronsFromFeature (SeqEntryPtr sep, BioseqPtr bsp,
if (slp == NULL) return FALSE;
first = TRUE;
last = 0;
+ part_number = first_exon_number;
while (slp != NULL) {
CheckSeqLocForPartial (slp, &partial5, &partial3);
next = SeqLocFindNext (location, slp);
@@ -2095,7 +2163,7 @@ static Boolean MakeExonsAndIntronsFromFeature (SeqEntryPtr sep, BioseqPtr bsp,
start = stop;
stop = tmp;
}
- if (! first) {
+ if (! first && MakeIntrons) {
sfp = SeqFeatNew ();
if (sfp != NULL) {
sfp->data.choice = SEQFEAT_IMP;
@@ -2111,6 +2179,15 @@ static Boolean MakeExonsAndIntronsFromFeature (SeqEntryPtr sep, BioseqPtr bsp,
sfp->data.value.ptrvalue = (Pointer) ifp;
ifp->key = StringSave ("intron");
}
+ gbqual = GBQualNew ();
+ if (gbqual != NULL)
+ {
+ sprintf (number_text, "%d", part_number - 1);
+ gbqual->qual = StringSave ("number");
+ gbqual->val = StringSave (number_text);
+ gbqual->next = sfp->qual;
+ sfp->qual = gbqual;
+ }
curr->next = sfp;
curr = sfp;
}
@@ -2132,6 +2209,16 @@ static Boolean MakeExonsAndIntronsFromFeature (SeqEntryPtr sep, BioseqPtr bsp,
ifp->key = StringSave ("exon");
}
SetSeqLocPartial (sfp->location, partial5, partial3);
+ gbqual = GBQualNew ();
+ if (gbqual != NULL)
+ {
+ sprintf (number_text, "%d", part_number);
+ gbqual->qual = StringSave ("number");
+ gbqual->val = StringSave (number_text);
+ gbqual->next = sfp->qual;
+ sfp->qual = gbqual;
+ }
+ part_number ++;
curr->next = sfp;
curr = sfp;
}
@@ -2142,6 +2229,163 @@ static Boolean MakeExonsAndIntronsFromFeature (SeqEntryPtr sep, BioseqPtr bsp,
return TRUE;
}
+typedef struct makeexondata {
+ FEATURE_FORM_BLOCK
+
+ ButtoN make_introns_button;
+ TexT exon_number_field;
+ ButtoN accept;
+
+ SeqEntryPtr sep;
+ Boolean make_introns;
+ Int4 first_exon_number;
+ Uint1 feature_type;
+} MakeExonData, PNTR MakeExonPtr;
+
+static void MakeExonsFromFeatureIntervalsVisitFunc (SeqFeatPtr sfp, Pointer userdata)
+{
+ MakeExonPtr mep;
+ BioseqPtr bsp;
+
+ if (sfp == NULL || (mep = (MakeExonPtr) userdata) == NULL || sfp->idx.subtype != mep->feature_type)
+ {
+ return;
+ }
+
+ mep = (MakeExonPtr) userdata;
+ bsp = BioseqFindFromSeqLoc (sfp->location);
+
+ MakeExonsAndIntronsFromFeature (mep->sep, bsp, sfp->location, sfp,
+ mep->make_introns, mep->first_exon_number);
+
+}
+
+static void DoMakeExonsFromFeatureIntervals (ButtoN b)
+{
+ MakeExonPtr mep;
+ Char exon_number_str [256];
+
+ if (b == NULL || (mep = (MakeExonPtr) GetObjectExtra (b)) == NULL) return;
+
+ Hide (mep->form);
+
+ WatchCursor ();
+ Update ();
+
+ mep->sep = GetTopSeqEntryForEntityID (mep->input_entityID);
+ mep->make_introns = GetStatus (mep->make_introns_button);
+ GetTitle (mep->exon_number_field,
+ exon_number_str,
+ sizeof (exon_number_str) - 1 );
+ mep->first_exon_number = atoi (exon_number_str);
+ VisitFeaturesInSep (mep->sep, mep,
+ MakeExonsFromFeatureIntervalsVisitFunc);
+ ObjMgrSetDirtyFlag (mep->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, mep->input_entityID, 0, 0);
+ ArrowCursor ();
+ Update ();
+}
+
+static void CheckExonNumberText (TexT number_field)
+{
+ MakeExonPtr mep;
+ Char exon_number_str [256];
+ CharPtr cp;
+
+ if (number_field == NULL || (mep = (MakeExonPtr)GetObjectExtra (number_field)) == NULL) return;
+
+ GetTitle (mep->exon_number_field,
+ exon_number_str,
+ sizeof (exon_number_str) - 1 );
+ if (exon_number_str [0] == 0)
+ {
+ Disable (mep->accept);
+ return;
+ }
+
+ for (cp = exon_number_str; cp != NULL && *cp != 0; cp++)
+ {
+ if (*cp != '0' && *cp != '1' && *cp != '2' && *cp != '3'
+ && *cp != '4' && *cp != '5' && *cp != '6' && *cp != '7'
+ && *cp != '8' && *cp != '9')
+ {
+ Disable (mep->accept);
+ return;
+ }
+ }
+ Enable (mep->accept);
+ return;
+}
+
+static void CommonMakeExonsFromFeatureIntervals (
+ IteM i,
+ Boolean make_introns,
+ Uint1 feature_type
+)
+{
+ BaseFormPtr bfp;
+ MakeExonPtr mep;
+ WindoW w;
+ GrouP h, p, c;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+
+ if (bfp == NULL) return;
+
+ mep = MemNew (sizeof (MakeExonData));
+ if (mep == NULL) return;
+ mep->input_entityID = bfp->input_entityID;
+ mep->feature_type = feature_type;
+
+ if (feature_type == FEATDEF_CDS)
+ {
+ w = FixedWindow (-50, -33, -10, -10, "Make Exons from CDS", NULL);
+ }
+ else if (feature_type == FEATDEF_mRNA)
+ {
+ w = FixedWindow (-50, -33, -10, -10, "Make Exons from mRNA", NULL);
+ }
+ else
+ {
+ w = FixedWindow (-50, -33, -10, -10, "Make Exons from Feature", NULL);
+ }
+
+ SetObjectExtra (w, mep, StdCleanupFormProc);
+ mep->form = (ForM) w;
+
+ h = HiddenGroup (w, -1, 0, NULL);
+ SetGroupSpacing (h, 10, 10);
+
+ p = HiddenGroup (h, 2, 0, NULL);
+ StaticPrompt (p, "First Exon Number", 0, 0, programFont, 'c');
+ mep->exon_number_field = DialogText (p, "1", 3, CheckExonNumberText);
+ SetObjectExtra (mep->exon_number_field, mep, NULL);
+ mep->make_introns_button = CheckBox (p, "Make Introns", NULL);
+
+ c = HiddenGroup (h, 4, 0, NULL);
+ mep->accept = DefaultButton (c, "Accept", DoMakeExonsFromFeatureIntervals);
+ SetObjectExtra (mep->accept, mep, NULL);
+ PushButton (c, "Cancel", StdCancelButtonProc);
+ AlignObjects (ALIGN_CENTER, (HANDLE) p, (HANDLE) c, NULL);
+ RealizeWindow (w);
+ Show (w);
+ Update ();
+}
+
+extern void MakeExonsFromCDSIntervals (IteM i)
+{
+ CommonMakeExonsFromFeatureIntervals (i, FALSE, FEATDEF_CDS);
+}
+
+extern void MakeExonsFromMRNAIntervals (IteM i)
+{
+ CommonMakeExonsFromFeatureIntervals (i, TRUE, FEATDEF_mRNA);
+}
+
static Int2 LIBCALLBACK MakeExonIntron (Pointer data)
{
@@ -2175,7 +2419,7 @@ static Int2 LIBCALLBACK MakeExonIntron (Pointer data)
nbsp = (BioseqPtr) nsep->data.ptrvalue;
if (nbsp == NULL) return OM_MSG_RET_ERROR;
- if (MakeExonsAndIntronsFromFeature (sep, nbsp, sfp->location, sfp))
+ if (MakeExonsAndIntronsFromFeature (sep, nbsp, sfp->location, sfp, TRUE, 1))
{
ObjMgrSetDirtyFlag (ompcp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, ompcp->input_entityID, ompcp->input_itemID,
@@ -3905,6 +4149,21 @@ static ProtRefPtr FindBestProtRef (Uint2 entityID, SeqFeatPtr cds)
return pfl.prp;
}
+/* if gene location matches mRNA exactly, make it partial on both ends */
+static void MakeMRNAGenesPartial (SeqFeatPtr sfp, Pointer userdata)
+{
+ SeqFeatPtr mrna;
+
+ if (sfp == NULL || userdata == NULL) return;
+ if (sfp->data.choice != SEQFEAT_GENE) return;
+
+ mrna = (SeqFeatPtr) userdata;
+
+ if (SeqLocAinB (mrna->location, sfp->location) != 0) return;
+
+ SetSeqLocPartial (sfp->location, TRUE, TRUE);
+}
+
extern void MRnaFromCdsProc (Uint2 entityID)
{
@@ -3971,6 +4230,7 @@ extern void MRnaFromCdsProc (Uint2 entityID)
rna->next = cds->next;
cds->next = rna;
}
+ VisitFeaturesOnBsp (bsp, (Pointer) rna, MakeMRNAGenesPartial);
} else {
rna->next = cds->next;
cds->next = rna;
@@ -4143,12 +4403,15 @@ static void RevCompFeats (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 inde
{
BioseqPtr bsp;
BioseqSetPtr bssp;
+ CodeBreakPtr cbp;
+ CdRegionPtr crp;
+ RnaRefPtr rrp;
SeqAnnotPtr sap;
SeqFeatPtr sfp;
SeqIdPtr sip;
SeqLocPtr slp;
Boolean split;
-
+ tRNAPtr trp;
if (mydata == NULL) return;
if (sep == NULL || sep->data.ptrvalue == NULL) return;
@@ -4173,6 +4436,35 @@ static void RevCompFeats (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 inde
bsp->length - 1, Seq_strand_minus, &split);
sfp->location = SeqLocFree (sfp->location);
sfp->location = slp;
+ switch (sfp->data.choice) {
+ case SEQFEAT_CDREGION :
+ crp = (CdRegionPtr) sfp->data.value.ptrvalue;
+ if (crp != NULL) {
+ for (cbp = crp->code_break; cbp != NULL; cbp = cbp->next) {
+ sip = SeqLocId (cbp->loc);
+ slp = SeqLocCopyRegion (sip, cbp->loc, bsp, 0,
+ bsp->length - 1, Seq_strand_minus, &split);
+ cbp->loc = SeqLocFree (cbp->loc);
+ cbp->loc = slp;
+ }
+ }
+ break;
+ case SEQFEAT_RNA :
+ rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
+ if (rrp != NULL && rrp->ext.choice == 2) {
+ trp = (tRNAPtr) rrp->ext.value.ptrvalue;
+ if (trp != NULL && trp->anticodon != NULL) {
+ sip = SeqLocId (trp->anticodon);
+ slp = SeqLocCopyRegion (sip, trp->anticodon, bsp, 0,
+ bsp->length - 1, Seq_strand_minus, &split);
+ trp->anticodon = SeqLocFree (trp->anticodon);
+ trp->anticodon = slp;
+ }
+ }
+ break;
+ default :
+ break;
+ }
}
}
sfp = sfp->next;
@@ -6559,6 +6851,7 @@ static void CheckFeatForNuclID_callback (SeqFeatPtr sfp, Pointer userdata)
/* Get the location Seq ID for this CDS feature */
featSip = SeqLocId (sfp->location);
+ if (featSip == NULL) return;
oip = (ObjectIdPtr) featSip->data.ptrvalue;
/* If the location Seq ID matches the old Seq Id */
@@ -6799,21 +7092,14 @@ static void ResolveExistingIDsCallback (SeqEntryPtr sep, Pointer mydata, Int4 in
extern Int2 DoOneSegFixup (SeqEntryPtr sep, Boolean ask);
-extern void ResolveExistingLocalIDs (IteM i);
-extern void ResolveExistingLocalIDs (IteM i)
+static void ResolveExistingLocalIDsBaseForm (BaseFormPtr bfp)
{
MsgAnswer ans;
- BaseFormPtr bfp;
Boolean doParts = FALSE;
LclIdListPtr head = NULL;
SeqEntryPtr sep;
-#ifdef WIN_MAC
- bfp = currentFormDataPtr;
-#else
- bfp = GetObjectExtra (i);
-#endif
if (bfp == NULL) return;
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
if (sep == NULL) return;
@@ -6828,6 +7114,30 @@ extern void ResolveExistingLocalIDs (IteM i)
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
+extern void ResolveExistingLocalIDs (IteM i);
+extern void ResolveExistingLocalIDs (IteM i)
+{
+ BaseFormPtr bfp;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+
+ if (bfp == NULL) return;
+ ResolveExistingLocalIDsBaseForm (bfp);
+}
+
+extern void ResolveExistingLocalIDsToolBtn (ButtoN b)
+{
+ BaseFormPtr bfp;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+ ResolveExistingLocalIDsBaseForm (bfp);
+}
+
extern void SetSourceFocus (IteM i);
extern void ClearSourceFocus (IteM i);
@@ -7048,7 +7358,7 @@ extern void ExtraAccToHistByPos (IteM i)
ahp->which = DialogText (g, "", 5, NULL);
c = HiddenGroup (h, 2, 0, NULL);
- b = PushButton (c, "Accept", DoProcessExtraAccToHis);
+ b = DefaultButton (c, "Accept", DoProcessExtraAccToHis);
SetObjectExtra (b, ahp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
@@ -7255,16 +7565,12 @@ extern void EditFeatureStrand (IteM i)
ButtoN b;
BaseFormPtr bfp;
GrouP c;
- FeatDefPtr curr;
EditStrandPtr esp;
GrouP g;
GrouP h;
ValNodePtr head;
GrouP k;
- Uint1 key;
- CharPtr label = NULL;
Int2 listHeight;
- Uint2 subtype;
ValNodePtr vnp;
WindoW w;
@@ -7307,41 +7613,11 @@ extern void EditFeatureStrand (IteM i)
/* Create a val node list of all feature types */
- head = ValNodeNew (NULL);
- curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
- while (curr != NULL) {
- if (key != FEATDEF_BAD) {
- subtype = curr->featdef_key;
- if (subtype != FEATDEF_misc_RNA &&
- subtype != FEATDEF_precursor_RNA &&
- subtype != FEATDEF_mat_peptide &&
- subtype != FEATDEF_sig_peptide &&
- subtype != FEATDEF_transit_peptide &&
- subtype != FEATDEF_Imp_CDS) {
- vnp = ValNodeNew (head);
- if (head == NULL) {
- head = vnp;
- }
- if (vnp != NULL) {
- vnp->choice = subtype;
- vnp->data.ptrvalue = StringSave (curr->typelabel);
- }
- }
- }
- curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
- }
+ head = BuildFeatureValNodeList (TRUE, "[ALL FEATURES]", 0, FALSE, TRUE);
/* Use the val node list to populate the feature list box */
if (head != NULL) {
- head = SortValNode (head, SortVnpByString);
- vnp = ValNodeNew (NULL);
- if (vnp != NULL) {
- vnp->choice = 0;
- vnp->data.ptrvalue = StringSave ("[ALL FEATURES]");
- }
- vnp->next = head;
- head = vnp;
for (vnp = head; vnp != NULL; vnp = vnp->next)
ListItem (esp->feature, (CharPtr) vnp->data.ptrvalue);
}
@@ -7372,7 +7648,7 @@ extern void EditFeatureStrand (IteM i)
/* Create accept and cancel buttons */
c = HiddenGroup (h, 2, 0, NULL);
- b = PushButton (c, "Accept", DoEditFeatureStrand);
+ b = DefaultButton (c, "Accept", DoEditFeatureStrand);
SetObjectExtra (b, esp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -7430,3 +7706,214 @@ extern void ClearMrnaProducts (IteM i)
ClearFeatProducts (i, FEATDEF_mRNA);
}
+static void ConsolidateOneLikeSubSourceModifier (
+ SubSourcePtr match_to,
+ Boolean use_semicolon
+)
+{
+ SubSourcePtr prev, index;
+ Int4 len, num_matches;
+ CharPtr new_value;
+
+ if (match_to == NULL) return;
+ len = StringLen (match_to->name) + 1;
+ num_matches = 0;
+ prev = match_to;
+ index = match_to->next;
+ while (index != NULL)
+ {
+ if (index->subtype == match_to->subtype && index->name != NULL)
+ {
+ len += StringLen (index->name) + 2;
+ num_matches++;
+ }
+ index = index->next;
+ }
+ if (num_matches == 0) return;
+
+ new_value = MemNew (len * sizeof (char));
+ if (new_value == NULL) return;
+
+ StringCpy (new_value, match_to->name);
+ index = match_to->next;
+ while (index != NULL)
+ {
+ if (index->subtype == match_to->subtype && index->name != NULL)
+ {
+ if (use_semicolon)
+ {
+ StringCat (new_value, "; ");
+ }
+ else
+ {
+ StringCat (new_value, " ");
+ }
+ StringCat (new_value, index->name);
+ prev->next = index->next;
+ index->next = NULL;
+ SubSourceFree (index);
+ index = prev;
+ }
+ prev = index;
+ index = index->next;
+ }
+ MemFree (match_to->name);
+ match_to->name = new_value;
+}
+
+static void ConsolidateOneLikeOrganismModifier (
+ OrgModPtr match_to,
+ Boolean use_semicolon
+)
+{
+ OrgModPtr prev, index;
+ Int4 len, num_matches;
+ CharPtr new_value;
+
+ if (match_to == NULL) return;
+ len = StringLen (match_to->subname) + 1;
+ num_matches = 0;
+ prev = match_to;
+ index = match_to->next;
+ while (index != NULL)
+ {
+ if (index->subtype == match_to->subtype && index->subname != NULL)
+ {
+ len += StringLen (index->subname) + 2;
+ num_matches++;
+ }
+ index = index->next;
+ }
+ if (num_matches == 0) return;
+
+ new_value = MemNew (len * sizeof (char));
+ if (new_value == NULL) return;
+
+ StringCpy (new_value, match_to->subname);
+ index = match_to->next;
+ while (index != NULL)
+ {
+ if (index->subtype == match_to->subtype && index->subname != NULL)
+ {
+ if (use_semicolon)
+ {
+ StringCat (new_value, "; ");
+ }
+ else
+ {
+ StringCat (new_value, " ");
+ }
+ StringCat (new_value, index->subname);
+ prev->next = index->next;
+ index->next = NULL;
+ OrgModFree (index);
+ index = prev;
+ }
+ prev = index;
+ index = index->next;
+ }
+ MemFree (match_to->subname);
+ match_to->subname = new_value;
+}
+
+static void ConsolidateLikeModifiersProc (BioSourcePtr biop, Pointer userdata)
+{
+ SubSourcePtr ssp;
+ OrgModPtr mod;
+ Boolean use_semicolon;
+
+ if (biop == NULL || userdata == NULL) return;
+
+ use_semicolon = *((Boolean PNTR) userdata);
+
+ for (ssp = biop->subtype; ssp != NULL; ssp = ssp->next)
+ {
+ if (ssp->name != NULL)
+ {
+ ConsolidateOneLikeSubSourceModifier (ssp, use_semicolon);
+ }
+ }
+
+ if (biop->org == NULL || biop->org->orgname == NULL) return;
+ for (mod = biop->org->orgname->mod; mod != NULL; mod = mod->next)
+ {
+ if (mod->subname != NULL)
+ {
+ ConsolidateOneLikeOrganismModifier (mod, use_semicolon);
+ }
+ }
+}
+
+static void ConsolidateLikeModifiers (IteM i, Boolean use_semicolon)
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+ VisitBioSourcesInSep (sep, &use_semicolon, ConsolidateLikeModifiersProc);
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
+
+extern void ConsolidateLikeModifiersWithSemicolons (IteM i)
+{
+ ConsolidateLikeModifiers (i, TRUE);
+}
+
+extern void ConsolidateLikeModifiersWithoutSemicolons (IteM i)
+{
+ ConsolidateLikeModifiers (i, FALSE);
+}
+
+static void ConsolidateOrganismNotesProc (BioSourcePtr biop, Pointer userdata)
+{
+ SubSourcePtr ssp, note_ssp;
+ OrgModPtr mod, note_mod;
+
+ if (biop == NULL) return;
+
+ for (ssp = biop->subtype; ssp != NULL; ssp = ssp->next)
+ {
+ if (ssp->subtype == 255 && ssp->name != NULL)
+ {
+ ConsolidateOneLikeSubSourceModifier (ssp, TRUE);
+ note_ssp = ssp;
+ }
+ }
+
+ if (biop->org == NULL || biop->org->orgname == NULL) return;
+ for (mod = biop->org->orgname->mod; mod != NULL; mod = mod->next)
+ {
+ if (mod->subtype == 255 && mod->subname != NULL)
+ {
+ ConsolidateOneLikeOrganismModifier (mod, TRUE);
+ note_mod = mod;
+ }
+ }
+}
+
+extern void ConsolidateOrganismNotes (IteM i)
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+ VisitBioSourcesInSep (sep, NULL, ConsolidateOrganismNotesProc);
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
+
diff --git a/sequin/sequin5.c b/sequin/sequin5.c
index 449b7dc4..4f4baf9a 100644
--- a/sequin/sequin5.c
+++ b/sequin/sequin5.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 8/26/97
*
-* $Revision: 6.153 $
+* $Revision: 6.165 $
*
* File Description:
*
@@ -76,6 +76,7 @@
#include <subutil.h>
#include <explore.h>
#include <import.h>
+#include <salutil.h>
static void CommonLaunchBioseqViewer (SeqEntryPtr sep, CharPtr path, Boolean directToEditor)
@@ -819,7 +820,7 @@ void EditLocusProc (IteM i)
StaticPrompt (g, "Accession: ", 0, stdLineHeight, systemFont, 'l');
elp->accnnumber = StaticPrompt (g, "", 20 * stdCharWidth, stdLineHeight, systemFont, 'l');
c = HiddenGroup (w, 2, 0, NULL);
- b = PushButton (c, "Accept", StdAcceptFormButtonProc);
+ b = DefaultButton (c, "Accept", StdAcceptFormButtonProc);
SetObjectExtra (b, elp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
@@ -3197,7 +3198,7 @@ static ForM CreatePowBlastForm (Uint2 entityID, SeqEntryPtr sep)
AlignObjects (ALIGN_MIDDLE, (HANDLE) ppt4, (HANDLE) pfp->stringency, NULL);
c = HiddenGroup (w, 4, 0, NULL);
- pfp->accept = PushButton (c, "Accept", PowBlastFormAcceptProc);
+ pfp->accept = DefaultButton (c, "Accept", PowBlastFormAcceptProc);
SetObjectExtra (pfp->accept, pfp, NULL);
Disable (pfp->accept);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -5546,7 +5547,7 @@ static ForM CreateAutoParseForm (Uint2 entityID, SeqEntryPtr sep, BioseqPtr targ
}
c = HiddenGroup (w, 4, 0, NULL);
- b = PushButton (c, "Accept", AutoParseAcceptProc);
+ b = DefaultButton (c, "Accept", AutoParseAcceptProc);
SetObjectExtra (b, afp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -5857,7 +5858,7 @@ void AutoParseFeatureTableProc (IteM i)
SetValue (ppp->tabDelimited, 1);
c = HiddenGroup (w, 4, 0, NULL);
- b = PushButton (c, "Accept", PreParseAcceptProc);
+ b = DefaultButton (c, "Accept", PreParseAcceptProc);
SetObjectExtra (b, ppp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -6011,6 +6012,7 @@ typedef struct qualformdata {
EnumFieldAssoc PNTR realalist;
EnumFieldAssoc PNTR alist;
ValNodePtr bsplist;
+ ButtoN leaveDlgUp;
} QualFormData, PNTR QualFormPtr;
static void LIBCALLBACK AsnWriteQualifierForDCallBack (AsnExpOptStructPtr pAEOS)
@@ -6174,83 +6176,6 @@ extern void SeqLocAdjustByOffset (SeqLocPtr slp,
/*=========================================================================*/
/* */
-/* SeqLocAddToEnd () */
-/* */
-/*=========================================================================*/
-
-static Boolean SeqLocAddToEnd (SeqLocPtr slp, Int4 length)
-{
- SeqIntPtr sinp;
-
- switch (slp->choice) {
- case SEQLOC_INT :
- sinp = (SeqIntPtr) slp->data.ptrvalue;
- if (NULL == sinp)
- return FALSE;
- sinp->to += length;
- break;
- case SEQLOC_EMPTY :
- case SEQLOC_NULL :
- case SEQLOC_WHOLE :
- case SEQLOC_PNT :
- case SEQLOC_PACKED_PNT :
- case SEQLOC_PACKED_INT :
- case SEQLOC_MIX :
- case SEQLOC_EQUIV :
- case SEQLOC_BOND :
- case SEQLOC_FEAT :
- default :
- break;
- }
-
- return TRUE;
-}
-
-/*=========================================================================*/
-/* */
-/* SeqLocGetLength () */
-/* */
-/*=========================================================================*/
-
-static Int4 SeqLocGetLength (SeqLocPtr slp)
-{
- SeqIntPtr sinp;
- Int4 length;
-
- switch (slp->choice) {
- case SEQLOC_INT :
-
- sinp = (SeqIntPtr) slp->data.ptrvalue;
- if (NULL == sinp)
- return 0;
-
- if (sinp->from < sinp->to)
- length = sinp->to - sinp->from + 1;
- else
- length = sinp->from - sinp->to + 1;
-
- break;
-
- case SEQLOC_EMPTY :
- case SEQLOC_NULL :
- case SEQLOC_WHOLE :
- case SEQLOC_PNT :
- case SEQLOC_PACKED_PNT :
- case SEQLOC_PACKED_INT :
- case SEQLOC_MIX :
- case SEQLOC_EQUIV :
- case SEQLOC_BOND :
- case SEQLOC_FEAT :
- default :
- length = 0;
- break;
- }
-
- return length;
-}
-
-/*=========================================================================*/
-/* */
/* MoveProteinFeatures () */
/* */
/*=========================================================================*/
@@ -6437,6 +6362,41 @@ static void ConvertProtsToMatPeptides (BioseqPtr bsp)
return;
}
+static void ConvertFirstMatProteinToPolyProtein (
+ BioseqPtr nucBsp,
+ SeqFeatPtr firstMatCDS
+)
+{
+
+ SeqLocPtr firstMatLoc;
+ BioseqPtr firstMatBsp;
+ Uint1 strand;
+
+ if (nucBsp == NULL
+ || firstMatCDS == NULL)
+ {
+ return;
+ }
+
+ firstMatBsp = BioseqFindFromSeqLoc (firstMatCDS->product);
+ if (firstMatBsp == NULL) return;
+
+ strand = SeqLocStrand (firstMatCDS->location);
+ firstMatLoc = firstMatCDS->location;
+ firstMatCDS->location = SeqLocMerge (nucBsp, firstMatLoc, NULL, FALSE, TRUE, FALSE);
+ expand_seq_loc (0, nucBsp->length - 1, strand, firstMatCDS->location);
+
+ SetSeqLocPartial (firstMatCDS->location, TRUE, TRUE);
+ firstMatCDS->partial = TRUE;
+ SeqLocFree (firstMatLoc);
+
+ firstMatBsp->seq_data = BSFree (firstMatBsp->seq_data);
+ firstMatBsp->seq_data = ProteinFromCdRegion (firstMatCDS, FALSE);
+ firstMatBsp->length = BSLen (firstMatBsp->seq_data);
+ SetSeqFeatProduct (firstMatCDS, firstMatBsp);
+
+}
+
/*=========================================================================*/
/* */
/* MergeProteinBioseqs () */
@@ -6450,12 +6410,7 @@ static Boolean MergeProteinBioseqs (BioseqSetPtr bssp)
BioseqPtr protBsp;
SeqEntryPtr sep;
Int4 offset;
- Uint1 seqtype;
- SeqPortPtr spp;
- Int2 residue;
SeqFeatPtr cdsSfp;
- SeqFeatPtr firstProtCDS;
- Int4 cdsLen;
Boolean found;
SeqMgrFeatContext fcontext;
@@ -6489,8 +6444,9 @@ static Boolean MergeProteinBioseqs (BioseqSetPtr bssp)
/* offset for the next Bioseq. */
if (NULL == firstProtBsp) {
+ ConvertFirstMatProteinToPolyProtein (bsp, cdsSfp);
+ protBsp = BioseqFindFromSeqLoc (cdsSfp->product);
firstProtBsp = protBsp;
- firstProtCDS = SeqMgrGetCDSgivenProduct (firstProtBsp, NULL);
offset = firstProtBsp->length;
}
@@ -6500,41 +6456,16 @@ static Boolean MergeProteinBioseqs (BioseqSetPtr bssp)
else {
/* Move all features to 1st protein Bioseq */
-
- MoveProteinAnnots (firstProtBsp, protBsp, &offset);
-
- /* Merge the actual sequences */
-
- seqtype = Seq_code_ncbieaa;
- spp = SeqPortNew(protBsp, 0, protBsp->length-1, protBsp->strand,
- seqtype);
-
- while ((residue = SeqPortGetResidue(spp)) != SEQPORT_EOF) {
- if (! IS_residue(residue))
- ErrPost(CTX_NCBIOBJ, 1, "Non-residue in MergeProteinBioseqs [%d]",
- (int)residue);
- else
- BSPutByte(firstProtBsp->seq_data, residue);
- }
-
- SeqPortFree(spp);
- firstProtBsp->length += protBsp->length;
-
- /* Mark for deletion the original Bioseq */
-
- offset += protBsp->length;
- protBsp->idx.deleteme = TRUE;
+ offset = fcontext.left / 3;
- /* Mark for deletion any CDS */
- /* pointing to this Bioseq. */
+ MoveProteinAnnots (firstProtBsp, protBsp, &offset);
- cdsSfp = SeqMgrGetCDSgivenProduct (protBsp, NULL);
+ /* Mark for deletion the original Bioseq */
+ protBsp->idx.deleteme = TRUE;
+ /* Mark for deletion the CDS */
+ /* pointing to this Bioseq. */
cdsSfp->idx.deleteme = TRUE;
- /* Adjust the length of the merged Bioseq's CDS */
-
- cdsLen = SeqLocGetLength (cdsSfp->location);
- SeqLocAddToEnd (firstProtCDS->location, cdsLen);
}
cdsSfp = SeqMgrGetNextFeature (protBsp, cdsSfp, SEQFEAT_CDREGION,
@@ -8112,7 +8043,11 @@ static void DoProcessQualifier (ButtoN b)
qfp->findStr = JustSaveStringFromText (qfp->findthis);
PrepareToConvertToCDS (sep, qfp->input_entityID,
qfp->subtype, qfp->findStr);
- Remove (qfp->form);
+ if (GetStatus (qfp->leaveDlgUp)) {
+ Show (qfp->form);
+ } else {
+ Remove (qfp->form);
+ }
return;
}
}
@@ -8151,7 +8086,11 @@ static void DoProcessQualifier (ButtoN b)
DeleteMarkedObjects (qfp->input_entityID, 0, NULL);
ObjMgrSetDirtyFlag (qfp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, qfp->input_entityID, 0, 0);
- Remove (qfp->form);
+ if (GetStatus (qfp->leaveDlgUp)) {
+ Show (qfp->form);
+ } else {
+ Remove (qfp->form);
+ }
}
static void QualMessageProc (ForM f, Int2 mssg)
@@ -8177,6 +8116,15 @@ static void CleanupQualForm (GraphiC g, VoidPtr data)
if (qfp != NULL) {
MemFree (qfp->findStr);
MemFree (qfp->replaceStr);
+ if (qfp->alist != NULL
+ && qfp->alist != qfp->realalist
+ && qfp->alist != qfp->realalist + 1)
+ {
+ for (j = 0; qfp->alist [j].name != NULL; j++) {
+ MemFree (qfp->alist [j].name);
+ }
+ MemFree (qfp->alist);
+ }
if (qfp->realalist != NULL) {
for (j = 0; qfp->realalist [j].name != NULL; j++) {
MemFree (qfp->realalist [j].name);
@@ -8258,6 +8206,7 @@ static void ProcessQualifier (IteM i, Int2 type)
} else {
ap = import_featdef_alist (FALSE, FALSE, FALSE);
}
+ SortEnumFieldAssocPtrArray (ap, CompareImpFeatEnumFieldAssoc);
qfp->realalist = ap;
if (type == CONVERT_FEAT) {
ap++;
@@ -8265,7 +8214,15 @@ static void ProcessQualifier (IteM i, Int2 type)
ap->name = MemFree (ap->name);
ap->name = StringSave ("[ALL FEATURES]");
}
- qfp->alist = ap;
+
+ if (type == CONVERT_FEAT)
+ {
+ qfp->alist = InsertMostUsedFeatureEnumFieldAssoc (ap);
+ }
+ else
+ {
+ qfp->alist = ap;
+ }
h = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
@@ -8365,9 +8322,10 @@ static void ProcessQualifier (IteM i, Int2 type)
}
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoProcessQualifier);
+ b = DefaultButton (c, "Accept", DoProcessQualifier);
SetObjectExtra (b, qfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
+ qfp->leaveDlgUp = CheckBox (c, "Leave Dialog Up", NULL);
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) k, (HANDLE) c, NULL);
RealizeWindow (w);
@@ -8617,13 +8575,79 @@ typedef struct sourceformdata {
Boolean replaceOldAsked;
Boolean doReplaceAll;
+ Boolean use_semicolon;
+ ButtoN leaveDlgUp;
} SourceFormData, PNTR SourceFormPtr;
+extern void AppendOrReplaceString (
+ CharPtr PNTR string_loc,
+ CharPtr new_value,
+ Boolean PNTR asked_question,
+ Boolean PNTR do_replace,
+ Boolean PNTR use_semicolon
+)
+{
+ MsgAnswer ans;
+ CharPtr tmp_value, tmp_new_value;
+
+ if (string_loc == NULL
+ || new_value == NULL
+ || asked_question == NULL
+ || do_replace == NULL
+ || use_semicolon == NULL)
+ {
+ return;
+ }
+
+ if (! *asked_question && !StringHasNoText (*string_loc))
+ {
+ *asked_question = TRUE;
+ ArrowCursor ();
+ ans = Message (MSG_YN, "Do you wish to overwrite existing content?");
+ *do_replace = (Boolean) (ans == ANS_YES);
+ if (! *use_semicolon)
+ {
+ if (! *do_replace)
+ {
+ ans = Message (MSG_YN, "Separate items with semicolon?");
+ *use_semicolon = (Boolean) (ans == ANS_YES);
+ }
+ }
+ WatchCursor ();
+ Update ();
+ }
+ if (*do_replace || StringHasNoText (*string_loc))
+ {
+ MemFree (*string_loc);
+ *string_loc = StringSave (new_value);
+ }
+ else
+ {
+ tmp_value = MemNew (StringLen (*string_loc) + StringLen ( new_value) + 3);
+ if (tmp_value == NULL) return;
+ StringCpy (tmp_value, *string_loc);
+ TrimSpacesAroundString (tmp_value);
+ if (*use_semicolon)
+ {
+ StringCat (tmp_value, "; ");
+ }
+ else
+ {
+ StringCat (tmp_value, " ");
+ }
+ tmp_new_value = StringSave (new_value);
+ TrimSpacesAroundString (tmp_new_value);
+ StringCat (tmp_value, tmp_new_value);
+ MemFree (tmp_new_value);
+ MemFree (*string_loc);
+ *string_loc = tmp_value;
+ }
+}
+
static SubSourcePtr FindSubSource (BioSourcePtr biop, Uint1 subtype, SourceFormPtr sfp,
Boolean forceRemove, Boolean convertNote, Boolean is_feat)
{
- MsgAnswer ans;
SubSourcePtr PNTR prev;
SubSourcePtr ssp;
SubSourcePtr tmp;
@@ -8641,18 +8665,6 @@ static SubSourcePtr FindSubSource (BioSourcePtr biop, Uint1 subtype, SourceFormP
SubSourceFree (ssp);
return NULL;
}
- } else if (sfp->type == ADD_SOURCE) {
- if (! sfp->replaceOldAsked) {
- sfp->replaceOldAsked = TRUE;
- ArrowCursor ();
- ans = Message (MSG_YN, "Do you wish to overwrite existing modifiers?");
- WatchCursor ();
- Update ();
- sfp->doReplaceAll = (Boolean) (ans == ANS_YES);
- }
- if (sfp->doReplaceAll) {
- return ssp;
- }
} else {
return ssp;
}
@@ -8681,7 +8693,6 @@ static SubSourcePtr FindSubSource (BioSourcePtr biop, Uint1 subtype, SourceFormP
static OrgModPtr FindOrgMod (BioSourcePtr biop, Uint1 subtype, SourceFormPtr sfp, Boolean forceRemove, Boolean convertNote)
{
- MsgAnswer ans;
OrgModPtr mod;
OrgNamePtr onp;
OrgRefPtr orp;
@@ -8722,18 +8733,6 @@ static OrgModPtr FindOrgMod (BioSourcePtr biop, Uint1 subtype, SourceFormPtr sfp
OrgModFree (mod);
return NULL;
}
- } else if (sfp->type == ADD_SOURCE) {
- if (! sfp->replaceOldAsked) {
- sfp->replaceOldAsked = TRUE;
- ArrowCursor ();
- ans = Message (MSG_YN, "Do you wish to overwrite existing modifiers?");
- WatchCursor ();
- Update ();
- sfp->doReplaceAll = (Boolean) (ans == ANS_YES);
- }
- if (sfp->doReplaceAll) {
- return mod;
- }
} else {
return mod;
}
@@ -8771,7 +8770,7 @@ static void ConvertSourceString (OrgRefPtr orp, Int2 fromval, Int2 toval)
switch (fromval) {
case 1 :
tmp = orp->taxname;
- orp->taxname = NULL;
+ SetTaxNameAndRemoveTaxRef (orp, NULL);
break;
case 2 :
tmp = orp->common;
@@ -8797,7 +8796,7 @@ static void ConvertSourceString (OrgRefPtr orp, Int2 fromval, Int2 toval)
switch (toval) {
case 1 :
- orp->taxname = tmp;
+ SetTaxNameAndRemoveTaxRef (orp, tmp);
break;
case 2 :
orp->common = tmp;
@@ -8873,6 +8872,241 @@ static Uint1 AssignSubtype (Uint1 subtype)
return subtype;
}
+static void RemoveSubSourceByPtr (BioSourcePtr biop, SubSourcePtr to_remove)
+{
+ SubSourcePtr ssp, prev;
+
+ if (biop == NULL || to_remove == NULL) return;
+
+ prev = NULL;
+ ssp = biop->subtype;
+ while (ssp != NULL)
+ {
+ if (ssp == to_remove)
+ {
+ if (prev == NULL)
+ {
+ biop->subtype = ssp->next;
+ ssp->next = NULL;
+ SubSourceFree (ssp);
+ ssp = biop->subtype;
+ }
+ else
+ {
+ prev->next = ssp->next;
+ ssp->next = NULL;
+ SubSourceFree (ssp);
+ ssp = prev->next;
+ }
+ }
+ else
+ {
+ prev = ssp;
+ ssp = ssp->next;
+ }
+ }
+}
+
+static void ConvertSubSourceModifier (
+ BioSourcePtr biop,
+ SourceFormPtr sfp,
+ Boolean is_feat,
+ SubSourcePtr ssp_from
+)
+{
+ SubSourcePtr ssp_to;
+
+ if (biop == NULL || sfp == NULL || ssp_from == NULL) return;
+ ssp_to = FindSubSource (biop, sfp->toval - 100, sfp, TRUE, FALSE, is_feat);
+ if (ssp_to != NULL)
+ {
+ AppendOrReplaceString (&(ssp_to->name), ssp_from->name,
+ &(sfp->replaceOldAsked),
+ &(sfp->doReplaceAll),
+ &(sfp->use_semicolon));
+ RemoveSubSourceByPtr (biop, ssp_from);
+ }
+ else
+ {
+ ssp_from->subtype = AssignSubtype (sfp->toval);
+ }
+}
+
+static void RemoveOrgModByPtr (BioSourcePtr biop, OrgModPtr to_remove)
+{
+ OrgModPtr mod, prev;
+
+ if (biop == NULL
+ || biop->org == NULL
+ || biop->org->orgname == NULL
+ || biop->org->orgname->mod == NULL
+ || to_remove == NULL)
+ {
+ return;
+ }
+
+ prev = NULL;
+ mod = biop->org->orgname->mod;
+ while (mod != NULL)
+ {
+ if (mod == to_remove)
+ {
+ if (prev == NULL)
+ {
+ biop->org->orgname->mod = mod->next;
+ mod->next = NULL;
+ OrgModFree (mod);
+ mod = biop->org->orgname->mod;
+ }
+ else
+ {
+ prev->next = mod->next;
+ mod->next = NULL;
+ OrgModFree (mod);
+ mod = prev->next;
+ }
+ }
+ else
+ {
+ prev = mod;
+ mod = mod->next;
+ }
+ }
+}
+
+static void ConvertOrganismModifier (
+ BioSourcePtr biop,
+ SourceFormPtr sfp,
+ Boolean is_feat,
+ OrgModPtr mod_from
+)
+{
+ OrgModPtr mod_to;
+
+ if (biop == NULL || sfp == NULL || mod_from == NULL) return;
+ mod_to = FindOrgMod (biop, sfp->toval, sfp, FALSE, FALSE);
+ if (mod_to != NULL)
+ {
+ AppendOrReplaceString (&(mod_to->subname), mod_from->subname,
+ &(sfp->replaceOldAsked),
+ &(sfp->doReplaceAll),
+ &(sfp->use_semicolon));
+ RemoveOrgModByPtr (biop, mod_from);
+ }
+ else
+ {
+ mod_from->subtype = AssignSubtype (sfp->toval);
+ }
+}
+
+static void ConvertSubSourceToOrgMod (
+ BioSourcePtr biop,
+ SourceFormPtr sfp,
+ Boolean is_feat,
+ SubSourcePtr ssp
+)
+{
+ OrgModPtr mod;
+
+ if (biop == NULL
+ || sfp == NULL
+ || ssp == NULL)
+ {
+ return;
+ }
+
+ if (sfp->toval == 55)
+ {
+ mod = FindOrgMod (biop, 255, sfp, FALSE, FALSE);
+ }
+ else
+ {
+ mod = FindOrgMod (biop, sfp->toval, sfp, FALSE, FALSE);
+ }
+ if (mod == NULL)
+ {
+ if (biop->org == NULL)
+ {
+ biop->org = OrgRefNew ();
+ if (biop->org == NULL) return;
+ }
+ if (biop->org->orgname == NULL)
+ {
+ biop->org->orgname = OrgNameNew ();
+ if (biop->org->orgname == NULL) return;
+ }
+ mod = OrgModNew ();
+ if (sfp->toval == 55)
+ {
+ mod->subtype = 255;
+ }
+ else
+ {
+ mod->subtype = sfp->toval;
+ }
+ mod->subname = StringSave (ssp->name);
+ mod->next = biop->org->orgname->mod;
+ biop->org->orgname->mod = mod;
+ }
+ else
+ {
+ AppendOrReplaceString (&(mod->subname), ssp->name,
+ &(sfp->replaceOldAsked),
+ &(sfp->doReplaceAll),
+ &(sfp->use_semicolon));
+ }
+ RemoveSubSourceByPtr (biop, ssp);
+}
+
+static void ConvertOrgModToSubSource (
+ BioSourcePtr biop,
+ SourceFormPtr sfp,
+ Boolean is_feat,
+ OrgModPtr mod
+)
+{
+ SubSourcePtr ssp;
+
+ if (biop == NULL
+ || sfp == NULL
+ || mod == NULL)
+ {
+ return;
+ }
+
+ if (sfp->toval == 155)
+ {
+ ssp = FindSubSource (biop, 255, sfp, FALSE, FALSE, is_feat);
+ }
+ else
+ {
+ ssp = FindSubSource (biop, sfp->toval - 100, sfp, FALSE, FALSE, is_feat);
+ }
+ if (ssp == NULL)
+ {
+ ssp = SubSourceNew ();
+ if (sfp->toval == 155)
+ {
+ ssp->subtype = 255;
+ }
+ else
+ {
+ ssp->subtype = sfp->toval - 100;
+ }
+ ssp->name = StringSave (mod->subname);
+ ssp->next = biop->subtype;
+ biop->subtype = ssp;
+ }
+ else
+ {
+ AppendOrReplaceString (&(ssp->name), mod->subname,
+ &(sfp->replaceOldAsked),
+ &(sfp->doReplaceAll),
+ &(sfp->use_semicolon));
+ }
+ RemoveOrgModByPtr (biop, mod);
+}
+
static void ProcessBioSourceFunc (BioSourcePtr biop, SourceFormPtr sfp, Boolean is_feat)
{
@@ -8884,6 +9118,7 @@ static void ProcessBioSourceFunc (BioSourcePtr biop, SourceFormPtr sfp, Boolean
CharPtr str = NULL;
CharPtr str1 = NULL;
CharPtr str2 = NULL;
+ CharPtr tmp_str;
if (biop == NULL || sfp == NULL) return;
if (sfp->choice == 1) {
@@ -8913,19 +9148,13 @@ static void ProcessBioSourceFunc (BioSourcePtr biop, SourceFormPtr sfp, Boolean
if (sfp->toval < 1) return;
if (StringHasNoText (sfp->findStr) || StringISearch (str, sfp->findStr) != NULL) {
if (sfp->toval >= 100 && ssp != NULL) {
- ssp->subtype = AssignSubtype (sfp->toval);
+ ConvertSubSourceModifier (biop, sfp, is_feat, ssp);
} else if (sfp->toval < 100 && mod != NULL) {
- mod->subtype = AssignSubtype (sfp->toval);
+ ConvertOrganismModifier (biop, sfp, is_feat, mod);
} else if (sfp->toval < 100 && ssp != NULL) {
- mod = FindOrgMod (biop, sfp->toval, sfp, FALSE, TRUE);
- if (mod == NULL) return;
- mod->subname = StringSave (str);
- ssp = FindSubSource (biop, sfp->fromval - 100, sfp, TRUE, FALSE, is_feat);
+ ConvertSubSourceToOrgMod (biop, sfp, is_feat, ssp);
} else if (sfp->toval >= 100 && mod != NULL) {
- ssp = FindSubSource (biop, sfp->toval - 100, sfp, FALSE, TRUE, is_feat);
- if (ssp == NULL) return;
- ssp->name = StringSave (str);
- mod = FindOrgMod (biop, sfp->fromval, sfp, TRUE, FALSE);
+ ConvertOrgModToSubSource (biop, sfp, is_feat, mod);
}
}
break;
@@ -8944,19 +9173,23 @@ static void ProcessBioSourceFunc (BioSourcePtr biop, SourceFormPtr sfp, Boolean
break;
case ADD_SOURCE :
if (ssp != NULL) {
- ssp->name = MemFree (ssp->name);
- ssp->name = StringSave (sfp->findStr);
+ AppendOrReplaceString (&(ssp->name), sfp->findStr,
+ &(sfp->replaceOldAsked),
+ &(sfp->doReplaceAll),
+ &(sfp->use_semicolon));
if (ssp->name == NULL &&
(ssp->subtype == SUBSRC_germline ||
ssp->subtype == SUBSRC_rearranged ||
ssp->subtype == SUBSRC_environmental_sample)) {
- ssp->name = StringSave ("");
+ ssp->name = StringSave ("");
} else if (ssp->subtype == SUBSRC_transgenic && (! is_feat)) {
ssp->name = StringSave ("");
}
} else if (mod != NULL) {
- mod->subname = MemFree (mod->subname);
- mod->subname = StringSave (sfp->findStr);
+ AppendOrReplaceString (&(mod->subname), sfp->findStr,
+ &(sfp->replaceOldAsked),
+ &(sfp->doReplaceAll),
+ &(sfp->use_semicolon));
}
break;
default :
@@ -8975,7 +9208,6 @@ static void ProcessBioSourceFunc (BioSourcePtr biop, SourceFormPtr sfp, Boolean
}
break;
case EDIT_SOURCE :
- break;
case ADD_SOURCE :
biop->genome = sfp->fromval;
break;
@@ -9012,7 +9244,7 @@ static void ProcessBioSourceFunc (BioSourcePtr biop, SourceFormPtr sfp, Boolean
switch (sfp->fromval) {
case 1 :
if (orp != NULL) {
- orp->taxname = MemFree (orp->taxname);
+ SetTaxNameAndRemoveTaxRef (orp, MemFree (orp->taxname));
}
break;
case 2 :
@@ -9043,7 +9275,10 @@ static void ProcessBioSourceFunc (BioSourcePtr biop, SourceFormPtr sfp, Boolean
if (orp != NULL) {
foundit = StringISearch (orp->taxname, sfp->findStr);
if (foundit != NULL) {
- EditSourceString (&(orp->taxname), sfp, foundit);
+ tmp_str = StringSave (orp->taxname);
+ foundit = StringISearch (tmp_str, sfp->findStr);
+ EditSourceString (&(tmp_str), sfp, foundit);
+ SetTaxNameAndRemoveTaxRef (orp, tmp_str);
}
}
break;
@@ -9247,6 +9482,7 @@ static void DoProcessSource (ButtoN b)
}
if (sfp->type != EDIT_SOURCE
|| (! StringHasNoText (sfp->findStr))
+ || sfp->choice == 2
|| sfp->choice == 3) {
sfp->replaceOldAsked = FALSE;
sfp->doReplaceAll = FALSE;
@@ -9283,7 +9519,11 @@ static void DoProcessSource (ButtoN b)
}
ObjMgrSetDirtyFlag (sfp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, sfp->input_entityID, 0, 0);
- Remove (sfp->form);
+ if (GetStatus (sfp->leaveDlgUp)) {
+ Show (sfp->form);
+ } else {
+ Remove (sfp->form);
+ }
}
@@ -9395,6 +9635,61 @@ static void SourceApplyToPartsProc (ButtoN b)
}
}
+static void ClearProcessSourceDlg (ButtoN b)
+{
+ SourceFormPtr sfp;
+
+ sfp = (SourceFormPtr) GetObjectExtra (b);
+ if (sfp == NULL) return;
+
+ if ( sfp->onlyThisPart != NULL) {
+ Disable (sfp->onlyThisPart);
+ }
+ SetValue (sfp->sourceGroup, 1);
+ Hide (sfp->modGrp);
+ switch (sfp->type) {
+ case REMOVE_SOURCE :
+ SetEnumPopup (sfp->fromgen, biosource_genome_alistX, 0);
+ SetEnumPopup (sfp->fromref, orgref_textfield_alist, 0);
+ SetTitle (sfp->findthis, "");
+ SetValue (sfp->frommod, 1);
+ SetValue (sfp->fromorigin, 1);
+ break;
+ case CONVERT_SOURCE :
+ SetEnumPopup (sfp->fromgen, biosource_genome_alistX, 0);
+ SetEnumPopup (sfp->togen, biosource_genome_alistX, 0);
+ SetEnumPopup (sfp->fromref, orgref_textfield_alist, 0);
+ SetEnumPopup (sfp->toref, orgref_textfield_alist, 0);
+ SetTitle (sfp->findthis, "");
+ SetValue (sfp->frommod, 1);
+ SetValue (sfp->tomod, 1);
+ SetValue (sfp->fromorigin, 1);
+ SetValue (sfp->toorigin, 1);
+ break;
+ case EDIT_SOURCE :
+ SetEnumPopup (sfp->fromgen, biosource_genome_alistX, 0);
+ SetEnumPopup (sfp->fromref, orgref_textfield_alist, 0);
+ SetTitle (sfp->findthis, "");
+ SetTitle (sfp->replacewith, "");
+ SetValue (sfp->frommod, 1);
+ SetValue (sfp->fromorigin, 1);
+ break;
+ case ADD_SOURCE :
+ SetEnumPopup (sfp->fromgen, biosource_genome_alistX, 0);
+ SetTitle (sfp->findthis, "");
+ SetValue (sfp->frommod, 1);
+ SetValue (sfp->fromorigin, 1);
+ break;
+ default :
+ break;
+ }
+ Hide (sfp->genGrp);
+ Hide (sfp->refGrp);
+ Show (sfp->modGrp);
+ SafeHide (sfp->originGrp);
+ Select (sfp->findthis);
+}
+
static void ProcessSource (IteM i, Int2 type)
{
@@ -9465,6 +9760,8 @@ static void ProcessSource (IteM i, Int2 type)
StaticPrompt (x, "Apply only to particular numbered segment", 0, dialogTextHeight, programFont, 'l');
sfp->onlyThisPart = DialogText (x, "", 4, NULL);
Disable (sfp->onlyThisPart);
+ } else {
+ sfp->onlyThisPart = NULL;
}
sfp->sourceGroup = HiddenGroup (h, 4, 0, ChangeSourceGroup);
@@ -9625,9 +9922,12 @@ static void ProcessSource (IteM i, Int2 type)
SafeHide (sfp->originGrp);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoProcessSource);
+ b = DefaultButton (c, "Accept", DoProcessSource);
SetObjectExtra (b, sfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
+ b = PushButton (c, "Clear", ClearProcessSourceDlg);
+ SetObjectExtra (b, sfp, NULL);
+ sfp->leaveDlgUp = CheckBox (c, "Leave Dialog Up", NULL);
AlignObjects (ALIGN_CENTER, (HANDLE) c, (HANDLE) sfp->sourceGroup,
(HANDLE) sfp->modGrp, (HANDLE) sfp->genGrp,
diff --git a/sequin/sequin6.c b/sequin/sequin6.c
index 1c936a0a..3d1c1727 100644
--- a/sequin/sequin6.c
+++ b/sequin/sequin6.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 11/12/97
*
-* $Revision: 6.116 $
+* $Revision: 6.143 $
*
* File Description:
*
@@ -50,6 +50,7 @@
#include <import.h>
#include <objsub.h>
#include <explore.h>
+#include <subutil.h>
#define NUMBER_OF_SUFFIXES 7
@@ -289,6 +290,7 @@ typedef struct convertformdata {
Boolean includeright;
Boolean replaceOldAsked;
Boolean doReplaceAll;
+ Boolean use_semicolon;
Boolean isDirty;
ButtoN removeBefore;
ButtoN removeAfter;
@@ -297,9 +299,14 @@ typedef struct convertformdata {
GrouP ifNotFoundGroup;
Int2 ifNotFound;
Int2 index;
- Boolean isCommentConvert;
+ Int4 parsetype;
} ConvertFormData, PNTR ConvertFormPtr;
+/* values for parse type */
+#define PARSETYPE_FILE 0
+#define PARSETYPE_COMMENT 1
+#define PARSETYPE_LOCALID 2
+
/* Values for ifNotFound field */
#define DO_NOTHING 2
@@ -407,7 +414,8 @@ static void SetConvertAcceptButton (Handle a)
{
if ((! TextHasNoText (cfp->atleft)) ||
(! TextHasNoText (cfp->atright)) ||
- cfp->isCommentConvert)
+ cfp->parsetype == PARSETYPE_COMMENT ||
+ cfp->parsetype == PARSETYPE_LOCALID)
{
SafeEnable (cfp->accept);
return;
@@ -1225,7 +1233,7 @@ extern Int2 LIBCALLBACK CreateDeleteByTextWindow (Pointer data)
cfp = (ConvertFormPtr) MemNew (sizeof (ConvertFormData));
if (cfp == NULL)
return OM_MSG_RET_ERROR;
- cfp->isCommentConvert = FALSE;
+ cfp->parsetype = PARSETYPE_FILE;
w = FixedWindow (-50, -33, -10, -10, "Delete By Text String",
StdCloseWindowProc);
@@ -1309,7 +1317,7 @@ extern Int2 LIBCALLBACK CreateDeleteByTextWindow (Pointer data)
/* Add Accept and Cancel buttons */
c = HiddenGroup (h, 4, 0, NULL);
- cfp->accept = PushButton (c, "Accept", DeleteByText_Callback);
+ cfp->accept = DefaultButton (c, "Accept", DeleteByText_Callback);
SetObjectExtra (cfp->accept, cfp, NULL);
Disable (cfp->accept);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -1329,49 +1337,14 @@ extern Int2 LIBCALLBACK CreateDeleteByTextWindow (Pointer data)
return OM_MSG_RET_OK;
}
-static Boolean ShouldReplaceParsedString (ConvertFormPtr cfp)
-
-{
- MsgAnswer ans;
-
- if (cfp == NULL) return FALSE;
- if (! cfp->replaceOldAsked) {
- cfp->replaceOldAsked = TRUE;
- ArrowCursor ();
- Update ();
- ans = Message (MSG_YN, "Do you wish to overwrite existing contents?");
- WatchCursor ();
- Update ();
- cfp->doReplaceAll = (Boolean) (ans == ANS_YES);
- }
- return cfp->doReplaceAll;
-}
-
static CharPtr SaveOrReplaceStringCopy (ConvertFormPtr cfp, CharPtr str, CharPtr current)
{
- size_t len;
- CharPtr tmp;
-
if (cfp == NULL) return NULL;
if (StringHasNoText (str)) return current;
- if (current != NULL) {
- if (ShouldReplaceParsedString (cfp)) {
- MemFree (current);
- } else {
- len = StringLen (str) + StringLen (current) + 4;
- tmp = MemNew (len);
- if (tmp != NULL) {
- StringCpy (tmp, current);
- StringCat (tmp, "; ");
- StringCat (tmp, str);
- /* str is within asn2ff string, so must not MemFree (str); */
- MemFree (current);
- return tmp;
- }
- }
- }
- return StringSave (str);
+ AppendOrReplaceString (&current, str, &(cfp->replaceOldAsked),
+ &(cfp->doReplaceAll), &(cfp->use_semicolon));
+ return current;
}
static void ConvertAFeatureField (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
@@ -1388,6 +1361,7 @@ static void ConvertAFeatureField (SeqEntryPtr sep, Pointer mydata, Int4 index, I
SeqFeatPtr sfp;
ValNodePtr vnp;
SeqFeatXrefPtr xref;
+ CharPtr cp;
if (sep == NULL || sep->data.ptrvalue == NULL) return;
cfp = (ConvertFormPtr) mydata;
@@ -1424,10 +1398,15 @@ static void ConvertAFeatureField (SeqEntryPtr sep, Pointer mydata, Int4 index, I
break;
case 6 :
if (! StringHasNoText (cfp->foundstr)) {
- if (grp->syn != NULL && ShouldReplaceParsedString (cfp)) {
+ if (grp->syn != NULL) {
vnp = grp->syn;
- vnp->data.ptrvalue = MemFree (vnp->data.ptrvalue);
- vnp->data.ptrvalue = StringSave (cfp->foundstr);
+ cp = vnp->data.ptrvalue;
+ AppendOrReplaceString (&cp,
+ cfp->foundstr,
+ &(cfp->replaceOldAsked),
+ &(cfp->doReplaceAll),
+ &(cfp->use_semicolon));
+ vnp->data.ptrvalue = cp;
} else {
vnp = ValNodeNew (NULL);
if (vnp != NULL) {
@@ -1485,10 +1464,15 @@ static void ConvertAFeatureField (SeqEntryPtr sep, Pointer mydata, Int4 index, I
switch (cfp->subtype) {
case 1 :
if (! StringHasNoText (cfp->foundstr)) {
- if (prp->name != NULL && ShouldReplaceParsedString (cfp)) {
+ if (prp->name != NULL) {
vnp = prp->name;
- vnp->data.ptrvalue = MemFree (vnp->data.ptrvalue);
- vnp->data.ptrvalue = StringSave (cfp->foundstr);
+ cp = vnp->data.ptrvalue;
+ AppendOrReplaceString (&cp,
+ cfp->foundstr,
+ &(cfp->replaceOldAsked),
+ &(cfp->doReplaceAll),
+ &(cfp->use_semicolon));
+ vnp->data.ptrvalue = cp;
} else {
vnp = ValNodeNew (NULL);
if (vnp != NULL) {
@@ -1504,10 +1488,15 @@ static void ConvertAFeatureField (SeqEntryPtr sep, Pointer mydata, Int4 index, I
break;
case 3 :
if (! StringHasNoText (cfp->foundstr)) {
- if (prp->ec != NULL && ShouldReplaceParsedString (cfp)) {
+ if (prp->ec != NULL) {
vnp = prp->ec;
- vnp->data.ptrvalue = MemFree (vnp->data.ptrvalue);
- vnp->data.ptrvalue = StringSave (cfp->foundstr);
+ cp = vnp->data.ptrvalue;
+ AppendOrReplaceString (&cp,
+ cfp->foundstr,
+ &(cfp->replaceOldAsked),
+ &(cfp->doReplaceAll),
+ &(cfp->use_semicolon));
+ vnp->data.ptrvalue = cp;
} else {
vnp = ValNodeNew (NULL);
if (vnp != NULL) {
@@ -1520,10 +1509,15 @@ static void ConvertAFeatureField (SeqEntryPtr sep, Pointer mydata, Int4 index, I
break;
case 4 :
if (! StringHasNoText (cfp->foundstr)) {
- if (prp->activity != NULL && ShouldReplaceParsedString (cfp)) {
+ if (prp->activity != NULL) {
vnp = prp->activity;
- vnp->data.ptrvalue = MemFree (vnp->data.ptrvalue);
- vnp->data.ptrvalue = StringSave (cfp->foundstr);
+ cp = vnp->data.ptrvalue;
+ AppendOrReplaceString (&cp,
+ cfp->foundstr,
+ &(cfp->replaceOldAsked),
+ &(cfp->doReplaceAll),
+ &(cfp->use_semicolon));
+ vnp->data.ptrvalue = cp;
} else {
vnp = ValNodeNew (NULL);
if (vnp != NULL) {
@@ -1602,7 +1596,7 @@ static void ConvertASourceField (BioSourcePtr biop, ConvertFormPtr cfp)
if (orp == NULL) return;
switch (cfp->subtype) {
case ORGREF_SCI_NAME_FIELD :
- orp->taxname = SaveOrReplaceStringCopy (cfp, cfp->foundstr, orp->taxname);
+ SetTaxNameAndRemoveTaxRef (orp, SaveOrReplaceStringCopy (cfp, cfp->foundstr, orp->taxname));
break;
case ORGREF_COMMON_NAME_FIELD :
orp->common = SaveOrReplaceStringCopy (cfp, cfp->foundstr, orp->common);
@@ -1729,6 +1723,13 @@ static void FoundStringForConversion (Uint2 entityID, SeqEntryPtr sep, ConvertFo
break;
case ORGMOD_SUBSOURCE_TYPE :
SeqEntryToBioSource (sep, NULL, NULL, 0, &biop);
+ if (biop == NULL && cfp->parsetype == PARSETYPE_LOCALID
+ && IS_Bioseq (sep))
+ {
+ sep = GetBestTopParentForData (cfp->input_entityID,
+ sep->data.ptrvalue);
+ SeqEntryToBioSource (sep, NULL, NULL, 0, &biop);
+ }
ConvertASourceField (biop, cfp);
break;
case IMPORT_FEAT_TYPE :
@@ -1803,34 +1804,116 @@ static CharPtr FindStringForConversion (CharPtr string, ConvertFormPtr cfp)
return NULL;
}
-static void ConvertOneComment (SeqDescrPtr sdp, Pointer userdata)
+static void ConvertBioseqComments (BioseqPtr bsp, Pointer userdata)
{
CharPtr string;
CommentConvertPtr ccp;
ConvertFormPtr cfp;
CharPtr result;
-
- if (sdp == NULL
- || sdp->choice != Seq_descr_comment
- || sdp->data.ptrvalue == NULL
+ SeqDescrPtr sdp;
+ SeqFeatPtr sfp;
+ SeqEntryPtr sep, psep;
+ SeqMgrDescContext dcontext;
+ SeqMgrFeatContext fcontext;
+ UserObjectPtr uop;
+ ObjectIdPtr oip;
+ UserFieldPtr ufp;
+
+ if (bsp == NULL
|| (ccp = (CommentConvertPtr) userdata) == NULL
|| (cfp = ccp->cfp) == NULL)
{
return;
}
- string = StringSave (sdp->data.ptrvalue);
- if (string == NULL || *string == '\0')
+ sep = SeqMgrGetSeqEntryForData (bsp);
+ if (sep == NULL) return;
+
+ psep = GetBestTopParentForDataEx (ccp->entityID, bsp, TRUE);
+ if (psep != NULL) sep = psep;
+
+ /* Get descriptor comments */
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_comment, &dcontext);
+ while (sdp != NULL)
{
- MemFree (string);
- return;
+ if (sdp->data.ptrvalue != NULL)
+ {
+ string = StringSave (sdp->data.ptrvalue);
+
+ if (string == NULL || *string == '\0')
+ {
+ MemFree (string);
+ return;
+ }
+
+ if ((result = FindStringForConversion (string, cfp)) != NULL)
+ {
+ FoundStringForConversion (ccp->entityID, sep, cfp, result);
+ }
+ MemFree (string);
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_comment, &dcontext);
+ }
+
+ /* get BankIt comments */
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, Seq_descr_user, &dcontext);
+ while (sdp != NULL)
+ {
+ if (sdp->data.ptrvalue != NULL && sdp->extended != 0)
+ {
+ uop = (UserObjectPtr) sdp->data.ptrvalue;
+ oip = uop->type;
+ if (oip != NULL && StringCmp (oip->str, "Submission") == 0)
+ {
+ for (ufp = uop->data; ufp != NULL; ufp = ufp->next)
+ {
+ oip = ufp->label;
+ if (oip != NULL && StringCmp (oip->str, "AdditionalComment") == 0)
+ {
+ string = StringSave (ufp->data.ptrvalue);
+
+ if (string == NULL || *string == '\0')
+ {
+ MemFree (string);
+ return;
+ }
+
+ if ((result = FindStringForConversion (string, cfp)) != NULL)
+ {
+ FoundStringForConversion (ccp->entityID, sep, cfp, result);
+ }
+ MemFree (string);
+ }
+ }
+ }
+ }
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, Seq_descr_user, &dcontext);
}
+
- if ((result = FindStringForConversion (string, cfp)) != NULL)
+ /* get feature comments */
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_COMMENT, 0, &fcontext);
+ while (sfp != NULL)
{
- FoundStringForConversion (ccp->entityID, ccp->sep, cfp, result);
+ if (sfp->comment != NULL)
+ {
+ string = StringSave (sfp->comment);
+
+ if (string == NULL || *string == '\0')
+ {
+ MemFree (string);
+ return;
+ }
+
+ if ((result = FindStringForConversion (string, cfp)) != NULL)
+ {
+ FoundStringForConversion (ccp->entityID, sep, cfp, result);
+ }
+ MemFree (string);
+ }
+ sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_COMMENT, 0, &fcontext);
}
- MemFree (string);
+
}
static void ConvertFromComment (
@@ -1847,7 +1930,51 @@ static void ConvertFromComment (
ccd.entityID = entityID;
ccd.sep = sep;
ccd.cfp = cfp;
- VisitDescriptorsOnSep (sep, &ccd, ConvertOneComment);
+ VisitBioseqsInSep (sep, &ccd, ConvertBioseqComments);
+ ErrSetMessageLevel (level);
+}
+
+static void ConvertOneLocalID (BioseqPtr bsp, Pointer userdata)
+{
+ SeqEntryPtr sep;
+ SeqIdPtr sip;
+ Char str [256];
+ CharPtr result;
+ ConvertFormPtr cfp;
+
+ if (bsp == NULL || userdata == NULL) return;
+
+ cfp = (ConvertFormPtr) userdata;
+ sep = SeqMgrGetSeqEntryForData (bsp);
+ if (sep == NULL) return;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_LOCAL) {
+ SeqIdWrite (sip, str, PRINTID_REPORT, sizeof (str));
+ if (StringNICmp (str, "tmpseq_", 7) != 0 &&
+ StringNICmp (str, "segseq_", 7) != 0 &&
+ StringNICmp (str, "SEG_dna", 7) != 0 &&
+ str [0] != 0)
+ {
+ if ((result = FindStringForConversion (str, cfp)) != NULL)
+ {
+ FoundStringForConversion (cfp->input_entityID, sep, cfp, result);
+ }
+ }
+ }
+ }
+}
+
+static void ConvertFromLocalIDs (
+ SeqEntryPtr sep,
+ ConvertFormPtr cfp
+)
+{
+ ErrSev level;
+
+ level = ErrSetMessageLevel (SEV_MAX);
+
+ VisitBioseqsInSep (sep, cfp, ConvertOneLocalID);
ErrSetMessageLevel (level);
}
@@ -1943,11 +2070,18 @@ static void DoOneConvert (Uint2 entityID, SeqEntryPtr sep, ConvertFormPtr cfp, M
Char str [64];
if (sep == NULL || cfp == NULL) return;
+ if (cfp->parsetype == PARSETYPE_COMMENT)
+ {
+ ConvertFromComment (entityID, sep, cfp);
+ return;
+ }
+ else if (cfp->parsetype == PARSETYPE_LOCALID)
+ {
+ ConvertFromLocalIDs (sep, cfp);
+ return;
+ }
+
if (IS_Bioseq_set (sep)) {
- if (cfp->report == 3)
- {
- ConvertFromComment (entityID, sep, cfp);
- }
bssp = (BioseqSetPtr) sep->data.ptrvalue;
if (bssp != NULL && (bssp->_class == 7 ||
(IsPopPhyEtcSet (bssp->_class)))) {
@@ -1962,18 +2096,26 @@ static void DoOneConvert (Uint2 entityID, SeqEntryPtr sep, ConvertFormPtr cfp, M
sprintf (str, "Parsing component %d", (int) cfp->index);
MonitorStrValue (mon, str);
}
- switch (cfp->report) {
- case 1 :
- ConvertFromFlatFile (entityID, sep, cfp, GENBANK_FMT);
- break;
- case 2 :
- ConvertFromFlatFile (entityID, sep, cfp, EMBL_FMT);
- break;
- case 3 :
- ConvertFromComment (entityID, sep, cfp);
- break;
- default :
- break;
+ if (cfp->parsetype == PARSETYPE_FILE)
+ {
+ switch (cfp->report) {
+ case 1 :
+ ConvertFromFlatFile (entityID, sep, cfp, GENBANK_FMT);
+ break;
+ case 2 :
+ ConvertFromFlatFile (entityID, sep, cfp, EMBL_FMT);
+ break;
+ default :
+ break;
+ }
+ }
+ else if (cfp->parsetype == PARSETYPE_COMMENT)
+ {
+ ConvertFromComment (entityID, sep, cfp);
+ }
+ else if (cfp->parsetype == PARSETYPE_LOCALID)
+ {
+ ConvertFromLocalIDs (sep, cfp);
}
}
@@ -2187,6 +2329,7 @@ static void RemoveASourceText (BioSourcePtr biop, ConvertFormPtr cfp)
OrgNamePtr onp;
OrgRefPtr orp;
SubSourcePtr ssp;
+ CharPtr tmp_str;
if (biop == NULL || cfp == NULL) return;
switch (cfp->type) {
@@ -2195,7 +2338,9 @@ static void RemoveASourceText (BioSourcePtr biop, ConvertFormPtr cfp)
if (orp == NULL) return;
switch (cfp->subtype) {
case ORGREF_SCI_NAME_FIELD :
- SearchAndExciseText (&orp->taxname, cfp);
+ tmp_str = StringSave (orp->taxname);
+ SearchAndExciseText (&tmp_str, cfp);
+ SetTaxNameAndRemoveTaxRef (orp, tmp_str);
break;
case ORGREF_COMMON_NAME_FIELD :
SearchAndExciseText (&orp->common, cfp);
@@ -2374,10 +2519,14 @@ static void DoConvertProc (ButtoN b)
cfp->endQuotesFlag = FALSE;
cfp->includeleft = (Boolean) (GetValue (cfp->leftbehav) == 2);
cfp->includeright = (Boolean) (GetValue (cfp->rightbehav) == 2);
- if (cfp->report == 3)
+ if (cfp->parsetype == PARSETYPE_COMMENT)
{
mon = MonitorStrNewEx ("Parsing Text From Comments", 20, FALSE);
}
+ else if (cfp->parsetype == PARSETYPE_LOCALID)
+ {
+ mon = MonitorStrNewEx ("Parsing Text From Local IDs", 20, FALSE);
+ }
else
{
mon = MonitorStrNewEx ("Parsing Text From FlatFile", 20, FALSE);
@@ -2506,7 +2655,7 @@ static void CleanupParseForm (GraphiC g, VoidPtr data)
StdCleanupFormProc (g, data);
}
-static void BuildParseToAnywhereDialog (IteM i, Boolean use_files)
+static void BuildParseToAnywhereDialog (IteM i, Int4 parsetype)
{
EnumFieldAssocPtr ap;
@@ -2534,14 +2683,8 @@ static void BuildParseToAnywhereDialog (IteM i, Boolean use_files)
cfp = (ConvertFormPtr) MemNew (sizeof (ConvertFormData));
if (cfp == NULL) return;
- if (use_files)
- {
- cfp->isCommentConvert = FALSE;
- }
- else
- {
- cfp->isCommentConvert = TRUE;
- }
+ cfp->parsetype = parsetype;
+
w = FixedWindow (-50, -33, -10, -10, "General Field Conversion", StdCloseWindowProc);
SetObjectExtra (w, cfp, CleanupParseForm);
cfp->form = (ForM) w;
@@ -2560,7 +2703,7 @@ static void BuildParseToAnywhereDialog (IteM i, Boolean use_files)
h = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
- if (use_files)
+ if (cfp->parsetype == PARSETYPE_FILE)
{
q = HiddenGroup (h, 4, 0, NULL);
StaticPrompt (q, "File format to parse", 0, stdLineHeight, programFont, 'l');
@@ -2632,7 +2775,7 @@ static void BuildParseToAnywhereDialog (IteM i, Boolean use_files)
}
c = HiddenGroup (h, 4, 0, NULL);
- cfp->accept = PushButton (c, "Accept", DoConvertProc);
+ cfp->accept = DefaultButton (c, "Accept", DoConvertProc);
SetObjectExtra (cfp->accept, cfp, NULL);
Disable (cfp->accept);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -2648,13 +2791,18 @@ static void BuildParseToAnywhereDialog (IteM i, Boolean use_files)
extern void ParseAsnOrFlatfileToAnywhere (IteM i)
{
- BuildParseToAnywhereDialog (i, TRUE);
+ BuildParseToAnywhereDialog (i, PARSETYPE_FILE);
}
extern void ParseCommentToAnywhere (IteM i)
{
- BuildParseToAnywhereDialog (i, FALSE);
+ BuildParseToAnywhereDialog (i, PARSETYPE_COMMENT);
+}
+
+extern void ParseLocalIDToAnywhere (IteM i)
+{
+ BuildParseToAnywhereDialog (i, PARSETYPE_LOCALID);
}
/*---------------------------------------------------------------------*/
@@ -3635,7 +3783,7 @@ extern void RemoveTextOutsideString (IteM i)
if (cfp == NULL)
return;
- cfp->isCommentConvert = FALSE;
+ cfp->parsetype = PARSETYPE_FILE;
/* Create a window for getting user input */
@@ -3768,7 +3916,7 @@ extern void RemoveTextOutsideString (IteM i)
/* Accept and Cancel buttons */
buttonGroup = HiddenGroup (mainGroup, 4, 0, NULL);
- cfp->accept = PushButton (buttonGroup, "Accept",
+ cfp->accept = DefaultButton (buttonGroup, "Accept",
RemOutTxt_AcceptCallback);
SetObjectExtra (cfp->accept, cfp, NULL);
Disable (cfp->accept);
@@ -3814,7 +3962,7 @@ extern void RemoveTextInsideString (IteM i)
cfp = (ConvertFormPtr) MemNew (sizeof (ConvertFormData));
if (cfp == NULL) return;
- cfp->isCommentConvert = FALSE;
+ cfp->parsetype = PARSETYPE_FILE;
w = FixedWindow (-50, -33, -10, -10, "General Text Excision", StdCloseWindowProc);
SetObjectExtra (w, cfp, StdCleanupFormProc);
@@ -3892,7 +4040,7 @@ extern void RemoveTextInsideString (IteM i)
}
c = HiddenGroup (h, 4, 0, NULL);
- cfp->accept = PushButton (c, "Accept", DoRemoveTextProc);
+ cfp->accept = DefaultButton (c, "Accept", DoRemoveTextProc);
SetObjectExtra (cfp->accept, cfp, NULL);
Disable (cfp->accept);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -4114,7 +4262,7 @@ static ENUM_ALIST(rnax_subtype_alist)
{"snRNA", 5},
{"scRNA", 6},
{"snoRNA", 7},
- {"Other RNA", 255},
+ {"misc_RNA", 255},
END_ENUM_ALIST
typedef struct applyformdata {
@@ -4140,6 +4288,8 @@ typedef struct applyformdata {
EnumFieldAssoc PNTR realalist;
EnumFieldAssoc PNTR alist;
GrouP strand_group;
+ PopuP reading_frame;
+ ButtoN leaveDlgUp;
} ApplyFormData, PNTR ApplyFormPtr;
typedef struct alreadyhas {
@@ -4318,34 +4468,42 @@ static void Apply_AddCDS (Uint2 entityID,
if (! TextHasNoText (afp->featcomment)) {
sfp->comment = SaveStringFromTextAndStripNewlines (afp->featcomment);
}
- max = 0;
- frame = 0;
- for (i = 1; i <= 3; i++) {
- crp->frame = (Uint1) i;
- bs = ProteinFromCdRegionEx (sfp, FALSE, FALSE);
- len = BSLen (bs);
- BSFree (bs);
- lens [i] = len;
- if (len > max) {
- max = len;
- frame = (Uint1) i;
- }
- }
- str [0] = '\0';
- if (IS_Bioseq (nsep)) {
- bsp = (BioseqPtr) nsep->data.ptrvalue;
- if (bsp != NULL) {
- sip = SeqIdFindBest (bsp->id, 0);
- SeqIdWrite (sip, str, PRINTID_REPORT, sizeof (str) - 1);
+
+ if (GetValue (afp->reading_frame) < 1 || GetValue (afp->reading_frame) > 3)
+ {
+ max = 0;
+ frame = 0;
+ for (i = 1; i <= 3; i++) {
+ crp->frame = (Uint1) i;
+ bs = ProteinFromCdRegionEx (sfp, FALSE, FALSE);
+ len = BSLen (bs);
+ BSFree (bs);
+ lens [i] = len;
+ if (len > max) {
+ max = len;
+ frame = (Uint1) i;
+ }
}
- }
- for (i = 1; i <= 3; i++) {
- if (lens [i] == max && i != frame) {
- (afp->errcount)++;
- ValNodeCopyStr (&(afp->ambigList), 0, str);
+ str [0] = '\0';
+ if (IS_Bioseq (nsep)) {
+ bsp = (BioseqPtr) nsep->data.ptrvalue;
+ if (bsp != NULL) {
+ sip = SeqIdFindBest (bsp->id, 0);
+ SeqIdWrite (sip, str, PRINTID_REPORT, sizeof (str) - 1);
+ }
}
+ for (i = 1; i <= 3; i++) {
+ if (lens [i] == max && i != frame) {
+ (afp->errcount)++;
+ ValNodeCopyStr (&(afp->ambigList), 0, str);
+ }
+ }
+ crp->frame = frame;
+ }
+ else
+ {
+ crp->frame = GetValue (afp->reading_frame);
}
- crp->frame = frame;
/* Create corresponding protein sequence data for the CDS */
@@ -4591,7 +4749,7 @@ static void RealApplyBioFeatToAll (Uint2 entityID,
if (val > 0) {
ifp = ImpFeatNew ();
if (ifp != NULL) {
- if (val > 1) {
+ if (val > 0) {
for (i = 1, ap = afp->alist; ap->name != NULL; i++, ap++) {
if (i == val) {
ifp->key = StringSave (ap->name);
@@ -4790,6 +4948,11 @@ Int2 ApplyAnnotationToAll (Int2 type, SeqEntryPtr sep,
return 0;
}
+static void CommonApplyToAllProcBfpInfo (Uint2 entityID,
+ Uint4 itemID,
+ Uint2 itemtype,
+ Int2 type);
+
static void NowReadyToApplyToAll (ApplyFormPtr afp, DialoG gbquals)
{
@@ -4868,6 +5031,13 @@ static void NowReadyToApplyToAll (ApplyFormPtr afp, DialoG gbquals)
ObjMgrSetDirtyFlag (afp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, afp->input_entityID, 0, 0);
Remove (afp->form);
+ if (afp->type == ADD_IMP && GetStatus (afp->leaveDlgUp))
+ {
+ CommonApplyToAllProcBfpInfo (afp->input_entityID,
+ afp->input_itemID,
+ afp->input_itemtype,
+ ADD_IMP);
+ }
}
typedef struct qualsform {
@@ -5014,31 +5184,27 @@ static void CleanupApplyToAllForm (GraphiC g, VoidPtr data)
StdCleanupFormProc (g, data);
}
-static void CommonApplyToAllProc (IteM i, Int2 type)
-
+static void CommonApplyToAllProcBfpInfo (Uint2 entityID,
+ Uint4 itemID,
+ Uint2 itemtype,
+ Int2 type)
{
ApplyFormPtr afp;
EnumFieldAssocPtr ap;
- BaseFormPtr bfp;
ButtoN b;
GrouP c;
GrouP g = NULL;
GrouP h;
GrouP p;
GrouP q;
+ GrouP r;
SeqEntryPtr sep;
StdEditorProcsPtr sepp;
WindoW w;
GrouP x;
GrouP z;
-#ifdef WIN_MAC
- bfp = currentFormDataPtr;
-#else
- bfp = GetObjectExtra (i);
-#endif
- if (bfp == NULL) return;
- sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ sep = GetTopSeqEntryForEntityID (entityID);
if (sep == NULL) return;
afp = (ApplyFormPtr) MemNew (sizeof (ApplyFormData));
if (afp == NULL) return;
@@ -5053,9 +5219,9 @@ static void CommonApplyToAllProc (IteM i, Int2 type)
afp->appmessage = sepp->handleMessages;
}
- afp->input_entityID = bfp->input_entityID;
- afp->input_itemID = bfp->input_itemID;
- afp->input_itemtype = bfp->input_itemtype;
+ afp->input_entityID = entityID;
+ afp->input_itemID = itemID;
+ afp->input_itemtype = itemtype;
h = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
@@ -5086,6 +5252,17 @@ static void CommonApplyToAllProc (IteM i, Int2 type)
SetValue (afp->strand_group, 1);
}
+ if (type == ADD_CDS) {
+ r = HiddenGroup (h, 2, 0, NULL);
+ StaticPrompt (r, "Codon Start", 0, dialogTextHeight, programFont, 'l');
+ afp->reading_frame = PopupList (r, TRUE, NULL);
+ PopupItem (afp->reading_frame, "1");
+ PopupItem (afp->reading_frame, "2");
+ PopupItem (afp->reading_frame, "3");
+ PopupItem (afp->reading_frame, "Best");
+ SetValue (afp->reading_frame, 4);
+ }
+
if (type == ADD_TITLE) {
p = HiddenGroup (h, 0, 2, NULL);
StaticPrompt (p, "Title", 0, 0, programFont, 'c');
@@ -5104,6 +5281,7 @@ static void CommonApplyToAllProc (IteM i, Int2 type)
afp->geneName = DialogText (p, "", 20, NULL);
} else if (type == ADD_IMP) {
ap = import_featdef_alist (FALSE, FALSE, FALSE);
+ SortEnumFieldAssocPtrArray (ap, CompareImpFeatEnumFieldAssoc);
afp->realalist = ap;
ap++;
afp->alist = ap;
@@ -5131,12 +5309,23 @@ static void CommonApplyToAllProc (IteM i, Int2 type)
}
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoTheApplyToAllProc);
+ b = DefaultButton (c, "Accept", DoTheApplyToAllProc);
SetObjectExtra (b, afp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
+ if (afp->type == ADD_IMP) {
+ afp->leaveDlgUp = CheckBox (c, "Leave Dialog Up", NULL);
+ } else {
+ afp->leaveDlgUp = NULL;
+ }
- AlignObjects (ALIGN_CENTER, (HANDLE) p, (HANDLE) c, (HANDLE) z,
- (HANDLE) g, (HANDLE) afp->strand_group, (HANDLE) q, NULL);
+ if (type == ADD_CDS)
+ {
+ AlignObjects (ALIGN_CENTER, (HANDLE) p, (HANDLE) c, (HANDLE) z,
+ (HANDLE) g, (HANDLE) afp->strand_group, (HANDLE) r, (HANDLE) q, NULL);
+ } else {
+ AlignObjects (ALIGN_CENTER, (HANDLE) p, (HANDLE) c, (HANDLE) z,
+ (HANDLE) g, (HANDLE) afp->strand_group, (HANDLE) q, NULL);
+ }
RealizeWindow (w);
Show (w);
if (type == ADD_TITLE) {
@@ -5149,28 +5338,50 @@ static void CommonApplyToAllProc (IteM i, Int2 type)
Update ();
}
+extern void CommonApplyToAllProc (BaseFormPtr bfp, Int2 type)
+{
+ if (bfp == NULL) return;
+ CommonApplyToAllProcBfpInfo (bfp->input_entityID,
+ bfp->input_itemID,
+ bfp->input_itemtype, type);
+}
+
+static void CommonApplyToAllProcMenuItem (IteM i, Int2 type)
+{
+ BaseFormPtr bfp;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+
+ CommonApplyToAllProc (bfp, type);
+}
+
extern void ApplyTitle (IteM i)
{
- CommonApplyToAllProc (i, ADD_TITLE);
+ CommonApplyToAllProcMenuItem (i, ADD_TITLE);
}
extern void ApplyCDS (IteM i)
{
- CommonApplyToAllProc (i, ADD_CDS);
+ CommonApplyToAllProcMenuItem (i, ADD_CDS);
}
extern void ApplyRRNA (IteM i)
{
- CommonApplyToAllProc (i, ADD_RRNA);
+ CommonApplyToAllProcMenuItem (i, ADD_RRNA);
}
extern void ApplyImpFeat (IteM i)
{
- CommonApplyToAllProc (i, ADD_IMP);
+ CommonApplyToAllProcMenuItem (i, ADD_IMP);
}
#define SUBMISSION_PAGE 0
@@ -6597,6 +6808,15 @@ static ENUM_ALIST(rna_field_alist)
{"Product GBQUAL", 3},
END_ENUM_ALIST
+static ENUM_ALIST(rna_removal_field_alist)
+ {" ", 0},
+ {"Name", 1},
+ {"Comment", 2},
+ {"Product GBQUAL", 3},
+ {"Anticodon", 4},
+ {"Codons Recognized", 5},
+END_ENUM_ALIST
+
static ENUM_ALIST(rna_subtype_alist)
{" ", 99},
{"unknown", 0},
@@ -6607,7 +6827,7 @@ static ENUM_ALIST(rna_subtype_alist)
{"snRNA", 5},
{"scRNA", 6},
{"snoRNA", 7},
- {"Other RNA", 255},
+ {"misc_RNA", 255},
END_ENUM_ALIST
typedef struct rnaformdata {
@@ -6874,6 +7094,7 @@ static Boolean CleanupEachRNAFunc (GatherContextPtr gcp)
RnaRefPtr rrp;
SeqFeatPtr sfp;
UIEnum val;
+ tRNAPtr trp;
if (gcp == NULL) return TRUE;
rfp = (RnaFormPtr) gcp->userdata;
@@ -6939,6 +7160,27 @@ static Boolean CleanupEachRNAFunc (GatherContextPtr gcp)
gbqual = nextqual;
}
break;
+ case 4 :
+ if (rrp->ext.choice == 2) {
+ trp = (tRNAPtr) rrp->ext.value.ptrvalue;
+ if (trp != NULL && trp->anticodon != NULL) {
+ trp->anticodon = SeqLocFree (trp->anticodon);
+ }
+ }
+ break;
+ case 5 :
+ if (rrp->ext.choice == 2) {
+ trp = (tRNAPtr) rrp->ext.value.ptrvalue;
+ if (trp != NULL) {
+ trp->codon [0] = 255;
+ trp->codon [1] = 255;
+ trp->codon [2] = 255;
+ trp->codon [3] = 255;
+ trp->codon [4] = 255;
+ trp->codon [5] = 255;
+ }
+ }
+ break;
default :
break;
}
@@ -6968,8 +7210,15 @@ static void DoProcessRnaProc (ButtoN b)
Update ();
rfp->fromval = 0;
rfp->toval = 0;
- if (GetEnumPopup (rfp->fromfield, rna_field_alist, &val)) {
- rfp->fromval = (Int2) val;
+
+ if (rfp->type == REMOVE_RNA) {
+ if (GetEnumPopup (rfp->fromfield, rna_removal_field_alist, &val)) {
+ rfp->fromval = (Int2) val;
+ }
+ } else {
+ if (GetEnumPopup (rfp->fromfield, rna_field_alist, &val)) {
+ rfp->fromval = (Int2) val;
+ }
}
if (GetEnumPopup (rfp->tofield, rna_field_alist, &val)) {
rfp->toval = (Int2) val;
@@ -7084,8 +7333,8 @@ static void ProcessRNA (IteM i, Int2 type)
StaticPrompt (g, "Remove", 0, popupMenuHeight, programFont, 'l');
rfp->fromfield = PopupList (g, TRUE, NULL);
SetObjectExtra (rfp->fromfield, rfp, NULL);
- InitEnumPopup (rfp->fromfield, rna_field_alist, NULL);
- SetEnumPopup (rfp->fromfield, rna_field_alist, 0);
+ InitEnumPopup (rfp->fromfield, rna_removal_field_alist, NULL);
+ SetEnumPopup (rfp->fromfield, rna_removal_field_alist, 0);
break;
case CONVERT_RNA :
StaticPrompt (g, "From", 0, popupMenuHeight, programFont, 'l');
@@ -7158,7 +7407,7 @@ static void ProcessRNA (IteM i, Int2 type)
}
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoProcessRnaProc);
+ b = DefaultButton (c, "Accept", DoProcessRnaProc);
SetObjectExtra (b, rfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -7192,6 +7441,74 @@ extern void EditRNA (IteM i)
ProcessRNA (i, EDIT_RNA);
}
+typedef struct orgnamechangedata {
+ CharPtr oldname;
+ CharPtr newname;
+} OrgNameChangeData, PNTR OrgNameChangePtr;
+
+static void ReplaceOldOrgNameInTitle (SeqDescrPtr sdp, OrgNameChangePtr oncp)
+{
+ CharPtr oldtitle, newtitle, orgnamestart;
+ Int4 oldorglen;
+
+ if (sdp == NULL || oncp == NULL
+ || oncp->oldname == NULL || oncp->newname == NULL)
+ {
+ return;
+ }
+
+ oldtitle = sdp->data.ptrvalue;
+
+ if (oldtitle == NULL) return;
+
+ orgnamestart = StringRChr (oldtitle, '[');
+ if (orgnamestart == NULL) return;
+ oldorglen = StringLen (oncp->oldname);
+ if (StringNCmp (orgnamestart + 1, oncp->oldname, oldorglen) == 0
+ && orgnamestart [ oldorglen + 1] == ']')
+ {
+ newtitle = MemNew (StringLen (oldtitle) - StringLen (oncp->oldname) + StringLen (oncp->newname) + 2);
+ if (newtitle == NULL) return;
+ StringNCpy (newtitle, oldtitle, orgnamestart - oldtitle + 1);
+ StringCat (newtitle, oncp->newname);
+ StringCat (newtitle, "]");
+ MemFree (sdp->data.ptrvalue);
+ sdp->data.ptrvalue = newtitle;
+ }
+}
+
+static void FixProteinTitleAfterOrganismNameChange (BioseqPtr bsp, Pointer userdata)
+{
+ OrgNameChangePtr oncp;
+ SeqDescrPtr sdp;
+ BioSourcePtr biop;
+
+ if (bsp == NULL
+ || ! ISA_aa (bsp->mol)
+ || (oncp = (OrgNameChangePtr)userdata) == NULL
+ || oncp->oldname == NULL
+ || oncp->newname == NULL)
+ {
+ return;
+ }
+
+ for (sdp = bsp->descr; sdp != NULL; sdp = sdp->next) {
+ if (sdp->choice == Seq_descr_title)
+ {
+ ReplaceOldOrgNameInTitle (sdp, oncp);
+ }
+ else if (sdp->choice == Seq_descr_source)
+ {
+ biop = sdp->data.ptrvalue;
+ if (biop != NULL && biop->org != NULL
+ && StringCmp (biop->org->taxname, oncp->oldname) == 0)
+ {
+ SetTaxNameAndRemoveTaxRef (biop->org, StringSave (oncp->newname));
+ }
+ }
+ }
+}
+
typedef struct parseformdata {
FEATURE_FORM_BLOCK
@@ -7203,115 +7520,135 @@ typedef struct parseformdata {
Boolean parsedef;
Char path [PATH_MAX];
FILE *fp;
+ Boolean replaceOldAsked;
+ Boolean doReplaceAll;
+ Boolean use_semicolon;
+ ButtoN leaveDlgUp;
} ParseFormData, PNTR ParseFormPtr;
-static void DoOneParseItem (Uint2 entityID, SeqEntryPtr sep, ParseFormPtr pfp, BioSourcePtr topbiop, CharPtr useme, SeqEntryPtr nps)
-
+typedef struct localidfinddata {
+ CharPtr str;
+ Int4 str_size;
+} LocalIDFindData, PNTR LocalIDFindPtr;
+
+static void LookForLocalID (BioseqPtr bsp, Pointer userdata)
{
- BioSourcePtr biop;
- BioseqPtr bsp;
- BioseqSetPtr bssp;
- OrgModPtr mod;
- SeqEntryPtr nsep;
- OrgNamePtr onp;
- Uint1 orgmodtype;
- OrgRefPtr orp;
- CharPtr ptr;
+ LocalIDFindPtr lidfp;
SeqIdPtr sip;
- SubSourcePtr ssp;
- Char str [256];
- Uint1 subsourcetype;
- Uint1 subtype;
- Int2 taxnameval;
- SeqEntryPtr tmp;
- OrgModPtr tmpmod;
- SubSourcePtr tmpssp;
- ValNodePtr ttl;
- Char txt [128];
- UIEnum val;
- ValNodePtr vnp;
- if (sep == NULL || pfp == NULL) return;
- if (IS_Bioseq_set (sep)) {
- bssp = (BioseqSetPtr) sep->data.ptrvalue;
- if (bssp != NULL) {
- /* if nucprot set, look for biosource here */
- biop = NULL;
- SeqEntryToBioSource (sep, NULL, NULL, 0, &biop);
- if (biop != NULL && topbiop != NULL) {
- topbiop = biop;
- }
- for (tmp = bssp->seq_set; tmp != NULL; tmp = tmp->next) {
- DoOneParseItem (entityID, tmp, pfp, topbiop, useme, sep);
+ if (bsp == NULL || (lidfp = (LocalIDFindPtr) userdata) == NULL) {
+ return;
+ }
+ if (lidfp->str [0] != 0) return;
+
+ for (sip = bsp->id; sip != NULL; sip = sip->next) {
+ if (sip->choice == SEQID_LOCAL) {
+ SeqIdWrite (sip, lidfp->str, PRINTID_REPORT, lidfp->str_size);
+ if (StringNICmp (lidfp->str, "tmpseq_", 7) == 0 ||
+ StringNICmp (lidfp->str, "segseq_", 7) == 0 ||
+ StringNICmp (lidfp->str, "SEG_dna", 7) == 0)
+ {
+ /* don't want to use this one */
+ lidfp->str [0] = 0;
+ } else {
+ return;
}
- return;
}
}
+}
+
+static void FindLocalIDForOrganism (
+ SeqEntryPtr sep,
+ CharPtr str,
+ Int4 str_size
+)
+{
+ LocalIDFindData lidfd;
+
+ if (sep == NULL || sep->data.ptrvalue == NULL) return;
+ lidfd.str = str;
+ lidfd.str_size = str_size;
+ VisitBioseqsInSep (sep, (Pointer) &lidfd, LookForLocalID);
+}
+
+static void GetDataForOrganism (
+ SeqEntryPtr sep,
+ CharPtr str,
+ Int4 str_size,
+ CharPtr useme,
+ ParseFormPtr pfp
+)
+{
+ SeqEntryPtr nsep;
+ ValNodePtr ttl;
+ Char txt [128];
+ CharPtr ptr;
+
+ str [0] = 0;
+ if (sep == NULL || pfp == NULL) return;
nsep = FindNucSeqEntry (sep);
- if (nsep != NULL && nsep->data.ptrvalue != NULL) {
- str [0] = '\0';
- if (useme != NULL) {
- StringNCpy_0 (str, useme, sizeof (str));
- } else if (pfp->parsedef) {
- ttl = SeqEntryGetSeqDescr (nsep, Seq_descr_title, NULL);
- if (ttl == NULL && nps != NULL) {
- ttl = SeqEntryGetSeqDescr (nps, Seq_descr_title, NULL);
- }
- if (ttl == NULL || ttl->data.ptrvalue == NULL) return;
- StringNCpy_0 (str, (CharPtr) ttl->data.ptrvalue, sizeof (str));
- GetTitle (pfp->atleft, txt, sizeof (txt));
- if (! StringHasNoText (txt)) {
- ptr = StringISearch (str, txt);
- if (ptr != NULL) {
- StringNCpy_0 (str, ptr + StringLen (txt), sizeof (str));
- }
- }
- GetTitle (pfp->atright, txt, sizeof (txt));
- if (txt [0] != '\0' /* ! StringHasNoText (txt) */) {
- ptr = StringISearch (str, txt);
- if (ptr != NULL) {
- *ptr = '\0';
- }
- }
- } else {
- bsp = (BioseqPtr) nsep->data.ptrvalue;
- for (sip = bsp->id; sip != NULL; sip = sip->next) {
- if (sip->choice == SEQID_LOCAL) {
- SeqIdWrite (sip, str, PRINTID_REPORT, sizeof (str));
- if (StringNICmp (str, "tmpseq_", 7) == 0 ||
- StringNICmp (str, "segseq_", 7) == 0 ||
- StringNICmp (str, "SEG_dna", 7) == 0) return;
- }
+ if (nsep == NULL || nsep->data.ptrvalue == NULL) return;
+
+ if (useme != NULL) {
+ StringNCpy_0 (str, useme, str_size);
+ } else if (pfp->parsedef) {
+ ttl = SeqEntryGetSeqDescr (nsep, Seq_descr_title, NULL);
+ if (ttl == NULL && sep != nsep) {
+ ttl = SeqEntryGetSeqDescr (sep, Seq_descr_title, NULL);
+ }
+ if (ttl == NULL || ttl->data.ptrvalue == NULL) return;
+ StringNCpy_0 (str, (CharPtr) ttl->data.ptrvalue, str_size);
+ GetTitle (pfp->atleft, txt, sizeof (txt));
+ if (! StringHasNoText (txt)) {
+ ptr = StringISearch (str, txt);
+ if (ptr != NULL) {
+ StringNCpy_0 (str, ptr + StringLen (txt), str_size);
}
}
- if (StringHasNoText (str)) return;
- biop = NULL;
- SeqEntryToBioSource (sep, NULL, NULL, 0, &biop);
- taxnameval = GetValue (pfp->taxname);
- if (taxnameval == 2) {
- if (biop == NULL) {
- biop = BioSourceNew ();
- if (biop != NULL) {
- orp = OrgRefNew ();
- biop->org = orp;
- vnp = CreateNewDescriptor (sep, Seq_descr_source);
- if (vnp != NULL) {
- vnp->data.ptrvalue = (Pointer) biop;
- }
- }
+ GetTitle (pfp->atright, txt, sizeof (txt));
+ if (txt [0] != '\0' /* ! StringHasNoText (txt) */) {
+ ptr = StringISearch (str, txt);
+ if (ptr != NULL) {
+ *ptr = '\0';
}
- if (biop == NULL) return;
- orp = biop->org;
- if (orp == NULL) return;
- orp->taxname = MemFree (orp->taxname);
- orp->taxname = StringSave (str);
- return;
}
- if (biop == NULL && topbiop != NULL) {
- biop = (BioSourcePtr) AsnIoMemCopy ((Pointer) topbiop,
- (AsnReadFunc) BioSourceAsnRead,
- (AsnWriteFunc) BioSourceAsnWrite);
+ } else {
+ FindLocalIDForOrganism (nsep, str, str_size);
+ if (str [0] == 0) {
+ FindLocalIDForOrganism (sep, str, str_size);
+ }
+ }
+ return;
+}
+
+static void ApplyDataToBioSourcePtr (
+ ParseFormPtr pfp,
+ BioSourcePtr biop,
+ BioSourcePtr topbiop,
+ SeqEntryPtr sep,
+ CharPtr data
+)
+{
+ Int2 taxnameval;
+ ValNodePtr vnp;
+ OrgRefPtr orp;
+ OrgModPtr mod;
+ Uint1 orgmodtype;
+ Uint1 subsourcetype;
+ UIEnum val;
+ Uint1 subtype;
+ OrgNamePtr onp;
+ OrgModPtr tmpmod;
+ SubSourcePtr ssp;
+ SubSourcePtr tmpssp;
+
+ taxnameval = GetValue (pfp->taxname);
+ if (taxnameval == 2) {
+ if (biop == NULL) {
+ biop = BioSourceNew ();
if (biop != NULL) {
+ orp = OrgRefNew ();
+ biop->org = orp;
vnp = CreateNewDescriptor (sep, Seq_descr_source);
if (vnp != NULL) {
vnp->data.ptrvalue = (Pointer) biop;
@@ -7319,81 +7656,144 @@ static void DoOneParseItem (Uint2 entityID, SeqEntryPtr sep, ParseFormPtr pfp, B
}
}
if (biop == NULL) return;
- orgmodtype = 0;
- subsourcetype = 0;
- if (taxnameval == 3) {
- orgmodtype = 255;
- } else if (taxnameval == 4) {
- subsourcetype = 255;
- } else if (GetEnumPopup (pfp->orgmod, orgmod_subtype_alist, &val) && val > 0) {
- orgmodtype = val;
- } else if (GetEnumPopup (pfp->subsource, subsource_subtype_alist, &val) && val > 0) {
- subsourcetype = val;
+ orp = biop->org;
+ if (orp == NULL) return;
+ SetTaxNameAndRemoveTaxRef (orp, StringSave (data));
+ }
+ if (biop == NULL && topbiop != NULL) {
+ biop = (BioSourcePtr) AsnIoMemCopy ((Pointer) topbiop,
+ (AsnReadFunc) BioSourceAsnRead,
+ (AsnWriteFunc) BioSourceAsnWrite);
+ if (biop != NULL) {
+ vnp = CreateNewDescriptor (sep, Seq_descr_source);
+ if (vnp != NULL) {
+ vnp->data.ptrvalue = (Pointer) biop;
+ }
}
- if (! StringHasNoText (str)) {
- if (orgmodtype > 0) {
- subtype = orgmodtype;
- orp = biop->org;
- if (orp == NULL) {
- orp = OrgRefNew ();
- biop->org = orp;
+ }
+ if (biop == NULL) return;
+ orgmodtype = 0;
+ subsourcetype = 0;
+ if (taxnameval == 3) {
+ orgmodtype = 255;
+ } else if (taxnameval == 4) {
+ subsourcetype = 255;
+ } else if (GetEnumPopup (pfp->orgmod, orgmod_subtype_alist, &val) && val > 0) {
+ orgmodtype = val;
+ } else if (GetEnumPopup (pfp->subsource, subsource_subtype_alist, &val) && val > 0) {
+ subsourcetype = val;
+ }
+ if (! StringHasNoText (data)) {
+ if (orgmodtype > 0) {
+ subtype = orgmodtype;
+ orp = biop->org;
+ if (orp == NULL) {
+ orp = OrgRefNew ();
+ biop->org = orp;
+ }
+ if (orp != NULL) {
+ onp = orp->orgname;
+ if (onp == NULL) {
+ onp = OrgNameNew ();
+ orp->orgname = onp;
}
- if (orp != NULL) {
- onp = orp->orgname;
- if (onp == NULL) {
- onp = OrgNameNew ();
- orp->orgname = onp;
+ if (onp != NULL) {
+ mod = onp->mod;
+ while (mod != NULL && mod->subtype != subtype) {
+ mod = mod->next;
}
- if (onp != NULL) {
- mod = onp->mod;
- while (mod != NULL && mod->subtype != subtype) {
- mod = mod->next;
- }
- if (mod == NULL) {
- mod = OrgModNew ();
- if (onp->mod == NULL) {
- onp->mod = mod;
- } else {
- tmpmod = onp->mod;
- while (tmpmod->next != NULL) {
- tmpmod = tmpmod->next;
- }
- tmpmod->next = mod;
+ if (mod == NULL) {
+ mod = OrgModNew ();
+ if (onp->mod == NULL) {
+ onp->mod = mod;
+ } else {
+ tmpmod = onp->mod;
+ while (tmpmod->next != NULL) {
+ tmpmod = tmpmod->next;
}
- }
- if (mod != NULL) {
- mod->subtype = subtype;
- mod->subname = MemFree (mod->subname);
- mod->subname = StringSave (str);
+ tmpmod->next = mod;
}
}
+ if (mod != NULL) {
+ mod->subtype = subtype;
+ AppendOrReplaceString (&(mod->subname), data,
+ &(pfp->replaceOldAsked),
+ &(pfp->doReplaceAll),
+ &(pfp->use_semicolon));
+ }
}
- } else if (subsourcetype > 0) {
- subtype = subsourcetype;
- ssp = biop->subtype;
- while (ssp != NULL && ssp->subtype != subtype) {
- ssp = ssp->next;
- }
- if (ssp == NULL) {
- ssp = SubSourceNew ();
- if (biop->subtype == NULL) {
- biop->subtype = ssp;
- } else {
- tmpssp = biop->subtype;
- while (tmpssp->next != NULL) {
- tmpssp = tmpssp->next;
- }
- tmpssp->next = ssp;
+ }
+ } else if (subsourcetype > 0) {
+ subtype = subsourcetype;
+ ssp = biop->subtype;
+ while (ssp != NULL && ssp->subtype != subtype) {
+ ssp = ssp->next;
+ }
+ if (ssp == NULL) {
+ ssp = SubSourceNew ();
+ if (biop->subtype == NULL) {
+ biop->subtype = ssp;
+ } else {
+ tmpssp = biop->subtype;
+ while (tmpssp->next != NULL) {
+ tmpssp = tmpssp->next;
}
+ tmpssp->next = ssp;
}
- if (ssp != NULL) {
- ssp->subtype = subtype;
- ssp->name = MemFree (ssp->name);
- ssp->name = StringSave (str);
+ }
+ if (ssp != NULL) {
+ ssp->subtype = subtype;
+ AppendOrReplaceString (&(ssp->name), data,
+ &(pfp->replaceOldAsked),
+ &(pfp->doReplaceAll),
+ &(pfp->use_semicolon));
+ }
+ }
+ }
+}
+
+static void DoOneParseItem (Uint2 entityID, SeqEntryPtr sep, ParseFormPtr pfp, BioSourcePtr topbiop, CharPtr useme, SeqEntryPtr nps)
+
+{
+ BioSourcePtr biop;
+ BioseqSetPtr bssp;
+ Char str [256];
+ SeqEntryPtr tmp;
+ OrgNameChangeData oncd;
+
+ if (sep == NULL || pfp == NULL) return;
+ if (IS_Bioseq_set (sep)) {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL) {
+ /* if nucprot set, look for biosource here */
+ biop = NULL;
+ SeqEntryToBioSource (sep, NULL, NULL, 0, &biop);
+ if (biop != NULL && topbiop != NULL) {
+ topbiop = biop;
+ if (bssp->_class == BioseqseqSet_class_nuc_prot)
+ {
+ GetDataForOrganism ( sep, str, sizeof (str), useme, pfp);
+ if (topbiop->org != NULL && topbiop->org->taxname != NULL)
+ {
+ oncd.oldname = topbiop->org->taxname;
+ oncd.newname = str;
+ VisitBioseqsInSep (sep, &oncd, FixProteinTitleAfterOrganismNameChange);
+ }
+ ApplyDataToBioSourcePtr (pfp, topbiop, NULL, sep, str);
+ return;
}
}
+ for (tmp = bssp->seq_set; tmp != NULL; tmp = tmp->next) {
+ DoOneParseItem (entityID, tmp, pfp, topbiop, useme, sep);
+ }
+ return;
}
}
+ GetDataForOrganism ( sep, str, sizeof (str), useme, pfp);
+ if (StringHasNoText (str)) return;
+ biop = NULL;
+ SeqEntryToBioSource (sep, NULL, NULL, 0, &biop);
+ ApplyDataToBioSourcePtr (pfp, biop, topbiop, sep, str);
}
static void DoOneParse (Uint2 entityID, SeqEntryPtr sep, ParseFormPtr pfp, BioSourcePtr topbiop)
@@ -7410,7 +7810,7 @@ static void DoOneParse (Uint2 entityID, SeqEntryPtr sep, ParseFormPtr pfp, BioSo
if (sep == NULL || pfp == NULL) return;
if (pfp->fp != NULL) {
ReadLine (pfp->fp, str, sizeof (str)); /* FileGets on Mac sometimes sees '\r' instead of '\n' */
- while (Nlm_fileDone) {
+ while (Nlm_fileDone || str [0] != 0) {
if (! StringHasNoText (str)) {
ptr = StringChr (str, '\t');
if (ptr != NULL) {
@@ -7433,6 +7833,7 @@ static void DoOneParse (Uint2 entityID, SeqEntryPtr sep, ParseFormPtr pfp, BioSo
}
}
}
+ str [0] = 0;
ReadLine (pfp->fp, str, sizeof (str));
}
return;
@@ -7475,7 +7876,11 @@ static void DoParseDeflineProc (ButtoN b)
Update ();
ObjMgrSetDirtyFlag (pfp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, pfp->input_entityID, 0, 0);
- Remove (pfp->form);
+ if (GetStatus (pfp->leaveDlgUp)) {
+ Show (pfp->form);
+ } else {
+ Remove (pfp->form);
+ }
}
static void ParseDeflineMessageProc (ForM f, Int2 mssg)
@@ -7491,11 +7896,10 @@ static void ParseDeflineMessageProc (ForM f, Int2 mssg)
}
}
-static void ParseDefOrLocalIDToSource (IteM i, Boolean parsedef, CharPtr path)
+static void ParseDefOrLocalIDToSource (BaseFormPtr bfp, Boolean parsedef, CharPtr path)
{
ButtoN b;
- BaseFormPtr bfp;
GrouP c;
GrouP g;
GrouP h;
@@ -7505,11 +7909,6 @@ static void ParseDefOrLocalIDToSource (IteM i, Boolean parsedef, CharPtr path)
StdEditorProcsPtr sepp;
WindoW w;
-#ifdef WIN_MAC
- bfp = currentFormDataPtr;
-#else
- bfp = GetObjectExtra (i);
-#endif
if (bfp == NULL) return;
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
if (sep == NULL) return;
@@ -7571,9 +7970,10 @@ static void ParseDefOrLocalIDToSource (IteM i, Boolean parsedef, CharPtr path)
SetEnumPopup (pfp->subsource, subsource_subtype_alist, 0);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoParseDeflineProc);
+ b = DefaultButton (c, "Accept", DoParseDeflineProc);
SetObjectExtra (b, pfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
+ pfp->leaveDlgUp = CheckBox (c, "Leave Dialog Up", NULL);
AlignObjects (ALIGN_CENTER, (HANDLE) p, (HANDLE) c, (HANDLE) g, NULL);
RealizeWindow (w);
@@ -7583,16 +7983,46 @@ static void ParseDefOrLocalIDToSource (IteM i, Boolean parsedef, CharPtr path)
Update ();
}
+static void ParseDefOrLocalIDToSourceMenuItem (IteM i, Boolean parsedef, CharPtr path)
+{
+ BaseFormPtr bfp;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+
+ if (bfp == NULL) return;
+
+ ParseDefOrLocalIDToSource (bfp, parsedef, path);
+}
+
+static void ParseDefOrLocalIDToSourceToolBtn (ButtoN b, Boolean parsedef, CharPtr path)
+{
+ BaseFormPtr bfp;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+
+ ParseDefOrLocalIDToSource (bfp, parsedef, path);
+}
+
extern void ParseDefToSource (IteM i)
{
- ParseDefOrLocalIDToSource (i, TRUE, NULL);
+ ParseDefOrLocalIDToSourceMenuItem (i, TRUE, NULL);
}
extern void ParseLocalIDToSource (IteM i)
{
- ParseDefOrLocalIDToSource (i, FALSE, NULL);
+ ParseDefOrLocalIDToSourceMenuItem (i, FALSE, NULL);
+}
+
+extern void ParseLocalIDToSourceToolBtn (ButtoN b)
+{
+ ParseDefOrLocalIDToSourceToolBtn (b, FALSE, NULL);
}
extern void ParseFileToSource (IteM i)
@@ -7601,31 +8031,84 @@ extern void ParseFileToSource (IteM i)
Char path [PATH_MAX];
if (GetInputFileName (path, sizeof (path), "", "TEXT")) {
- ParseDefOrLocalIDToSource (i, FALSE, path);
+ ParseDefOrLocalIDToSourceMenuItem (i, FALSE, path);
+ }
+}
+
+static void TrimOrgNameCallback (BioSourcePtr biop, Pointer userdata)
+{
+ OrgRefPtr orp;
+ CharPtr tmp;
+ CharPtr word_break;
+
+ if (biop == NULL) return;
+
+ orp = biop->org;
+ if (orp == NULL || StringHasNoText (orp->taxname)) return;
+
+ tmp = StringSave (orp->taxname);
+
+ word_break = StringStr (tmp, " ");
+ if (word_break == NULL) return;
+
+ if (StringNCmp (word_break + 1, "sp.", 3) == 0)
+ {
+ word_break = StringStr (word_break + 1, " ");
+ if (word_break == NULL) return;
}
+
+ word_break = StringStr (word_break + 1, " ");
+ if (word_break == NULL) return;
+ *word_break = 0;
+
+ SetTaxNameAndRemoveTaxRef (orp, tmp);
+}
+
+extern void TrimOrganismName (IteM i)
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+
+ VisitBioSourcesInSep (sep, NULL, TrimOrgNameCallback);
+ Update ();
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
typedef struct addmodinfo {
Boolean isOrgMod;
Uint1 subtype;
+ Boolean only_sp;
+ CharPtr abbreviation;
+ Boolean use_abbreviation;
} AddModInfo, PNTR AddModInfoPtr;
typedef struct addmodlistitem {
Boolean isOrgMod;
Uint1 subtype;
CharPtr name;
+ CharPtr abbreviation;
} AddModListItem, PNTR AddModListItemPtr;
static AddModListItem mods_list[] = {
-{ TRUE, 24, "Authority" },
-{ FALSE, 3, "Clone" },
-{ FALSE, 6, "Genotype" },
-{ FALSE, 5, "Haplotype" },
-{ TRUE, 17, "Isolate" },
-{ TRUE, 23, "Specimen-voucher" },
-{ TRUE, 2, "Strain" },
-{ TRUE, 22, "Sub-species" },
-{ TRUE, 6, "Variety" }
+{ TRUE, ORGMOD_authority, "Authority", NULL },
+{ FALSE, SUBSRC_clone, "Clone", NULL },
+{ FALSE, SUBSRC_genotype, "Genotype", NULL },
+{ FALSE, SUBSRC_haplotype, "Haplotype", NULL },
+{ TRUE, ORGMOD_isolate, "Isolate", NULL },
+{ TRUE, ORGMOD_specimen_voucher, "Specimen voucher", NULL },
+{ TRUE, ORGMOD_strain, "Strain", NULL },
+{ TRUE, ORGMOD_sub_species, "Sub-species", "subsp." },
+{ TRUE, ORGMOD_variety, "Variety", "var." }
};
static void AddModToOrgProc (BioSourcePtr biop, Pointer userdata)
@@ -7648,6 +8131,8 @@ static void AddModToOrgProc (BioSourcePtr biop, Pointer userdata)
orp = biop->org;
if (orp == NULL) return;
+ if (ami->only_sp && StringStr (orp->taxname, " sp.") == NULL) return;
+
onp = orp->orgname;
if (onp == NULL) return;
@@ -7694,10 +8179,19 @@ static void AddModToOrgProc (BioSourcePtr biop, Pointer userdata)
if (influenza) {
len += 2;
}
+ if (ami->abbreviation != NULL && ami->use_abbreviation)
+ {
+ len += StringLen (ami->abbreviation) + 1;
+ }
str = MemNew (len);
if (str != NULL) {
StringCpy (str, orp->taxname);
StringCat (str, " ");
+ if (ami->abbreviation != NULL && ami->use_abbreviation)
+ {
+ StringCat (str, ami->abbreviation);
+ StringCat (str, " ");
+ }
if (influenza) {
StringCat (str, "(");
}
@@ -7705,8 +8199,7 @@ static void AddModToOrgProc (BioSourcePtr biop, Pointer userdata)
if (influenza) {
StringCat (str, ")");
}
- orp->taxname = MemFree (orp->taxname);
- orp->taxname = str;
+ SetTaxNameAndRemoveTaxRef (biop->org, str);
}
}
}
@@ -7715,6 +8208,8 @@ typedef struct addmodformptr {
FEATURE_FORM_BLOCK
PopuP modifier_to_add;
+ ButtoN only_sp;
+ ButtoN use_abbreviation;
} AddModFormData, PNTR AddModFormPtr;
@@ -7740,6 +8235,9 @@ static void DoAddModToOrg (ButtoN b)
ami->isOrgMod = mods_list[mod_index].isOrgMod;
ami->subtype = mods_list[mod_index].subtype;
+ ami->abbreviation = mods_list[mod_index].abbreviation;
+ ami->only_sp = GetStatus (amfp->only_sp);
+ ami->use_abbreviation = GetStatus (amfp->use_abbreviation);
VisitBioSourcesInSep (sep, ami, AddModToOrgProc);
Update ();
ObjMgrSetDirtyFlag (amfp->input_entityID, TRUE);
@@ -7747,6 +8245,29 @@ static void DoAddModToOrg (ButtoN b)
Remove (amfp->form);
}
+static void ChangeModPopup (PopuP p)
+{
+ AddModFormPtr amfp;
+ Int4 mod_index;
+
+ amfp = (AddModFormPtr) GetObjectExtra (p);
+ if (amfp == NULL) return;
+
+ mod_index = GetValue (amfp->modifier_to_add);
+ if (mod_index < 1
+ || mod_index > sizeof (mods_list) / sizeof (AddModListItem))
+ return;
+ mod_index = mod_index - 1;
+ if ( mods_list [mod_index].abbreviation != NULL)
+ {
+ Enable (amfp->use_abbreviation);
+ }
+ else
+ {
+ Disable (amfp->use_abbreviation);
+ }
+}
+
extern void AddModToOrg (IteM i)
{
BaseFormPtr bfp;
@@ -7778,20 +8299,26 @@ extern void AddModToOrg (IteM i)
g = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (g, 10, 10);
- h = HiddenGroup (g, 0, 1, NULL);
- amfp->modifier_to_add = PopupList (h, TRUE, NULL);
+ h = HiddenGroup (g, 1, 0, NULL);
+ amfp->modifier_to_add = PopupList (h, TRUE, ChangeModPopup);
for (index=0; index< sizeof (mods_list) / sizeof (AddModListItem); index++)
{
PopupItem (amfp->modifier_to_add, mods_list[index].name);
}
+ SetObjectExtra (amfp->modifier_to_add, amfp, NULL);
SetValue (amfp->modifier_to_add, 1);
+ amfp->only_sp = CheckBox (g, "Only append to sp. organisms", NULL);
+ amfp->use_abbreviation = CheckBox (g, "Use abbreviation (subsp. or var.)", NULL);
+ SetStatus (amfp->use_abbreviation, TRUE);
+ Disable (amfp->use_abbreviation);
+
c = HiddenGroup (g, 2, 0, NULL);
- b = PushButton(c, "Accept", DoAddModToOrg);
+ b = DefaultButton(c, "Accept", DoAddModToOrg);
SetObjectExtra(b, amfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
- AlignObjects (ALIGN_CENTER, (HANDLE) h, (HANDLE) c, NULL);
+ AlignObjects (ALIGN_CENTER, (HANDLE) h, (HANDLE) amfp->only_sp, (HANDLE) c, NULL);
RealizeWindow(w);
Show(w);
Update();
@@ -8821,7 +9348,7 @@ extern void EditGenbankElements (Handle i)
gfp->clearTaxonomy = CheckBox (g, "Clear Lineage", NULL);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoEditGenbank);
+ b = DefaultButton (c, "Accept", DoEditGenbank);
SetObjectExtra (b, gfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
diff --git a/sequin/sequin7.c b/sequin/sequin7.c
index 68c4d6be..2bdfabb9 100644
--- a/sequin/sequin7.c
+++ b/sequin/sequin7.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/3/98
*
-* $Revision: 6.122 $
+* $Revision: 6.133 $
*
* File Description:
*
@@ -1119,7 +1119,7 @@ static SeqLocPtr AskForInterval (SeqEntryPtr sep, BioseqPtr nuc, BioseqPtr prot)
d = CreateIntervalEditorDialog (g, NULL, 4, 2, sep, TRUE, FALSE);
c = HiddenGroup (g, 2, 0, NULL);
SetGroupSpacing (c, 10, 2);
- PushButton (c, "Accept", AcceptAskProc);
+ DefaultButton (c, "Accept", AcceptAskProc);
PushButton (c, "Cancel", CancelAskProc);
AlignObjects (ALIGN_CENTER, (HANDLE) d, (HANDLE) c, (HANDLE) m, NULL);
Show (w);
@@ -2624,7 +2624,7 @@ extern ForM CreateGenomeCenterForm (Int2 left, Int2 top, CharPtr title,
Hide (ffp->controlblock);
c = HiddenGroup (h, 2, 0, NULL);
- ffp->okBtn = PushButton (c, "Accept", AcceptFa2htgs);
+ ffp->okBtn = DefaultButton (c, "Accept", AcceptFa2htgs);
SetObjectExtra (ffp->okBtn, ffp, NULL);
Disable (ffp->okBtn);
b = PushButton (c, "Cancel", CancelFa2htgs);
@@ -3115,7 +3115,7 @@ extern void PrepareToConvertToCDS (SeqEntryPtr sep, Uint2 entityID,
ccp->retain = CheckBox (h, "Retain original features", NULL);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoConvertToCDS);
+ b = DefaultButton (c, "Accept", DoConvertToCDS);
SetObjectExtra (b, ccp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -3548,6 +3548,7 @@ typedef struct cdsetformdata {
PopuP protSubType;
GrouP protSubGrp;
+ ButtoN leaveDlgUp;
} CdsetFormData, PNTR CdsetFormPtr;
typedef struct geneprotfind {
@@ -4101,6 +4102,7 @@ static Boolean CleanupEachCDSFunc (GatherContextPtr gcp)
ProtRefPtr prp;
SeqFeatPtr sfp;
CharPtr str;
+ UIEnum val;
if (gcp == NULL) return TRUE;
cfp = (CdsetFormPtr) gcp->userdata;
@@ -4123,6 +4125,15 @@ static Boolean CleanupEachCDSFunc (GatherContextPtr gcp)
cds = sfp;
} else return TRUE;
+ /* if a protein subtype is selected, delete only that subtype */
+ if (cfp->protSubType != NULL && prot != NULL && prp != NULL) {
+ if (GetEnumPopup (cfp->protSubType, prot_subtype_alist, &val)) {
+ if (val < 5 && (Uint1) val != prp->processed) {
+ return TRUE;
+ }
+ }
+ }
+
/* If there is a string constraint, only delete if */
/* the field contains that string. */
@@ -4359,7 +4370,11 @@ static void DoProcessCDSet (ButtoN b)
sep = GetTopSeqEntryForEntityID (cfp->input_entityID);
SeqEntryExplore (sep, NULL, CleanupEmptyFeatCallback);
ObjMgrSendMsg (OM_MSG_UPDATE, cfp->input_entityID, 0, 0);
- Remove (cfp->form);
+ if (GetStatus (cfp->leaveDlgUp)) {
+ Show (cfp->form);
+ } else {
+ Remove (cfp->form);
+ }
}
static Boolean SetCDSExample (GatherContextPtr gcp)
@@ -4591,7 +4606,22 @@ static void CleanupCdsetForm (GraphiC g, VoidPtr data)
StdCleanupFormProc (g, data);
}
+static void ClearProcessCDSetDlg (ButtoN b)
+{
+ CdsetFormPtr cfp;
+
+ cfp = (CdsetFormPtr) GetObjectExtra (b);
+ if (cfp == NULL) return;
+
+ SetValue ( cfp->fromfield, 0);
+ SetValue ( cfp->tofield, 0);
+ SetValue ( cfp->protSubType, 0);
+ SafeHide (cfp->protSubGrp);
+ SetTitle ( cfp->findthis, "");
+ SetTitle ( cfp->replacewith, "");
+ SafeSetTitle (cfp->example, "");
+}
static void ProcessCDSet (IteM i, Int2 type)
@@ -4725,7 +4755,14 @@ static void ProcessCDSet (IteM i, Int2 type)
cfp->example = StaticPrompt (x, "", 14 * stdCharWidth, 0, programFont, 'l');
y = NULL;
- cfp->protSubGrp = NULL;
+
+ cfp->protSubGrp = HiddenGroup (h, 2, 0, NULL);
+ StaticPrompt (cfp->protSubGrp, "Protein subtype", 0, dialogTextHeight, programFont, 'l');
+ cfp->protSubType = PopupList (cfp->protSubGrp, TRUE, NULL);
+ InitEnumPopup (cfp->protSubType, prot_subtype_alist, NULL);
+ SetEnumPopup (cfp->protSubType, prot_subtype_alist, (UIEnum) 5);
+ SafeHide (cfp->protSubGrp);
+
switch (type) {
case REMOVE_CDSET :
y = HiddenGroup (h, 2, 0, NULL);
@@ -4746,13 +4783,6 @@ static void ProcessCDSet (IteM i, Int2 type)
cfp->findthis = DialogText (y, "", 14, NULL);
break;
case EDIT_CDSET :
- cfp->protSubGrp = HiddenGroup (h, 2, 0, NULL);
- StaticPrompt (cfp->protSubGrp, "Protein subtype", 0, dialogTextHeight, programFont, 'l');
- cfp->protSubType = PopupList (cfp->protSubGrp, TRUE, NULL);
- InitEnumPopup (cfp->protSubType, prot_subtype_alist, NULL);
- SetEnumPopup (cfp->protSubType, prot_subtype_alist, (UIEnum) 5);
- Hide (cfp->protSubGrp);
-
y = HiddenGroup (h, 2, 0, NULL);
StaticPrompt (y, "Find", 0, dialogTextHeight, programFont, 'c');
cfp->findthis = DialogText (y, "", 14, NULL);
@@ -4766,9 +4796,12 @@ static void ProcessCDSet (IteM i, Int2 type)
b1 = PushButton (h, "Legend", CDSetLegend);
c = HiddenGroup (w, 4, 0, NULL);
- b = PushButton (c, "Accept", DoProcessCDSet);
+ b = DefaultButton (c, "Accept", DoProcessCDSet);
SetObjectExtra (b, cfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
+ b = PushButton (c, "Clear", ClearProcessCDSetDlg);
+ SetObjectExtra (b, cfp, NULL);
+ cfp->leaveDlgUp = CheckBox (c, "Leave Dialog Up", NULL);
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) b1, (HANDLE) y,
(HANDLE) cfp->protSubGrp, NULL);
@@ -5085,7 +5118,7 @@ extern void SwapQualifiers (IteM i)
/* Create Accept and Cancel buttons */
c = HiddenGroup (w, 4, 0, NULL);
- b = PushButton (c, "Accept", DoSwapQualifiers);
+ b = DefaultButton (c, "Accept", DoSwapQualifiers);
SetObjectExtra (b, cfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -5332,15 +5365,15 @@ static void CommonFindReplaceProc (ButtoN b, Boolean replace, Boolean replaceAll
ffp = (FindFormPtr) GetObjectExtra (b);
if (ffp != NULL) {
- findme = SaveStringFromText (ffp->findTxt);
+ findme = JustSaveStringFromText (ffp->findTxt);
ObjMgrDeSelect (0, 0, 0, 0, NULL);
caseCounts = GetStatus (ffp->caseCounts);
wholeWord = GetStatus (ffp->wholeWord);
doSeqIdLocal = GetStatus (ffp->doSeqIdLocal);
if (replace) {
- changeme = SaveStringFromText (ffp->replaceTxt);
+ changeme = JustSaveStringFromText (ffp->replaceTxt);
FindReplaceInEntity (ffp->input_entityID, findme, changeme, caseCounts, wholeWord, replaceAll,
- TRUE, UPDATE_ONCE, NULL, NULL, NULL, doSeqIdLocal);
+ FALSE, UPDATE_ONCE, NULL, NULL, NULL, doSeqIdLocal);
GetRidOfEmptyFeatsDescStrings (ffp->input_entityID, NULL);
ObjMgrSetDirtyFlag (ffp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, ffp->input_entityID, 0, 0);
@@ -5437,7 +5470,6 @@ static void FindByLabelOrPosProc (ButtoN b)
ObjMgrAlsoSelect (context.entityID, context.itemID, OBJ_SEQFEAT, 0, NULL);
}
- Remove (ffp->form);
}
static void ClearFindTextProc (ButtoN b)
@@ -5599,6 +5631,22 @@ extern void FindStringProc (IteM i)
}
}
+extern void FindStringProcToolBtn (ButtoN b)
+
+{
+ BaseFormPtr bfp;
+ ForM w;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+
+ w = CreateFindForm (-90, -66, "Find", bfp->input_entityID,
+ bfp->input_itemID, bfp->input_itemtype, FIND_ASN);
+ Show (w);
+ Select (w);
+
+}
+
extern void FindFlatfileProc (IteM i)
{
@@ -6937,27 +6985,22 @@ static void DoEditPartials (ButtoN b)
pfp->orderjoinpolicy = GetValue (pfp->orderJoinState);
pfp->findThisStr = JustSaveStringFromText (pfp->findThis);
- val = GetValue (pfp->feature);
- vnp = NULL;
- if (val > 0) {
- vnp = pfp->featlist;
- while (vnp != NULL && val > 1) {
- val--;
- vnp = vnp->next;
- }
- }
-
- if (vnp != NULL)
- pfp->subtype = vnp->choice;
- else
- pfp->subtype = 0;
-
pfp->omp = ObjMgrGet ();
pfp->omtp = NULL;
if (pfp->omp != NULL)
pfp->omtp = ObjMgrTypeFind (pfp->omp, OBJ_SEQFEAT, NULL, NULL);
- SeqEntryExplore (sep, (Pointer) pfp, PartialCallback);
+ val = 1;
+ for (vnp = pfp->featlist; vnp != NULL; vnp = vnp->next)
+ {
+ if (GetItemStatus ( pfp->feature, val))
+ {
+ pfp->subtype = vnp->choice;
+
+ SeqEntryExplore (sep, (Pointer) pfp, PartialCallback);
+ }
+ val++;
+ }
ArrowCursor ();
Update ();
@@ -6997,18 +7040,14 @@ extern void EditFeaturePartials (IteM i)
BaseFormPtr bfp;
ButtoN b;
GrouP c;
- FeatDefPtr curr;
GrouP g;
GrouP h;
ValNodePtr head;
GrouP k;
- Uint1 key;
- CharPtr label = NULL;
Int2 listHeight;
PartialFormPtr pfp;
SeqEntryPtr sep;
StdEditorProcsPtr sepp;
- Uint2 subtype;
ValNodePtr vnp;
WindoW w;
GrouP x;
@@ -7049,42 +7088,16 @@ extern void EditFeaturePartials (IteM i)
} else {
listHeight = 8;
}
- pfp->feature = SingleList (g, 16, listHeight, NULL);
-
- head = ValNodeNew (NULL);
- curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
- while (curr != NULL) {
- if (key != FEATDEF_BAD) {
- subtype = curr->featdef_key;
- if (subtype != FEATDEF_misc_RNA &&
- subtype != FEATDEF_precursor_RNA &&
- subtype != FEATDEF_mat_peptide &&
- subtype != FEATDEF_sig_peptide &&
- subtype != FEATDEF_transit_peptide &&
- subtype != FEATDEF_Imp_CDS) {
- vnp = ValNodeNew (head);
- if (head == NULL) {
- head = vnp;
- }
- if (vnp != NULL) {
- vnp->choice = subtype;
- vnp->data.ptrvalue = StringSave (curr->typelabel);
- }
+ pfp->feature = MultiList (g, 16, listHeight, NULL);
+
+ head = BuildFeatureValNodeList (TRUE, "[ALL FEATURES]", 0, FALSE, TRUE);
+ if (head != NULL)
+ {
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ if ( vnp->data.ptrvalue != NULL ) {
+ ListItem (pfp->feature, (CharPtr) vnp->data.ptrvalue);
}
}
- curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
- }
- if (head != NULL) {
- head = SortValNode (head, SortVnpByString);
- vnp = ValNodeNew (NULL);
- if (vnp != NULL) {
- vnp->choice = 0;
- vnp->data.ptrvalue = StringSave ("[ALL FEATURES]");
- }
- vnp->next = head;
- head = vnp;
- for (vnp = head; vnp != NULL; vnp = vnp->next)
- ListItem (pfp->feature, (CharPtr) vnp->data.ptrvalue);
}
pfp->featlist = head;
@@ -7133,7 +7146,7 @@ extern void EditFeaturePartials (IteM i)
pfp->findThis = DialogText (y, "", 14, NULL);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoEditPartials);
+ b = DefaultButton (c, "Accept", DoEditPartials);
SetObjectExtra (b, pfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -8321,7 +8334,7 @@ extern void EditSeqEndsProc (IteM i)
SafeDisable (esp->trimCountText);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoEditSeqEndsProc);
+ b = DefaultButton (c, "Accept", DoEditSeqEndsProc);
SetObjectExtra (b, esp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
diff --git a/sequin/sequin8.c b/sequin/sequin8.c
index bfd7f5ab..e9a5dc1a 100644
--- a/sequin/sequin8.c
+++ b/sequin/sequin8.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 2/3/98
*
-* $Revision: 6.234 $
+* $Revision: 6.250 $
*
* File Description:
*
@@ -266,19 +266,15 @@ extern void EditEvidenceFlag (IteM i)
BaseFormPtr bfp;
ButtoN b;
GrouP c;
- FeatDefPtr curr;
EvidenceFormPtr efp;
GrouP g;
GrouP h;
ValNodePtr head;
GrouP k;
- Uint1 key;
- CharPtr label = NULL;
Int2 listHeight;
GrouP q;
SeqEntryPtr sep;
StdEditorProcsPtr sepp;
- Uint2 subtype;
ValNodePtr vnp;
WindoW w;
@@ -318,35 +314,8 @@ extern void EditEvidenceFlag (IteM i)
listHeight = 8;
}
efp->objlist = SingleList (g, 16, listHeight, NULL);
- head = ValNodeNew (NULL);
+ head = BuildFeatureValNodeList (TRUE, "[ALL FEATURES]", 0, FALSE, TRUE);
if (head != NULL) {
- head->choice = 0;
- head->data.ptrvalue = StringSave ("[ALL FEATURES]");
- }
- curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
- while (curr != NULL) {
- if (key != FEATDEF_BAD) {
- subtype = curr->featdef_key;
- if (subtype != FEATDEF_misc_RNA &&
- subtype != FEATDEF_precursor_RNA &&
- subtype != FEATDEF_mat_peptide &&
- subtype != FEATDEF_sig_peptide &&
- subtype != FEATDEF_transit_peptide &&
- subtype != FEATDEF_Imp_CDS) {
- vnp = ValNodeNew (head);
- /* if (head == NULL) {
- head = vnp;
- } */
- if (vnp != NULL) {
- vnp->choice = subtype;
- vnp->data.ptrvalue = StringSave (curr->typelabel);
- }
- }
- }
- curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
- }
- if (head != NULL) {
- head = SortValNode (head, SortByVnpChoice);
for (vnp = head; vnp != NULL; vnp = vnp->next) {
ListItem (efp->objlist, (CharPtr) vnp->data.ptrvalue);
}
@@ -366,7 +335,7 @@ extern void EditEvidenceFlag (IteM i)
efp->findthis = DialogText (k, "", 14, NULL);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoEvidence);
+ b = DefaultButton (c, "Accept", DoEvidence);
SetObjectExtra (b, efp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -670,21 +639,17 @@ extern void EditExceptionFlag (IteM i)
BaseFormPtr bfp;
ButtoN b;
GrouP c;
- FeatDefPtr curr;
ExceptionFormPtr efp;
GrouP g;
GrouP h;
ValNodePtr head;
GrouP j;
GrouP k;
- Uint1 key;
- CharPtr label = NULL;
Int2 listHeight;
PrompT ppt;
GrouP q, r;
SeqEntryPtr sep;
StdEditorProcsPtr sepp;
- Uint2 subtype;
ValNodePtr vnp;
WindoW w;
@@ -724,35 +689,8 @@ extern void EditExceptionFlag (IteM i)
listHeight = 8;
}
efp->objlist = SingleList (g, 16, listHeight, NULL);
- head = ValNodeNew (NULL);
+ head = BuildFeatureValNodeList (TRUE, "[ALL FEATURES]", 0, FALSE, TRUE);
if (head != NULL) {
- head->choice = 0;
- head->data.ptrvalue = StringSave ("[ALL FEATURES]");
- }
- curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
- while (curr != NULL) {
- if (key != FEATDEF_BAD) {
- subtype = curr->featdef_key;
- if (subtype != FEATDEF_misc_RNA &&
- subtype != FEATDEF_precursor_RNA &&
- subtype != FEATDEF_mat_peptide &&
- subtype != FEATDEF_sig_peptide &&
- subtype != FEATDEF_transit_peptide &&
- subtype != FEATDEF_Imp_CDS) {
- vnp = ValNodeNew (head);
- /* if (head == NULL) {
- head = vnp;
- } */
- if (vnp != NULL) {
- vnp->choice = subtype;
- vnp->data.ptrvalue = StringSave (curr->typelabel);
- }
- }
- }
- curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
- }
- if (head != NULL) {
- head = SortValNode (head, SortByVnpChoice);
for (vnp = head; vnp != NULL; vnp = vnp->next) {
ListItem (efp->objlist, (CharPtr) vnp->data.ptrvalue);
}
@@ -786,7 +724,7 @@ extern void EditExceptionFlag (IteM i)
SetValue (efp->prodgrp, 3);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoException);
+ b = DefaultButton (c, "Accept", DoException);
SetObjectExtra (b, efp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -991,6 +929,7 @@ typedef struct recompdata {
MonitorPtr mon;
BioseqPtr batchbsp;
Boolean include_stop;
+ Boolean no_stop_at_end_of_complete_cds;
} RecompData, PNTR RecompDataPtr;
static Int2 GeneticCodeFromCrp (CdRegionPtr crp)
@@ -1038,33 +977,205 @@ static Int2 GeneticCodeFromCrp (CdRegionPtr crp)
return code;
}
-static Boolean RecomputeSuggCallback (GatherContextPtr gcp)
+static void ExtendSeqLocToEnd (SeqLocPtr slp, BioseqPtr bsp, Boolean end5)
+{
+ Uint1 strand;
+ SeqLocPtr slp_to_change, slp_index;
+ Int4 extent_to_change;
+ Int4 start, stop;
+ SeqIdPtr sip;
+
+ if (slp == NULL || bsp == NULL) return;
+
+ slp_to_change = NULL;
+ strand = SeqLocStrand (slp);
+ switch (slp->choice)
+ {
+ case SEQLOC_INT:
+ slp_to_change = slp;
+ break;
+ case SEQLOC_MIX:
+ sip = SeqLocId (slp);
+ if (sip == NULL) return; /* can only process if all on one bioseq */
+ slp_to_change = NULL;
+ if ((strand == Seq_strand_minus && end5)
+ || (strand != Seq_strand_minus && !end5))
+ {
+ extent_to_change = 0;
+ for (slp_index = (SeqLocPtr)slp->data.ptrvalue; slp_index != NULL; slp_index = slp_index->next)
+ {
+ stop = GetOffsetInBioseq (slp_index, bsp, SEQLOC_STOP);
+ if (stop > extent_to_change)
+ {
+ slp_to_change = slp_index;
+ extent_to_change = stop;
+ }
+ }
+ }
+ else
+ {
+ extent_to_change = bsp->length;
+ for (slp_index = (SeqLocPtr)slp->data.ptrvalue; slp_index != NULL; slp_index = slp_index->next)
+ {
+ start = GetOffsetInBioseq (slp_index, bsp, SEQLOC_START);
+ if (start < extent_to_change)
+ {
+ slp_to_change = slp_index;
+ extent_to_change = start;
+ }
+ }
+ }
+ break;
+ }
+
+ if (slp_to_change != NULL)
+ {
+ if ((strand == Seq_strand_minus && end5)
+ || (strand != Seq_strand_minus && !end5))
+ {
+ start = GetOffsetInBioseq (slp_to_change, bsp, SEQLOC_START);
+ stop = bsp->length - 1;
+ }
+ else
+ {
+ start = 0;
+ stop = GetOffsetInBioseq (slp_to_change, bsp, SEQLOC_STOP);
+ }
+ expand_seq_loc (start, stop, strand, slp_to_change);
+ }
+}
+
+static void ExtendOnePartialFeature (SeqFeatPtr sfp, Pointer userdata)
+{
+ BioseqPtr bsp;
+ Boolean partial3, partial5;
+
+ if (sfp == NULL) return;
+ bsp = BioseqFindFromSeqLoc (sfp->location);
+ if (bsp == NULL) return;
+ CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
+ if (partial5)
+ {
+ ExtendSeqLocToEnd (sfp->location, bsp, TRUE);
+ }
+ if (partial3)
+ {
+ ExtendSeqLocToEnd (sfp->location, bsp, FALSE);
+ }
+}
+
+extern void ExtendPartialFeatures (IteM i)
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+ SelStructPtr sel;
+ SeqFeatPtr sfp;
+ SeqMgrFeatContext fcontext;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+ sel = ObjMgrGetSelected ();
+ WatchCursor ();
+ Update ();
+ if (sel == NULL)
+ {
+ VisitFeaturesInSep (sep, NULL, ExtendOnePartialFeature);
+ }
+ else
+ {
+ while (sel != NULL)
+ {
+ if (sel->entityID == bfp->input_entityID
+ && sel->itemtype == OBJ_SEQFEAT)
+ {
+ sfp = SeqMgrGetDesiredFeature (bfp->input_entityID, NULL, sel->itemID, 0, NULL, &fcontext);
+ if (sfp != NULL)
+ {
+ ExtendOnePartialFeature (sfp, NULL);
+ }
+ }
+ sel = sel->next;
+ }
+ }
+ ArrowCursor ();
+ Update ();
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
+
+static Boolean HasValidStartCodon (SeqFeatPtr cds)
+{
+ ByteStorePtr bs;
+ CharPtr prot;
+
+ if (cds == NULL) return FALSE;
+
+ bs = ProteinFromCdRegionEx (cds, TRUE, FALSE);
+
+ if (bs == NULL) return FALSE;
+ prot = BSMerge (bs, NULL);
+ bs = BSFree (bs);
+ if (prot == NULL) return FALSE;
+ if (prot [0] != 'M') return FALSE;
+ return TRUE;
+}
+
+static void FixReadingFrame (
+ CdRegionPtr crp,
+ SeqLocPtr slp,
+ BioseqPtr bsp,
+ Int4 start
+)
+{
+ Int4 offset;
+
+ if (crp == NULL || slp == NULL) return;
+
+ if (SeqLocStrand (slp) == Seq_strand_minus)
+ {
+ offset = bsp->length - start;
+ }
+ else
+ {
+ offset = start;
+ }
+ start = start % 3;
+ start = start + 1;
+ crp->frame = start;
+}
+
+static void RecomputeSuggestedIntervalsForCDS (
+ RecompDataPtr rdp,
+ SeqFeatPtr sfp,
+ Uint2 entityID
+)
{
Int2 code;
CdRegionPtr crp;
BioseqPtr nucbsp;
BioseqPtr protbsp;
- RecompDataPtr rdp;
- SeqFeatPtr sfp;
SeqIdPtr sip;
SeqLocPtr slp;
Char str [256];
Char tmp [256];
+ Boolean partial3, partial5;
+ Int4 start;
- if (gcp == NULL) return TRUE;
- if (gcp->thistype != OBJ_SEQFEAT) return TRUE;
- rdp = (RecompDataPtr) gcp->userdata;
- if (rdp == NULL) return TRUE;
- sfp = (SeqFeatPtr) gcp->thisitem;
- if (sfp == NULL || sfp->data.choice != SEQFEAT_CDREGION) return TRUE;
+ if (rdp == NULL) return;
+ if (sfp == NULL || sfp->data.choice != SEQFEAT_CDREGION) return;
crp = (CdRegionPtr) sfp->data.value.ptrvalue;
- if (crp == NULL) return TRUE;
- /* if (CdsTranslatesProperly (sfp, gcp)) return TRUE; */
+ if (crp == NULL) return;
code = GeneticCodeFromCrp (crp);
- nucbsp = GetBioseqGivenSeqLoc (sfp->location, gcp->entityID);
+ nucbsp = GetBioseqGivenSeqLoc (sfp->location, entityID);
if (nucbsp != NULL && rdp->batchbsp != NULL && nucbsp != rdp->batchbsp) {
ClearBatchSuggestNucleotide ();
rdp->batchbsp = NULL;
@@ -1087,24 +1198,68 @@ static Boolean RecomputeSuggCallback (GatherContextPtr gcp)
Update ();
}
slp = PredictCodingRegion (nucbsp, protbsp, code);
- if (slp == NULL) return TRUE;
+ if (slp == NULL) return;
+
+ /* correct for partial conditions */
+ CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
+
sfp->location = SeqLocFree (sfp->location);
sfp->location = slp;
+
+ /* if no valid start codon, cds is 5' partial */
+ if (! HasValidStartCodon (sfp))
+ {
+ partial5 = TRUE;
+ }
+
+ if (partial5 || partial3)
+ {
+ if (partial5)
+ {
+ start = GetOffsetInBioseq (sfp->location, nucbsp, SEQLOC_START);
+ ExtendSeqLocToEnd (sfp->location, nucbsp, TRUE);
+ FixReadingFrame (crp, sfp->location, nucbsp, start);
+ }
+ if (partial3)
+ {
+ ExtendSeqLocToEnd (sfp->location, nucbsp, FALSE);
+ }
+ SetSeqLocPartial (sfp->location, partial5, partial3);
+ }
sfp->partial = LocationHasNullsBetween (sfp->location);
+ sfp->partial |= partial5 || partial3;
}
}
+}
+
+static Boolean RecomputeSuggCallback (GatherContextPtr gcp)
+{
+ RecompDataPtr rdp;
+ SeqFeatPtr sfp;
+
+ if (gcp == NULL) return TRUE;
+ if (gcp->thistype != OBJ_SEQFEAT) return TRUE;
+ rdp = (RecompDataPtr) gcp->userdata;
+ if (rdp == NULL) return TRUE;
+ sfp = (SeqFeatPtr) gcp->thisitem;
+ if (sfp == NULL || sfp->data.choice != SEQFEAT_CDREGION) return TRUE;
+
+ RecomputeSuggestedIntervalsForCDS (rdp, sfp, gcp->entityID);
return TRUE;
}
extern void RecomputeSuggest (IteM i)
{
- BaseFormPtr bfp;
- Int2 code;
- GatherScope gs;
- SeqEntryPtr nucsep;
- RecompData rd;
- SeqEntryPtr sep;
+ BaseFormPtr bfp;
+ Int2 code;
+ GatherScope gs;
+ SeqEntryPtr nucsep;
+ RecompData rd;
+ SeqEntryPtr sep;
+ SelStructPtr sel;
+ SeqFeatPtr sfp;
+ SeqMgrFeatContext fcontext;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -1114,11 +1269,13 @@ extern void RecomputeSuggest (IteM i)
if (bfp == NULL) return;
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
if (sep == NULL) return;
+ sel = ObjMgrGetSelected ();
WatchCursor ();
Update ();
rd.count = 0;
rd.mon = MonitorStrNewEx ("Correcting Coding Regions", 20, FALSE);
rd.batchbsp = NULL;
+ rd.no_stop_at_end_of_complete_cds = FALSE;
nucsep = FindNucSeqEntry (sep);
if (nucsep != NULL && IS_Bioseq (nucsep)) {
rd.batchbsp = (BioseqPtr) nucsep->data.ptrvalue;
@@ -1127,15 +1284,34 @@ extern void RecomputeSuggest (IteM i)
code = SeqEntryToGeneticCode (sep, NULL, NULL, 0);
SetBatchSuggestNucleotide (rd.batchbsp, code);
}
- MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
- gs.seglevels = 1;
- gs.get_feats_location = FALSE;
- MemSet((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
- gs.ignore[OBJ_BIOSEQ] = FALSE;
- gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
- gs.ignore[OBJ_SEQFEAT] = FALSE;
- gs.ignore[OBJ_SEQANNOT] = FALSE;
- GatherEntity (bfp->input_entityID, (Pointer) (&rd), RecomputeSuggCallback, &gs);
+ if (sel == NULL)
+ {
+ MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
+ gs.seglevels = 1;
+ gs.get_feats_location = FALSE;
+ MemSet((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
+ gs.ignore[OBJ_BIOSEQ] = FALSE;
+ gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
+ gs.ignore[OBJ_SEQFEAT] = FALSE;
+ gs.ignore[OBJ_SEQANNOT] = FALSE;
+ GatherEntity (bfp->input_entityID, (Pointer) (&rd), RecomputeSuggCallback, &gs);
+ }
+ else
+ {
+ while (sel != NULL)
+ {
+ if (sel->entityID == bfp->input_entityID
+ && sel->itemtype == OBJ_SEQFEAT)
+ {
+ sfp = SeqMgrGetDesiredFeature (bfp->input_entityID, NULL, sel->itemID, 0, NULL, &fcontext);
+ if (sfp != NULL && sfp->idx.subtype == FEATDEF_CDS)
+ {
+ RecomputeSuggestedIntervalsForCDS (&rd, sfp, bfp->input_entityID);
+ }
+ }
+ sel = sel->next;
+ }
+ }
MonitorFree (rd.mon);
if (rd.batchbsp != NULL) {
ClearBatchSuggestNucleotide ();
@@ -1146,7 +1322,12 @@ extern void RecomputeSuggest (IteM i)
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
-static Boolean RetranslateOneCDS (SeqFeatPtr sfp, Uint2 entityID, Boolean include_stop)
+static Boolean RetranslateOneCDS (
+ SeqFeatPtr sfp,
+ Uint2 entityID,
+ Boolean include_stop,
+ Boolean no_stop_at_end_of_complete_cds
+)
{
SeqFeatPtr bestprot;
@@ -1229,7 +1410,10 @@ static Boolean RetranslateOneCDS (SeqFeatPtr sfp, Uint2 entityID, Boolean includ
bsp = BioseqFind (sip);
if (bsp != NULL && ISA_aa (bsp->mol) && bsp->repr == Seq_repr_raw) {
bestprot = FindBestProtein (entityID, sfp->product);
- bs = ProteinFromCdRegionEx (sfp, include_stop, FALSE);
+ bs = ProteinFromCdRegionExWithTrailingCodonHandling (sfp,
+ include_stop,
+ FALSE,
+ no_stop_at_end_of_complete_cds );
if (bs == NULL) return TRUE;
prot = BSMerge (bs, NULL);
bs = BSFree (bs);
@@ -1311,10 +1495,14 @@ static Boolean RetranslateCDSCallback (GatherContextPtr gcp)
rdp = (RecompDataPtr) gcp->userdata;
if (rdp == NULL) return TRUE;
sfp = (SeqFeatPtr) gcp->thisitem;
- return RetranslateOneCDS (sfp, gcp->entityID, rdp->include_stop);
+ return RetranslateOneCDS (sfp, gcp->entityID, rdp->include_stop,
+ rdp->no_stop_at_end_of_complete_cds);
}
-static void RetranslateCdRegions (IteM i, Boolean include_stop)
+static void RetranslateCdRegions (
+ IteM i,
+ Boolean include_stop,
+ Boolean no_stop_at_end_of_complete_cds )
{
BaseFormPtr bfp;
@@ -1335,6 +1523,7 @@ static void RetranslateCdRegions (IteM i, Boolean include_stop)
rd.count = 0;
rd.mon = MonitorStrNewEx ("Correcting Coding Regions", 20, FALSE);
rd.include_stop = include_stop;
+ rd.no_stop_at_end_of_complete_cds = no_stop_at_end_of_complete_cds;
MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
gs.seglevels = 1;
gs.get_feats_location = FALSE;
@@ -1354,15 +1543,21 @@ static void RetranslateCdRegions (IteM i, Boolean include_stop)
extern void RetranslateCdRegionsNoStop (IteM i)
{
- RetranslateCdRegions (i, FALSE);
+ RetranslateCdRegions (i, FALSE, FALSE);
}
extern void RetranslateCdRegionsDoStop (IteM i)
{
- RetranslateCdRegions (i, TRUE);
+ RetranslateCdRegions (i, TRUE, FALSE);
}
+extern void RetranslateCdRegionsNoStopExceptEndCompleteCDS (IteM i)
+{
+ RetranslateCdRegions (i, TRUE, TRUE);
+}
+
+
static void DoReprocessPeptides (SeqFeatPtr sfp, Pointer userdata)
{
@@ -1677,7 +1872,7 @@ static Boolean LIBCALLBACK ApplyCodeBreak_FeatureCallback (SeqFeatPtr sfp,
/* Retranslate the CDS */
- RetranslateOneCDS (sfp, fcontext->entityID, TRUE);
+ RetranslateOneCDS (sfp, fcontext->entityID, TRUE, FALSE);
}
basePtr += 3;
@@ -1999,7 +2194,7 @@ extern void AddGlobalCodeBreak (IteM i)
/* Add Accept and Cancel buttons */
buttGroup = HiddenGroup (breakWin, 2, 0, NULL);
- cbfp->acceptButton = PushButton (buttGroup, "Accept",
+ cbfp->acceptButton = DefaultButton (buttGroup, "Accept",
DoAddCodeBreak_Callback);
SetObjectExtra (cbfp->acceptButton, cbfp, NULL);
SafeDisable (cbfp->acceptButton);
@@ -2864,6 +3059,7 @@ static void DoRemoveAsnObject (ButtoN b)
ValNodePtr tmp;
Int2 val;
ValNodePtr vnp;
+ Boolean removed_some_features;
rfp = GetObjectExtra (b);
if (rfp == NULL) return;
@@ -2877,65 +3073,72 @@ static void DoRemoveAsnObject (ButtoN b)
} else {
rfp->itemtype = OBJ_SEQDESC;
}
- vnp = NULL;
- val = GetValue (rfp->objlist);
- if (val > 0) {
- vnp = rfp->head;
- while (vnp != NULL && val > 1) {
- val--;
- vnp = vnp->next;
- }
+
+ rfp->omp = ObjMgrGet ();
+ rfp->omtp = NULL;
+ if (rfp->omp != NULL) {
+ rfp->omtp = ObjMgrTypeFind (rfp->omp, rfp->itemtype, NULL, NULL);
}
- if (vnp != NULL) {
- rfp->omp = ObjMgrGet ();
- rfp->omtp = NULL;
- if (rfp->omp != NULL) {
- rfp->omtp = ObjMgrTypeFind (rfp->omp, rfp->itemtype, NULL, NULL);
- }
- rfp->subtype = vnp->choice;
- if (rfp->itemtype != 0 && rfp->subtype != 0 && rfp->omtp != NULL) {
- if (rfp->is_feature) {
- SeqEntryExplore (sep, (Pointer) rfp, RemoveFeatureCallback);
- if (rfp->bsplist != NULL) {
- ans = Message (MSG_YN, "Remove protein products?");
- if (ans == ANS_YES) {
- for (tmp = rfp->bsplist; tmp != NULL; tmp = tmp->next) {
- bsp = (BioseqPtr) tmp->data.ptrvalue;
- itemID = GetItemIDGivenPointer (rfp->input_entityID, OBJ_BIOSEQ, (Pointer) bsp);
- if (itemID > 0) {
- MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
- ompc.do_not_reload_from_cache = TRUE;
- ompc.input_entityID = rfp->input_entityID;
- ompc.input_itemID = itemID;
- ompc.input_itemtype = OBJ_BIOSEQ;
- if (! DetachDataForProc (&ompc, FALSE)) {
- Message (MSG_POSTERR, "DetachDataForProc failed");
- }
- }
+
+ if (rfp->itemtype == 0 || rfp->omtp == NULL) return;
+
+ removed_some_features = FALSE;
+
+ val = 1;
+ for (vnp = rfp->head; vnp != NULL; vnp = vnp->next)
+ {
+ if (GetItemStatus (rfp->objlist, val))
+ {
+ rfp->subtype = vnp->choice;
+ if (rfp->subtype != 0) {
+ if (rfp->is_feature) {
+ SeqEntryExplore (sep, (Pointer) rfp, RemoveFeatureCallback);
+ removed_some_features = TRUE;
+ } else {
+ SeqEntryExplore (sep, (Pointer) rfp, RemoveDescriptorCallback);
+ }
+ }
+ }
+ val ++;
+ }
+
+ if (removed_some_features) {
+ if (rfp->bsplist != NULL) {
+ ans = Message (MSG_YN, "Remove protein products?");
+ if (ans == ANS_YES) {
+ for (tmp = rfp->bsplist; tmp != NULL; tmp = tmp->next) {
+ bsp = (BioseqPtr) tmp->data.ptrvalue;
+ itemID = GetItemIDGivenPointer (rfp->input_entityID, OBJ_BIOSEQ, (Pointer) bsp);
+ if (itemID > 0) {
+ MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
+ ompc.do_not_reload_from_cache = TRUE;
+ ompc.input_entityID = rfp->input_entityID;
+ ompc.input_itemID = itemID;
+ ompc.input_itemtype = OBJ_BIOSEQ;
+ if (! DetachDataForProc (&ompc, FALSE)) {
+ Message (MSG_POSTERR, "DetachDataForProc failed");
}
}
}
- if (rfp->bssplist != NULL) {
- ans = Message (MSG_YN, "Remove cDNA nuc-prot products?");
- if (ans == ANS_YES) {
- for (tmp = rfp->bssplist; tmp != NULL; tmp = tmp->next) {
- bssp = (BioseqSetPtr) tmp->data.ptrvalue;
- itemID = GetItemIDGivenPointer (rfp->input_entityID, OBJ_BIOSEQSET, (Pointer) bssp);
- if (itemID > 0) {
- MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
- ompc.do_not_reload_from_cache = TRUE;
- ompc.input_entityID = rfp->input_entityID;
- ompc.input_itemID = itemID;
- ompc.input_itemtype = OBJ_BIOSEQSET;
- if (! DetachDataForProc (&ompc, FALSE)) {
- Message (MSG_POSTERR, "DetachDataForProc failed");
- }
- }
+ }
+ }
+ if (rfp->bssplist != NULL) {
+ ans = Message (MSG_YN, "Remove cDNA nuc-prot products?");
+ if (ans == ANS_YES) {
+ for (tmp = rfp->bssplist; tmp != NULL; tmp = tmp->next) {
+ bssp = (BioseqSetPtr) tmp->data.ptrvalue;
+ itemID = GetItemIDGivenPointer (rfp->input_entityID, OBJ_BIOSEQSET, (Pointer) bssp);
+ if (itemID > 0) {
+ MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
+ ompc.do_not_reload_from_cache = TRUE;
+ ompc.input_entityID = rfp->input_entityID;
+ ompc.input_itemID = itemID;
+ ompc.input_itemtype = OBJ_BIOSEQSET;
+ if (! DetachDataForProc (&ompc, FALSE)) {
+ Message (MSG_POSTERR, "DetachDataForProc failed");
}
}
}
- } else {
- SeqEntryExplore (sep, (Pointer) rfp, RemoveDescriptorCallback);
}
}
}
@@ -2947,6 +3150,64 @@ static void DoRemoveAsnObject (ButtoN b)
Remove (rfp->form);
}
+static void RemoveDefLinesCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
+
+{
+ BioseqPtr bsp;
+ BioseqSetPtr bssp;
+ ValNodePtr nextsdp;
+ Pointer PNTR prevsdp;
+ ValNodePtr sdp;
+
+ if (sep == NULL || sep->data.ptrvalue == NULL) return;
+ if (IS_Bioseq (sep)) {
+ bsp = (BioseqPtr) sep->data.ptrvalue;
+ sdp = bsp->descr;
+ prevsdp = (Pointer PNTR) &(bsp->descr);
+ } else if (IS_Bioseq_set (sep)) {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ sdp = bssp->descr;
+ prevsdp = (Pointer PNTR) &(bssp->descr);
+ } else return;
+
+ while (sdp != NULL) {
+ nextsdp = sdp->next;
+ if (sdp->choice == Seq_descr_title)
+ {
+ *(prevsdp) = sdp->next;
+ sdp->next = NULL;
+ SeqDescFree (sdp);
+ } else {
+ prevsdp = (Pointer PNTR) &(sdp->next);
+ }
+ sdp = nextsdp;
+ }
+}
+
+extern void RemoveDefLinesToolBtn (ButtoN b)
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+
+ bfp = (BaseFormPtr) GetObjectExtra (b);
+ if (bfp == NULL) return;
+
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+
+ WatchCursor ();
+ Update ();
+
+ SeqEntryExplore (sep, NULL, RemoveDefLinesCallback);
+
+ ArrowCursor ();
+ Update ();
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+ ObjMgrDeSelect (0, 0, 0, 0, NULL);
+ CommonApplyToAllProc (bfp, ADD_TITLE);
+}
+
int LIBCALLBACK SortByVnpChoice (VoidPtr ptr1, VoidPtr ptr2)
{
@@ -3016,65 +3277,6 @@ static CharPtr descNames [] = {
#endif
*/
-CharPtr MostUsedFeatureList[] = { "All", "CDS", "Gene", "mRNA", "rRNA", "RNA" };
-
-static Boolean isMostUsedFeature (CharPtr featname)
-{
- Int2 i;
-
- if (featname == NULL) return FALSE;
-
- for (i=0; i < sizeof (MostUsedFeatureList) / sizeof (CharPtr); i++)
- {
- if (StringCmp (featname, MostUsedFeatureList[i]) == 0)
- return TRUE;
- }
- return FALSE;
-}
-
-static int LIBCALLBACK SortMostUsedFeaturesFirst (VoidPtr ptr1, VoidPtr ptr2)
-
-{
- ValNodePtr vnp1;
- ValNodePtr vnp2;
- CharPtr str1;
- CharPtr str2;
- Boolean str1_is_most_used;
- Boolean str2_is_most_used;
-
- /* Check parameters */
-
- if ((NULL == ptr1) || (NULL == ptr2))
- return 0;
-
- vnp1 = *((ValNodePtr PNTR) ptr1);
- vnp2 = *((ValNodePtr PNTR) ptr2);
- if ((NULL == vnp1) || (NULL == vnp2))
- return 0;
-
- str1 = (CharPtr) vnp1->data.ptrvalue;
- str2 = (CharPtr) vnp2->data.ptrvalue;
- if ((NULL == str1) || (NULL == str2))
- return 0;
-
- str1_is_most_used = isMostUsedFeature (str1);
- str2_is_most_used = isMostUsedFeature (str2);
-
- if ((str1_is_most_used && str2_is_most_used)
- || (!str1_is_most_used && !str2_is_most_used))
- {
- return SortVnpByString (ptr1, ptr2);
- }
- else if (str1_is_most_used)
- {
- return -1;
- }
- else
- {
- return 1;
- }
-}
-
CharPtr MostUsedDescriptorList[] = { "Title" };
static Boolean isMostUsedDescriptor (CharPtr descname)
@@ -3140,21 +3342,16 @@ static void RemoveAsnObject (IteM i, Boolean feature)
BaseFormPtr bfp;
ButtoN b;
GrouP c;
- FeatDefPtr curr;
GrouP g;
GrouP h;
ValNodePtr head;
Int2 j;
GrouP k;
- Uint1 key;
- CharPtr label = NULL;
Int2 listHeight;
GrouP m;
RemoveFormPtr rfp;
SeqEntryPtr sep;
StdEditorProcsPtr sepp;
- Char str [256];
- Uint2 subtype;
CharPtr title;
ValNodePtr vnp;
WindoW w;
@@ -3204,51 +3401,10 @@ static void RemoveAsnObject (IteM i, Boolean feature)
} else {
listHeight = 8;
}
- rfp->objlist = SingleList (g, 16, listHeight, NULL);
+ rfp->objlist = MultiList (g, 16, listHeight, NULL);
head = NULL;
if (feature) {
- curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
- while (curr != NULL) {
- if (key != FEATDEF_BAD) {
- subtype = curr->featdef_key;
- if (subtype == FEATDEF_ORG ||
- subtype == FEATDEF_mutation ||
- subtype == FEATDEF_site_ref ||
- subtype == FEATDEF_gap ||
- subtype == FEATDEF_NON_STD_RESIDUE ||
- subtype == FEATDEF_NUM)
- {
- /* indexers requested that these features not appear in the list */
- }
- else
- {
- vnp = ValNodeNew (head);
- if (head == NULL)
- head = vnp;
- if (vnp != NULL) {
- vnp->choice = subtype;
- if (subtype != FEATDEF_misc_RNA &&
- subtype != FEATDEF_precursor_RNA &&
- subtype != FEATDEF_mat_peptide &&
- subtype != FEATDEF_sig_peptide &&
- subtype != FEATDEF_transit_peptide &&
- subtype != FEATDEF_Imp_CDS) {
- vnp->data.ptrvalue = StringSave (curr->typelabel);
- } else {
- StringNCpy_0 (str, curr->typelabel, sizeof (str) - 10);
- StringCat (str, "_imp");
- vnp->data.ptrvalue = StringSave (str);
- }
- }
- }
- }
- curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
- }
- vnp = ValNodeNew (head);
- if (vnp != NULL) {
- vnp->choice = ALL_FEATURES;
- vnp->data.ptrvalue = StringSave ("All");
- }
+ head = BuildFeatureValNodeList (TRUE, "All", ALL_FEATURES, TRUE, FALSE);
} else {
for (j = 1; descNames [j] != NULL; j++) {
if (StringHasNoText (descNames [j])) continue;
@@ -3261,19 +3417,9 @@ static void RemoveAsnObject (IteM i, Boolean feature)
vnp->data.ptrvalue = StringSave (descNames [j]);
}
}
+ head = SortValNode (head, SortMostUsedDescriptorsFirst);
}
if (head != NULL) {
- /*
- head = SortValNode (head, SortByVnpChoice);
- */
- if (feature)
- {
- head = SortValNode (head, SortMostUsedFeaturesFirst);
- }
- else
- {
- head = SortValNode (head, SortMostUsedDescriptorsFirst);
- }
for (vnp = head; vnp != NULL; vnp = vnp->next) {
ListItem (rfp->objlist, (CharPtr) vnp->data.ptrvalue);
@@ -3297,7 +3443,7 @@ static void RemoveAsnObject (IteM i, Boolean feature)
}
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoRemoveAsnObject);
+ b = DefaultButton (c, "Accept", DoRemoveAsnObject);
SetObjectExtra (b, rfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -3338,6 +3484,172 @@ typedef struct selectformdata {
Char findStr [128];
} SelectFormData, PNTR SelectFormPtr;
+static Boolean StringListMatchesString (ValNodePtr string_list, CharPtr findStr)
+{
+ ValNodePtr vnp;
+
+ if (StringHasNoText (findStr)) return TRUE;
+ for (vnp = string_list; vnp != NULL; vnp = vnp->next)
+ {
+ if (StringStr (vnp->data.ptrvalue, findStr) != NULL) return TRUE;
+ }
+ return FALSE;
+}
+
+static Boolean PubJournalMatchesString (CitJourPtr cjp, CharPtr findStr)
+{
+ if (cjp == NULL || cjp->title == NULL) return FALSE;
+ if (StringListMatchesString (cjp->title, findStr)) return TRUE;
+ return FALSE;
+}
+
+static Boolean PubBookMatchesString (CitBookPtr cbp, CharPtr findStr)
+{
+ if (cbp == NULL || cbp->title == NULL) return FALSE;
+ if (StringListMatchesString (cbp->title, findStr)) return TRUE;
+ return FALSE;
+}
+
+static Boolean PubArticleMatchesString (CitArtPtr cap, CharPtr findStr)
+{
+ if (cap == NULL || cap->fromptr == NULL) return FALSE;
+ switch (cap->from)
+ {
+ case 1:
+ if (PubJournalMatchesString (cap->fromptr, findStr)) return TRUE;
+ case 2:
+ case 3:
+ if (PubBookMatchesString (cap->fromptr, findStr)) return TRUE;
+ }
+ return FALSE;
+}
+
+static Boolean PubdescMatchesString ( ValNodePtr vnp, CharPtr findStr)
+{
+ CitGenPtr cgp;
+ CitPatPtr cpp;
+ MedlineEntryPtr mep;
+ ValNodePtr pub;
+
+
+ if (vnp == NULL) return FALSE;
+ switch (vnp->choice)
+ {
+ case PUB_Gen :
+ cgp = (CitGenPtr) vnp->data.ptrvalue;
+ if (cgp == NULL) return FALSE;
+ if (StringStr (cgp->title, findStr) != NULL) return TRUE;
+ if (StringListMatchesString (cgp->journal, findStr)) return TRUE;
+ break;
+ case PUB_Medline :
+ mep = (MedlineEntryPtr) vnp->data.ptrvalue;
+ if (mep == NULL) return FALSE;
+ if ( PubArticleMatchesString (mep->cit, findStr)) return TRUE;
+ break;
+ case PUB_Article :
+ if ( PubArticleMatchesString (vnp->data.ptrvalue, findStr)) return TRUE;
+ break;
+ case PUB_Journal :
+ if (PubJournalMatchesString (vnp->data.ptrvalue, findStr)) return TRUE;
+ break;
+ case PUB_Patent :
+ cpp = (CitPatPtr) vnp->data.ptrvalue;
+ if (cpp == NULL || cpp->title == NULL) return FALSE;
+ if (StringStr (cpp->title, findStr) != NULL) return TRUE;
+ break;
+ case PUB_Book :
+ case PUB_Man :
+ if (PubBookMatchesString (vnp->data.ptrvalue, findStr)) return TRUE;
+ break;
+ case PUB_Equiv :
+ for (pub = vnp->data.ptrvalue; pub != NULL; pub = pub->next)
+ {
+ if (PubdescMatchesString (pub, findStr)) return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static Boolean FeatureMatchesString (SeqFeatPtr sfp, CharPtr findStr)
+{
+ SeqMgrFeatContext context;
+ SeqFeatPtr new_sfp;
+ PubdescPtr pdp;
+ ValNodePtr vnp;
+
+ if (sfp == NULL) return FALSE;
+ if (StringHasNoText (findStr)) return TRUE;
+ if (sfp->data.choice == SEQFEAT_PUB)
+ {
+ if( (pdp = (PubdescPtr) sfp->data.value.ptrvalue) == NULL) return FALSE;
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next)
+ {
+ if (PubdescMatchesString (sfp->data.value.ptrvalue, findStr))
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+
+ new_sfp = SeqMgrGetDesiredFeature (sfp->idx.entityID, NULL, 0, 0, sfp,
+ &context);
+ if (new_sfp != sfp || StringStr (context.label, findStr) == NULL)
+ return FALSE;
+
+ return TRUE;
+}
+
+static Boolean DescriptorMatchesString ( SeqDescPtr sdp, CharPtr findStr)
+{
+ CharPtr cp;
+ OrgRefPtr orp;
+ BioSourcePtr biop;
+ PubdescPtr pdp;
+ ValNodePtr vnp;
+
+ if (sdp == NULL) return FALSE;
+ if (StringHasNoText (findStr)) return TRUE;
+
+ switch (sdp->choice)
+ {
+ case Seq_descr_name:
+ case Seq_descr_title:
+ case Seq_descr_comment:
+ case Seq_descr_region:
+ cp = sdp->data.ptrvalue;
+ if (StringStr (cp, findStr) == NULL) return FALSE;
+ break;
+ case Seq_descr_org:
+ orp = sdp->data.ptrvalue;
+ if (orp == NULL || orp->taxname == NULL) return FALSE;
+ if (StringStr (orp->taxname, findStr) == NULL) return FALSE;
+ break;
+ case Seq_descr_source:
+ biop = sdp->data.ptrvalue;
+ if (biop == NULL || biop->org == NULL || biop->org->taxname == NULL) return FALSE;
+ if (StringStr (biop->org->taxname, findStr) == NULL) return FALSE;
+ break;
+ case Seq_descr_pub:
+ if( (pdp = (PubdescPtr) sdp->data.ptrvalue) == NULL) return FALSE;
+ for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next)
+ {
+ if (PubdescMatchesString (vnp, findStr))
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+
+ return TRUE;
+}
+
static Boolean SelectObjCallback (GatherContextPtr gcp)
{
@@ -3353,6 +3665,17 @@ static Boolean SelectObjCallback (GatherContextPtr gcp)
if (omtp == NULL) return TRUE;
subtype = (*(omtp->subtypefunc)) ((Pointer) gcp->thisitem);
if (subtype != selfp->subtype) return TRUE;
+
+ if (gcp->thistype == OBJ_SEQFEAT
+ && ! FeatureMatchesString (gcp->thisitem, selfp->findStr))
+ {
+ return TRUE;
+ }
+ if (gcp->thistype == OBJ_SEQDESC
+ && ! DescriptorMatchesString (gcp->thisitem, selfp->findStr))
+ {
+ return TRUE;
+ }
ObjMgrAlsoSelect (gcp->entityID, gcp->itemID, gcp->thistype, 0, NULL);
return TRUE;
}
@@ -3397,6 +3720,10 @@ static void DoSelectAsnObject (ButtoN b)
vnp = vnp->next;
}
}
+ if (selfp->type == SLCT_FEAT || selfp->type == SLCT_DESC)
+ {
+ GetTitle (selfp->findthis, selfp->findStr, sizeof (selfp->findStr) - 1);
+ }
if (selfp->type == SLCT_BIOSEQ || vnp != NULL) {
selfp->omp = ObjMgrGet ();
selfp->omtp = NULL;
@@ -3457,18 +3784,15 @@ static void SelectAsnObject (IteM i, Int2 type)
BaseFormPtr bfp;
ButtoN b;
GrouP c;
- FeatDefPtr curr;
GrouP g;
GrouP h;
+ GrouP k;
ValNodePtr head;
Int2 j;
- Uint1 key;
- CharPtr label = NULL;
Int2 listHeight;
SelectFormPtr selfp;
SeqEntryPtr sep;
StdEditorProcsPtr sepp;
- Uint2 subtype;
CharPtr title;
ValNodePtr vnp;
WindoW w;
@@ -3538,23 +3862,10 @@ static void SelectAsnObject (IteM i, Int2 type)
selfp->objlist = SingleList (g, 16, listHeight, NULL);
head = NULL;
if (type == SLCT_FEAT) {
- curr = FeatDefFindNext (NULL, &key, &label, FEATDEF_ANY, TRUE);
- while (curr != NULL) {
- if (key != FEATDEF_BAD) {
- subtype = curr->featdef_key;
- vnp = ValNodeNew (head);
- if (head == NULL) {
- head = vnp;
- }
- if (vnp != NULL) {
- vnp->choice = subtype;
- vnp->data.ptrvalue = StringSave (curr->typelabel);
- }
- }
- curr = FeatDefFindNext (curr, &key, &label, FEATDEF_ANY, TRUE);
- }
+ head = BuildFeatureValNodeList (TRUE, NULL, ALL_FEATURES, TRUE, FALSE);
} else if (type == SLCT_DESC) {
for (j = 1; descNames [j] != NULL; j++) {
+ if (StringHasNoText (descNames [j])) continue;
vnp = ValNodeNew (head);
if (head == NULL) {
head = vnp;
@@ -3566,19 +3877,35 @@ static void SelectAsnObject (IteM i, Int2 type)
}
}
if (head != NULL) {
- head = SortValNode (head, SortByVnpChoice);
+ if (type != SLCT_FEAT) {
+ head = SortValNode (head, SortByVnpChoice);
+ }
for (vnp = head; vnp != NULL; vnp = vnp->next) {
ListItem (selfp->objlist, (CharPtr) vnp->data.ptrvalue);
}
}
selfp->head = head;
+ if (selfp->type == SLCT_FEAT || selfp->type == SLCT_DESC)
+ {
+ k = HiddenGroup (h, 0, 2, NULL);
+ StaticPrompt (k, "Optional string constraint", 0, dialogTextHeight, programFont, 'c');
+ selfp->findthis = DialogText (k, "", 14, NULL);
+ }
+
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoSelectAsnObject);
+ b = DefaultButton (c, "Accept", DoSelectAsnObject);
SetObjectExtra (b, selfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
- AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
+ if (selfp->type == SLCT_FEAT || selfp->type == SLCT_DESC)
+ {
+ AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) k, (HANDLE) c, NULL);
+ }
+ else
+ {
+ AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
+ }
RealizeWindow (w);
if (type == SLCT_BIOSEQ) {
DoSelectAsnObject (b);
@@ -3833,7 +4160,7 @@ extern void FuseFeature (IteM i)
ffp->head = head;
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoFuseFeature);
+ b = DefaultButton (c, "Accept", DoFuseFeature);
SetObjectExtra (b, ffp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -4397,7 +4724,7 @@ static ForM CreateRefGeneDescForm (Int2 left, Int2 top, Int2 width,
rfp->data = CreateRefGeneDialog (g);
c = HiddenGroup (w, 2, 0, NULL);
- b = PushButton (c, "Accept", StdAcceptFormButtonProc);
+ b = DefaultButton (c, "Accept", StdAcceptFormButtonProc);
SetObjectExtra (b, rfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
@@ -4532,8 +4859,10 @@ typedef struct cka_acc {
static Int4 CKA_blast_wordsize;
static FloatHi CKA_blast_expect_value;
+static Boolean CKA_blast_allow_repeats;
static Int4 CKA_blast_detailed_wordsize;
static FloatHi CKA_blast_detailed_expect_value;
+static Boolean CKA_blast_detailed_allow_repeats;
static SeqAlignPtr CKA_MakeAlign(BioseqPtr bsp, CKA_AccPtr acc_head);
@@ -5515,7 +5844,9 @@ static SeqAlignPtr CKA_MakeAlign(BioseqPtr bsp, CKA_AccPtr acc_head)
if (acc->sap != NULL && acc->sap->next != NULL)
{
AlnMgr2IndexLite(acc->sap);
- CKA_RemoveInconsistentAlnsFromSet(acc->sap, -1);
+ if (!CKA_blast_allow_repeats) {
+ CKA_RemoveInconsistentAlnsFromSet(acc->sap, -1);
+ }
sap_tmp = acc->sap;
acc->sap = (SeqAlignPtr)(acc->sap->segs);
sap_tmp->segs = NULL;
@@ -5638,6 +5969,7 @@ extern void CreateSeqHistTPA (IteM i)
{
CKA_blast_wordsize = 28;
CKA_blast_expect_value = 0.000001;
+ CKA_blast_allow_repeats = FALSE;
DoCreateSeqHistTPA(i);
}
@@ -5751,6 +6083,7 @@ extern void CreateSeqHistDelta (IteM i)
static TexT blast_wordsize_text = NULL;
static TexT blast_expect_value_text = NULL;
+static ButtoN blast_allow_repeats_button = NULL;
static IteM blast_i;
static void DoAcceptBlastOptions (ButtoN b)
@@ -5768,6 +6101,8 @@ static void DoAcceptBlastOptions (ButtoN b)
if (sscanf (buf, "%lf", &val2) == 1) {
CKA_blast_expect_value = CKA_blast_detailed_expect_value = (FloatHi) val2;
}
+ CKA_blast_allow_repeats = CKA_blast_detailed_allow_repeats =
+ (Boolean) GetStatus (blast_allow_repeats_button);
Remove (ParentWindow (b));
DoCreateSeqHistTPA(blast_i);
}
@@ -5804,6 +6139,11 @@ extern void CreateSeqHistTPADetailed (IteM i)
sprintf(buf, "%f", CKA_blast_expect_value);
blast_expect_value_text = DialogText (g, buf, 10, NULL);
+ blast_allow_repeats_button = CheckBox (g, "Allow Repeats", NULL);
+ if (CKA_blast_detailed_allow_repeats) {
+ SetStatus(blast_allow_repeats_button, TRUE);
+ }
+
c = HiddenGroup (w, 2, 0, NULL);
SetGroupSpacing (c, 5, 5);
DefaultButton (c, "Accept", DoAcceptBlastOptions);
@@ -6166,7 +6506,7 @@ static ForM CreateAssemblyDescForm (Int2 left, Int2 top, Int2 width,
afp->data = CreateAssemblyDialog (g);
c = HiddenGroup (w, 2, 0, NULL);
- b = PushButton (c, "Accept", StdAcceptFormButtonProc);
+ b = DefaultButton (c, "Accept", StdAcceptFormButtonProc);
SetObjectExtra (b, afp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
@@ -6644,7 +6984,7 @@ extern void EditSequenceHistory (IteM i)
AlignObjects (ALIGN_CENTER, (HANDLE) hfp->deleted, (HANDLE) hfp->deleted_date, NULL);
c = HiddenGroup (h, 4, 0, NULL);
- b = PushButton (c, "Accept", DoChangeHistory);
+ b = DefaultButton (c, "Accept", DoChangeHistory);
SetObjectExtra (b, hfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -9351,7 +9691,7 @@ static ForM CreateDefLineModForm (Uint2 entityID, SeqEntryPtr sep, BioseqPtr tar
}
c = HiddenGroup (w, 4, 0, NULL);
- b = PushButton (c, "Accept", DefLineModFormAcceptProc);
+ b = DefaultButton (c, "Accept", DefLineModFormAcceptProc);
SetObjectExtra (b, dfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
diff --git a/sequin/sequin9.c b/sequin/sequin9.c
index d439ea7f..32704a8e 100644
--- a/sequin/sequin9.c
+++ b/sequin/sequin9.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 4/20/99
*
-* $Revision: 6.187 $
+* $Revision: 6.195 $
*
* File Description:
*
@@ -129,6 +129,7 @@ typedef struct upsdata {
Boolean useGUI;
Boolean do_update;
ButtoN add_cit_subs;
+ ButtoN update_proteins;
} UpsData, PNTR UpsDataPtr;
/*---------------------*/
@@ -430,6 +431,8 @@ static void SimpleRsiteProc (IteM i)
static VQUEUE vsquerylist = NULL;
+static Int2 vsquerynum = 0;
+
static void LIBCALLBACK AnnounceCallback (CharPtr requestID, CharPtr seqID, Int2 estimatedSeconds)
{
@@ -441,6 +444,8 @@ static void LIBCALLBACK AnnounceCallback (CharPtr requestID, CharPtr seqID, Int2
}
Message (MSG_POST, "Queued rID %s, seqID %s, estimated seconds = %d",
requestID, seqID, (int) estimatedSeconds);
+
+ vsquerynum++;
}
static Boolean LIBCALLBACK VecScreenCallback (
@@ -671,6 +676,8 @@ extern void SubmitToNCBI (IteM i)
static QUEUE cddquerylist = NULL;
+static Int2 cddquerynum = 0;
+
#include <cddapi.h>
#define CDD_EXPECT_VALUE 0.01
@@ -721,6 +728,8 @@ static void SearchCDD (BioseqPtr bsp, Pointer userdata)
dofeats = (BoolPtr) userdata;
if (! CddAsynchronousQuery (bsp, CDD_EXPECT_VALUE, TRUE, TRUE, *dofeats, "cdd", &cddquerylist, CddProc, (Pointer) bsp)) {
ErrPostEx (SEV_ERROR, 0, 0, "Unable to run CDD search");
+ } else {
+ cddquerynum++;
}
}
@@ -813,8 +822,16 @@ extern void SequinCheckSocketsProc (void)
pendingqueries--;
}
remaining = VecScreenCheckQueue (&vsquerylist);
+ if (remaining < vsquerynum) {
+ vsquerynum = remaining;
+ Message (MSG_POST, "There are %d vector screens remaining", (int) vsquerynum);
+ }
remaining = QBlastCheckQueue (&qbquerylist);
remaining = CddCheckQueue (&cddquerylist);
+ if (remaining < cddquerynum) {
+ cddquerynum = remaining;
+ Message (MSG_POST, "There are %d cdd searches remaining", (int) cddquerynum);
+ }
}
static Boolean LIBCALLBACK DemoModeResultProc (CONN conn, VoidPtr userdata, EIO_Status status)
@@ -1607,7 +1624,7 @@ static void BuildArgumentForm (NewObjectPtr nop, BaseFormPtr bfp, Int2 which)
c = HiddenGroup (w, 2, 0, NULL);
SetGroupSpacing (c, 10, 3);
- b = PushButton (c, "Accept", AcceptArgumentFormProc);
+ b = DefaultButton (c, "Accept", AcceptArgumentFormProc);
SetObjectExtra (b, ufp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
@@ -4096,150 +4113,319 @@ static void AcceptExtend (ButtoN b)
}
static void PrepareToUpdateSequences (UpsDataPtr udp);
-
-static void UpdateOneProtein (SeqFeatPtr sfp, Pointer userdata)
+static Boolean PrepareUpdatePtr (UpsDataPtr udp);
+static ForM UpdateSequenceForm (UpsDataPtr udp);
+static void UpdateOneSequence (
+ UpsDataPtr udp,
+ Int2 rmcval,
+ Int2 sfbval,
+ Boolean add_cit_subs,
+ Boolean update_proteins);
+
+static UpsDataPtr PrepareUpdatePtrForProtein (
+ SeqFeatPtr sfp,
+ Uint2 input_entityID,
+ Uint4 input_itemID,
+ Uint4 input_itemtype
+)
{
- BaseFormPtr bfp;
- BioseqPtr protBsp; /* This will point to the old version of the
- * protein bioseq
- */
ByteStorePtr bs;
- BioseqPtr newBsp;
CharPtr newprot, ptr;
Char ch;
- UpsDataPtr udp_copy;
Boolean star_at_end;
SeqEntryPtr nwsep;
-
- bfp = (BaseFormPtr) userdata;
- if ( bfp == NULL
- || sfp == NULL
+ BioseqPtr newBsp, protBsp;
+ UpsDataPtr udp_copy;
+
+ if (sfp == NULL
|| sfp->idx.subtype != FEATDEF_CDS
|| sfp->product == NULL
|| (protBsp = BioseqFindFromSeqLoc (sfp->product)) == NULL)
{
- return;
+ return NULL;
}
-
- newprot = NULL;
bs = ProteinFromCdRegionEx (sfp, TRUE, FALSE);
+ if (bs == NULL) return NULL;
+
+ newprot = BSMerge (bs, NULL);
+ bs = BSFree (bs);
+ if (newprot == NULL) return NULL;
+
+ ptr = newprot;
+ ch = *ptr;
+ while (ch != '\0')
+ {
+ *ptr = TO_UPPER (ch);
+ if (ch == '*') {
+ star_at_end = 1;
+ } else {
+ star_at_end = 0;
+ }
+ ptr++;
+ ch = *ptr;
+ }
+ if (star_at_end)
+ {
+ ptr [ StringLen (ptr) - 1] = 0;
+ }
+ bs = BSNew (1000);
if (bs != NULL)
{
- newprot = BSMerge (bs, NULL);
- bs = BSFree (bs);
- if (newprot != NULL)
+ ptr = newprot;
+ BSWrite (bs, (VoidPtr) ptr, (Int4) StringLen (ptr));
+ }
+ MemFree (newprot);
+
+ newBsp = BioseqNew ();
+ if (newBsp == NULL) return NULL;
+
+ newBsp->id = SeqIdParse ("lcl|CdRgnTransl");
+ newBsp->repr = Seq_repr_raw;
+ newBsp->mol = Seq_mol_aa;
+ newBsp->seq_data_type = Seq_code_ncbieaa;
+ newBsp->seq_data = bs;
+ newBsp->length = BSLen (bs);
+
+ /* create SeqEntry for temporary protein bioseq to live in */
+ nwsep = SeqEntryNew ();
+ nwsep->choice = 1;
+ nwsep->data.ptrvalue = newBsp;
+ SeqMgrSeqEntry (SM_BIOSEQ, (Pointer) newBsp, nwsep);
+
+ udp_copy = MemNew (sizeof (UpsData));
+ if (udp_copy == NULL) return NULL;
+ udp_copy->input_entityID = input_entityID;
+ udp_copy->input_itemID = input_itemID;
+ udp_copy->input_itemtype = input_itemtype;
+ udp_copy->fp = NULL;
+ udp_copy->isSet = FALSE;
+ udp_copy->useGUI = TRUE;
+ udp_copy->convertPubs = CONVERTPUBS_NO; /* was CONVERTPUBS_NOT_SET */
+ udp_copy->do_update = TRUE;
+ udp_copy->newbsp = newBsp;
+ udp_copy->oldbsp = protBsp;
+ udp_copy->seq1 = GetSequenceByBsp (protBsp);
+ udp_copy->seq2 = GetSequenceByBsp (newBsp);
+ if (StringCmp (udp_copy->seq1, udp_copy->seq2) == 0
+ || (star_at_end == 1
+ && StringNCmp (udp_copy->seq1,
+ udp_copy->seq2,
+ StringLen (udp_copy->seq1)) == 0))
+ {
+ SeqEntryFree (nwsep);
+ MemFree (udp_copy->seq1);
+ MemFree (udp_copy->seq2);
+ MemFree (udp_copy);
+ return NULL;
+ }
+ return udp_copy;
+}
+
+static void FixProtRefPtr (SeqFeatPtr sfp, Pointer userdata)
+{
+ ProtRefPtr prp;
+ BioseqPtr bsp;
+ Int4 offset;
+ Int4 start;
+ Int4 stop;
+ Uint1 strand;
+
+ if (sfp == NULL || sfp->idx.subtype != FEATDEF_PROT) return;
+ prp = (ProtRefPtr) sfp->data.value.ptrvalue;
+ bsp = BioseqFindFromSeqLoc (sfp->location);
+ offset = GetOffsetInBioseq (sfp->location, bsp, SEQLOC_RIGHT_END);
+ if (bsp->length - 1 > offset)
+ {
+ start = GetOffsetInBioseq (sfp->location, bsp, SEQLOC_START);
+ stop = GetOffsetInBioseq (sfp->location, bsp, SEQLOC_STOP);
+ strand = SeqLocStrand (sfp->location);
+ if (strand == Seq_strand_minus)
{
- ptr = newprot;
- ch = *ptr;
- while (ch != '\0')
- {
- *ptr = TO_UPPER (ch);
- if (ch == '*') {
- star_at_end = 1;
- } else {
- star_at_end = 0;
- }
- ptr++;
- ch = *ptr;
- }
- if (star_at_end)
- {
- ptr [ StringLen (ptr) - 1] = 0;
- }
- bs = BSNew (1000);
- if (bs != NULL)
- {
- ptr = newprot;
- BSWrite (bs, (VoidPtr) ptr, (Int4) StringLen (ptr));
- }
- MemFree (newprot);
+ expand_seq_loc (bsp->length - 1, stop, strand, sfp->location);
}
- newBsp = BioseqNew ();
- if (newBsp != NULL)
+ else
{
- newBsp->id = SeqIdParse ("lcl|CdRgnTransl");
- newBsp->repr = Seq_repr_raw;
- newBsp->mol = Seq_mol_aa;
- newBsp->seq_data_type = Seq_code_ncbieaa;
- newBsp->seq_data = bs;
- newBsp->length = BSLen (bs);
-
- /* create SeqEntry for temporary protein bioseq to live in */
- nwsep = SeqEntryNew ();
- nwsep->choice = 1;
- nwsep->data.ptrvalue = newBsp;
- SeqMgrSeqEntry (SM_BIOSEQ, (Pointer) newBsp, nwsep);
-
- udp_copy = MemNew (sizeof (UpsData));
- if (udp_copy == NULL) return;
- udp_copy->input_entityID = bfp->input_entityID;
- udp_copy->input_itemID = bfp->input_itemID;
- udp_copy->input_itemtype = bfp->input_itemtype;
- udp_copy->fp = NULL;
- udp_copy->isSet = FALSE;
- udp_copy->useGUI = TRUE;
- udp_copy->convertPubs = CONVERTPUBS_NO; /* was CONVERTPUBS_NOT_SET */
- udp_copy->do_update = TRUE;
- udp_copy->newbsp = newBsp;
- udp_copy->oldbsp = protBsp;
- udp_copy->seq1 = GetSequenceByBsp (protBsp);
- udp_copy->seq2 = GetSequenceByBsp (newBsp);
- if (StringCmp (udp_copy->seq1, udp_copy->seq2) == 0
- || (star_at_end == 1
- && StringNCmp (udp_copy->seq1,
- udp_copy->seq2,
- StringLen (udp_copy->seq1)) == 0))
- {
- SeqEntryFree (nwsep);
- MemFree (udp_copy->seq1);
- MemFree (udp_copy->seq2);
- MemFree (udp_copy);
- }
- else
- {
- PrepareToUpdateSequences (udp_copy);
- }
+ expand_seq_loc (start, bsp->length - 1, strand, sfp->location);
}
}
}
-
-extern void UpdateProteinsFromCDS ( IteM i)
+
+extern SeqLocPtr SeqLocWholeNew (BioseqPtr bsp)
{
- BaseFormPtr bfp;
- SeqEntryPtr sep;
+ ValNodePtr vnp;
-#ifdef WIN_MAC
- bfp = currentFormDataPtr;
-#else
- bfp = GetObjectExtra (i);
-#endif
+ if (bsp == NULL) return NULL;
- if (bfp == NULL)
+ vnp = ValNodeNew (NULL);
+
+ if (vnp == NULL) return NULL;
+
+ vnp->choice = SEQLOC_WHOLE;
+ vnp->data.ptrvalue = (Pointer) SeqIdFindBest (bsp->id, 0);
+ return (SeqLocPtr)vnp;
+}
+
+static void UpdateOneProtein (SeqFeatPtr sfp, Pointer userdata)
+{
+ BaseFormPtr bfp;
+ UpsDataPtr udp_copy;
+ SeqLocPtr new_product;
+
+ bfp = (BaseFormPtr) userdata;
+ if ( bfp == NULL
+ || sfp == NULL
+ || sfp->idx.subtype != FEATDEF_CDS
+ || sfp->product == NULL)
+ {
return;
- sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
- if (sep == NULL) return;
+ }
+
+ udp_copy = PrepareUpdatePtrForProtein (sfp,
+ bfp->input_entityID,
+ bfp->input_itemID,
+ bfp->input_itemtype);
+ if (udp_copy == NULL) return;
- VisitFeaturesInSep (sep, (Pointer) bfp, UpdateOneProtein);
+ if ( ! PrepareUpdatePtr (udp_copy)) return;
- ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
- ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+ UpdateOneSequence (udp_copy, 1, 1, FALSE, FALSE);
+ if (sfp->product->choice != SEQLOC_WHOLE)
+ {
+ new_product = SeqLocWholeNew (udp_copy->oldbsp);
+ if (new_product == NULL) return;
+ SeqLocFree (sfp->product);
+ sfp->product = new_product;
+ }
+ VisitFeaturesOnBsp (udp_copy->oldbsp, NULL, FixProtRefPtr);
}
-static void AcceptRMC (ButtoN b)
+static Boolean CheckForIDCollision (
+ BioseqPtr oldbsp,
+ BioseqPtr newbsp,
+ BoolPtr islocal
+)
+
+{
+ SeqIdPtr sip;
+
+ if (oldbsp == NULL || newbsp == NULL) return FALSE;
+ for (sip = newbsp->id; sip != NULL; sip = sip->next) {
+ if (SeqIdIn (sip, oldbsp->id)) {
+ if (sip->choice == SEQID_LOCAL) {
+ *islocal = TRUE;
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static CharPtr convPubDescMssg =
+"Do you wish to convert publications to apply only to the appropriate ranges?";
+
+static Boolean PrepareUpdatePtr (UpsDataPtr udp)
{
- UpsDataPtr udp;
Uint2 entityID;
- Int2 rmcval, sfbval;
+ SeqEntryPtr oldsep, newsep;
+ SeqIdPtr tempid = NULL;
+ SeqIdPtr sip;
+ MsgAnswer ans;
+ Boolean islocal = FALSE;
+ SeqIdPtr lclid = NULL;
+ Char buf [64];
+ Boolean descfilt [SEQDESCR_MAX];
+ Boolean featfilt [SEQFEAT_MAX];
+ SeqAlignPtr salp = NULL;
+ Boolean revcomp = FALSE;
+
+ if (udp->oldbsp == NULL || udp->newbsp == NULL) return FALSE;
+ if (ISA_na (udp->oldbsp->mol) != ISA_na (udp->newbsp->mol)) {
+ Message (MSG_OK, "Both sequences must be either nucleotides or proteins");
+ return FALSE;
+ }
+
+ entityID = ObjMgrGetEntityIDForPointer (udp->oldbsp);
+ oldsep = GetBestTopParentForData (entityID, udp->oldbsp);
+ entityID = ObjMgrGetEntityIDForPointer (udp->newbsp);
+ newsep = GetBestTopParentForData (entityID, udp->newbsp);
+ if (oldsep == NULL || newsep == NULL)
+ return FALSE;
+
+ if (CONVERTPUBS_NOT_SET == udp->convertPubs)
+ {
+ if (Message (MSG_YN, convPubDescMssg) == ANS_YES) {
+ ConvertPubSrcComDescsToFeats (oldsep, TRUE, FALSE, FALSE, FALSE);
+ ConvertPubSrcComDescsToFeats (newsep, TRUE, FALSE, FALSE, FALSE);
+ udp->convertPubs = CONVERTPUBS_YES;
+ }
+ else
+ udp->convertPubs = CONVERTPUBS_NO;
+ }
+
+ tempid = NULL;
+ if (CheckForIDCollision (udp->oldbsp, udp->newbsp, &islocal)) {
+ sip = SeqIdParse ("lcl|SequinUpdateSequence");
+ if (sip != NULL) {
+ if (islocal) {
+ entityID = ObjMgrGetEntityIDForPointer (udp->newbsp);
+ for (lclid = udp->newbsp->id;
+ lclid != NULL && lclid->choice != SEQID_LOCAL;
+ lclid = lclid->next) continue;
+ if (lclid != NULL) {
+ SeqIdWrite (lclid, buf, PRINTID_REPORT, sizeof (buf) - 1);
+ FindReplaceInEntity (entityID, buf, "SequinUpdateSequence", TRUE, FALSE, TRUE,
+ FALSE, UPDATE_NEVER, descfilt, featfilt, NULL, TRUE);
+ SeqMgrReplaceInBioseqIndex (udp->newbsp);
+ } else {
+ Message (MSG_OK, "Unable to find colliding local id");
+ return FALSE;
+ }
+ } else {
+ /* unlink colliding id, temporarily replace */
+ tempid = udp->newbsp->id;
+ udp->newbsp->id = sip;
+ SeqMgrReplaceInBioseqIndex (udp->newbsp);
+ }
+ }
+ }
+ salp = Sqn_GlobalAlign2Seq (udp->oldbsp, udp->newbsp, &revcomp);
+ if (tempid != NULL) {
+ /* add back colliding id now that blast is done */
+ sip->next = tempid;
+ SeqMgrReplaceInBioseqIndex (udp->newbsp);
+ }
+
+ if (salp == NULL) {
+ ans = Message (MSG_YN, "There is no alignment between the sequences. "
+ "Do you wish to continue anyway?");
+ if (ans == ANS_NO)
+ return FALSE;
+ }
+
+ udp->salp = salp;
+ udp->revcomp = revcomp;
+ udp->diffOrgs = FALSE;
+ udp->recomb1 = -1;
+ udp->recomb2 = -1;
+
+ return TRUE;
+}
+
+static void UpdateProteinsOnNewBsp (SeqFeatPtr sfp, Pointer userdata);
+
+static void UpdateOneSequence (
+ UpsDataPtr udp,
+ Int2 rmcval,
+ Int2 sfbval,
+ Boolean add_cit_subs,
+ Boolean update_proteins
+)
+{
SeqAnnotPtr sap = NULL;
+ Uint2 entityID;
SeqEntryPtr sep;
Boolean update = FALSE;
-
- udp = (UpsDataPtr) GetObjectExtra (b);
- if (udp == NULL) return;
- SafeHide (udp->form);
-
- sfbval = GetValue (udp->sfb);
- rmcval = GetValue (udp->rmc);
+ Boolean feature_update = FALSE;
if (sfbval == 1 || sfbval == 3) {
switch (rmcval) {
@@ -4281,21 +4467,25 @@ static void AcceptRMC (ButtoN b)
case 1 :
if (DoFeaturePropWithOffset (udp, 0, &sap, FALSE)) {
update = TRUE;
+ feature_update = TRUE;
}
break;
case 2 :
if (DoFeaturePropWithOffset (udp, 0, &sap, FALSE)) {
update = TRUE;
+ feature_update = TRUE;
}
break;
case 3 :
if (DoFeaturePropWithOffset (udp, udp->old5 - udp->new5, &sap, FALSE)) {
update = TRUE;
+ feature_update = TRUE;
}
break;
case 4 :
if (DoFeaturePropWithOffset (udp, udp->old5 - udp->new5, &sap, TRUE)) {
update = TRUE;
+ feature_update = TRUE;
}
break;
default :
@@ -4307,21 +4497,25 @@ static void AcceptRMC (ButtoN b)
case 1 :
if (DoFeaturePropThruAlign (udp, &sap)) {
update = TRUE;
+ feature_update = TRUE;
}
break;
case 2 :
if (DoFeaturePropThruAlign (udp, &sap)) {
update = TRUE;
+ feature_update = TRUE;
}
break;
case 3 :
if (DoFeaturePropThruAlign (udp, &sap)) {
update = TRUE;
+ feature_update = TRUE;
}
break;
case 4 :
if (DoFeaturePropThruAlign (udp, &sap)) {
update = TRUE;
+ feature_update = TRUE;
}
break;
default :
@@ -4341,13 +4535,99 @@ static void AcceptRMC (ButtoN b)
}
if (update) {
entityID = ObjMgrGetEntityIDForPointer (udp->oldbsp);
- if (GetStatus (udp->add_cit_subs))
+ if (add_cit_subs
+ && (feature_update || StringCmp (udp->seq1, udp->seq2) != 0))
{
AddCitSubToUpdatedSequence ( udp->oldbsp, entityID);
}
+ if (update_proteins)
+ {
+ sep = GetBestTopParentForData (entityID, udp->oldbsp);
+ VisitFeaturesInSep (sep, udp, UpdateProteinsOnNewBsp);
+ }
ObjMgrSetDirtyFlag (entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, entityID, 0, 0);
}
+}
+
+static void UpdateProteinsOnNewBsp (SeqFeatPtr sfp, Pointer userdata)
+{
+ UpsDataPtr udp_orig, udp_copy;
+ Int2 sfbval, rmcval;
+ SeqLocPtr new_product;
+
+ if (sfp == NULL || sfp->idx.subtype != FEATDEF_CDS || userdata == NULL)
+ {
+ return;
+ }
+ udp_orig = (UpsDataPtr) userdata;
+
+ udp_copy = PrepareUpdatePtrForProtein (sfp,
+ udp_orig->input_entityID,
+ udp_orig->input_itemID,
+ udp_orig->input_itemtype);
+
+ if (udp_copy == NULL) return;
+
+ if (! PrepareUpdatePtr (udp_copy)) return;
+
+ if (udp_copy != NULL)
+ {
+ sfbval = GetValue (udp_orig->sfb);
+ rmcval = GetValue (udp_orig->rmc);
+
+ UpdateOneSequence (udp_copy, rmcval, sfbval,
+ GetStatus (udp_orig->add_cit_subs),
+ FALSE);
+ if (sfp->product->choice != SEQLOC_WHOLE)
+ {
+ new_product = SeqLocWholeNew (udp_copy->oldbsp);
+ if (new_product == NULL) return;
+ SeqLocFree (sfp->product);
+ sfp->product = new_product;
+ }
+ VisitFeaturesOnBsp (udp_copy->oldbsp, NULL, FixProtRefPtr);
+ }
+}
+
+extern void UpdateProteinsFromCDS ( IteM i)
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+
+ if (bfp == NULL)
+ return;
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ if (sep == NULL) return;
+
+ WatchCursor ();
+ VisitFeaturesInSep (sep, (Pointer) bfp, UpdateOneProtein);
+ ArrowCursor ();
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
+
+static void AcceptRMC (ButtoN b)
+{
+ UpsDataPtr udp;
+ Int2 rmcval, sfbval;
+
+ udp = (UpsDataPtr) GetObjectExtra (b);
+ if (udp == NULL) return;
+ SafeHide (udp->form);
+
+ sfbval = GetValue (udp->sfb);
+ rmcval = GetValue (udp->rmc);
+
+ UpdateOneSequence (udp, rmcval, sfbval,
+ GetStatus (udp->add_cit_subs),
+ GetStatus (udp->update_proteins));
Remove (udp->form);
}
@@ -4411,152 +4691,15 @@ static void AcceptRMCAll (ButtoN b)
static void DoAcceptRMCSet (UpsDataPtr udp)
{
- Uint2 entityID;
Int2 rmcval;
- SeqAnnotPtr sap = NULL;
- SeqEntryPtr sep;
Int2 sfbval;
- Boolean update = FALSE;
- Boolean feature_update = FALSE;
SafeHide (udp->form);
sfbval = GetValue (udp->sfb);
rmcval = GetValue (udp->rmc);
- if (sfbval == 1 || sfbval == 3) {
- switch (rmcval) {
- case 1 :
- if (ReplaceSequence (udp))
- update = TRUE;
- break;
- case 2 :
- if (NULL == udp->salp) {
- if (Merge5PrimeNoOverlap (udp))
- {
- update = TRUE;
- }
- }
- else {
- if (Merge5Prime (udp))
- {
- update = TRUE;
- }
- }
- break;
- case 3 :
- if (NULL == udp->salp) {
- if (Merge3PrimeNoOverlap (udp))
- {
- update = TRUE;
- }
- }
- else {
- if (Merge3Prime (udp))
- {
- update = TRUE;
- }
- }
- break;
- case 4 :
- if (PatchSequence (udp))
- {
- update = TRUE;
- }
- break;
- default :
- break;
- }
- if ( sfbval == 3) {
- switch (rmcval) {
- case 1 :
- if (DoFeaturePropWithOffset (udp, 0, &sap, FALSE))
- {
- update = TRUE;
- feature_update = TRUE;
- }
- break;
- case 2 :
- if (DoFeaturePropWithOffset (udp, 0, &sap, FALSE))
- {
- update = TRUE;
- feature_update = TRUE;
- }
- break;
- case 3 :
- if (DoFeaturePropWithOffset (udp, udp->old5 - udp->new5, &sap, FALSE))
- {
- update = TRUE;
- feature_update = TRUE;
- }
- break;
- case 4 :
- if (DoFeaturePropWithOffset (udp, udp->old5 - udp->new5, &sap, TRUE))
- {
- update = TRUE;
- feature_update = TRUE;
- }
- break;
- default :
- break;
- }
- }
- } else if (sfbval == 2) {
- switch (rmcval) {
- case 1 :
- if (DoFeaturePropThruAlign (udp, &sap))
- {
- update = TRUE;
- feature_update = TRUE;
- }
- break;
- case 2 :
- if (DoFeaturePropThruAlign (udp, &sap))
- {
- update = TRUE;
- feature_update = TRUE;
- }
- break;
- case 3 :
- if (DoFeaturePropThruAlign (udp, &sap))
- {
- update = TRUE;
- feature_update = TRUE;
- }
- break;
- case 4 :
- if (DoFeaturePropThruAlign (udp, &sap))
- {
- update = TRUE;
- feature_update = TRUE;
- }
- break;
- default :
- break;
- }
- }
-
- if (sfbval == 2 || sfbval == 3) {
- if (update) {
- entityID = ObjMgrGetEntityIDForPointer (udp->oldbsp);
- sep = GetTopSeqEntryForEntityID (entityID);
- /* need to set scope to be sure we mark the right bioseq for deletion */
- SeqEntrySetScope (sep);
- ResolveDuplicateFeats (udp, udp->oldbsp, sap);
- SeqEntrySetScope (NULL);
- DeleteMarkedObjects (entityID, 0, NULL);
- }
- }
-
- if (update) {
- entityID = ObjMgrGetEntityIDForPointer (udp->oldbsp);
- if (GetStatus (udp->add_cit_subs)
- && (feature_update || StringCmp (udp->seq1, udp->seq2) != 0))
- {
- AddCitSubToUpdatedSequence ( udp->oldbsp, entityID);
- }
- ObjMgrSetDirtyFlag (entityID, TRUE);
- ObjMgrSendMsg (OM_MSG_UPDATE, entityID, 0, 0);
- }
+ UpdateOneSequence (udp, rmcval, sfbval, GetStatus (udp->add_cit_subs),
+ GetStatus (udp->update_proteins));
Remove (udp->form);
FreeUdpFields (udp);
@@ -5911,21 +6054,26 @@ static ForM UpdateSequenceForm (UpsDataPtr udp)
(HANDLE) gp3, (HANDLE) udp->keepProteinIDs, NULL);
}
udp->add_cit_subs = CheckBox (g, "Add Cit-subs for Updated Sequences", NULL);
+ if (! ISA_aa (udp->oldbsp->mol))
+ {
+ udp->update_proteins = CheckBox (g, "Update proteins for Updated Sequences", NULL);
+ SetStatus (udp->update_proteins, TRUE);
+ }
if (! udp->do_update) {
c = HiddenGroup (w, 4, 0, NULL);
- udp->accept = PushButton (c, "Accept", AcceptExtend);
+ udp->accept = DefaultButton (c, "Accept", AcceptExtend);
SetObjectExtra (udp->accept, (Pointer) udp, NULL);
} else if (TRUE == udp->isSet) {
c = HiddenGroup (w, 5, 0, NULL);
- udp->accept = PushButton (c, "Accept", AcceptRMCSet);
+ udp->accept = DefaultButton (c, "Accept", AcceptRMCSet);
SetObjectExtra (udp->accept, (Pointer) udp, NULL);
- udp->acceptAll = PushButton (c, "Accept All", AcceptRMCAll);
+ udp->acceptAll = DefaultButton (c, "Accept All", AcceptRMCAll);
SetObjectExtra (udp->acceptAll, (Pointer) udp, NULL);
}
else {
c = HiddenGroup (w, 4, 0, NULL);
- udp->accept = PushButton (c, "Accept", AcceptRMC);
+ udp->accept = DefaultButton (c, "Accept", AcceptRMC);
SetObjectExtra (udp->accept, (Pointer) udp, NULL);
}
@@ -6022,133 +6170,17 @@ static Boolean LIBCALL SeqEntryHasPubs (SeqEntryPtr sep)
return rsult;
}
-static Boolean CheckForIDCollision (
- BioseqPtr oldbsp,
- BioseqPtr newbsp,
- BoolPtr islocal
-)
-
-{
- SeqIdPtr sip;
-
- if (oldbsp == NULL || newbsp == NULL) return FALSE;
- for (sip = newbsp->id; sip != NULL; sip = sip->next) {
- if (SeqIdIn (sip, oldbsp->id)) {
- if (sip->choice == SEQID_LOCAL) {
- *islocal = TRUE;
- }
- return TRUE;
- }
- }
- return FALSE;
-}
-
/*=====================================================================*/
/* */
/* PrepareToUpdateSequences () */
/* */
/*=====================================================================*/
-static CharPtr convPubDescMssg =
-"Do you wish to convert publications to apply only to the appropriate ranges?";
-
static void PrepareToUpdateSequences (UpsDataPtr udp)
{
- Char buf [64];
- Boolean descfilt [SEQDESCR_MAX];
- Boolean featfilt [SEQFEAT_MAX];
- Uint2 entityID;
ForM f;
- Boolean islocal = FALSE;
- SeqIdPtr lclid = NULL;
- SeqEntryPtr oldsep;
- SeqEntryPtr newsep;
- Boolean revcomp = FALSE;
- SeqAlignPtr salp = NULL;
- SeqIdPtr tempid = NULL;
- SeqIdPtr sip;
- MsgAnswer ans;
-
- if (udp->oldbsp == NULL || udp->newbsp == NULL) return;
- if (ISA_na (udp->oldbsp->mol) != ISA_na (udp->newbsp->mol)) {
- Message (MSG_OK, "Both sequences must be either nucleotides or proteins");
- return;
- }
-
- entityID = ObjMgrGetEntityIDForPointer (udp->oldbsp);
- oldsep = GetBestTopParentForData (entityID, udp->oldbsp);
- entityID = ObjMgrGetEntityIDForPointer (udp->newbsp);
- newsep = GetBestTopParentForData (entityID, udp->newbsp);
- if (oldsep == NULL || newsep == NULL)
- return;
-
- /*
- if (SeqEntryHasPubs (oldsep) || SeqEntryHasPubs (newsep)) {
- if ((FALSE == udp->isSet) || (TRUE == udp->useGUI)) {
- if (Message (MSG_YN, convPubDescMssg) == ANS_YES) {
- ConvertPubSrcComDescsToFeats (oldsep, TRUE, FALSE, FALSE, FALSE);
- ConvertPubSrcComDescsToFeats (newsep, TRUE, FALSE, FALSE, FALSE);
- }
- }
- else
- */
- if (CONVERTPUBS_NOT_SET == udp->convertPubs)
- if (Message (MSG_YN, convPubDescMssg) == ANS_YES) {
- ConvertPubSrcComDescsToFeats (oldsep, TRUE, FALSE, FALSE, FALSE);
- ConvertPubSrcComDescsToFeats (newsep, TRUE, FALSE, FALSE, FALSE);
- udp->convertPubs = CONVERTPUBS_YES;
- }
- else
- udp->convertPubs = CONVERTPUBS_NO;
- /*
- }
- */
-
- tempid = NULL;
- if (CheckForIDCollision (udp->oldbsp, udp->newbsp, &islocal)) {
- sip = SeqIdParse ("lcl|SequinUpdateSequence");
- if (sip != NULL) {
- if (islocal) {
- entityID = ObjMgrGetEntityIDForPointer (udp->newbsp);
- for (lclid = udp->newbsp->id;
- lclid != NULL && lclid->choice != SEQID_LOCAL;
- lclid = lclid->next) continue;
- if (lclid != NULL) {
- SeqIdWrite (lclid, buf, PRINTID_REPORT, sizeof (buf) - 1);
- FindReplaceInEntity (entityID, buf, "SequinUpdateSequence", TRUE, FALSE, TRUE,
- FALSE, UPDATE_NEVER, descfilt, featfilt, NULL, TRUE);
- SeqMgrReplaceInBioseqIndex (udp->newbsp);
- } else {
- Message (MSG_OK, "Unable to find colliding local id");
- return;
- }
- } else {
- /* unlink colliding id, temporarily replace */
- tempid = udp->newbsp->id;
- udp->newbsp->id = sip;
- SeqMgrReplaceInBioseqIndex (udp->newbsp);
- }
- }
- }
- salp = Sqn_GlobalAlign2Seq (udp->oldbsp, udp->newbsp, &revcomp);
- if (tempid != NULL) {
- /* add back colliding id now that blast is done */
- sip->next = tempid;
- SeqMgrReplaceInBioseqIndex (udp->newbsp);
- }
- if (salp == NULL) {
- ans = Message (MSG_YN, "There is no alignment between the sequences. "
- "Do you wish to continue anyway?");
- if (ans == ANS_NO)
- return;
- }
-
- udp->salp = salp;
- udp->revcomp = revcomp;
- udp->diffOrgs = FALSE;
- udp->recomb1 = -1;
- udp->recomb2 = -1;
+ if ( ! PrepareUpdatePtr (udp)) return;
if (TRUE == udp->useGUI) {
f = UpdateSequenceForm (udp);
@@ -6530,8 +6562,38 @@ extern void UpdateSeqAfterDownload (
)
{
+ MsgAnswer ans;
UpsDataPtr udp;
+ /* convert delta lit to raw so sequence can be updated */
+
+ if (oldbsp->repr == Seq_repr_delta && DeltaLitOnly (oldbsp)) {
+ if (indexerVersion) {
+ SegOrDeltaBioseqToRaw (oldbsp);
+ ObjMgrSetDirtyFlag (oldbsp->idx.entityID, TRUE);
+ } else {
+ ans = Message (MSG_YN, "Only raw sequences can be updated."
+ " Do you wish to convert this delta sequence to raw?");
+ if (ans == ANS_YES) {
+ SegOrDeltaBioseqToRaw (oldbsp);
+ ObjMgrSetDirtyFlag (oldbsp->idx.entityID, TRUE);
+ }
+ }
+ }
+
+ if (newbsp->repr == Seq_repr_delta && DeltaLitOnly (newbsp)) {
+ if (indexerVersion) {
+ SegOrDeltaBioseqToRaw (newbsp);
+ ObjMgrSetDirtyFlag (newbsp->idx.entityID, TRUE);
+ } else {
+ ans = Message (MSG_YN, "Only raw sequences can be updated."
+ " Do you wish to convert this delta sequence to raw?");
+ if (ans == ANS_YES) {
+ SegOrDeltaBioseqToRaw (newbsp);
+ ObjMgrSetDirtyFlag (newbsp->idx.entityID, TRUE);
+ }
+ }
+ }
/* Create data ptr */
udp = (UpsDataPtr) MemNew (sizeof (UpsData));
@@ -6561,8 +6623,38 @@ extern void ExtendSeqAfterDownload (
)
{
+ MsgAnswer ans;
UpsDataPtr udp;
+ /* convert delta lit to raw so sequence can be updated */
+
+ if (oldbsp->repr == Seq_repr_delta && DeltaLitOnly (oldbsp)) {
+ if (indexerVersion) {
+ SegOrDeltaBioseqToRaw (oldbsp);
+ ObjMgrSetDirtyFlag (oldbsp->idx.entityID, TRUE);
+ } else {
+ ans = Message (MSG_YN, "Only raw sequences can be extended."
+ " Do you wish to convert this delta sequence to raw?");
+ if (ans == ANS_YES) {
+ SegOrDeltaBioseqToRaw (oldbsp);
+ ObjMgrSetDirtyFlag (oldbsp->idx.entityID, TRUE);
+ }
+ }
+ }
+
+ if (newbsp->repr == Seq_repr_delta && DeltaLitOnly (newbsp)) {
+ if (indexerVersion) {
+ SegOrDeltaBioseqToRaw (newbsp);
+ ObjMgrSetDirtyFlag (newbsp->idx.entityID, TRUE);
+ } else {
+ ans = Message (MSG_YN, "Only raw sequences can be extended."
+ " Do you wish to convert this delta sequence to raw?");
+ if (ans == ANS_YES) {
+ SegOrDeltaBioseqToRaw (newbsp);
+ ObjMgrSetDirtyFlag (newbsp->idx.entityID, TRUE);
+ }
+ }
+ }
/* Create data ptr */
udp = (UpsDataPtr) MemNew (sizeof (UpsData));
@@ -7502,7 +7594,7 @@ static ForM FeaturePropagateForm (
fdp->fixCDS = CheckBox (g, "Cleanup CDS partials after propagation", NULL);
c = HiddenGroup (w, 4, 0, NULL);
- fdp->accept = PushButton (c, "Accept", AcceptFeatProp);
+ fdp->accept = DefaultButton (c, "Accept", AcceptFeatProp);
SetObjectExtra (fdp->accept, (Pointer) fdp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
diff --git a/tools/actutils.c b/tools/actutils.c
index 50528c15..3167c282 100644
--- a/tools/actutils.c
+++ b/tools/actutils.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: actutils.c,v 6.34 2003/06/30 15:01:29 whlavina Exp $";
+static char const rcsid[] = "$Id: actutils.c,v 6.35 2004/01/02 18:11:28 kans Exp $";
/* ===========================================================================
*
@@ -30,13 +30,16 @@ static char const rcsid[] = "$Id: actutils.c,v 6.34 2003/06/30 15:01:29 whlavina
*
* Version Creation Date: 2/00
*
-* $Revision: 6.34 $
+* $Revision: 6.35 $
*
* File Description: utility functions for alignments
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: actutils.c,v $
+* Revision 6.35 2004/01/02 18:11:28 kans
+* Sqn_GlobalAlign2Seq flips code break, anticodon when reverse complementing sequence
+*
* Revision 6.34 2003/06/30 15:01:29 whlavina
* Correct minus strand handling in CreaeContinuousAln functions; previous
* code could corrupt alignments (stop2-start1>1 would imply len<-2 if
@@ -2519,7 +2522,9 @@ static void SPI_flip_sa_list (SeqAlignPtr sap)
NLM_EXTERN SeqAlignPtr Sqn_GlobalAlign2Seq (BioseqPtr bsp1, BioseqPtr bsp2, BoolPtr revcomp)
{
- AMAlignIndex2Ptr amaip;
+ AMAlignIndex2Ptr amaip;
+ CodeBreakPtr cbp;
+ CdRegionPtr crp;
Int4 i;
BLAST_OptionsBlkPtr options;
CharPtr program = "blastn";
@@ -2536,9 +2541,11 @@ NLM_EXTERN SeqAlignPtr Sqn_GlobalAlign2Seq (BioseqPtr bsp1, BioseqPtr bsp2, Bool
Int4 extnd = 20;
SeqMgrFeatContext context;
Uint2 entityID;
+ RnaRefPtr rrp;
SeqFeatPtr sfp;
SeqIdPtr sip;
SeqLocPtr slp;
+ tRNAPtr trp;
if (bsp1 == NULL || bsp2 == NULL)
return NULL;
@@ -2588,6 +2595,33 @@ NLM_EXTERN SeqAlignPtr Sqn_GlobalAlign2Seq (BioseqPtr bsp1, BioseqPtr bsp2, Bool
slp = SeqLocCopyRegion (sip, sfp->location, bsp2, 0, bsp2->length - 1, Seq_strand_minus, FALSE);
sfp->location = SeqLocFree (sfp->location);
sfp->location = slp;
+ switch (sfp->data.choice) {
+ case SEQFEAT_CDREGION :
+ crp = (CdRegionPtr) sfp->data.value.ptrvalue;
+ if (crp != NULL) {
+ for (cbp = crp->code_break; cbp != NULL; cbp = cbp->next) {
+ sip = SeqLocId (cbp->loc);
+ slp = SeqLocCopyRegion (sip, cbp->loc, bsp2, 0, bsp2->length - 1, Seq_strand_minus, FALSE);
+ cbp->loc = SeqLocFree (cbp->loc);
+ cbp->loc = slp;
+ }
+ }
+ break;
+ case SEQFEAT_RNA :
+ rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
+ if (rrp != NULL && rrp->ext.choice == 2) {
+ trp = (tRNAPtr) rrp->ext.value.ptrvalue;
+ if (trp != NULL && trp->anticodon != NULL) {
+ sip = SeqLocId (trp->anticodon);
+ slp = SeqLocCopyRegion (sip, trp->anticodon, bsp2, 0, bsp2->length - 1, Seq_strand_minus, FALSE);
+ trp->anticodon = SeqLocFree (trp->anticodon);
+ trp->anticodon = slp;
+ }
+ }
+ break;
+ default :
+ break;
+ }
sfp = SeqMgrGetNextFeature (bsp2, sfp, 0, 0, &context);
}
SeqMgrClearFeatureIndexes (entityID, NULL);
diff --git a/tools/blast.c b/tools/blast.c
index f6249f32..7fc601c9 100644
--- a/tools/blast.c
+++ b/tools/blast.c
@@ -1,6 +1,6 @@
-static char const rcsid[] = "$Id: blast.c,v 6.391 2003/10/23 17:46:17 dondosha Exp $";
+static char const rcsid[] = "$Id: blast.c,v 6.397 2004/01/06 22:37:10 dondosha Exp $";
-/* $Id: blast.c,v 6.391 2003/10/23 17:46:17 dondosha Exp $
+/* $Id: blast.c,v 6.397 2004/01/06 22:37:10 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -49,9 +49,27 @@ Detailed Contents:
further manipulation.
******************************************************************************
- * $Revision: 6.391 $
+ * $Revision: 6.397 $
*
* $Log: blast.c,v $
+ * Revision 6.397 2004/01/06 22:37:10 dondosha
+ * Use BLAST_HSPfree function
+ *
+ * Revision 6.396 2003/12/29 15:42:46 coulouri
+ * tblastn query concatenation fixes from morgulis
+ *
+ * Revision 6.395 2003/12/12 16:01:23 madden
+ * Change to signature of BlastCutoffs, remove BlastCutoffs_simple
+ *
+ * Revision 6.394 2003/12/10 17:05:27 dondosha
+ * Added function ReevaluateScoreWithAmbiguities to reevaluate score for one HSP; use it after greedy traceback
+ *
+ * Revision 6.393 2003/11/19 18:09:13 dondosha
+ * Use consistent rounding in length adjustment calculation
+ *
+ * Revision 6.392 2003/11/10 20:15:29 dondosha
+ * Bug fix in BLASTMergeHsps
+ *
* Revision 6.391 2003/10/23 17:46:17 dondosha
* Fix in BlastGetDbChunk for looking up ordinal ids within a range
*
@@ -3256,7 +3274,7 @@ do_blast_search(VoidPtr ptr)
if (!search->handle_results)
status = BlastReevaluateWithAmbiguities(search, index1);
} else {
- MegaBlastReevaluateWithAmbiguities(search, index1);
+ MegaBlastReevaluateWithAmbiguities(search);
}
if (search->handle_results)
@@ -3289,7 +3307,7 @@ do_blast_search(VoidPtr ptr)
if (!search->handle_results)
status = BlastReevaluateWithAmbiguities(search, index);
} else {
- MegaBlastReevaluateWithAmbiguities(search, index);
+ MegaBlastReevaluateWithAmbiguities(search);
}
if (search->handle_results)
search->handle_results((VoidPtr) search);
@@ -4004,7 +4022,7 @@ Boolean BlastCalculateEffectiveLengths(BLAST_OptionsBlkPtr options,
}
else
{
- *length_adjustment = (Int4) ((kbp->logK)+log((Nlm_FloatHi)(length-last_length_adjustment)*(Nlm_FloatHi)(MAX(1, (dblen)-(dbseq_num*last_length_adjustment)))))/(kbp->H);
+ *length_adjustment = Nlm_Nint(((kbp->logK)+log((Nlm_FloatHi)(length-last_length_adjustment)*(Nlm_FloatHi)(MAX(1, (dblen)-(dbseq_num*last_length_adjustment)))))/(kbp->H));
}
if (*length_adjustment >= length-min_query_length)
{
@@ -5918,8 +5936,7 @@ BLASTMergeHsps(BlastSearchBlkPtr search, BLAST_HSPPtr hsp1, BLAST_HSPPtr hsp2,
if (new_segment1->s_end <= new_segment2->s_end) {
new_segment1 = new_segment1->next;
num1++;
- }
- if (new_segment1->s_end >= new_segment2->s_end) {
+ } else {
new_segment2 = new_segment2->next;
num2++;
}
@@ -6054,9 +6071,7 @@ BLASTMergeHitLists(BlastSearchBlkPtr search, BLAST_HitListPtr hitlist1,
OVERLAP_DIAG_CLOSE) {
if (merge_hsps) {
if (BLASTMergeHsps(search, hspp1[index], hspp2[index1], start)) {
- hspp2[index1]->gap_info =
- GapXEditBlockDelete(hspp2[index1]->gap_info);
- hspp2[index1] = MemFree(hspp2[index1]);
+ hspp2[index1] = BLAST_HSPFree(hspp2[index1]);
break;
}
} else { /* No gap information available */
@@ -6161,8 +6176,7 @@ BlastReapPartialHitlistByEvalue(BlastSearchBlkPtr search, Int4 start)
searchsp_eff);
if (hsp->evalue > 10*search->pbp->cutoff_e) {
- hsp->gap_info = GapXEditBlockDelete(hsp->gap_info);
- hsp = MemFree(hsp);
+ hsp = BLAST_HSPFree(hsp);
search->current_hitlist->hsp_array[index] = NULL;
}
}
@@ -7824,8 +7838,8 @@ BlastWordExtend_prelim(BlastSearchBlkPtr search, Int4 q_off, Int4 s_off, Int4 wo
/* AM: Support for query multiplexing. */
if( search->prog_number == blast_type_tblastn && search->mult_queries )
{
- query_num = GetQueryNum( search->mult_queries, q_off,
- q_off + word_width + 1, 0 );
+ query_num = GetQueryNum( search->mult_queries, q_off - word_width + 1,
+ q_off + 1, 0 );
X = search->mult_queries->dropoff_2nd_pass_array[query_num];
}
else X=pbp->X;
@@ -9459,6 +9473,7 @@ BlastSaveCurrentHitlist(BlastSearchBlkPtr search)
/* AM: Support for query concatenation. */
if( search->mult_queries && !retval ) return 0;
+
if (search->pbp->gapped_calculation &&
search->prog_number != blast_type_blastn)
kbp = search->sbp->kbp_gap[search->first_context];
@@ -9745,10 +9760,8 @@ BlastSaveCurrentHitlist(BlastSearchBlkPtr search)
mq_worst_result
= result_info->results[result_info->NumResults - 1];
--tmp_num_results;
- del_index = ResultIndex( mq_worst_result->best_evalue,
- mq_worst_result->high_score,
- mq_worst_result->subject_id,
- results, hitlist_count );
+ del_index = ResultIndex1( mq_worst_result,
+ results, hitlist_count );
BlastFreeHeap( search, results[del_index] );
if( results[del_index]->seqalign )
@@ -9881,27 +9894,26 @@ blast_set_parameters(BlastSearchBlkPtr search,
meff = (Nlm_FloatHi) search->context[search->first_context].query->length;
if (pbp->mb_params)
- BlastCutoffs_simple(&s, &e, kbp, searchsp, TRUE);
+ BlastCutoffs(&s, &e, kbp, searchsp, TRUE, search->pbp->gap_decay_rate );
else
{
if (pbp->gapped_calculation && search->prog_number != blast_type_blastn)
- { /* AM: Changed to support query concatenation. */
- if( !search->mult_queries )
- BlastCutoffs_simple(&s, &e, kbp_gap, searchsp, FALSE);
- else
- BlastCutoffs_simple( &s, &e, kbp_gap,
- search->mult_queries->MinSearchSpEff,
- FALSE );
- }
+ { /* AM: Changed to support query concatenation. */
+ if( !search->mult_queries )
+ BlastCutoffs(&s, &e, kbp_gap, searchsp, FALSE, 0.0 );
+ else
+ BlastCutoffs( &s, &e, kbp_gap,
+ search->mult_queries->MinSearchSpEff,
+ FALSE, 0.0 );
+ }
else
- { /* AM: Changed to support query concatenation. */
- if( !search->mult_queries )
- BlastCutoffs_simple(&s, &e, kbp, searchsp, FALSE);
- else
- BlastCutoffs_simple( &s, &e, kbp,
- search->mult_queries->MinSearchSpEff,
- FALSE );
- }
+ { /* AM: Changed to support query concatenation. */
+ if( !search->mult_queries )
+ BlastCutoffs(&s, &e, kbp, searchsp, FALSE, 0.0 );
+ else
+ BlastCutoffs( &s, &e, kbp, search->mult_queries->MinSearchSpEff,
+ FALSE, 0.0 );
+ }
}
/* Determine the secondary cutoff score, S2, to use */
if (e2 == 0. && !pbp->cutoff_s2_set)
@@ -9920,24 +9932,26 @@ blast_set_parameters(BlastSearchBlkPtr search,
/*
BlastCutoffs(&s2, &e2, kbp, meff, avglen, TRUE);
*/
- if (pbp->gapped_calculation && search->prog_number != blast_type_blastn)
- {
- if( !search->mult_queries )
- BlastCutoffs(&s2, &e2, kbp_gap, MIN(avglen,meff), avglen, TRUE);
- else
- BlastCutoffs( &s2, &e2, kbp_gap,
- MIN( avglen,search->mult_queries->MinLen ),
- avglen, TRUE );
- }
- else
- { /* AM: Changed to support query concatenation. */
- if( !search->mult_queries )
- BlastCutoffs(&s2, &e2, kbp, MIN(avglen,meff), avglen, TRUE);
- else
- BlastCutoffs( &s2, &e2, kbp,
- MIN(avglen,2*(search->mult_queries->MinLen)),
- avglen, TRUE );
- }
+ if (pbp->gapped_calculation && search->prog_number != blast_type_blastn)
+ {
+ if( !search->mult_queries )
+ BlastCutoffs(&s2, &e2, kbp_gap, MIN(avglen,meff) * avglen,
+ TRUE, search->pbp->gap_decay_rate );
+ else
+ BlastCutoffs( &s2, &e2, kbp_gap,
+ MIN( avglen,search->mult_queries->MinLen ) * avglen,
+ TRUE, search->pbp->gap_decay_rate );
+ }
+ else
+ { /* AM: Changed to support query concatenation. */
+ if( !search->mult_queries )
+ BlastCutoffs(&s2, &e2, kbp, MIN(avglen,meff) * avglen,
+ TRUE, search->pbp->gap_decay_rate );
+ else
+ BlastCutoffs( &s2, &e2, kbp,
+ MIN(avglen,2*(search->mult_queries->MinLen)) * avglen,
+ TRUE, search->pbp->gap_decay_rate );
+ }
/* Adjust s2 to be in line with s, as necessary */
s2 = MAX(s2, 1);
if (s2 > s)
@@ -11351,9 +11365,7 @@ BlastReapHitlistByEvalue (BlastSearchBlkPtr search)
if (hsp->evalue > cutoff &&
(search->pbp->no_check_score || search->pbp->cutoff_s > hsp->score))
{
- hsp_array[index]->gap_info =
- GapXEditBlockDelete(hsp_array[index]->gap_info);
- hsp_array[index] = MemFree(hsp_array[index]);
+ hsp_array[index] = BLAST_HSPFree(hsp_array[index]);
hsp_deleted = TRUE;
}
else
diff --git a/tools/blastconcat.c b/tools/blastconcat.c
index 8deaf72d..ab8a1fae 100644
--- a/tools/blastconcat.c
+++ b/tools/blastconcat.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: blastconcat.c,v 1.4 2003/05/30 17:25:36 coulouri Exp $";
+static char const rcsid[] = "$Id: blastconcat.c,v 1.5 2003/12/29 15:42:46 coulouri Exp $";
/* ===========================================================================
*
@@ -33,8 +33,11 @@ Contents: implementation of functions needed for query multiplexing
functionality.
******************************************************************************/
-/* $Revision: 1.4 $
+/* $Revision: 1.5 $
* $Log: blastconcat.c,v $
+* Revision 1.5 2003/12/29 15:42:46 coulouri
+* tblastn query concatenation fixes from morgulis
+*
* Revision 1.4 2003/05/30 17:25:36 coulouri
* add rcsid
*
@@ -877,6 +880,56 @@ void LIBCALL InitHitLists PROTO(( BlastSearchBlkPtr search ))
}
}
}
+/* TEMPORARY FUNCTION - FOR DEBUGGING ONLY */
+void LIBCALL MQ_CheckLists PROTO(( BLASTResultHitlistPtr PNTR local, Int4 lsize,
+ BLASTResultHitlistPtr PNTR res, Int4 rsize ))
+{
+ Int4 i, j;
+
+ for( i = 0; i < lsize; ++i )
+ {
+ int found = 0;
+
+ for( j = 0; j < rsize; ++j )
+ if( local[i] == res[j] )
+ {
+ found = 1;
+ break;
+ }
+
+ if( !found )
+ {
+ fprintf( stderr, "ERROR: %d is not in res\n", i );
+ return;
+ }
+ }
+}
+
+/* ResultIndex1():
+
+ This function first calls the binary search via ResultIndex(). Then tries
+ to locate the exact object in the array by pointer.
+
+*/
+Int4 LIBCALL ResultIndex1 PROTO(( BLASTResultHitlistPtr ptr,
+ BLASTResultHitlistPtr PNTR results,
+ Int4 num_elements ))
+{
+ Int4 del_index = ResultIndex( ptr->best_evalue, ptr->high_score,
+ ptr->subject_id, results, num_elements );
+ ASSERT( del_index < num_elements );
+
+ if( results[del_index] == ptr ) return del_index;
+
+ while( del_index >= 0 && results[del_index]->subject_id == ptr->subject_id )
+ --del_index;
+
+ while( ++del_index < num_elements && results[del_index] != ptr );
+
+ ASSERT( del_index < num_elements );
+
+ return del_index;
+}
/* ResultIndex():
diff --git a/tools/blastconcatdef.h b/tools/blastconcatdef.h
index aa519e85..7a4bf7e7 100644
--- a/tools/blastconcatdef.h
+++ b/tools/blastconcatdef.h
@@ -31,8 +31,11 @@ Contents: type definitions and function prototypes for query
multiplexing code.
******************************************************************************/
-/* $Revision: 1.1 $
+/* $Revision: 1.2 $
* $Log: blastconcatdef.h,v $
+* Revision 1.2 2003/12/29 15:42:46 coulouri
+* tblastn query concatenation fixes from morgulis
+*
* Revision 1.1 2003/03/24 20:47:28 madden
* Utilities for concatenation of blastn/tblastn queries
*
@@ -143,6 +146,9 @@ Uint4 LIBCALL GetNumSpacers PROTO(( BLAST_OptionsBlkPtr options,
Boolean believe_query,
BspArray fake_bsp_arr ));
void LIBCALL InitHitLists PROTO(( BlastSearchBlkPtr search ));
+Int4 LIBCALL ResultIndex1 PROTO(( BLASTResultHitlistPtr ptr,
+ BLASTResultHitlistPtr PNTR results,
+ Int4 num_elements ));
Int4 LIBCALL ResultIndex PROTO(( Nlm_FloatHi target_e, Int4 target_score, Int4 subject_id,
BLASTResultHitlistPtr PNTR results,
Int4 num_elements ));
diff --git a/tools/blastdef.h b/tools/blastdef.h
index 7e5fcd8f..1dcb0458 100644
--- a/tools/blastdef.h
+++ b/tools/blastdef.h
@@ -30,8 +30,23 @@ Author: Tom Madden
Contents: #defines and definitions for structures used by BLAST.
******************************************************************************/
-/* $Revision: 6.149 $
+/* $Revision: 6.154 $
* $Log: blastdef.h,v $
+* Revision 6.154 2004/01/27 20:46:06 dondosha
+* Allow values 0, 1, 2 for no_traceback megablast option
+*
+* Revision 6.153 2004/01/05 22:09:26 madden
+* Put back dashes in date
+*
+* Revision 6.152 2004/01/02 13:44:32 coulouri
+* Revert to hardcoded BLAST_RELEASE_DATE
+*
+* Revision 6.151 2003/12/29 15:51:18 coulouri
+* Bump version, use __DATE__ instead of hardcoded date
+*
+* Revision 6.150 2003/11/06 19:52:13 dondosha
+* Added error MBTemplateType, so it can be returned when wordsize/template length combination is wrong
+*
* Revision 6.149 2003/10/02 19:30:11 madden
* add field seAlign to SWResults for use in kappa.c
*
@@ -856,8 +871,8 @@ extern "C" {
#endif
/* the version of BLAST. */
-#define BLAST_ENGINE_VERSION "2.2.6"
-#define BLAST_RELEASE_DATE "Apr-09-2003"
+#define BLAST_ENGINE_VERSION "2.2.7"
+#define BLAST_RELEASE_DATE "Jan-02-2004"
/* Defines for program numbers. (Translated in BlastGetProgramNumber). */
#define blast_type_undefined 0
@@ -1104,7 +1119,7 @@ typedef struct _blast_optionsblk {
Int4 max_num_patterns; /* Maximum number of patterns to be used in PHI-Blast search */
Boolean no_check_score;
Boolean is_megablast_search; /* Is this a MegaBlast search? */
- Boolean no_traceback; /* No traceback in MegaBLAST extension */
+ Uint1 no_traceback; /* No traceback in MegaBLAST extension */
Boolean is_rps_blast; /* If this RPS Blast ? */
SeqLocPtr query_lcase_mask; /* Masking of input DNA regions */
Boolean sort_gi_list; /* Should the gi list be sorted? */
@@ -1170,7 +1185,7 @@ struct _blast_wizardoptionsblk {
CharPtr matrix;
MBDiscWordType mb_disc_type;
Int2 mb_template_length;
- Boolean no_traceback;
+ Uint1 no_traceback;
Int2 penalty;
FloatLo perc_identity;
Boolean perform_culling;
@@ -1254,11 +1269,12 @@ typedef enum {
TEMPL_11_18_OPT = 8,
TEMPL_12_18_OPT = 9,
TEMPL_11_21_OPT = 10,
- TEMPL_12_21_OPT = 11
+ TEMPL_12_21_OPT = 11,
+ TEMPL_ERROR = -1
} MBTemplateType;
typedef struct _mb_parameter_blk_ {
- Boolean no_traceback; /* No traceback in greedy extension */
+ Uint1 no_traceback; /* No traceback in greedy extension */
Boolean is_neighboring; /* Is this a neighboring task? */
Boolean full_seqids; /* Print full seqids in tabular output? */
FloatLo perc_identity; /* Identity percentage cut-off */
diff --git a/tools/blastkar.c b/tools/blastkar.c
index 831bc3c2..7e6e6e35 100644
--- a/tools/blastkar.c
+++ b/tools/blastkar.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: blastkar.c,v 6.90 2003/06/30 20:01:32 dondosha Exp $";
+static char const rcsid[] = "$Id: blastkar.c,v 6.95 2003/12/12 16:00:34 madden Exp $";
/* ===========================================================================
*
@@ -49,8 +49,24 @@ Detailed Contents:
- calculate pseuod-scores from p-values.
******************************************************************************
- * $Revision: 6.90 $
+ * $Revision: 6.95 $
* $Log: blastkar.c,v $
+ * Revision 6.95 2003/12/12 16:00:34 madden
+ * Add gap_decay_rate to BlastCutoffs, remove BlastCutoffs_simple, protection against overflow, removal of defunct _real variables (all from Mike Gertz)
+ *
+ * Revision 6.94 2003/11/30 03:36:38 camacho
+ * Fix compilation error
+ *
+ * Revision 6.93 2003/11/28 22:39:40 camacho
+ * +static keyword to BlastKarlinLtoH
+ *
+ * Revision 6.92 2003/11/28 15:16:38 camacho
+ * Combine newkar.c's contents with blastkar.c
+ *
+ * Revision 6.91 2003/11/26 19:08:10 madden
+ * simplified BlastKarlinLtoH and BlastKarlinLHtoK and provided better protection against overflow, new function NlmKarlinLambdaNR (all from Mike Gertz)
+ *
+ *
* Revision 6.90 2003/06/30 20:01:32 dondosha
* Correction in logic of finding matrices by BLASTMAT environment variable
*
@@ -2975,10 +2991,10 @@ BlastKarlinkGapBlkFill(BLAST_KarlinBlkPtr kbp, Int4 gap_open, Int4 gap_extend, I
{
if (kbp)
{
- kbp->Lambda_real = kbp->Lambda = values[index][3];
- kbp->K_real = kbp->K = values[index][4];
- kbp->logK_real = kbp->logK = log(kbp->K);
- kbp->H_real = kbp->H = values[index][5];
+ kbp->Lambda = values[index][3];
+ kbp->K = values[index][4];
+ kbp->logK = log(kbp->K);
+ kbp->H = values[index][5];
}
found_values = TRUE;
break;
@@ -3127,6 +3143,40 @@ BlastKarlinReportAllowedValues(const Char *matrix_name, ValNodePtr PNTR error_re
return 0;
}
+/*
+ BlastKarlinLtoH
+
+ Calculate H, the relative entropy of the p's and q's
+*/
+static Nlm_FloatHi LIBCALL
+BlastKarlinLtoH(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda)
+{
+ BLAST_Score score;
+ Nlm_FloatHi H, etonlam, sum, scale;
+
+ Nlm_FloatHi PNTR probs = sfp->sprob;
+ BLAST_Score low = sfp->obs_min, high = sfp->obs_max;
+
+ if (lambda < 0.) {
+ return -1.;
+ }
+ if (BlastScoreChk(low, high) != 0) return -1.;
+
+ etonlam = exp( - lambda );
+ sum = low * probs[low];
+ for( score = low + 1; score <= high; score++ ) {
+ sum = score * probs[score] + etonlam * sum;
+ }
+
+ scale = Nlm_Powi( etonlam, high );
+ if( scale > 0 ) {
+ H = lambda * sum/scale;
+ } else { /* Underflow of exp( -lambda * high ) */
+ H = lambda * exp( lambda * high + log(sum) );
+ }
+ return H;
+}
+
/*
Everything below here was (more or less) copied from the old
karlin.c and could work separately from the stuff above.
@@ -3206,41 +3256,41 @@ BlastKarlinBlkCalc(BLAST_KarlinBlkPtr kbp, BLAST_ScoreFreqPtr sfp)
/* Calculate the parameter Lambda */
- kbp->Lambda_real = kbp->Lambda = BlastKarlinLambdaNR(sfp);
+ kbp->Lambda = BlastKarlinLambdaNR(sfp);
if (kbp->Lambda < 0.)
goto ErrExit;
/* Calculate H */
- kbp->H_real = kbp->H = BlastKarlinLtoH(sfp, kbp->Lambda);
+ kbp->H = BlastKarlinLtoH(sfp, kbp->Lambda);
if (kbp->H < 0.)
goto ErrExit;
/* Calculate K and log(K) */
- kbp->K_real = kbp->K = BlastKarlinLHtoK(sfp, kbp->Lambda, kbp->H);
+ kbp->K = BlastKarlinLHtoK(sfp, kbp->Lambda, kbp->H);
if (kbp->K < 0.)
goto ErrExit;
- kbp->logK_real = kbp->logK = log(kbp->K);
+ kbp->logK = log(kbp->K);
/* Normal return */
return 0;
ErrExit:
- kbp->Lambda = kbp->H = kbp->K
- = kbp->Lambda_real = kbp->H_real = kbp->K_real = -1.;
+ kbp->Lambda = kbp->H = kbp->K = -1.;
#ifdef BLASTKAR_HUGE_VAL
- kbp->logK_real = kbp->logK = BLASTKAR_HUGE_VAL;
+ kbp->logK = BLASTKAR_HUGE_VAL;
#else
- kbp->logK_real = kbp->logK = 1.e30;
+ kbp->logK = 1.e30;
#endif
return 1;
}
#define DIMOFP0 (iter*range + 1)
#define DIMOFP0_MAX (BLAST_KARLIN_K_ITER_MAX*BLAST_SCORE_RANGE_MAX+1)
+
Nlm_FloatHi
BlastKarlinLHtoK(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda, Nlm_FloatHi H)
{
@@ -3260,7 +3310,7 @@ BlastKarlinLHtoK(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda, Nlm_FloatHi H)
int iter;
Nlm_FloatHi sumlimit;
Nlm_FloatHi PNTR p, PNTR ptrP, PNTR ptr1, PNTR ptr2, PNTR ptr1e;
- Nlm_FloatHi etolami, etolam;
+ Nlm_FloatHi x;
Boolean bi_modal_score = FALSE;
if (lambda <= 0. || H <= 0.) {
@@ -3289,7 +3339,7 @@ BlastKarlinLHtoK(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda, Nlm_FloatHi H)
range = high - low;
av = H/lambda;
- etolam = exp((Nlm_FloatHi)lambda);
+ x = exp((Nlm_FloatHi) -lambda);
if (low == -1 || high == 1) {
if (high == 1)
@@ -3298,7 +3348,7 @@ BlastKarlinLHtoK(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda, Nlm_FloatHi H)
score_avg = sfp->score_avg / d;
K = (score_avg * score_avg) / av;
}
- return K * (1.0 - 1./etolam);
+ return K * (1.0 - x);
}
sumlimit = BLAST_KARLIN_K_SUMLIMIT_DEFAULT;
@@ -3341,11 +3391,13 @@ BlastKarlinLHtoK(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda, Nlm_FloatHi H)
if (ptrP - P0 <= range)
--last;
}
- etolami = Nlm_Powi((Nlm_FloatHi)etolam, lo - 1);
- for (sum = 0., i = lo; i != 0; ++i) {
- etolami *= etolam;
- sum += *++ptrP * etolami;
- }
+ /* Horner's rule */
+ sum = *++ptrP;
+ for( i = lo + 1; i < 0; i++ ) {
+ sum = *++ptrP + sum * x;
+ }
+ sum *= x;
+
for (; i <= hi; ++i)
sum += *++ptrP;
oldsum2 = oldsum;
@@ -3366,92 +3418,21 @@ BlastKarlinLHtoK(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda, Nlm_FloatHi H)
}
}
- if (etolam > 0.05)
- {
- etolami = 1 / etolam;
- K = exp((Nlm_FloatHi)-2.0*Sum) / (av*(1.0 - etolami));
+ if (x < 1.0 / 0.05 ) {
+ K = exp((double)-2.0*Sum) / (av*(1.0 - x));
+ } else {
+ K = -exp((double)-2.0*Sum) / (av*Expm1(-(double)lambda));
}
- else
- K = -exp((Nlm_FloatHi)-2.0*Sum) / (av*Nlm_Expm1(-(Nlm_FloatHi)lambda));
CleanUp:
#ifndef BLAST_KARLIN_K_STACKP
if (P0 != NULL)
MemFree(P0);
#endif
+
return K;
}
-/*
- BlastKarlinLambdaBis
-
- Calculate Lambda using the bisection method (slow).
-*/
-Nlm_FloatHi
-BlastKarlinLambdaBis(BLAST_ScoreFreqPtr sfp)
-{
- register Nlm_FloatHi PNTR sprob;
- Nlm_FloatHi lambda, up, newval;
- BLAST_Score i, low, high, d;
- int j;
- register Nlm_FloatHi sum, x0, x1;
-
- if (sfp->score_avg >= 0.) {
- return -1.;
- }
- low = sfp->obs_min;
- high = sfp->obs_max;
- if (BlastScoreChk(low, high) != 0)
- return -1.;
-
- sprob = sfp->sprob;
-
- /* Find greatest common divisor of all scores */
- for (i = 1, d = -low; i <= high-low && d > 1; ++i) {
- if (sprob[i+low] != 0)
- d = Nlm_Gcd(d, i);
- }
-
- high = high / d;
- low = low / d;
-
- up = BLAST_KARLIN_LAMBDA0_DEFAULT;
- for (lambda=0.; ; ) {
- up *= 2;
- x0 = exp((Nlm_FloatHi)up);
- x1 = Nlm_Powi((Nlm_FloatHi)x0, low - 1);
- if (x1 > 0.) {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i*d] * (x1 *= x0);
- }
- else {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i*d] * exp(up * i);
- }
- if (sum >= 1.0)
- break;
- lambda = up;
- }
-
- for (j=0; j<BLAST_KARLIN_LAMBDA_ITER_DEFAULT; ++j) {
- newval = (lambda + up) / 2.;
- x0 = exp((Nlm_FloatHi)newval);
- x1 = Nlm_Powi((Nlm_FloatHi)x0, low - 1);
- if (x1 > 0.) {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i*d] * (x1 *= x0);
- }
- else {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i*d] * exp(newval * i);
- }
- if (sum > 1.0)
- up = newval;
- else
- lambda = newval;
- }
- return (lambda + up) / (2. * d);
-}
/******************* Fast Lambda Calculation Subroutine ************************
Version 1.0 May 16, 1991
@@ -3461,100 +3442,189 @@ BlastKarlinLambdaBis(BLAST_ScoreFreqPtr sfp)
guess (lambda0) obtained perhaps by the bisection method.
*******************************************************************************/
+/**
+ * Find positive solution to sum_{i=low}^{high} exp(i lambda) = 1.
+ *
+ * @param probs probabilities of a score occuring
+ * @param d the gcd of the possible scores. This equals 1 if the scores
+ * are not a lattice
+ * @param low the lowest possible score
+ * @param high the highest possible score
+ * @param lambda0 an initial value for lambda
+ * @param tolx the tolerance to which lambda must be computed
+ * @param itmax the maximum number of times the function may be
+ * evaluated
+ * @param maxNewton the maximum permissible number of Newton
+ * iteration. After that the computation will proceed by bisection.
+ * @param itn a pointer to an integer that will receive the actually
+ * number of iterations performed.
+ *
+ * Let phi(lambda) = sum_{i=low}^{high} exp(i lambda) - 1. Then phi(lambda)
+ * may be written
+ *
+ * phi(lamdba) = exp(u lambda) p( exp(-lambda) )
+ *
+ * where p(x) is a polynomial that has exactly two zeros, one at x = 1
+ * and one at y = exp(-lamdba). It is simpler, more numerically
+ * efficient and stable to apply Newton's method to p(x) than to
+ * phi(lambda).
+ *
+ * We define a safeguarded Newton iteration as follows. Let the
+ * initial interval of uncertainty be [0,1]. If p'(x) >= 0, we bisect
+ * the interval. Otherwise we try a Newton step. If the Newton iterate
+ * lies in the current interval of uncertainty and it reduces the
+ * value of | p(x) | by at least 10%, we accept the new
+ * point. Otherwise, we bisect the current interval of uncertainty.
+ * It is clear that this method converges to a zero of p(x). Since
+ * p'(x) > 0 in an interval containing x = 1, the method cannot
+ * converge to x = 1 and therefore converges to the only other zero,
+ * y.
+ */
+
+static Nlm_FloatHi
+NlmKarlinLambdaNR( Nlm_FloatHi PNTR probs, BLAST_Score d,
+ BLAST_Score low, BLAST_Score high,
+ Nlm_FloatHi lambda0, Nlm_FloatHi tolx,
+ int itmax, int maxNewton, int * itn )
+{
+ int k;
+ Nlm_FloatHi x0, x, a = 0, b = 1;
+ Nlm_FloatHi f = 4; /* Larger than any possible value of the poly in [0,1] */
+ int isNewton = 0; /* we haven't yet taken a Newton step. */
+
+ assert( d > 0 );
+
+ x0 = exp( -lambda0 );
+ x = ( 0 < x0 && x0 < 1 ) ? x0 : .5;
+
+ for( k = 0; k < itmax; k++ ) { /* all iteration indices k */
+ int i;
+ Nlm_FloatHi g, fold = f;
+ int wasNewton = isNewton; /* If true, then the previous step was a */
+ /* Newton step */
+ isNewton = 0; /* Assume that this step is not */
+
+ /* Horner's rule for evaluating a polynomial and its derivative */
+ g = 0;
+ f = probs[low];
+ for( i = low + d; i < 0; i += d ) {
+ g = x * g + f;
+ f = f * x + probs[i];
+ }
+ g = x * g + f;
+ f = f * x + probs[0] - 1;
+ for( i = d; i <= high; i += d ) {
+ g = x * g + f;
+ f = f * x + probs[i];
+ }
+ /* End Horner's rule */
+
+ if( f > 0 ) {
+ a = x; /* move the left endpoint */
+ } else if( f < 0 ) {
+ b = x; /* move the right endpoint */
+ } else { /* f == 0 */
+ break; /* x is an exact solution */
+ }
+ if( b - a < 2 * a * ( 1 - b ) * tolx ) {
+ /* The midpoint of the interval converged */
+ x = (a + b) / 2; break;
+ }
+
+ if( k >= maxNewton ||
+ /* If convergence of Newton's method appears to be failing; or */
+ ( wasNewton && fabs( f ) > .9 * fabs(fold) ) ||
+ /* if the previous iteration was a Newton step but didn't decrease
+ * f sufficiently; or */
+ g >= 0
+ /* if a Newton step will move us away from the desired solution */
+ ) { /* then */
+ /* bisect */
+ x = (a + b)/2;
+ } else {
+ /* try a Newton step */
+ double p = - f/g;
+ double y = x + p;
+ if( y <= a || y >= b ) { /* The proposed iterate is not in (a,b) */
+ x = (a + b)/2;
+ } else { /* The proposed iterate is in (a,b). Accept it. */
+ isNewton = 1;
+ x = y;
+ if( fabs( p ) < tolx * x * (1-x) ) break; /* Converged */
+ } /* else the proposed iterate is in (a,b) */
+ } /* else try a Newton step. */
+ } /* end for all iteration indices k */
+ *itn = k;
+ return -log(x)/d;
+}
+
+
Nlm_FloatHi
BlastKarlinLambdaNR(BLAST_ScoreFreqPtr sfp)
{
BLAST_Score low; /* Lowest score (must be negative) */
BLAST_Score high; /* Highest score (must be positive) */
- int j;
+ int itn;
BLAST_Score i, d;
Nlm_FloatHi PNTR sprob;
- Nlm_FloatHi lambda0, sum, slope, temp, x0, x1, amt;
+ Nlm_FloatHi returnValue;
low = sfp->obs_min;
high = sfp->obs_max;
if (sfp->score_avg >= 0.) { /* Expected score must be negative */
return -1.0;
}
- if (BlastScoreChk(low, high) != 0)
- return -1.;
-
- lambda0 = BLAST_KARLIN_LAMBDA0_DEFAULT;
-
+ if (BlastScoreChk(low, high) != 0) return -1.;
+
sprob = sfp->sprob;
- /* Find greatest common divisor of all scores */
- for (i = 1, d = -low; i <= high-low && d > 1; ++i) {
- if (sprob[i+low] != 0)
- d = Nlm_Gcd(d, i);
- }
-
- high = high / d;
- low = low / d;
- /* Calculate lambda */
-
- for (j=0; j<20; ++j) { /* limit of 20 should never be close-approached */
- sum = -1.0;
- slope = 0.0;
- if (lambda0 < 0.01)
- break;
- x0 = exp((Nlm_FloatHi)lambda0);
- x1 = Nlm_Powi((Nlm_FloatHi)x0, low - 1);
- if (x1 == 0.)
- break;
- for (i=low; i<=high; i++) {
- sum += (temp = sprob[i*d] * (x1 *= x0));
- slope += temp * i;
- }
- lambda0 -= (amt = sum/slope);
- if (ABS(amt/lambda0) < BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT) {
- /*
- Does it appear that we may be on the verge of converging
- to the ever-present, zero-valued solution?
- */
- if (lambda0 > BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT)
- return lambda0 / d;
- break;
+ /* Find greatest common divisor of all scores */
+ for (i = 1, d = -low; i <= high-low && d > 1; ++i) {
+ if (sprob[i+low] != 0) {
+ d = Nlm_Gcd(d, i);
}
}
- return BlastKarlinLambdaBis(sfp);
-}
+ returnValue =
+ NlmKarlinLambdaNR( sprob, d, low, high,
+ BLAST_KARLIN_LAMBDA0_DEFAULT,
+ BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT,
+ 20, 20 + BLAST_KARLIN_LAMBDA_ITER_DEFAULT, &itn );
-/*
- BlastKarlinLtoH
- Calculate H, the relative entropy of the p's and q's
-*/
+ return returnValue;
+}
+
Nlm_FloatHi LIBCALL
-BlastKarlinLtoH(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda)
+impalaKarlinLambdaNR(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi initialLambda)
{
- BLAST_Score score;
- Nlm_FloatHi av, etolam, etolami;
+ Nlm_FloatHi returnValue;
+ int itn;
+ Nlm_FloatHi PNTR sprob = sfp->sprob;
- if (lambda < 0.) {
- return -1.;
- }
- if (BlastScoreChk(sfp->obs_min, sfp->obs_max) != 0)
- return -1.;
-
- etolam = exp((Nlm_FloatHi)lambda);
- etolami = Nlm_Powi((Nlm_FloatHi)etolam, sfp->obs_min - 1);
- if (etolami > 0.)
- {
- av = 0.0;
- for (score=sfp->obs_min; score<=sfp->obs_max; score++)
- av += sfp->sprob[score] * score * (etolami *= etolam);
+ if (sfp->score_avg >= 0.) { /* Expected score must be negative */
+ return -1.0;
}
- else
{
- av = 0.0;
- for (score=sfp->obs_min; score<=sfp->obs_max; score++)
- av += sfp->sprob[score] * score * exp(lambda * score);
+ Boolean foundPositive = FALSE;
+ BLAST_Score j;
+ for(j = 1; j <=sfp->obs_max; j++) {
+ if (sprob[j] > 0.0) {
+ foundPositive = TRUE;
+ break;
+ }
+ }
+ if (!foundPositive) return(-1);
}
- return lambda * av;
+ returnValue =
+ NlmKarlinLambdaNR( sprob, 1, sfp->obs_min, sfp->obs_max,
+ initialLambda, BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT,
+ 20, 20 + BLAST_KARLIN_LAMBDA_ITER_DEFAULT, &itn );
+
+ return returnValue;
}
+
static Nlm_FloatHi
BlastGapDecayInverse(Nlm_FloatHi pvalue, unsigned nsegs, Nlm_FloatHi decayrate)
{
@@ -3584,19 +3654,9 @@ Int2 LIBCALL
BlastCutoffs(BLAST_ScorePtr S, /* cutoff score */
Nlm_FloatHi PNTR E, /* expected no. of HSPs scoring at or above S */
BLAST_KarlinBlkPtr kbp,
- Nlm_FloatHi qlen, /* length of query sequence */
- Nlm_FloatHi dblen, /* length of database or database sequence */
- Nlm_Boolean dodecay) /* TRUE ==> use gapdecay feature */
-{
- return BlastCutoffs_simple(S, E, kbp, qlen*dblen, dodecay);
-}
-
-Int2 LIBCALL
-BlastCutoffs_simple(BLAST_ScorePtr S, /* cutoff score */
- Nlm_FloatHi PNTR E, /* expected no. of HSPs scoring at or above S */
- BLAST_KarlinBlkPtr kbp,
Nlm_FloatHi searchsp, /* size of search space. */
- Nlm_Boolean dodecay) /* TRUE ==> use gapdecay feature */
+ Nlm_Boolean dodecay, /* TRUE ==> use gapdecay feature */
+ Nlm_FloatHi gap_decay_rate )
{
BLAST_Score s = *S, es;
Nlm_FloatHi e = *E, esave;
@@ -3614,7 +3674,7 @@ BlastCutoffs_simple(BLAST_ScorePtr S, /* cutoff score */
if (e > 0.)
{
if (dodecay)
- e = BlastGapDecayInverse(e, 1, 0.5);
+ e = BlastGapDecayInverse(e, 1, gap_decay_rate);
es = BlastKarlinEtoS_simple(e, kbp, searchsp);
}
/*
@@ -3633,7 +3693,7 @@ BlastCutoffs_simple(BLAST_ScorePtr S, /* cutoff score */
{
e = BlastKarlinStoE_simple(s, kbp, searchsp);
if (dodecay)
- e = BlastGapDecay(e, 1, 0.5);
+ e = BlastGapDecay(e, 1, gap_decay_rate);
*E = e;
}
@@ -4022,7 +4082,7 @@ BlastSmallGapSumE(BLAST_KarlinBlkPtr kbp, Int4 gap, Nlm_FloatHi gap_prob, Nlm_Fl
sum_e = sum_e/gap_prob;
}
- return sum_e;
+ return (sum_e <= INT4_MAX) ? sum_e : INT4_MAX;
}
/*
@@ -4057,7 +4117,7 @@ BlastUnevenGapSumE(BLAST_KarlinBlkPtr kbp, Int4 p_gap, Int4 n_gap, Nlm_FloatHi g
sum_e = sum_e/gap_prob;
}
- return sum_e;
+ return (sum_e <= INT4_MAX) ? sum_e : INT4_MAX;
}
/*
@@ -4094,7 +4154,7 @@ BlastLargeGapSumE(BLAST_KarlinBlkPtr kbp, Nlm_FloatHi gap_prob, Nlm_FloatHi gap_
sum_e = sum_e/(1.0 - gap_prob);
}
- return sum_e;
+ return (sum_e <= INT4_MAX) ? sum_e : INT4_MAX;
}
/********************************************************************
diff --git a/tools/blastkar.h b/tools/blastkar.h
index 7d289851..41d56aa3 100644
--- a/tools/blastkar.h
+++ b/tools/blastkar.h
@@ -32,8 +32,17 @@ Contents: definitions and prototypes used by blastkar.c to calculate BLAST
******************************************************************************/
-/* $Revision: 6.31 $
+/* $Revision: 6.34 $
* $Log: blastkar.h,v $
+* Revision 6.34 2003/12/12 16:00:46 madden
+* Add gap_decay_rate to BlastCutoffs, remove BlastCutoffs_simple, removal of defunct _real variables (all from Mike Gertz)
+*
+* Revision 6.33 2003/11/28 22:39:41 camacho
+* +static keyword to BlastKarlinLtoH
+*
+* Revision 6.32 2003/11/26 19:09:09 madden
+* Remove ref to BlastKarlinLambdaBis (no longer needed per Mike Gertz)
+*
* Revision 6.31 2003/02/27 19:07:56 madden
* Add functions PrintMatrixMessage and PrintAllowedValuesMessage
*
@@ -308,9 +317,6 @@ typedef struct {
Nlm_FloatHi Lambda; /* Lambda value used in statistics */
Nlm_FloatHi K, logK; /* K value used in statistics */
Nlm_FloatHi H; /* H value used in statistics */
- /* "real" values are ones actually found, may be replaced by above */
- Nlm_FloatHi Lambda_real, K_real, logK_real, H_real;
- Int4 q_frame, s_frame; /* reading frame for query and subject.*/
Nlm_FloatHi paramC; /* for use in seed. */
} BLAST_KarlinBlk, PNTR BLAST_KarlinBlkPtr;
@@ -499,12 +505,8 @@ Int2 LIBCALL BlastKarlinReportAllowedValues(const Char *matrix_name, ValNodePtr
Nlm_FloatHi BlastKarlinLHtoK PROTO((BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda, Nlm_FloatHi H));
-Nlm_FloatHi BlastKarlinLambdaBis PROTO((BLAST_ScoreFreqPtr sfp));
-
Nlm_FloatHi BlastKarlinLambdaNR PROTO((BLAST_ScoreFreqPtr sfp));
-Nlm_FloatHi LIBCALL BlastKarlinLtoH PROTO((BLAST_ScoreFreqPtr sfp, Nlm_FloatHi lambda));
-
BLAST_Score LIBCALL BlastKarlinEtoS PROTO((Nlm_FloatHi E, BLAST_KarlinBlkPtr kbp, Nlm_FloatHi qlen, Nlm_FloatHi dblen));
BLAST_Score LIBCALL BlastKarlinEtoS_simple PROTO((Nlm_FloatHi E, BLAST_KarlinBlkPtr kbp, Nlm_FloatHi searchsp));
@@ -521,10 +523,9 @@ Nlm_FloatHi LIBCALL BlastKarlinStoE PROTO((BLAST_Score S, BLAST_KarlinBlkPtr kbp
Nlm_FloatHi LIBCALL BlastKarlinStoE_simple PROTO((BLAST_Score S, BLAST_KarlinBlkPtr kbp, Nlm_FloatHi searchsp));
-Int2 LIBCALL BlastCutoffs PROTO((BLAST_ScorePtr S, Nlm_FloatHi PNTR E, BLAST_KarlinBlkPtr kbp, Nlm_FloatHi qlen, Nlm_FloatHi dblen, Nlm_Boolean dodecay));
-
+Int2 LIBCALL BlastCutoffs PROTO((BLAST_ScorePtr S, Nlm_FloatHi PNTR E, BLAST_KarlinBlkPtr kbp, Nlm_FloatHi search_sp, Nlm_Boolean dodecay,
+ Nlm_FloatHi gap_decay_rate));
-Int2 LIBCALL BlastCutoffs_simple PROTO((BLAST_ScorePtr S, Nlm_FloatHi PNTR E, BLAST_KarlinBlkPtr kbp, Nlm_FloatHi search_sp, Nlm_Boolean dodecay));
Nlm_FloatHi LIBCALL BlastKarlinStoLen PROTO((BLAST_KarlinBlkPtr kbp, BLAST_Score S));
/* SumP function. Called by BlastSmallGapSumE and BlastLargeGapSumE. */
diff --git a/tools/blastool.c b/tools/blastool.c
index e1ad48da..3dc73492 100644
--- a/tools/blastool.c
+++ b/tools/blastool.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: blastool.c,v 6.253 2003/09/12 16:02:06 dondosha Exp $";
+static char const rcsid[] = "$Id: blastool.c,v 6.258 2003/12/30 15:14:40 camacho Exp $";
/* ===========================================================================
*
@@ -34,8 +34,25 @@ Contents: Utilities for BLAST
******************************************************************************/
/*
-* $Revision: 6.253 $
+* $Revision: 6.258 $
* $Log: blastool.c,v $
+* Revision 6.258 2003/12/30 15:14:40 camacho
+* Fix to MergeDbGiListsWithOIDLists:
+* When searching gi lists for matches in rdfp linked list, isolate each
+* element of the linked list first.
+*
+* Revision 6.257 2003/12/23 23:28:27 dondosha
+* Use number of identities from the seqalign to calculate percent identity in tabular output
+*
+* Revision 6.256 2003/12/12 16:01:23 madden
+* Change to signature of BlastCutoffs, remove BlastCutoffs_simple
+*
+* Revision 6.255 2003/11/10 16:59:42 dondosha
+* Print the seqid in AcknowledgeBlastQuery for any non-local id
+*
+* Revision 6.254 2003/10/29 17:46:59 dondosha
+* Allow 2-stage greedy extension in megablast
+*
* Revision 6.253 2003/09/12 16:02:06 dondosha
* If gap open is non-zero for megablast, require gap extension option to be non-zero too
*
@@ -1076,30 +1093,50 @@ FormatBlastParameters(BlastSearchBlkPtr search)
cutoff = 0;
}
if (search->last_context <= 1) {
- evalue = pbp->cutoff_e;
- if (StringCmp(search->prog_name, "blastn") == 0 ||
- search->pbp->gapped_calculation == FALSE) {
- /* AM: Changed to support query concatenation. */
- if( !search->mult_queries )
- BlastCutoffs(&cutoff, &evalue, search->sbp->kbp[search->first_context], (Nlm_FloatHi) search->context[search->first_context].query->effective_length, (Nlm_FloatHi) search->dblen_eff, FALSE);
- else
- { BlastCutoffs(&cutoff, &evalue, search->sbp->kbp[search->first_context], (Nlm_FloatHi) search->mult_queries->MinLenEff, (Nlm_FloatHi) search->dblen_eff, FALSE); }
-
- sprintf(buffer, "S2: %ld (%4.1f bits)", (long) cutoff, (((cutoff)*(search->sbp->kbp[search->first_context]->Lambda))-(search->sbp->kbp[search->first_context]->logK))/NCBIMATH_LN2);
- } else {
- if( !search->mult_queries )
- BlastCutoffs(&cutoff, &evalue, search->sbp->kbp_gap[search->first_context], (Nlm_FloatHi) search->context[search->first_context].query->effective_length, (Nlm_FloatHi) search->dblen_eff, FALSE);
- else
- BlastCutoffs( &cutoff, &evalue,
- search->sbp->kbp_gap[search->first_context],
- (Nlm_FloatHi)search->mult_queries->MinLenEff,
- (Nlm_FloatHi)search->dblen_eff, FALSE );
-
- sprintf(buffer, "S2: %ld (%4.1f bits)", (long) cutoff, (((cutoff)*(search->sbp->kbp_gap[search->first_context]->Lambda))-(search->sbp->kbp_gap[search->first_context]->logK))/NCBIMATH_LN2);
- }
- add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
+ evalue = pbp->cutoff_e;
+ if (StringCmp(search->prog_name, "blastn") == 0 ||
+ search->pbp->gapped_calculation == FALSE) {
+ /* AM: Changed to support query concatenation. */
+ if( !search->mult_queries ) {
+ Nlm_FloatHi search_sp =
+ search->context[search->first_context]
+ .query->effective_length *
+ (Nlm_FloatHi) search->dblen_eff;
+ BlastCutoffs(&cutoff, &evalue,
+ search->sbp->kbp[search->first_context],
+ search_sp, FALSE, 0.0 );
+ } else {
+ Nlm_FloatHi search_sp =
+ search->mult_queries->MinLenEff *
+ (Nlm_FloatHi) search->dblen_eff;
+ BlastCutoffs(&cutoff, &evalue,
+ search->sbp->kbp[search->first_context],
+ search_sp, FALSE, 0.0 );
+ }
+
+ sprintf(buffer, "S2: %ld (%4.1f bits)", (long) cutoff, (((cutoff)*(search->sbp->kbp[search->first_context]->Lambda))-(search->sbp->kbp[search->first_context]->logK))/NCBIMATH_LN2);
+ } else {
+ if( !search->mult_queries ) {
+ Nlm_FloatHi search_sp =
+ search->context[search->first_context]
+ .query->effective_length *
+ (Nlm_FloatHi) search->dblen_eff;
+ BlastCutoffs(&cutoff, &evalue,
+ search->sbp->kbp_gap[search->first_context],
+ search_sp, FALSE, 0.0 );
+ } else {
+ Nlm_FloatHi search_sp =
+ search->mult_queries->MinLenEff *
+ (Nlm_FloatHi)search->dblen_eff;
+ BlastCutoffs( &cutoff, &evalue,
+ search->sbp->kbp_gap[search->first_context],
+ search_sp, FALSE, 0.0 );
+ }
+ sprintf(buffer, "S2: %ld (%4.1f bits)", (long) cutoff, (((cutoff)*(search->sbp->kbp_gap[search->first_context]->Lambda))-(search->sbp->kbp_gap[search->first_context]->logK))/NCBIMATH_LN2);
+ }
+ add_string_to_buffer(buffer, &ret_buffer, &ret_buffer_length);
}
- return ret_buffer;
+ return ret_buffer;
}
/*
@@ -1430,7 +1467,7 @@ AcknowledgeBlastQuery(BioseqPtr bsp, Int4 line_length, FILE *outfp, Boolean beli
ff_AddString("<b>Query=</b> ");
else
ff_AddString("Query= ");
- if (bsp->id && believe_query)
+ if (bsp->id && (bsp->id->choice != SEQID_LOCAL || believe_query))
{
SeqIdWrite(bsp->id, buffer, PRINTID_FASTA_LONG, BUFFER_LENGTH);
if (StringNCmp(buffer, "lcl|", 4) == 0)
@@ -2622,7 +2659,11 @@ static
void MergeDbGiListsWithOIDLists(ReadDBFILEPtr rdfp_chain, ValNodePtr *err_ret,
BlastGiListPtr *bglpp)
{
- ReadDBFILEPtr rdfp = NULL, rdfp_tmp = NULL;
+ ReadDBFILEPtr rdfp = NULL; /* holds an individual element of the
+ rdfp_chain linked list */
+ ReadDBFILEPtr rdfp_tmp = NULL; /* holds the rest of the rdfp linked list
+ when searching for gis in a rdfp element
+ */
BlastDoubleInt4Ptr list=NULL, global_list = NULL;
BlastGiListPtr tmp_list = NULL;
Int4 i, index, ngis = 0, total_num_gis = 0, start;
@@ -2646,6 +2687,10 @@ void MergeDbGiListsWithOIDLists(ReadDBFILEPtr rdfp_chain, ValNodePtr *err_ret,
ErrPostEx(SEV_FATAL, 1, 0, "Out of memory");
return;
}
+
+ /* Isolate the current rdfp element */
+ rdfp_tmp = rdfp->next;
+ rdfp->next = NULL;
/* See which gis in rdfp->gilist belong to this rdfp */
for (index=0, i=0; i < ngis; i++) {
@@ -2658,6 +2703,9 @@ void MergeDbGiListsWithOIDLists(ReadDBFILEPtr rdfp_chain, ValNodePtr *err_ret,
}
}
+ /* Restore the rdfp_chain linked list */
+ rdfp->next = rdfp_tmp;
+
/* After this point we don't really need the rdfp->gilist */
rdfp->gilist = Int4ListFree(rdfp->gilist);
@@ -4917,6 +4965,17 @@ void BlastPrintTabulatedResultsEx(SeqAlignPtr seqalign, BioseqPtr query_bsp,
q_shift, s_shift, fp, num_formatted, print_query_info);
}
+static Int4 FindNumIdentInScore(ScorePtr score)
+{
+ Int4 num_ident = 0;
+ for ( ; score; score = score->next) {
+ if (!strcmp(score->id->str, "num_ident")) {
+ num_ident = score->value.intvalue;
+ }
+ }
+ return num_ident;
+}
+
void BlastPrintTabularResults(SeqAlignPtr seqalign, BioseqPtr query_bsp,
SeqLocPtr query_slp, Int4 num_alignments, CharPtr blast_program,
Boolean is_ungapped, Boolean is_ooframe, Boolean believe_query,
@@ -5056,6 +5115,8 @@ void BlastPrintTabularResults(SeqAlignPtr seqalign, BioseqPtr query_bsp,
} else
num_gap_opens++;
}
+ if ((num_ident = FindNumIdentInScore(sap->score)) > 0)
+ perc_ident = num_ident;
perc_ident = perc_ident / align_length * 100;
if (dsp->strands[0] != dsp->strands[1]) {
@@ -6433,7 +6494,7 @@ BLASTPostSearchLogic(BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options,
seqalign = SumBlastGetGappedAlignmentTraceback(
search, index, FALSE, FALSE,
sequence+1, length);
- } else if (!search->pbp->mb_params->no_traceback) {
+ } else {
/* Mega BLAST with non-greedy extension */
SumBlastGetGappedAlignmentEx(search, index, FALSE, FALSE,
sequence+1, length, TRUE,
diff --git a/tools/blastpri.h b/tools/blastpri.h
index db75abc8..421a5d0f 100644
--- a/tools/blastpri.h
+++ b/tools/blastpri.h
@@ -32,8 +32,14 @@ Contents: prototypes for "private" BLAST functions, these should not be called
******************************************************************************/
-/* $Revision: 6.109 $
+/* $Revision: 6.111 $
* $Log: blastpri.h,v $
+* Revision 6.111 2004/01/16 23:43:43 dondosha
+* No more need for special argument for partial search: it is set in options
+*
+* Revision 6.110 2004/01/06 22:36:24 dondosha
+* Added BLAST_HSPFree function that frees the edit block and the HSP
+*
* Revision 6.109 2003/08/20 22:12:56 dondosha
* Added BlastPrintTabularResults with an extra boolean parameter for OOF alignments
*
@@ -832,7 +838,6 @@ CharPtr FormatBlastParameters PROTO((BlastSearchBlkPtr search));
SeqAlignPtr LIBCALL BioseqBlastEngineCore PROTO((BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options, Int4Ptr *pos_matrix));
-SeqAlignPtr LIBCALL BioseqBlastEngineCoreEx PROTO((BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options, Int4Ptr *pos_matrix, Boolean partial));
Uint1Ptr GetSequenceWithDenseSeg PROTO((DenseSegPtr dsp, Boolean query, Int4Ptr start, Int4Ptr length));
@@ -1045,6 +1050,7 @@ SeqAlignPtr BlastClusterHitsFromSeqAlign PROTO((SeqAlignPtr seqalign, CharPtr pr
SeqAlignPtr RedoAlignmentCore PROTO((BlastSearchBlkPtr search,
BLAST_OptionsBlkPtr options, Int4 hitlist_count, Boolean adjustParameters,
Boolean SmithWaterman));
+BLAST_HSPPtr BLAST_HSPFree PROTO((BLAST_HSPPtr hsp));
void BLASTResultFreeHsp PROTO((BLASTResultHitlistPtr result));
void BLASTPostSearchLogic PROTO((BlastSearchBlkPtr search, BLAST_OptionsBlkPtr
options, SeqAlignPtr PNTR seqalignp,
diff --git a/tools/blastutl.c b/tools/blastutl.c
index 12a77967..1efd5cef 100644
--- a/tools/blastutl.c
+++ b/tools/blastutl.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: blastutl.c,v 6.417 2003/08/20 22:14:08 dondosha Exp $";
+static char const rcsid[] = "$Id: blastutl.c,v 6.429 2004/01/30 16:54:45 dondosha Exp $";
/* ===========================================================================
*
@@ -32,12 +32,48 @@ Author: Tom Madden
Contents: Utilities for BLAST
-$Revision: 6.417 $
+$Revision: 6.429 $
******************************************************************************/
/*
*
* $Log: blastutl.c,v $
+* Revision 6.429 2004/01/30 16:54:45 dondosha
+* Check if HSP needs to be deleted after reevaluation with ambiguities, after greedy traceback
+*
+* Revision 6.428 2004/01/28 16:54:03 dondosha
+* Restored the code that shifts subject coordinates for blastn traceback with long subject sequences
+*
+* Revision 6.427 2004/01/25 05:06:21 dondosha
+* Translate only relevant parts of long subject sequences for tblastn traceback
+*
+* Revision 6.426 2004/01/16 23:43:44 dondosha
+* No more need for special argument for partial search: it is set in options
+*
+* Revision 6.425 2004/01/14 17:01:06 dondosha
+* Gapped alignment is position based only if posMatrix exists
+*
+* Revision 6.424 2004/01/09 18:13:24 dondosha
+* In [Get,Check]StartForGappedAlignment: if posMatrix not available, use square matrix for calculations
+*
+* Revision 6.423 2004/01/06 22:37:40 dondosha
+* Use BLAST_HSPfree function; in particular fixes a bug with wrong memory being freed
+*
+* Revision 6.422 2003/12/11 23:46:28 dondosha
+* Correction in setting hit ranges after repeats filtering
+*
+* Revision 6.421 2003/12/10 17:05:28 dondosha
+* Added function ReevaluateScoreWithAmbiguities to reevaluate score for one HSP; use it after greedy traceback
+*
+* Revision 6.420 2003/11/24 22:06:41 madden
+* Tblastn optimization, only fetch part of sequence needed
+*
+* Revision 6.419 2003/10/30 18:37:19 dondosha
+* Fix for megablast with non-greedy traceback
+*
+* Revision 6.418 2003/10/29 17:46:59 dondosha
+* Allow 2-stage greedy extension in megablast
+*
* Revision 6.417 2003/08/20 22:14:08 dondosha
* Little correction in call to OOFBlastHSPGetNumIdentical
*
@@ -2490,7 +2526,7 @@ BlastTwoSequencesCoreEx (BlastSearchBlkPtr search, BioseqPtr subject_bsp, Uint1P
}
if (search->pbp->mb_params) {
search->subject->sequence = subject_seq;
- MegaBlastReevaluateWithAmbiguities(search, 0);
+ MegaBlastReevaluateWithAmbiguities(search);
}
status = BlastReapHitlistByEvalue(search);
@@ -4210,7 +4246,7 @@ BlastGetSubjectIdEx(BlastSearchBlkPtr search, Int4 hit_number, Boolean ordinal_n
Uint4 header;
BLASTResultsStructPtr result_struct;
- if (search->pbp->mb_params && search->pbp->mb_params->use_dyn_prog)
+ if (search->pbp->mb_params)
result_struct = search->mb_result_struct[query_number];
else
result_struct = search->result_struct;
@@ -4353,13 +4389,6 @@ SeqAlignPtr LIBCALL
BioseqBlastEngineCore(BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options,
Int4Ptr *pos_matrix)
{
- return BioseqBlastEngineCoreEx(search, options, pos_matrix, FALSE);
-}
-
-SeqAlignPtr LIBCALL
-BioseqBlastEngineCoreEx(BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options,
- Int4Ptr *pos_matrix, Boolean partial)
-{
BLASTResultHspPtr hsp, hsp1;
BlastResultHspWithIdPtr PNTR hspp;
BLASTResultsStructPtr result_struct;
@@ -4565,7 +4594,7 @@ BioseqBlastEngineCoreEx(BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options,
}
#endif /* Clustering hits */
- if (partial) {
+ if (options->no_traceback) {
BlastStopAwakeThread(search->thr_info);
return NULL;
}
@@ -6388,8 +6417,8 @@ GetTranslation(Uint1Ptr query_seq, Int4 nt_length, Int2 frame, Int4Ptr length, C
if (IS_residue(new_residue))
{
prot_seq[index_prot] = new_residue;
- index_prot++;
}
+ index_prot++;
}
prot_seq[index_prot] = NULLB;
*length = index_prot-1;
@@ -7544,6 +7573,13 @@ FilterWithSeg (Uint1Ptr sequence, Int4 length, Uint1 alphabet)
#endif
}
+
+BLAST_HSPPtr BLAST_HSPFree(BLAST_HSPPtr hsp)
+{
+ hsp->gap_info = GapXEditBlockDelete(hsp->gap_info);
+ return (BLAST_HSPPtr) MemFree(hsp);
+}
+
/*
Frees memory used for HSP's on the ResultHitlist.
Should be called as the SeqAlignPtr for a hitlist
@@ -7784,6 +7820,7 @@ Int4 GetStartForGappedAlignment (BlastSearchBlkPtr search, BLAST_HSPPtr hsp, Uin
{
Int4 index1, max_offset, score, max_score, hsp_end;
Uint1Ptr query_var, subject_var;
+ Boolean positionBased = (search->positionBased && search->sbp->posMatrix);
if (hsp->query.length <= HSP_MAX_WINDOW) {
max_offset = hsp->query.offset + hsp->query.length/2;
@@ -7794,19 +7831,23 @@ Int4 GetStartForGappedAlignment (BlastSearchBlkPtr search, BLAST_HSPPtr hsp, Uin
query_var = query + hsp->query.offset;
subject_var = subject + hsp->subject.offset;
score=0;
- for (index1=hsp->query.offset; index1<hsp_end; index1++) {
- if (!(search->positionBased))
- score += matrix[*query_var][*subject_var];
- else
- score += search->sbp->posMatrix[index1][*subject_var];
- query_var++; subject_var++;
+ if (!positionBased) {
+ for (index1=hsp->query.offset; index1<hsp_end; index1++) {
+ score += matrix[*query_var][*subject_var];
+ query_var++; subject_var++;
+ }
+ } else {
+ for (index1=hsp->query.offset; index1<hsp_end; index1++) {
+ score += search->sbp->posMatrix[index1][*subject_var];
+ query_var++; subject_var++;
+ }
}
max_score = score;
max_offset = hsp_end - 1;
hsp_end = hsp->query.end -
MAX(0, hsp->query.length - hsp->subject.length);
for (index1=hsp->query.offset + HSP_MAX_WINDOW; index1<hsp_end; index1++) {
- if (!(search->positionBased)) {
+ if (!positionBased) {
score -= matrix[*(query_var-HSP_MAX_WINDOW)][*(subject_var-HSP_MAX_WINDOW)];
score += matrix[*query_var][*subject_var];
} else {
@@ -7838,7 +7879,8 @@ CheckStartForGappedAlignment (BlastSearchBlkPtr search, BLAST_HSPPtr hsp, Uint1P
{
Int4 index1, score, start, end, width;
Uint1Ptr query_var, subject_var;
-
+ Boolean positionBased =
+ (search->positionBased && search->sbp->posMatrix);
width = MIN((hsp->query.gapped_start-hsp->query.offset), HSP_MAX_WINDOW/2);
start = hsp->query.gapped_start - width;
@@ -7851,7 +7893,7 @@ CheckStartForGappedAlignment (BlastSearchBlkPtr search, BLAST_HSPPtr hsp, Uint1P
score=0;
for (index1=start; index1<end; index1++)
{
- if (!(search->positionBased))
+ if (!positionBased)
score += matrix[*query_var][*subject_var];
else
score += search->sbp->posMatrix[index1][*subject_var];
@@ -7883,6 +7925,9 @@ GetDbSubjRatio(BlastSearchBlkPtr search, Int4 subject_length)
return db_subj_ratio;
}
+/* The following value should be divisible by 3, to make sure that frames stay
+ the same when translations are restricted to partial sequence. */
+#define SUBJECT_ADJUSTMENT 2100
SeqAlignPtr LIBCALL
BlastGetGapAlgnTbckWithReaddb (BlastSearchBlkPtr search, Int4 hit_number, Boolean ordinal_number)
@@ -7891,6 +7936,9 @@ BlastGetGapAlgnTbckWithReaddb (BlastSearchBlkPtr search, Int4 hit_number, Boolea
BioseqPtr subject_bsp;
Boolean subject_allocated = FALSE;
Int4 index1, subject_length, rev_subject_length;
+ Int4 subject_start, subject_end;
+ Int4 hsp_count;
+ BLASTResultHspPtr hsp_array;
SeqAlignPtr seqalign;
SeqPortPtr spp;
Uint1Ptr subject, rev_subject;
@@ -7904,9 +7952,29 @@ BlastGetGapAlgnTbckWithReaddb (BlastSearchBlkPtr search, Int4 hit_number, Boolea
spp = SeqPortNew(subject_bsp, 0, -1, Seq_strand_plus, Seq_code_ncbi4na);
/* make one longer to "protect" ALIGN. */
subject = MemNew((1+subject_bsp->length)*sizeof(Uint1));
- for (index1=0; index1<subject_bsp->length; index1++)
+ hsp_array = result_hitlist->hsp_array;
+ hsp_count = result_hitlist->hspcnt;
+ for (index1=0; index1<hsp_count; index1++)
{
- subject[index1] = SeqPortGetResidue(spp);
+ if (hsp_array[index1].subject_frame > 0)
+ { /* Get subsequence corresponding to this hsp. */
+ Int4 offset;
+
+ subject_start = 3*hsp_array[index1].subject_offset;
+ subject_end = subject_start + 3*hsp_array[index1].subject_length;
+
+ /* add SUBJECT_ADJUSTMENT bases to either end. */
+ subject_start = MAX(subject_start - SUBJECT_ADJUSTMENT, 0);
+ subject_end = MIN(subject_end + SUBJECT_ADJUSTMENT, subject_bsp->length);
+
+ SeqPortSeek(spp, subject_start, SEEK_SET);
+
+ for (offset=subject_start; offset<subject_end; offset++)
+ subject[offset] = SeqPortGetResidue(spp);
+
+ if (subject_start == 0 && subject_end == subject_bsp->length)
+ break; /* entire sequence has been fetched. */
+ }
}
/* Gap character in last space. */
subject[subject_bsp->length] = NULLB;
@@ -7916,9 +7984,29 @@ BlastGetGapAlgnTbckWithReaddb (BlastSearchBlkPtr search, Int4 hit_number, Boolea
spp = SeqPortNew(subject_bsp, 0, -1, Seq_strand_minus, Seq_code_ncbi4na);
/* make one longer to "protect" ALIGN. */
rev_subject = MemNew((1+subject_bsp->length)*sizeof(Uint1));
- for (index1=0; index1<subject_bsp->length; index1++)
+ hsp_array = result_hitlist->hsp_array;
+ hsp_count = result_hitlist->hspcnt;
+ for (index1=0; index1<hsp_count; index1++)
{
- rev_subject[index1] = SeqPortGetResidue(spp);
+ if (hsp_array[index1].subject_frame < 0)
+ { /* Get subsequence corresponding to this hsp. */
+ Int4 offset;
+
+ subject_start = 3*hsp_array[index1].subject_offset;
+ subject_end = subject_start + 3*hsp_array[index1].subject_length;
+
+ /* add SUBJECT_ADJUSTMENT bases to either end. */
+ subject_start = MAX(subject_start - SUBJECT_ADJUSTMENT, 0);
+ subject_end = MIN(subject_end + SUBJECT_ADJUSTMENT, subject_bsp->length);
+
+ SeqPortSeek(spp, subject_start, SEEK_SET);
+
+ for (offset=subject_start; offset<subject_end; offset++)
+ rev_subject[offset] = SeqPortGetResidue(spp);
+
+ if (subject_start == 0 && subject_end == subject_bsp->length)
+ break; /* entire sequence has been fetched. */
+ }
}
/* Gap character in last space. */
rev_subject[subject_bsp->length] = NULLB;
@@ -8598,11 +8686,11 @@ BlastHitRangeLoad (BlastSearchBlkPtr search, BLAST_HSPPtr *hsp_array, Int4 hspcn
if (hsp->query.frame >= 0)
{
tmp->gi = hsp->query.offset;
- tmp->ordinal_id = hsp->query.end;
+ tmp->ordinal_id = hsp->query.end - 1;
}
else
{
- tmp->gi = query_length - hsp->query.end - 1;
+ tmp->gi = query_length - hsp->query.end;
tmp->ordinal_id = query_length - hsp->query.offset - 1;
}
tmp++;
@@ -8677,9 +8765,8 @@ static void BLASTCheckHSPInclusion(BLAST_HSPPtr *hsp_array, Int4 hspcnt,
mean, that current HSP should be removed. */
if(hsp_array[index] != NULL) {
- hsp_array[index]->gap_info = GapXEditBlockDelete(hsp_array[index]->gap_info);
- hsp_array[index] = MemFree(hsp_array[index]);
- break;
+ hsp_array[index] = BLAST_HSPFree(hsp_array[index]);
+ break;
}
}
}
@@ -8689,6 +8776,7 @@ static void BLASTCheckHSPInclusion(BLAST_HSPPtr *hsp_array, Int4 hspcnt,
return;
}
+
/*
Take a BLAST_HSPPtr (array of HSP's) and get a traceback for them.
*/
@@ -8717,7 +8805,9 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
Int4 max_start = MAX_DBSEQ_LEN / 2, start_shift;
Int4 align_length;
Int4 query_num; /* AM: Added to support query concatenation. */
-
+ Boolean partial_translation;
+ Int4 translation_length;
+
pbp = search->pbp;
MemSet(&result_hsp, 0, sizeof(BLASTResultHsp));
@@ -8744,13 +8834,16 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
gap_align->shift_pen = pbp->shift_pen;
gap_align->discontinuous = pbp->discontinuous;
- gap_align->positionBased = search->positionBased;
+ gap_align->positionBased =
+ (search->positionBased && search->sbp->posMatrix);
gap_align->gap_open = pbp->gap_open;
gap_align->gap_extend = pbp->gap_extend;
gap_align->decline_align = pbp->decline_align;
gap_align->x_parameter = pbp->gap_x_dropoff_final;
gap_align->matrix = search->sbp->matrix;
gap_align->posMatrix = search->sbp->posMatrix;
+ partial_translation = (subject_length > SUBJECT_ADJUSTMENT);
+
for (index=0; index<hspcnt; index++) {
hsp_start_is_contained = FALSE;
hsp_end_is_contained = FALSE;
@@ -8842,6 +8935,8 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
gap_align->translate2 = FALSE;
}
+ start_shift = 0;
+
if (StringCmp(search->prog_name, "tblastn") == 0 ||
StringCmp(search->prog_name, "psitblastn") == 0) {
gap_align->translate1 = FALSE;
@@ -8851,7 +8946,32 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
translated_subject = translated_subject_orig + 3;
translated_subject_length_orig = MemNew(8*sizeof(Int4));
translated_subject_length = translated_subject_length_orig + 3;
- } if (translated_subject[hsp->subject.frame] == NULL) {
+ }
+ if (partial_translation) {
+ translated_subject[hsp->subject.frame] =
+ MemFree(translated_subject[hsp->subject.frame]);
+ /* NB: since SUBJECT_ADJUSTMENT is divisible by 3, the frame
+ will remain the same.
+ */
+ start_shift =
+ MAX(0, 3*hsp->subject.offset - SUBJECT_ADJUSTMENT);
+ translation_length =
+ MIN(3*hsp->subject.end + SUBJECT_ADJUSTMENT, subject_length)
+ - start_shift;
+ if (hsp->subject.frame > 0) {
+ translated_subject[hsp->subject.frame] =
+ GetTranslation(subject+start_shift, translation_length, hsp->subject.frame, &translated_subject_length[hsp->subject.frame], search->db_genetic_code);
+ } else {
+ translated_subject[hsp->subject.frame] =
+ GetTranslation(rev_subject+start_shift, translation_length, hsp->subject.frame, &translated_subject_length[hsp->subject.frame], search->db_genetic_code);
+ }
+ /* Below, the start_shift will be used for the protein
+ coordinates, so need to divide it by 3 */
+ start_shift /= CODON_LENGTH;
+ hsp->subject.offset -= start_shift;
+ hsp->subject.gapped_start -= start_shift;
+
+ } else if (translated_subject[hsp->subject.frame] == NULL) {
if (hsp->subject.frame > 0) {
translated_subject[hsp->subject.frame] =
GetTranslation(subject, subject_length, hsp->subject.frame, &translated_subject_length[hsp->subject.frame], search->db_genetic_code);
@@ -8891,28 +9011,39 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
gap_align->s_start = hsp->subject.gapped_start;
}
}
-
- if (gap_align->s_start > max_start) {
- start_shift = (gap_align->s_start / max_start) * max_start;
- gap_align->subject = gap_align->subject + start_shift;
-
- gap_align->s_start %= max_start;
- } else
- start_shift = 0;
-
- gap_align->subject_length =
- MIN(gap_align->subject_length - start_shift,
- gap_align->s_start + hsp->subject.length + max_start);
-
+ if (search->prog_number == blast_type_blastn) {
+ /* For blastn, use only part of a long subject sequence,
+ because the placeholders for the gapped alignment
+ information have only been allocated for at most a
+ certain length */
+ if (gap_align->s_start > max_start) {
+ start_shift = (gap_align->s_start / max_start) * max_start;
+ gap_align->subject = gap_align->subject + start_shift;
+
+ gap_align->s_start %= max_start;
+ } else
+ start_shift = 0;
+
+ gap_align->subject_length =
+ MIN(gap_align->subject_length - start_shift,
+ gap_align->s_start + hsp->subject.length + max_start);
+ }
- if (do_traceback)
- PerformGappedAlignmentWithTraceback(gap_align);
- else
+ if (do_traceback) {
+ if (!search->pbp->mb_params ||
+ search->pbp->mb_params->use_dyn_prog) {
+ PerformGappedAlignmentWithTraceback(gap_align);
+ } else {
+ PerformGreedyAlignmentWithTraceback(gap_align, search->abmp,
+ search->sbp);
+ }
+ } else {
PerformGappedAlignment(gap_align);
-
+ }
+
if (gap_align->score >= min_score_to_keep) {
-
+
if(search->pbp->is_ooframe) {
hsp->query.offset = gap_align->subject_start + start_shift;
hsp->subject.offset = gap_align->query_start;
@@ -8940,7 +9071,16 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
}
keep = TRUE;
- if (search->prog_number == blast_type_blastp ||
+ /* If greedy alignment was used for traceback, we still need
+ to reevaluate the score with ambiguity information */
+ if (search->pbp->mb_params &&
+ !search->pbp->mb_params->use_dyn_prog &&
+ ReevaluateScoreWithAmbiguities(search, subject, hsp)) {
+ /* HSP became below the cutoff after reevaluation */
+ keep = FALSE;
+ }
+
+ if (keep && search->prog_number == blast_type_blastp ||
search->prog_number == blast_type_blastn) {
if (search->pbp->mb_params) {
FloatHi searchsp_eff = (FloatHi) search->dblen_eff *
@@ -8985,37 +9125,39 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
#endif
}
- if (search->pbp->is_ooframe) {
- OOFBlastHSPGetNumIdentical(gap_align->query,
- gap_align->subject-start_shift, hsp, NULL,
- &hsp->num_ident, &align_length);
- } else {
- search->subject->sequence_start =
- gap_align->subject - start_shift - 1;
- BlastHSPGetNumIdentical(search, hsp, NULL, &hsp->num_ident,
- &align_length);
- }
- if (search->pbp->mb_params &&
- search->pbp->mb_params->use_dyn_prog) {
- if (hsp->num_ident * 100 <
- align_length * search->pbp->mb_params->perc_identity) {
- keep = FALSE;
+ if (keep) {
+ if (search->pbp->is_ooframe) {
+ OOFBlastHSPGetNumIdentical(gap_align->query,
+ gap_align->subject-start_shift, hsp, NULL,
+ &hsp->num_ident, &align_length);
+ } else {
+ search->subject->sequence_start =
+ gap_align->subject - start_shift - 1;
+ BlastHSPGetNumIdentical(search, hsp, NULL, &hsp->num_ident,
+ &align_length);
}
- }
- search->subject->sequence_start = NULL;
-
- if (search->pbp->scalingFactor != 0.0 && search->pbp->scalingFactor != 1.0)
- { /* Scale down score for blastp and tblastn. */
- hsp->score = (hsp->score+(0.5*search->pbp->scalingFactor))/search->pbp->scalingFactor;
- }
+ if (search->pbp->mb_params &&
+ search->pbp->mb_params->use_dyn_prog) {
+ if (hsp->num_ident * 100 <
+ align_length * search->pbp->mb_params->perc_identity) {
+ keep = FALSE;
+ }
+ }
+ search->subject->sequence_start = NULL;
+ if (search->pbp->scalingFactor != 0.0 && search->pbp->scalingFactor != 1.0)
+ /* Scale down score for blastp and tblastn. */
+ hsp->score = (hsp->score+(0.5*search->pbp->scalingFactor))/search->pbp->scalingFactor;
+
/* only one alignment considered for blast[np]. */
/* This may be changed by LinkHsps for blastx or tblastn. */
- hsp->num = 1;
- if ((search->prog_number == blast_type_tblastn ||
- search->prog_number == blast_type_psitblastn) &&
- search->pbp->longest_intron > 0)
- hsp->evalue = BlastKarlinStoE_simple(hsp->score, search->sbp->kbp_gap[search->first_context], search->searchsp_eff);
+ hsp->num = 1;
+ if ((search->prog_number == blast_type_tblastn ||
+ search->prog_number == blast_type_psitblastn) &&
+ search->pbp->longest_intron > 0)
+ hsp->evalue = BlastKarlinStoE_simple(hsp->score,
+ search->sbp->kbp_gap[search->first_context], search->searchsp_eff);
+ }
for (index2=0; index2<index && keep == TRUE; index2++) {
hsp2 = hsp_array[index2];
@@ -9035,10 +9177,11 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
} else {
new_hspcnt--;
if (do_traceback) {
- seqalign_array[index2] = SeqAlignFree(seqalign_array[index2]);
- hsp_array[index2]->gap_info = GapXEditBlockDelete(hsp_array[index2]->gap_info);
+ seqalign_array[index2] =
+ SeqAlignFree(seqalign_array[index2]);
}
- hsp_array[index2] = MemFree(hsp_array[index2]);
+ hsp_array[index2] =
+ BLAST_HSPFree(hsp_array[index2]);
}
}
}
@@ -9046,18 +9189,13 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
if (keep) {
new_hspcnt++;
} else {
- hsp_array[index] = MemFree(hsp_array[index]);
- if (do_traceback)
- gap_align->edit_block = GapXEditBlockDelete(gap_align->edit_block);
+ hsp_array[index] = BLAST_HSPFree(hsp_array[index]);
}
} else { /* Should be kept? */
- hsp_array[index] = MemFree(hsp_array[index]);
- if (do_traceback)
- gap_align->edit_block = GapXEditBlockDelete(gap_align->edit_block);
+ hsp_array[index] = BLAST_HSPFree(hsp_array[index]);
}
} else { /* Contained within another HSP, delete. */
- hsp_array[index]->gap_info = GapXEditBlockDelete(hsp_array[index]->gap_info);
- hsp_array[index] = MemFree(hsp_array[index]);
+ hsp_array[index] = BLAST_HSPFree(hsp_array[index]);
}
}
if (search->pbp->scalingFactor != 0.0 && search->pbp->scalingFactor != 1.0)
@@ -9122,9 +9260,7 @@ RealBlastGetGappedAlignmentTraceback(BlastSearchBlkPtr search, Uint1Ptr subject,
of HSPs per database sequence */
if (search->pbp->hsp_num_max > new_hspcnt) {
for (index=new_hspcnt; index<search->pbp->hsp_num_max; ++index) {
- hsp_array[index]->gap_info =
- GapXEditBlockDelete(hsp_array[index]->gap_info);
- hsp_array[index] = MemFree(hsp_array[index]);
+ hsp_array[index] = BLAST_HSPFree(hsp_array[index]);
}
new_hspcnt = MIN(new_hspcnt, search->pbp->hsp_num_max);
}
@@ -9242,8 +9378,8 @@ SumBlastGetGappedAlignmentEx (BlastSearchBlkPtr search, Int4 hit_number, Boolean
SeqIdPtr subject_id=NULL, sip, subject_id_var;
Nlm_FloatHi current_evalue=DBL_MAX;
ValNodePtr vnp, vnp_start;
- BLASTResultsStructPtr result_struct;
- Boolean is_megablast = (search->pbp->mb_params && search->pbp->mb_params->use_dyn_prog);
+ BLASTResultsStructPtr result_struct;
+ Boolean is_megablast = (search->pbp->mb_params != NULL);
if (search == NULL)
return FALSE;
@@ -9555,7 +9691,8 @@ BlastPreliminaryGappedScore (BlastSearchBlkPtr search, Uint1Ptr subject, Int4 su
gap_align->is_ooframe = pbp->is_ooframe;
gap_align->shift_pen = pbp->shift_pen;
gap_align->discontinuous = pbp->discontinuous;
- gap_align->positionBased = search->positionBased;
+ gap_align->positionBased =
+ (search->positionBased && search->sbp->posMatrix);
gap_align->include_query = 0;
gap_align->gap_open = pbp->gap_open;
gap_align->gap_extend = pbp->gap_extend;
@@ -9874,7 +10011,8 @@ BlastGetGappedScore (BlastSearchBlkPtr search, Int4 subject_length, Uint1Ptr sub
gap_align->is_ooframe = pbp->is_ooframe;
gap_align->shift_pen = pbp->shift_pen;
gap_align->discontinuous = pbp->discontinuous;
- gap_align->positionBased = search->positionBased;
+ gap_align->positionBased =
+ (search->positionBased && search->sbp->posMatrix);
gap_align->include_query = 0;
gap_align->gap_open = pbp->gap_open;
gap_align->gap_extend = pbp->gap_extend;
@@ -10497,16 +10635,13 @@ bove.*/
{
if (new_index >= hspcnt)
{ /* this HSP is less significant than others on a full list.*/
- new_hsp->gap_info = GapXEditBlockDelete(new_hsp->gap_info);
- new_hsp = MemFree(new_hsp);
+ new_hsp = BLAST_HSPFree(new_hsp);
return;
}
else
{ /* Delete the last HSP on the list. */
hspcnt = --current_hitlist->hspcnt;
- hsp_array[hspcnt]->gap_info =
- GapXEditBlockDelete(hsp_array[hspcnt]->gap_info);
- hsp_array[hspcnt] = MemFree(hsp_array[hspcnt]);
+ hsp_array[hspcnt] = BLAST_HSPFree(hsp_array[hspcnt]);
}
}
current_hitlist->hspcnt++;
diff --git a/tools/gapxdrop.c b/tools/gapxdrop.c
index a1856943..8e1f4572 100644
--- a/tools/gapxdrop.c
+++ b/tools/gapxdrop.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: gapxdrop.c,v 6.75 2003/08/20 22:11:49 dondosha Exp $";
+static char const rcsid[] = "$Id: gapxdrop.c,v 6.76 2003/11/07 21:52:52 dondosha Exp $";
/* ===========================================================================
*
@@ -34,8 +34,11 @@ Author: Gennadiy Savchuk, Jinqhui Zhang, Tom Madden
Contents: Functions to perform a gapped alignment on two sequences.
****************************************************************************/
-/* $Revision: 6.75 $
+/* $Revision: 6.76 $
* $Log: gapxdrop.c,v $
+* Revision 6.76 2003/11/07 21:52:52 dondosha
+* Fixed SEMI_G_ALIGN_EX so it produces correct scores, by making code exactly correspond to ALIGN_EX
+*
* Revision 6.75 2003/08/20 22:11:49 dondosha
* Removed some garbage code
*
@@ -807,7 +810,7 @@ ALIGN_EX(Uint1Ptr A, Uint1Ptr B, Int4 M, Int4 N, Int4Ptr S, Int4Ptr pei,
}
if (best_score - c > X){
if (tt == i) tt++;
- else { dp->CC = MININT; }
+ else { dp->CC = MININT; }
} else {
cb = i;
if (c > best_score) {
@@ -924,6 +927,7 @@ static Int4 SEMI_G_ALIGN_EX(Uint1Ptr A, Uint1Ptr B, Int4 M, Int4 N,
register GapXDPPtr dp;
Uint1Ptr Bptr;
Int4 B_increment=1;
+ Int4 next_c, next_f;
if(!score_only) {
return ALIGN_EX(A, B, M, N, S, pei, pej, sapp, gap_align, query_offset, reversed, reverse_sequence);
@@ -946,12 +950,12 @@ static Int4 SEMI_G_ALIGN_EX(Uint1Ptr A, Uint1Ptr B, Int4 M, Int4 N,
dyn_prog = (GapXDPPtr)Nlm_Malloc(j);
dyn_prog[0].CC = 0; c = dyn_prog[0].DD = -m;
- dyn_prog[0].FF = -m;
+ dyn_prog[0].FF = -m - decline_penalty;
for(i = 1; i <= N; i++) {
if(c < -X) break;
dyn_prog[i].CC = c;
dyn_prog[i].DD = c - m;
- dyn_prog[i].FF = c-m;
+ dyn_prog[i].FF = c-m - decline_penalty;
c -= h;
}
@@ -985,64 +989,50 @@ static Int4 SEMI_G_ALIGN_EX(Uint1Ptr A, Uint1Ptr B, Int4 M, Int4 N,
e = c =f = MININT;
Bptr = &B[tt];
if(reverse_sequence)
- Bptr = &B[N-tt];
+ Bptr = &B[N-tt];
for (cb = i = tt, dp = &dyn_prog[i]; i < j; i++) {
+ d = dp->DD;
Bptr += B_increment;
- d = dp->DD;
- if (e < f) e = f;
- if (d < f) d = f;
- if (c < d || c < e) {
- if (d < e) {
- c = e;
- } else {
- c = d;
- }
- if (best_score - c > X) {
- c = dp->CC+wa[*Bptr]; f = dp->FF;
- if (tt == i) tt++;
- else { dp->CC =dp->FF= MININT;}
- } else {
- cb = i;
- if ((c-=m) > (d-=h)) {
- dp->DD = c;
- } else {
- dp->DD = d;
- }
- if (c > (e-=h)) {
- e = c;
- }
- c+=m;
- d = dp->CC+wa[*Bptr]; dp->CC = c; c=d;
- d = dp->FF; dp->FF = f-decline_penalty; f = d;
- }
- } else {
- if (best_score - c > X){
- c = dp->CC+wa[*Bptr]; f= dp->FF;
- if (tt == i) tt++;
- else { dp->CC =dp->FF= MININT;}
- } else {
- cb = i;
- if (c > best_score) {
- best_score = c;
- *pei = j_r; *pej = i;
- }
- if ((c-=m) > (d-=h)) {
- dp->DD = c;
- } else {
- dp->DD = d;
- }
- if (c > (e-=h)) {
- e = c;
- }
- c+=m;
- d = dp->FF;
- if (c-g>f) dp->FF = c-g-decline_penalty; else dp->FF = f-decline_penalty;
- f = d;
- d = dp->CC+wa[*Bptr]; dp->CC = c; c = d;
- }
- }
- dp++;
+ next_c = dp->CC+wa[*Bptr]; /* Bptr is & B[i+1]; */
+ next_f = dp->FF;
+
+ if (c < f) c = f;
+ if (f > d) d = f;
+ else if (c < d) c= d;
+
+ if (f > e) e = f;
+ else if (c < e) c = e;
+
+ if (best_score - c > X){
+ if (tt == i) tt++;
+ else { dp->CC = MININT; }
+ } else {
+ cb = i;
+ if (c > best_score) {
+ best_score = c;
+ *pei = j_r; *pej = i;
+ }
+ if ((c-=m) > (d-=h)) {
+ dp->DD = c;
+ } else {
+ dp->DD = d;
+ }
+ if (c > (e-=h)) {
+ e = c;
+ }
+ c+=m;
+ if (f < c-g) {
+ dp->FF = c-g-decline_penalty;
+ } else {
+ dp->FF = f-decline_penalty;
+ }
+ dp->CC = c;
+ }
+ c = next_c;
+ f = next_f;
+ dp++;
}
+
if (tt == j) break;
if (cb < j-1) { j = cb+1;}
else while (e >= best_score-X && j <= N) {
@@ -1054,7 +1044,6 @@ static Int4 SEMI_G_ALIGN_EX(Uint1Ptr A, Uint1Ptr B, Int4 M, Int4 N,
}
}
-
MemFree(dyn_prog);
return best_score;
diff --git a/tools/kappa.c b/tools/kappa.c
index e16bd0c7..e5ae43b8 100644
--- a/tools/kappa.c
+++ b/tools/kappa.c
@@ -1,6 +1,6 @@
-static char const rcsid[] = "$Id: kappa.c,v 6.34 2003/10/22 20:37:19 madden Exp $";
+static char const rcsid[] = "$Id: kappa.c,v 6.37 2004/01/27 20:31:52 madden Exp $";
-/* $Id: kappa.c,v 6.34 2003/10/22 20:37:19 madden Exp $
+/* $Id: kappa.c,v 6.37 2004/01/27 20:31:52 madden Exp $
* ==========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -34,9 +34,18 @@ Author: Alejandro Schaffer
Contents: Utilities for doing Smith-Waterman alignments and adjusting
the scoring system for each match in blastpgp
- $Revision: 6.34 $
+ $Revision: 6.37 $
$Log: kappa.c,v $
+ Revision 6.37 2004/01/27 20:31:52 madden
+ remove extra setting of kbp_gap
+
+ Revision 6.36 2004/01/06 17:48:44 dondosha
+ Do not free Karlin block in RedoAlignmentCore, because its pointer is passed outside
+
+ Revision 6.35 2003/12/01 19:15:27 madden
+ Add one byte to filteredMatchingSequence to prevent ABR/ABW
+
Revision 6.34 2003/10/22 20:37:19 madden
Set kbp to rescaled values, use upper-case for SCALING_FACTOR define
@@ -1584,6 +1593,7 @@ SeqAlignPtr RedoAlignmentCore(BlastSearchBlkPtr search,
Int4 queryLength; /*the length of the query sequence*/
Uint1Ptr matchingSequence; /*one sequence that matches the query*/
Uint1Ptr filteredMatchingSequence; /*other representations of matchingSequence*/
+ Uint1Ptr filteredMatchingSequenceStart; /* other representations of matchingSequence with one more byte on beginning*/
Int4 matchingSequenceLength; /*length of matching sequence*/
Int4 matchStart, queryStart; /*starting positions for local alignment*/
Int4 queryEnd, matchEnd, finalQueryEnd, finalMatchEnd; /*end positions of optimal local alignment*/
@@ -1740,12 +1750,10 @@ SeqAlignPtr RedoAlignmentCore(BlastSearchBlkPtr search,
if (search->positionBased)
{
search->sbp->kbp_gap_psi[0] = kbp;
- search->sbp->kbp_gap[0] = kbp;
}
else
{
search->sbp->kbp_gap_std[0] = kbp;
- search->sbp->kbp_gap[0] = kbp;
}
resProb = (Nlm_FloatHi *) MemNew (PROTEIN_ALPHABET * sizeof(Nlm_FloatHi));
@@ -1812,7 +1820,8 @@ SeqAlignPtr RedoAlignmentCore(BlastSearchBlkPtr search,
/*filteredMatchingSequence = matchingSequence;*/
/* switch to this if we want to filter the match*/
- filteredMatchingSequence = MemNew((matchingSequenceLength+1) * sizeof(Uint1));
+ filteredMatchingSequenceStart = MemNew((matchingSequenceLength+2) * sizeof(Uint1));
+ filteredMatchingSequence = filteredMatchingSequenceStart+1;
segResult(bsp_db, matchingSequence, filteredMatchingSequence, matchingSequenceLength);
foundFirstAlignment = FALSE;
if (adjustParameters) {
@@ -2076,7 +2085,7 @@ SeqAlignPtr RedoAlignmentCore(BlastSearchBlkPtr search,
}
index++;
if (matchingSequence != filteredMatchingSequence)
- MemFree(filteredMatchingSequence);
+ MemFree(filteredMatchingSequenceStart);
if (bsp_db) {
if (bioseq_unlock) {
BioseqUnlock(bsp_db); bsp_db = NULL;
@@ -2126,7 +2135,6 @@ SeqAlignPtr RedoAlignmentCore(BlastSearchBlkPtr search,
freeStartFreqs(startFreqRatios,PROTEIN_ALPHABET);
MemFree(queryProb);
}
- MemFree(kbp);
MemFree(resProb);
MemFree(scoreArray);
MemFree(return_sfp);
diff --git a/tools/mbalign.c b/tools/mbalign.c
index 609dc6e9..bf9a3d43 100644
--- a/tools/mbalign.c
+++ b/tools/mbalign.c
@@ -1,6 +1,6 @@
-static char const rcsid[] = "$Id: mbalign.c,v 6.40 2003/05/30 17:25:36 coulouri Exp $";
+static char const rcsid[] = "$Id: mbalign.c,v 6.41 2003/10/29 17:46:59 dondosha Exp $";
-/* $Id: mbalign.c,v 6.40 2003/05/30 17:25:36 coulouri Exp $
+/* $Id: mbalign.c,v 6.41 2003/10/29 17:46:59 dondosha Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -32,12 +32,15 @@ static char const rcsid[] = "$Id: mbalign.c,v 6.40 2003/05/30 17:25:36 coulouri
*
* Initial Creation Date: 10/27/1999
*
-* $Revision: 6.40 $
+* $Revision: 6.41 $
*
* File Description:
* Alignment functions for Mega Blast program
*
* $Log: mbalign.c,v $
+* Revision 6.41 2003/10/29 17:46:59 dondosha
+* Allow 2-stage greedy extension in megablast
+*
* Revision 6.40 2003/05/30 17:25:36 coulouri
* add rcsid
*
@@ -691,6 +694,8 @@ Int4 MegaBlastGreedyAlign(const UcharPtr s1, Int4 len1,
}
if (S==NULL)
space = 0;
+ else if (!space)
+ abmp->space = space = new_mb_space();
else
refresh_mb_space(space);
@@ -935,7 +940,9 @@ Int4 MegaBlastAffineGreedyAlign (const UcharPtr s1, Int4 len1,
flast_d = abmp->flast_d_affine;
if (S==NULL) {
space = 0;
- } else {
+ } else if (!space) {
+ abmp->space = space = new_mb_space();
+ } else {
refresh_mb_space(space);
}
max_row = max_row_free + D_diff;
diff --git a/tools/mblast.c b/tools/mblast.c
index 5e0fd082..9e83593e 100644
--- a/tools/mblast.c
+++ b/tools/mblast.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: mblast.c,v 6.190 2003/05/30 17:25:36 coulouri Exp $";
+static char const rcsid[] = "$Id: mblast.c,v 6.199 2004/01/27 20:46:06 dondosha Exp $";
/* ===========================================================================
*
@@ -40,9 +40,36 @@ Detailed Contents:
- Functions specific to Mega BLAST
******************************************************************************
- * $Revision: 6.190 $
+ * $Revision: 6.199 $
*
* $Log: mblast.c,v $
+ * Revision 6.199 2004/01/27 20:46:06 dondosha
+ * Allow values 0, 1, 2 for no_traceback megablast option
+ *
+ * Revision 6.198 2004/01/23 22:29:11 dondosha
+ * Increase hitlist size for preliminary alignment if traceback is delayed
+ *
+ * Revision 6.197 2004/01/16 23:43:45 dondosha
+ * No more need for special argument for partial search: it is set in options
+ *
+ * Revision 6.196 2004/01/13 15:46:54 dondosha
+ * Changed cast to nearest integer in length adjustment calculation
+ *
+ * Revision 6.195 2004/01/06 22:37:10 dondosha
+ * Use BLAST_HSPfree function
+ *
+ * Revision 6.194 2003/12/10 17:05:28 dondosha
+ * Added function ReevaluateScoreWithAmbiguities to reevaluate score for one HSP; use it after greedy traceback
+ *
+ * Revision 6.193 2003/11/06 19:53:07 dondosha
+ * Fix in MegaBlastSetupSearchInternalByLoc when query submitted as Bioseq instead of SeqLoc; removed unused variables
+ *
+ * Revision 6.192 2003/11/05 21:11:09 dondosha
+ * Fix for traceback with greedy algorithm
+ *
+ * Revision 6.191 2003/10/29 17:46:59 dondosha
+ * Allow 2-stage greedy extension in megablast
+ *
* Revision 6.190 2003/05/30 17:25:36 coulouri
* add rcsid
*
@@ -861,13 +888,6 @@ static Int2 mb_two_hit_min_step;
SeqAlignPtr PNTR
BioseqMegaBlastEngineCore(BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options)
{
- return BioseqMegaBlastEngineCoreEx(search, options, FALSE);
-}
-
-SeqAlignPtr PNTR
-BioseqMegaBlastEngineCoreEx(BlastSearchBlkPtr search, BLAST_OptionsBlkPtr
- options, Boolean partial)
-{
SeqAlignPtr seqalign, PNTR seqalignp;
Int2 num_queries;
CharPtr tmpstr;
@@ -890,26 +910,20 @@ start_timer;
stop_timer("BioseqBlastEngineCore: before do_the_blast_run()");
do_the_blast_run(search);
- if (!search->pbp->mb_params->no_traceback) {
- search->sbp->kbp_gap[search->first_context] = search->sbp->kbp[search->first_context];
-
- search->pbp->gap_open = options->gap_open;
- search->pbp->gap_extend = options->gap_extend;
-
- search->sbp->kbp_gap[search->first_context] = NULL;
- if (search->pbp->mb_params->use_dyn_prog) {
- search->context[search->first_context].query->length =
- search->query_context_offsets[search->first_context+1] - 1;
- }
-
- /* If this is a partial search, do not compute the seqaligns,
- but only if traceback has not been done yet */
- if (partial && search->pbp->mb_params->use_dyn_prog) {
- BlastStopAwakeThread(search->thr_info);
- return NULL;
- }
- }
-
+ /* If this is a partial search, we do not do traceback, so can return
+ immediately */
+ if (options->no_traceback == 1 || search->handle_results) {
+ BlastStopAwakeThread(search->thr_info);
+ return NULL;
+ }
+
+ /* So far the length of the first query was set to the total
+ concatenated length. It can be reset to the real length of the
+ first query sequence here. */
+ search->context[search->first_context].query->length =
+ search->query_context_offsets[search->first_context+1] - 1;
+
+
start_timer;
num_queries = search->last_context / 2 + 1;
seqalignp = (SeqAlignPtr PNTR)
@@ -939,11 +953,11 @@ MegaBlastSetUpSearchWithReadDbInternal (SeqLocPtr query_slp, BioseqPtr
BlastSearchBlkPtr search;
Boolean options_alloc=FALSE;
Int2 status, first_context, last_context;
- Int8 dblen, real_dblen;
- Int4 query_length, real_dbseq_num;
- Int4 i;
+ Int8 dblen;
+ Int4 query_length;
Nlm_FloatHi searchsp_eff=0;
-
+ Int4 hitlist_size;
+
/* Allocate default options if none are allocated yet. */
if (options == NULL)
{
@@ -951,6 +965,14 @@ MegaBlastSetUpSearchWithReadDbInternal (SeqLocPtr query_slp, BioseqPtr
options_alloc = TRUE;
}
+ /* Increase the hitlist size for the preliminary gapped alignment,
+ if traceback is delayed */
+ if (options->no_traceback) {
+ hitlist_size =
+ MIN(2*options->hitlist_size, options->hitlist_size + 50);
+ } else {
+ hitlist_size = options->hitlist_size;
+ }
/* last context is the total number of contexts in concatenated
queries */
@@ -959,7 +981,7 @@ MegaBlastSetUpSearchWithReadDbInternal (SeqLocPtr query_slp, BioseqPtr
query_length = SeqLocTotalLen(prog_name, query_slp);
MegaBlastGetFirstAndLastContext(prog_name, query_slp, &first_context, &last_context, options->strand_option);
} else {
- query_length = query_bsp->length;
+ query_length = 2*query_bsp->length + 3;
BlastGetFirstAndLastContext(prog_name, query_slp, &first_context, &last_context, options->strand_option);
}
@@ -974,7 +996,7 @@ MegaBlastSetUpSearchWithReadDbInternal (SeqLocPtr query_slp, BioseqPtr
search = BlastSearchBlkNewExtra(options->wordsize, qlen,
dbname, FALSE, 0,
options->threshold_second,
- options->hitlist_size, prog_name, NULL,
+ hitlist_size, prog_name, NULL,
first_context, last_context, rdfp,
options->window_size);
@@ -1074,12 +1096,6 @@ FindGiInGiList(Uint4 query_gi, BlastDoubleInt4Ptr gi_list,
return FALSE;
}
-#define DROPOFF_NUMBER_OF_BITS 10.0
-#define TOP_HALFBYTE 0xf0
-#define BOTTOM_HALFBYTE 0x0f
-static Uint1 inverse_halfbyte[16] =
-{ 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 };
-
#define MIN_LIMIT_HSP_NUM 1e20
#define BLASTNA_N_RESIDUE 14
@@ -1093,22 +1109,20 @@ MegaBlastSetUpSearchInternalByLoc (BlastSearchBlkPtr search, SeqLocPtr
positives)))
{
- BioseqPtr bsp;
Boolean mask_at_hash=FALSE, private_slp_delete;
- Boolean query_is_na, db_is_na;
Char buffer[128];
- Int2 retval, status, rem;
+ Int2 retval, status;
Int4 effective_query_length, query_length,
- index, index1, length, length_adjustment=0, last_length_adjustment,
+ index, length, length_adjustment=0, last_length_adjustment,
min_query_length, full_query_length=0;
- Int4 context, last_context, num_queries;
+ Int4 context, num_queries;
Nlm_FloatHi avglen;
- SeqIdPtr query_id, qid;
+ SeqIdPtr qid;
SeqLocPtr filter_slp=NULL, private_slp=NULL, private_slp_rev=NULL, slp,
tmp_slp;
- Uint1 residue, strand, seq_data_type;
+ Uint1 residue;
Uint1Ptr query_seq, query_seq_start, query_seq_rev, query_seq_start_rev;
- Uint1Ptr query_seq_combined, sequence;
+ Uint1Ptr query_seq_combined;
CharPtr filter_string;
Uint4 query_gi;
Int4 homo_gilist_size, mouse_gilist_size, rat_gilist_size;
@@ -1143,6 +1157,9 @@ MegaBlastSetUpSearchInternalByLoc (BlastSearchBlkPtr search, SeqLocPtr
private_slp_delete = FALSE;
search->query_slp = private_slp;
search->allocated += BLAST_SEARCH_ALLOC_QUERY_SLP;
+ /* Now let query_length be the total length of 2 strands together with
+ sentinel bytes */
+ query_length = 2*query_length + 3;
} else {
search->query_slp = query_slp;
query_length = SeqLocTotalLen(search->prog_name, query_slp);
@@ -1499,11 +1516,12 @@ MegaBlastSetUpSearchInternalByLoc (BlastSearchBlkPtr search, SeqLocPtr
completely masked */
while (!search->sbp->kbp[context])
context++;
+
min_query_length = (Int4) 1/(search->sbp->kbp[context]->K);
last_length_adjustment = 0;
for (index=0; index<5; index++) {
- length_adjustment = (Int4) ((search->sbp->kbp[context]->logK)+log((Nlm_FloatHi)(length-last_length_adjustment)*(Nlm_FloatHi)(MAX(1, (search->dblen)-(search->dbseq_num*last_length_adjustment)))))/(search->sbp->kbp[context]->H);
+ length_adjustment = Nlm_Nint(((search->sbp->kbp[context]->logK)+log((Nlm_FloatHi)(length-last_length_adjustment)*(Nlm_FloatHi)(MAX(1, (search->dblen)-(search->dbseq_num*last_length_adjustment)))))/(search->sbp->kbp[context]->H));
if (length_adjustment >= length-min_query_length) {
length_adjustment = length-min_query_length;
break;
@@ -1686,7 +1704,6 @@ BlastFillQueryOffsets(BlastSearchBlkPtr search, SeqLocPtr query_slp,
Int2 num_contexts;
Int2 i = 0;
Int4 length;
- Uint1 strand;
if (slp == NULL) return search;
/* Note: the last offset will be equal to the combined query length + 1, for
@@ -1726,7 +1743,6 @@ static int LIBCALLBACK
evalue_compare_seqaligns(VoidPtr v1, VoidPtr v2)
{
SeqAlignPtr sap1, sap2, PNTR sapp1, PNTR sapp2;
- SeqIdPtr id1, id2;
sapp1 = (SeqAlignPtr PNTR) v1;
sapp2 = (SeqAlignPtr PNTR) v2;
@@ -1952,17 +1968,16 @@ MegaBlastWordFinder_disc(BlastSearchBlkPtr search, LookupTablePtr lookup)
register Uint1Ptr subject;
register Int4 s_off, ecode, mask, q_off, extra_code;
Int4 ecode1, ecode2;
- Int4 index, index1;
Int4 subj_length = search->subject->length;
- Int4 query_length = search->context[search->first_context].query->length;
- MbStackPtr estack;
Int4 min_hit_size;
PV_ARRAY_TYPE *pv_array = lookup->pv_array;
Int4 pv_array_bts;
Int4 bit0, no_bit0;
Int2 word_length;
+#ifdef USE_HASH_TABLE
Uint1Ptr hash_buf;
Int4 hash_shift, hash_mask, crc, size;
+#endif
MegaBlastParameterBlkPtr mb_params = search->pbp->mb_params;
Int2 template_length = mb_params->template_length;
MBTemplateType template_type = mb_params->template_type;
@@ -2302,18 +2317,17 @@ MegaBlastWordFinder_disc_1b(BlastSearchBlkPtr search, LookupTablePtr lookup)
register Uint1Ptr subject;
register Int4 s_off, ecode, mask, q_off, extra_code;
Int4 ecode1, ecode2;
- Int4 index, index1;
Int4 subj_length = search->subject->length;
- Int4 query_length = search->context[search->first_context].query->length;
- MbStackPtr estack;
Int4 min_hit_size;
PV_ARRAY_TYPE *pv_array = lookup->pv_array;
Int4 pv_array_bts;
Uint1 bit;
Int4 no_bit0, bit0;
Int2 word_length;
+#ifdef USE_HASH_TABLE
Uint1Ptr hash_buf;
Int4 hash_shift, hash_mask, crc, size;
+#endif
MegaBlastParameterBlkPtr mb_params = search->pbp->mb_params;
Int2 template_length = mb_params->template_length;
MBTemplateType template_type = mb_params->template_type;
@@ -2671,10 +2685,7 @@ MegaBlastWordFinder(BlastSearchBlkPtr search, LookupTablePtr lookup)
{
register Uint1Ptr subject;
register Int4 s_off, ecode, mask, q_off;
- Int4 index, index1;
Int4 subj_length = search->subject->length;
- Int4 query_length = search->context[search->first_context].query->length;
- MbStackPtr estack;
Int4 min_hit_size;
PV_ARRAY_TYPE *pv_array = lookup->pv_array;
Int4 pv_array_bts;
@@ -2759,11 +2770,10 @@ diag_compare_match(VoidPtr v1, VoidPtr v2)
#define MB_MAX_LENGTH_TO_UNPACK 400
Int2 MegaBlastGappedAlign(BlastSearchBlkPtr search)
{
- BLAST_HSPPtr hsp, PNTR hsp_array;
MegaBlastExactMatchPtr PNTR e_hsp_array;
MegaBlastExactMatchPtr e_hsp;
- Int4 index, i, hspcnt, new_hspcnt=0, buf_len=0;
- Uint1Ptr subject0 = NULL, seq_4na, seq_2na;
+ Int4 index, i, hspcnt, buf_len=0;
+ Uint1Ptr subject0 = NULL;
Boolean delete_hsp;
GapAlignBlkPtr gap_align;
Boolean use_dyn_prog = search->pbp->mb_params->use_dyn_prog;
@@ -2875,13 +2885,12 @@ Int4
MegaBlastExtendHit(BlastSearchBlkPtr search, LookupTablePtr lookup,
Int4 s_off, Int4 q_off) {
Int4 index, len = 4*lookup->mb_lt->width;
- Int4 query_offset, subject_offset, index1, step;
- Int2 skip, min_hit_length;
+ Int4 index1, step;
+ Int2 min_hit_length;
MbStackPtr estack;
- Int4 diag, level, stack_top;
+ Int4 diag, stack_top;
BLAST_ExtendWordParamsPtr ewp_params = search->ewp_params;
register Int4 window;
- CharPtr str;
Int4 step_unit;
Boolean one_word, hit_ready, two_hits;
@@ -3038,7 +3047,7 @@ MegaBlastNtWordExtend(BlastSearchBlkPtr search, Uint1Ptr subject0,
BLAST_ScoreBlkPtr sbp;
Int4 q_avail, s_avail;
/* Variables for the call to MegaBlastGreedyAlign */
- Int4 ndiff, q_ext_l, q_ext_r, s_ext_l, s_ext_r;
+ Int4 q_ext_l, q_ext_r, s_ext_l, s_ext_r;
edit_script_t *ed_script_fwd=NULL, *ed_script_rev=NULL;
Boolean good_hit;
Uint1 rem;
@@ -3126,6 +3135,74 @@ MegaBlastNtWordExtend(BlastSearchBlkPtr search, Uint1Ptr subject0,
return 0;
}
+#define NO_UNPACK_MBALIGN_ARG 4
+void PerformGreedyAlignmentWithTraceback(GapAlignBlkPtr gap_align,
+ GreedyAlignMemPtr gamp, BLAST_ScoreBlkPtr sbp)
+{
+ Int4 score, s_ext_r, q_ext_r, s_ext_l, q_ext_l;
+ Uint1Ptr query0, subject0, query, subject;
+ Int4 X = gap_align->x_parameter;
+ Int4 reward = sbp->reward;
+ Int4 penalty = -sbp->penalty;
+ Int4 q_off, s_off, q_avail, s_avail;
+ edit_script_t *ed_script_fwd=NULL, *ed_script_rev=NULL;
+ GapXEditScriptPtr esp = NULL;
+
+ query0 = gap_align->query;
+ subject0 = gap_align->subject;
+ q_off = gap_align->q_start;
+ s_off = gap_align->s_start;
+ query = query0 + q_off;
+ subject = subject0 + s_off;
+ q_avail = gap_align->query_length - q_off;
+ s_avail = gap_align->subject_length - s_off;
+ ed_script_fwd = edit_script_new();
+ ed_script_rev = edit_script_new();
+
+ /* extend to the right */
+ score = MegaBlastAffineGreedyAlign(subject, s_avail, query, q_avail,
+ FALSE, X, reward, penalty, gap_align->gap_open,
+ gap_align->gap_extend, &s_ext_r, &q_ext_r, gamp,
+ ed_script_fwd, NO_UNPACK_MBALIGN_ARG);
+ /* extend to the left */
+ score += MegaBlastAffineGreedyAlign(subject0, s_off, query0, q_off,
+ TRUE, X, reward, penalty, gap_align->gap_open,
+ gap_align->gap_extend, &s_ext_l, &q_ext_l, gamp,
+ ed_script_rev, NO_UNPACK_MBALIGN_ARG);
+
+ /* In basic case the greedy algorithm returns number of
+ differences, hence we need to convert it to score */
+ if (gap_align->gap_open==0 && gap_align->gap_extend==0)
+ score =
+ (q_ext_r + s_ext_r + q_ext_l + s_ext_l)*sbp->reward/2 -
+ score*(sbp->reward - sbp->penalty);
+ else if (sbp->reward % 2 == 1)
+ score /= 2;
+
+ edit_script_append(ed_script_rev, ed_script_fwd);
+ esp = MBToGapXEditScript(ed_script_rev);
+
+ edit_script_free(ed_script_fwd);
+ edit_script_free(ed_script_rev);
+
+ gap_align->score = score;
+ gap_align->query_start = q_off - q_ext_l;
+ gap_align->subject_start = s_off - s_ext_l;
+ gap_align->query_stop = q_off + q_ext_r;
+ gap_align->subject_stop = s_off + s_ext_r;
+ gap_align->edit_block = GapXEditBlockNew(gap_align->query_start, gap_align->subject_start);
+
+ gap_align->edit_block->start1 = gap_align->query_start;
+ gap_align->edit_block->start2 = gap_align->subject_start;
+ gap_align->edit_block->length1 = gap_align->query_length;
+ gap_align->edit_block->length2 = gap_align->subject_length;
+ gap_align->edit_block->frame1 = gap_align->query_frame;
+ gap_align->edit_block->frame2 = gap_align->subject_frame;
+ gap_align->edit_block->reverse = 0;
+
+ gap_align->edit_block->esp = esp;
+}
+
/* A routine to mask the residues from a mask SeqLoc by changing to a given
* value (mask_residue).
* The buffer should contain an already decoded sequence.
@@ -3227,16 +3304,14 @@ diag_compare_hsps(VoidPtr v1, VoidPtr v2)
h1->subject.offset >= h2->subject.offset &&
h1->subject.end <= h2->subject.end &&
h1->evalue >= h2->evalue) {
- h1->gap_info = GapXEditBlockDelete(h1->gap_info);
- *hp1 = MemFree(*hp1);
+ *hp1 = BLAST_HSPFree(h1);
return 1;
} else if (h1->query.offset <= h2->query.offset &&
h1->query.end >= h2->query.end &&
h1->subject.offset <= h2->subject.offset &&
h1->subject.end >= h2->subject.end &&
h1->evalue <= h2->evalue) {
- h2->gap_info = GapXEditBlockDelete(h2->gap_info);
- *hp2 = MemFree(*hp2);
+ *hp2 = BLAST_HSPFree(h2);
return -1;
}
@@ -3275,18 +3350,14 @@ BlastSortUniqHspArray(BLAST_HitListPtr hitlist)
q_end <= hsp_array[index1]->query.end &&
s_end <= hsp_array[index1]->subject.end &&
evalue >= hsp_array[index1]->evalue) {
- hsp_array[index]->gap_info =
- GapXEditBlockDelete(hsp_array[index]->gap_info);
- hsp_array[index] = MemFree(hsp_array[index]);
+ hsp_array[index] = BLAST_HSPFree(hsp_array[index]);
break;
} else if (q_off <= hsp_array[index1]->query.offset &&
s_off <= hsp_array[index1]->subject.offset &&
q_end >= hsp_array[index1]->query.end &&
s_end >= hsp_array[index1]->subject.end &&
evalue <= hsp_array[index1]->evalue) {
- hsp_array[index1]->gap_info =
- GapXEditBlockDelete(hsp_array[index1]->gap_info);
- hsp_array[index1] = MemFree(hsp_array[index1]);
+ hsp_array[index1] = BLAST_HSPFree(hsp_array[index1]);
shift_needed = TRUE;
}
}
@@ -3362,7 +3433,7 @@ MegaBlastGapInfoToSeqAlign(BlastSearchBlkPtr search, Int4 subject_index,
BLASTResultHitlistPtr result_hitlist;
SeqIdPtr subject_id;
BLASTResultHspPtr hsp_array;
- Int4 index, i;
+ Int4 index;
SeqIdPtr query_id, new_subject_seqid;
StdSegPtr ssp;
ValNodePtr gi_list=NULL;
@@ -3459,27 +3530,171 @@ MegaBlastGetNumIdentical(Uint1Ptr query, Uint1Ptr subject, Int4 q_start,
return ident;
}
+/* Reevaluate score of one HSP, using ambiguity information */
+Boolean ReevaluateScoreWithAmbiguities(BlastSearchBlkPtr search,
+ Uint1Ptr subject_start, BLAST_HSPPtr hsp)
+{
+ BLAST_Score sum, score, gap_open, gap_extend;
+ BLAST_ScorePtr PNTR matrix;
+ Uint1Ptr query_start, query, subject;
+ Uint1Ptr new_q_start, new_s_start, new_q_end, new_s_end;
+ Int4 index, i, context, last_esp_num;
+ Int2 factor;
+ Uint1 mask = 0x0f;
+ Boolean delete_hsp;
+ GapXEditBlockPtr gap_info = hsp->gap_info;
+ GapXEditScriptPtr esp, last_esp, prev_esp, first_esp;
+ FloatHi searchsp_eff;
+ Int4 align_length;
+
+ if (search->sbp->reward % 2 == 1)
+ factor = 2;
+ else
+ factor = 1;
+
+ if (search->pbp->gap_open == 0 && search->pbp->gap_extend == 0) {
+ gap_open = 0;
+ gap_extend =
+ (search->sbp->reward - 2*search->sbp->penalty) * factor / 2;
+ } else {
+ gap_open = factor*search->pbp->gap_open;
+ gap_extend = factor*search->pbp->gap_extend;
+ }
+
+ matrix = search->sbp->matrix;
+
+ context = hsp->context;
+
+ searchsp_eff = (FloatHi) search->dblen_eff *
+ ((FloatHi) search->context[context].query->effective_length);
+
+ query_start = search->context[context].query->sequence;
+ query = query_start + hsp->query.offset;
+ subject = subject_start + hsp->subject.offset;
+ score = 0;
+ sum = 0;
+ new_q_start = new_q_end = query;
+ new_s_start = new_s_end = subject;
+ i = 0;
+
+ esp = gap_info->esp;
+ prev_esp = NULL;
+ last_esp = first_esp = esp;
+ last_esp_num = 0;
+
+ while (esp) {
+ if (esp->op_type == GAPALIGN_SUB) {
+ sum += factor*matrix[*query & mask][*subject];
+ query++;
+ subject++;
+ i++;
+ } else if (esp->op_type == GAPALIGN_DEL) {
+ sum -= gap_open + gap_extend * esp->num;
+ subject += esp->num;
+ i += esp->num;
+ } else if (esp->op_type == GAPALIGN_INS) {
+ sum -= gap_open + gap_extend * esp->num;
+ query += esp->num;
+ i += esp->num;
+ }
+
+ if (sum < 0) {
+ if (score < search->pbp->cutoff_s2 ||
+ BlastKarlinStoE_simple(score, search->sbp->kbp[context],
+ searchsp_eff) > search->pbp->cutoff_e) {
+ /* Start from new offset */
+ new_q_start = query;
+ new_s_start = subject;
+ score = sum = 0;
+ if (i < esp->num) {
+ esp->num -= i;
+ first_esp = esp;
+ i = 0;
+ } else {
+ first_esp = esp->next;
+ }
+ /* Unlink the bad part of the esp chain
+ so it can be freed later */
+ if (prev_esp)
+ prev_esp->next = NULL;
+ last_esp = NULL;
+ } else {
+ /* Stop here */
+ break;
+ }
+ } else if (sum > score) {
+ /* Remember this point as the best scoring end point */
+ score = sum;
+ last_esp = esp;
+ last_esp_num = i;
+ new_q_end = query;
+ new_s_end = subject;
+ }
+ if (i >= esp->num) {
+ i = 0;
+ prev_esp = esp;
+ esp = esp->next;
+ }
+ }
+
+ score /= factor;
+
+ delete_hsp = FALSE;
+
+ if (score >= search->pbp->cutoff_s2) {
+ hsp->score = score;
+ searchsp_eff = (FloatHi) search->dblen_eff *
+ (FloatHi) search->context[context].query->effective_length;
+ hsp->evalue = BlastKarlinStoE_simple(score,
+ search->sbp->kbp[context], searchsp_eff);
+ if (hsp->evalue > search->pbp->cutoff_e) {
+ delete_hsp = TRUE;
+ } else {
+ hsp->query.length = new_q_end - new_q_start;
+ hsp->subject.length = new_s_end - new_s_start;
+ hsp->query.offset = new_q_start - query_start;
+ hsp->query.end = hsp->query.offset + hsp->query.length;
+ hsp->subject.offset = new_s_start - subject_start;
+ hsp->subject.end = hsp->subject.offset + hsp->subject.length;
+ /* Make corrections in edit block and free any parts that
+ are no longer needed */
+ if (first_esp != hsp->gap_info->esp) {
+ GapXEditScriptDelete(hsp->gap_info->esp);
+ hsp->gap_info->esp = first_esp;
+ }
+ if (last_esp->next != NULL) {
+ GapXEditScriptDelete(last_esp->next);
+ last_esp->next = NULL;
+ }
+ last_esp->num = last_esp_num;
+ BlastHSPGetNumIdentical(search, hsp, NULL, &hsp->num_ident,
+ &align_length);
+ }
+ } else {
+ delete_hsp = TRUE;
+ }
+
+ if (delete_hsp) { /* This HSP is now below the cutoff */
+ if (first_esp != NULL && first_esp != hsp->gap_info->esp)
+ GapXEditScriptDelete(first_esp);
+ hsp->gap_info = GapXEditBlockDelete(hsp->gap_info);
+ }
+
+ return delete_hsp;
+}
+
/* In the following function the forward strand is assumed */
Int2
-MegaBlastReevaluateWithAmbiguities(BlastSearchBlkPtr search, Int4 sequence_number)
+MegaBlastReevaluateWithAmbiguities(BlastSearchBlkPtr search)
{
- register BLAST_Score sum, score, gap_open, gap_extend;
- register BLAST_ScorePtr PNTR matrix;
BLAST_HitListPtr current_hitlist;
BLAST_HSPPtr PNTR hsp_array, hsp;
- Uint1Ptr query, subject, query_start, subject_start = NULL;
- Uint1Ptr new_q_start, new_s_start, new_q_end, new_s_end;
- Int4 index, context, hspcnt, buf_len=0, i;
- Int2 factor;
- Uint1 mask = 0x0f;
- GapXEditScriptPtr esp, last_esp, prev_esp, first_esp;
+ Uint1Ptr subject_start = NULL;
+ Int4 index, context, hspcnt, buf_len=0;
Boolean purge, delete_hsp;
- FloatHi searchsp_eff;
- Int4 last_esp_num;
Int4 query_length;
Int2 status;
- Int4 align_length;
if (!search->pbp->mb_params)
return 1;
@@ -3497,8 +3712,10 @@ MegaBlastReevaluateWithAmbiguities(BlastSearchBlkPtr search, Int4 sequence_numbe
hspcnt = current_hitlist->hspcnt;
hsp_array = current_hitlist->hsp_array;
- /* In case of no traceback, only adjust the offsets */
- if (search->pbp->mb_params->no_traceback) {
+ /* In case of greedy extension without traceback,
+ only adjust the offsets */
+ if (!search->pbp->mb_params->use_dyn_prog &&
+ search->pbp->mb_params->no_traceback) {
for (index=0; index<hspcnt; index++) {
if (hsp_array[index] != NULL) {
/* Adjust the query offsets here */
@@ -3520,22 +3737,6 @@ MegaBlastReevaluateWithAmbiguities(BlastSearchBlkPtr search, Int4 sequence_numbe
/* All HSPs have been deleted */
return 0;
- if (search->sbp->reward % 2 == 1)
- factor = 2;
- else
- factor = 1;
-
- if (search->pbp->gap_open == 0 && search->pbp->gap_extend == 0) {
- gap_open = 0;
- gap_extend =
- (search->sbp->reward - 2*search->sbp->penalty) * factor / 2;
- } else {
- gap_open = factor*search->pbp->gap_open;
- gap_extend = factor*search->pbp->gap_extend;
- }
-
- matrix = search->sbp->matrix;
-
/* Can happen only when subject was being unpacked on the fly
during gapped extensions */
if (!search->subject->sequence_start)
@@ -3561,8 +3762,8 @@ MegaBlastReevaluateWithAmbiguities(BlastSearchBlkPtr search, Int4 sequence_numbe
if (search->pbp->mb_params->use_dyn_prog) {
/* Check if the extension jumped through the border between
- sequences or sequence strands. If this happens, leave the part which
- contains the original offset pair, saved in gapped_start's
+ sequences or sequence strands. If this happens, leave the part
+ which contains the original offset pair, saved in gapped_start's
*/
Int4 extra_length;
query_length = search->query_context_offsets[context+1] -
@@ -3595,118 +3796,10 @@ MegaBlastReevaluateWithAmbiguities(BlastSearchBlkPtr search, Int4 sequence_numbe
continue;
}
- query_start = (Uint1Ptr) search->context[context].query->sequence;
- searchsp_eff = (FloatHi) search->dblen_eff *
- (FloatHi) search->context[context].query->effective_length;
-
- query = query_start + hsp->query.offset;
- subject = subject_start + hsp->subject.offset;
- score = 0;
- sum = 0;
- new_q_start = new_q_end = query;
- new_s_start = new_s_end = subject;
- i = 0;
-
- esp = hsp->gap_info->esp;
- prev_esp = NULL;
- last_esp = first_esp = esp;
- last_esp_num = 0;
-
- while (esp) {
- if (esp->op_type == GAPALIGN_SUB) {
- sum += factor*matrix[*query & mask][*subject];
- query++;
- subject++;
- i++;
- } else if (esp->op_type == GAPALIGN_DEL) {
- sum -= gap_open + gap_extend * esp->num;
- subject += esp->num;
- i += esp->num;
- } else if (esp->op_type == GAPALIGN_INS) {
- sum -= gap_open + gap_extend * esp->num;
- query += esp->num;
- i += esp->num;
- }
-
- if (sum < 0) {
- if (score < search->pbp->cutoff_s2 ||
- BlastKarlinStoE_simple(score, search->sbp->kbp[context],
- searchsp_eff) > search->pbp->cutoff_e) {
- /* Start from new offset */
- new_q_start = query;
- new_s_start = subject;
- score = sum = 0;
- if (i < esp->num) {
- esp->num -= i;
- first_esp = esp;
- i = 0;
- } else {
- first_esp = esp->next;
- }
- /* Unlink the bad part of the esp chain
- so it can be freed later */
- if (prev_esp)
- prev_esp->next = NULL;
- last_esp = NULL;
- } else {
- /* Stop here */
- break;
- }
- } else if (sum > score) {
- /* Remember this point as the best scoring end point */
- score = sum;
- last_esp = esp;
- last_esp_num = i;
- new_q_end = query;
- new_s_end = subject;
- }
- if (i >= esp->num) {
- i = 0;
- prev_esp = esp;
- esp = esp->next;
- }
- }
-
- score /= factor;
-
- delete_hsp = FALSE;
- if (score >= search->pbp->cutoff_s2) {
- hsp->score = score;
- searchsp_eff = (FloatHi) search->dblen_eff *
- (FloatHi) search->context[context].query->effective_length;
- hsp->evalue = BlastKarlinStoE_simple(score,
- search->sbp->kbp[context], searchsp_eff);
- if (hsp->evalue > search->pbp->cutoff_e) {
- delete_hsp = TRUE;
- } else {
- hsp->query.length = new_q_end - new_q_start;
- hsp->subject.length = new_s_end - new_s_start;
- hsp->query.offset = new_q_start - query_start;
- hsp->query.end = hsp->query.offset + hsp->query.length;
- hsp->subject.offset = new_s_start - subject_start;
- hsp->subject.end = hsp->subject.offset + hsp->subject.length;
- /* Make corrections in edit block and free any parts that
- are no longer needed */
- if (first_esp != hsp->gap_info->esp) {
- GapXEditScriptDelete(hsp->gap_info->esp);
- hsp->gap_info->esp = first_esp;
- }
- if (last_esp->next != NULL) {
- GapXEditScriptDelete(last_esp->next);
- last_esp->next = NULL;
- }
- last_esp->num = last_esp_num;
- BlastHSPGetNumIdentical(search, hsp, NULL, &hsp->num_ident,
- &align_length);
- }
- } else {
- delete_hsp = TRUE;
- }
+ delete_hsp =
+ ReevaluateScoreWithAmbiguities(search, subject_start, hsp);
if (delete_hsp) { /* This HSP is now below the cutoff */
- if (first_esp != NULL && first_esp != hsp->gap_info->esp)
- GapXEditScriptDelete(first_esp);
- hsp->gap_info = GapXEditBlockDelete(hsp->gap_info);
hsp_array[index] = MemFree(hsp_array[index]);
purge = TRUE;
}
@@ -3734,10 +3827,8 @@ MegaBlastReevaluateWithAmbiguities(BlastSearchBlkPtr search, Int4 sequence_numbe
*/
for (index=search->pbp->hsp_num_max;
index < search->current_hitlist->hspcnt; ++index) {
- current_hitlist->hsp_array[index]->gap_info =
- GapXEditBlockDelete(current_hitlist->hsp_array[index]->gap_info);
current_hitlist->hsp_array[index] =
- MemFree(current_hitlist->hsp_array[index]);
+ BLAST_HSPFree(current_hitlist->hsp_array[index]);
}
search->current_hitlist->hspcnt = search->pbp->hsp_num_max;
}
@@ -3799,8 +3890,6 @@ void PrintMaskedSequence(BioseqPtr query_bsp, SeqLocPtr mask_slp,
SeqLocPtr query_slp = NULL;
SeqPortPtr spp;
Uint1Ptr query_seq, seq_line;
- BioseqPtr masked_bsp;
- ByteStorePtr byte_sp;
Int4 index, id_length = 0, defline_len;
Uint1 residue;
CharPtr buffer = NULL;
@@ -3863,13 +3952,11 @@ MegaBlastSaveCurrentHitlist(BlastSearchBlkPtr search)
BLAST_KarlinBlkPtr kbp;
BLASTResultHspPtr hsp_array;
Int4 hspcnt, index, index1, new_index, old_index, low_index, high_index;
- Int4 hitlist_count, hitlist_max, hspmax, hspset_cnt, high_score=0, retval;
+ Int4 hitlist_count, hitlist_max, hspmax, high_score=0, retval;
Nlm_FloatHi current_evalue=DBL_MAX;
- Int2 deleted;
- Int4 query_length, i, hsp_index, new_size;
+ Int4 query_length, hsp_index, new_size;
Int4Ptr hsp_array_sizes;
- Int2 context, num_queries, query_index;
- SeqIdPtr subject_id=NULL;
+ Int2 num_queries, query_index;
Boolean PNTR do_not_reallocate;
Boolean use_dyn_prog = search->pbp->mb_params->use_dyn_prog;
@@ -3994,7 +4081,7 @@ MegaBlastSaveCurrentHitlist(BlastSearchBlkPtr search)
query_length =
search->query_context_offsets[hsp->context+1] -
search->query_context_offsets[hsp->context] - 1;
- if (!use_dyn_prog) {
+ if (!use_dyn_prog && !search->pbp->mb_params->no_traceback) {
hsp->gap_info->start1 = hsp->query.offset;
hsp->gap_info->start2 = hsp->subject.offset;
hsp->gap_info->frame1 = hsp_array[hsp_index].query_frame;
@@ -4244,4 +4331,5 @@ MBTemplateType GetMBTemplateType(Int2 weight, Int2 length, MBDiscWordType type)
return TEMPL_12_21_OPT;
}
}
+ return TEMPL_ERROR;
}
diff --git a/tools/mblast.h b/tools/mblast.h
index a8109ade..dd84413a 100644
--- a/tools/mblast.h
+++ b/tools/mblast.h
@@ -32,8 +32,17 @@ Contents: prototypes for "public" Mega BLAST functions (ones that other utilitil
******************************************************************************/
-/* $Revision: 6.46 $
+/* $Revision: 6.49 $
* $Log: mblast.h,v $
+* Revision 6.49 2004/01/16 23:43:44 dondosha
+* No more need for special argument for partial search: it is set in options
+*
+* Revision 6.48 2003/12/10 17:05:28 dondosha
+* Added function ReevaluateScoreWithAmbiguities to reevaluate score for one HSP; use it after greedy traceback
+*
+* Revision 6.47 2003/10/29 17:47:00 dondosha
+* Allow 2-stage greedy extension in megablast
+*
* Revision 6.46 2002/09/03 13:52:45 kans
* added prototypes for MegaBlastWordFinder and MegaBlastGappedAlign for Mac compiler
*
@@ -232,9 +241,6 @@ BioseqMegaBlastEngineByLoc PROTO((SeqLocPtr slp, CharPtr progname, CharPtr datab
SeqAlignPtr PNTR
BioseqMegaBlastEngineCore PROTO((BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options));
-SeqAlignPtr PNTR
-BioseqMegaBlastEngineCoreEx PROTO((BlastSearchBlkPtr search, BLAST_OptionsBlkPtr options, Boolean partial));
-
BlastSearchBlkPtr BlastFillQueryOffsets PROTO((BlastSearchBlkPtr search, SeqLocPtr query_slp, Int4 wordsize));
BlastSearchBlkPtr
@@ -258,8 +264,11 @@ MegaBlastGetNumIdentical PROTO((Uint1Ptr query, Uint1Ptr subject,
Int4 q_start, Int4 s_start, Int4 length,
Boolean reverse));
+Boolean ReevaluateScoreWithAmbiguities(BlastSearchBlkPtr search,
+ Uint1Ptr subject_start, BLAST_HSPPtr hsp);
+
Int2
-MegaBlastReevaluateWithAmbiguities PROTO((BlastSearchBlkPtr search, Int4 sequence_number));
+MegaBlastReevaluateWithAmbiguities PROTO((BlastSearchBlkPtr search));
Int4 BinarySearchInt4 PROTO((Int4 n, Int4Ptr A, Int4 size));
@@ -277,9 +286,10 @@ MegaBlastParameterBlkPtr
MegaBlastParameterBlkNew PROTO((BLAST_OptionsBlkPtr options));
Int4
-MegaBlastWordFinder(BlastSearchBlkPtr search, LookupTablePtr lookup);
-Int2 MegaBlastGappedAlign(BlastSearchBlkPtr search);
+MegaBlastWordFinder PROTO((BlastSearchBlkPtr search, LookupTablePtr lookup));
+void PerformGreedyAlignmentWithTraceback(GapAlignBlkPtr gap_align,
+ GreedyAlignMemPtr gamp, BLAST_ScoreBlkPtr sbp);
#ifdef __cplusplus
}
diff --git a/tools/ncbisrti.h b/tools/ncbisrti.h
index dd1fef61..e4c8c1ed 100644
--- a/tools/ncbisrti.h
+++ b/tools/ncbisrti.h
@@ -1,4 +1,4 @@
-/* $Id: ncbisrti.h,v 6.2 1998/06/01 14:52:38 madden Exp $
+/* $Id: ncbisrti.h,v 6.3 2003/12/03 02:10:52 kans Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,12 +29,15 @@
*
* Initial Version Creation Date: 03/24/1997
*
-* $Revision: 6.2 $
+* $Revision: 6.3 $
*
* File Description:
* Internal include file for SORTing library
*
* $Log: ncbisrti.h,v $
+* Revision 6.3 2003/12/03 02:10:52 kans
+* added defines missing from Mac OS 10.3 headers
+*
* Revision 6.2 1998/06/01 14:52:38 madden
* Change to using TmpNam
*
@@ -77,6 +80,16 @@
#endif /* OS_UNIX */
+/* Missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+#ifdef __MWERKS__
+#ifdef OS_UNIX_DARWIN
+#ifndef __SCHAR_MAX__
+#define __SCHAR_MAX__ 127
+#endif
+#endif
+#endif
+/* End missing from /usr/include/gcc/darwin/3.3/machine/limits.h */
+
#define MERGEALLOC 16384
#define UCHAR_LIM (UCHAR_MAX + 1)
diff --git a/tools/newkar.c b/tools/newkar.c
deleted file mode 100644
index 7248fc1d..00000000
--- a/tools/newkar.c
+++ /dev/null
@@ -1,142 +0,0 @@
-static char const rcsid[] = "$Id: newkar.c,v 6.3 2003/05/30 17:25:37 coulouri Exp $";
-
-#include <ncbi.h>
-#include <ncbimath.h>
-#include <objcode.h>
-#include <objseq.h>
-#include <sequtil.h>
-#include <blastkar.h>
-#include <blastpri.h>
-
-/*
- impalaKarlinLambdaBis
-
- Calculate Lambda using the bisection method (slow).
-*/
-static Nlm_FloatHi
-impalaKarlinLambdaBis(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi initialLambda)
-{
- Nlm_FloatHi PNTR sprob;
- Nlm_FloatHi lambda, up, newval;
- BLAST_Score i, low, high;
- int j;
- Nlm_FloatHi sum, x0, x1;
- Nlm_FloatHi returnValue;
-
- if (sfp->score_avg >= 0.) {
- return -1.;
- }
- low = sfp->obs_min;
- high = sfp->obs_max;
- /* if (BlastScoreChk(low, high) != 0)
- return -1.; */
-
- sprob = sfp->sprob;
- up = initialLambda;
- for (lambda=0.; ; ) {
- up *= 2;
- x0 = exp((Nlm_FloatHi)up);
- x1 = Nlm_Powi((Nlm_FloatHi)x0, low - 1);
- if (x1 > 0.) {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i] * (x1 *= x0);
- }
- else {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i] * exp(up * i);
- }
- if (sum >= 1.0)
- break;
- lambda = up;
- }
-
- for (j=0; j<BLAST_KARLIN_LAMBDA_ITER_DEFAULT; ++j) {
- newval = (lambda + up) / 2.;
- x0 = exp((Nlm_FloatHi)newval);
- x1 = Nlm_Powi((Nlm_FloatHi)x0, low - 1);
- if (x1 > 0.) {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i] * (x1 *= x0);
- }
- else {
- for (sum=0., i=low; i<=high; ++i)
- sum += sprob[i] * exp(newval * i);
- }
- if (sum > 1.0)
- up = newval;
- else
- lambda = newval;
- }
- returnValue = (lambda + up) /2;
- return (returnValue);
-}
-
-/******************* Fast Lambda Calculation Subroutine ************************
- Version 1.0 May 16, 1991
- Program by: Stephen Altschul
-
- Uses Newton-Raphson method (fast) to solve for Lambda, given an initial
- guess (lambda0) obtained perhaps by the bisection method.
-*******************************************************************************/
-
-Nlm_FloatHi LIBCALL
-impalaKarlinLambdaNR(BLAST_ScoreFreqPtr sfp, Nlm_FloatHi initialLambda)
-{
- BLAST_Score low; /* Lowest score (must be negative) */
- BLAST_Score high; /* Highest score (must be positive) */
- int j;
- BLAST_Score i;
- Nlm_FloatHi PNTR sprob;
- Nlm_FloatHi lambda0, sum, slope, temp, x0, x1, amt;
- Nlm_FloatHi returnValue;
- Boolean foundPositive;
-
- low = sfp->obs_min;
- high = sfp->obs_max;
- if (sfp->score_avg >= 0.) { /* Expected score must be negative */
- return -1.0;
- }
- /* if (BlastScoreChk(low, high) != 0)
- return -1.; */
-
- lambda0 = initialLambda;
-
- /* Calculate lambda */
-
- sprob = sfp->sprob;
- foundPositive = FALSE;
- for(j = 1; j <=high; j++)
- if (sprob[j] > 0.0) {
- foundPositive = TRUE;
- break;
- }
- if (!foundPositive)
- return(-1);
- for (j=0; j<40; ++j) { /* limit of 20 should never be close-approached */
- sum = -1.0;
- slope = 0.0;
- if (lambda0 < 0.01)
- break;
- x0 = exp((Nlm_FloatHi)lambda0);
- x1 = Nlm_Powi((Nlm_FloatHi)x0, low - 1);
- if (x1 == 0.)
- break;
- for (i=low; i<=high; ++i) {
- sum += (temp = sprob[i] * (x1 *= x0));
- slope += temp * i;
- }
- lambda0 -= (amt = sum/slope);
- if (ABS(amt/lambda0) < BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT) {
- /*
- Does it appear that we may be on the verge of converging
- to the ever-present, zero-valued solution?
- */
- if (lambda0 > BLAST_KARLIN_LAMBDA_ACCURACY_DEFAULT)
- return lambda0;
- break;
- }
- }
- returnValue= impalaKarlinLambdaBis(sfp, initialLambda);
- return(returnValue);
-}
-
diff --git a/tools/readdb.c b/tools/readdb.c
index fd0440b9..96e10722 100644
--- a/tools/readdb.c
+++ b/tools/readdb.c
@@ -1,6 +1,6 @@
-static char const rcsid[] = "$Id: readdb.c,v 6.424 2003/10/01 19:03:50 camacho Exp $";
+static char const rcsid[] = "$Id: readdb.c,v 6.429 2004/01/29 20:48:07 coulouri Exp $";
-/* $Id: readdb.c,v 6.424 2003/10/01 19:03:50 camacho Exp $ */
+/* $Id: readdb.c,v 6.429 2004/01/29 20:48:07 coulouri Exp $ */
/*
* ===========================================================================
*
@@ -50,7 +50,7 @@ Detailed Contents:
*
* Version Creation Date: 3/22/95
*
-* $Revision: 6.424 $
+* $Revision: 6.429 $
*
* File Description:
* Functions to rapidly read databases from files produced by formatdb.
@@ -65,6 +65,22 @@ Detailed Contents:
*
* RCS Modification History:
* $Log: readdb.c,v $
+* Revision 6.429 2004/01/29 20:48:07 coulouri
+* Only limit volume sizes on 32-bit platforms
+*
+* Revision 6.428 2004/01/28 19:34:51 camacho
+* Added sanity check for alias files
+*
+* Revision 6.427 2004/01/26 13:52:31 camacho
+* Do not use snprintf
+*
+* Revision 6.426 2004/01/23 21:13:54 camacho
+* 1. Refactored code to create multiple volumes.
+* 2. Set the maximum sequence file size to 1GB.
+*
+* Revision 6.425 2004/01/12 23:06:36 camacho
+* Sort link bit gi lists
+*
* Revision 6.424 2003/10/01 19:03:50 camacho
* Fix in readdb_get_totals_ex2 to use the alias file length/number of entries when
* gilist is populated.
@@ -1755,6 +1771,7 @@ static ValNodePtr IntValNodeCopy(ValNodePtr vnp);
static int LIBCALLBACK ID_Compare(VoidPtr i, VoidPtr j);
static void FDBBlastDefLineSetBit(Int2 bit_no, ValNodePtr PNTR retval);
static ReadDBFILEPtr readdb_merge_gifiles (ReadDBFILEPtr rdfp_chain);
+static Boolean s_IsTextFile(const char* filename);
#if defined(OS_UNIX_SOL) || defined(OS_UNIX_LINUX)
#ifdef HAVE_MADVISE
@@ -2448,6 +2465,11 @@ readdb_read_alias_file(CharPtr filename)
if (fp == NULL)
return NULL;
+ if (!s_IsTextFile(filename)) {
+ ErrPostEx(SEV_ERROR, 0, 1, "%s is not a valid alias file\n", filename);
+ return NULL;
+ }
+
file_path = Nlm_FilePathFind(filename);
buffer = MemNew(buflen + 1);
@@ -5396,6 +5418,7 @@ readdb_get_sequence_length (ReadDBFILEPtr rdfp, Int4 sequence_number)
Nlm_SwapUint4(rdfp->sequence_index[sequence_number]) - 1;
}
+#if 0
/* For nucl. return "unpacked" length and get the remainder out
of the last byte. */
if (is_prot == FALSE)
@@ -5420,6 +5443,7 @@ and the last two bits of the byte holds the size of the remainder (0-3). */
length *= 4;
length += remainder;
}
+#endif
return length;
}
@@ -7482,6 +7506,7 @@ ValNodePtr FDBLoadLinksTable(void)
ErrPostEx(SEV_ERROR,0,0,"Could not read %s", filename);
continue;
}
+ HeapSort(gis->i, gis->count, sizeof(Int4), ID_Compare);
lk_info = (LinkInfoPtr) MemNew(sizeof(LinkInfo));
lk_info->bit_number = bit;
lk_info->gi_list = gis;
@@ -8370,6 +8395,146 @@ static Boolean FDBDumpDefline(FormatDBPtr fdbp, CharPtr title, CharPtr seq_id)
return TRUE;
}
+/* Maximum size of sequence file: 1GB */
+#if LONG_BIT!=64
+#define SEQFILE_SIZE_MAX 1000000000UL
+#endif
+
+/* Creates a new volume of the blast database being created if the sequence
+ * being added causes it to exceed the volume limitations (number of
+ * letters/sequences) */
+static Int4 FDBCreateNewVolume(FormatDBPtr fdbp,
+ const ByteStorePtr seq,
+ Int4 seq_length,
+ const Uint4Ptr ambiguities)
+{
+ FDB_optionsPtr options = fdbp->options;
+ Int4 amb_size = 0; /* size of ambiguities for this sequence */
+ Int4 seq_size = 0; /* length of sequence file with new sequence being added */
+ Int4 hdr_size = 0; /* size of the header file without new sequence */
+ Char extension_prefix = options->is_protein ? 'p' : 'n';
+
+ if (ambiguities) {
+ amb_size = sizeof(*ambiguities) * ((*ambiguities)&0x7fffffffUL);
+ }
+ seq_size = (ftell(fdbp->fd_seq) + BSLen(seq) + 1 + amb_size);
+ hdr_size = ftell(fdbp->aip_def ? fdbp->aip_def->fp : fdbp->fd_def);
+
+ if ( /* if bases_in_volume was specified, don't exceed that */
+ (options->bases_in_volume &&
+ (fdbp->TotalLen + seq_length > options->bases_in_volume)) ||
+ /* if sequences_in_volume was specified, don't exceed that (will be
+ * deprecated) */
+ (options->sequences_in_volume &&
+ (fdbp->num_of_seqs+1) > options->sequences_in_volume) ||
+ /* if sequence file is about to grow larger than SEQFILE_SIZE_MAX */
+#if defined(SEQFILE_SIZE_MAX)
+ ( seq_size > SEQFILE_SIZE_MAX) ||
+#endif
+ /* if header file is about to grow too large (assuming header can not
+ * exceed 2G - 2000000000b) */
+ ( hdr_size > 2000000000UL)
+ )
+ {
+ Char dbnamebuf[PATH_MAX];
+ FormatDBPtr tmp_fdbp = NULL;
+#if 0
+ ErrLogPrintf("New volume : tell:%d seq:%d amd:%d total: %d (%d)\n",
+ ftell(fdbp->fd_seq),BSLen(*seq_data),amb_size,
+ seq_size, seq_size > 0x7fffffff );
+#endif
+ if (options->volume == 1) {
+ sprintf(dbnamebuf, "%s.00", options->base_name);
+ } else {
+ sprintf(dbnamebuf, "%s", options->base_name);
+ }
+ ErrLogPrintf("Closing volume %s with %ld sequences, %s letters"
+ "(.%csq file = %ld bytes; .%chr file = %ld bytes)\n",
+ dbnamebuf, fdbp->num_of_seqs,
+ Nlm_Int8tostr(fdbp->TotalLen, 1),
+ extension_prefix, (long)seq_size,
+ extension_prefix, (long)hdr_size);
+ tmp_fdbp = (FormatDBPtr) MemNew(sizeof(FormatDB));
+ MemCpy(tmp_fdbp, fdbp, sizeof(FormatDB));
+
+ if(FormatDBClose(tmp_fdbp))
+ return 9;
+ options->volume++;
+
+ /* When second volume is created, add suffix .00 to all
+ first volume files */
+ if (options->volume == 1)
+ {
+ Char oldnamebuf[FILENAME_MAX], newnamebuf[FILENAME_MAX];
+ int len = StringLen(options->base_name) + 2;
+ sprintf(oldnamebuf, "%s.%cin", options->base_name, extension_prefix);
+ sprintf(newnamebuf, "%s.00.%cin", options->base_name,
+ extension_prefix);
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ StringCpy(oldnamebuf + len, "hr");
+ StringCpy(newnamebuf + len + 3, "hr");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ StringCpy(oldnamebuf + len, "sq");
+ StringCpy(newnamebuf + len + 3, "sq");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ StringCpy(oldnamebuf + len, "nd");
+ StringCpy(newnamebuf + len + 3, "nd");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ StringCpy(oldnamebuf + len, "ni");
+ StringCpy(newnamebuf + len + 3, "ni");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ StringCpy(oldnamebuf + len, "sd");
+ StringCpy(newnamebuf + len + 3, "sd");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ StringCpy(oldnamebuf + len, "si");
+ StringCpy(newnamebuf + len + 3, "si");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ if (options->dump_info) {
+ StringCpy(oldnamebuf + len, "di");
+ StringCpy(newnamebuf + len + 3, "di");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ }
+ if (options->is_protein) {
+ /* PIG ISAM files */
+ StringCpy(oldnamebuf + len, "pd");
+ StringCpy(newnamebuf + len + 3, "pd");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ StringCpy(oldnamebuf + len, "pi");
+ StringCpy(newnamebuf + len + 3, "pi");
+ if (FileLength(oldnamebuf) > 0)
+ FileRename(oldnamebuf, newnamebuf);
+ }
+
+ MemFree(options->base_name);
+ newnamebuf[len+1] = NULLB;
+ options->base_name = StringSave(newnamebuf);
+ }
+
+ {
+ CharPtr ptr;
+ ptr = options->base_name + StringLen(options->base_name) - 2;
+ sprintf(ptr, "%02ld", (long) options->volume);
+ }
+
+ if ((tmp_fdbp = FormatDBInit(options)) == NULL)
+ return 2;
+
+ MemCpy(fdbp, tmp_fdbp, sizeof(FormatDB));
+ MemFree(tmp_fdbp);
+ }
+
+ return 0;
+}
+
Int2 FDBAddSequence (FormatDBPtr fdbp, BlastDefLinePtr bdp,
Uint1 seq_data_type, ByteStorePtr *seq_data,
Int4 SequenceLen,
@@ -8493,8 +8658,8 @@ Int2 FDBAddSequence2 (FormatDBPtr fdbp, BlastDefLinePtr bdp,
{
Uint4 hash;
Boolean bdp_was_allocated = FALSE;
- FormatDBPtr tmp_fdbp;
DI_Record direc;
+ Int4 retval = 0;
#if 0
/* testing heap overuse */
@@ -8508,101 +8673,9 @@ Int2 FDBAddSequence2 (FormatDBPtr fdbp, BlastDefLinePtr bdp,
}
/* If too many bases in thise file, start a new volume */
- if (fdbp->options->bases_in_volume > 0 || fdbp->options->sequences_in_volume > 0 || 1)
- {
- FDB_optionsPtr options = fdbp->options;
- int amb_size= sizeof(*AmbCharPtr)*(AmbCharPtr==NULL?0:(*AmbCharPtr)&0x7fffffffUL);
- int nl = (ftell(fdbp->fd_seq) + BSLen(*seq_data) + 1 + amb_size);
- int hdrsize = ftell(fdbp->aip_def?fdbp->aip_def->fp:fdbp->fd_def) ;
-
- if ((options->bases_in_volume && (fdbp->TotalLen + SequenceLen > options->bases_in_volume)) ||
- (options->sequences_in_volume && (fdbp->num_of_seqs+1) > options->sequences_in_volume) ||
- ( nl > 0x7fffffffUL) ||
- ( hdrsize > 2000000000UL /* assuming header can not exceed 2G - 2000000000b */ )
- )
- {
- ErrLogPrintf("New volume : tell:%d seq:%d amd:%d total: %d (%d)\n",
- ftell(fdbp->fd_seq),BSLen(*seq_data),amb_size,
- nl, nl > 0x7fffffff );
- tmp_fdbp = (FormatDBPtr) MemNew(sizeof(FormatDB));
- MemCpy(tmp_fdbp, fdbp, sizeof(FormatDB));
-
- if(FormatDBClose(tmp_fdbp))
- return 9;
- options->volume++;
-
- /* When second volume is created, add suffix .00 to all
- first volume files */
- if (options->volume == 1)
- {
- Char oldnamebuf[FILENAME_MAX], newnamebuf[FILENAME_MAX];
- int len = StringLen(options->base_name) + 2;
- sprintf(oldnamebuf, "%s.%cin", options->base_name,
- fdbp->options->is_protein ? 'p' : 'n');
- sprintf(newnamebuf, "%s.00.%cin", options->base_name,
- fdbp->options->is_protein ? 'p' : 'n');
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- StringCpy(oldnamebuf + len, "hr");
- StringCpy(newnamebuf + len + 3, "hr");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- StringCpy(oldnamebuf + len, "sq");
- StringCpy(newnamebuf + len + 3, "sq");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- StringCpy(oldnamebuf + len, "nd");
- StringCpy(newnamebuf + len + 3, "nd");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- StringCpy(oldnamebuf + len, "ni");
- StringCpy(newnamebuf + len + 3, "ni");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- StringCpy(oldnamebuf + len, "sd");
- StringCpy(newnamebuf + len + 3, "sd");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- StringCpy(oldnamebuf + len, "si");
- StringCpy(newnamebuf + len + 3, "si");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- if (options->dump_info) {
- StringCpy(oldnamebuf + len, "di");
- StringCpy(newnamebuf + len + 3, "di");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- }
- if (options->is_protein) {
- /* PIG ISAM files */
- StringCpy(oldnamebuf + len, "pd");
- StringCpy(newnamebuf + len + 3, "pd");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- StringCpy(oldnamebuf + len, "pi");
- StringCpy(newnamebuf + len + 3, "pi");
- if (FileLength(oldnamebuf) > 0)
- FileRename(oldnamebuf, newnamebuf);
- }
+ if ( (retval = FDBCreateNewVolume(fdbp, *seq_data, SequenceLen, AmbCharPtr)))
+ return retval;
- MemFree(options->base_name);
- newnamebuf[len+1] = NULLB;
- options->base_name = StringSave(newnamebuf);
- }
-
- {
- CharPtr ptr;
- ptr = options->base_name + StringLen(options->base_name) - 2;
- sprintf(ptr, "%02ld", (long) options->volume);
- }
-
- if ((tmp_fdbp = FormatDBInit(options)) == NULL)
- return 2;
-
- MemCpy(fdbp, tmp_fdbp, sizeof(FormatDB));
- MemFree(tmp_fdbp);
- }
- } /* bases in volume > 0 */
assert(ftell(fdbp->fd_seq)+BSLen(*seq_data) + 1 + (AmbCharPtr==NULL?0:(*AmbCharPtr)&0x7fffffffUL) < 0x7fffffffUL );
fdbp->TotalLen += SequenceLen;
@@ -12105,3 +12178,24 @@ readdb_pig2oid(ReadDBFILEPtr rdfp, Int4 pig, Int4Ptr start)
return retval;
}
+
+static Boolean s_IsTextFile(const char* filename)
+{
+ FILE* fp = NULL;
+ Boolean retval = TRUE;
+ Int4 i = 0;
+
+ if ( !(fp = FileOpen(filename, "r"))) {
+ return FALSE;
+ }
+
+ for (i = 0; i < 10 && !feof(fp); i++) {
+ int c = getc(fp);
+ if ( ! (isprint(c) || isspace(c)) ) {
+ retval = FALSE;
+ break;
+ }
+ }
+ FileClose(fp);
+ return retval;
+}
diff --git a/tools/salign.c b/tools/salign.c
index c9c88051..662adc5d 100644
--- a/tools/salign.c
+++ b/tools/salign.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: salign.c,v 6.6 2003/05/30 17:25:37 coulouri Exp $";
+static char const rcsid[] = "$Id: salign.c,v 6.7 2003/12/29 21:45:37 coulouri Exp $";
/* salign.c
* ===========================================================================
@@ -395,7 +395,7 @@ static SeqAlignPtr SortBlastHits (SeqAlignPtr salp, Int4 threshold, Uint1 choice
Boolean goOn = TRUE;
Boolean ok;
- if (salp == NULL || choice < 0)
+ if (salp == NULL)
return salp;
sap = SeqAnnotForSeqAlign (salp);
sap2 = (SeqAnnotPtr) AsnIoMemCopy ((Pointer) sap, (AsnReadFunc) SeqAnnotAsnRead, (AsnWriteFunc) SeqAnnotAsnWrite);
diff --git a/tools/spidey.c b/tools/spidey.c
index 595796a3..ea80eb6a 100644
--- a/tools/spidey.c
+++ b/tools/spidey.c
@@ -1,4 +1,4 @@
-static char const rcsid[] = "$Id: spidey.c,v 6.64 2003/10/21 15:26:17 kans Exp $";
+static char const rcsid[] = "$Id: spidey.c,v 6.67 2003/12/12 21:25:26 kskatz Exp $";
/* ===========================================================================
*
@@ -30,13 +30,22 @@ static char const rcsid[] = "$Id: spidey.c,v 6.64 2003/10/21 15:26:17 kans Exp $
*
* Version Creation Date: 5/01
*
-* $Revision: 6.64 $
+* $Revision: 6.67 $
*
* File Description: mrna-to-genomic alignment algorithms and functions
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: spidey.c,v $
+* Revision 6.67 2003/12/12 21:25:26 kskatz
+* Fixed bug in SPI_CheckForPolyAExon() where multiple SeqAlignPtr's to the same object were not handled carefully: one of the ptr's was being accessed when the object was freed via the other ptr.
+*
+* Revision 6.66 2003/12/12 17:57:04 kskatz
+* Fixed a potential array bounds read error in SPI_CheckMrnaOrder()
+*
+* Revision 6.65 2003/12/10 16:53:22 kskatz
+* Ensured that 'ovl' when used is never negative once set in SPI_AdjustOverlaps() [see revision 6.57]
+*
* Revision 6.64 2003/10/21 15:26:17 kans
* fixed typo of SPI_IvalPt to SPI_IvalPtr
*
@@ -4325,18 +4334,22 @@ static void SPI_CheckForPolyAExon(SeqAlignPtr sap)
sap_target = amaip->saps[amaip->numsaps-1];
salp = (SeqAlignPtr)(sap->segs);
salp_prev = NULL;
- while (salp != NULL)
- {
- if (salp == sap_target)
- {
- if (salp_prev == NULL)
- sap->segs = (Pointer)(sap_target->next);
- else
- salp_prev->next = sap_target->next;
- SeqAlignFree(sap_target);
- }
- salp_prev = salp;
- salp = salp->next;
+ while (salp != NULL){
+ if (salp == sap_target){
+ if (salp_prev == NULL){
+ sap->segs = (Pointer)(sap_target->next);
+ }
+ else {
+ salp_prev->next = sap_target->next;
+ }
+ SeqAlignFree(sap_target);
+ sap_target = 0;
+ salp = 0;
+ }
+ else {
+ salp_prev = salp;
+ salp = salp->next;
+ }
}
AMAlignIndexFreeEitherIndex(sap);
AlnMgr2IndexLite(sap);
@@ -5812,7 +5825,7 @@ static void SPI_AdjustOverlaps(SeqAlignPtr sap1, SeqAlignPtr sap2, Int4 n, SPI_m
}
ovl = -ovl;
}
- ovl = MIN(abs(ovl), start2-stop1);
+ ovl = MIN(abs(ovl), abs(start2-stop1));
if (spot->interspecies == TRUE)
fluff = SPI_FLUFF;
else
@@ -5841,7 +5854,7 @@ static void SPI_AdjustOverlaps(SeqAlignPtr sap1, SeqAlignPtr sap2, Int4 n, SPI_m
}
i = 0;
buf = (Uint1Ptr)MemNew((2*fluff+ovl+spllen+2)*sizeof(Uint1));
- buf2 = (Uint1Ptr)MemNew((2*fluff+(abs(ovl))+spllen+2)*sizeof(Uint1));
+ buf2 = (Uint1Ptr)MemNew((2*fluff+ovl+spllen+2)*sizeof(Uint1));
SeqPortRead(spp, buf2, 2*fluff+ovl+spllen+2);
for (f=0; f<SPI_NUMSITES; f++)
{
@@ -10691,7 +10704,8 @@ static void SPI_CheckMrnaOrder(SPI_IvalPtr PNTR spi_pp, const int num)
for (x = 0, ival = spi_pp[x], ival2 = spi_pp[x + 1];
x < num && ival != 0 && ival2 != 0;
- ++x, ival = spi_pp[x], ival2 = spi_pp[x + 1]){
+ ++x, ival = spi_pp[x],
+ ival2 = (x + 1 < num ? spi_pp[x + 1] : 0)){
if (x < num - 2){ /* three to window */
ival3 = spi_pp[x + 2];
if ((ival->strand == Seq_strand_plus == ival2->strand
diff --git a/util/tables/raw_scoremat.c b/util/tables/raw_scoremat.c
index d0c4e47d..67cecf3c 100644
--- a/util/tables/raw_scoremat.c
+++ b/util/tables/raw_scoremat.c
@@ -1,4 +1,4 @@
-/* $Id: raw_scoremat.c,v 1.2 2003/10/02 15:37:34 ivanov Exp $
+/* $Id: raw_scoremat.c,v 1.3 2003/12/29 21:25:50 ucko Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -40,6 +40,7 @@
#include "sm_blosum80.c"
#include "sm_pam30.c"
#include "sm_pam70.c"
+#include "sm_pam250.c"
static const char kNCBIstdaa[] = "-ABCDEFGHIKLMNPQRSTVWXYZU*";
@@ -112,6 +113,9 @@ void NCBISM_Unpack(const SNCBIPackedScoreMatrix* psm,
/*
* ===========================================================================
* $Log: raw_scoremat.c,v $
+ * Revision 1.3 2003/12/29 21:25:50 ucko
+ * +PAM250
+ *
* Revision 1.2 2003/10/02 15:37:34 ivanov
* Get rid of compilation warnings
*
diff --git a/util/tables/raw_scoremat.h b/util/tables/raw_scoremat.h
index 434e4a0a..b2289436 100644
--- a/util/tables/raw_scoremat.h
+++ b/util/tables/raw_scoremat.h
@@ -1,7 +1,7 @@
#ifndef UTIL_TABLES___SCOREMAT__H
#define UTIL_TABLES___SCOREMAT__H
-/* $Id: raw_scoremat.h,v 1.1 2003/08/21 19:48:19 ucko Exp $
+/* $Id: raw_scoremat.h,v 1.2 2003/12/29 21:25:50 ucko Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -76,6 +76,7 @@ extern NCBI_TABLES_EXPORT const SNCBIPackedScoreMatrix NCBISM_Blosum62;
extern NCBI_TABLES_EXPORT const SNCBIPackedScoreMatrix NCBISM_Blosum80;
extern NCBI_TABLES_EXPORT const SNCBIPackedScoreMatrix NCBISM_Pam30;
extern NCBI_TABLES_EXPORT const SNCBIPackedScoreMatrix NCBISM_Pam70;
+extern NCBI_TABLES_EXPORT const SNCBIPackedScoreMatrix NCBISM_Pam250;
#ifdef __cplusplus
}
@@ -85,6 +86,9 @@ extern NCBI_TABLES_EXPORT const SNCBIPackedScoreMatrix NCBISM_Pam70;
* ===========================================================================
*
* $Log: raw_scoremat.h,v $
+* Revision 1.2 2003/12/29 21:25:50 ucko
+* +PAM250
+*
* Revision 1.1 2003/08/21 19:48:19 ucko
* Add tables library (shared with C) for raw score matrices, etc.
*
diff --git a/util/tables/sm_pam250.c b/util/tables/sm_pam250.c
new file mode 100644
index 00000000..4044224a
--- /dev/null
+++ b/util/tables/sm_pam250.c
@@ -0,0 +1,98 @@
+/* $Id: sm_pam250.c,v 1.1 2003/12/29 21:25:51 ucko Exp $
+* ===========================================================================
+*
+* PUBLIC DOMAIN NOTICE
+* National Center for Biotechnology Information
+*
+* This software/database is a "United States Government Work" under the
+* terms of the United States Copyright Act. It was written as part of
+* the author's official duties as a United States Government employee and
+* thus cannot be copyrighted. This software/database is freely available
+* to the public for use. The National Library of Medicine and the U.S.
+* Government have not placed any restriction on its use or reproduction.
+*
+* Although all reasonable efforts have been taken to ensure the accuracy
+* and reliability of the software and data, the NLM and the U.S.
+* Government do not and cannot warrant the performance or results that
+* may be obtained by using this software or data. The NLM and the U.S.
+* Government disclaim all warranties, express or implied, including
+* warranties of performance, merchantability or fitness for any particular
+* purpose.
+*
+* Please cite the author in any work or product based on this material.
+*
+* ===========================================================================
+*
+* Author: Aaron Ucko (via ./convert_scoremat.pl)
+*
+* File Description:
+* Protein alignment score matrices; shared between the two toolkits.
+*
+* ===========================================================================
+*/
+
+#include <util/tables/raw_scoremat.h>
+
+/* This matrix was produced by "pam" Version 1.0.7 [01-Feb-98] */
+/* using Dayhoff et al. (1978) mutability data. */
+/* PAM 250 substitution matrix, scale = ln(2)/3 = 0.231049 */
+/* Expected score = -0.844, Entropy = 0.354 bits */
+/* Lowest score = -8, Highest score = 17 */
+
+static const TNCBIScore s_Pam250PSM[24][24] = {
+ /* A, R, N, D, C, Q, E, G, H, I, L, K,
+ M, F, P, S, T, W, Y, V, B, Z, X, * */
+ /*A*/ { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1,
+ -1, -3, 1, 1, 1, -6, -3, 0, 0, 0, 0, -8 },
+ /*R*/ { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3,
+ 0, -4, 0, 0, -1, 2, -4, -2, -1, 0, -1, -8 },
+ /*N*/ { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1,
+ -2, -3, 0, 1, 0, -4, -2, -2, 2, 1, 0, -8 },
+ /*D*/ { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0,
+ -3, -6, -1, 0, 0, -7, -4, -2, 3, 3, -1, -8 },
+ /*C*/ { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5,
+ -5, -4, -3, 0, -2, -8, 0, -2, -4, -5, -3, -8 },
+ /*Q*/ { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1,
+ -1, -5, 0, -1, -1, -5, -4, -2, 1, 3, -1, -8 },
+ /*E*/ { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0,
+ -2, -5, -1, 0, 0, -7, -4, -2, 3, 3, -1, -8 },
+ /*G*/ { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2,
+ -3, -5, 0, 1, 0, -7, -5, -1, 0, 0, -1, -8 },
+ /*H*/ { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0,
+ -2, -2, 0, -1, -1, -3, 0, -2, 1, 2, -1, -8 },
+ /*I*/ { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2,
+ 2, 1, -2, -1, 0, -5, -1, 4, -2, -2, -1, -8 },
+ /*L*/ { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3,
+ 4, 2, -3, -3, -2, -2, -1, 2, -3, -3, -1, -8 },
+ /*K*/ { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5,
+ 0, -5, -1, 0, 0, -3, -4, -2, 1, 0, -1, -8 },
+ /*M*/ { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0,
+ 6, 0, -2, -2, -1, -4, -2, 2, -2, -2, -1, -8 },
+ /*F*/ { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5,
+ 0, 9, -5, -3, -3, 0, 7, -1, -4, -5, -2, -8 },
+ /*P*/ { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1,
+ -2, -5, 6, 1, 0, -6, -5, -1, -1, 0, -1, -8 },
+ /*S*/ { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0,
+ -2, -3, 1, 2, 1, -2, -3, -1, 0, 0, 0, -8 },
+ /*T*/ { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0,
+ -1, -3, 0, 1, 3, -5, -3, 0, 0, -1, 0, -8 },
+ /*W*/ { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3,
+ -4, 0, -6, -2, -5, 17, 0, -6, -5, -6, -4, -8 },
+ /*Y*/ { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4,
+ -2, 7, -5, -3, -3, 0, 10, -2, -3, -4, -2, -8 },
+ /*V*/ { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2,
+ 2, -1, -1, -1, 0, -6, -2, 4, -2, -2, -1, -8 },
+ /*B*/ { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1,
+ -2, -4, -1, 0, 0, -5, -3, -2, 3, 2, -1, -8 },
+ /*Z*/ { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0,
+ -2, -5, 0, 0, -1, -6, -4, -2, 2, 3, -1, -8 },
+ /*X*/ { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1,
+ -1, -2, -1, 0, 0, -4, -2, -1, -1, -1, -1, -8 },
+ /***/ { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
+ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, 1 }
+};
+const SNCBIPackedScoreMatrix NCBISM_Pam250 = {
+ "ARNDCQEGHILKMFPSTWYVBZX*",
+ s_Pam250PSM[0],
+ -8
+};
diff --git a/vibrant/image.c b/vibrant/image.c
index 12689d06..45d2537d 100644
--- a/vibrant/image.c
+++ b/vibrant/image.c
@@ -27,7 +27,7 @@
*
* Author: Alex Smirnov, Denis Vakatov
*
-* $Revision: 6.6 $
+* $Revision: 6.7 $
*
* File Description:
* Image(pixmap) processing.
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: image.c,v $
+* Revision 6.7 2003/11/17 17:03:29 kans
+* changed C++ style comments to C comments
+*
* Revision 6.6 2002/03/28 13:35:48 kans
* only include MoreCarbonAccessors.h if not OS_UNIX_DARWIN
*
@@ -365,8 +368,8 @@ Nlm_Boolean Nlm_AllocateImage ( Nlm_Image image, Nlm_Uint2Ptr width,
im->pixelMap->bounds.left = 0;
im->pixelMap->bounds.top = 0;
im->pixelMap->cmpSize = 8;
-// 2001-03-22: Joshua Juran
-// Evidently these two members don't exist in Carbon. So don't set them.
+ /* 2001-03-22: Joshua Juran */
+ /* Evidently these two members don't exist in Carbon. So don't set them. */
#if !TARGET_API_MAC_CARBON
im->pixelMap->planeBytes = 0;
im->pixelMap->pmReserved = 0;
diff --git a/vibrant/ncbidraw.c b/vibrant/ncbidraw.c
index 36ef9889..ec3f4209 100644
--- a/vibrant/ncbidraw.c
+++ b/vibrant/ncbidraw.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/91
*
-* $Revision: 6.35 $
+* $Revision: 6.36 $
*
* File Description:
* Vibrant drawing functions.
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbidraw.c,v $
+* Revision 6.36 2003/11/17 17:03:30 kans
+* changed C++ style comments to C comments
+*
* Revision 6.35 2003/03/19 21:13:22 kans
* protect UNIX version of ScrollRect
*
@@ -6311,8 +6314,8 @@ extern void Nlm_CopyPixmap ( Nlm_RectPtr r, Nlm_Int1Ptr source,
pixelMap->bounds.left = 0;
pixelMap->bounds.top = 0;
pixelMap->cmpSize = 8;
-// 2001-03-22: Joshua Juran
-// Evidently these two members don't exist in Carbon. So don't set them.
+ /* 2001-03-22: Joshua Juran */
+ /* Evidently these two members don't exist in Carbon. So don't set them. */
#if !TARGET_API_MAC_CARBON
pixelMap->planeBytes = 0;
pixelMap->pmReserved = 0;
@@ -6415,10 +6418,10 @@ extern void Nlm_SetUpDrawingTools (void)
Nlm_updateRgn = (Nlm_RegioN) (NewRgn ());
SetRectRgn ((Nlm_RgnTool) Nlm_updateRgn, -32768, -32768, 32767, 32767);
- //HLock ((Handle) Nlm_updateRgn);
+ /* HLock ((Handle) Nlm_updateRgn); */
GetRegionBounds(Nlm_updateRgn, &bounds);
Local__RectToolToRecT (&bounds, &Nlm_updateRect);
- //HUnlock ((Handle) Nlm_updateRgn);
+ /* HUnlock ((Handle) Nlm_updateRgn); */
Nlm_fontList = NULL;
Nlm_fontInUse = NULL;
diff --git a/vibrant/palette.c b/vibrant/palette.c
index c9638a03..68d4cd25 100644
--- a/vibrant/palette.c
+++ b/vibrant/palette.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/91
*
-* $Revision: 6.0 $
+* $Revision: 6.1 $
*
* File Description: Active graphics objects
*
@@ -40,6 +40,9 @@
*
*
* $Log: palette.c,v $
+* Revision 6.1 2003/11/07 16:02:30 rsmith
+* Renamed static function NewPalette to Nlm_NewPalette to avoid a name conflict on Mac.
+*
* Revision 6.0 1997/08/25 18:56:11 madden
* Revision changed to 6.0
*
@@ -314,7 +317,7 @@ static void PaletteClick (PaneL p, PoinT pt)
}
}
-static void NewPalette (PalettE p, Int2 minwid, PaletteProc actn)
+static void Nlm_NewPalette (PalettE p, Int2 minwid, PaletteProc actn)
{
PoinT npt;
@@ -348,7 +351,7 @@ static void ResetPalette (PaneL p)
if (pdata.drawHandles != NULL) {
HandFree (pdata.drawHandles);
}
- NewPalette ((PalettE) p, pdata.width, pdata.action);
+ Nlm_NewPalette ((PalettE) p, pdata.width, pdata.action);
}
extern PalettE PalettePanel (SlatE s, Int2 pixwidth, PaletteProc actn)
@@ -363,7 +366,7 @@ extern PalettE PalettePanel (SlatE s, Int2 pixwidth, PaletteProc actn)
p = (PalettE) CustomPanel (s, DrawPalette, sizeof (PaletteData), ResetPalette);
if (p != NULL) {
SetPanelClick ((PaneL) p, PaletteClick, NULL, NULL, NULL);
- NewPalette (p, pixwidth, actn);
+ Nlm_NewPalette (p, pixwidth, actn);
}
RestorePort (tempPort);
}
diff --git a/vibrant/vibbutns.c b/vibrant/vibbutns.c
index 47795182..4dde5b31 100644
--- a/vibrant/vibbutns.c
+++ b/vibrant/vibbutns.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/1/91
*
-* $Revision: 6.7 $
+* $Revision: 6.8 $
*
* File Description:
* Vibrant button functions
@@ -41,6 +41,9 @@
*
*
* $Log: vibbutns.c,v $
+* Revision 6.8 2004/01/20 23:34:38 sinyakov
+* [WIN_MSWIN]: fixed to display '&' character in button text
+*
* Revision 6.7 2002/03/07 19:18:21 kans
* check box wid += 4 for Aqua
*
@@ -970,6 +973,35 @@ LRESULT CALLBACK EXPORT ButtonProc (HWND hwnd, UINT message,
Nlm_currentWindowTool = tempHWnd;
return rsult;
}
+
+
+static void Nlm_PrepareTitleMsWin(Nlm_CharPtr temp, Nlm_CharPtr title,
+ size_t siztemp)
+{
+ /* duplicate existing '&' */
+ Nlm_Uint4 src_pos = 0;
+ Nlm_Uint4 dest_pos = 0;
+
+ for(src_pos = 0, dest_pos = 0;
+ title[src_pos] != '\0' && dest_pos+1 < siztemp;
+ ++src_pos)
+ {
+ if(title[src_pos] == '&')
+ {
+ if(dest_pos + 2 < siztemp)
+ {
+ temp[dest_pos++] = '&';
+ temp[dest_pos++] = title[src_pos];
+ }
+ else
+ break;
+ }
+ else
+ temp[dest_pos++] = title[src_pos];
+ }
+
+ temp[dest_pos] = '\0';
+}
#endif
#ifdef WIN_MOTIF
@@ -1057,7 +1089,11 @@ static void Nlm_NewButton (Nlm_ButtoN b, Nlm_CharPtr title,
Nlm_GetRect ((Nlm_GraphiC) b, &r);
wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) b);
+#ifdef WIN_MSWIN
+ Nlm_PrepareTitleMsWin (temp, title, sizeof (temp));
+#else
Nlm_StringNCpy_0 (temp, title, sizeof (temp));
+#endif
c = (Nlm_ControlTool) 0;
border = 0;
offset = 0;
diff --git a/vibrant/vibdefns.h b/vibrant/vibdefns.h
index 48d29fd3..3d83a0d5 100644
--- a/vibrant/vibdefns.h
+++ b/vibrant/vibdefns.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/1/91
*
-* $Revision: 6.9 $
+* $Revision: 6.12 $
*
* File Description:
* Vibrant alias definitions
@@ -37,6 +37,16 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: vibdefns.h,v $
+* Revision 6.12 2004/01/05 17:11:20 kans
+* added defines for functions to control dual monitor usage
+*
+* Revision 6.11 2003/10/30 17:32:16 kans
+* removed define for SetTextColor, which was conflicting with Win32 symbol
+*
+* Revision 6.10 2003/10/29 19:10:00 bazhin
+* Added function Nlm_SetTextColor(Nlm_TexT t, Nlm_Uint4 r, Nlm_Uint4 g,
+* Nlm_Uint4 b).
+*
* Revision 6.9 2002/01/09 15:23:54 kans
* added HasAquaMenuLayout
*
@@ -252,6 +262,11 @@ extern "C" {
#define SetWindowExtra Nlm_SetWindowExtra
#define GetWindowExtra Nlm_GetWindowExtra
+#define HasDualScreen Nlm_HasDualScreen
+#define UseFullScreen Nlm_UseFullScreen
+#define UseLeftScreen Nlm_UseLeftScreen
+#define UseRightScreen Nlm_UseRightScreen
+
#define NormalGroup Nlm_NormalGroup
#define HiddenGroup Nlm_HiddenGroup
#define SetGroupMargins Nlm_SetGroupMargins
diff --git a/vibrant/vibforms.c b/vibrant/vibforms.c
index ab716df0..fe2afc30 100644
--- a/vibrant/vibforms.c
+++ b/vibrant/vibforms.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.12 $
+* $Revision: 6.13 $
*
* File Description:
*
@@ -40,6 +40,9 @@
*
*
* $Log: vibforms.c,v $
+* Revision 6.13 2004/01/16 22:35:37 kans
+* added WidestString and WidestAlist
+*
* Revision 6.12 2002/01/09 15:11:23 kans
* SetEnumPopupEx and SetEnumPopupByNameEx to suppress error if 0 or NULL initial value, called by dialog creators
*
@@ -1218,6 +1221,30 @@ extern Int2 MaxStringWidths (CharPtr PNTR strs)
return (max + 2);
}
+extern CharPtr WidestString (CharPtr PNTR strs)
+
+{
+ Int2 i;
+ Int2 len;
+ Int2 max;
+ CharPtr str;
+
+ str = NULL;
+ max = 0;
+ if (strs != NULL) {
+ i = 0;
+ while (strs [i] != NULL) {
+ len = StringWidth (strs [i]);
+ if (len > max) {
+ max = len;
+ str = strs [i];
+ }
+ i++;
+ }
+ }
+ return str;
+}
+
extern Int2 MaxAlistWidths (EnumFieldAssocPtr al)
{
@@ -1246,6 +1273,28 @@ extern Int2 MaxAlistWidths (EnumFieldAssocPtr al)
return max;
}
+extern CharPtr WidestAlist (EnumFieldAssocPtr al)
+
+{
+ Int2 i;
+ Int2 len;
+ Int2 max;
+ CharPtr str;
+
+ str = NULL;
+ max = 0;
+ if (al != NULL) {
+ for (i = 1; al->name != NULL; i++, al++) {
+ len = StringWidth (al->name);
+ if (len > max) {
+ max = len;
+ str = al->name;
+ }
+ }
+ }
+ return str;
+}
+
extern GrouP MultiLinePromptEx (GrouP prnt, CharPtr text, Int2 maxWidth, FonT font, Boolean stripSpaces)
{
diff --git a/vibrant/vibforms.h b/vibrant/vibforms.h
index cd5451d2..657031bc 100644
--- a/vibrant/vibforms.h
+++ b/vibrant/vibforms.h
@@ -29,13 +29,16 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.8 $
+* $Revision: 6.9 $
*
* File Description:
*
* Modifications:
* --------------------------------------------------------------------------
* $Log: vibforms.h,v $
+* Revision 6.9 2004/01/16 22:35:38 kans
+* added WidestString and WidestAlist
+*
* Revision 6.8 2002/08/07 18:13:42 kans
* G/SetPrimitiveIDs, itemID is Uint4
*
@@ -204,7 +207,9 @@ extern Nlm_CharPtr Nlm_SaveStringFromText (Nlm_TexT t);
extern ValNodePtr Nlm_SetTextFromVnp (Nlm_TexT t, ValNodePtr vnp);
extern ValNodePtr Nlm_GetVnpFromText (Nlm_TexT t, ValNodePtr vnp, Nlm_Boolean last);
extern Nlm_Int2 Nlm_MaxStringWidths (Nlm_CharPtr PNTR strs);
+extern Nlm_CharPtr Nlm_WidestString (Nlm_CharPtr PNTR strs);
extern Nlm_Int2 Nlm_MaxAlistWidths (Nlm_EnumFieldAssocPtr al);
+extern Nlm_CharPtr Nlm_WidestAlist (Nlm_EnumFieldAssocPtr al);
extern Nlm_GrouP Nlm_MultiLinePrompt (Nlm_GrouP prnt, Nlm_CharPtr text, Nlm_Int2 maxWidth, Nlm_FonT font);
extern Nlm_GrouP Nlm_MultiLinePromptEx (Nlm_GrouP prnt, Nlm_CharPtr text, Nlm_Int2 maxWidth, Nlm_FonT font, Nlm_Boolean stripSpaces);
@@ -513,7 +518,9 @@ extern Nlm_CharPtr Nlm_ExtractTagListColumn (Nlm_CharPtr source, Nlm_Int2 col);
#define SetTextFromVnp Nlm_SetTextFromVnp
#define GetVnpFromText Nlm_GetVnpFromText
#define MaxStringWidths Nlm_MaxStringWidths
+#define WidestString Nlm_WidestString
#define MaxAlistWidths Nlm_MaxAlistWidths
+#define WidestAlist Nlm_WidestAlist
#define MultiLinePrompt Nlm_MultiLinePrompt
#define MultiLinePromptEx Nlm_MultiLinePromptEx
#define JustInvalObject Nlm_JustInvalObject
diff --git a/vibrant/vibmenus.c b/vibrant/vibmenus.c
index f0e66410..b83ebb1a 100644
--- a/vibrant/vibmenus.c
+++ b/vibrant/vibmenus.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/1/91
*
-* $Revision: 6.16 $
+* $Revision: 6.18 $
*
* File Description:
* Vibrant menu functions
@@ -37,6 +37,12 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: vibmenus.c,v $
+* Revision 6.18 2004/01/20 23:35:38 sinyakov
+* [WIN_MSWIN] implemented menu accelerators
+*
+* Revision 6.17 2003/11/17 17:03:30 kans
+* changed C++ style comments to C comments
+*
* Revision 6.16 2003/03/27 19:35:43 kans
* Nlm_PrepareTitle removes non-Mac accelerator from Mac menu item
*
@@ -822,7 +828,7 @@ static void Nlm_DeskAccProc (Nlm_ChoicE c)
{
#if TARGET_API_MAC_CARBON >= 1
- // Carbon will create, fill, and handle everything in the Apple menu
+ /* Carbon will create, fill, and handle everything in the Apple menu */
return;
#else
Nlm_MenuTool h;
@@ -3920,6 +3926,172 @@ static void Nlm_AddTitleAccel(Widget w, Nlm_CharPtr title, Nlm_Int4 flags)
}
#endif /* WIN_MOTIF */
+#ifdef WIN_MSWIN
+
+extern Nlm_Handle Nlm_GetWindowHAccel (Nlm_WindoW w);
+extern void Nlm_SetWindowHAccel (Nlm_WindoW w, Nlm_Handle h);
+
+static void Nlm_AddAccel(Nlm_MenU m, Nlm_Int2 id, Nlm_Char key)
+{
+ HACCEL haccel = NULL; /* handle to accelerator table */
+
+ int i; /* loop counter */
+ LPACCEL lpaccelNew; /* pointer to new accelerator table */
+ HACCEL haccelOld; /* handle to old accelerator table */
+ int nAccelerators; /* number of accelerators in table */
+
+ BYTE fAccelFlags; /* accelerator flags */
+
+ Nlm_WindoW w; /* top-level window that contains the menu */
+
+ if(key == 0)
+ /* no accelerator key specified */
+ return;
+
+ if(IS_ALPHA(key))
+ {
+ fAccelFlags = FCONTROL;
+ key = TO_UPPER(key) - 'A' + 1;
+ }
+ else
+ if(IS_DIGIT(key))
+ {
+ fAccelFlags = FCONTROL | FVIRTKEY;
+ }
+ else
+ /* key is not supported */
+ return;
+
+ /* Get top-level window */
+ w = Nlm_GetParentWindow((Nlm_GraphiC)m);
+ if(w == NULL)
+ /* failure */
+ return;
+
+ haccel = Nlm_GetWindowHAccel(w);
+
+ /* Save the current accelerator table. */
+
+ haccelOld = haccel;
+
+ /* Count the number of entries in the current
+ table, allocate a buffer for the table, and
+ then copy the table into the buffer,
+ reserving space for a new accelerator */
+
+ if(haccelOld)
+ nAccelerators = CopyAcceleratorTable(haccelOld, NULL, 0);
+ else
+ nAccelerators = 0;
+
+ lpaccelNew = (LPACCEL) Nlm_MemNew((nAccelerators + 1) * sizeof(ACCEL));
+ if(lpaccelNew == NULL)
+ /* failure */
+ return;
+
+ if(lpaccelNew != NULL && nAccelerators)
+ CopyAcceleratorTable(haccel, lpaccelNew, nAccelerators);
+
+ /* Find the accelerator that the user modified
+ and change its flags and virtual-key code
+ as appropriate. */
+
+ for(i = 0; i < nAccelerators; ++i)
+ {
+ if(lpaccelNew[i].cmd == (WORD) id ||
+ (lpaccelNew[i].fVirt == fAccelFlags &&
+ lpaccelNew[i].key == key))
+ break;
+ }
+
+ lpaccelNew[i].cmd = id;
+ lpaccelNew[i].fVirt = fAccelFlags;
+ lpaccelNew[i].key = key;
+
+ if(i == nAccelerators)
+ /* new accelerator added */
+ ++nAccelerators;
+
+ /* Create the new accelerator table, and
+ destroy the old one. */
+
+ if(haccelOld)
+ DestroyAcceleratorTable(haccelOld);
+ haccel = CreateAcceleratorTable(lpaccelNew, nAccelerators);
+
+ Nlm_SetWindowHAccel(w, haccel);
+
+ Nlm_MemFree(lpaccelNew);
+}
+
+
+static void Nlm_PrepareTitleMsWin(Nlm_CharPtr temp, Nlm_CharPtr title,
+ size_t siztemp, Nlm_CharPtr paccel,
+ Nlm_Boolean isMenu)
+{
+ /* duplicate existing '&',
+ mark mnemo char with single '&',
+ add accelerator description */
+
+ Nlm_Char accel = '\0';
+ Nlm_Char mnemo = '\0';
+ Nlm_Uint4 mnemo_pos = 0;
+ Nlm_Uint4 src_pos = 0;
+ Nlm_Uint4 dest_pos = 0;
+
+ Nlm_TitleGetAccel(temp, &accel, &mnemo, &mnemo_pos);
+
+ if(isMenu)
+ accel = '\0';
+
+ if(paccel != NULL)
+ *paccel = accel;
+
+ for(src_pos = 0, dest_pos = 0;
+ title[src_pos] != '\0' && dest_pos+1 < siztemp;
+ ++src_pos)
+ {
+ if(mnemo && src_pos == mnemo_pos)
+ {
+ if(dest_pos + 2 < siztemp)
+ {
+ temp[dest_pos++] = '&';
+ temp[dest_pos++] = title[src_pos];
+ }
+ else
+ break;
+ }
+ else
+ if(title[src_pos] == '&')
+ {
+ if(dest_pos + 2 < siztemp)
+ {
+ temp[dest_pos++] = '&';
+ temp[dest_pos++] = title[src_pos];
+ }
+ else
+ break;
+ }
+ else
+ if(title[src_pos] == '/')
+ break;
+ else
+ temp[dest_pos++] = title[src_pos];
+ }
+
+ temp[dest_pos] = '\0';
+
+ if(accel != '\0' && dest_pos + 7 < siztemp)
+ {
+ Nlm_StrCpy(temp+dest_pos, "\tCtrl- ");
+ if(IS_ALPHA(accel))
+ temp[dest_pos+6] = TO_UPPER(accel);
+ else
+ temp[dest_pos+6] = accel;
+ }
+}
+#endif /* WIN_MSWIN */
+
static void Nlm_PrepareTitle(Nlm_CharPtr temp, Nlm_CharPtr title,
size_t siztemp, Nlm_Boolean isMenu)
@@ -3937,21 +4109,6 @@ static void Nlm_PrepareTitle(Nlm_CharPtr temp, Nlm_CharPtr title,
}
}}
#endif
-
-#ifdef WIN_MSWIN
- {{
- Nlm_Char mnemo;
- Nlm_Uint4 pos;
-
- if (Nlm_TitleGetAccel(temp, NULL, &mnemo, &pos) && mnemo)
- { /* temp := title[ 0..poslet-1 ] + '&' + title[ poslet..END ] */
- Nlm_StringNCpy_0(temp+pos+1, title+pos, siztemp-pos-1);
- temp[pos] = '&';
- }
-
- Nlm_StripTitleAccel( temp );
- }}
-#endif
}
@@ -3988,9 +4145,14 @@ static Nlm_ItemTool Nlm_AppendItems(Nlm_MenU m, Nlm_IteM i,
#endif
#ifdef WIN_MSWIN
+ {{
+ Nlm_Char accel;
+ Nlm_PrepareTitleMsWin(temp, itemNames, sizeof(temp), &accel, FALSE);
AppendMenu(h, MF_ENABLED, nextMenuNum, temp);
+ Nlm_AddAccel(m, nextMenuNum, accel);
if (nextMenuNum < 32767)
nextMenuNum++;
+ }}
#endif
#ifdef WIN_MOTIF
@@ -4820,6 +4982,7 @@ static void Nlm_NewPopup (Nlm_MenU m, Nlm_CharPtr title, Nlm_RectPtr r)
mb = (Nlm_MenuBaR) Nlm_GetParent ((Nlm_GraphiC) m);
mbh = Nlm_GetMenuBarHandle( mb );
h = CreateMenu();
+ Nlm_PrepareTitleMsWin(temp, title, sizeof (temp), NULL, TRUE);
AppendMenu(mbh, MF_POPUP | MF_ENABLED, (UINT)h, temp);
#endif
@@ -5525,6 +5688,7 @@ extern Nlm_MenU Nlm_SubMenu (Nlm_MenU m, Nlm_CharPtr title)
&r, sizeof(Nlm_ItemRec), subItemProcs);
if (i != NULL) {
#ifdef WIN_MSWIN
+ Nlm_PrepareTitleMsWin(temp, title, sizeof(temp), NULL, TRUE);
Nlm_NewSubMenuAndItem(i, sub, temp);
#else /* WIN_MOTIF */
Nlm_NewCascadingMenu(m, i, sub, temp);
diff --git a/vibrant/vibprocs.h b/vibrant/vibprocs.h
index c77bc799..8287c03e 100644
--- a/vibrant/vibprocs.h
+++ b/vibrant/vibprocs.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/1/91
*
-* $Revision: 6.21 $
+* $Revision: 6.23 $
*
* File Description:
* Vibrant procedure definitions
@@ -37,6 +37,12 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: vibprocs.h,v $
+* Revision 6.23 2004/01/05 17:08:09 kans
+* added functions to control use of dual screens
+*
+* Revision 6.22 2003/10/29 19:19:34 kans
+* added prototype for Nlm_SetTextColor
+*
* Revision 6.21 2002/04/30 18:25:12 bazhin
* Added function "Nlm_SetWindowConfigureCallback(WindoW w)", which
* allows to catch events, when window just moved without resizing.
@@ -335,6 +341,14 @@ Nlm_VoidPtr Nlm_GetWindowExtra PROTO((Nlm_WindoW w));
void Nlm_SetWindowConfigureCallback PROTO((Nlm_WindoW w));
+/* Dual screen functions control centering where the window left parameter is negative */
+
+Nlm_Boolean Nlm_HasDualScreen (void);
+void Nlm_UseFullScreen (void);
+void Nlm_UseLeftScreen (void);
+void Nlm_UseRightScreen (void);
+
+
/*** GROUPING OBJECT ***/
/*
@@ -537,6 +551,7 @@ size_t Nlm_TextLength PROTO((Nlm_TexT t));
void Nlm_SelectText PROTO((Nlm_TexT t, Nlm_Int2 begin, Nlm_Int2 end));
void Nlm_SetTextEditable PROTO((Nlm_TexT t, Nlm_Boolean editable));
void Nlm_SetTextCursorBlinkRate PROTO((Nlm_TexT t, Nlm_Int2 msec));
+void Nlm_SetTextColor PROTO((Nlm_TexT t, Nlm_Uint4 r, Nlm_Uint4 g, Nlm_Uint4 b));
/* return the new insertion position in the text(it may differ from "pos"
* if an error occured or "pos" is out of limits)
diff --git a/vibrant/vibtexts.c b/vibrant/vibtexts.c
index 79db447b..8d142f4d 100644
--- a/vibrant/vibtexts.c
+++ b/vibrant/vibtexts.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/1/91
*
-* $Revision: 6.14 $
+* $Revision: 6.17 $
*
* File Description:
* Vibrant edit text functions
@@ -37,6 +37,16 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: vibtexts.c,v $
+* Revision 6.17 2003/11/17 17:03:30 kans
+* changed C++ style comments to C comments
+*
+* Revision 6.16 2003/11/03 21:51:34 sinyakov
+* WIN_MSWIN: bugfix: strlen(title) moved out of loop condition
+*
+* Revision 6.15 2003/10/29 19:10:08 bazhin
+* Added function Nlm_SetTextColor(Nlm_TexT t, Nlm_Uint4 r, Nlm_Uint4 g,
+* Nlm_Uint4 b).
+*
* Revision 6.14 2003/07/30 13:51:42 johnson
* MSWIN: multi-line text boxes now respond to 'enter' key
*
@@ -1790,6 +1800,7 @@ static void Nlm_SetScrollText (Nlm_GraphiC t, Nlm_Int2 item,
#endif
#ifdef WIN_MSWIN
Nlm_Uint4 count;
+ Nlm_Uint4 len;
Nlm_CharPtr tmp, newTitle;
#endif
@@ -1822,9 +1833,10 @@ static void Nlm_SetScrollText (Nlm_GraphiC t, Nlm_Int2 item,
if (count == 0)
SetWindowText (h, title);
else { /* replace UNIX <lf> with DOS <cr><lf> */
- newTitle = (Nlm_CharPtr) MemNew(strlen(title)+count+1);
+ len = Nlm_StringLen (title);
+ newTitle = (Nlm_CharPtr) MemNew(len+count+1);
tmp = newTitle;
- for (count=0; count < strlen(title); ++count) {
+ for (count=0; count < len; ++count) {
if (title[count] == '\n' && (count == 0 || title[count-1] != '\r'))
*tmp++ = '\r';
*tmp++ = title[count];
@@ -1963,31 +1975,31 @@ extern Nlm_TexT Nlm_CurrentText (void)
static void Clipboard_TEToDeskScrap()
{
OSErr err;
- // Copy the TE scrap to the desk scrap.
+ /* Copy the TE scrap to the desk scrap. */
err = TEToScrap();
}
static void Clipboard_TECut(TEHandle inTE)
{
- // Cut the text into the TE scrap.
+ /* Cut the text into the TE scrap. */
TECut(inTE);
- // Update the desk scrap.
+ /* Update the desk scrap. */
Clipboard_TEToDeskScrap();
}
static void Clipboard_TECopy(TEHandle inTE)
{
- // Copy the text into the TE scrap.
+ /* Copy the text into the TE scrap. */
TECopy(inTE);
- // Update the desk scrap.
+ /* Update the desk scrap. */
Clipboard_TEToDeskScrap();
}
static void Clipboard_TEPaste(TEHandle inTE)
{
-//#if TARGET_API_MAC_CARBON
- //ScrapRef scrap;
- //OSStatus status = GetCurrentScrap(&scrap);
+ /* #if TARGET_API_MAC_CARBON */
+ /* ScrapRef scrap; */
+ /* OSStatus status = GetCurrentScrap(&scrap); */
OSErr err = TEFromScrap();
TEPaste(inTE);
}
@@ -3977,3 +3989,20 @@ extern void Nlm_SetTextCursorBlinkRate(Nlm_TexT t, Nlm_Int2 msec)
#endif
return;
}
+
+extern void Nlm_SetTextColor(Nlm_TexT t, Nlm_Uint4 r, Nlm_Uint4 g, Nlm_Uint4 b)
+{
+#ifdef WIN_MOTIF
+ Nlm_TextTool h;
+ Arg args[2];
+
+ if(t == NULL)
+ return;
+ h = Nlm_GetTextHandle(t);
+ if(h == NULL)
+ return;
+ XtSetArg(args[0], XmNforeground, Nlm_GetColorRGB(r, g, b));
+ XtSetValues(h, args, 1);
+#endif
+ return;
+}
diff --git a/vibrant/vibutils.c b/vibrant/vibutils.c
index e414f523..f0992619 100644
--- a/vibrant/vibutils.c
+++ b/vibrant/vibutils.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/1/91
*
-* $Revision: 6.55 $
+* $Revision: 6.57 $
*
* File Description:
* Vibrant miscellaneous functions
@@ -37,6 +37,12 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: vibutils.c,v $
+* Revision 6.57 2003/11/17 17:03:30 kans
+* changed C++ style comments to C comments
+*
+* Revision 6.56 2003/11/07 16:06:58 rsmith
+* Changed Mac printing system calls from deprecated ones to modern ones primarily to ease building with precompiled headers.
+*
* Revision 6.55 2003/05/05 12:38:07 rsmith
* casts to make call to RegQueryValueEx safer in Nlm_GetExecPath. Needed by Codewarrior when compiling to Win32.
*
@@ -391,27 +397,25 @@ either.
*/
#include <ncbilcl.h>
-#include <vibtypes.h>
-#include <vibprocs.h>
-#include <vibincld.h>
-#include <ncbiport.h>
#ifdef WIN_MAC
-# include <Navigation.h>
# if TARGET_API_MAC_CARBON
-// Use non-session APIs of the Carbon Printing Manager, for easy porting
-#ifdef PM_USE_SESSION_APIS
-#undef PM_USE_SESSION_APIS
-#endif
-# define PM_USE_SESSION_APIS 0
+/* Use non-session APIs of the Carbon Printing Manager, for easy porting */
# include <PMApplication.h>
# include <FullPath.h>
# endif
# ifdef OS_UNIX_DARWIN
# include <LaunchServices.h>
# endif
+# include <Navigation.h>
#endif
+#include <vibtypes.h>
+#include <vibprocs.h>
+#include <vibincld.h>
+#include <ncbiport.h>
+
+
#ifdef WIN_MOTIF
#include <sys/times.h>
#include <limits.h>
@@ -455,6 +459,8 @@ static Nlm_BoxData recentBoxData;
#ifdef WIN_MAC
# if TARGET_API_MAC_CARBON
+static PMPrintSession printSession;
+
static PMPageFormat pageFormat = kPMNoPageFormat;
static PMPrintSettings printSettings = kPMNoPrintSettings;
static PMPrintContext thePrintingPort = kPMNoReference;
@@ -3961,29 +3967,38 @@ static void Nlm_SetupPrinterDeviceContext(HDC prHDC)
#ifdef WIN_MAC
# if TARGET_API_MAC_CARBON
+
extern Nlm_WindoW Nlm_StartPrinting (void)
{
OSStatus status;
Boolean accepted;
- status = PMBegin();
+/* status = PMBegin(); */
+ status = PMCreateSession(&printSession);
if (status != noErr) return NULL;
- status = PMNewPageFormat(&pageFormat);
+/* status = PMNewPageFormat(&pageFormat); */
+ status = PMCreatePageFormat(&pageFormat);
if (status != noErr || pageFormat == kPMNoPageFormat) return NULL;
- status = PMDefaultPageFormat(pageFormat);
+/* status = PMDefaultPageFormat(pageFormat); */
+ status = PMSessionDefaultPageFormat(printSession, pageFormat);
if (status != noErr) return NULL;
- status = PMPageSetupDialog(pageFormat, &accepted);
+/* status = PMPageSetupDialog(pageFormat, &accepted); */
+ status = PMSessionPageSetupDialog(printSession, pageFormat, &accepted);
if (status != noErr) return NULL;
- status = PMNewPrintSettings(&printSettings);
+/* status = PMNewPrintSettings(&printSettings); */
+ status = PMCreatePrintSettings(&printSettings);
if (status != noErr || printSettings == kPMNoPrintSettings) return NULL;
- status = PMDefaultPrintSettings(printSettings);
+/* status = PMDefaultPrintSettings(printSettings); */
+ status = PMSessionDefaultPrintSettings (printSession, printSettings);
if (status != noErr) return NULL;
- status = PMPrintDialog(printSettings, pageFormat, &accepted);
+/* status = PMPrintDialog(printSettings, pageFormat, &accepted); */
+ status = PMSessionPrintDialog(printSession, printSettings, pageFormat, &accepted);
if (!accepted) status = kPMCancel;
if (status != noErr) return NULL;
- status = PMBeginDocument(printSettings, pageFormat, &thePrintingPort);
- if ((status != noErr) || (thePrintingPort == kPMNoReference)) return NULL;
+/* status = PMBeginDocument(printSettings, pageFormat, &thePrintingPort); */
+ status = PMSessionBeginDocument(printSession, printSettings, pageFormat);
+ if (status != noErr) return NULL;
return Nlm_CurrentWindow();
}
@@ -4091,35 +4106,28 @@ extern void Nlm_EndPrinting (Nlm_WindoW w)
Nlm_nowPrinting = FALSE;
if (w != NULL) {
- (void)PMEndDocument(thePrintingPort);
- status = PMError();
+ status = PMSessionError(printSession);
if (status != noErr) {
- Nlm_Message (MSG_ERROR, "PMEndDocument error %d", status);
- }
-// This call is not supported under Carbon, need to figure out
-// how Apple wants us to deal with this ... churchill 12/28/99
-#if 0
- PrPicFile (prHdl, 0L, 0L, 0L, &prStat);
- prerr = PrError ();
- if (prerr != noErr) {
- Nlm_Message (MSG_ERROR, "PrPicFile error %d", prerr);
+ Nlm_Message (MSG_ERROR, "PM Session error %d", status);
}
- prPort = NULL;
- Nlm_UseWindow (w);
-#endif
+ /* (void)PMEndDocument(thePrintingPort); */
+ PMSessionEndDocument (printSession);
}
if (pageFormat != kPMNoPageFormat) {
- (void)PMDisposePageFormat(pageFormat);
+ /* (void)PMDisposePageFormat(pageFormat); */
+ PMRelease(pageFormat);
pageFormat = kPMNoPageFormat;
}
if (printSettings != kPMNoPrintSettings) {
- (void)PMDisposePrintSettings(printSettings);
+ /* (void)PMDisposePrintSettings(printSettings); */
+ PMRelease(printSettings);
printSettings = kPMNoPrintSettings;
}
- (void)PMEnd();
+ /* (void)PMEnd(); */
+ PMRelease(printSession);
}
-# else // not TARGET_API_MAC_CARBON
+# else /* not TARGET_API_MAC_CARBON */
extern void Nlm_EndPrinting (Nlm_WindoW w)
{
@@ -4132,8 +4140,8 @@ extern void Nlm_EndPrinting (Nlm_WindoW w)
if (prerr != noErr) {
Nlm_Message (MSG_ERROR, "PrCloseDoc error %d", prerr);
}
-// This call is not supported under Carbon, need to figure out
-// how Apple wants us to deal with this ... churchill 12/28/99
+ /* This call is not supported under Carbon, need to figure out
+ how Apple wants us to deal with this ... churchill 12/28/99 */
PrPicFile (prHdl, 0L, 0L, 0L, &prStat);
prerr = PrError ();
if (prerr != noErr) {
@@ -4363,8 +4371,9 @@ extern Nlm_Boolean Nlm_StartPage (void)
{
OSStatus status;
- status = PMBeginPage(thePrintingPort, NULL);
- if (status != noErr) return false; // ??
+/* status = PMBeginPage(thePrintingPort, NULL); */
+ status = PMSessionBeginPage(printSession, pageFormat, NULL);
+ if (status != noErr) return false; /* ?? */
return true;
}
@@ -4432,8 +4441,9 @@ extern Nlm_Boolean Nlm_EndPage (void)
{
OSStatus status;
- status = PMEndPage(thePrintingPort);
- if (status != noErr) return false; // ??
+/* status = PMEndPage(thePrintingPort); */
+ status = PMSessionEndPage(printSession);
+ if (status != noErr) return false; /* ?? */
return true;
}
@@ -4502,10 +4512,12 @@ static OSType Nlm_GetOSType (Nlm_CharPtr str, OSType dfault)
return rsult;
}
-// 2001-03-22: Joshua Juran
-// Working directory records are gone in Carbon.
-// However, so is Standard File. The code which calls Nav Services instead of SF
-// doesn't need this function, so we don't define it.
+/*
+ 2001-03-22: Joshua Juran
+ Working directory records are gone in Carbon.
+ However, so is Standard File. The code which calls Nav Services instead of SF
+ doesn't need this function, so we don't define it.
+*/
# if !TARGET_API_MAC_CARBON
static void Nlm_GetFilePath (Nlm_Int2 currentVol, Nlm_CharPtr path, size_t maxsize)
@@ -4773,14 +4785,14 @@ static Nlm_Boolean Nlm_NavServGetInputFileName (Nlm_CharPtr fileName, size_t max
filterProc = NewNavObjectFilterUPP(MyNavFilterProc);
}
- // Specify default options for dialog box
+ /* Specify default options for dialog box */
anErr = NavGetDefaultDialogOptions(&dialogOptions);
if (anErr == noErr)
{
- // Adjust the options to fit our needs
- // Set this option
+ /* Adjust the options to fit our needs */
+ /* Set this option */
dialogOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
- // Clear this one
+ /* Clear this one */
dialogOptions.dialogOptionFlags ^= kNavAllowPreviews;
anErr = AECreateDesc(typeFSS, &fss,
@@ -4788,8 +4800,8 @@ static Nlm_Boolean Nlm_NavServGetInputFileName (Nlm_CharPtr fileName, size_t max
&defaultLocation );
if (anErr == noErr)
{
- // Get 'open' resource. A nil handle being returned is OK,
- // this simply means no automatic file filtering.
+ /* Get 'open' resource. A nil handle being returned is OK,
+ this simply means no automatic file filtering. */
NavTypeListHandle typeList = (NavTypeListHandle)GetResource(
'open', 128);
NavReplyRecord reply;
@@ -4799,7 +4811,7 @@ static Nlm_Boolean Nlm_NavServGetInputFileName (Nlm_CharPtr fileName, size_t max
typeList, 0);
if (anErr == noErr && reply.validRecord)
{
- // Deal with multiple file selection
+ /* Deal with multiple file selection */
long count;
anErr = AECountItems(&(reply.selection), &count);
@@ -4830,7 +4842,7 @@ static Nlm_Boolean Nlm_NavServGetInputFileName (Nlm_CharPtr fileName, size_t max
}
}
}
- // Dispose of NavReplyRecord, resources, descriptors
+ /* Dispose of NavReplyRecord, resources, descriptors */
anErr = NavDisposeReply(&reply);
}
if (typeList != NULL)
@@ -5120,10 +5132,10 @@ static Nlm_Boolean Nlm_NavServGetOutputFileName (Nlm_CharPtr fileName, size_t ma
anErr = NavGetDefaultDialogOptions (&dialogOptions);
if (anErr == noErr)
{
- // Adjust the options to fit our needs
- // Set this option
+ /* Adjust the options to fit our needs */
+ /* Set this option */
dialogOptions.dialogOptionFlags |= kNavNoTypePopup;
- // Clear this one
+ /* Clear this one */
dialogOptions.dialogOptionFlags ^= kNavAllowStationery;
anErr = AECreateDesc(typeFSS, &fss,
@@ -5131,7 +5143,7 @@ static Nlm_Boolean Nlm_NavServGetOutputFileName (Nlm_CharPtr fileName, size_t ma
&defaultLocation );
if (anErr == noErr) {
- // One way to get the name for the file to be saved.
+ /* One way to get the name for the file to be saved. */
Nlm_StringNCpy_0 ((Nlm_CharPtr) dialogOptions.savedFileName, dfault, 255);
Nlm_CtoPstr ((Nlm_CharPtr) dialogOptions.savedFileName);
@@ -5153,10 +5165,12 @@ static Nlm_Boolean Nlm_NavServGetOutputFileName (Nlm_CharPtr fileName, size_t ma
{
if (reply.replacing)
{
- // Make sure you save a temporary file
- // so you can check for problems before replacing
- // an existing file. Once the save is confirmed,
- // swap the files and delete the original.
+ /*
+ Make sure you save a temporary file
+ so you can check for problems before replacing
+ an existing file. Once the save is confirmed,
+ swap the files and delete the original.
+ */
Nlm_ConvertFilename (&documentFSSpec, filename);
Nlm_StringNCpy_0 (fileName, filename, maxsize);
rsult = TRUE;
@@ -5170,7 +5184,7 @@ static Nlm_Boolean Nlm_NavServGetOutputFileName (Nlm_CharPtr fileName, size_t ma
if ( anErr == noErr)
{
- // DO NOT call NavCompleteSave() to complete
+ /* DO NOT call NavCompleteSave() to complete */
/* anErr = NavCompleteSave(&reply,
kNavTranslateInPlace); */
}
diff --git a/vibrant/vibwndws.c b/vibrant/vibwndws.c
index 125fc302..3e78ad9a 100644
--- a/vibrant/vibwndws.c
+++ b/vibrant/vibwndws.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/1/91
*
-* $Revision: 6.54 $
+* $Revision: 6.60 $
*
* File Description:
* Vibrant main, event loop, and window functions
@@ -37,6 +37,28 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: vibwndws.c,v $
+* Revision 6.60 2004/01/20 23:35:38 sinyakov
+* [WIN_MSWIN] implemented menu accelerators
+*
+* Revision 6.59 2004/01/05 18:42:40 kans
+* record screen mode at time of window creation
+*
+* Revision 6.58 2004/01/05 17:08:09 kans
+* added functions to control use of dual screens
+*
+* Revision 6.57 2003/12/03 17:45:21 kans
+* For OS_MAC, always include Profiler.h
+*
+* Revision 6.56 2003/11/17 17:03:30 kans
+* changed C++ style comments to C comments
+*
+* Revision 6.55 2003/11/03 21:57:48 sinyakov
+* WIN_MSWIN: added ability to put a message into message processing loop
+* to call a callback function within the main GUI thread
+* callback function address is passed in WPARAM,
+* callback function parameter is passed in LPARAM
+* this functionality is used by Win32 implementation of smartnet.c module
+*
* Revision 6.54 2003/04/09 18:16:53 kans
* motif version of Nlm_ProcessKeyPress sets ctrlKey and shftKey, clears cmmdKey and optKey, leaves dblClick alone
*
@@ -619,10 +641,10 @@
#ifdef WIN_MAC
#include <Appearance.h>
#include <Navigation.h>
-# if !defined(OS_UNIX_DARWIN)
-# include <Profiler.h>
-# endif
-# include "MoreCarbonAccessors.h"
+#if __profile__
+#include <Profiler.h>
+#endif
+#include "MoreCarbonAccessors.h"
#endif
#if defined(WIN_MOTIF) && defined(_DEBUG) && !defined(__hpux)
@@ -690,6 +712,14 @@ extern void Nlm_ConvertFilename ( FSSpec *fss, Nlm_CharPtr filename );
#endif
#endif
+typedef enum {
+ USE_FULL_SCREEN = 1,
+ USE_LEFT_SCREEN,
+ USE_RIGHT_SCREEN
+} Nlm_ScreenMode;
+
+static Nlm_ScreenMode Nlm_screenMode = USE_FULL_SCREEN;
+
typedef struct Nlm_shelldata {
struct Nlm_shelldata PNTR next;
Nlm_ShellTool shell;
@@ -720,6 +750,7 @@ typedef struct Nlm_windowdata {
Nlm_WndFreeProc cleanup;
Nlm_WndActnProc timer;
Nlm_WindoW modalOwner; /* esl++ to support nested modal dialogs */
+ Nlm_ScreenMode screenMode;
#ifdef WIN_MOTIF
Visual *visual;
Nlm_Boolean cMap_fixed;
@@ -727,6 +758,7 @@ typedef struct Nlm_windowdata {
#ifdef WIN_MSWIN
Nlm_Uint4 style;
Nlm_Uint4 ex_style;
+ Nlm_Handle haccel;
#endif
} Nlm_WindowData;
@@ -758,7 +790,7 @@ AEEventHandlerUPP HandleAEQuitAppPtr;
AEEventHandlerUPP HandleAEAnswerPtr;
#endif
typedef SInt32 AERefCon;
-//typedef UInt32 AERefCon;
+/* typedef UInt32 AERefCon; */
#endif
#ifdef WIN_MSWIN
@@ -932,6 +964,7 @@ static void Nlm_LoadWindowData (Nlm_WindoW w, Nlm_WindowTool hdl,
wdptr->cleanup = cln;
wdptr->timer = tmr;
wdptr->modalOwner = NULL; /* esl++ */
+ wdptr->screenMode = Nlm_screenMode; /* jk */
#ifdef WIN_MOTIF
wdptr->visual = NULL;
wdptr->cMap_fixed = FALSE;
@@ -1204,6 +1237,32 @@ extern Nlm_Boolean Nlm_IsWindowDying (Nlm_WindoW w)
return rsult;
}
+static void Nlm_SetScreenMode (Nlm_WindoW w, Nlm_ScreenMode screenMode)
+
+{
+ Nlm_WindowData wdata;
+
+ if (w != NULL) {
+ Nlm_GetWindowData (w, &wdata);
+ wdata.screenMode = screenMode;
+ Nlm_SetWindowData (w, &wdata);
+ }
+}
+
+static Nlm_ScreenMode Nlm_GetScreenMode (Nlm_WindoW w)
+
+{
+ Nlm_ScreenMode rsult;
+ Nlm_WindowData wdata;
+
+ rsult = USE_FULL_SCREEN;
+ if (w != NULL) {
+ Nlm_GetWindowData (w, &wdata);
+ rsult = wdata.screenMode;
+ }
+ return rsult;
+}
+
extern Nlm_WindoW Nlm_GetParentWindow (Nlm_GraphiC a)
{
@@ -2152,10 +2211,10 @@ extern void Nlm_SetUpdateRegion (WindowPtr wptr)
if (wptr != NULL) {
GetPortVisibleRegion(GetWindowPort(wptr), Nlm_updateRgn);
- //HLock ((Handle) Nlm_updateRgn);
+ /* HLock ((Handle) Nlm_updateRgn); */
GetRegionBounds(Nlm_updateRgn, &bounds);
Nlm_RectToolToRecT (&bounds, &Nlm_updateRect);
- //HUnlock ((Handle) Nlm_updateRgn);
+ /* HUnlock ((Handle) Nlm_updateRgn); */
}
}
#endif
@@ -2797,6 +2856,7 @@ static void Nlm_NewWindow (Nlm_WindoW w, Nlm_Int2 type, Nlm_Int2 procID,
Nlm_GetWindowData(w, &wdata);
wdata.style = style;
wdata.ex_style = ex_style;
+ wdata.haccel = 0;
Nlm_SetWindowData(w, &wdata);
}}
#endif
@@ -3047,6 +3107,35 @@ static void Nlm_RemoveWindow (Nlm_GraphiC w, Nlm_Boolean savePort)
Nlm_Update ();
}
+NLM_EXTERN void Nlm_UseFullScreen (void)
+
+{
+ Nlm_screenMode = USE_FULL_SCREEN;
+}
+
+NLM_EXTERN void Nlm_UseLeftScreen (void)
+
+{
+ Nlm_screenMode = USE_LEFT_SCREEN;
+}
+
+NLM_EXTERN void Nlm_UseRightScreen (void)
+
+{
+ Nlm_screenMode = USE_RIGHT_SCREEN;
+}
+
+NLM_EXTERN Nlm_Boolean Nlm_HasDualScreen (void)
+
+{
+ if (screenBitBounds.right > 2000 && screenBitBounds.bottom < 800) {
+ return TRUE;
+ } else if (screenBitBounds.right > 2500 && screenBitBounds.bottom < 1100) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
/* esl: extraWidth parameter added */
static void Nlm_ResizeWindow (Nlm_GraphiC w, Nlm_Int2 dragHeight,
Nlm_Int2 scrollWidth, Nlm_Int2 minWidth,
@@ -3062,6 +3151,7 @@ static void Nlm_ResizeWindow (Nlm_GraphiC w, Nlm_Int2 dragHeight,
Nlm_RecT r;
Nlm_Int4 rleft;
Nlm_Int4 rtop;
+ Nlm_ScreenMode screenMode;
Nlm_Int4 toppix;
Nlm_WindowTool wptr;
#ifdef WIN_MOTIF
@@ -3104,10 +3194,31 @@ static void Nlm_ResizeWindow (Nlm_GraphiC w, Nlm_Int2 dragHeight,
height = r.bottom + extraHeight;
if (r.left < 0)
{
- free = screenBitBounds.right - width;
- rleft = (Nlm_Int4)r.left;
- leftpix = free * (-rleft) / 100;
- r.left = (Nlm_Int2)leftpix;
+ if (Nlm_HasDualScreen ()) {
+ screenMode = Nlm_GetScreenMode ((Nlm_WindoW) w);
+ if (screenMode == USE_LEFT_SCREEN) {
+ free = screenBitBounds.right / 2 - width;
+ rleft = (Nlm_Int4)r.left;
+ leftpix = free * (-rleft) / 100;
+ r.left = (Nlm_Int2)leftpix;
+ } else if (screenMode == USE_RIGHT_SCREEN) {
+ free = screenBitBounds.right / 2 - width;
+ rleft = (Nlm_Int4)r.left;
+ leftpix = free * (-rleft) / 100;
+ r.left = (Nlm_Int2)leftpix;
+ r.left += screenBitBounds.right / 2;
+ } else {
+ free = screenBitBounds.right - width;
+ rleft = (Nlm_Int4)r.left;
+ leftpix = free * (-rleft) / 100;
+ r.left = (Nlm_Int2)leftpix;
+ }
+ } else {
+ free = screenBitBounds.right - width;
+ rleft = (Nlm_Int4)r.left;
+ leftpix = free * (-rleft) / 100;
+ r.left = (Nlm_Int2)leftpix;
+ }
}
if (r.top < 0)
{
@@ -3929,7 +4040,7 @@ static Nlm_Boolean Nlm_ZoomClick (Nlm_GraphiC w, Nlm_PoinT pt)
if (TrackBox (wptr, ptool, windowLoc)) {
Rect bounds;
- // WindowPeek::dataHandle is not supported under Carbon.
+ /* WindowPeek::dataHandle is not supported under Carbon. */
#if OPAQUE_TOOLBOX_STRUCTS
ZoomWindowIdeal(wptr, part, &idealSize);
#else
@@ -5418,7 +5529,7 @@ static void Nlm_HandleEvent (void)
mess = (Nlm_currentEvent.message & osEvtMessageMask) >> 24;
if (mess == suspendResumeMessage) {
if (Nlm_currentEvent.message & resumeFlag) {
- // Resume
+ /* Resume */
#if !TARGET_API_MAC_CARBON
if (Nlm_currentEvent.message & convertClipboardFlag) {
/* 2001-05-14: JDJ
@@ -6421,11 +6532,13 @@ void main ()
#endif
#if TARGET_API_MAC_CARBON >= 1
- // carbon changes the API: pass the number of master pointers to allocate
- //MoreMasters (1280);
- // 2001-03-22: Joshua Juran
- // CarbonDater report says to use MoreMasterPointers() instead of MoreMasters().
- // Universal Interfaces 3.3.2 declares MoreMasters(void) under Carbon.
+ /*
+ carbon changes the API: pass the number of master pointers to allocate
+ MoreMasters (1280);
+ 2001-03-22: Joshua Juran
+ CarbonDater report says to use MoreMasterPointers() instead of MoreMasters().
+ Universal Interfaces 3.3.2 declares MoreMasters(void) under Carbon.
+ */
MoreMasterPointers(1280);
FlushEvents (everyEvent, 0);
/* the rest of the toolbox is done for us can't init them...
@@ -6836,8 +6949,8 @@ extern void Nlm_RemoveDyingWindows (void)
Nlm_currentWindowTool = GetWindowFromPort(tempPort);
Nlm_SetUpdateRegion (GetWindowFromPort(tempPort));
SetPenState (&state);
- // 2001-03-22: Joshua Juran
- // Carbon does not support application-supplied storage for windows.
+ /* 2001-03-22: Joshua Juran
+ Carbon does not support application-supplied storage for windows. */
DisposeWindow(wptr);
#endif
#ifdef WIN_MSWIN
@@ -6845,6 +6958,10 @@ extern void Nlm_RemoveDyingWindows (void)
DeleteObject( wdata.cMap );
wdata.cMap = NULL;
}
+ if ( wdata.haccel != NULL ){
+ DestroyAcceleratorTable(wdata.haccel);
+ wdata.haccel = NULL;
+ }
Nlm_currentHDC = tempPort;
RemoveProp (wptr, (LPSTR) "Nlm_VibrantProp");
DestroyWindow (wptr);
@@ -6988,6 +7105,93 @@ static void Nlm_ProcessKeyPress (XEvent *event)
}
#endif
+#ifdef WIN_MSWIN
+
+typedef void (LIBCALLBACK *CallbackProc)(void* data);
+static UINT idWMVibrantCallback = 0;
+
+static void Nlm_InitVibrantCallback ()
+
+{
+ idWMVibrantCallback = RegisterWindowMessage("VibrantCallback");
+}
+
+
+static Nlm_Boolean Nlm_ProcessVibrantCallback (LPMSG lpMsg)
+
+{
+ if(idWMVibrantCallback && idWMVibrantCallback == lpMsg->message)
+ {
+ CallbackProc proc = (CallbackProc)lpMsg->wParam;
+ proc((void*)(lpMsg->lParam));
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+#endif
+
+#ifdef WIN_MSWIN
+
+extern Nlm_Handle Nlm_GetWindowHAccel (Nlm_WindoW w)
+
+{
+ Nlm_Handle rsult;
+ Nlm_WindowData wdata;
+
+ rsult = (Nlm_Handle) 0;
+ if (w != NULL) {
+ Nlm_GetWindowData (w, &wdata);
+ rsult = wdata.haccel;
+ }
+ return rsult;
+}
+
+
+extern void Nlm_SetWindowHAccel (Nlm_WindoW w, Nlm_Handle h)
+
+{
+ Nlm_WindowData wdata;
+
+ if (w != NULL) {
+ Nlm_GetWindowData (w, &wdata);
+ wdata.haccel = h;
+ Nlm_SetWindowData (w, &wdata);
+ }
+}
+
+
+static Nlm_Boolean Nlm_ProcessAccelerator (LPMSG lpMsg)
+
+{
+ if(lpMsg->hwnd != NULL &&
+ (lpMsg->message == WM_KEYDOWN ||
+ lpMsg->message == WM_KEYUP ||
+ lpMsg->message == WM_SYSKEYDOWN ||
+ lpMsg->message == WM_SYSKEYUP ||
+ lpMsg->message == WM_CHAR))
+ {
+ Nlm_WindoW w = (Nlm_WindoW) GetProp (lpMsg->hwnd, (LPSTR) "Nlm_VibrantProp");
+ if(w != NULL)
+ {
+ Nlm_WindoW p = Nlm_GetParentWindow((Nlm_GraphiC)w);
+ if(p != NULL)
+ {
+ Nlm_WindowData wdata;
+ Nlm_GetWindowData(p, &wdata);
+ if(wdata.haccel != NULL)
+ {
+ int ret = TranslateAccelerator(wdata.handle, wdata.haccel, lpMsg);
+ return ret != 0;
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+#endif
+
extern void Nlm_ProcessAnEvent (void)
{
@@ -7003,6 +7207,7 @@ extern void Nlm_ProcessAnEvent (void)
if (GetMessage (&Nlm_currentMssg, NULL, 0, 0)) {
TranslateMessage (&Nlm_currentMssg);
Nlm_ProcessKeyPress (&Nlm_currentMssg);
+ Nlm_ProcessVibrantCallback(&Nlm_currentMssg);
DispatchMessage (&Nlm_currentMssg);
}
}
@@ -7076,6 +7281,7 @@ extern void Nlm_ProcessEventOrIdle (void)
if (GetMessage (&Nlm_currentMssg, NULL, 0, 0)) {
TranslateMessage (&Nlm_currentMssg);
Nlm_ProcessKeyPress (&Nlm_currentMssg);
+ Nlm_ProcessVibrantCallback(&Nlm_currentMssg);
DispatchMessage (&Nlm_currentMssg);
}
}
@@ -7115,6 +7321,7 @@ extern void Nlm_ProcessExternalEvent (void)
if (GetMessage (&Nlm_currentMssg, NULL, 0, 0)) {
TranslateMessage (&Nlm_currentMssg);
Nlm_ProcessKeyPress (&Nlm_currentMssg);
+ Nlm_ProcessVibrantCallback(&Nlm_currentMssg);
DispatchMessage (&Nlm_currentMssg);
}
}
@@ -7150,6 +7357,7 @@ extern void Nlm_ProcessEvents (void)
}
#endif
#ifdef WIN_MSWIN
+ Nlm_InitVibrantCallback ();
if (registeredDropProc != NULL) {
DragAcceptFiles(Nlm_currentHWnd, TRUE);
}
@@ -7162,9 +7370,12 @@ extern void Nlm_ProcessEvents (void)
}
}
if (GetMessage (&Nlm_currentMssg, NULL, 0, 0)) {
- TranslateMessage (&Nlm_currentMssg);
- Nlm_ProcessKeyPress (&Nlm_currentMssg);
- DispatchMessage (&Nlm_currentMssg);
+ if(!Nlm_ProcessAccelerator(&Nlm_currentMssg)) {
+ TranslateMessage (&Nlm_currentMssg);
+ Nlm_ProcessKeyPress (&Nlm_currentMssg);
+ Nlm_ProcessVibrantCallback(&Nlm_currentMssg);
+ DispatchMessage (&Nlm_currentMssg);
+ }
Nlm_RemoveDyingWindows ();
}
}