(name: &str, license: &str, tax_id: Option<&str>)
| 12 | const LICENSE_TYPES: [&str; 3] = ["academic", "commercial", "nonprofit"]; |
| 13 | |
| 14 | pub fn load_resource(name: &str, license: &str, tax_id: Option<&str>) -> anyhow::Result<DataFrame> { |
| 15 | if !LICENSE_TYPES.contains(&license) { |
| 16 | return Err(anyhow!( |
| 17 | "This license is not an allowed type, available are: academic, commercial, nonprofit." |
| 18 | )); |
| 19 | } |
| 20 | |
| 21 | let path = OMNIPATH_BASE_URL.to_owned() + format!("{}&license={}", name, license).as_str(); |
| 22 | |
| 23 | let results = Runtime::new().unwrap().block_on(download_resource(&path))?; |
| 24 | let res_bytes = results.to_bytes(); |
| 25 | let df = dataframe_from_csv_bytes(res_bytes, b'\t', true, None)?; |
| 26 | let df = process_omnipath_dataframe(df, tax_id)?; |
| 27 | Ok(df) |
| 28 | } |
| 29 | |
| 30 | fn process_omnipath_dataframe( |
| 31 | mut df: DataFrame, |
no test coverage detected