|
@@ -7,7 +7,7 @@ use flate2::Compression;
|
|
|
use serde::Serialize;
|
|
use serde::Serialize;
|
|
|
use serde_json::{json, Value};
|
|
use serde_json::{json, Value};
|
|
|
use smart_default::SmartDefault;
|
|
use smart_default::SmartDefault;
|
|
|
-use std::{io::prelude::*, usize};
|
|
|
|
|
|
|
+use std::io::prelude::*;
|
|
|
|
|
|
|
|
/// Compress string according to compressString from: https://github.com/igvteam/igv-utils/blob/master/src/bgzf.js#L125
|
|
/// Compress string according to compressString from: https://github.com/igvteam/igv-utils/blob/master/src/bgzf.js#L125
|
|
|
fn compress_string(input: &str) -> anyhow::Result<String> {
|
|
fn compress_string(input: &str) -> anyhow::Result<String> {
|
|
@@ -104,12 +104,20 @@ impl Session {
|
|
|
Ok(self)
|
|
Ok(self)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- pub fn with_locus_at(mut self, at: (String, i32)) -> anyhow::Result<Self> {
|
|
|
|
|
|
|
+ pub fn with_locus_at(
|
|
|
|
|
+ mut self,
|
|
|
|
|
+ (contig, position): (&str, u32),
|
|
|
|
|
+ plus_minus: u32,
|
|
|
|
|
+ ) -> anyhow::Result<Self> {
|
|
|
*self
|
|
*self
|
|
|
.value
|
|
.value
|
|
|
.get_mut("locus")
|
|
.get_mut("locus")
|
|
|
- .context("Can't access locus value")? =
|
|
|
|
|
- json!(format!("{}:{}-{}", at.0, at.1 - 19, at.1 + 19));
|
|
|
|
|
|
|
+ .context("Can't access locus value")? = json!(format!(
|
|
|
|
|
+ "{}:{}-{}",
|
|
|
|
|
+ contig,
|
|
|
|
|
+ position.saturating_sub(plus_minus),
|
|
|
|
|
+ position + plus_minus
|
|
|
|
|
+ ));
|
|
|
Ok(self)
|
|
Ok(self)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -337,7 +345,7 @@ mod tests {
|
|
|
fn it_works() -> anyhow::Result<()> {
|
|
fn it_works() -> anyhow::Result<()> {
|
|
|
let sess = Session::default()
|
|
let sess = Session::default()
|
|
|
.with_reference(ReferenceValues::default())
|
|
.with_reference(ReferenceValues::default())
|
|
|
- .with_locus_at(("chr1".to_string(), 47_098_189))?
|
|
|
|
|
|
|
+ .with_locus_at(("chr1", 47_098_189), 33)?
|
|
|
.add_track(Track::Bam(BamTrack::new(
|
|
.add_track(Track::Bam(BamTrack::new(
|
|
|
"ROBIN diag",
|
|
"ROBIN diag",
|
|
|
"/data/longreads_basic_pipe/ROBIN/diag/ROBIN_diag_hs1.bam",
|
|
"/data/longreads_basic_pipe/ROBIN/diag/ROBIN_diag_hs1.bam",
|
|
@@ -352,8 +360,35 @@ mod tests {
|
|
|
)))?
|
|
)))?
|
|
|
.add_track(Track::Genes(GenesTrack::new(
|
|
.add_track(Track::Genes(GenesTrack::new(
|
|
|
"/data/ref/hs1/chm13v2.0_RefSeq_Liftoff_v5.1_sorted.gff3.gz",
|
|
"/data/ref/hs1/chm13v2.0_RefSeq_Liftoff_v5.1_sorted.gff3.gz",
|
|
|
- )))?
|
|
|
|
|
- ;
|
|
|
|
|
|
|
+ )))?;
|
|
|
|
|
+ let compressed_str = sess.link("http://store-desktop.local/igv/")?;
|
|
|
|
|
+ println!("{compressed_str}");
|
|
|
|
|
+ Ok(())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ #[test]
|
|
|
|
|
+ fn denovo_link() -> anyhow::Result<()> {
|
|
|
|
|
+ let id = "ACHITE";
|
|
|
|
|
+ let chr = "chr1";
|
|
|
|
|
+ let alt_id = "47108362-81682505_8090_wtdbg2";
|
|
|
|
|
+ let alt_prefix = format!("/data/longreads_basic_pipe/{id}/diag/assemblies/{chr}/{alt_id}");
|
|
|
|
|
+
|
|
|
|
|
+ let reference = ReferenceValues {
|
|
|
|
|
+ id: "contig".to_string(),
|
|
|
|
|
+ name: "de novo".to_owned(),
|
|
|
|
|
+ fasta_url: format!("{alt_prefix}.fa"),
|
|
|
|
|
+ index_url: format!("{alt_prefix}.fa.fai"),
|
|
|
|
|
+ cytoband_url: "".to_string(),
|
|
|
|
|
+ alias_url: "".to_owned(),
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ let sess = Session::default()
|
|
|
|
|
+ .with_reference(reference)
|
|
|
|
|
+ .with_locus_at((alt_id, 100), 19)?
|
|
|
|
|
+ .add_track(Track::Bam(BamTrack::new(
|
|
|
|
|
+ "On contig",
|
|
|
|
|
+ &format!("{alt_prefix}.bam"),
|
|
|
|
|
+ )))?;
|
|
|
let compressed_str = sess.link("http://store-desktop.local/igv/")?;
|
|
let compressed_str = sess.link("http://store-desktop.local/igv/")?;
|
|
|
println!("{compressed_str}");
|
|
println!("{compressed_str}");
|
|
|
Ok(())
|
|
Ok(())
|