Skip to content

Commit dfb84e0

Browse files
committed
update README.md and go.mod
1 parent d17653c commit dfb84e0

File tree

10 files changed

+282
-14
lines changed

10 files changed

+282
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ vendor
77
.DS_Store
88
_log
99
go.sum
10+
11+
.XML.tmp*

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2020-04-29 Li Jianfeng <[email protected]>
2+
3+
* support covid19 api
4+
15
2020-04-22 Li Jianfeng <[email protected]>
26

37
* bio.tools API support --from and --size flag

README.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ For website spider (optional):
2525

2626
For raw sequencing data query (optional):
2727

28-
- [sra-tools](https://github.com/ncbi/sra-tools) for SRA and dbGAP database: MAC and Windows user `bget i base/[email protected]`, Linux user `bget i base/sratools`;
28+
- [sra-tools](https://github.com/ncbi/sra-tools) for SRA and dbGAP database: `bget i sratools`;
2929
- [pyega3](https://github.com/EGA-archive/ega-download-client) for EGA database: `pip3 install pyega3`;
30-
- [gdc-client](https://gdc.cancer.gov/access-data/gdc-data-transfer-tool) for GDC portal: `bget i base/gdc-client@1.4.0 -u`.
30+
- [gdc-client](https://gdc.cancer.gov/access-data/gdc-data-transfer-tool) for GDC portal: `bget i gdc-client@1.5.0 -u`.
3131

3232
## Installation
3333

3434
```bash
3535
# windows
36-
wget https://github.com/openanno/bget/releases/download/v0.2.4/bget.exe
36+
wget https://github.com/openanno/bget/releases/download/v0.3.0/bget.exe
3737

3838
# osx
39-
wget https://github.com/openanno/bget/releases/download/v0.2.4/bget_osx
39+
wget https://github.com/openanno/bget/releases/download/v0.3.0/bget_osx
4040
mv bget_osx bget
4141
chmod a+x bget
4242

4343
# linux
44-
wget https://github.com/openanno/bget/releases/download/v0.2.4/bget_linux64
44+
wget https://github.com/openanno/bget/releases/download/v0.3.0/bget_linux64
4545
mv bget_linux64 bget
4646
chmod a+x bget
4747

@@ -142,6 +142,41 @@ bget api mgrast anno --info
142142
bget api mgrast anno --evalue 100 --type organism --source SwissProt --seq mgm4447943.3
143143

144144
bget api mgrast compute --info
145+
146+
# returns all data in the system. Warning: this request returns 8MB+ and takes 5+ seconds
147+
bget api covid19 --all
148+
# returns all countries and associated provinces
149+
bget api covid19 --cts
150+
# returns all cases by case type for a country from the first recorded case.
151+
bget api covid19 --ct --name China
152+
# returns all cases by case type for a country from the first recorded case.
153+
bget api covid19 --ct-d-one --name China
154+
# returns all cases by case type for a country.
155+
bget api covid19 --ct-d-one-total --name China
156+
# returns all cases by case type for a country from the first recorded case with the latest record being the live count.
157+
bget api covid19 --ct-st-d-one --name China --status confirmed
158+
# returns all cases by case type for a country from the first recorded case.
159+
bget api covid19 --ct-st-d-one-live --name China --status confirmed
160+
# returns all cases by case type for a country from the first recorded case
161+
bget api covid19 --ct-st-d-one-total --name China --status confirmed
162+
# returns all cases by case type for a country with the latest record being the live count.
163+
bget api covid19 --ct-st-live --name China --status confirmed
164+
# returns all cases by case type for a country.
165+
bget api covid19 --ct-st --name China --status confirmed
166+
# returns all cases by case type for a country.
167+
bget api covid19 --ct-st-total --name China --status confirmed
168+
# returns all cases of a country.
169+
bget api covid19 --ct-total --name China
170+
# returns all live cases by case type for a country.
171+
bget api covid19 --live-ct --name China
172+
# returns all live cases by case type for a country after a given date.
173+
bget api covid19 --live-ct-st-date --name China --status confirmed --date 2020-04-20T06:20:47Z
174+
# returns all live cases by case type for a country.
175+
bget api covid19 --live-ct-st --name China --status confirmed
176+
# a summary of new and total cases per country
177+
bget api covid19 --summary
178+
bget api covid19 --export
179+
bget api covid19 --webhook https://your_webhook.com
145180
```
146181

147182
### Query DOI resources

_examples/bapi.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ bget api gdc -m -q "5b2974ad-f932-499b-90a3-93577a9f0573,556e5e3f-0ab9-4b6c-aa62
3535
bget api gdc -m -q "5b2974ad-f932-499b-90a3-93577a9f0573,556e5e3f-0ab9-4b6c-aa62-c42f6a6cf20c" -n
3636
bget api gdc -d -q "5b2974ad-f932-499b-90a3-93577a9f0573" -n
3737
bget api ncbi -q "Galectins control MTOR and AMPK in response to lysosomal damage to induce autophagy OR MTOR-independent autophagy induced by interrupted endoplasmic reticulum-mitochondrial Ca2+ communication: a dead end in cancer cells. OR The PARK10 gene USP24 is a negative regulator of autophagy and ULK1 protein stability OR Coordinate regulation of autophagy and the ubiquitin proteasome system by MTOR." | bioctl cvrt --xml2json pubmed -
38+
bget api covid19 --all
39+
bget api covid19 --cts
40+
bget api covid19 --ct --name China
41+
bget api covid19 --ct-d-one --name China
42+
bget api covid19 --ct-d-one-total --name China
43+
bget api covid19 --ct-st-d-one --name China --status confirmed
44+
bget api covid19 --ct-st-d-one-live --name China --status confirmed
45+
bget api covid19 --ct-st-d-one-total --name China --status confirmed
46+
bget api covid19 --ct-st-live --name China --status confirmed
47+
bget api covid19 --ct-st --name China --status confirmed
48+
bget api covid19 --ct-st-total --name China --status confirmed
49+
bget api covid19 --ct-total --name China
50+
bget api covid19 --live-ct --name China
51+
bget api covid19 --live-ct-st-date --name China --status confirmed --date 2020-04-20T06:20:47Z
52+
bget api covid19 --live-ct-st --name China --status confirmed
53+
bget api covid19 --summary
54+
bget api covid19 --export
55+
bget api covid19 --webhook https://your_webhook.com
3856

3957
cd ..
4058
bget --clean

_meta/tools/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@
236236
"Name": "golang",
237237
"Description": "",
238238
"Versions": [
239+
"1.14.2",
240+
"1.14.1",
241+
"1.14",
239242
"1.13.4",
240243
"1.13.3",
241244
"1.13.2",

api/cmd/covid19.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package cmd
2+
3+
import (
4+
"github.com/openanno/bget/api/fetch"
5+
"github.com/openanno/bget/api/types"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
var covid19Endp types.Covid19Endpoints
10+
var Covid19Cmd = &cobra.Command{
11+
Use: "covid19",
12+
Short: "Query covid19api.com website APIs.",
13+
Long: `Query covid19api.com website APIs. Detail see https://covid19api.com`,
14+
Run: func(cmd *cobra.Command, args []string) {
15+
Covid19CmdRunOptions(cmd, args)
16+
},
17+
}
18+
19+
func Covid19CmdRunOptions(cmd *cobra.Command, args []string) {
20+
if fetch.Covid19(&covid19Endp, &bapiClis, func() { initCmd(cmd, args) }, nil) {
21+
bapiClis.HelpFlags = false
22+
}
23+
if bapiClis.HelpFlags {
24+
cmd.Help()
25+
}
26+
}
27+
28+
func init() {
29+
setGlobalFlag(Covid19Cmd, &bapiClis)
30+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.AllRoute, "all", "", false, `Get all Data.`)
31+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountriesRoute, "cts", "", false, `Get list of countries.`)
32+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryDayOneRoute, "ct-d-one", "", false, `Get list of cases per country per province by case type from the first recorded case.`)
33+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryDayOneTotalRoute, "ct-d-one-total", "", false, `Get list of cases per country by case type from the first recorded case.`)
34+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryRoute, "ct", "", false, `Get list of cases per country per province by case type.`)
35+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusDayOneLiveRoute, "ct-st-d-one-live", "", false, `Get list of cases per country per province by case type from the first recorded case, updated with latest live count.`)
36+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusDayOneRoute, "ct-st-d-one", "", false, `Get list of cases per country per province by case type from the first recorded case".`)
37+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusDayOneTotalRoute, "ct-st-d-one-total", "", false, `Get list of cases per country by case type from the first recorded case.`)
38+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusLiveRoute, "ct-st-live", "", false, `Daily list of cases per country per province by case type, updated with latest live count.`)
39+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusRoute, "ct-st", "", false, `Get list of cases per country per province by case type.`)
40+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusTotalRoute, "ct-st-total", "", false, `Get list of cases per country by case type.`)
41+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryTotalRoute, "ct-total", "", false, `Get list of cases per country by case type.`)
42+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.ExportRoute, "export", "", false, `Get all data as a zip file.`)
43+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.LiveCountryRoute, "live-ct", "", false, `Get live list of cases per country per province by case type.`)
44+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.LiveCountryStatusAfterDateRoute, "live-ct-st-date", "", false, `Get a time series of cases per country per province by case type after a date.`)
45+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.LiveCountryStatusRoute, "live-ct-st", "", false, `Get a time series of cases per country per province by case type.`)
46+
Covid19Cmd.Flags().BoolVarP(&covid19Endp.SummaryRoute, "summary", "", false, `Summary of new and total cases per country.`)
47+
Covid19Cmd.Flags().StringVarP(&covid19Endp.WebhookRoute, "webhook", "", "", `Add a webhook to be notified when new data becomes available.`)
48+
49+
Covid19Cmd.Flags().StringVarP(&covid19Endp.Country, "name", "", "", `Country name.`)
50+
Covid19Cmd.Flags().StringVarP(&covid19Endp.Status, "status", "", "", `Patient status [confirmed, recovered, deaths].`)
51+
Covid19Cmd.Flags().StringVarP(&covid19Endp.Date, "date", "", "", `After a given date.`)
52+
53+
Covid19Cmd.Example = ` # returns all data in the system. Warning: this request returns 8MB+ and takes 5+ seconds
54+
bget api covid19 --all
55+
# returns all countries and associated provinces
56+
bget api covid19 --cts
57+
# returns all cases by case type for a country from the first recorded case.
58+
bget api covid19 --ct --name China
59+
# returns all cases by case type for a country from the first recorded case.
60+
bget api covid19 --ct-d-one --name China
61+
# returns all cases by case type for a country.
62+
bget api covid19 --ct-d-one-total --name China
63+
# returns all cases by case type for a country from the first recorded case with the latest record being the live count.
64+
bget api covid19 --ct-st-d-one --name China --status confirmed
65+
# returns all cases by case type for a country from the first recorded case.
66+
bget api covid19 --ct-st-d-one-live --name China --status confirmed
67+
# returns all cases by case type for a country from the first recorded case
68+
bget api covid19 --ct-st-d-one-total --name China --status confirmed
69+
# returns all cases by case type for a country with the latest record being the live count.
70+
bget api covid19 --ct-st-live --name China --status confirmed
71+
# returns all cases by case type for a country.
72+
bget api covid19 --ct-st --name China --status confirmed
73+
# returns all cases by case type for a country.
74+
bget api covid19 --ct-st-total --name China --status confirmed
75+
# returns all cases of a country.
76+
bget api covid19 --ct-total --name China
77+
# returns all live cases by case type for a country.
78+
bget api covid19 --live-ct --name China
79+
# returns all live cases by case type for a country after a given date.
80+
bget api covid19 --live-ct-st-date --name China --status confirmed --date 2020-04-20T06:20:47Z
81+
# returns all live cases by case type for a country.
82+
bget api covid19 --live-ct-st --name China --status confirmed
83+
# a summary of new and total cases per country
84+
bget api covid19 --summary
85+
bget api covid19 --export
86+
bget api covid19 --webhook https://your_webhook.com`
87+
}

api/cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func init() {
4444
BapiCmd.AddCommand(Dataset2toolsCmd)
4545
BapiCmd.AddCommand(CligovCmd)
4646
BapiCmd.AddCommand(CrossRefCmd)
47+
BapiCmd.AddCommand(Covid19Cmd)
4748
wd, _ := os.Getwd()
4849

4950
BapiCmd.PersistentFlags().StringVarP(&(bapiClis.TaskID), "task-id", "k", stringo.RandString(15), "Task ID (random).")

api/fetch/covid19.go

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package fetch
2+
3+
import (
4+
"encoding/json"
5+
"io"
6+
"strings"
7+
8+
"github.com/openbiox/ligo/stringo"
9+
10+
"github.com/openanno/bget/api/types"
11+
)
12+
13+
const Covid19Host = "https://api.covid19api.com/"
14+
15+
// Covid19 access api.covid19api.com API
16+
func Covid19(endpoints *types.Covid19Endpoints, bapiClis *types.BapiClisT, f func(), of io.Writer) bool {
17+
setLog(bapiClis)
18+
if bapiClis.Format == "" {
19+
bapiClis.Format = "json"
20+
}
21+
netopt := setNetOpt(bapiClis)
22+
url := Covid19Host + setCovid19QuerySuffix(endpoints, bapiClis)
23+
if url == Covid19Host || url == Covid19Host+"?fmt=json" {
24+
return false
25+
}
26+
f()
27+
if endpoints.WebhookRoute != "" {
28+
val := make(map[string]string)
29+
val["URL"] = endpoints.WebhookRoute
30+
postData, _ := json.MarshalIndent(val, "", " ")
31+
32+
PostReq("api.mg-rast.org", url, postData, bapiClis, netopt, of)
33+
} else {
34+
GetReq("api.covid19api.com", url, bapiClis, netopt, of)
35+
}
36+
37+
return true
38+
}
39+
40+
func setCovid19QuerySuffix(endpoints *types.Covid19Endpoints, BapiClis *types.BapiClisT) (suffix string) {
41+
suffixList := []string{}
42+
if endpoints.AllRoute {
43+
suffix = "all"
44+
} else if endpoints.CountriesRoute {
45+
suffix = "countries"
46+
} else if endpoints.CountryDayOneRoute {
47+
suffix = "dayone/country/:country"
48+
} else if endpoints.CountryDayOneTotalRoute {
49+
suffix = "total/dayone/country/:country"
50+
} else if endpoints.CountryRoute {
51+
suffix = "country/:country"
52+
} else if endpoints.CountryStatusDayOneLiveRoute {
53+
suffix = "dayone/country/:country/status/:status/live"
54+
} else if endpoints.CountryStatusDayOneRoute {
55+
suffix = "dayone/country/:country/status/:status"
56+
} else if endpoints.CountryStatusDayOneTotalRoute {
57+
suffix = "total/dayone/country/:country/status/:status"
58+
} else if endpoints.CountryStatusLiveRoute {
59+
suffix = "country/:country/status/:status/live"
60+
} else if endpoints.CountryStatusRoute {
61+
suffix = "country/:country/status/:status"
62+
} else if endpoints.CountryStatusTotalRoute {
63+
suffix = "total/country/:country/status/:status"
64+
} else if endpoints.CountryTotalRoute {
65+
suffix = "total/country/:country"
66+
} else if endpoints.ExportRoute {
67+
suffix = "export"
68+
} else if endpoints.LiveCountryRoute {
69+
suffix = "live/country/:country"
70+
} else if endpoints.LiveCountryStatusAfterDateRoute {
71+
suffix = "live/country/:country/status/:status/date/:date"
72+
} else if endpoints.LiveCountryStatusRoute {
73+
suffix = "live/country/:country/status/:status"
74+
} else if endpoints.SummaryRoute {
75+
suffix = "summary"
76+
} else if endpoints.WebhookRoute != "" {
77+
suffix = "webhook"
78+
}
79+
if strings.Contains(suffix, ":country") {
80+
suffix = stringo.StrReplaceAll(suffix, ":country", endpoints.Country)
81+
}
82+
if strings.Contains(suffix, ":status") {
83+
suffix = stringo.StrReplaceAll(suffix, ":status", endpoints.Status)
84+
}
85+
if strings.Contains(suffix, ":date") {
86+
suffix = stringo.StrReplaceAll(suffix, ":date", endpoints.Date)
87+
}
88+
if BapiClis.Extra != "" {
89+
suffixList = append(suffixList, BapiClis.Extra)
90+
}
91+
if len(suffixList) > 0 {
92+
suffix = suffix + "?" + strings.Join(suffixList, "&")
93+
}
94+
return suffix
95+
}

api/types/api.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,29 @@ type MgRastEndpoints struct {
139139

140140
Auth string
141141
}
142+
143+
// Covid19Endpoints is https://api.covid19api.com/ website endpoints
144+
type Covid19Endpoints struct {
145+
AllRoute bool
146+
CountriesRoute bool
147+
CountryDayOneRoute bool
148+
CountryDayOneTotalRoute bool
149+
CountryRoute bool
150+
CountryStatusDayOneLiveRoute bool
151+
CountryStatusDayOneRoute bool
152+
CountryStatusDayOneTotalRoute bool
153+
CountryStatusLiveRoute bool
154+
CountryStatusRoute bool
155+
CountryStatusTotalRoute bool
156+
CountryTotalRoute bool
157+
ExportRoute bool
158+
LiveCountryRoute bool
159+
LiveCountryStatusAfterDateRoute bool
160+
LiveCountryStatusRoute bool
161+
SummaryRoute bool
162+
WebhookRoute string
163+
164+
Country string
165+
Status string
166+
Date string
167+
}

go.mod

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@ require (
99
github.com/biogo/ncbi v1.0.2
1010
github.com/bitly/go-simplejson v0.5.0 // indirect
1111
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
12-
github.com/chromedp/cdproto v0.0.0-20200209033844-7e00b02ea7d2 // indirect
12+
github.com/chromedp/cdproto v0.0.0-20200424080200-0de008e41fa0 // indirect
1313
github.com/chromedp/chromedp v0.5.3
1414
github.com/gobwas/ws v1.0.3 // indirect
1515
github.com/gocolly/colly v1.2.0
1616
github.com/google/go-github/v27 v27.0.6
17+
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
1718
github.com/mailru/easyjson v0.7.1 // indirect
1819
github.com/mattn/go-runewidth v0.0.9 // indirect
19-
github.com/nwaples/rardecode v1.1.0 // indirect
2020
github.com/olekukonko/tablewriter v0.0.4
2121
github.com/onsi/ginkgo v1.11.0 // indirect
2222
github.com/onsi/gomega v1.8.1 // indirect
23-
github.com/openbiox/ligo v0.0.0-20200422182023-2b3120cef2ab
24-
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
23+
github.com/openbiox/ligo v0.0.0-20200429101038-6db14930de2a
2524
github.com/sirupsen/logrus v1.5.0
2625
github.com/spf13/cobra v1.0.0
27-
github.com/spf13/pflag v1.0.5 // indirect
2826
github.com/tidwall/pretty v1.0.1
29-
github.com/ulikunitz/xz v0.5.7 // indirect
30-
github.com/vbauerster/mpb/v5 v5.0.3
31-
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd // indirect
27+
github.com/vbauerster/mpb/v5 v5.0.4
28+
golang.org/x/crypto v0.0.0-20200427165652-729f1e841bcc // indirect
3229
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
33-
google.golang.org/appengine v1.6.6 // indirect
30+
golang.org/x/sys v0.0.0-20200428200454-593003d681fa // indirect
3431
)

0 commit comments

Comments
 (0)