Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower mem usage #55

Merged
merged 7 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

commit_re="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-zA-Z 0-9 \-_]+\))?!?: .+$"
commit_message=$(cat "$1")

if [[ "$commit_message" =~ $commit_re ]]; then
exit 0
fi

echo "The commit message does not meet the Conventional Commit standard."
echo "An example of a valid message is: "
echo " feat(login): add the 'remember me' button"
echo "Details: https://www.conventionalcommits.org/en/v1.0.0/#summary"
exit 1
81 changes: 81 additions & 0 deletions releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
##### Semantic Release Configuration #####
branches:
- master
- name: dev
channel: prerelease
prerelease: prerelease
# ci: true # Set via CLI arg: --ci | --no-ci
# debug: false # Set via CLI arg: --debug
# dryRun: false # Set via CLI arg: --dry-run
# repositoryUrl: "" # Not needed, will use git origin
tagFormat: "v${version}"

# Global plugin options (passed to all plugins)
preset: 'angular'

### Plugin Setup ###

plugins:
- "@semantic-release/exec"
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/changelog"
- "@semantic-release/git"
# - "@saithodev/semantic-release-backmerge"

# 1. Verify conditions necessary to proceed with the release
verifyConditions:
- path: '@semantic-release/changelog'
- path: '@semantic-release/git'

# 2. Determine the type of the next release (major, minor or patch)
analyzeCommits:
- path: '@semantic-release/commit-analyzer'

# 3. Verify the parameters (version, type, dist-tag etc...) of the release
verifyRelease:
- path: '@semantic-release/exec'
cmd: "echo ${nextRelease.version} > VERSION.txt && echo ${lastRelease.version} > LAST_VERSION.txt"

# 4. Generate the content of the release notes
generateNotes:
- path: '@semantic-release/release-notes-generator'

# 5. Prepare the release, e.g. create or update files such as package.json, CHANGELOG.md etc
prepare:
- path: "@semantic-release/changelog"
changelogFile: CHANGELOG.md
changelogTitle: "# Change Log"
- path: "@semantic-release/git"
assets:
- CHANGELOG.md
message: |-
chore(release): ${nextRelease.version} [skip ci]

${lastRelease.notes}
- path: '@semantic-release/exec'
cmd: "git status && git add . && git stash --all"

# 6. Publish the release
# publish:

# 7. Add a release channel
# addChannel:

# 8. Notify of a new release
# success:

# 9. Notify of a failed release
# fail:

# Other
# done:
# - path: '@saithodev/semantic-release-backmerge'
# branches:
# - from: master
# to: develop
# backmergeStrategy: merge # Allowed: rebase (default) | merge
# mergeMode: theirs # Allowed: none (default) | ours | theirs
# message: 'chore(backmerge): Prepare for next release [skip ci]'

2 changes: 1 addition & 1 deletion src/abundance/abundance_calculator_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'a> AbundanceCalculatorEngine<'a> {
let mut total_depth = vc.genotypes.genotypes()[sample_index]
.ad
.iter()
.sum::<i64>()
.sum::<i32>()
as f64;

// catch sample where no mapping occured at this location
Expand Down
16 changes: 8 additions & 8 deletions src/activity_profile/activity_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl Profile for ActivityProfile {
}
}
}
debug!("Soft clips added {}", states.len());
// debug!("Soft clips added {}", states.len());
return states;
}
ActivityProfileDataType::None => {
Expand Down Expand Up @@ -392,7 +392,7 @@ impl Profile for ActivityProfile {
};
// let force_conversion = false;

debug!("Force conversion {}", force_conversion);
// debug!("Force conversion {}", force_conversion);
let next_region = self.pop_next_ready_assembly_region(
assembly_region_extension,
min_region_size,
Expand All @@ -403,7 +403,7 @@ impl Profile for ActivityProfile {
match next_region {
Some(region) => {
region_start = Some(region.active_span.start);
debug!("Next region {:?}", &region.active_span);
// debug!("Next region {:?}", &region.active_span);
regions.push(region);
}
None => return regions,
Expand Down Expand Up @@ -474,7 +474,7 @@ impl Profile for ActivityProfile {
force_conversion,
);

debug!("Offset {:?}", &offset_of_next_region_end);
// debug!("Offset {:?}", &offset_of_next_region_end);
match offset_of_next_region_end {
Some(offset_of_next_region_end) => {
// we need to create the active region, and clip out the states we're extracting from this profile
Expand Down Expand Up @@ -507,7 +507,7 @@ impl Profile for ActivityProfile {
// divide this density count by the length
let activity_density = activity_density as f32 / region_loc.size() as f32;

debug!("regionLoc {:?}: activity density {}", &region_loc, activity_density);
// debug!("regionLoc {:?}: activity density {}", &region_loc, activity_density);
return Some(AssemblyRegion::new(
region_loc,
is_active_region,
Expand Down Expand Up @@ -559,10 +559,10 @@ impl Profile for ActivityProfile {

let mut end_of_active_region =
self.find_first_activity_boundary(is_active_region, max_region_size);
debug!("Find end 1 {}", end_of_active_region);
// debug!("Find end 1 {}", end_of_active_region);
if is_active_region && (end_of_active_region == max_region_size) {
end_of_active_region = self.find_best_cut_site(end_of_active_region, min_region_size);
debug!("Find end 2 {}", end_of_active_region);
// debug!("Find end 2 {}", end_of_active_region);
}

return end_of_active_region.checked_sub(1);
Expand Down Expand Up @@ -631,7 +631,7 @@ impl Profile for ActivityProfile {
if (self.get_prob(end_of_active_region) > self.active_prob_threshold)
!= is_active_region
{
debug!("Active {}", self.get_prob(end_of_active_region));
// debug!("Active {}", self.get_prob(end_of_active_region));
break;
}
end_of_active_region += 1;
Expand Down
46 changes: 23 additions & 23 deletions src/ani_calculator/ani_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ use crate::model::variant_context_utils::VariantContextUtils;
/// Since lorikeet calls Indels, we compare the length of the allele rather than just the position
/// So the rather than alleles different, it is bases different.
pub struct ANICalculator {
popANI: Array2<f64>,
subpopANI: Array2<f64>,
conANI: Array2<f64>,
popANI: Array2<f32>,
subpopANI: Array2<f32>,
conANI: Array2<f32>,
// fst: Array2<f64>
}

Expand All @@ -59,14 +59,15 @@ impl ANICalculator {
sample_names: &[&str],
reference_name: &str,
genome_size: u64,
passing_sites: Option<Vec<Vec<i32>>>,
compared_bases: Option<Array2<f32>>,
qual_by_depth_filter: f64,
qual_threshold: f64,
depth_per_sample_filter: i64,
) {
let compared_bases =
self.calculate_compared_bases(passing_sites, genome_size, sample_names.len());

let compared_bases = match compared_bases {
Some(compared_bases) => compared_bases,
None => Self::calculate_compared_bases(None, genome_size, sample_names.len()),
};
// debug!("Comparable bases \n{:?}", &compared_bases);
self.calculate_from_contexts(
contexts,
Expand Down Expand Up @@ -100,12 +101,11 @@ impl ANICalculator {
);
}

fn calculate_compared_bases(
&mut self,
pub fn calculate_compared_bases(
passing_sites: Option<Vec<Vec<i32>>>,
genome_size: u64,
n_samples: usize,
) -> Array2<f64> {
) -> Array2<f32> {
let mut compared_bases = Array2::default((n_samples, n_samples));
match passing_sites {
Some(passing_sites) => {
Expand Down Expand Up @@ -151,19 +151,19 @@ impl ANICalculator {
}
}

let comparable_bases = (genome_size - differing_bases as u64) as f64;
let comparable_bases = (genome_size - differing_bases as u64) as f32;
compared_bases[[s1_ind, s2_ind]] = comparable_bases;
compared_bases[[s2_ind, s1_ind]] = comparable_bases;
}
let comparable_bases_to_ref = (genome_size as i32
+ s1.into_iter().filter(|x| x.is_negative()).sum::<i32>())
as f64;
as f32;
compared_bases[[s1_ind, s1_ind]] = comparable_bases_to_ref;
}
}
_ => {
compared_bases.iter_mut().for_each(|val| {
*val = genome_size as f64;
*val = genome_size as f32;
});
}
}
Expand All @@ -180,7 +180,7 @@ impl ANICalculator {
qual_by_depth_filter: f64,
qual_threshold: f64,
depth_per_sample_filter: i64,
compared_bases: Array2<f64>,
compared_bases: Array2<f32>,
) {
let n_samples = self.conANI.ncols();

Expand Down Expand Up @@ -209,7 +209,7 @@ impl ANICalculator {
);
// which alleles are present in first sample
let which_are_present =
context.alleles_present_in_sample(sample_idx_1, depth_per_sample_filter);
context.alleles_present_in_sample(sample_idx_1, depth_per_sample_filter as i32);

present_alleles.push(which_are_present);
}
Expand All @@ -228,7 +228,7 @@ impl ANICalculator {
);
// which alleles are present in first sample with at least two supporting reads
let which_are_present = context
.alleles_present_in_sample(sample_idx_2, depth_per_sample_filter);
.alleles_present_in_sample(sample_idx_2, depth_per_sample_filter as i32);
present_alleles.push(which_are_present);
}

Expand All @@ -247,8 +247,8 @@ impl ANICalculator {
if context.alleles[*consensus_1].len() > 1
|| context.alleles[*consensus_2].len() > 1
{
let bases_different = (context.alleles[*consensus_1].len() as f64
- context.alleles[*consensus_2].len() as f64)
let bases_different = (context.alleles[*consensus_1].len() as f32
- context.alleles[*consensus_2].len() as f32)
.abs();
self.conANI[[sample_idx_1, sample_idx_2]] += bases_different;
self.conANI[[sample_idx_2, sample_idx_1]] += bases_different;
Expand All @@ -266,7 +266,7 @@ impl ANICalculator {
.enumerate()
{
if present_1 != present_2 {
bases_different += context.alleles[idx].len() as f64;
bases_different += context.alleles[idx].len() as f32;
divisor += 1.0;
}
}
Expand Down Expand Up @@ -297,8 +297,8 @@ impl ANICalculator {
if context.alleles[*consensus_1].len() > 1
|| context.alleles[0].len() > 1
{
let bases_different = (context.alleles[*consensus_1].len() as f64
- context.alleles[0].len() as f64)
let bases_different = (context.alleles[*consensus_1].len() as f32
- context.alleles[0].len() as f32)
.abs();
self.conANI[[sample_idx_1, sample_idx_2]] += bases_different;
} else {
Expand All @@ -312,7 +312,7 @@ impl ANICalculator {
let mut divisor = 0.0;
for (idx, present) in allele_present_1.iter().enumerate() {
if *present {
bases_different += context.alleles[idx].len() as f64;
bases_different += context.alleles[idx].len() as f32;
divisor += 1.0;
}
}
Expand Down Expand Up @@ -354,7 +354,7 @@ impl ANICalculator {
output_prefix: &str,
sample_names: &[&str],
reference_name: &str,
table: &Array2<f64>,
table: &Array2<f32>,
table_name: &str,
) {
// debug!("Printing ani calculations {}", reference_name);
Expand Down
10 changes: 5 additions & 5 deletions src/annotator/variant_annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl VariantAnnotations {
annotation_type,
);
};
let total_ad: i64 = genotype.ad.iter().sum();
let total_ad: i32 = genotype.ad.iter().sum();
genotype.dp = total_ad;
return AttributeObject::None;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ impl VariantAnnotations {
pub fn get_depth<A: Allele>(
genotypes: &mut GenotypesContext,
likelihoods: &AlleleLikelihoods<A>,
) -> i64 {
) -> i32 {
let mut depth = 0;
let mut AD_restrict_depth = 0;

Expand All @@ -378,7 +378,7 @@ impl VariantAnnotations {

// if we have the AD values for this sample, let's make sure that the variant depth is greater than 1!
if genotype.has_ad() {
let total_ad: i64 = genotype.ad.iter().sum();
let total_ad: i32 = genotype.ad.iter().sum();
genotype.dp = total_ad;
if total_ad != 0 {
if total_ad - genotype.ad[0] > 0 {
Expand All @@ -390,8 +390,8 @@ impl VariantAnnotations {
}

// if there is no AD value or it is a dummy value, we want to look to other means to get the depth
if let Some(sample_index) = likelihoods.index_of_sample(&genotype.sample_name) {
depth += likelihoods.sample_evidence_count(sample_index) as i64;
if let Some(sample_index) = likelihoods.index_of_sample(genotype.sample_name) {
depth += likelihoods.sample_evidence_count(sample_index) as i32;
} else if genotype.has_dp() {
depth += genotype.dp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/assembly/assembly_based_caller_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl AssemblyBasedCallerUtils {
) -> HashMap<ReadIndexer, BirdToolRead> {
let best_alleles = original_read_likelihoods
.best_alleles_breaking_ties_main(Self::haplotype_alignment_tiebreaking_priority());
debug!("Best alleles {:?}", best_alleles.iter().map(|x| x.allele_index).collect::<Vec<_>>());
// debug!("Best alleles {:?}", best_alleles.iter().map(|x| x.allele_index).collect::<Vec<_>>());
return best_alleles
.iter()
.map(|best_allele| {
Expand Down
Loading