-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
282 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ vendor | |
.DS_Store | ||
_log | ||
go.sum | ||
|
||
.XML.tmp* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters