@sjcrh/proteinpaint-rust 2.37.0 → 2.38.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/gdcmaf.rs +15 -3
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.37.0",
2
+ "version": "2.38.0",
3
3
  "name": "@sjcrh/proteinpaint-rust",
4
4
  "description": "Rust-based utilities for proteinpaint",
5
5
  "main": "index.js",
package/src/gdcmaf.rs CHANGED
@@ -1,3 +1,15 @@
1
+ /*
2
+ This script download cohort maf files from GDC, combine them into a single file, and output the sorted file based on chromsome and Start_Position.
3
+
4
+ Input JSON:
5
+ host: GDC host
6
+ fileIdLst: An array of uuid
7
+ Output gzip compressed maf file to stdout.
8
+
9
+ Example of usage:
10
+ echo '{"host": "https://api.gdc.cancer.gov/data/", "fileIdLst": ["8b31d6d1-56f7-4aa8-b026-c64bafd531e7", "b429fcc1-2b59-4b4c-a472-fb27758f6249"]}'|./target/release/gdcmaf
11
+ */
12
+
1
13
  use flate2::read::GzDecoder;
2
14
  use flate2::write::GzEncoder;
3
15
  use flate2::Compression;
@@ -85,14 +97,14 @@ const MAF_COL: [&str;96] = ["Hugo_Symbol", "Entrez_Gene_Id", "Center", "NCBI_Bui
85
97
  async fn main() -> Result<(),Box<dyn std::error::Error>> {
86
98
  // Accepting the piped input json from jodejs and assign to the variable
87
99
  // host: GDC host
88
- // save output into json string
89
100
  // url: urls to download single maf files
90
101
  let mut buffer = String::new();
91
102
  io::stdin().read_line(&mut buffer)?;
92
103
  let file_id_lst_js = serde_json::from_str::<Value>(&buffer).expect("Error reading input and serializing to JSON");
93
- let host = &file_id_lst_js["host"].as_str().unwrap();
104
+ let host = file_id_lst_js.get("host").expect("Host was not provided").as_str().expect("Host is not a string");
94
105
  let mut url: Vec<String> = Vec::new();
95
- for v in file_id_lst_js["fileIdLst"].as_array().unwrap() {
106
+ let file_id_lst = file_id_lst_js.get("fileIdLst").expect("File ID list is missed!").as_array().expect("File ID list is not an array");
107
+ for v in file_id_lst {
96
108
  url.push(Path::new(&host).join(&v.as_str().unwrap()).display().to_string());
97
109
  };
98
110