Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
claymcleod committed Jan 3, 2025
1 parent b3c68f7 commit 638fd27
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/comparison.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Compare

on:
push:
branches:
- main
pull_request:

jobs:
crossmap:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: chainfiles
key: ${{ runner.os }}-chainfiles
- name: Update Rust
run: rustup update stable && rustup default stable
- name: Install CrossMap
run: pip install CrossMap
- uses: Swatinem/rust-cache@v2
with:
workspaces: .
- run: |
mkdir -p chainfiles
cargo run --release --features=binaries -- -d chainfiles hg19ToHg38 -v
30 changes: 15 additions & 15 deletions src/bin/kitchen_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@ impl std::fmt::Display for LiftoverResult {
// CrossMap execution
////////////////////////////////////////////////////////////////////////////////////////

/// A struct for working with `crossmap`.
/// A struct for working with `CrossMap`.
struct CrossMap;

impl CrossMap {
/// Ensures the `crossmap` is installed.
/// Ensures the `CrossMap` is installed.
fn ensure_installed() -> Result<()> {
Command::new("crossmap")
Command::new("CrossMap")
.arg("--version")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.status()
.context("retrieving `crossmap`'s version")
.context("retrieving `CrossMap`'s version")
.map(|_| ())
}

Expand Down Expand Up @@ -181,7 +181,7 @@ impl CrossMap {
let stderr = String::from_utf8_lossy(&output.stderr);
for line in stderr.lines() {
if !line.contains("[INFO]") {
panic!("`crossmap` returned something on stderr: {stderr}");
panic!("`CrossMap` returned something on stderr: {stderr}");
}
}
}
Expand All @@ -193,7 +193,7 @@ impl CrossMap {
let parts = line.split("\t").collect::<Vec<_>>();
assert!(
parts.len() > 3,
"should always have at least four parts of a `crossmap` result line; found \
"should always have at least four parts of a `CrossMap` result line; found \
`{line}`"
);

Expand Down Expand Up @@ -221,7 +221,7 @@ impl CrossMap {

LiftoverResult::Mapped(to)
}
_ => unreachable!("cannot parse `crossmap` result: `{line}`"),
_ => unreachable!("cannot parse `CrossMap` result: `{line}`"),
};

results.insert(from, to);
Expand Down Expand Up @@ -333,7 +333,7 @@ impl WorkDirectory {
self.0.join("reference")
}

/// The input positions bed file to `crossmap`.
/// The input positions bed file to `CrossMap`.
fn input_bed_file(&self) -> PathBuf {
self.0.join("input.bed")
}
Expand Down Expand Up @@ -389,10 +389,10 @@ impl Deref for WorkDirectory {
}

////////////////////////////////////////////////////////////////////////////////////////
// Comparsion between `chainfile` and `crossmap`
// Comparsion between `chainfile` and`CrossMap`
////////////////////////////////////////////////////////////////////////////////////////

/// A comparison of liftover results between `chainfile` and `crossmap`.
/// A comparison of liftover results between `chainfile` and `CrossMap`.
#[derive(Clone, Debug)]
struct Comparison {
/// The original position.
Expand All @@ -401,7 +401,7 @@ struct Comparison {
/// The lifted position from `chainfile`.
chainfile: LiftoverResult,

/// The lifted position from `crossmap`.
/// The lifted position from `CrossMap`.
crossmap: LiftoverResult,
}

Expand Down Expand Up @@ -475,8 +475,8 @@ fn throw(args: &Args) -> Result<()> {

info!("working directory: {}", work_dir.display());

info!("crossmap: ensuring `crossmap` is installed");
CrossMap::ensure_installed().context("ensuring `crossmap` is installed")?;
info!("crossmap: ensuring `CrossMap` is installed");
CrossMap::ensure_installed().context("ensuring `CrossMap` is installed")?;

let chain_file_path = work_dir
.download_chain_file(&args.chain)
Expand Down Expand Up @@ -510,7 +510,7 @@ fn throw(args: &Args) -> Result<()> {

info!("crossmap: running liftover");
for (from, crossmap_result) in CrossMap::run_bed(&chain_file_path, &work_dir.input_bed_file())
.context("getting the `crossmap` mappings")?
.context("getting the `CrossMap` mappings")?
{
let start =
Coordinate::<Interbase>::new(from.contig.as_str(), Strand::Positive, from.start);
Expand Down Expand Up @@ -570,7 +570,7 @@ fn throw(args: &Args) -> Result<()> {
let matched_percent = (n_matches as f64 * 100.0) / total_comparisons as f64;

println!(
"`chainfile` and `crossmap` matched in {matched_percent:.2}% of cases (n = {})",
"`chainfile` and `CrossMap` matched in {matched_percent:.2}% of cases (n = {})",
total_comparisons
);

Expand Down

0 comments on commit 638fd27

Please sign in to comment.