Skip to content

Commit

Permalink
update README.md and go.mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Miachol committed Apr 29, 2020
1 parent d17653c commit dfb84e0
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ vendor
.DS_Store
_log
go.sum

.XML.tmp*
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2020-04-29 Li Jianfeng <[email protected]>

* support covid19 api

2020-04-22 Li Jianfeng <[email protected]>

* bio.tools API support --from and --size flag
Expand Down
45 changes: 40 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ For website spider (optional):

For raw sequencing data query (optional):

- [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`;
- [sra-tools](https://github.com/ncbi/sra-tools) for SRA and dbGAP database: `bget i sratools`;
- [pyega3](https://github.com/EGA-archive/ega-download-client) for EGA database: `pip3 install pyega3`;
- [gdc-client](https://gdc.cancer.gov/access-data/gdc-data-transfer-tool) for GDC portal: `bget i base/gdc-client@1.4.0 -u`.
- [gdc-client](https://gdc.cancer.gov/access-data/gdc-data-transfer-tool) for GDC portal: `bget i gdc-client@1.5.0 -u`.

## Installation

```bash
# windows
wget https://github.com/openanno/bget/releases/download/v0.2.4/bget.exe
wget https://github.com/openanno/bget/releases/download/v0.3.0/bget.exe

# osx
wget https://github.com/openanno/bget/releases/download/v0.2.4/bget_osx
wget https://github.com/openanno/bget/releases/download/v0.3.0/bget_osx
mv bget_osx bget
chmod a+x bget

# linux
wget https://github.com/openanno/bget/releases/download/v0.2.4/bget_linux64
wget https://github.com/openanno/bget/releases/download/v0.3.0/bget_linux64
mv bget_linux64 bget
chmod a+x bget

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

bget api mgrast compute --info

# returns all data in the system. Warning: this request returns 8MB+ and takes 5+ seconds
bget api covid19 --all
# returns all countries and associated provinces
bget api covid19 --cts
# returns all cases by case type for a country from the first recorded case.
bget api covid19 --ct --name China
# returns all cases by case type for a country from the first recorded case.
bget api covid19 --ct-d-one --name China
# returns all cases by case type for a country.
bget api covid19 --ct-d-one-total --name China
# returns all cases by case type for a country from the first recorded case with the latest record being the live count.
bget api covid19 --ct-st-d-one --name China --status confirmed
# returns all cases by case type for a country from the first recorded case.
bget api covid19 --ct-st-d-one-live --name China --status confirmed
# returns all cases by case type for a country from the first recorded case
bget api covid19 --ct-st-d-one-total --name China --status confirmed
# returns all cases by case type for a country with the latest record being the live count.
bget api covid19 --ct-st-live --name China --status confirmed
# returns all cases by case type for a country.
bget api covid19 --ct-st --name China --status confirmed
# returns all cases by case type for a country.
bget api covid19 --ct-st-total --name China --status confirmed
# returns all cases of a country.
bget api covid19 --ct-total --name China
# returns all live cases by case type for a country.
bget api covid19 --live-ct --name China
# returns all live cases by case type for a country after a given date.
bget api covid19 --live-ct-st-date --name China --status confirmed --date 2020-04-20T06:20:47Z
# returns all live cases by case type for a country.
bget api covid19 --live-ct-st --name China --status confirmed
# a summary of new and total cases per country
bget api covid19 --summary
bget api covid19 --export
bget api covid19 --webhook https://your_webhook.com
```

### Query DOI resources
Expand Down
18 changes: 18 additions & 0 deletions _examples/bapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ bget api gdc -m -q "5b2974ad-f932-499b-90a3-93577a9f0573,556e5e3f-0ab9-4b6c-aa62
bget api gdc -m -q "5b2974ad-f932-499b-90a3-93577a9f0573,556e5e3f-0ab9-4b6c-aa62-c42f6a6cf20c" -n
bget api gdc -d -q "5b2974ad-f932-499b-90a3-93577a9f0573" -n
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 -
bget api covid19 --all
bget api covid19 --cts
bget api covid19 --ct --name China
bget api covid19 --ct-d-one --name China
bget api covid19 --ct-d-one-total --name China
bget api covid19 --ct-st-d-one --name China --status confirmed
bget api covid19 --ct-st-d-one-live --name China --status confirmed
bget api covid19 --ct-st-d-one-total --name China --status confirmed
bget api covid19 --ct-st-live --name China --status confirmed
bget api covid19 --ct-st --name China --status confirmed
bget api covid19 --ct-st-total --name China --status confirmed
bget api covid19 --ct-total --name China
bget api covid19 --live-ct --name China
bget api covid19 --live-ct-st-date --name China --status confirmed --date 2020-04-20T06:20:47Z
bget api covid19 --live-ct-st --name China --status confirmed
bget api covid19 --summary
bget api covid19 --export
bget api covid19 --webhook https://your_webhook.com

cd ..
bget --clean
3 changes: 3 additions & 0 deletions _meta/tools/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@
"Name": "golang",
"Description": "",
"Versions": [
"1.14.2",
"1.14.1",
"1.14",
"1.13.4",
"1.13.3",
"1.13.2",
Expand Down
87 changes: 87 additions & 0 deletions api/cmd/covid19.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package cmd

import (
"github.com/openanno/bget/api/fetch"
"github.com/openanno/bget/api/types"
"github.com/spf13/cobra"
)

var covid19Endp types.Covid19Endpoints
var Covid19Cmd = &cobra.Command{
Use: "covid19",
Short: "Query covid19api.com website APIs.",
Long: `Query covid19api.com website APIs. Detail see https://covid19api.com`,
Run: func(cmd *cobra.Command, args []string) {
Covid19CmdRunOptions(cmd, args)
},
}

func Covid19CmdRunOptions(cmd *cobra.Command, args []string) {
if fetch.Covid19(&covid19Endp, &bapiClis, func() { initCmd(cmd, args) }, nil) {
bapiClis.HelpFlags = false
}
if bapiClis.HelpFlags {
cmd.Help()
}
}

func init() {
setGlobalFlag(Covid19Cmd, &bapiClis)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.AllRoute, "all", "", false, `Get all Data.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountriesRoute, "cts", "", false, `Get list of countries.`)
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.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryDayOneTotalRoute, "ct-d-one-total", "", false, `Get list of cases per country by case type from the first recorded case.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryRoute, "ct", "", false, `Get list of cases per country per province by case type.`)
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.`)
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".`)
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.`)
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.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusRoute, "ct-st", "", false, `Get list of cases per country per province by case type.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusTotalRoute, "ct-st-total", "", false, `Get list of cases per country by case type.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryTotalRoute, "ct-total", "", false, `Get list of cases per country by case type.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.ExportRoute, "export", "", false, `Get all data as a zip file.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.LiveCountryRoute, "live-ct", "", false, `Get live list of cases per country per province by case type.`)
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.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.LiveCountryStatusRoute, "live-ct-st", "", false, `Get a time series of cases per country per province by case type.`)
Covid19Cmd.Flags().BoolVarP(&covid19Endp.SummaryRoute, "summary", "", false, `Summary of new and total cases per country.`)
Covid19Cmd.Flags().StringVarP(&covid19Endp.WebhookRoute, "webhook", "", "", `Add a webhook to be notified when new data becomes available.`)

Covid19Cmd.Flags().StringVarP(&covid19Endp.Country, "name", "", "", `Country name.`)
Covid19Cmd.Flags().StringVarP(&covid19Endp.Status, "status", "", "", `Patient status [confirmed, recovered, deaths].`)
Covid19Cmd.Flags().StringVarP(&covid19Endp.Date, "date", "", "", `After a given date.`)

Covid19Cmd.Example = ` # returns all data in the system. Warning: this request returns 8MB+ and takes 5+ seconds
bget api covid19 --all
# returns all countries and associated provinces
bget api covid19 --cts
# returns all cases by case type for a country from the first recorded case.
bget api covid19 --ct --name China
# returns all cases by case type for a country from the first recorded case.
bget api covid19 --ct-d-one --name China
# returns all cases by case type for a country.
bget api covid19 --ct-d-one-total --name China
# returns all cases by case type for a country from the first recorded case with the latest record being the live count.
bget api covid19 --ct-st-d-one --name China --status confirmed
# returns all cases by case type for a country from the first recorded case.
bget api covid19 --ct-st-d-one-live --name China --status confirmed
# returns all cases by case type for a country from the first recorded case
bget api covid19 --ct-st-d-one-total --name China --status confirmed
# returns all cases by case type for a country with the latest record being the live count.
bget api covid19 --ct-st-live --name China --status confirmed
# returns all cases by case type for a country.
bget api covid19 --ct-st --name China --status confirmed
# returns all cases by case type for a country.
bget api covid19 --ct-st-total --name China --status confirmed
# returns all cases of a country.
bget api covid19 --ct-total --name China
# returns all live cases by case type for a country.
bget api covid19 --live-ct --name China
# returns all live cases by case type for a country after a given date.
bget api covid19 --live-ct-st-date --name China --status confirmed --date 2020-04-20T06:20:47Z
# returns all live cases by case type for a country.
bget api covid19 --live-ct-st --name China --status confirmed
# a summary of new and total cases per country
bget api covid19 --summary
bget api covid19 --export
bget api covid19 --webhook https://your_webhook.com`
}
1 change: 1 addition & 0 deletions api/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func init() {
BapiCmd.AddCommand(Dataset2toolsCmd)
BapiCmd.AddCommand(CligovCmd)
BapiCmd.AddCommand(CrossRefCmd)
BapiCmd.AddCommand(Covid19Cmd)
wd, _ := os.Getwd()

BapiCmd.PersistentFlags().StringVarP(&(bapiClis.TaskID), "task-id", "k", stringo.RandString(15), "Task ID (random).")
Expand Down
95 changes: 95 additions & 0 deletions api/fetch/covid19.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package fetch

import (
"encoding/json"
"io"
"strings"

"github.com/openbiox/ligo/stringo"

"github.com/openanno/bget/api/types"
)

const Covid19Host = "https://api.covid19api.com/"

// Covid19 access api.covid19api.com API
func Covid19(endpoints *types.Covid19Endpoints, bapiClis *types.BapiClisT, f func(), of io.Writer) bool {
setLog(bapiClis)
if bapiClis.Format == "" {
bapiClis.Format = "json"
}
netopt := setNetOpt(bapiClis)
url := Covid19Host + setCovid19QuerySuffix(endpoints, bapiClis)
if url == Covid19Host || url == Covid19Host+"?fmt=json" {
return false
}
f()
if endpoints.WebhookRoute != "" {
val := make(map[string]string)
val["URL"] = endpoints.WebhookRoute
postData, _ := json.MarshalIndent(val, "", " ")

PostReq("api.mg-rast.org", url, postData, bapiClis, netopt, of)
} else {
GetReq("api.covid19api.com", url, bapiClis, netopt, of)
}

return true
}

func setCovid19QuerySuffix(endpoints *types.Covid19Endpoints, BapiClis *types.BapiClisT) (suffix string) {
suffixList := []string{}
if endpoints.AllRoute {
suffix = "all"
} else if endpoints.CountriesRoute {
suffix = "countries"
} else if endpoints.CountryDayOneRoute {
suffix = "dayone/country/:country"
} else if endpoints.CountryDayOneTotalRoute {
suffix = "total/dayone/country/:country"
} else if endpoints.CountryRoute {
suffix = "country/:country"
} else if endpoints.CountryStatusDayOneLiveRoute {
suffix = "dayone/country/:country/status/:status/live"
} else if endpoints.CountryStatusDayOneRoute {
suffix = "dayone/country/:country/status/:status"
} else if endpoints.CountryStatusDayOneTotalRoute {
suffix = "total/dayone/country/:country/status/:status"
} else if endpoints.CountryStatusLiveRoute {
suffix = "country/:country/status/:status/live"
} else if endpoints.CountryStatusRoute {
suffix = "country/:country/status/:status"
} else if endpoints.CountryStatusTotalRoute {
suffix = "total/country/:country/status/:status"
} else if endpoints.CountryTotalRoute {
suffix = "total/country/:country"
} else if endpoints.ExportRoute {
suffix = "export"
} else if endpoints.LiveCountryRoute {
suffix = "live/country/:country"
} else if endpoints.LiveCountryStatusAfterDateRoute {
suffix = "live/country/:country/status/:status/date/:date"
} else if endpoints.LiveCountryStatusRoute {
suffix = "live/country/:country/status/:status"
} else if endpoints.SummaryRoute {
suffix = "summary"
} else if endpoints.WebhookRoute != "" {
suffix = "webhook"
}
if strings.Contains(suffix, ":country") {
suffix = stringo.StrReplaceAll(suffix, ":country", endpoints.Country)
}
if strings.Contains(suffix, ":status") {
suffix = stringo.StrReplaceAll(suffix, ":status", endpoints.Status)
}
if strings.Contains(suffix, ":date") {
suffix = stringo.StrReplaceAll(suffix, ":date", endpoints.Date)
}
if BapiClis.Extra != "" {
suffixList = append(suffixList, BapiClis.Extra)
}
if len(suffixList) > 0 {
suffix = suffix + "?" + strings.Join(suffixList, "&")
}
return suffix
}
26 changes: 26 additions & 0 deletions api/types/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,29 @@ type MgRastEndpoints struct {

Auth string
}

// Covid19Endpoints is https://api.covid19api.com/ website endpoints
type Covid19Endpoints struct {
AllRoute bool
CountriesRoute bool
CountryDayOneRoute bool
CountryDayOneTotalRoute bool
CountryRoute bool
CountryStatusDayOneLiveRoute bool
CountryStatusDayOneRoute bool
CountryStatusDayOneTotalRoute bool
CountryStatusLiveRoute bool
CountryStatusRoute bool
CountryStatusTotalRoute bool
CountryTotalRoute bool
ExportRoute bool
LiveCountryRoute bool
LiveCountryStatusAfterDateRoute bool
LiveCountryStatusRoute bool
SummaryRoute bool
WebhookRoute string

Country string
Status string
Date string
}
15 changes: 6 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,23 @@ require (
github.com/biogo/ncbi v1.0.2
github.com/bitly/go-simplejson v0.5.0 // indirect
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
github.com/chromedp/cdproto v0.0.0-20200209033844-7e00b02ea7d2 // indirect
github.com/chromedp/cdproto v0.0.0-20200424080200-0de008e41fa0 // indirect
github.com/chromedp/chromedp v0.5.3
github.com/gobwas/ws v1.0.3 // indirect
github.com/gocolly/colly v1.2.0
github.com/google/go-github/v27 v27.0.6
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/mailru/easyjson v0.7.1 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/olekukonko/tablewriter v0.0.4
github.com/onsi/ginkgo v1.11.0 // indirect
github.com/onsi/gomega v1.8.1 // indirect
github.com/openbiox/ligo v0.0.0-20200422182023-2b3120cef2ab
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
github.com/openbiox/ligo v0.0.0-20200429101038-6db14930de2a
github.com/sirupsen/logrus v1.5.0
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/tidwall/pretty v1.0.1
github.com/ulikunitz/xz v0.5.7 // indirect
github.com/vbauerster/mpb/v5 v5.0.3
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd // indirect
github.com/vbauerster/mpb/v5 v5.0.4
golang.org/x/crypto v0.0.0-20200427165652-729f1e841bcc // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
google.golang.org/appengine v1.6.6 // indirect
golang.org/x/sys v0.0.0-20200428200454-593003d681fa // indirect
)

0 comments on commit dfb84e0

Please sign in to comment.