Commit 4fe0af9 1 parent 0f68138 commit 4fe0af9 Copy full SHA for 4fe0af9
File tree 2 files changed +22
-17
lines changed
2 files changed +22
-17
lines changed Original file line number Diff line number Diff line change @@ -8,20 +8,13 @@ or re-downloaded if corrupt. Aborted downloads are safely resumed.
8
8
9
9
` ncbi-blast-dbs ` is faster than NCBI's ` update_blastdb.pl ` . But unlike
10
10
` update_blastdb.pl ` , which is a pure Perl script, ` ncbi-blast-dbs ` delegates
11
- download and checksum verification to ` wget ` and ` md5sum ` and is thus not as
12
- universal.
11
+ download and checksum verification to ` wget ` and ` md5sum ` / ` md5 ` and is thus
12
+ not as universal.
13
13
14
14
### Installation
15
15
16
16
gem install ncbi-blast-dbs
17
17
18
- #### Note for macOS users
19
-
20
- If ` md5sum ` command is not present, you can install it using
21
- [ ` Homebrew ` ] ( https://brew.sh ) :
22
-
23
- brew install md5sha1sum
24
-
25
18
### Usage
26
19
27
20
#### List available BLAST databases
Original file line number Diff line number Diff line change @@ -12,14 +12,26 @@ def download(url)
12
12
# the server is newer and if so download the new copy.
13
13
sh "wget -N --no-verbose #{ url } "
14
14
15
- # Immediately download md5 and verify the tarball. Re-download tarball if
16
- # corrupt; extract otherwise.
17
- sh "wget --no-verbose #{ url } .md5 && md5sum -c #{ file } .md5" do |matched , _ |
18
- if !matched
19
- sh "rm #{ file } #{ file } .md5" ; download ( url )
20
- else
21
- sh "tar xf #{ file } "
22
- end
15
+ # Download Md5
16
+ sh "wget --no-verbose #{ url } .md5"
17
+
18
+ # Verify the tarball using md5sum or md5
19
+ if system ( "which md5sum > /dev/null" )
20
+ matched = system ( "md5sum -c #{ file } .md5" )
21
+ elsif system ( "which md5 > /dev/null" )
22
+ md5_out = %x[md5 -q #{ file } ] . chomp
23
+ md5_actual = File . read ( "#{ file } .md5" ) . split [ 0 ]
24
+ matched = md5_out == md5_actual
25
+ else
26
+ puts "Cannot find md5sum or md5. Please install md5sum or md5 and try again"
27
+ exit 1
28
+ end
29
+
30
+ # Re-download tarball if corrupt; extract otherwise.
31
+ if !matched
32
+ sh "rm #{ file } #{ file } .md5" ; download ( url )
33
+ else
34
+ sh "tar xf #{ file } "
23
35
end
24
36
end
25
37
You can’t perform that action at this time.
0 commit comments