mspire 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. data/INSTALL +1 -0
  2. data/README +25 -0
  3. data/Rakefile +129 -40
  4. data/bin/{find_aa_freq.rb → aafreqs.rb} +2 -2
  5. data/bin/bioworks_to_pepxml.rb +1 -0
  6. data/bin/fasta_shaker.rb +1 -96
  7. data/bin/filter_and_validate.rb +5 -0
  8. data/bin/{mzxml_to_lmat.rb → ms_to_lmat.rb} +8 -7
  9. data/bin/prob_validate.rb +6 -0
  10. data/bin/raw_to_mzXML.rb +2 -2
  11. data/bin/srf_group.rb +1 -0
  12. data/bin/srf_to_sqt.rb +40 -0
  13. data/changelog.txt +68 -0
  14. data/lib/align/chams.rb +6 -6
  15. data/lib/align.rb +4 -3
  16. data/lib/bsearch.rb +120 -0
  17. data/lib/fasta.rb +318 -86
  18. data/lib/group_by.rb +10 -0
  19. data/lib/index_by.rb +11 -0
  20. data/lib/merge_deep.rb +21 -0
  21. data/lib/{spec → ms/converter}/mzxml.rb +77 -109
  22. data/lib/ms/gradient_program.rb +171 -0
  23. data/lib/ms/msrun.rb +209 -0
  24. data/lib/{spec/msrun.rb → ms/msrun_index.rb} +7 -40
  25. data/lib/ms/parser/mzdata/axml.rb +12 -0
  26. data/lib/ms/parser/mzdata/dom.rb +160 -0
  27. data/lib/ms/parser/mzdata/libxml.rb +7 -0
  28. data/lib/ms/parser/mzdata.rb +25 -0
  29. data/lib/ms/parser/mzxml/axml.rb +11 -0
  30. data/lib/ms/parser/mzxml/dom.rb +159 -0
  31. data/lib/ms/parser/mzxml/hpricot.rb +253 -0
  32. data/lib/ms/parser/mzxml/libxml.rb +15 -0
  33. data/lib/ms/parser/mzxml/regexp.rb +122 -0
  34. data/lib/ms/parser/mzxml/rexml.rb +72 -0
  35. data/lib/ms/parser/mzxml/xmlparser.rb +248 -0
  36. data/lib/ms/parser/mzxml.rb +175 -0
  37. data/lib/ms/parser.rb +108 -0
  38. data/lib/ms/precursor.rb +10 -0
  39. data/lib/ms/scan.rb +81 -0
  40. data/lib/ms/spectrum.rb +193 -0
  41. data/lib/ms.rb +10 -0
  42. data/lib/mspire.rb +4 -0
  43. data/lib/roc.rb +61 -1
  44. data/lib/sample_enzyme.rb +31 -8
  45. data/lib/scan_i.rb +21 -0
  46. data/lib/spec_id/aa_freqs.rb +7 -3
  47. data/lib/spec_id/bioworks.rb +20 -14
  48. data/lib/spec_id/digestor.rb +139 -0
  49. data/lib/spec_id/mass.rb +116 -0
  50. data/lib/spec_id/parser/proph.rb +236 -0
  51. data/lib/spec_id/precision/filter/cmdline.rb +209 -0
  52. data/lib/spec_id/precision/filter/interactive.rb +134 -0
  53. data/lib/spec_id/precision/filter/output.rb +147 -0
  54. data/lib/spec_id/precision/filter.rb +623 -0
  55. data/lib/spec_id/precision/output.rb +60 -0
  56. data/lib/spec_id/precision/prob/cmdline.rb +139 -0
  57. data/lib/spec_id/precision/prob/output.rb +88 -0
  58. data/lib/spec_id/precision/prob.rb +171 -0
  59. data/lib/spec_id/proph/pep_summary.rb +92 -0
  60. data/lib/spec_id/proph/prot_summary.rb +484 -0
  61. data/lib/spec_id/proph.rb +2 -466
  62. data/lib/spec_id/protein_summary.rb +2 -2
  63. data/lib/spec_id/sequest/params.rb +316 -0
  64. data/lib/spec_id/sequest/pepxml.rb +1513 -0
  65. data/lib/spec_id/sequest.rb +2 -1672
  66. data/lib/spec_id/srf.rb +445 -177
  67. data/lib/spec_id.rb +183 -95
  68. data/lib/spec_id_xml.rb +8 -10
  69. data/lib/transmem/phobius.rb +147 -0
  70. data/lib/transmem/toppred.rb +368 -0
  71. data/lib/transmem.rb +157 -0
  72. data/lib/validator/aa.rb +135 -0
  73. data/lib/validator/background.rb +73 -0
  74. data/lib/validator/bias.rb +95 -0
  75. data/lib/validator/cmdline.rb +260 -0
  76. data/lib/validator/decoy.rb +94 -0
  77. data/lib/validator/digestion_based.rb +69 -0
  78. data/lib/validator/probability.rb +48 -0
  79. data/lib/validator/prot_from_pep.rb +234 -0
  80. data/lib/validator/transmem.rb +272 -0
  81. data/lib/validator/true_pos.rb +46 -0
  82. data/lib/validator.rb +214 -0
  83. data/lib/xml.rb +38 -0
  84. data/lib/xml_style_parser.rb +105 -0
  85. data/lib/xmlparser_wrapper.rb +19 -0
  86. data/script/compile_and_plot_smriti_final.rb +97 -0
  87. data/script/extract_gradient_programs.rb +56 -0
  88. data/script/get_apex_values_rexml.rb +44 -0
  89. data/script/mzXML2timeIndex.rb +1 -1
  90. data/script/smriti_final_analysis.rb +103 -0
  91. data/script/toppred_to_yaml.rb +47 -0
  92. data/script/tpp_installer.rb +1 -1
  93. data/{test/tc_align.rb → specs/align_spec.rb} +21 -27
  94. data/{test/tc_bioworks_to_pepxml.rb → specs/bin/bioworks_to_pepxml_spec.rb} +25 -41
  95. data/specs/bin/fasta_shaker_spec.rb +259 -0
  96. data/specs/bin/filter_and_validate__multiple_vals_helper.yaml +202 -0
  97. data/specs/bin/filter_and_validate_spec.rb +124 -0
  98. data/specs/bin/ms_to_lmat_spec.rb +34 -0
  99. data/specs/bin/prob_validate_spec.rb +62 -0
  100. data/specs/bin/protein_summary_spec.rb +10 -0
  101. data/{test/tc_fasta.rb → specs/fasta_spec.rb} +354 -310
  102. data/specs/gi_spec.rb +22 -0
  103. data/specs/load_bin_path.rb +7 -0
  104. data/specs/merge_deep_spec.rb +13 -0
  105. data/specs/ms/gradient_program_spec.rb +77 -0
  106. data/specs/ms/msrun_spec.rb +455 -0
  107. data/specs/ms/parser_spec.rb +92 -0
  108. data/specs/ms/spectrum_spec.rb +89 -0
  109. data/specs/roc_spec.rb +251 -0
  110. data/specs/rspec_autotest.rb +149 -0
  111. data/specs/sample_enzyme_spec.rb +41 -0
  112. data/specs/spec_helper.rb +133 -0
  113. data/specs/spec_id/aa_freqs_spec.rb +52 -0
  114. data/{test/tc_bioworks.rb → specs/spec_id/bioworks_spec.rb} +56 -71
  115. data/specs/spec_id/digestor_spec.rb +75 -0
  116. data/specs/spec_id/precision/filter/cmdline_spec.rb +20 -0
  117. data/specs/spec_id/precision/filter/output_spec.rb +31 -0
  118. data/specs/spec_id/precision/filter_spec.rb +243 -0
  119. data/specs/spec_id/precision/prob_spec.rb +111 -0
  120. data/specs/spec_id/precision/prob_spec_helper.rb +0 -0
  121. data/specs/spec_id/proph/pep_summary_spec.rb +143 -0
  122. data/{test/tc_proph.rb → specs/spec_id/proph/prot_summary_spec.rb} +52 -32
  123. data/{test/tc_protein_summary.rb → specs/spec_id/protein_summary_spec.rb} +85 -0
  124. data/specs/spec_id/sequest/params_spec.rb +68 -0
  125. data/specs/spec_id/sequest/pepxml_spec.rb +452 -0
  126. data/specs/spec_id/sqt_spec.rb +138 -0
  127. data/specs/spec_id/srf_spec.rb +209 -0
  128. data/specs/spec_id/srf_spec_helper.rb +302 -0
  129. data/specs/spec_id_helper.rb +33 -0
  130. data/specs/spec_id_spec.rb +361 -0
  131. data/specs/spec_id_xml_spec.rb +33 -0
  132. data/specs/transmem/phobius_spec.rb +423 -0
  133. data/specs/transmem/toppred_spec.rb +297 -0
  134. data/specs/transmem_spec.rb +60 -0
  135. data/specs/transmem_spec_shared.rb +64 -0
  136. data/specs/validator/aa_spec.rb +107 -0
  137. data/specs/validator/background_spec.rb +51 -0
  138. data/specs/validator/bias_spec.rb +146 -0
  139. data/specs/validator/decoy_spec.rb +51 -0
  140. data/specs/validator/fasta_helper.rb +26 -0
  141. data/specs/validator/prot_from_pep_spec.rb +141 -0
  142. data/specs/validator/transmem_spec.rb +145 -0
  143. data/specs/validator/true_pos_spec.rb +58 -0
  144. data/specs/validator_helper.rb +33 -0
  145. data/specs/xml_spec.rb +12 -0
  146. data/test_files/000_pepxml18_small.xml +206 -0
  147. data/test_files/020a.mzXML.timeIndex +4710 -0
  148. data/test_files/4-03-03_mzXML/000.mzXML.timeIndex +3973 -0
  149. data/test_files/4-03-03_mzXML/020.mzXML.timeIndex +3872 -0
  150. data/test_files/4-03-03_small-prot.xml +321 -0
  151. data/test_files/4-03-03_small.xml +3876 -0
  152. data/test_files/7MIX_STD_110802_1.sequest_params_fragment.srf +0 -0
  153. data/test_files/bioworks-3.3_10prots.xml +5999 -0
  154. data/test_files/bioworks31.params +77 -0
  155. data/test_files/bioworks32.params +62 -0
  156. data/test_files/bioworks33.params +63 -0
  157. data/test_files/bioworks_single_run_small.xml +7237 -0
  158. data/test_files/bioworks_small.fasta +212 -0
  159. data/test_files/bioworks_small.params +63 -0
  160. data/test_files/bioworks_small.phobius +109 -0
  161. data/test_files/bioworks_small.toppred.out +2847 -0
  162. data/test_files/bioworks_small.xml +5610 -0
  163. data/test_files/bioworks_with_INV_small.xml +3753 -0
  164. data/test_files/bioworks_with_SHUFF_small.xml +2503 -0
  165. data/test_files/corrupted_900.srf +0 -0
  166. data/test_files/head_of_7MIX.srf +0 -0
  167. data/test_files/interact-opd1_mods_small-prot.xml +304 -0
  168. data/test_files/messups.fasta +297 -0
  169. data/test_files/opd1/000.my_answer.100lines.xml +101 -0
  170. data/test_files/opd1/000.tpp_1.2.3.first10.xml +115 -0
  171. data/test_files/opd1/000.tpp_2.9.2.first10.xml +126 -0
  172. data/test_files/opd1/000.v2.1.mzXML.timeIndex +3748 -0
  173. data/test_files/opd1/000_020-prot.png +0 -0
  174. data/test_files/opd1/000_020_3prots-prot.mod_initprob.xml +62 -0
  175. data/test_files/opd1/000_020_3prots-prot.xml +62 -0
  176. data/test_files/opd1/opd1_cat_inv_small-prot.xml +139 -0
  177. data/test_files/opd1/sequest.3.1.params +77 -0
  178. data/test_files/opd1/sequest.3.2.params +62 -0
  179. data/test_files/opd1/twenty_scans.mzXML +418 -0
  180. data/test_files/opd1/twenty_scans.v2.1.mzXML +382 -0
  181. data/test_files/opd1/twenty_scans_answ.lmat +0 -0
  182. data/test_files/opd1/twenty_scans_answ.lmata +9 -0
  183. data/test_files/opd1_020_beginning.RAW +0 -0
  184. data/test_files/opd1_2runs_2mods/interact-opd1_mods__small.xml +753 -0
  185. data/test_files/orbitrap_mzData/000_cut.xml +1920 -0
  186. data/test_files/pepproph_small.xml +4691 -0
  187. data/test_files/phobius.small.noheader.txt +50 -0
  188. data/test_files/phobius.small.small.txt +53 -0
  189. data/test_files/s01_anC1_ld020mM.key.txt +25 -0
  190. data/test_files/s01_anC1_ld020mM.meth +0 -0
  191. data/test_files/small.fasta +297 -0
  192. data/test_files/smallraw.RAW +0 -0
  193. data/test_files/tf_bioworks2excel.bioXML +14340 -0
  194. data/test_files/tf_bioworks2excel.txt.actual +1035 -0
  195. data/test_files/toppred.small.out +416 -0
  196. data/test_files/toppred.xml.out +318 -0
  197. data/test_files/validator_hits_separate/bias_bioworks_small_HS.fasta +7 -0
  198. data/test_files/validator_hits_separate/bioworks_small_HS.xml +5651 -0
  199. data/test_files/yeast_gly_small-prot.xml +265 -0
  200. data/test_files/yeast_gly_small.1.0_1.0_1.0.parentTimes +6 -0
  201. data/test_files/yeast_gly_small.xml +3807 -0
  202. data/test_files/yeast_gly_small2.parentTimes +6 -0
  203. metadata +273 -57
  204. data/bin/filter.rb +0 -6
  205. data/bin/precision.rb +0 -5
  206. data/lib/spec/mzdata/parser.rb +0 -108
  207. data/lib/spec/mzdata.rb +0 -48
  208. data/lib/spec/mzxml/parser.rb +0 -449
  209. data/lib/spec/scan.rb +0 -55
  210. data/lib/spec_id/filter.rb +0 -797
  211. data/lib/spec_id/precision.rb +0 -421
  212. data/lib/toppred.rb +0 -18
  213. data/script/filter-peps.rb +0 -164
  214. data/test/tc_aa_freqs.rb +0 -59
  215. data/test/tc_fasta_shaker.rb +0 -149
  216. data/test/tc_filter.rb +0 -203
  217. data/test/tc_filter_peps.rb +0 -46
  218. data/test/tc_gi.rb +0 -17
  219. data/test/tc_id_class_anal.rb +0 -70
  220. data/test/tc_id_precision.rb +0 -89
  221. data/test/tc_msrun.rb +0 -88
  222. data/test/tc_mzxml.rb +0 -88
  223. data/test/tc_mzxml_to_lmat.rb +0 -36
  224. data/test/tc_peptide_parent_times.rb +0 -27
  225. data/test/tc_precision.rb +0 -60
  226. data/test/tc_roc.rb +0 -166
  227. data/test/tc_sample_enzyme.rb +0 -32
  228. data/test/tc_scan.rb +0 -26
  229. data/test/tc_sequest.rb +0 -336
  230. data/test/tc_spec.rb +0 -78
  231. data/test/tc_spec_id.rb +0 -201
  232. data/test/tc_spec_id_xml.rb +0 -36
  233. data/test/tc_srf.rb +0 -262
data/test/tc_mzxml.rb DELETED
@@ -1,88 +0,0 @@
1
- require 'test/unit'
2
- require 'spec/mzxml/parser'
3
-
4
- class SpecMzXML < Test::Unit::TestCase
5
- def initialize(arg)
6
- super(arg)
7
- @tfiles = File.dirname(__FILE__) + '/tfiles/'
8
- @tscans = @tfiles + "opd1/twenty_scans.mzXML"
9
- @big_file = "../bioworks2prophet/xml/opd00001_test_set/opd00001_prophprepped/000.mzXML"
10
- end
11
-
12
- def test_times_and_spectra
13
- #parser = Spec::MzXML::Parser.new
14
- #arr = parser.parse_times_and_spectra( @tscans)
15
- (times, spectra) = Spec::MzXML::Parser.new.times_and_spectra(@tscans)
16
- times = %w(0.440000 5.150000 10.690000 16.400000 22.370000)
17
- num_peaks = [992, 814, 796, 849, 813]
18
- ind_0_2__3 = [301.430114746094, 22192.0]
19
- ind_0_n2__n1 = [1499.09912109375, 111286.0]
20
- ind_n1_2__3 = [301.243774414062, 77503.0]
21
- ind_n1_n2__n1 = [1499.42016601562, 13.0]
22
- assert_equal_pair(ind_0_2__3, spectra[0][2..3])
23
- assert_equal_pair(ind_0_n2__n1, spectra[0][-2..-1])
24
- assert_equal_pair(ind_n1_2__3, spectra[-1][2..3])
25
- assert_equal_pair(ind_n1_n2__n1, spectra[-1][-2..-1])
26
-
27
- num_peaks.each_with_index do |n,i|
28
- assert_equal(n, spectra[i].size/2)
29
- end
30
- times.each_with_index do |t,i|
31
- assert_equal(t, times[i])
32
- end
33
-
34
- end
35
-
36
- def test_basic_info
37
- hash = Spec::MzXML::Parser.new.basic_info(@tscans)
38
- assert_equal({:scan_count=>[20, 5, 15], :start_time=>0.44, :end_time=>27.05, :start_mz=>300.0, :end_mz=>1500.0, :ms_level=>1}, hash, "basic info the same")
39
- end
40
-
41
- def assert_equal_pair(exp, pair)
42
- assert_in_delta(exp[0], pair[0], 0.000000001)
43
- assert_in_delta(exp[1], pair[1], 0.000000001)
44
- end
45
-
46
- def test_file_to_mzxml
47
- if has_t2x?
48
- sr_raw = @tfiles + 'smallraw.RAW'
49
- sr_noext = @tfiles + 'smallraw'
50
- sr_mzxml = @tfiles + 'smallraw.mzXML'
51
- klass = Spec::MzXML
52
- # given raw
53
- file = klass.file_to_mzxml(sr_raw)
54
- file_to_mzxml_assert(file)
55
- # given mzXML
56
- file = klass.file_to_mzxml(sr_mzxml)
57
- file_to_mzxml_assert(file)
58
- File.unlink(sr_mzxml)
59
- # given basename (and no mzXML)
60
- file = klass.file_to_mzxml(sr_noext)
61
- file_to_mzxml_assert(file)
62
- # given basename (and mzXML)
63
- file = klass.file_to_mzxml(sr_noext)
64
- file_to_mzxml_assert(file)
65
- File.unlink(sr_mzxml)
66
- else
67
- puts "SKIPPING tests requiring 't2x' to convert RAW to mzXML"
68
- puts "(look in the archive folder of the gem for t2x binary for linux)"
69
- end
70
- end
71
-
72
-
73
- def file_to_mzxml_assert(file)
74
- assert(file, "file is not nil")
75
- assert(File.exist?(file), "file #{file} exists")
76
- assert_match(/\.mzXML$/, file, "file ends in mzXML")
77
- end
78
-
79
- # returns true if 't2x' matches 'Usage'
80
- def has_t2x?
81
- reply = ''
82
- eval(%q{reply = `t2x`})
83
- reply.include? 't2x'
84
- end
85
-
86
- end
87
-
88
-
@@ -1,36 +0,0 @@
1
-
2
- require 'test/unit'
3
-
4
-
5
- class TestMzXML2LMat < Test::Unit::TestCase
6
- ROOT_DIR = File.join(File.dirname(__FILE__), '..')
7
-
8
- def initialize(arg)
9
- super(arg)
10
- @tfiles = File.dirname(File.expand_path(__FILE__)) + '/tfiles/'
11
- @mzxml = @tfiles + "opd1/twenty_scans.mzXML"
12
- @mzxml_big = @tfiles + "yeast_gly_mzXML/000.mzXML"
13
- @cmd = "ruby -I #{File.join(ROOT_DIR, 'lib')} -S #{File.join(ROOT_DIR, 'bin', 'mzxml_to_lmat.rb')} "
14
- @ans_lmata = @tfiles + "opd1/twenty_scans_answ.lmata"
15
- @ans_lmat = @tfiles + "opd1/twenty_scans_answ.lmat"
16
- end
17
-
18
- def test_basic_ascii
19
- cmd = "#{@cmd} #{@mzxml} --ascii"
20
- puts `#{cmd}`
21
- newfile = @mzxml.sub(".mzXML", ".lmata")
22
- assert(File.exist?(newfile), "#{newfile} exists")
23
- assert(IO.read(@ans_lmata), IO.read(newfile))
24
- File.unlink(newfile)
25
- end
26
-
27
- def test_basic_binary
28
- cmd = "#{@cmd} #{@mzxml}"
29
- puts `#{cmd}`
30
- newfile = @mzxml.sub(".mzXML", ".lmat")
31
- assert(File.exist?(newfile), "#{newfile} exists")
32
- assert(IO.read(@ans_lmat), IO.read(newfile))
33
- File.unlink(newfile)
34
- end
35
- end
36
-
@@ -1,27 +0,0 @@
1
-
2
- require 'test/unit'
3
-
4
- class PeptideParentTimesTest < Test::Unit::TestCase
5
-
6
- def initialize(arg)
7
- super(arg)
8
- @tfiles = "tfiles" # relative test file directory
9
- end
10
-
11
- def test_blank
12
- ## need to finish this guy up:
13
- puts "\nSKIPPING: tests for peptide_parent_times"
14
- end
15
-
16
- def Xtest_run
17
- reply = `ruby ../script/peptide_parent_times.rb 1.00 tfiles/yeast_gly_small-prot.xml tfiles/yeast_gly_small.xml tfiles/020a.mzXML.timeIndex`
18
- #puts reply
19
- string1 = File.open((@tfiles +'/'+'yeast_gly_small.1.0_1.0_1.0.parentTimes__020a.working')).read
20
- assert(string1.size > 20)
21
- string2 = File.open((@tfiles +'/'+'yeast_gly_small.1.0_1.0_1.0.parentTimes__020a')).read
22
- assert_equal(string1, string2)
23
- to_delete = %w(yeast_gly_small.xml.seqchargehash yeast_gly_small-prot.xml.1.0_1.0_1.0.protpep yeast_gly_small.1.0_1.0_1.0.parentTimes__020a)
24
- with_dir = to_delete.collect { |f| @tfiles + '/' + f }
25
- with_dir.each { |f| File.unlink f }
26
- end
27
- end
data/test/tc_precision.rb DELETED
@@ -1,60 +0,0 @@
1
-
2
- require 'test/unit'
3
- require File.dirname(File.expand_path(__FILE__)) + '/load_bin_path'
4
-
5
-
6
- class PrecTest < Test::Unit::TestCase
7
- ROOT_DIR = File.join(File.dirname(__FILE__), "..")
8
-
9
- def initialize(arg)
10
- super(arg)
11
- @tfiles = File.dirname(__FILE__) + '/tfiles/'
12
- @tf_bioworks_esmall_xml = @tfiles + "bioworks_with_INV_small.xml"
13
- @tf_bioworks_shuff = @tfiles + "bioworks_with_SHUFF_small.xml"
14
- @cmd = "ruby -I#{File.join(ROOT_DIR, "lib")} -S precision.rb "
15
- @tf_html = @tfiles + "ppv.html"
16
- @tf_png = @tfiles + "ppv.png"
17
- @nodelete = false
18
- end
19
-
20
- def test_usage
21
- assert_match(/Usage:/, `#{@cmd}`)
22
- end
23
-
24
- def test_basic_cat
25
- output = `#{@cmd} -o #{@tf_html} -f SHUFF_ --prefix #{@tf_bioworks_shuff}`
26
- puts output
27
-
28
- assert_match(/<table.*<\/table>/m, IO.read(@tf_html), "has html table in it")
29
- assert_match(/10.*0.3000/m, IO.read(@tf_html), "has values")
30
- [@tf_html, @tf_png].each do |file|
31
- assert(File.exist?(file), "file #{file} exists")
32
- File.unlink(file) unless @nodelete
33
- end
34
- end
35
-
36
- def test_multiple_files
37
- output = `#{@cmd} -o #{@tf_html} -f SHUFF_,INV_ --prefix #{@tf_bioworks_shuff} #{@tf_bioworks_esmall_xml}`
38
- assert_match(/<table.*<\/table>/m, IO.read(@tf_html), "has html table in it")
39
- assert_match(/1.*1.0000.*1.*1.0000.*0.*0.*15.*0.8667/m, IO.read(@tf_html), "has values")
40
- [@tf_html, @tf_png].each do |file|
41
- assert(File.exist?(file), "file #{file} exists")
42
- File.unlink(file) unless @nodelete
43
- end
44
- end
45
-
46
- def test_area_under_curve
47
- file = @tfiles + 'ppv_area.txt'
48
- `#{@cmd} -o #{file} -a -f SHUFF_ --prefix #{@tf_bioworks_shuff}`
49
- assert(File.exist?(file), "file #{file} exists")
50
- output = IO.read(file)
51
- assert_match(/Prec.*7.39206/, output, "consistency check")
52
- File.unlink file
53
-
54
- outfile = File.join(File.dirname(__FILE__), 'other.html')
55
- `#{@cmd} -o #{outfile} -f SHUFF_ --prefix #{@tf_bioworks_shuff}`
56
- File.unlink outfile
57
- File.unlink File.join(File.dirname(__FILE__),'other.png')
58
- end
59
-
60
- end
data/test/tc_roc.rb DELETED
@@ -1,166 +0,0 @@
1
-
2
- require 'test/unit'
3
-
4
- require 'roc'
5
-
6
- class ROCTest < Test::Unit::TestCase
7
-
8
- def initialize(arg)
9
- super(arg)
10
- end
11
-
12
- def test_area_under_curve
13
- x = [1,2,3]
14
- y = [2,3,4]
15
- _test_auc(6,x,y)
16
-
17
- x = [1,2,3]
18
- y = [-2,-3,-4]
19
- _test_auc(-6, x, y)
20
-
21
- x = [1,2,3]
22
- y = [4,3,2]
23
- _test_auc(6, x, y)
24
-
25
- x = [1,2,3]
26
- y = [-4,-3,-2]
27
- _test_auc(-6, x, y)
28
-
29
- x = [4,5,6]
30
- y = [2,1,2]
31
- _test_auc(3, x, y)
32
-
33
- x = [4,5,6]
34
- y = [-2,-1,-2]
35
- _test_auc(-3, x, y)
36
- end
37
-
38
- def _test_auc(expected_area,x,y)
39
- area = ROC.new.area_under_curve(x,y)
40
- assert_equal(expected_area, area)
41
- end
42
-
43
- def test_prep_list
44
- t = true
45
- f = false
46
- x,y = ROC.new.prep_list([[0,f],[1,f],[2,f],[3,t],[3,f],[0,f],[4,f],[1,t],[2,t]])
47
- assert_equal([1,2,3], x)
48
- assert_equal([0,0,1,2,3,4], y)
49
- end
50
-
51
- def test_tps_and_ppv
52
- tp = %w(1 2 3 4 5 6 6 6 7 8 9 10 10 10 10 11 12 ).collect {|c| c.to_f } # 17 total
53
- fp = %w(3.5 4 5 5 5 6 6 6.5 7 8 9 9.5 10 15).collect {|c| c.to_f } # 14 total
54
- xe = [1, 2, 3, 4, 5, 8, 9, 10, 11, 15, 16, 17]
55
- # 1, 2, 3, 4 5, 6, 7, 8, 9
56
- # 10 11 12
57
- ye = [1, 1, 1, 4.0/6.0, 0.5, 8.0/(7.0+8.0), 9.0/(9.0+9.0), 0.5, 11.0/(11.0+ 11.0), 15.0/(15.0+13.0), 16.0/(16.0+13.0), 17.0/(17.0+13.0)]
58
- _test_tps_and_ppv_method(tp,fp,xe,ye,"complex real-life-like scenario")
59
-
60
- ## leading fp's
61
- tp = [1,2,3]
62
- fp = [0,0,1,2,3,4]
63
- xe = [1,2,3]
64
- ye = [1.0/(1+3), 2.0/(2+4), 3.0/(3+5)]
65
- _test_tps_and_ppv_method(tp,fp,xe,ye, "leading fps")
66
-
67
- ## leading tp's
68
- tp = [-1,2,3]
69
- fp = [0,4]
70
- xe = [1,2,3]
71
- ye = [1.0/(1+0), 2.0/(2+1), 3.0/(3+1)]
72
- _test_tps_and_ppv_method(tp,fp,xe,ye, "leading tps")
73
-
74
- ## equal tp's leading
75
- tp = [0.0001,0.0001,0.0001,2]
76
- fp = [0.01,4.0]
77
- xe = [3,4]
78
- ye = [3.0/(3+0), 4.0/(4+1)]
79
- _test_tps_and_ppv_method(tp,fp,xe,ye, "equal tps leading")
80
-
81
- ## equal arrays with some repeated values
82
- tp = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
83
- fp = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
84
- xe = [1,2,4,5,6,7]
85
- ye = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
86
- _test_tps_and_ppv_method(tp,fp,xe,ye, "equal arrays with some repeated values")
87
-
88
- end
89
-
90
- def _test_tps_and_ppv_method(tp,fp,xe,ye,message='')
91
- (x,y) = ROC.new.tps_and_ppv(tp,fp)
92
- assert_equal(x.size, y.size)
93
- assert_equal(xe, x)
94
- assert_equal(ye, y, "tps_and_ppv: #{message}")
95
- end
96
-
97
- end
98
-
99
- class DecoyROCTest < ROCTest
100
-
101
- def test_pred_tps_ppv__leading_fps
102
- ## leading fp's
103
- hits = [1,2,3]
104
- decoys = [0,0,1,2,3,4]
105
- num_hits_e = [1,2,3]
106
- num_fps = [3,4,5]
107
- tps_e = make_tps_e(num_fps, num_hits_e)
108
- ppv_e = make_ppv_e(tps_e, num_hits_e)
109
- _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
110
- end
111
-
112
- def test_pred_tps_ppv__leading_tps
113
- ## leading tp's
114
- hits = [-1,2,3]
115
- decoys = [0,4]
116
- num_hits_e = [1,2,3]
117
- num_fps = [0,1,1]
118
- tps_e = make_tps_e(num_fps, num_hits_e)
119
- ppv_e = make_ppv_e(tps_e, num_hits_e)
120
- _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
121
- end
122
-
123
- def test_pred_tps_ppv__equal_tps_leading
124
- hits = [0.0001,0.0001,0.0001,2]
125
- decoys = [0.01,4.0]
126
- num_hits_e = [3,4]
127
- num_fps = [0,1]
128
- tps_e = make_tps_e(num_fps, num_hits_e)
129
- ppv_e = make_ppv_e(tps_e, num_hits_e)
130
- _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
131
- end
132
-
133
- def test_pred_tps_ppv__equal_arrays_with_some_repeated_values
134
- hits = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
135
- decoys = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
136
- num_hits_e = [1,2,4,5,6,7]
137
- num_fps = [1,2,4,5,6,7]
138
- tps_e = make_tps_e(num_fps, num_hits_e)
139
- ppv_e = make_ppv_e(tps_e, num_hits_e)
140
- _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
141
- end
142
-
143
- def _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
144
- answer = DecoyROC.new.pred_and_tps_and_ppv(hits, decoys)
145
- expected = [num_hits_e, tps_e, ppv_e]
146
- %w(num_hits num_tps ppv).each_with_index do |cat, i|
147
- assert_equal(expected[i], answer[i], cat)
148
- end
149
- end
150
-
151
- def make_tps_e(num_fps, num_hits_e)
152
- tps_e = []
153
- num_hits_e.each_with_index do |v,i|
154
- tps_e[i] = v - num_fps[i]
155
- end
156
- tps_e
157
- end
158
-
159
- def make_ppv_e(tps_e, num_hits_e)
160
- ppv_e = []
161
- tps_e.each_with_index {|v,i| ppv_e[i] = v.to_f/num_hits_e[i] }
162
- ppv_e
163
- end
164
-
165
- end
166
-
@@ -1,32 +0,0 @@
1
-
2
- require 'test/unit'
3
- require 'sample_enzyme'
4
- require 'set'
5
-
6
- class Trypsin < Test::Unit::TestCase
7
- def test_no_missed_cleavage
8
- st = "CRGATKKTAGRPMEK"
9
- assert_equal(%w(CR GATK K TAGRPMEK), SampleEnzyme.tryptic(st))
10
- st = "CATRP"
11
- assert_equal(%w(CATRP), SampleEnzyme.tryptic(st))
12
- st = "RCATRP"
13
- assert_equal(%w(R CATRP), SampleEnzyme.tryptic(st))
14
- st = ""
15
- assert_equal([], SampleEnzyme.tryptic(st))
16
- st = "R"
17
- assert_equal(%w(R), SampleEnzyme.tryptic(st))
18
- end
19
-
20
- def test_missed_cleavage
21
- st = "CRGATKKTAGRPMEKLLLERTKY"
22
- zero = %w(CR GATK K TAGRPMEK LLLER TK Y)
23
- assert_equal(zero.to_set, SampleEnzyme.tryptic(st,0).to_set)
24
- one = %w(CRGATK GATKK KTAGRPMEK TAGRPMEKLLLER LLLERTK TKY)
25
- assert_equal((zero+one).to_set, SampleEnzyme.tryptic(st,1).to_set)
26
- two = %w(CRGATKK GATKKTAGRPMEK KTAGRPMEKLLLER TAGRPMEKLLLERTK LLLERTKY)
27
- all = zero + one + two
28
- assert_equal(all.to_set, SampleEnzyme.tryptic(st,2).to_set)
29
- end
30
-
31
-
32
- end
data/test/tc_scan.rb DELETED
@@ -1,26 +0,0 @@
1
-
2
- require 'test/unit'
3
- require 'spec/scan'
4
-
5
- class ScanTest < Test::Unit::TestCase
6
- include Spec
7
- def test_add_parent_scan
8
- s1 = Scan.new(1,1,0.13)
9
- s2 = Scan.new(2,2,0.23)
10
- s3 = Scan.new(3,2,0.33)
11
- s4 = Scan.new(4,3,0.43)
12
- s5 = Scan.new(5,3,0.53)
13
- s6 = Scan.new(6,1,0.63)
14
- s7 = Scan.new(7,2,0.73)
15
- s8 = Scan.new(8,3,0.83)
16
- s9 = Scan.new(9,2,0.93)
17
- scans = [s1,s2,s3,s4,s5,s6,s7,s8,s9]
18
- parents = [nil,s1,s1,s3,s3,nil,s6,s7,s6]
19
- Scan.add_parent_scan(scans)
20
-
21
- scans.each_with_index do |scan,i|
22
- assert_equal parents[i], scan.parent
23
- end
24
- end
25
-
26
- end