Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created July 7, 2010 20:10
Show Gist options
  • Save jhsu/467203 to your computer and use it in GitHub Desktop.
Save jhsu/467203 to your computer and use it in GitHub Desktop.
1 3000721 A W 4 4 60 33 5 28 1
1 3000727 G K 24 24 60 32 5 27 1
1 3000767 T K 21 21 60 29 5 24 1
1 3001443 G A 96 96 60 23 23 0 2
1 3002052 C T 48 48 60 7 7 0 2
1 3004103 C T 45 45 60 6 6 0 1
1 3004121 * +AC/* 99 99 60 5 2 3 1
1 3004918 C T 53 54 30 15 2 2 1
1 3004919 C G 29 57 30 15 5 10 1
1 3004964 T A 31 45 27 7 1 6 1
mongoimport -d pileup -c pileup -type tsv --stopOnError -f chrID,chrLOC,refBase,conBase,consQual,SNPQual,maxMapqual,numbReadBases,numberMajorRead,numberMinorRead,strain differencestest.pileup
require 'mongo'
require 'mongoid'
Mongoid.configure do |config|
name = "pileup"
host = "localhost"
config.master = Mongo::Connection.new.db(name)
config.persist_in_safe_mode = false
end
class Entry
include Mongoid::Document
store_in :pileup
field :chrID
field :chrLOC
field :refBase
field :conBase
field :consqual
field :SNPQual
field :maxMapqual
field :numbReadBases
field :numberMajorRead
field :numberMinorRead
field :strain
index [[:chrID, Mongo::ASCENDING], [:charLOC, Mongo::ASCENDING]]
end
Entry.only(:chrID, :chrLOC, :strain).where(:chrID => 1).where(:chrLOC.gt => 13000757).where(:chrLOC.lt => 13000808).to_a
# Profiler
#=> { "ts" : "Wed Jul 07 2010 16:18:59 GMT-0400 (EST)", "info" : "query pileup.$cmd ntoreturn:1 command: { count: \"pileup\", query: { chrID: 1, chrLOC: { $lt: 13000808 } }, fields: { chrID: 1, chrLOC: 1, strain: 1, _type: 1 } } reslen:57 bytes:41", "millis" : 0 }
--- sample query
SELECT strain, chrID, chrLOC FROM akrdba WHERE chrID = 1 and chrpos > 13000757 AND chrpos < 13000808
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment