Possibly fixed zipfulldata job, currently testing. Added rake task to remove annotation for vg-SNPs and to remove annotation without SNPs.

This commit is contained in:
Philipp Bayer
2013-06-09 14:38:15 +10:00
parent f434a478b2
commit 3ecf49fec3
3 changed files with 69 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ class Zipfulldata
def run(target_address)
genotypes = Genotype.includes(user: :user_phenotypes).all
log "Got #{genotypes.length} genotypes"
# only try to create csv & zip-file if there is data at all.
if genotypes.empty?
@@ -42,7 +43,9 @@ class Zipfulldata
end
begin
log "Making tmpdir #{tmp_dir}"
Dir.mkdir(tmp_dir)
log "Starting zipfile #{zip_fs_path}"
Zip::ZipFile.open(zip_fs_path, Zip::ZipFile::CREATE) do |zipfile|
create_user_csv(genotypes, zipfile)
create_fitbit_csv(zipfile)

View File

@@ -0,0 +1,46 @@
def check_to_destroy(type)
set_to_destroy = Set.new []
type.find_each do |m|
parental = m.snp
if parental == nil
set_to_destroy.add(m)
next
end
# check if name of parental snp is a pesky vg-SNP
if parental.name.start_with? "vg"
set_to_destroy.add(m)
end
end
set_to_destroy
end
def destroy(set, type)
set.each do |s|
if s.parental != nil and s.parental.name.start_with? "vg"
# has to be a vg-SNP, we don't want annotation for these right now as they are mostly bogus
s.parental.update_attributes(:ranking => 0)
end
# delete
puts "Want to destroy: #{s.inspect}"
# type.destroy(s)
end
end
namespace :snps do
desc "Iterates over all annotations, deletes a) ones without SNP and b) annotations for SNPs starting in 'vg' (also sets vg-SNPs scores to 0)"
task :clean_annotation => :environment do
require 'set'
# need to store annotations to destroy first, iterating over stuff
# while destroying it only makes problems
ms_to_destroy = check_to_destroy(MendeleyPaper)
sn_to_destroy = check_to_destroy(SnpediaPaper)
sp_to_destroy = check_to_destroy(PlosPaper)
spg_to_destroy = check_to_destroy(PgpAnnotation)
gg_to_destroy = check_to_destroy(GenomeGovPaper)
destroy(ms_to_destroy, MendeleyPaper)
destroy(sn_to_destroy, SnpediaPaper)
destroy(sp_to_destroy, PlosPaper)
destroy(spg_to_destroy, PgpAnnotation)
destroy(gg_to_destroy, GenomeGovPaper)
end
end

View File

@@ -10,6 +10,10 @@ namespace :snps do
f.write("SNP\tPosition\tChromosome\tYear\tFirst Author\tTitle\tDOI\tOpen Access\tLink\n")
MendeleyPaper.find_each do |m|
parental = m.snp
if parental == nil
puts m.snp_id
next
end
position = parental.position
name = parental.name
chrom = parental.chromosome
@@ -26,6 +30,10 @@ namespace :snps do
f.write("SNP\tPosition\tChromosome\tSummary\tLink\n")
SnpediaPaper.find_each do |sn|
parental = sn.snp
if parental == nil
puts m.snp_id
next
end
position = parental.position
name = parental.name
chrom = parental.chromosome
@@ -38,6 +46,10 @@ namespace :snps do
f.write("SNP\tPosition\tChromosome\tFirst author\tTitle\tDOI\tYear\n")
PlosPaper.find_each do |sp|
parental = sp.snp
if parental == nil
puts m.snp_id
next
end
position = parental.position
name = parental.name
chrom = parental.chromosome
@@ -53,6 +65,10 @@ namespace :snps do
f.write("SNP\tPosition\tChromosome\tGene\tQualified Impact\tInheritance\tSummary\tTrait\n")
PgpAnnotation.find_each do |spg|
parental = sp.snp
if parental == nil
puts m.snp_id
next
end
position = parental.position
name = parental.name
chrom = parental.chromosome
@@ -68,6 +84,10 @@ namespace :snps do
f.write("SNP\tPosition\tChromosome\tFirst author\tTitle\tPubmed-link\tYear\tJournal\tTrait\tp-value\tp-value description\tConfidence Interval\n")
GenomeGovPaper.find_each do |gg|
parental = gg.snp
if parental == nil
puts m.snp_id
next
end
position = parental.position
name = parental.name
chrom = parental.chromosome