Package: acedb / 4.9.39+dfsg.02-5

efetch_help.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
Author: Steffen Moeller <moeller@debian.org>
Last-Update: Sun, 11 Jul 2010 06:27:12 +0200
Description: Add -h argument for help and -v for version info

--- a/w9/efetch.c
+++ b/w9/efetch.c
@@ -126,25 +126,85 @@ void main(int argc, char *argv[])
     -s <#>        Start at position #\n\
     -e <#>        Stop at position #\n\
     -o            More options and info...\n\
+    -h            shows this usage text\n\
 \n\
   by Erik Sonnhammer (esr@sanger.ac.uk)\n\
   Version 2.1, ";
 
-  if (!(usage = malloc(strlen(usageText) + 102))) {
-      fprintf(stderr, "Malloc error\n");
-      exit(1);
-  }
+  char *help;
+  static char helpText[] = "\n\
+  EFETCH - retrieve entries from sequence databases.\n\
+\n\
+  Synopsis: efetch -options [database:]<query> \n\
+\n\
+  Databases:  SWissprot/SP, PIR, WOrmpep/WP, EMbl, GEnbank/GB, ProDom, ProSite\n\
+\n\
+  Options:\n\
+    -a            Search with Accession number\n\
+    -f            Fasta format output\n\
+    -q            Sequence only output (one line)\n\
+    -s <#>        Start at position #\n\
+    -e <#>        Stop at position #\n\
+    -o            More options and info...\n\
+\n\
+    -D <dir>      Specify database directory\n\
+    -H            Display index header data\n\
+    -p            Display entrynames in search path\n\
+    -r            Print sequence in 'raw' format\n\
+    -m            Fetch from mixed mini database\n\
+    -M            Mini format output\n\
+    -b            Do NOT reverse the order of bytes\n\
+                              (SunOS, IRIX do reverse, Alpha not)\n\
+    -d <dbfile>   Specify database file (avoid this)\n\
+    -i <idxfile>  Specify index file (avoid this)\n\
+    -l <divfile>  Specify division lookup table (avoid this)\n\
+    -B <database> Specify database (archaic)\n\
+    -A            Only return entryname for accession number\n\
+    -n <name>     Give the sequence this name\n\
+    -x            Don't require query to match entry's name exactly (avoid)\n\
+    -w            For Wormpep: also fetch cross-referenced SwissProt entry\n\
+    -h            shows this help text\n\
+\n\
+\n\
+  Environment:\n\
+  SWDIR      = SwissProt  directory - database and EMBL index files\n\
+  PIRDIR     = PIR        -- \" --\n\
+  WORMDIR    = Wormpep    -- \" --\n\
+  EMBLDIR    = EMBL       -- \" --\n\
+  GBDIR      = Genbank    -- \" --\n\
+  PRODOMDIR  = ProDom     -- \" --\n\
+  PROSITEDIR = ProSite    -- \" --\n\
+  DBDIR      = User's own -- \" -- (fasta format)\n\
+\n\
+  SEQDB    database file (default SwissProt)\n\
+  SEQDBIDX index file\n\
+  DIVTABL  division lookup table\n\
+\n\
+  Ex. setenv DBDIR /pubseq/seqlibs/embl/\n\
+\n\
+  Note that Prodom family consensus seqs can be fetched by PD:_#\n\n\
+  by Erik Sonnhammer (esr@sanger.ac.uk)\n\
+  Version 2.1, ";
 
-  strcpy(usage, usageText);
-  strncat(usage, cc_date, 100);
-  strcat(usage, "\n");
+  // check if any argument is --help or -help
+  for(i=1; i<argc; i++) {
+	if (0 == strncmp("--help",argv[i],6) || 0 == strncmp("-help",argv[i],5)) {
+		if (!(help = malloc(strlen(helpText) + 102))) {
+		  fprintf(stderr, "Malloc error\n");
+		  exit(1);
+		}
+		strcpy(help, helpText);
+		strncat(help, cc_date, 100);
+		strcat(help, "\n");
+		fprintf(stderr,"%s\n",helpText);
+		exit(0);
+	}
+  }
 
   /* parse command line */
   while ((optc = getopt(argc, argv, optstring)) != -1)
   switch (optc) {
    
-  case 'h':
-      fprintf(stderr, "\n%s\n", usage); exit(1);
   case 'B':
       strcpy(dbsource, optarg); break;
   case 'a':
@@ -166,43 +226,16 @@ void main(int argc, char *argv[])
       strcpy(dbfile, optarg); break;
   case 'H':
       display_head=1; break;
+  case 'h':
   case 'o':
-      printf("\n\
-         -D <dir>      Specify database directory\n\
-         -H            Display index header data\n\
-         -p            Display entrynames in search path\n\
-         -r            Print sequence in 'raw' format\n\
-         -m            Fetch from mixed mini database\n\
-         -M            Mini format output\n\
-         -b            Do NOT reverse the order of bytes\n\
-                              (SunOS, IRIX do reverse, Alpha not)\n\
-         -d <dbfile>   Specify database file (avoid this)\n\
-	 -i <idxfile>  Specify index file (avoid this)\n\
-         -l <divfile>  Specify division lookup table (avoid this)\n\
-         -B <database> Specify database (archaic)\n\
-         -A            Only return entryname for accession number\n\
-         -n <name>     Give the sequence this name\n\
-         -x            Don't require query to match entry's name exactly (avoid)\n\
-         -w            For Wormpep: also fetch cross-referenced SwissProt entry\n\
-\n\
-\n\
-  Environment variables:\n\
-  SWDIR      = SwissProt  directory - database and EMBL index files\n\
-  PIRDIR     = PIR        -- \" --\n\
-  WORMDIR    = Wormpep    -- \" --\n\
-  EMBLDIR    = EMBL       -- \" --\n\
-  GBDIR      = Genbank    -- \" --\n\
-  PRODOMDIR  = ProDom     -- \" --\n\
-  PROSITEDIR = ProSite    -- \" --\n\
-  DBDIR      = User's own -- \" -- (fasta format)\n\
-\n\
-  SEQDB    database file (default SwissProt)\n\
-  SEQDBIDX index file\n\
-  DIVTABL  division lookup table\n\
-\n\
-  Ex. setenv DBDIR /pubseq/seqlibs/embl/\n\
-\n\
-  Note that Prodom family consensus seqs can be fetched by PD:_#\n\n");
+      if (!(help = malloc(strlen(helpText) + 102))) {
+          fprintf(stderr, "Malloc error\n");
+          exit(1);
+      }
+      strcpy(help, helpText);
+      strncat(help, cc_date, 100);
+      strcat(help, "\n");
+      fprintf(stderr,"%s\n",helpText);
       exit(0);
   case 'p':
       search = 1; break;
@@ -229,8 +262,19 @@ void main(int argc, char *argv[])
       strcpy(customName, optarg); break;
   case 'w':
       wormpep2swiss = 1;       break;
+  case '-':
+	// omit option indicator
+	break;
   default:
+      if (!(usage = malloc(strlen(usageText) + 102))) {
+          fprintf(stderr, "Malloc error\n");
+          exit(1);
+      }
+      strcpy(usage, usageText);
+      strncat(usage, cc_date, 102);
+      strcat(usage, "\n");
       fprintf(stderr, "\n%s\n", usage); exit(1);      
+      break;
   }
 
   if (argc - optind != 1)