ngs_server 0.1 → 0.2

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 (248) hide show
  1. data/bin/ngs_server +72 -50
  2. data/ext/bamtools/extconf.rb +3 -3
  3. data/ext/vcftools/Makefile +28 -0
  4. data/ext/vcftools/README.txt +36 -0
  5. data/ext/vcftools/cpp/.svn/all-wcprops +125 -0
  6. data/ext/vcftools/cpp/.svn/dir-prop-base +6 -0
  7. data/ext/vcftools/cpp/.svn/entries +708 -0
  8. data/ext/vcftools/cpp/.svn/text-base/Makefile.svn-base +46 -0
  9. data/ext/vcftools/cpp/.svn/text-base/dgeev.cpp.svn-base +146 -0
  10. data/ext/vcftools/cpp/.svn/text-base/dgeev.h.svn-base +43 -0
  11. data/ext/vcftools/cpp/.svn/text-base/output_log.cpp.svn-base +79 -0
  12. data/ext/vcftools/cpp/.svn/text-base/output_log.h.svn-base +34 -0
  13. data/ext/vcftools/cpp/.svn/text-base/parameters.cpp.svn-base +535 -0
  14. data/ext/vcftools/cpp/.svn/text-base/parameters.h.svn-base +154 -0
  15. data/ext/vcftools/cpp/.svn/text-base/vcf_entry.cpp.svn-base +497 -0
  16. data/ext/vcftools/cpp/.svn/text-base/vcf_entry.h.svn-base +190 -0
  17. data/ext/vcftools/cpp/.svn/text-base/vcf_entry_getters.cpp.svn-base +421 -0
  18. data/ext/vcftools/cpp/.svn/text-base/vcf_entry_setters.cpp.svn-base +482 -0
  19. data/ext/vcftools/cpp/.svn/text-base/vcf_file.cpp.svn-base +495 -0
  20. data/ext/vcftools/cpp/.svn/text-base/vcf_file.h.svn-base +184 -0
  21. data/ext/vcftools/cpp/.svn/text-base/vcf_file_diff.cpp.svn-base +1282 -0
  22. data/ext/vcftools/cpp/.svn/text-base/vcf_file_filters.cpp.svn-base +1215 -0
  23. data/ext/vcftools/cpp/.svn/text-base/vcf_file_format_convert.cpp.svn-base +1138 -0
  24. data/ext/vcftools/cpp/.svn/text-base/vcf_file_index.cpp.svn-base +171 -0
  25. data/ext/vcftools/cpp/.svn/text-base/vcf_file_output.cpp.svn-base +3012 -0
  26. data/ext/vcftools/cpp/.svn/text-base/vcftools.cpp.svn-base +107 -0
  27. data/ext/vcftools/cpp/.svn/text-base/vcftools.h.svn-base +25 -0
  28. data/ext/vcftools/cpp/Makefile +46 -0
  29. data/ext/vcftools/cpp/dgeev.cpp +146 -0
  30. data/ext/vcftools/cpp/dgeev.h +43 -0
  31. data/ext/vcftools/cpp/output_log.cpp +79 -0
  32. data/ext/vcftools/cpp/output_log.h +34 -0
  33. data/ext/vcftools/cpp/parameters.cpp +535 -0
  34. data/ext/vcftools/cpp/parameters.h +154 -0
  35. data/ext/vcftools/cpp/vcf_entry.cpp +497 -0
  36. data/ext/vcftools/cpp/vcf_entry.h +190 -0
  37. data/ext/vcftools/cpp/vcf_entry_getters.cpp +421 -0
  38. data/ext/vcftools/cpp/vcf_entry_setters.cpp +482 -0
  39. data/ext/vcftools/cpp/vcf_file.cpp +495 -0
  40. data/ext/vcftools/cpp/vcf_file.h +184 -0
  41. data/ext/vcftools/cpp/vcf_file_diff.cpp +1282 -0
  42. data/ext/vcftools/cpp/vcf_file_filters.cpp +1215 -0
  43. data/ext/vcftools/cpp/vcf_file_format_convert.cpp +1138 -0
  44. data/ext/vcftools/cpp/vcf_file_index.cpp +171 -0
  45. data/ext/vcftools/cpp/vcf_file_output.cpp +3012 -0
  46. data/ext/vcftools/cpp/vcftools.cpp +107 -0
  47. data/ext/vcftools/cpp/vcftools.h +25 -0
  48. data/ext/vcftools/examples/.svn/all-wcprops +185 -0
  49. data/ext/vcftools/examples/.svn/dir-prop-base +6 -0
  50. data/ext/vcftools/examples/.svn/entries +1048 -0
  51. data/ext/vcftools/examples/.svn/prop-base/perl-api-1.pl.svn-base +5 -0
  52. data/ext/vcftools/examples/.svn/text-base/annotate-test.vcf.svn-base +37 -0
  53. data/ext/vcftools/examples/.svn/text-base/annotate.out.svn-base +23 -0
  54. data/ext/vcftools/examples/.svn/text-base/annotate.txt.svn-base +7 -0
  55. data/ext/vcftools/examples/.svn/text-base/annotate2.out.svn-base +52 -0
  56. data/ext/vcftools/examples/.svn/text-base/annotate3.out.svn-base +23 -0
  57. data/ext/vcftools/examples/.svn/text-base/cmp-test-a-3.3.vcf.svn-base +12 -0
  58. data/ext/vcftools/examples/.svn/text-base/cmp-test-a.vcf.svn-base +12 -0
  59. data/ext/vcftools/examples/.svn/text-base/cmp-test-b-3.3.vcf.svn-base +12 -0
  60. data/ext/vcftools/examples/.svn/text-base/cmp-test-b.vcf.svn-base +12 -0
  61. data/ext/vcftools/examples/.svn/text-base/cmp-test.out.svn-base +53 -0
  62. data/ext/vcftools/examples/.svn/text-base/concat-a.vcf.svn-base +21 -0
  63. data/ext/vcftools/examples/.svn/text-base/concat-b.vcf.svn-base +13 -0
  64. data/ext/vcftools/examples/.svn/text-base/concat-c.vcf.svn-base +19 -0
  65. data/ext/vcftools/examples/.svn/text-base/concat.out.svn-base +39 -0
  66. data/ext/vcftools/examples/.svn/text-base/invalid-4.0.vcf.svn-base +31 -0
  67. data/ext/vcftools/examples/.svn/text-base/isec-n2-test.vcf.out.svn-base +19 -0
  68. data/ext/vcftools/examples/.svn/text-base/merge-test-a.vcf.svn-base +17 -0
  69. data/ext/vcftools/examples/.svn/text-base/merge-test-b.vcf.svn-base +17 -0
  70. data/ext/vcftools/examples/.svn/text-base/merge-test-c.vcf.svn-base +15 -0
  71. data/ext/vcftools/examples/.svn/text-base/merge-test.vcf.out.svn-base +31 -0
  72. data/ext/vcftools/examples/.svn/text-base/perl-api-1.pl.svn-base +46 -0
  73. data/ext/vcftools/examples/.svn/text-base/query-test.out.svn-base +6 -0
  74. data/ext/vcftools/examples/.svn/text-base/shuffle-test.vcf.svn-base +12 -0
  75. data/ext/vcftools/examples/.svn/text-base/subset.SNPs.out.svn-base +10 -0
  76. data/ext/vcftools/examples/.svn/text-base/subset.indels.out.svn-base +18 -0
  77. data/ext/vcftools/examples/.svn/text-base/subset.vcf.svn-base +21 -0
  78. data/ext/vcftools/examples/.svn/text-base/valid-3.3.vcf.svn-base +30 -0
  79. data/ext/vcftools/examples/.svn/text-base/valid-4.0.vcf.stats.svn-base +104 -0
  80. data/ext/vcftools/examples/.svn/text-base/valid-4.0.vcf.svn-base +34 -0
  81. data/ext/vcftools/examples/.svn/text-base/valid-4.1.vcf.svn-base +37 -0
  82. data/ext/vcftools/examples/annotate-test.vcf +37 -0
  83. data/ext/vcftools/examples/annotate.out +23 -0
  84. data/ext/vcftools/examples/annotate.txt +7 -0
  85. data/ext/vcftools/examples/annotate2.out +52 -0
  86. data/ext/vcftools/examples/annotate3.out +23 -0
  87. data/ext/vcftools/examples/cmp-test-a-3.3.vcf +12 -0
  88. data/ext/vcftools/examples/cmp-test-a.vcf +12 -0
  89. data/ext/vcftools/examples/cmp-test-b-3.3.vcf +12 -0
  90. data/ext/vcftools/examples/cmp-test-b.vcf +12 -0
  91. data/ext/vcftools/examples/cmp-test.out +53 -0
  92. data/ext/vcftools/examples/concat-a.vcf +21 -0
  93. data/ext/vcftools/examples/concat-b.vcf +13 -0
  94. data/ext/vcftools/examples/concat-c.vcf +19 -0
  95. data/ext/vcftools/examples/concat.out +39 -0
  96. data/ext/vcftools/examples/invalid-4.0.vcf +31 -0
  97. data/ext/vcftools/examples/isec-n2-test.vcf.out +19 -0
  98. data/ext/vcftools/examples/merge-test-a.vcf +17 -0
  99. data/ext/vcftools/examples/merge-test-b.vcf +17 -0
  100. data/ext/vcftools/examples/merge-test-c.vcf +15 -0
  101. data/ext/vcftools/examples/merge-test.vcf.out +31 -0
  102. data/ext/vcftools/examples/perl-api-1.pl +46 -0
  103. data/ext/vcftools/examples/query-test.out +6 -0
  104. data/ext/vcftools/examples/shuffle-test.vcf +12 -0
  105. data/ext/vcftools/examples/subset.SNPs.out +10 -0
  106. data/ext/vcftools/examples/subset.indels.out +18 -0
  107. data/ext/vcftools/examples/subset.vcf +21 -0
  108. data/ext/vcftools/examples/valid-3.3.vcf +30 -0
  109. data/ext/vcftools/examples/valid-4.0.vcf +34 -0
  110. data/ext/vcftools/examples/valid-4.0.vcf.stats +104 -0
  111. data/ext/vcftools/examples/valid-4.1.vcf +37 -0
  112. data/ext/vcftools/extconf.rb +2 -0
  113. data/ext/vcftools/perl/.svn/all-wcprops +149 -0
  114. data/ext/vcftools/perl/.svn/entries +844 -0
  115. data/ext/vcftools/perl/.svn/prop-base/fill-aa.svn-base +5 -0
  116. data/ext/vcftools/perl/.svn/prop-base/fill-an-ac.svn-base +5 -0
  117. data/ext/vcftools/perl/.svn/prop-base/fill-ref-md5.svn-base +5 -0
  118. data/ext/vcftools/perl/.svn/prop-base/tab-to-vcf.svn-base +5 -0
  119. data/ext/vcftools/perl/.svn/prop-base/test.t.svn-base +5 -0
  120. data/ext/vcftools/perl/.svn/prop-base/vcf-annotate.svn-base +5 -0
  121. data/ext/vcftools/perl/.svn/prop-base/vcf-compare.svn-base +5 -0
  122. data/ext/vcftools/perl/.svn/prop-base/vcf-concat.svn-base +5 -0
  123. data/ext/vcftools/perl/.svn/prop-base/vcf-convert.svn-base +5 -0
  124. data/ext/vcftools/perl/.svn/prop-base/vcf-fix-newlines.svn-base +5 -0
  125. data/ext/vcftools/perl/.svn/prop-base/vcf-isec.svn-base +5 -0
  126. data/ext/vcftools/perl/.svn/prop-base/vcf-merge.svn-base +5 -0
  127. data/ext/vcftools/perl/.svn/prop-base/vcf-query.svn-base +5 -0
  128. data/ext/vcftools/perl/.svn/prop-base/vcf-shuffle-cols.svn-base +5 -0
  129. data/ext/vcftools/perl/.svn/prop-base/vcf-sort.svn-base +5 -0
  130. data/ext/vcftools/perl/.svn/prop-base/vcf-stats.svn-base +5 -0
  131. data/ext/vcftools/perl/.svn/prop-base/vcf-subset.svn-base +5 -0
  132. data/ext/vcftools/perl/.svn/prop-base/vcf-to-tab.svn-base +5 -0
  133. data/ext/vcftools/perl/.svn/prop-base/vcf-validator.svn-base +5 -0
  134. data/ext/vcftools/perl/.svn/text-base/ChangeLog.svn-base +84 -0
  135. data/ext/vcftools/perl/.svn/text-base/FaSlice.pm.svn-base +214 -0
  136. data/ext/vcftools/perl/.svn/text-base/Makefile.svn-base +12 -0
  137. data/ext/vcftools/perl/.svn/text-base/Vcf.pm.svn-base +2853 -0
  138. data/ext/vcftools/perl/.svn/text-base/VcfStats.pm.svn-base +681 -0
  139. data/ext/vcftools/perl/.svn/text-base/fill-aa.svn-base +103 -0
  140. data/ext/vcftools/perl/.svn/text-base/fill-an-ac.svn-base +56 -0
  141. data/ext/vcftools/perl/.svn/text-base/fill-ref-md5.svn-base +204 -0
  142. data/ext/vcftools/perl/.svn/text-base/tab-to-vcf.svn-base +92 -0
  143. data/ext/vcftools/perl/.svn/text-base/test.t.svn-base +376 -0
  144. data/ext/vcftools/perl/.svn/text-base/vcf-annotate.svn-base +1099 -0
  145. data/ext/vcftools/perl/.svn/text-base/vcf-compare.svn-base +1193 -0
  146. data/ext/vcftools/perl/.svn/text-base/vcf-concat.svn-base +310 -0
  147. data/ext/vcftools/perl/.svn/text-base/vcf-convert.svn-base +180 -0
  148. data/ext/vcftools/perl/.svn/text-base/vcf-fix-newlines.svn-base +97 -0
  149. data/ext/vcftools/perl/.svn/text-base/vcf-isec.svn-base +660 -0
  150. data/ext/vcftools/perl/.svn/text-base/vcf-merge.svn-base +577 -0
  151. data/ext/vcftools/perl/.svn/text-base/vcf-query.svn-base +272 -0
  152. data/ext/vcftools/perl/.svn/text-base/vcf-shuffle-cols.svn-base +89 -0
  153. data/ext/vcftools/perl/.svn/text-base/vcf-sort.svn-base +79 -0
  154. data/ext/vcftools/perl/.svn/text-base/vcf-stats.svn-base +160 -0
  155. data/ext/vcftools/perl/.svn/text-base/vcf-subset.svn-base +206 -0
  156. data/ext/vcftools/perl/.svn/text-base/vcf-to-tab.svn-base +112 -0
  157. data/ext/vcftools/perl/.svn/text-base/vcf-validator.svn-base +145 -0
  158. data/ext/vcftools/perl/ChangeLog +84 -0
  159. data/ext/vcftools/perl/FaSlice.pm +214 -0
  160. data/ext/vcftools/perl/Makefile +12 -0
  161. data/ext/vcftools/perl/Vcf.pm +2853 -0
  162. data/ext/vcftools/perl/VcfStats.pm +681 -0
  163. data/ext/vcftools/perl/fill-aa +103 -0
  164. data/ext/vcftools/perl/fill-an-ac +56 -0
  165. data/ext/vcftools/perl/fill-ref-md5 +204 -0
  166. data/ext/vcftools/perl/tab-to-vcf +92 -0
  167. data/ext/vcftools/perl/test.t +376 -0
  168. data/ext/vcftools/perl/vcf-annotate +1099 -0
  169. data/ext/vcftools/perl/vcf-compare +1193 -0
  170. data/ext/vcftools/perl/vcf-concat +310 -0
  171. data/ext/vcftools/perl/vcf-convert +180 -0
  172. data/ext/vcftools/perl/vcf-fix-newlines +97 -0
  173. data/ext/vcftools/perl/vcf-isec +660 -0
  174. data/ext/vcftools/perl/vcf-merge +577 -0
  175. data/ext/vcftools/perl/vcf-query +286 -0
  176. data/ext/vcftools/perl/vcf-shuffle-cols +89 -0
  177. data/ext/vcftools/perl/vcf-sort +79 -0
  178. data/ext/vcftools/perl/vcf-stats +160 -0
  179. data/ext/vcftools/perl/vcf-subset +206 -0
  180. data/ext/vcftools/perl/vcf-to-tab +112 -0
  181. data/ext/vcftools/perl/vcf-validator +145 -0
  182. data/ext/vcftools/website/.svn/all-wcprops +41 -0
  183. data/ext/vcftools/website/.svn/entries +238 -0
  184. data/ext/vcftools/website/.svn/prop-base/VCF-poster.pdf.svn-base +5 -0
  185. data/ext/vcftools/website/.svn/prop-base/favicon.ico.svn-base +5 -0
  186. data/ext/vcftools/website/.svn/prop-base/favicon.png.svn-base +5 -0
  187. data/ext/vcftools/website/.svn/text-base/Makefile.svn-base +6 -0
  188. data/ext/vcftools/website/.svn/text-base/README.svn-base +2 -0
  189. data/ext/vcftools/website/.svn/text-base/VCF-poster.pdf.svn-base +0 -0
  190. data/ext/vcftools/website/.svn/text-base/default.css.svn-base +250 -0
  191. data/ext/vcftools/website/.svn/text-base/favicon.ico.svn-base +0 -0
  192. data/ext/vcftools/website/.svn/text-base/favicon.png.svn-base +0 -0
  193. data/ext/vcftools/website/Makefile +6 -0
  194. data/ext/vcftools/website/README +2 -0
  195. data/ext/vcftools/website/VCF-poster.pdf +0 -0
  196. data/ext/vcftools/website/default.css +250 -0
  197. data/ext/vcftools/website/favicon.ico +0 -0
  198. data/ext/vcftools/website/favicon.png +0 -0
  199. data/ext/vcftools/website/img/.svn/all-wcprops +53 -0
  200. data/ext/vcftools/website/img/.svn/entries +300 -0
  201. data/ext/vcftools/website/img/.svn/prop-base/bg.gif.svn-base +5 -0
  202. data/ext/vcftools/website/img/.svn/prop-base/bgcode.gif.svn-base +5 -0
  203. data/ext/vcftools/website/img/.svn/prop-base/bgcontainer.gif.svn-base +5 -0
  204. data/ext/vcftools/website/img/.svn/prop-base/bgul.gif.svn-base +5 -0
  205. data/ext/vcftools/website/img/.svn/prop-base/header.gif.svn-base +5 -0
  206. data/ext/vcftools/website/img/.svn/prop-base/li.gif.svn-base +5 -0
  207. data/ext/vcftools/website/img/.svn/prop-base/quote.gif.svn-base +5 -0
  208. data/ext/vcftools/website/img/.svn/prop-base/search.gif.svn-base +5 -0
  209. data/ext/vcftools/website/img/.svn/text-base/bg.gif.svn-base +0 -0
  210. data/ext/vcftools/website/img/.svn/text-base/bgcode.gif.svn-base +0 -0
  211. data/ext/vcftools/website/img/.svn/text-base/bgcontainer.gif.svn-base +0 -0
  212. data/ext/vcftools/website/img/.svn/text-base/bgul.gif.svn-base +0 -0
  213. data/ext/vcftools/website/img/.svn/text-base/header.gif.svn-base +0 -0
  214. data/ext/vcftools/website/img/.svn/text-base/li.gif.svn-base +0 -0
  215. data/ext/vcftools/website/img/.svn/text-base/quote.gif.svn-base +0 -0
  216. data/ext/vcftools/website/img/.svn/text-base/search.gif.svn-base +0 -0
  217. data/ext/vcftools/website/img/bg.gif +0 -0
  218. data/ext/vcftools/website/img/bgcode.gif +0 -0
  219. data/ext/vcftools/website/img/bgcontainer.gif +0 -0
  220. data/ext/vcftools/website/img/bgul.gif +0 -0
  221. data/ext/vcftools/website/img/header.gif +0 -0
  222. data/ext/vcftools/website/img/li.gif +0 -0
  223. data/ext/vcftools/website/img/quote.gif +0 -0
  224. data/ext/vcftools/website/img/search.gif +0 -0
  225. data/ext/vcftools/website/src/.svn/all-wcprops +53 -0
  226. data/ext/vcftools/website/src/.svn/entries +300 -0
  227. data/ext/vcftools/website/src/.svn/text-base/docs.inc.svn-base +202 -0
  228. data/ext/vcftools/website/src/.svn/text-base/index.inc.svn-base +52 -0
  229. data/ext/vcftools/website/src/.svn/text-base/index.php.svn-base +80 -0
  230. data/ext/vcftools/website/src/.svn/text-base/license.inc.svn-base +27 -0
  231. data/ext/vcftools/website/src/.svn/text-base/links.inc.svn-base +13 -0
  232. data/ext/vcftools/website/src/.svn/text-base/options.inc.svn-base +654 -0
  233. data/ext/vcftools/website/src/.svn/text-base/perl_module.inc.svn-base +249 -0
  234. data/ext/vcftools/website/src/.svn/text-base/specs.inc.svn-base +18 -0
  235. data/ext/vcftools/website/src/docs.inc +202 -0
  236. data/ext/vcftools/website/src/index.inc +52 -0
  237. data/ext/vcftools/website/src/index.php +80 -0
  238. data/ext/vcftools/website/src/license.inc +27 -0
  239. data/ext/vcftools/website/src/links.inc +13 -0
  240. data/ext/vcftools/website/src/options.inc +654 -0
  241. data/ext/vcftools/website/src/perl_module.inc +249 -0
  242. data/ext/vcftools/website/src/specs.inc +18 -0
  243. data/lib/config.ru +9 -0
  244. data/lib/ngs_server/add.rb +9 -0
  245. data/lib/ngs_server/version.rb +1 -1
  246. data/lib/ngs_server.rb +55 -3
  247. data/ngs_server.gemspec +5 -2
  248. metadata +296 -6
@@ -0,0 +1,482 @@
1
+ /*
2
+ * vcf_entry_setters.cpp
3
+ *
4
+ * Created on: Nov 11, 2009
5
+ * Author: Adam Auton
6
+ * ($Revision: 230 $)
7
+ */
8
+
9
+ #include "vcf_entry.h"
10
+
11
+ void vcf_entry::set_CHROM(const string &in)
12
+ {
13
+ CHROM = in;
14
+ }
15
+
16
+ void vcf_entry::set_POS(const int in)
17
+ {
18
+ POS = in;
19
+ }
20
+
21
+ void vcf_entry::set_ID(const string &in)
22
+ {
23
+ ID = in;
24
+ }
25
+
26
+ void vcf_entry::set_REF(const string &in)
27
+ {
28
+ REF = in;
29
+ }
30
+
31
+ void vcf_entry::set_ALT(const string &in)
32
+ {
33
+ istringstream ss(in);
34
+ string tmpstr;
35
+ ALT.resize(0);
36
+ while(!ss.eof())
37
+ {
38
+ getline(ss, tmpstr, ',');
39
+ add_ALT_allele(tmpstr);
40
+ }
41
+ parsed_ALT = true;
42
+ }
43
+
44
+ void vcf_entry::add_ALT_allele(const string &in)
45
+ {
46
+ if (in != ".")
47
+ {
48
+ if (find(ALT.begin(), ALT.end(),in) == ALT.end())
49
+ {
50
+ ALT.push_back(in);
51
+ }
52
+ }
53
+ parsed_ALT = true;
54
+ }
55
+
56
+ void vcf_entry::set_QUAL(const double in)
57
+ {
58
+ QUAL = in;
59
+ }
60
+
61
+ void vcf_entry::add_FILTER_entry(const string &in)
62
+ {
63
+ if ((in != "PASS") && (in != "."))
64
+ if (find(FILTER.begin(), FILTER.end(), in) == FILTER.end())
65
+ FILTER.push_back(in);
66
+ sort(FILTER.begin(), FILTER.end());
67
+ parsed_FILTER = true;
68
+ }
69
+
70
+ void vcf_entry::set_FORMAT(const string &in)
71
+ {
72
+ FORMAT.resize(0);
73
+ FORMAT_to_idx.clear();
74
+
75
+ if (in.size() > 0)
76
+ {
77
+ istringstream ss(in);
78
+ string tmpstr;
79
+
80
+ unsigned int pos=0;
81
+ while(!ss.eof())
82
+ {
83
+ getline(ss, tmpstr, ':');
84
+ add_FORMAT_entry(tmpstr, pos);
85
+ pos++;
86
+ }
87
+ }
88
+
89
+ GT_idx = -1;
90
+ GQ_idx = -1;
91
+ DP_idx = -1;
92
+ FT_idx = -1;
93
+
94
+ if (FORMAT_to_idx.find("GT") != FORMAT_to_idx.end())
95
+ GT_idx = FORMAT_to_idx["GT"];
96
+ if (FORMAT_to_idx.find("GQ") != FORMAT_to_idx.end())
97
+ GQ_idx = FORMAT_to_idx["GQ"];
98
+ if (FORMAT_to_idx.find("DP") != FORMAT_to_idx.end())
99
+ DP_idx = FORMAT_to_idx["DP"];
100
+ if (FORMAT_to_idx.find("FT") != FORMAT_to_idx.end())
101
+ FT_idx = FORMAT_to_idx["FT"];
102
+
103
+ parsed_FORMAT = true;
104
+ }
105
+
106
+ void vcf_entry::add_FORMAT_entry(const string &in, unsigned int pos)
107
+ {
108
+ FORMAT.push_back(in);
109
+ FORMAT_to_idx[in] = pos;
110
+ }
111
+
112
+ // The following function reads in a genotype from a '0/1'-like string.
113
+ // Should handle haploid types to, but NOT polyploidy.
114
+ void vcf_entry::set_indv_GENOTYPE_and_PHASE(unsigned int indv, const string &in)
115
+ {
116
+ ploidy.resize(N_indv);
117
+ if ((in.size() == 3) && ((in.c_str()[1] == '/') || (in.c_str()[1] == '|')))
118
+ { // Fast, diploid case...
119
+ ploidy[indv] = 2;
120
+ set_indv_PHASE(indv, in.c_str()[1]);
121
+ set_indv_GENOTYPE_alleles(indv, in.c_str()[0], in.c_str()[2]);
122
+ }
123
+ else
124
+ { // More complex case...
125
+ size_t pos = in.find_first_of("/|");
126
+ if (pos != string::npos)
127
+ { // autosome
128
+ ploidy[indv] = 2;
129
+ set_indv_PHASE(indv, in[pos]);
130
+ set_indv_GENOTYPE_alleles(indv, make_pair(in.substr(0,pos), in.substr(pos+1)));
131
+ }
132
+ else
133
+ { // Male chrX, or chrY
134
+ ploidy[indv] = 1;
135
+ set_indv_PHASE(indv, '|');
136
+ set_indv_GENOTYPE_alleles(indv, make_pair(in.substr(0,pos), "."));
137
+ }
138
+
139
+ // Check for polypoidy
140
+ size_t pos2 = in.find_last_of("/|");
141
+ if (pos != pos2)
142
+ error("Polypolidy found, and not supported: " + CHROM + ":" + int2str(POS));
143
+ }
144
+
145
+ parsed_GT[indv] = true;
146
+ }
147
+
148
+ void vcf_entry::set_indv_GENOTYPE_and_PHASE(unsigned int indv, const pair<int, int> &genotype, char phase)
149
+ {
150
+ set_indv_GENOTYPE_ids(indv, genotype);
151
+ set_indv_PHASE(indv, phase);
152
+ parsed_GT[indv] = true;
153
+ }
154
+
155
+ void vcf_entry::set_indv_GENOTYPE_and_PHASE(unsigned int indv, const pair<string, string> &genotype, char phase)
156
+ {
157
+ set_indv_GENOTYPE_alleles(indv, genotype);
158
+ set_indv_PHASE(indv, phase);
159
+ parsed_GT[indv] = true;
160
+ }
161
+
162
+ void vcf_entry::set_indv_GENOTYPE_alleles(unsigned int indv, const pair<string, string> &in)
163
+ {
164
+ if (GENOTYPE.size() == 0)
165
+ GENOTYPE.resize(N_indv, make_pair(-1,-1));
166
+
167
+ pair<int, int> a(-1,-1);
168
+
169
+ if (in.first != ".")
170
+ a.first = str2int(in.first);
171
+
172
+ if (in.second != ".")
173
+ a.second = str2int(in.second);
174
+
175
+ GENOTYPE[indv] = a;
176
+ parsed_GT[indv] = true;
177
+ }
178
+
179
+ void vcf_entry::set_indv_GENOTYPE_alleles(unsigned int indv, char a1, char a2)
180
+ {
181
+ if (GENOTYPE.size() == 0)
182
+ GENOTYPE.resize(N_indv, make_pair(-1,-1));
183
+
184
+ pair<int, int> a(-1,-1);
185
+
186
+ if (a1 != '.')
187
+ a.first = a1 - '0';
188
+
189
+ if (a2 != '.')
190
+ a.second = a2 - '0';
191
+
192
+ GENOTYPE[indv] = a;
193
+ parsed_GT[indv] = true;
194
+ }
195
+
196
+
197
+ void vcf_entry::set_indv_GENOTYPE_ids(unsigned int indv, const pair<int, int> &in)
198
+ {
199
+ if (GENOTYPE.size() == 0)
200
+ GENOTYPE.resize(N_indv, make_pair(-1,-1));
201
+ GENOTYPE[indv] = in;
202
+ }
203
+
204
+ void vcf_entry::set_indv_PHASE(unsigned int indv, char in)
205
+ {
206
+ if (PHASE.size() == 0)
207
+ PHASE.resize(N_indv, '/');
208
+
209
+ PHASE[indv] = in;
210
+ parsed_GT[indv] = true;
211
+ }
212
+
213
+ void vcf_entry::set_indv_GQUALITY(unsigned int indv, double in)
214
+ {
215
+ parsed_GQ[indv] = true;
216
+ if (in == -1)
217
+ return;
218
+ if (GQUALITY.size() == 0)
219
+ GQUALITY.resize(N_indv, -1);
220
+
221
+ if (in > 99)
222
+ in = 99;
223
+ GQUALITY[indv] = in;
224
+ }
225
+
226
+ void vcf_entry::set_indv_DEPTH(unsigned int indv, int in)
227
+ {
228
+ parsed_DP[indv] = true;
229
+ if (in == -1)
230
+ return;
231
+ if (DEPTH.size() == 0)
232
+ DEPTH.resize(N_indv, -1);
233
+
234
+ DEPTH[indv] = in;
235
+ }
236
+
237
+ void vcf_entry::add_indv_GFILTER(unsigned int indv, const string &in)
238
+ {
239
+ if (GFILTER.size() == 0)
240
+ GFILTER.resize(N_indv);
241
+
242
+ if (in != ".")
243
+ if (find(GFILTER[indv].begin(), GFILTER[indv].end(), in) == GFILTER[indv].end())
244
+ GFILTER[indv].push_back(in);
245
+ parsed_FT[indv] = true;
246
+ }
247
+
248
+ void vcf_entry::set_indv_GFILTER(unsigned int indv, const string &in)
249
+ {
250
+ parsed_FT[indv] = true;
251
+ if ((in.size() == 0) || (in == "."))
252
+ return;
253
+
254
+ if (GFILTER.size() == 0)
255
+ GFILTER.resize(N_indv);
256
+
257
+ GFILTER[indv].resize(0);
258
+
259
+ static istringstream ss;
260
+ static string ith_FILTER;
261
+ ss.clear();
262
+ ss.str(in);
263
+ while (!ss.eof())
264
+ {
265
+ getline(ss, ith_FILTER, ';');
266
+
267
+ if ((ith_FILTER.size()==0) || (ith_FILTER == "."))
268
+ continue; // Don't bother storing "unfiltered" state.
269
+
270
+ GFILTER[indv].push_back(ith_FILTER);
271
+ }
272
+ }
273
+
274
+ void vcf_entry::set_FILTER(const string &FILTER_str)
275
+ {
276
+ FILTER.resize(0);
277
+ passed_filters = false;
278
+ if (FILTER_str == "PASS")
279
+ passed_filters = true;
280
+ else
281
+ {
282
+ if (FILTER_str != ".")
283
+ {
284
+ istringstream ss(FILTER_str);
285
+ string ith_FILTER;
286
+ while (!ss.eof())
287
+ {
288
+ getline(ss, ith_FILTER, ';');
289
+ FILTER.push_back(ith_FILTER);
290
+ }
291
+ }
292
+ }
293
+ sort(FILTER.begin(), FILTER.end());
294
+ parsed_FILTER = true;
295
+ }
296
+
297
+ void vcf_entry::set_INFO(const string &INFO_str)
298
+ {
299
+ INFO.resize(0);
300
+ if ((INFO_str.size() > 0) && (INFO_str != "."))
301
+ {
302
+ istringstream ss(INFO_str);
303
+ string tmpstr;
304
+ while(!ss.eof())
305
+ {
306
+ getline(ss, tmpstr, ';');
307
+
308
+ istringstream ss2(tmpstr);
309
+ getline(ss2, tmpstr, '=');
310
+ pair<string, string> INFO_entry(tmpstr, ".");
311
+
312
+ if (!ss2.eof())
313
+ { // If there is a value entry, read it now
314
+ getline(ss2, tmpstr);
315
+ INFO_entry.second = tmpstr;
316
+ }
317
+ else // Otherwise, set it equal to 1
318
+ INFO_entry.second = "1";
319
+
320
+ INFO.push_back(INFO_entry);
321
+ }
322
+ }
323
+ parsed_INFO = true;
324
+ }
325
+
326
+ void vcf_entry::add_INFO_descriptor(const string &in)
327
+ {
328
+ size_t found=in.find("##INFO=");
329
+ if (found!=string::npos)
330
+ { // Found an INFO descriptor
331
+ size_t found_start=in.find_first_of("<");
332
+ size_t found_end=in.find_last_of(">");
333
+ string details = in.substr(found_start+1, found_end-found_start-1);
334
+ Field_description I;
335
+
336
+ vector<string> tokens;
337
+ tokenize(details, ',', tokens);
338
+ if (tokens.size() < 4)
339
+ error("Expected 4 parts in INFO definition: " + in);
340
+
341
+ vector<string> entry;
342
+ tokenize(tokens[0], '=', entry);
343
+ if (entry[0] == "ID") I.ID = entry[1];
344
+ else error("Expected ID entry as first field in INFO description: " + in);
345
+
346
+ tokenize(tokens[1], '=', entry);
347
+ if (entry[0] == "Number")
348
+ { // TODO - handle 'A' and 'G' categories correctly.
349
+ if ((entry[1] == "A") || (entry[1] == "G"))
350
+ I.N_entries = -1; // Currently just treat as missing.
351
+ else
352
+ I.N_entries = str2int(entry[1]);
353
+ }
354
+ else error("Expected Number entry as second field in INFO description: " + in);
355
+
356
+ tokenize(tokens[2], '=', entry);
357
+ if (entry[0] == "Type")
358
+ {
359
+ if (entry[1] == "Integer") I.Type = Integer;
360
+ else if ((entry[1] == "Float") || (entry[1] == "Numeric")) I.Type = Float;
361
+ else if (entry[1] == "Character") I.Type = Character;
362
+ else if (entry[1] == "String") I.Type = String;
363
+ else if (entry[1] == "Flag")
364
+ {
365
+ I.Type = Flag;
366
+ if (I.N_entries != 0) error("Flag Type must have 0 entries: " + in);
367
+ }
368
+ else error("Unknown Type in INFO meta-information: " + in);
369
+ }
370
+ else error("Expected Type entry as third field in INFO description: " + in);
371
+
372
+ tokenize(tokens[3], '=', entry);
373
+ if (entry[0] == "Description")
374
+ {
375
+ I.Description = entry[1];
376
+ for (unsigned int i=4; i<tokens.size(); i++)
377
+ {
378
+ I.Description += "; " + tokens[i];
379
+ }
380
+ }
381
+ else error("Expected Description entry as fourth field in INFO description: " + in);
382
+
383
+ INFO_map[I.ID] = I;
384
+ }
385
+ }
386
+
387
+ void vcf_entry::add_FILTER_descriptor(const string &in)
388
+ {
389
+ size_t found=in.find("##FILTER=");
390
+ if (found!=string::npos)
391
+ {
392
+ size_t found_start=in.find_first_of("<");
393
+ size_t found_end=in.find_last_of(">");
394
+ string details = in.substr(found_start+1, found_end-found_start-1);
395
+ vector<string> tokens;
396
+ tokenize(details, ',', tokens);
397
+
398
+ if (tokens.size() < 2)
399
+ error("Expected 2 parts in FILTER definition: " + in);
400
+
401
+ string ID, Description;
402
+ vector<string> entry;
403
+ tokenize(tokens[0], '=', entry);
404
+ if (entry[0] == "ID") ID = entry[1];
405
+ else error("Expected ID as first field in FILTER description: " + in);
406
+
407
+ tokenize(tokens[1], '=', entry);
408
+ if (entry[0] == "Description")
409
+ {
410
+ Description = entry[1];
411
+ for (unsigned int i=2; i<tokens.size(); i++)
412
+ {
413
+ Description += "; " + tokens[i];
414
+ }
415
+ }
416
+ else
417
+ error("Expected Description as second field in FILTER description: " + in);
418
+
419
+ FILTER_map[ID] = Description;
420
+ }
421
+ }
422
+
423
+ void vcf_entry::add_FORMAT_descriptor(const string &in)
424
+ {
425
+ size_t found=in.find("##FORMAT=");
426
+ if (found!=string::npos)
427
+ { // Found an FORMAT descriptor
428
+ size_t found_start=in.find_first_of("<");
429
+ size_t found_end=in.find_last_of(">");
430
+ string details = in.substr(found_start+1, found_end-found_start-1);
431
+ vector<string> tokens;
432
+ tokenize(details, ',', tokens);
433
+ Field_description I;
434
+
435
+ if (tokens.size() < 4)
436
+ error("Expected 4 parts in FORMAT definition: " + in);
437
+
438
+ vector<string> entry;
439
+ tokenize(tokens[0], '=', entry);
440
+ if (entry[0] == "ID") I.ID = entry[1];
441
+ else error("Expected ID entry as first field in FORMAT description: " + in);
442
+
443
+ tokenize(tokens[1], '=', entry);
444
+ if (entry[0] == "Number")
445
+ { // TODO - handle 'A' and 'G' categories correctly.
446
+ if ((entry[1] == "A") || (entry[1] == "G"))
447
+ I.N_entries = -1; // Currently just treat as missing.
448
+ else
449
+ I.N_entries = str2int(entry[1]);
450
+ }
451
+ else error("Expected Number entry as second field in FORMAT description: " + in);
452
+
453
+ tokenize(tokens[2], '=', entry);
454
+ if (entry[0] == "Type")
455
+ {
456
+ if (entry[1] == "Integer") I.Type = Integer;
457
+ else if ((entry[1] == "Float") || (entry[1] == "Numeric")) I.Type = Float;
458
+ else if (entry[1] == "Character") I.Type = Character;
459
+ else if (entry[1] == "String") I.Type = String;
460
+ else if (entry[1] == "Flag")
461
+ {
462
+ I.Type = Flag;
463
+ if (I.N_entries != 0) error("Flag Type must have 0 entries: " + in);
464
+ }
465
+ else error("Unknown Type in FORMAT meta-information: " + in);
466
+ }
467
+ else error("Expected Type entry as third field in FORMAT description: " + in);
468
+
469
+ tokenize(tokens[3], '=', entry);
470
+ if (entry[0] == "Description")
471
+ {
472
+ I.Description = entry[1];
473
+ for (unsigned int i=4; i<tokens.size(); i++)
474
+ {
475
+ I.Description += "; " + tokens[i];
476
+ }
477
+ }
478
+ else error("Expected Description entry as fourth field in FORMAT description: " + in);
479
+
480
+ FORMAT_map[I.ID] = I;
481
+ }
482
+ }