Skip to content

Commit

Permalink
update ncbi query
Browse files Browse the repository at this point in the history
  • Loading branch information
Miachol committed Jan 19, 2020
1 parent cc94a78 commit 945f310
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 0 additions & 2 deletions api/cmd/ncbi.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ func init() {
setGlobalFlag(ncbiCmd, &BapiClis)
ncbiCmd.Flags().StringVarP(&ncbiClis.NcbiDB, "db", "d", "pubmed", "Db specifies the database to search")
ncbiCmd.Flags().IntVarP(&ncbiClis.NcbiRetmax, "per-size", "m", 100, "Retmax specifies the number of records to be retrieved per request.")
//ncbiCmd.Flags().StringVarP(&ncbiClis.NcbiKeywords, "keywords", "w", "algorithm, tool, model, pipleline, method, database, workflow, dataset, bioinformatics, sequencing, http, github.com, gitlab.com, bitbucket.org", "Keywords to extracted from abstract.")
ncbiCmd.Flags().IntVarP(&BapiClis.Thread, "thread", "t", 2, "Thread to process.")
//ncbiCmd.Flags().BoolVarP(&BapiClis.CallCor, "call-cor", "", false, "Wheather to calculate the corelated keywords, and return the sentence contains >=2 keywords.")
ncbiCmd.Flags().StringVarP(&BapiClis.Email, "email", "e", "[email protected]", "Email specifies the email address to be sent to the server (NCBI website is required).")

ncbiCmd.Example = ` # query pubmed with 'B-ALL'
Expand Down
7 changes: 5 additions & 2 deletions api/fetch/ncbi.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ func Ncbi(BapiClis *types.BapiClisT, ncbiClis *types.NcbiClisT) {
log.Fatalf("error: %v\n", err)
}
log.Infof("Available retrieve %d records.", s.Count)
if s.Count == 0 {
return
}
from, end := cnet.SetQueryFromEnd(BapiClis.From, BapiClis.Size, s.Count)
log.Infof("Will retrieve %d records, from %d to %d.", end-from+1, from+1, end+1)
log.Infof("Will retrieve %d records, from %d to %d.", end-from, from+1, end)

of := cio.NewOutStream(BapiClis.Outfn, "")
defer of.Close()
Expand All @@ -38,7 +41,7 @@ func Ncbi(BapiClis *types.BapiClisT, ncbiClis *types.NcbiClisT) {
bn, n int64
)
if p.RetMax > end-from {
p.RetMax = end - from + 1
p.RetMax = end - from
}
for p.RetStart = from; p.RetStart < end; p.RetStart += p.RetMax {
log.Infof("Attempting to retrieve %d records: %d-%d with %d retries.", p.RetMax, p.RetStart+1, p.RetMax+p.RetStart, BapiClis.Retries)
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package cmd

var version = "v0.2.4"
var version = "v0.2.4-1"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
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-20200118071238-d342cb716c4e
github.com/openbiox/ligo v0.0.0-20200119135627-2571ec0d416e
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5 // indirect
Expand Down

0 comments on commit 945f310

Please sign in to comment.