transrate 1.0.0.alpha.8.bowtie → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/README.md +2 -0
  4. data/bin/transrate +3 -5
  5. data/deps/deps.yaml +12 -20
  6. data/lib/transrate.rb +1 -1
  7. data/lib/transrate/assembly.rb +21 -0
  8. data/lib/transrate/contig.rb +33 -3
  9. data/lib/transrate/express.rb +29 -24
  10. data/lib/transrate/read_metrics.rb +40 -28
  11. data/lib/transrate/sam_checker.rb +6 -31
  12. data/lib/transrate/samtools.rb +1 -1
  13. data/lib/transrate/score_optimiser.rb +31 -0
  14. data/lib/transrate/snap.rb +28 -3
  15. data/lib/transrate/transrater.rb +5 -10
  16. data/lib/transrate/version.rb +1 -1
  17. data/test/data/express_results.xprs +5 -0
  18. data/test/test_bin.rb +2 -8
  19. data/test/test_express.rb +22 -0
  20. data/test/test_read_metrics.rb +17 -29
  21. data/test/test_transrater.rb +1 -1
  22. data/test/vagrant/centos_6.5_64/Vagrantfile +122 -0
  23. data/test/vagrant/debian_7.4_64/Vagrantfile +126 -0
  24. data/test/vagrant/debian_7.4_64/provision.sh +28 -0
  25. data/test/vagrant/fedora_20_64/Vagrantfile +122 -0
  26. data/test/vagrant/fedora_20_64/provision.sh +16 -0
  27. data/test/vagrant/fedora_20_64/sample_data/params.xprs +182 -0
  28. data/test/vagrant/fedora_20_64/sample_data/reads_1.fastq +40000 -0
  29. data/test/vagrant/fedora_20_64/sample_data/reads_1.fastq-reads_2.fastq-read_count.txt +1 -0
  30. data/test/vagrant/fedora_20_64/sample_data/reads_2.fastq +40000 -0
  31. data/test/vagrant/fedora_20_64/sample_data/transcripts.fasta +498 -0
  32. data/test/vagrant/fedora_20_64/sample_data/transcripts.fasta_results.xprs +16 -0
  33. data/test/vagrant/fedora_20_64/sample_data/transcripts/Genome +17 -0
  34. data/test/vagrant/fedora_20_64/sample_data/transcripts/GenomeIndex +1 -0
  35. data/test/vagrant/fedora_20_64/sample_data/transcripts/GenomeIndexHash +0 -0
  36. data/test/vagrant/fedora_20_64/sample_data/transcripts/OverflowTable +0 -0
  37. data/test/vagrant/ubuntu_12.04_64/Vagrantfile +126 -0
  38. data/test/vagrant/ubuntu_12.04_64/provision.sh +24 -0
  39. data/test/vagrant/ubuntu_12.04_64/sample_data/params.xprs +182 -0
  40. data/test/vagrant/ubuntu_12.04_64/sample_data/reads_1.fastq +40000 -0
  41. data/test/vagrant/ubuntu_12.04_64/sample_data/reads_1.fastq-reads_2.fastq-read_count.txt +1 -0
  42. data/test/vagrant/ubuntu_12.04_64/sample_data/reads_2.fastq +40000 -0
  43. data/test/vagrant/ubuntu_12.04_64/sample_data/transcripts.fasta +498 -0
  44. data/test/vagrant/ubuntu_12.04_64/sample_data/transcripts.fasta_results.xprs +16 -0
  45. data/test/vagrant/ubuntu_12.04_64/sample_data/transcripts/Genome +17 -0
  46. data/test/vagrant/ubuntu_12.04_64/sample_data/transcripts/GenomeIndex +1 -0
  47. data/test/vagrant/ubuntu_12.04_64/sample_data/transcripts/GenomeIndexHash +0 -0
  48. data/test/vagrant/ubuntu_12.04_64/sample_data/transcripts/OverflowTable +0 -0
  49. data/transrate.gemspec +4 -4
  50. metadata +111 -71
  51. data/lib/transrate/bowtie.rb +0 -103
@@ -1,103 +0,0 @@
1
- module Transrate
2
-
3
- class Bowtie2Error < StandardError
4
- end
5
-
6
- class Bowtie2
7
-
8
- attr_reader :index_name, :sam, :read_count
9
-
10
- def initialize
11
- @bowtie2 = get_bin_path("bowtie2")
12
- @bowtie2_build = get_bin_path("bowtie2-build")
13
-
14
- @index_built = false
15
- @index_name = ""
16
- end
17
-
18
- def get_bin_path bin
19
- which_bin = Cmd.new("which #{bin}")
20
- which_bin.run
21
- if !which_bin.status.success?
22
- raise IOError.new("ReadMetrics: could not find #{bin} in path")
23
- end
24
- which_bin.stdout.split("\n").first
25
- end
26
-
27
- def map_reads(file, left, right,
28
- insertsize: 200, insertsd: 50, threads: 8)
29
- raise Bowtie2Error.new("Index not built") if !@index_built
30
- lbase = File.basename(left.split(",").first)
31
- rbase = File.basename(right.split(",").first)
32
- index = File.basename(@index_name)
33
- @sam = File.expand_path("#{lbase}.#{rbase}.#{index}.sam")
34
- realistic_dist = insertsize + (5 * insertsd)
35
- unless File.exists? @sam
36
- # construct bowtie command
37
- bowtiecmd = "#{@bowtie2} --very-sensitive"
38
- bowtiecmd << " -x #{@index_name}"
39
- bowtiecmd << " -a"
40
- bowtiecmd << " -p #{threads} -X #{realistic_dist}"
41
- bowtiecmd << " --no-unal"
42
- bowtiecmd << " --seed 1337"
43
- bowtiecmd << " --rdg 6,5"
44
- bowtiecmd << " --rfg 6,5"
45
- bowtiecmd << " --score-min L,-.6,-.4"
46
- bowtiecmd << " -1 #{left}"
47
- # paired end?
48
- bowtiecmd << " -2 #{right}" if right
49
- bowtiecmd << " -S #{@sam}"
50
- # run bowtie
51
- runner = Cmd.new bowtiecmd
52
- runner.run
53
- # parse bowtie output
54
- if runner.stderr=~/([0-9]+)\ reads\;\ of\ these\:/
55
- @read_count = $1.to_i
56
- # save read_count to file
57
- File.open("#{@sam}-read_count.txt", "wb") do |out|
58
- out.write("#{@read_count}\n")
59
- end
60
- end
61
- if !runner.status.success?
62
- raise Bowtie2Error.new("Bowtie2 failed\n#{runner.stderr}")
63
- end
64
- else
65
- @read_count = 0
66
- if File.exist?("#{@sam}-read_count.txt")
67
- @read_count = File.open("#{@sam}-read_count.txt").readlines.join.to_i
68
- else
69
- left.split(",").each do |l|
70
- cmd = "wc -l #{l}"
71
- count = Cmd.new(cmd)
72
- count.run
73
- if count.status.success?
74
- @read_count += count.stdout.strip.split(/\s+/).first.to_i/4
75
- File.open("#{@sam}-read_count.txt", "wb") do |out|
76
- out.write("#{@read_count}\n")
77
- end
78
- else
79
- logger.warn "couldn't get number of reads from #{l}"
80
- end
81
- end
82
- end
83
- end
84
- @sam
85
- end
86
-
87
- def build_index file
88
- @index_name = File.basename(file).split(".")[0..-2].join(".")
89
- unless File.exists?(@index_name + '.1.bt2')
90
- cmd = "#{@bowtie2_build} --quiet --offrate 1 #{file} #{@index_name}"
91
- runner = Cmd.new cmd
92
- runner.run
93
- if !runner.status.success?
94
- msg = "Failed to build Bowtie2 index\n#{runner.stderr}"
95
- raise Bowtie2Error.new(msg)
96
- end
97
- end
98
- @index_built = true
99
- end
100
-
101
- end # Bowtie2
102
-
103
- end # Transrate