config.rs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. #[derive(Debug, Clone)]
  2. pub struct Config {
  3. pub pod_dir: String,
  4. pub result_dir: String,
  5. pub align: AlignConfig,
  6. pub reference: String,
  7. pub reference_name: String,
  8. pub savana_bin: String,
  9. pub savana_threads: u8,
  10. pub tumoral_name: String,
  11. pub normal_name: String,
  12. pub haplotagged_bam_tag_name: String,
  13. pub savana_output_dir: String,
  14. pub germline_phased_vcf: String,
  15. pub savana_passed_vcf: String,
  16. pub conda_sh: String,
  17. pub savana_force: bool,
  18. pub deepvariant_output_dir: String,
  19. pub severus_bin: String,
  20. pub severus_force: bool,
  21. pub severus_threads: u8,
  22. pub vntrs_bed: String,
  23. pub severus_pon: String,
  24. pub severus_output_dir: String,
  25. pub severus_solo_output_dir: String,
  26. pub longphase_bin: String,
  27. pub longphase_threads: u8,
  28. pub longphase_modcall_vcf: String,
  29. pub modkit_bin: String,
  30. pub modkit_summary_threads: u8,
  31. pub modkit_summary_file: String,
  32. pub longphase_modcall_threads: u8,
  33. pub deepvariant_threads: u8,
  34. pub deepvariant_bin_version: String,
  35. pub deepvariant_model_type: String,
  36. pub deepvariant_force: bool,
  37. }
  38. lazy_static! {
  39. static ref DEEPVARIANT_OUTPUT_NAME: &'static str = "{id}_{time}_DeepVariant.vcf.gz";
  40. }
  41. impl Default for Config {
  42. fn default() -> Self {
  43. Self {
  44. pod_dir: "/data/run_data".to_string(),
  45. align: Default::default(),
  46. // Reference genome
  47. reference: "/data/ref/hs1/chm13v2.0.fa".to_string(),
  48. reference_name: "hs1".to_string(),
  49. // File structure
  50. result_dir: "/data/longreads_basic_pipe".to_string(),
  51. tumoral_name: "diag".to_string(),
  52. normal_name: "mrd".to_string(),
  53. haplotagged_bam_tag_name: "hp".to_string(),
  54. germline_phased_vcf:
  55. "{result_dir}/{id}/diag/ClairS/clair3_normal_tumoral_germline_output_PS.vcf"
  56. .to_string(),
  57. conda_sh: "/data/miniconda3/etc/profile.d/conda.sh".to_string(),
  58. // DeepVariant
  59. deepvariant_output_dir: "{result_dir}/{id}/{time}/DeepVariant".to_string(),
  60. deepvariant_threads: 155,
  61. deepvariant_bin_version: "1.8.0".to_string(),
  62. deepvariant_model_type: "ONT_R104".to_string(),
  63. deepvariant_force: false,
  64. // Savana
  65. savana_bin: "savana".to_string(),
  66. savana_threads: 150,
  67. savana_output_dir: "{result_dir}/{id}/diag/savana".to_string(),
  68. savana_passed_vcf: "{output_dir}/{id}_diag_savana_PASSED.vcf".to_string(),
  69. savana_force: true,
  70. // Severus
  71. severus_bin: "/data/tools/Severus/severus.py".to_string(),
  72. severus_threads: 32,
  73. vntrs_bed: "/data/ref/hs1/vntrs_chm13.bed".to_string(),
  74. severus_pon: "/data/ref/hs1/PoN_1000G_chm13.tsv.gz".to_string(),
  75. severus_output_dir: "{result_dir}/{id}/diag/severus".to_string(),
  76. severus_solo_output_dir: "{result_dir}/{id}/{time}/severus".to_string(),
  77. severus_force: true,
  78. // Longphase
  79. longphase_bin: "/data/tools/longphase_linux-x64".to_string(),
  80. longphase_threads: 150,
  81. longphase_modcall_threads: 8, // ! out of memory
  82. longphase_modcall_vcf:
  83. "{result_dir}/{id}/{time}/5mC_5hmC/{id}_{time}_5mC_5hmC_modcall.vcf.gz".to_string(),
  84. // modkit
  85. modkit_bin: "modkit".to_string(),
  86. modkit_summary_threads: 50,
  87. modkit_summary_file: "{result_dir}/{id}/{time}/{id}_{time}_5mC_5hmC_summary.txt"
  88. .to_string(),
  89. }
  90. }
  91. }
  92. #[derive(Debug, Clone)]
  93. pub struct AlignConfig {
  94. pub dorado_bin: String,
  95. pub dorado_basecall_arg: String,
  96. pub ref_fa: String,
  97. pub ref_mmi: String,
  98. pub samtools_view_threads: u16,
  99. pub samtools_sort_threads: u16,
  100. }
  101. impl Default for AlignConfig {
  102. fn default() -> Self {
  103. Self {
  104. dorado_bin: "/data/tools/dorado-0.9.0-linux-x64/bin/dorado".to_string(),
  105. dorado_basecall_arg: "-x 'cuda:0,1,2,3' sup,5mC_5hmC".to_string(), // since v0.8.0 need
  106. // to specify cuda devices (exclude the T1000)
  107. ref_fa: "/data/ref/hs1/chm13v2.0.fa".to_string(),
  108. ref_mmi: "/data/ref/chm13v2.0.mmi".to_string(),
  109. samtools_view_threads: 20,
  110. samtools_sort_threads: 50,
  111. }
  112. }
  113. }
  114. impl Config {
  115. pub fn tumoral_dir(&self, id: &str) -> String {
  116. format!("{}/{}/{}", self.result_dir, id, self.tumoral_name)
  117. }
  118. pub fn normal_dir(&self, id: &str) -> String {
  119. format!("{}/{}/{}", self.result_dir, id, self.normal_name)
  120. }
  121. pub fn solo_dir(&self, id: &str, time: &str) -> String {
  122. format!("{}/{}/{}", self.result_dir, id, time)
  123. }
  124. pub fn solo_bam(&self, id: &str, time: &str) -> String {
  125. format!(
  126. "{}/{}_{}_{}.bam",
  127. self.solo_dir(id, time),
  128. id,
  129. time,
  130. self.reference_name,
  131. )
  132. }
  133. pub fn tumoral_bam(&self, id: &str) -> String {
  134. format!(
  135. "{}/{}_{}_{}.bam",
  136. self.tumoral_dir(id),
  137. id,
  138. self.tumoral_name,
  139. self.reference_name,
  140. )
  141. }
  142. pub fn normal_bam(&self, id: &str) -> String {
  143. format!(
  144. "{}/{}_{}_{}.bam",
  145. self.normal_dir(id),
  146. id,
  147. self.normal_name,
  148. self.reference_name,
  149. )
  150. }
  151. pub fn tumoral_haplotagged_bam(&self, id: &str) -> String {
  152. format!(
  153. "{}/{}_{}_{}_{}.bam",
  154. self.tumoral_dir(id),
  155. id,
  156. self.tumoral_name,
  157. self.reference_name,
  158. self.haplotagged_bam_tag_name
  159. )
  160. }
  161. pub fn normal_haplotagged_bam(&self, id: &str) -> String {
  162. format!(
  163. "{}/{}_{}_{}_{}.bam",
  164. self.normal_dir(id),
  165. id,
  166. self.normal_name,
  167. self.reference_name,
  168. self.haplotagged_bam_tag_name
  169. )
  170. }
  171. pub fn germline_phased_vcf(&self, id: &str) -> String {
  172. self.germline_phased_vcf
  173. .replace("{result_dir}", &self.result_dir)
  174. .replace("{id}", id)
  175. }
  176. // DeepVariant
  177. pub fn deepvariant_output_dir(&self, id: &str, time: &str) -> String {
  178. self.deepvariant_output_dir
  179. .replace("{result_dir}", &self.result_dir)
  180. .replace("{id}", id)
  181. .replace("{time}", time)
  182. }
  183. pub fn deepvariant_output_vcf(&self, id: &str, time: &str) -> String {
  184. format!(
  185. "{}/{}",
  186. self.deepvariant_output_dir(id, time),
  187. *DEEPVARIANT_OUTPUT_NAME
  188. )
  189. .replace("{id}", id)
  190. .replace("{time}", time)
  191. }
  192. // Savana
  193. pub fn savana_output_dir(&self, id: &str) -> String {
  194. self.savana_output_dir
  195. .replace("{result_dir}", &self.result_dir)
  196. .replace("{id}", id)
  197. }
  198. pub fn savana_output_vcf(&self, id: &str) -> String {
  199. let output_dir = self.savana_output_dir(id);
  200. format!("{output_dir}/{id}_diag_hs1_hp.classified.somatic.vcf")
  201. }
  202. pub fn savana_passed_vcf(&self, id: &str) -> String {
  203. self.savana_passed_vcf
  204. .replace("{output_dir}", &self.savana_output_dir(id))
  205. .replace("{id}", id)
  206. }
  207. // Severus
  208. pub fn severus_output_dir(&self, id: &str) -> String {
  209. self.severus_output_dir
  210. .replace("{result_dir}", &self.result_dir)
  211. .replace("{id}", id)
  212. }
  213. pub fn severus_output_vcf(&self, id: &str) -> String {
  214. let output_dir = self.severus_output_dir(id);
  215. format!("{output_dir}/somatic_SVs/severus_somatic.vcf")
  216. }
  217. pub fn severus_passed_vcf(&self, id: &str) -> String {
  218. format!(
  219. "{}/{}_diag_severus_PASSED.vcf.gz",
  220. &self.severus_output_dir(id),
  221. id
  222. )
  223. }
  224. // Severus solo
  225. pub fn severus_solo_output_dir(&self, id: &str, time: &str) -> String {
  226. self.severus_solo_output_dir
  227. .replace("{result_dir}", &self.result_dir)
  228. .replace("{id}", id)
  229. .replace("{time}", time)
  230. }
  231. pub fn severus_solo_output_vcf(&self, id: &str, time: &str) -> String {
  232. let output_dir = self.severus_solo_output_dir(id, time);
  233. format!("{output_dir}/all_SVs/severus_all.vcf")
  234. }
  235. pub fn severus_solo_passed_vcf(&self, id: &str, time: &str) -> String {
  236. format!(
  237. "{}/{}_{}_severus-solo_PASSED.vcf.gz",
  238. &self.severus_solo_output_dir(id, time),
  239. id,
  240. time
  241. )
  242. }
  243. pub fn constit_vcf(&self, id: &str) -> String {
  244. format!("{}/{}_variants_constit.vcf.gz", self.tumoral_dir(id), id)
  245. }
  246. pub fn constit_phased_vcf(&self, id: &str) -> String {
  247. format!("{}/{}_variants_constit_PS.vcf.gz", self.tumoral_dir(id), id)
  248. }
  249. pub fn modkit_summary_file(&self, id: &str, time: &str) -> String {
  250. self.modkit_summary_file
  251. .replace("{result_dir}", &self.result_dir)
  252. .replace("{id}", id)
  253. .replace("{time}", time)
  254. }
  255. pub fn longphase_modcall_vcf(&self, id: &str, time: &str) -> String {
  256. self.longphase_modcall_vcf
  257. .replace("{result_dir}", &self.result_dir)
  258. .replace("{id}", id)
  259. .replace("{time}", time)
  260. }
  261. }