1
/* $Id: taxblast.c,v 6.12 2001/12/13 21:48:51 camacho Exp $
1
static char const rcsid[] = "$Id: taxblast.c,v 6.23 2004/09/08 11:40:09 bollin Exp $";
3
/* $Id: taxblast.c,v 6.23 2004/09/08 11:40:09 bollin Exp $
2
4
* ===========================================================================
4
6
* PUBLIC DOMAIN NOTICE
30
32
* Initial Version Creation Date: 04/04/2000
34
36
* File Description:
35
37
* Utilities and functions for Tax-Blast program
37
39
* $Log: taxblast.c,v $
40
* Revision 6.23 2004/09/08 11:40:09 bollin
41
* removed network/taxon1 dependencies
43
* Revision 6.22 2004/08/30 13:43:54 madden
44
* Change from htbin-post URL
46
* Revision 6.21 2003/09/16 16:03:19 rsmith
47
* guard include of unistd.h to only those platforms that need it and can use it.
49
* Revision 6.20 2003/09/15 18:46:29 rsmith
50
* added unistd.h include for sleep
52
* Revision 6.19 2003/05/30 17:25:38 coulouri
55
* Revision 6.18 2003/05/13 16:02:54 coulouri
56
* make ErrPostEx(SEV_FATAL, ...) exit with nonzero status
58
* Revision 6.17 2002/11/06 21:31:47 ucko
59
* TXBGetGiFromSeqId: Compare oip->id to 0 rather than NULL, as it is an integer.
61
* Revision 6.16 2002/10/07 19:52:07 camacho
62
* Added RDTaxLookupReset
64
* Revision 6.15 2002/07/02 16:38:04 camacho
65
* Moved increment of number of taxids in db to end of FDBTaxCallback
67
* Revision 6.14 2002/05/23 22:22:15 camacho
68
* Do not keep entries with taxid 0 in blast taxonomy database
70
* Revision 6.13 2002/01/11 16:31:13 camacho
71
* Verify if taxonomy service is properly initialized in RDTaxLookupInit
38
73
* Revision 6.12 2001/12/13 21:48:51 camacho
39
74
* Fixed retrieval of maximum taxonomy id to properly populate the
40
75
* RDBTaxLookup structure.
1243
1279
for (i=0; i<depth; i++)
1244
1280
fputs (". ", outfile);
1246
fprintf (outfile, "<a href=http://www.ncbi.nlm.nih.gov/htbin-post/Taxonomy/wgetorg?id=%d>%s</a>", lo_next->taxid, lo_next->name);
1282
fprintf (outfile, "<a href=http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=%ld>%s</a>",
1283
(long) lo_next->taxid, lo_next->name);
1248
1285
bname = GetBlastName (lo_next->taxid, tree);
1250
1287
if (bname && bname->name) {
1251
1288
for (i=taxa_name_len[depth];
1252
1289
i<=longname; i++) fputc (' ', outfile);
1253
fprintf (outfile, "[<a href=http://www.ncbi.nlm.nih.gov/htbin-post/Taxonomy/wgetorg?id=%d>%s</a>]", bname->taxid, bname->name);
1290
fprintf (outfile, "[<a href=http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=%ld>%s</a>]",
1291
(long) bname->taxid, bname->name);
1255
1293
fputc ('\n', outfile);
1297
1335
orgoff = org->data.intvalue;
1298
1336
taxid = orgobj->taxids[orgoff];
1299
1337
for (j=0; j<depth; j++) fputs(". ", outfile);
1300
fprintf (outfile, "<A HREF=http://www.ncbi.nlm.nih.gov/htbin-post/Taxonomy/wgetorg?id=%d>%s</A>", taxid, orgobj->names[orgoff]);
1338
fprintf (outfile, "<A HREF=http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=%ld>%s</A>",
1339
(long) taxid, orgobj->names[orgoff]);
1301
1340
if (orgobj->cnames[orgoff]->count > 0) {
1302
1341
cname = (CharPtr)orgobj->cnames[orgoff]->names->data.ptrvalue;
1303
1342
StrNCpy (buffer, cname, BUFFLEN);
1328
1367
else fprintf(outfile, "<a href=#%d>%d hits</a>", taxid, numhits);
1330
1369
if (size_bnames[i]>0)
1331
fprintf (outfile, " [<a href=http://www.ncbi.nlm.nih.gov/htbin-post/Taxonomy/wgetorg?id=%d>%s</a>]", orgobj->bnames[orgoff]->taxid, orgobj->bnames[orgoff]->name);
1370
fprintf (outfile, " [<a href=http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=%ld>%s</a>]",
1371
(long) orgobj->bnames[orgoff]->taxid, orgobj->bnames[orgoff]->name);
1332
1372
else fputs(" []", outfile);
1333
1373
for (j=size_bnames[i]; j<=max_bnames; j++) fputc(' ', outfile);
1385
1425
numorgs = orgobj->numorgs;
1386
1426
for (i=0; i<numorgs; i++) {
1387
1427
fprintf (outfile, "<a name=%d></a>", orgobj->taxids[i]);
1388
fprintf (outfile, " <b><a href=http://www.ncbi.nlm.nih.gov/htbin-post/Taxonomy/wgetorg?id=%d>%s</a></b>", orgobj->taxids[i], orgobj->names[i]);
1428
fprintf (outfile, " <b><a href=http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=%ld>%s</a></b>",
1429
(long) orgobj->taxids[i], orgobj->names[i]);
1390
1431
if (orgobj->cnames[i]->count > 0) {
1391
1432
cname= (CharPtr) orgobj->cnames[i]->names->data.ptrvalue;
1398
1439
if (orgobj->bnames[i] && orgobj->bnames[i]->name) {
1399
fprintf (outfile, " [<a href=http://www.ncbi.nlm.nih.gov/htbin-post/Taxonomy/wgetorg?id=%d>%s</a>]", orgobj->bnames[i]->taxid, orgobj->bnames[i]->name);
1440
fprintf (outfile, " [<a href=http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=%ld>%s</a>]",
1441
(long) orgobj->bnames[i]->taxid, orgobj->bnames[i]->name);
1402
1444
fprintf (outfile, " taxid %d", orgobj->taxids[i]);
1693
1735
if(tax_lookup->tax_array[tax_id] != NULL)
1697
/* For unresolved tax_id we will eventually create some
1699
tnames = MemNew(sizeof(RDBTaxNames));
1700
tnames->sci_name = StringSave("Unknown");
1701
tnames->common_name = StringSave("Unknown");
1702
tnames->blast_name = StringSave("Unknown");
1703
StringCpy(tnames->s_king, "-");
1704
tax_lookup->tax_array[0] = tnames;
1705
tax_lookup->taxids_in_db++;
1710
tax_lookup->taxids_in_db++;
1711
1741
tdp = (TAXDataPtr) tax_lookup->tax_data;
1713
1743
tax_tree= tdp->tax_tree;
1803
1834
RDBTaxLookupPtr tax_lookup;
1804
1835
TAXDataPtr tax_data;
1836
Int2 retries = 3, secs2wait = 10;
1806
1838
/* connect to taxonomy service */
1846
if (!tax1_isAlive()) {
1847
ErrPostEx(SEV_FATAL, 1,0,
1848
"Could not initialize taxonomy service: RDTaxLookupInit");
1809
1852
/* download all the taxonomy tree from the server */
1810
1853
tax1e_invokeChildren(-1);
1823
1866
return tax_lookup;
1826
void RDTaxLookupClose(RDBTaxLookupPtr tax_lookup)
1869
/* Remove all entries from taxonomy lookup structure but don't close the
1870
* connection to the taxonomy service */
1871
RDBTaxLookupPtr RDTaxLookupReset(RDBTaxLookupPtr tax_lookup)
1828
1873
RDBTaxNamesPtr tnames;
1831
MemFree(tax_lookup->tax_data);
1833
1876
for(i = 0; i < tax_lookup->all_taxid_count; i++) {
1835
1878
tnames = tax_lookup->tax_array[i];
1837
if(tnames != NULL) {
1880
if (tnames != NULL) {
1838
1881
MemFree(tnames->sci_name);
1839
1882
MemFree(tnames->common_name);
1840
1883
MemFree(tnames->blast_name);
1841
1884
MemFree(tnames);
1886
tax_lookup->tax_array[i] = tnames = NULL;
1888
tax_lookup->taxids_in_db = 0;
1891
void RDTaxLookupClose(RDBTaxLookupPtr tax_lookup)
1893
tax_lookup = RDTaxLookupReset(tax_lookup);
1895
MemFree(tax_lookup->tax_data);
1845
1896
MemFree(tax_lookup->tax_array);
1846
1897
MemFree(tax_lookup);
1882
1933
if((aip = AsnIoOpen(myargs[0].strvalue, "r")) == NULL) {
1883
ErrPostEx(SEV_FATAL, 0,0, "AsnIoOpen failure\n");
1934
ErrPostEx(SEV_FATAL, 1,0, "AsnIoOpen failure\n");
1887
1938
if((sap = SeqAnnotAsnRead (aip, NULL)) == NULL) {
1888
ErrPostEx(SEV_FATAL, 0,0,"SeqAlignAsnRead failure\n");
1939
ErrPostEx(SEV_FATAL, 1,0,"SeqAlignAsnRead failure\n");