mspire 0.4.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. data/README +27 -17
  2. data/changelog.txt +31 -62
  3. data/lib/ms/calc.rb +32 -0
  4. data/lib/ms/data/interleaved.rb +60 -0
  5. data/lib/ms/data/lazy_io.rb +73 -0
  6. data/lib/ms/data/lazy_string.rb +15 -0
  7. data/lib/ms/data/simple.rb +59 -0
  8. data/lib/ms/data/transposed.rb +41 -0
  9. data/lib/ms/data.rb +57 -0
  10. data/lib/ms/format/format_error.rb +12 -0
  11. data/lib/ms/spectrum.rb +25 -384
  12. data/lib/ms/support/binary_search.rb +126 -0
  13. data/lib/ms.rb +10 -10
  14. metadata +38 -350
  15. data/INSTALL +0 -58
  16. data/README.rdoc +0 -18
  17. data/Rakefile +0 -330
  18. data/bin/aafreqs.rb +0 -23
  19. data/bin/bioworks2excel.rb +0 -14
  20. data/bin/bioworks_to_pepxml.rb +0 -148
  21. data/bin/bioworks_to_pepxml_gui.rb +0 -225
  22. data/bin/fasta_shaker.rb +0 -5
  23. data/bin/filter_and_validate.rb +0 -5
  24. data/bin/gi2annot.rb +0 -14
  25. data/bin/id_class_anal.rb +0 -112
  26. data/bin/id_precision.rb +0 -172
  27. data/bin/ms_to_lmat.rb +0 -67
  28. data/bin/pepproph_filter.rb +0 -16
  29. data/bin/prob_validate.rb +0 -6
  30. data/bin/protein_summary.rb +0 -6
  31. data/bin/protxml2prots_peps.rb +0 -32
  32. data/bin/raw_to_mzXML.rb +0 -55
  33. data/bin/run_percolator.rb +0 -122
  34. data/bin/sqt_group.rb +0 -26
  35. data/bin/srf_group.rb +0 -27
  36. data/bin/srf_to_sqt.rb +0 -40
  37. data/lib/align/chams.rb +0 -78
  38. data/lib/align.rb +0 -154
  39. data/lib/archive/targz.rb +0 -94
  40. data/lib/bsearch.rb +0 -120
  41. data/lib/core_extensions.rb +0 -16
  42. data/lib/fasta.rb +0 -626
  43. data/lib/gi.rb +0 -124
  44. data/lib/group_by.rb +0 -10
  45. data/lib/index_by.rb +0 -11
  46. data/lib/merge_deep.rb +0 -21
  47. data/lib/ms/converter/mzxml.rb +0 -77
  48. data/lib/ms/gradient_program.rb +0 -170
  49. data/lib/ms/msrun.rb +0 -244
  50. data/lib/ms/msrun_index.rb +0 -108
  51. data/lib/ms/parser/mzdata/axml.rb +0 -67
  52. data/lib/ms/parser/mzdata/dom.rb +0 -175
  53. data/lib/ms/parser/mzdata/libxml.rb +0 -7
  54. data/lib/ms/parser/mzdata.rb +0 -31
  55. data/lib/ms/parser/mzxml/axml.rb +0 -70
  56. data/lib/ms/parser/mzxml/dom.rb +0 -182
  57. data/lib/ms/parser/mzxml/hpricot.rb +0 -253
  58. data/lib/ms/parser/mzxml/libxml.rb +0 -19
  59. data/lib/ms/parser/mzxml/regexp.rb +0 -122
  60. data/lib/ms/parser/mzxml/rexml.rb +0 -72
  61. data/lib/ms/parser/mzxml/xmlparser.rb +0 -248
  62. data/lib/ms/parser/mzxml.rb +0 -282
  63. data/lib/ms/parser.rb +0 -108
  64. data/lib/ms/precursor.rb +0 -25
  65. data/lib/ms/scan.rb +0 -81
  66. data/lib/mspire.rb +0 -4
  67. data/lib/pi_zero.rb +0 -244
  68. data/lib/qvalue.rb +0 -161
  69. data/lib/roc.rb +0 -187
  70. data/lib/sample_enzyme.rb +0 -160
  71. data/lib/scan_i.rb +0 -21
  72. data/lib/spec_id/aa_freqs.rb +0 -170
  73. data/lib/spec_id/bioworks.rb +0 -497
  74. data/lib/spec_id/digestor.rb +0 -138
  75. data/lib/spec_id/mass.rb +0 -179
  76. data/lib/spec_id/parser/proph.rb +0 -335
  77. data/lib/spec_id/precision/filter/cmdline.rb +0 -218
  78. data/lib/spec_id/precision/filter/interactive.rb +0 -134
  79. data/lib/spec_id/precision/filter/output.rb +0 -148
  80. data/lib/spec_id/precision/filter.rb +0 -637
  81. data/lib/spec_id/precision/output.rb +0 -60
  82. data/lib/spec_id/precision/prob/cmdline.rb +0 -160
  83. data/lib/spec_id/precision/prob/output.rb +0 -94
  84. data/lib/spec_id/precision/prob.rb +0 -249
  85. data/lib/spec_id/proph/pep_summary.rb +0 -104
  86. data/lib/spec_id/proph/prot_summary.rb +0 -484
  87. data/lib/spec_id/proph.rb +0 -4
  88. data/lib/spec_id/protein_summary.rb +0 -489
  89. data/lib/spec_id/sequest/params.rb +0 -316
  90. data/lib/spec_id/sequest/pepxml.rb +0 -1458
  91. data/lib/spec_id/sequest.rb +0 -33
  92. data/lib/spec_id/sqt.rb +0 -349
  93. data/lib/spec_id/srf.rb +0 -973
  94. data/lib/spec_id.rb +0 -778
  95. data/lib/spec_id_xml.rb +0 -99
  96. data/lib/transmem/phobius.rb +0 -147
  97. data/lib/transmem/toppred.rb +0 -368
  98. data/lib/transmem.rb +0 -157
  99. data/lib/validator/aa.rb +0 -48
  100. data/lib/validator/aa_est.rb +0 -112
  101. data/lib/validator/background.rb +0 -77
  102. data/lib/validator/bias.rb +0 -95
  103. data/lib/validator/cmdline.rb +0 -431
  104. data/lib/validator/decoy.rb +0 -107
  105. data/lib/validator/digestion_based.rb +0 -70
  106. data/lib/validator/probability.rb +0 -51
  107. data/lib/validator/prot_from_pep.rb +0 -234
  108. data/lib/validator/q_value.rb +0 -32
  109. data/lib/validator/transmem.rb +0 -272
  110. data/lib/validator/true_pos.rb +0 -46
  111. data/lib/validator.rb +0 -197
  112. data/lib/xml.rb +0 -38
  113. data/lib/xml_style_parser.rb +0 -119
  114. data/lib/xmlparser_wrapper.rb +0 -19
  115. data/release_notes.txt +0 -2
  116. data/script/compile_and_plot_smriti_final.rb +0 -97
  117. data/script/create_little_pepxml.rb +0 -61
  118. data/script/degenerate_peptides.rb +0 -47
  119. data/script/estimate_fpr_by_cysteine.rb +0 -226
  120. data/script/extract_gradient_programs.rb +0 -56
  121. data/script/find_cysteine_background.rb +0 -137
  122. data/script/genuine_tps_and_probs.rb +0 -136
  123. data/script/get_apex_values_rexml.rb +0 -44
  124. data/script/histogram_probs.rb +0 -61
  125. data/script/mascot_fix_pepxml.rb +0 -123
  126. data/script/msvis.rb +0 -42
  127. data/script/mzXML2timeIndex.rb +0 -25
  128. data/script/peps_per_bin.rb +0 -67
  129. data/script/prep_dir.rb +0 -121
  130. data/script/simple_protein_digestion.rb +0 -27
  131. data/script/smriti_final_analysis.rb +0 -103
  132. data/script/sqt_to_meta.rb +0 -24
  133. data/script/top_hit_per_scan.rb +0 -67
  134. data/script/toppred_to_yaml.rb +0 -47
  135. data/script/tpp_installer.rb +0 -249
  136. data/specs/align_spec.rb +0 -79
  137. data/specs/bin/bioworks_to_pepxml_spec.rb +0 -79
  138. data/specs/bin/fasta_shaker_spec.rb +0 -259
  139. data/specs/bin/filter_and_validate__multiple_vals_helper.yaml +0 -199
  140. data/specs/bin/filter_and_validate_spec.rb +0 -180
  141. data/specs/bin/ms_to_lmat_spec.rb +0 -34
  142. data/specs/bin/prob_validate_spec.rb +0 -86
  143. data/specs/bin/protein_summary_spec.rb +0 -14
  144. data/specs/fasta_spec.rb +0 -354
  145. data/specs/gi_spec.rb +0 -22
  146. data/specs/load_bin_path.rb +0 -7
  147. data/specs/merge_deep_spec.rb +0 -13
  148. data/specs/ms/gradient_program_spec.rb +0 -77
  149. data/specs/ms/msrun_spec.rb +0 -498
  150. data/specs/ms/parser_spec.rb +0 -92
  151. data/specs/ms/spectrum_spec.rb +0 -87
  152. data/specs/pi_zero_spec.rb +0 -115
  153. data/specs/qvalue_spec.rb +0 -39
  154. data/specs/roc_spec.rb +0 -251
  155. data/specs/rspec_autotest.rb +0 -149
  156. data/specs/sample_enzyme_spec.rb +0 -126
  157. data/specs/spec_helper.rb +0 -135
  158. data/specs/spec_id/aa_freqs_spec.rb +0 -52
  159. data/specs/spec_id/bioworks_spec.rb +0 -148
  160. data/specs/spec_id/digestor_spec.rb +0 -75
  161. data/specs/spec_id/precision/filter/cmdline_spec.rb +0 -20
  162. data/specs/spec_id/precision/filter/output_spec.rb +0 -31
  163. data/specs/spec_id/precision/filter_spec.rb +0 -246
  164. data/specs/spec_id/precision/prob_spec.rb +0 -44
  165. data/specs/spec_id/precision/prob_spec_helper.rb +0 -0
  166. data/specs/spec_id/proph/pep_summary_spec.rb +0 -98
  167. data/specs/spec_id/proph/prot_summary_spec.rb +0 -128
  168. data/specs/spec_id/protein_summary_spec.rb +0 -189
  169. data/specs/spec_id/sequest/params_spec.rb +0 -68
  170. data/specs/spec_id/sequest/pepxml_spec.rb +0 -374
  171. data/specs/spec_id/sequest_spec.rb +0 -38
  172. data/specs/spec_id/sqt_spec.rb +0 -246
  173. data/specs/spec_id/srf_spec.rb +0 -172
  174. data/specs/spec_id/srf_spec_helper.rb +0 -139
  175. data/specs/spec_id_helper.rb +0 -33
  176. data/specs/spec_id_spec.rb +0 -366
  177. data/specs/spec_id_xml_spec.rb +0 -33
  178. data/specs/transmem/phobius_spec.rb +0 -425
  179. data/specs/transmem/toppred_spec.rb +0 -298
  180. data/specs/transmem_spec.rb +0 -60
  181. data/specs/transmem_spec_shared.rb +0 -64
  182. data/specs/validator/aa_est_spec.rb +0 -66
  183. data/specs/validator/aa_spec.rb +0 -40
  184. data/specs/validator/background_spec.rb +0 -67
  185. data/specs/validator/bias_spec.rb +0 -122
  186. data/specs/validator/decoy_spec.rb +0 -51
  187. data/specs/validator/fasta_helper.rb +0 -26
  188. data/specs/validator/prot_from_pep_spec.rb +0 -141
  189. data/specs/validator/transmem_spec.rb +0 -146
  190. data/specs/validator/true_pos_spec.rb +0 -58
  191. data/specs/validator_helper.rb +0 -33
  192. data/specs/xml_spec.rb +0 -12
  193. data/test_files/000_pepxml18_small.xml +0 -206
  194. data/test_files/020a.mzXML.timeIndex +0 -4710
  195. data/test_files/4-03-03_mzXML/000.mzXML.timeIndex +0 -3973
  196. data/test_files/4-03-03_mzXML/020.mzXML.timeIndex +0 -3872
  197. data/test_files/4-03-03_small-prot.xml +0 -321
  198. data/test_files/4-03-03_small.xml +0 -3876
  199. data/test_files/7MIX_STD_110802_1.sequest_params_fragment.srf +0 -0
  200. data/test_files/bioworks-3.3_10prots.xml +0 -5999
  201. data/test_files/bioworks31.params +0 -77
  202. data/test_files/bioworks32.params +0 -62
  203. data/test_files/bioworks33.params +0 -63
  204. data/test_files/bioworks_single_run_small.xml +0 -7237
  205. data/test_files/bioworks_small.fasta +0 -212
  206. data/test_files/bioworks_small.params +0 -63
  207. data/test_files/bioworks_small.phobius +0 -109
  208. data/test_files/bioworks_small.toppred.out +0 -2847
  209. data/test_files/bioworks_small.xml +0 -5610
  210. data/test_files/bioworks_with_INV_small.xml +0 -3753
  211. data/test_files/bioworks_with_SHUFF_small.xml +0 -2503
  212. data/test_files/corrupted_900.srf +0 -0
  213. data/test_files/head_of_7MIX.srf +0 -0
  214. data/test_files/interact-opd1_mods_small-prot.xml +0 -304
  215. data/test_files/messups.fasta +0 -297
  216. data/test_files/opd1/000.my_answer.100lines.xml +0 -101
  217. data/test_files/opd1/000.tpp_1.2.3.first10.xml +0 -115
  218. data/test_files/opd1/000.tpp_2.9.2.first10.xml +0 -126
  219. data/test_files/opd1/000.v2.1.mzXML.timeIndex +0 -3748
  220. data/test_files/opd1/000_020-prot.png +0 -0
  221. data/test_files/opd1/000_020_3prots-prot.mod_initprob.xml +0 -62
  222. data/test_files/opd1/000_020_3prots-prot.xml +0 -62
  223. data/test_files/opd1/opd1_cat_inv_small-prot.xml +0 -139
  224. data/test_files/opd1/sequest.3.1.params +0 -77
  225. data/test_files/opd1/sequest.3.2.params +0 -62
  226. data/test_files/opd1/twenty_scans.mzXML +0 -418
  227. data/test_files/opd1/twenty_scans.v2.1.mzXML +0 -382
  228. data/test_files/opd1/twenty_scans_answ.lmat +0 -0
  229. data/test_files/opd1/twenty_scans_answ.lmata +0 -9
  230. data/test_files/opd1_020_beginning.RAW +0 -0
  231. data/test_files/opd1_2runs_2mods/data/020.mzData.xml +0 -683
  232. data/test_files/opd1_2runs_2mods/data/020.readw.mzXML +0 -382
  233. data/test_files/opd1_2runs_2mods/data/040.mzData.xml +0 -683
  234. data/test_files/opd1_2runs_2mods/data/040.readw.mzXML +0 -382
  235. data/test_files/opd1_2runs_2mods/data/README.txt +0 -6
  236. data/test_files/opd1_2runs_2mods/interact-opd1_mods__small.xml +0 -753
  237. data/test_files/orbitrap_mzData/000_cut.xml +0 -1920
  238. data/test_files/pepproph_small.xml +0 -4691
  239. data/test_files/phobius.small.noheader.txt +0 -50
  240. data/test_files/phobius.small.small.txt +0 -53
  241. data/test_files/s01_anC1_ld020mM.key.txt +0 -25
  242. data/test_files/s01_anC1_ld020mM.meth +0 -0
  243. data/test_files/small.fasta +0 -297
  244. data/test_files/small.sqt +0 -87
  245. data/test_files/smallraw.RAW +0 -0
  246. data/test_files/tf_bioworks2excel.bioXML +0 -14340
  247. data/test_files/tf_bioworks2excel.txt.actual +0 -1035
  248. data/test_files/toppred.small.out +0 -416
  249. data/test_files/toppred.xml.out +0 -318
  250. data/test_files/validator_hits_separate/bias_bioworks_small_HS.fasta +0 -7
  251. data/test_files/validator_hits_separate/bioworks_small_HS.xml +0 -5651
  252. data/test_files/yeast_gly_small-prot.xml +0 -265
  253. data/test_files/yeast_gly_small.1.0_1.0_1.0.parentTimes +0 -6
  254. data/test_files/yeast_gly_small.xml +0 -3807
  255. data/test_files/yeast_gly_small2.parentTimes +0 -6
@@ -1,115 +0,0 @@
1
- require File.expand_path( File.dirname(__FILE__) + '/spec_helper' )
2
- require 'pi_zero'
3
-
4
- describe PiZero do
5
- before(:all) do
6
- @bools = "11110010110101010101000001101010101001010010100001001010000010010000010010000010010101010101000001010000000010000000000100001000100000100000100000001000000000000100000000".split('').map do |v|
7
- if v.to_i == 1
8
- true
9
- else
10
- false
11
- end
12
- end
13
- increment = 6.0 / @bools.size
14
- @xcorrs = []
15
- 0.0.step(6.0, increment) {|v| @xcorrs << v }
16
- @xcorrs.reverse!
17
-
18
- @sorted_pvals = [0.0, 0.1, 0.223, 0.24, 0.55, 0.68, 0.68, 0.90, 0.98, 1.0]
19
- end
20
-
21
- xit 'calculates instantaneous pi_0 hats' do
22
- answ = PiZero.pi_zero_hats(@sorted_pvals, :step => 0.1)
23
- exp_lambdas = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
24
- passing_threshold = [9, 8, 8, 6, 6, 6, 5, 3, 3, 2]
25
- expected = passing_threshold.zip(exp_lambdas).map {|v,l| v.to_f / (10.0 * (1.0 - l)) }
26
- (answ_lams, answ_pis) = answ
27
- answ_lams.zip(exp_lambdas) {|a,e| a.should be_close(e, 0.0000000001) }
28
- answ_pis.zip(expected) {|a,e| a.should be_close(e, 0.0000000001) }
29
- end
30
-
31
- xit 'can find a plateau height with exponential' do
32
- x = [0.0, 0.01, 0.012, 0.13, 0.2, 0.3, 0.4, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2]
33
- y = [1.0, 0.95, 0.92, 0.8, 0.7, 0.6, 0.55, 0.58, 0.62, 0.53, 0.54, 0.59, 0.4, 0.72]
34
-
35
- z = PiZero.plateau_exponential(x,y)
36
- # still working on this one
37
- end
38
-
39
- xit 'can find a plateau height' do
40
- x = [0.0, 0.01, 0.012, 0.13, 0.2, 0.3, 0.4, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2]
41
- y = [1.0, 0.95, 0.92, 0.8, 0.7, 0.6, 0.55, 0.58, 0.62, 0.53, 0.54, 0.59, 0.4, 0.72]
42
- z = PiZero.plateau_height(x,y)
43
- z.should be_close(0.57, 0.05)
44
- #require 'rsruby'
45
- #r = RSRuby.instance
46
- #r.plot(x,y)
47
- #sleep(8)
48
- end
49
-
50
- xit 'can calculate p values for SEQUEST hits' do
51
- class FakeSequest ; attr_accessor :xcorr ; def initialize(xcorr) ; @xcorr = xcorr ; end ; end
52
-
53
- target = []
54
- decoy = []
55
- cnt = 0
56
- @xcorrs.zip(@bools) do |xcorr, bool|
57
- if bool
58
- target << FakeSequest.new(xcorr)
59
- else
60
- decoy << FakeSequest.new(xcorr)
61
- end
62
- end
63
- pvalues = PiZero.p_values_for_sequest(target, decoy)
64
- # frozen:
65
- exp = [1.71344886775144e-07, 1.91226800512155e-07, 2.1332611415515e-07, 2.37879480495429e-07, 3.29004960353623e-07, 4.07557294032203e-07, 4.5332397295349e-07, 5.60147945165288e-07, 6.90985835582987e-07, 8.50958233458999e-07, 1.04621373866358e-06, 1.28412129273e-06, 2.35075612646546e-06, 2.59621031358335e-06, 3.16272156036349e-06, 3.84642913860656e-06, 4.67014790912829e-06, 5.66082984245324e-06, 7.53093419443452e-06, 9.09058296339405e-06, 1.20185706815653e-05, 1.44474800911154e-05, 2.27242185508328e-05, 2.967213280773e-05, 3.537451312629e-05, 5.93486219583748e-05, 7.64456599577934e-05, 0.000125433021038759, 0.000159783941297163, 0.000256431068540685, 0.000323066395099306, 0.00037608522266194, 0.000437091783629134, 0.000507167844234063, 0.000587522219112902, 0.000679502786805963, 0.00104103901250011, 0.00119624534498457, 0.00219153400681528, 0.00439503742960694, 0.00593498821589879, 0.00749365688957234, 0.0105069659581753, 0.0145259091109191, 0.0218905360424189, 0.0404530419122661]
66
- pvalues.zip(exp) do |v,e|
67
- v.should be_close(e, 0.000001)
68
- end
69
- end
70
-
71
- xit 'can calculate pi zero for target/decoy booleans' do
72
- pi_zero = PiZero.pi_zero_from_booleans(@bools)
73
- # frozen
74
- pi_zero.should be_close(0.03522869, 0.0001)
75
- end
76
-
77
- it 'can calculate frit for groups of hits' do
78
- # setup
79
- targets = [4,3,8,3,5,3,4,5,4]
80
- decoys = [0,2,2,3,5,7,8,8,8]
81
- targets_summed = []
82
- targets.each_with_index do |ar,i|
83
- sum = 0
84
- (0..i).each do |j|
85
- sum += targets[j]
86
- end
87
- targets_summed << sum
88
- end
89
- decoys_summed = []
90
- decoys.each_with_index do |ar,i|
91
- sum = 0
92
- (0..i).each do |j|
93
- sum += decoys[j]
94
- end
95
- decoys_summed << sum
96
- end
97
- zipped = targets_summed.zip(decoys_summed)
98
- frit = PiZero.frit_from_groups(zipped)
99
- # frozen
100
- frit.should be_close(0.384064, 0.00001)
101
- end
102
-
103
- xit 'can calcuate pi zero for total number of hits and precision' do
104
- tot_hits = [1,10,20,30,50,200]
105
- precision = [1.0, 1.0, 0.85, 0.80, 0.7, 0.5]
106
- reply = PiZero.frit_from_precision(tot_hits, precision)
107
- puts "ANSER"
108
- # frozen
109
- puts reply
110
- #reply.should be_close()
111
-
112
- end
113
-
114
- end
115
-
data/specs/qvalue_spec.rb DELETED
@@ -1,39 +0,0 @@
1
- require File.expand_path( File.dirname(__FILE__) + '/spec_helper' )
2
-
3
- require 'qvalue'
4
-
5
- describe 'finding q-values' do
6
-
7
- it 'can do num_le' do
8
- x = VecD[1,8,10,8,9,10]
9
- exp = VecD[1, 3, 6, 3, 4, 6]
10
- x.num_le.should == exp
11
-
12
- x = VecD[10,9,8,5,5,5,5,3,2]
13
- exp = VecD[9, 8, 7, 6, 6, 6, 6, 2, 1]
14
- x.num_le.should == exp
15
- end
16
-
17
- it 'can do qvalues with smooth pi0' do
18
- pvals = VecD[0.00001, 0.0001, 0.001, 0.01, 0.03, 0.02, 0.01, 0.1, 0.2, 0.4, 0.5, 0.6, 0.77, 0.8, 0.99]
19
- exp = [0.0000938637, 0.0004693185, 0.0031287899, 0.0187727394, 0.0402272988, 0.0312878991, 0.0187727394, 0.1173296215, 0.2085859937, 0.3754547887, 0.4266531690, 0.4693184859, 0.5363639839, 0.5363639839, 0.6195004014]
20
- pvals.qvalues.zip(exp) do |a,b|
21
- a.should be_close(b, 1.0e-9)
22
- end
23
- end
24
-
25
- it 'can do qvalues with bootstrap pi0' do
26
- puts "\nbootstrap pi0 needs further testing although answers seem to be close!"
27
- pvals = VecD[0.00001, 0.0001, 0.001, 0.01, 0.03, 0.02, 0.01, 0.1, 0.2, 0.4, 0.5, 0.6, 0.77, 0.8, 0.99]
28
- # this is what the Storey software gives for this:
29
- # exp = [8.888889e-05, 4.444444e-04, 2.962963e-03, 1.777778e-02, 3.809524e-02, 2.962963e-02, 1.777778e-02, 1.111111e-01, 1.975309e-01, 3.555556e-01, 4.040404e-01, 4.444444e-01, 5.079365e-01, 5.079365e-01, 5.866667e-01]
30
- exp = [9.38636971774565e-05, 0.000469318485887282, 0.00312878990591522, 0.0187727394354913, 0.0402272987903385, 0.0312878990591522, 0.0187727394354913, 0.117329621471821, 0.208585993727681, 0.375454788709826, 0.426653168988439, 0.469318485887282, 0.53636398387118, 0.53636398387118, 0.619500401371213]
31
- robust = false
32
- qvals = pvals.qvalues(robust, :method => :bootstrap)
33
- qvals.zip(exp) do |a,b|
34
- a.should be_close(b, 0.00001)
35
- end
36
- end
37
-
38
- end
39
-
data/specs/roc_spec.rb DELETED
@@ -1,251 +0,0 @@
1
- require File.expand_path( File.dirname(__FILE__) + '/spec_helper'
2
  )
3
- require 'roc'
4
-
5
- describe 'an area under the curve calculator', :shared => true do
6
-
7
- it 'calculates area under curve correctly' do
8
- x_y_pairs = {
9
- [[1,2,3],[2,3,4]] => 6,
10
- [[1,2,3],[-2,-3,-4]] => -6,
11
- [[1,2,3],[4,3,2]] => 6,
12
- [[1,2,3],[-4,-3,-2]] => -6,
13
- [[4,5,6],[2,1,2]] => 3,
14
- [[4,5,6],[-2,-1,-2]] => -3,
15
- }
16
- x_y_pairs.each do |k,v|
17
- calculate(*k).should == v
18
- end
19
- end
20
-
21
- def calculate(x,y)
22
- @method.call(x,y)
23
- end
24
- end
25
-
26
- describe ROC do
27
- before(:all) do
28
- @method = proc {|x,y| ROC.new.area_under_curve(x,y) }
29
- end
30
- it_should_behave_like 'an area under the curve calculator'
31
-
32
- it 'gives doublets_to_separate' do
33
- t = true
34
- f = false
35
- x,y = ROC.new.doublets_to_separate([[0,f],[1,f],[2,f],[3,t],[3,f],[0,f],[4,f],[1,t],[2,t]])
36
- x.should == [1,2,3]
37
- y.should == [0,0,1,2,3,4]
38
- end
39
-
40
- it 'gives tps_and_ppv' do
41
- 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
42
- 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
43
- xe = [1, 2, 3, 4, 5, 8, 9, 10, 11, 15, 16, 17]
44
- # 1, 2, 3, 4 5, 6, 7, 8, 9
45
- # 10 11 12
46
- 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)]
47
- _test_tps_and_ppv_method(tp,fp,xe,ye,"complex real-life-like scenario")
48
-
49
- ## leading fp's
50
- tp = [1,2,3]
51
- fp = [0,0,1,2,3,4]
52
- xe = [1,2,3]
53
- ye = [1.0/(1+3), 2.0/(2+4), 3.0/(3+5)]
54
- _test_tps_and_ppv_method(tp,fp,xe,ye, "leading fps")
55
-
56
- ## leading tp's
57
- tp = [-1,2,3]
58
- fp = [0,4]
59
- xe = [1,2,3]
60
- ye = [1.0/(1+0), 2.0/(2+1), 3.0/(3+1)]
61
- _test_tps_and_ppv_method(tp,fp,xe,ye, "leading tps")
62
-
63
- ## equal tp's leading
64
- tp = [0.0001,0.0001,0.0001,2]
65
- fp = [0.01,4.0]
66
- xe = [3,4]
67
- ye = [3.0/(3+0), 4.0/(4+1)]
68
- _test_tps_and_ppv_method(tp,fp,xe,ye, "equal tps leading")
69
-
70
- ## equal arrays with some repeated values
71
- tp = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
72
- fp = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
73
- xe = [1,2,4,5,6,7]
74
- ye = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
75
- _test_tps_and_ppv_method(tp,fp,xe,ye, "equal arrays with some repeated values")
76
-
77
- end
78
-
79
- it 'gives numhits_and_ppv' do
80
- ## leading fp's
81
- tp = [1,2,3]
82
- fp = [0,0,1,2,3,4]
83
- xe = [2,4,6,8,9]
84
- ye = [0.0/2, 1.0/4, 2.0/6, 3.0/8, 3.0/9]
85
- _test_numhits_and_ppv_method(tp,fp,xe,ye, "leading fps")
86
-
87
- ## leading tp's
88
- tp = [-1,2,3]
89
- fp = [0,4]
90
- xe = [1, 2, 3, 4, 5]
91
- ye = [1.0/1, 1.0/2, 2.0/3, 3.0/4, 3.0/5]
92
- _test_numhits_and_ppv_method(tp,fp,xe,ye, "leading tps")
93
-
94
- ## equal tp's leading
95
- tp = [0.0001,0.0001,0.0001,2]
96
- fp = [0.01,4.0]
97
- xe = [3, 4, 5, 6]
98
- ye = [3.0/3, 3.0/4, 4.0/5, 4.0/6]
99
- _test_numhits_and_ppv_method(tp,fp,xe,ye, "equal tps leading")
100
-
101
- ## equal arrays with some repeated values
102
- tp = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
103
- fp = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
104
- xe = [2, 4, 8, 10, 12, 14]
105
- ye = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
106
- _test_numhits_and_ppv_method(tp,fp,xe,ye, "equal arrays with some repeated values")
107
-
108
- ## @TODO: NEED TO FILL THIS OUT!
109
- =begin
110
- 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
111
- 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
112
- xe = [1, 2, 3, 4, ]
113
- # 1, 2, 3, 4 5, 6, 7, 8, 9
114
- # 10 11 12
115
- 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)]
116
- _test_tps_and_ppv_method(tp,fp,xe,ye,"complex real-life-like scenario")
117
- =end
118
-
119
- end
120
-
121
- def _test_numhits_and_ppv_method(tp,fp,xe,ye,message='')
122
- roc = ROC.new
123
- list = roc.separate_to_doublets(tp,fp)
124
- (x,y) = roc.numhits_and_ppv(list)
125
- y.size.should == x.size
126
- x.should == xe
127
- y.should == ye
128
- end
129
-
130
- def _test_tps_and_ppv_method(tp,fp,xe,ye,message='')
131
- (x,y) = ROC.new.tps_and_ppv(tp,fp)
132
- y.size.should == x.size
133
- x.should == xe
134
- y.should == ye
135
- end
136
-
137
- end
138
-
139
- describe DecoyROC do
140
-
141
- ###################################################################
142
-
143
- it 'gives pred_and_ppv' do
144
- hits = [1,2,3]
145
- decoys = [0,0,1,2,3,4]
146
- num_hits_e = [1,2,3]
147
- num_fps = [3,4,5]
148
- # expected = [-2.0/1, -2.0/2, -2.0/3]
149
- _test_pred_and_ppv(hits, decoys, num_hits_e, num_fps)
150
- end
151
-
152
- it 'gives pred_tps_ppv__leading_tps' do
153
- ## leading tp's
154
- hits = [-1,2,3]
155
- decoys = [0,4]
156
- num_hits_e = [1,2,3]
157
- num_fps = [0,1,1]
158
- _test_pred_and_ppv(hits, decoys, num_hits_e, num_fps)
159
- end
160
-
161
- it 'gives pred_tps_ppv__equal_tps_leading' do
162
- hits = [0.0001,0.0001,0.0001,2]
163
- decoys = [0.01,4.0]
164
- num_hits_e = [3,4]
165
- num_fps = [0,1]
166
- _test_pred_and_ppv(hits, decoys, num_hits_e, num_fps)
167
- end
168
-
169
- it 'gives pred_tps_ppv__equal_arrays_with_some_repeated_values' do
170
- hits = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
171
- decoys = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
172
- num_hits_e = [1,2,4,5,6,7]
173
- num_fps = [1,2,4,5,6,7]
174
- _test_pred_and_ppv(hits, decoys, num_hits_e, num_fps)
175
- end
176
-
177
- ###################################################################
178
-
179
- it 'gives pred_tps_ppv__leading_fps' do
180
- ## leading fp's
181
- hits = [1,2,3]
182
- decoys = [0,0,1,2,3,4]
183
- num_hits_e = [1,2,3]
184
- num_fps = [3,4,5]
185
- tps_e = make_tps_e(num_fps, num_hits_e)
186
- ppv_e = make_ppv_e(tps_e, num_hits_e)
187
- _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
188
- end
189
-
190
- it 'gives pred_tps_ppv__leading_tps' do
191
- ## leading tp's
192
- hits = [-1,2,3]
193
- decoys = [0,4]
194
- num_hits_e = [1,2,3]
195
- num_fps = [0,1,1]
196
- tps_e = make_tps_e(num_fps, num_hits_e)
197
- ppv_e = make_ppv_e(tps_e, num_hits_e)
198
- _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
199
- end
200
-
201
- it 'gives pred_tps_ppv__equal_tps_leading' do
202
- hits = [0.0001,0.0001,0.0001,2]
203
- decoys = [0.01,4.0]
204
- num_hits_e = [3,4]
205
- num_fps = [0,1]
206
- tps_e = make_tps_e(num_fps, num_hits_e)
207
- ppv_e = make_ppv_e(tps_e, num_hits_e)
208
- _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
209
- end
210
-
211
- it 'gives pred_tps_ppv__equal_arrays_with_some_repeated_values' do
212
- hits = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
213
- decoys = %w(1 2 3 3 4 5 6 ).collect {|x| x.to_f } # 17 total
214
- num_hits_e = [1,2,4,5,6,7]
215
- num_fps = [1,2,4,5,6,7]
216
- tps_e = make_tps_e(num_fps, num_hits_e)
217
- ppv_e = make_ppv_e(tps_e, num_hits_e)
218
- _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
219
- end
220
-
221
- def _test_pred_and_ppv(hits, decoys, num_hits_e, num_fps)
222
- answer = DecoyROC.new.pred_and_ppv(hits, decoys)
223
- precision = num_hits_e.zip(num_fps).map do |h,f|
224
- (h - f).to_f / h
225
- end
226
- answer.should == [num_hits_e, precision]
227
- end
228
-
229
- def _test_pred_and_tps_and_ppv(hits, decoys, num_hits_e, tps_e, ppv_e)
230
- answer = DecoyROC.new.pred_and_tps_and_ppv(hits, decoys)
231
- expected = [num_hits_e, tps_e, ppv_e]
232
- %w(num_hits num_tps ppv).each_with_index do |cat, i|
233
- answer[i].should == expected[i]
234
- end
235
- end
236
-
237
- def make_tps_e(num_fps, num_hits_e)
238
- tps_e = []
239
- num_hits_e.each_with_index do |v,i|
240
- tps_e[i] = v - num_fps[i]
241
- end
242
- tps_e
243
- end
244
-
245
- def make_ppv_e(tps_e, num_hits_e)
246
- ppv_e = []
247
- tps_e.each_with_index {|v,i| ppv_e[i] = v.to_f/num_hits_e[i] }
248
- ppv_e
249
- end
250
-
251
- end
252
-
@@ -1,149 +0,0 @@
1
- # (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person
4
- # obtaining a copy of this software and associated documentation files
5
- # (the "Software"), to deal in the Software without restriction,
6
- # including without limitation the rights to use, copy, modify, merge,
7
- # publish, distribute, sublicense, and/or sell copies of the Software,
8
- # and to permit persons to whom the Software is furnished to do so,
9
- # subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
- # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19
- # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
- require 'rubygems'
24
- gem 'ZenTest'
25
- require 'autotest'
26
-
27
- class RspecAutotest < Autotest
28
- attr_accessor :spec_command
29
- def initialize # :nodoc:
30
- @spec_command = "spec --diff unified"
31
- super
32
- @exceptions = %r%^\./(?:coverage|doc)%
33
- end
34
-
35
- def tests_for_file(filename)
36
- case filename
37
- when /^lib\/.*\.rb$/ then
38
- impl = File.basename(filename).gsub('_', '_?').sub(/\.rb$/, '')
39
- @files.keys.select do |k|
40
- k =~ %r%^spec/.*#{impl}_spec\.rb$%
41
- end
42
- when %r%^spec/spec_helper.rb% then
43
- @files.keys.select do |f|
44
- f =~ %r%^spec/.*_spec\.rb$%
45
- end
46
- when /^spec\/.*_spec\.rb$/ then
47
- [filename]
48
- when /#{Regexp.quote(File.basename(__FILE__))}/
49
- # Don't respond to changes to this file
50
- []
51
- else
52
- @output.puts "Dunno! #{filename}" if $TESTING
53
- []
54
- end
55
- end
56
-
57
- def handle_results(results)
58
- failed = results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
59
- @files_to_test = consolidate_failures failed
60
- unless @files_to_test.empty? then
61
- hook :red
62
- else
63
- hook :green
64
- end unless $TESTING
65
- @tainted = true unless @files_to_test.empty?
66
- end
67
-
68
- def consolidate_failures(failed)
69
- filters = Hash.new { |h,k| h[k] = [] }
70
- failed.each do |spec, failed_trace|
71
- @files.keys.select{|f| f =~ /spec\//}.each do |f|
72
- if failed_trace =~ Regexp.new(f)
73
- filters[f] << spec
74
- break
75
- end
76
- end
77
- end
78
- return filters
79
- end
80
-
81
- def make_test_cmd(files_to_test)
82
- cmds = []
83
- full, partial = files_to_test.partition { |k,v| v.empty? }
84
-
85
- unless full.empty? then
86
- classes = full.map {|k,v| k}.flatten.join(' ')
87
- cmds << "#{spec_command} #{classes}"
88
- end
89
-
90
- partial.each do |klass, methods|
91
- methods.each { |meth| cmds << "#{spec_command} -s #{meth.inspect} #{klass}" }
92
- end
93
-
94
- return cmds.join('; ')
95
- end
96
- end
97
-
98
- class RspecOnRailsAutotest < RspecAutotest
99
- def initialize # :nodoc:
100
- super
101
- @exceptions = %r%^\./(?:coverage|db|doc|log|public|script|vendor)%
102
- end
103
-
104
- def tests_for_file(filename)
105
- case filename
106
- when %r%^spec/fixtures/(.*)s.yml% then
107
- ["spec/models/#{$1}_spec.rb",
108
- "spec/controllers/#{$1}_controller_spec.rb"]
109
- when %r%^spec/models/.*rb$% then
110
- [filename]
111
- when %r%^spec/controllers/.*\.rb$% then
112
- [filename]
113
- when %r%^spec/views/.*\.rb$% then
114
- [filename]
115
- when %r%^spec/helpers/.*\.rb$% then
116
- [filename]
117
- when %r%^app/models/(.*)\.rb$% then
118
- ["spec/models/#{$1}_spec.rb"]
119
- when %r%^app/helpers/application_helper.rb% then
120
- @files.keys.select { |f|
121
- f =~ %r%^spec/controllers/.*_spec\.rb$%
122
- }
123
- when %r%^app/helpers/(.*)_helper.rb% then
124
- ["spec/controllers/#{$1}_controller_spec.rb", "spec/helpers/#{$1}_spec.rb"]
125
- when %r%^app/controllers/application.rb$% then
126
- @files.keys.select { |f|
127
- f =~ %r%^spec/controllers/.*_spec\.rb$%
128
- }
129
- when %r%^app/controllers/(.*)\.rb$% then
130
- ["spec/controllers/#{$1}_spec.rb"]
131
- when %r%^app/views/layouts/% then
132
- []
133
- when %r%^app/views/(.*)/% then
134
- ["spec/controllers/#{$1}_controller_spec.rb", "spec/views/#{$1}_spec.rb"]
135
- when %r%^config/routes.rb$% then
136
- @files.keys.select do |f|
137
- f =~ %r%^spec/controllers/.*_spec\.rb$%
138
- end
139
- when %r%^spec/spec_helper.rb%,
140
- %r%^config/((boot|environment(s/test)?).rb|database.yml)% then
141
- @files.keys.select do |f|
142
- f =~ %r%^spec/(models|controllers)/.*_spec\.rb$%
143
- end
144
- else
145
- @output.puts "Dunno! #{filename}" if $TESTING
146
- []
147
- end.uniq.select { |f| @files.has_key? f }
148
- end
149
- end
@@ -1,126 +0,0 @@
1
-
2
- require File.expand_path( File.dirname(__FILE__) + '/spec_helper' )
3
- require 'sample_enzyme'
4
- require 'set'
5
-
6
- describe SampleEnzyme, "digesting sequences" do
7
- it 'can digest with no missed cleavages' do
8
- st = "CRGATKKTAGRPMEK"
9
- SampleEnzyme.tryptic(st).should == %w(CR GATK K TAGRPMEK)
10
- st = "CATRP"
11
- SampleEnzyme.tryptic(st).should == %w(CATRP)
12
- st = "RCATRP"
13
- SampleEnzyme.tryptic(st).should == %w(R CATRP)
14
- st = ""
15
- SampleEnzyme.tryptic(st).should == []
16
- st = "R"
17
- SampleEnzyme.tryptic(st).should == %w(R)
18
- end
19
-
20
- it 'can digest with missed cleavages' do
21
- st = "CRGATKKTAGRPMEKLLLERTKY"
22
- zero = %w(CR GATK K TAGRPMEK LLLER TK Y)
23
- SampleEnzyme.tryptic(st,0).to_set.should == zero.to_set
24
- one = %w(CRGATK GATKK KTAGRPMEK TAGRPMEKLLLER LLLERTK TKY)
25
- SampleEnzyme.tryptic(st,1).to_set.should == (zero+one).to_set
26
- two = %w(CRGATKK GATKKTAGRPMEK KTAGRPMEKLLLER TAGRPMEKLLLERTK LLLERTKY)
27
- all = zero + one + two
28
- SampleEnzyme.tryptic(st,2).to_set.should == all.to_set
29
- end
30
-
31
- it 'contains duplicates IF there are duplicate tryptic sequences' do
32
- st = "AAAAKCCCCKDDDDKCCCCK"
33
- peps = SampleEnzyme.new('trypsin').digest(st, 2)
34
- peps.select {|aaseq| aaseq == 'CCCCK'}.size.should == 2
35
- end
36
-
37
- end
38
-
39
- describe SampleEnzyme, 'making enzyme calculations on sequences and aaseqs' do
40
-
41
- before(:each) do
42
- @full_KRP = SampleEnzyme.new do |se|
43
- se.name = 'trypsin'
44
- se.cut = 'KR'
45
- se.no_cut = 'P'
46
- se.sense = 'C'
47
- end
48
- @just_KR = SampleEnzyme.new do |se|
49
- se.name = 'trypsin'
50
- se.cut = 'KR'
51
- se.no_cut = ''
52
- se.sense = 'C'
53
- end
54
- end
55
-
56
- it 'calculates the number of tolerant termini' do
57
- exp = [{
58
- # full KR/P
59
- 'K.EPTIDR.E' => 2,
60
- 'K.PEPTIDR.E' => 1,
61
- 'F.EEPTIDR.E' => 1,
62
- 'F.PEPTIDW.R' => 0,
63
- },
64
- {
65
- # just KR
66
- 'K.EPTIDR.E' => 2,
67
- 'K.PEPTIDR.E' => 2,
68
- 'F.EEPTIDR.E' => 1,
69
- 'F.PEPTIDW.R' => 0,
70
- }
71
- ]
72
- scall = Sequest::PepXML::SearchHit
73
- sample_enzyme_ar = [@full_KRP, @just_KR]
74
- sample_enzyme_ar.zip(exp) do |sample_enzyme,hash|
75
- hash.each do |seq, val|
76
- sample_enzyme.num_tol_term(seq).should == val
77
- end
78
- end
79
- end
80
-
81
- it 'calculates number of missed cleavages' do
82
- exp = [{
83
- "EPTIDR" => 0,
84
- "PEPTIDR" => 0,
85
- "EEPTIDR" => 0,
86
- "PEPTIDW" => 0,
87
- "PERPTIDW" => 0,
88
- "PEPKPTIDW" => 0,
89
- "PEPKTIDW" => 1,
90
- "RTTIDR" => 1,
91
- "RTTIKK" => 2,
92
- "PKEPRTIDW" => 2,
93
- "PKEPRTIDKP" => 2,
94
- "PKEPRAALKPEERPTIDKW" => 3,
95
- },
96
- {
97
- "EPTIDR" => 0,
98
- "PEPTIDR" => 0,
99
- "EEPTIDR" => 0,
100
- "PEPTIDW" => 0,
101
- "PERPTIDW" => 1,
102
- "PEPKPTIDW" => 1,
103
- "PEPKTIDW" => 1,
104
- "RTTIDR" => 1,
105
- "RTTIKK" => 2,
106
- "PKEPRTIDW" => 2,
107
- "PKEPRTIDKP" => 3,
108
- "PKEPRAALKPEERPTIDKW" => 5,
109
- }
110
- ]
111
-
112
- sample_enzyme_ar = [@full_KRP, @just_KR]
113
- sample_enzyme_ar.zip(exp) do |sample_enzyme, hash|
114
- hash.each do |aaseq, val|
115
- #first, middle, last = SpecID::Pep.split_sequence(seq)
116
- # note that we are only using the middle section!
117
- sample_enzyme.num_missed_cleavages(aaseq).should == val
118
- end
119
- end
120
- end
121
-
122
- end
123
-
124
-
125
-
126
-