Skip to content

Instantly share code, notes, and snippets.

@epaule
Created December 4, 2023 11:32
Show Gist options
  • Save epaule/4c5f7bddbe4436defcb1abe9f2ec8407 to your computer and use it in GitHub Desktop.
Save epaule/4c5f7bddbe4436defcb1abe9f2ec8407 to your computer and use it in GitHub Desktop.
#!/nfs/users/nfs_m/mh6/.linuxbrew/homebrew/bin/ruby
# usage: ruby get_rnaseq_number_for_species.rb "Xestospongia muta"
require "net/http"
require "uri"
require "cgi"
species = ARGV[0]
species = CGI.escapeURIComponent(species)
uri = URI("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=sra&term=#{species}%5borgn%5d+AND+biomol_rna%5bProp%5d&usehistory=y")
r = Net::HTTP.get_response(uri)
spots = 0
if r.body =~ /\<Count\>\d+\<\/Count\>/
spots = r.body.to_enum(:scan,/\<Count\>(\d+)\<\/Count\>/).map{|r| $1.to_i }.sum
end
puts "#{ARGV[0]}\t#{spots}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment