Skip to content

Commit

Permalink
test v0.1.3
Browse files Browse the repository at this point in the history
fix bugs related to boolean values for CLI
  • Loading branch information
andyjslee committed Jan 31, 2024
1 parent f7eb9dc commit d1daedf
Show file tree
Hide file tree
Showing 23 changed files with 3,410 additions and 3,332 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vstolib"
version = "0.1.2"
version = "0.1.3"
edition = "2021"

[package.metadata.maturin]
Expand Down
396 changes: 198 additions & 198 deletions examples/outputs/hg002_cutesv.tsv

Large diffs are not rendered by default.

732 changes: 366 additions & 366 deletions examples/outputs/hg002_intersecting_variants.tsv

Large diffs are not rendered by default.

2,008 changes: 1,004 additions & 1,004 deletions examples/outputs/hg002_merged_variants.tsv

Large diffs are not rendered by default.

554 changes: 277 additions & 277 deletions examples/outputs/hg002_merged_variants_passed.tsv

Large diffs are not rendered by default.

104 changes: 52 additions & 52 deletions examples/outputs/hg002_merged_variants_private.tsv

Large diffs are not rendered by default.

1,316 changes: 658 additions & 658 deletions examples/outputs/hg002_merged_variants_rejected.tsv

Large diffs are not rendered by default.

382 changes: 191 additions & 191 deletions examples/outputs/hg002_sniffles2.tsv

Large diffs are not rendered by default.

386 changes: 193 additions & 193 deletions examples/outputs/hg002_sniffles2_ensembl_annotated.tsv

Large diffs are not rendered by default.

386 changes: 193 additions & 193 deletions examples/outputs/hg002_sniffles2_gencode_annotated.tsv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/outputs/hg002_sniffles2_overlap.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
variant_id variant_call_id sample_id chromosome_1 position_1 chromosome_2 position_2 variant_type reference_allele alternate_allele source_id phase_block_id clone_id nucleic_acid variant_calling_method sequencing_platform filter quality_score precise variant_subtype variant_size reference_allele_read_count alternate_allele_read_count total_read_count alternate_allele_fraction alternate_allele_read_ids variant_sequences tags attributes position_1_annotation_annotator position_1_annotation_annotator_version position_1_annotation_gene_id position_1_annotation_gene_id_stable position_1_annotation_gene_name position_1_annotation_gene_strand position_1_annotation_gene_type position_1_annotation_gene_version position_1_annotation_region position_1_annotation_species position_2_annotation_annotator position_2_annotation_annotator_version position_2_annotation_gene_id position_2_annotation_gene_id_stable position_2_annotation_gene_name position_2_annotation_gene_strand position_2_annotation_gene_type position_2_annotation_gene_version position_2_annotation_region position_2_annotation_species
1 HG002_dna_sniffles2_INS_1_chr1:10863_chr1:10863 HG002 chr1 10863 chr1 10863 INS N CAGGCGCAGAGACACATGCTAGCGCGTCCAGGGGAGGAGGCGTGGCA hg002 dna sniffles2 PACBIO PASS 45.0 True 48 5 8 13 0.615 m64011_190901_095311/23725469/ccs;m64011_190830_220126/131269927/ccs;m64012_190921_234837/125634487/ccs;m64012_190921_234837/58460920/ccs;m64011_190901_095311/150538373/ccs;m64011_190830_220126/102304431/ccs;m64011_190901_095311/166070209/ccs;m64011_190830_220126/70254798/ccs CAGGCGCAGAGACACATGCTAGCGCGTCCAGGGGAGGAGGCGTGGCA ID=Sniffles2.INS.5S0;PRECISE=True;SVTYPE=INS;SVLEN=48;END=10863;SUPPORT=8;RNAMES=m64011_190901_095311/166070209/ccs,m64012_190921_234837/125634487/ccs,m64011_190830_220126/70254798/ccs,m64011_190901_095311/150538373/ccs,m64011_190830_220126/102304431/ccs,m64012_190921_234837/58460920/ccs,m64011_190830_220126/131269927/ccs,m64011_190901_095311/23725469/ccs;COVERAGE=11,12,13,13,13;STRAND=-;AF=0.615;STDEV_LEN=14.341;STDEV_POS=0.0;SUPPORT_LONG=0;GT=0/1;GQ=27;DR=5;DV=8
1 HG002_dna_sniffles2_INS_1_chr1:10863_chr1:10863 HG002 chr1 10863 chr1 10863 INS N CAGGCGCAGAGACACATGCTAGCGCGTCCAGGGGAGGAGGCGTGGCA hg002 dna sniffles2 PACBIO PASS 45.0 True 48 5 8 13 0.615 m64012_190921_234837/58460920/ccs;m64011_190830_220126/131269927/ccs;m64012_190921_234837/125634487/ccs;m64011_190830_220126/102304431/ccs;m64011_190901_095311/166070209/ccs;m64011_190830_220126/70254798/ccs;m64011_190901_095311/23725469/ccs;m64011_190901_095311/150538373/ccs CAGGCGCAGAGACACATGCTAGCGCGTCCAGGGGAGGAGGCGTGGCA ID=Sniffles2.INS.5S0;PRECISE=True;SVTYPE=INS;SVLEN=48;END=10863;SUPPORT=8;RNAMES=m64011_190901_095311/166070209/ccs,m64012_190921_234837/125634487/ccs,m64011_190830_220126/70254798/ccs,m64011_190901_095311/150538373/ccs,m64011_190830_220126/102304431/ccs,m64012_190921_234837/58460920/ccs,m64011_190830_220126/131269927/ccs,m64011_190901_095311/23725469/ccs;COVERAGE=11,12,13,13,13;STRAND=-;AF=0.615;STDEV_LEN=14.341;STDEV_POS=0.0;SUPPORT_LONG=0;GT=0/1;GQ=27;DR=5;DV=8
2 HG002_dna_sniffles2_INS_2_chr1:10863_chr1:10863 HG002 chr1 10863 chr1 10863 INS N CAGGCGCAGAGAGGCGCGCCGCGCCGGCGCAGGCGCAGAGAGGCGCGCCGCGCCGGCGCAGGCGCAGAGAGGCGCGCCGGGCCGGCGCAGGCGCAGAGACACATGCTAGCGCGTCCAGGGGAGGAGGCGTGGCA hg002 dna sniffles2 PACBIO PASS 51.0 True 134 8 5 13 0.385 m64011_190901_095311/14353347/ccs;m64011_190901_095311/142478143/ccs;m64011_190830_220126/95815702/ccs;m64011_190901_095311/177932654/ccs;m64011_190901_095311/101253601/ccs CAGGCGCAGAGAGGCGCGCCGCGCCGGCGCAGGCGCAGAGAGGCGCGCCGCGCCGGCGCAGGCGCAGAGAGGCGCGCCGGGCCGGCGCAGGCGCAGAGACACATGCTAGCGCGTCCAGGGGAGGAGGCGTGGCA ID=Sniffles2.INS.6S0;PRECISE=True;SVTYPE=INS;SVLEN=134;END=10863;SUPPORT=5;RNAMES=m64011_190901_095311/177932654/ccs,m64011_190901_095311/101253601/ccs,m64011_190901_095311/14353347/ccs,m64011_190901_095311/142478143/ccs,m64011_190830_220126/95815702/ccs;COVERAGE=11,12,13,13,13;STRAND=+-;AF=0.385;STDEV_LEN=0.0;STDEV_POS=0.0;SUPPORT_LONG=0;GT=0/1;GQ=27;DR=8;DV=5
104 changes: 52 additions & 52 deletions examples/outputs/hg002_sniffles2_private.tsv

Large diffs are not rendered by default.

230 changes: 115 additions & 115 deletions examples/outputs/hg002_svim.tsv

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions examples/run_vstol_diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ vstol diff \
--query-tsv-file ../test/data/hg002_cutesv.tsv \
--num-threads 1 \
--max-neighbor-distance 10 \
--match-all-breakpoints no \
--match-variant-types no \
--output-tsv-file outputs/hg002_sniffles2_private.tsv

vstol diff \
Expand All @@ -14,4 +16,6 @@ vstol diff \
--query-tsv-file ../test/data/hg002_cutesv.tsv \
--num-threads 1 \
--max-neighbor-distance 10 \
--match-all-breakpoints no \
--match-variant-types no \
--output-tsv-file outputs/hg002_merged_variants_private.tsv
2 changes: 2 additions & 0 deletions examples/run_vstol_intersect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ vstol intersect \
--tsv-file ../test/data/hg002_svim.tsv \
--num-threads 4 \
--max-neighbor-distance 10 \
--match-all-breakpoints yes \
--match-variant-types yes \
--output-tsv-file outputs/hg002_intersecting_variants.tsv

2 changes: 2 additions & 0 deletions examples/run_vstol_merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ vstol merge \
--tsv-file ../test/data/hg002_svim.tsv \
--num-threads 4 \
--max-neighbor-distance 10 \
--match-all-breakpoints yes \
--match-variant-types yes \
--output-tsv-file outputs/hg002_merged_variants.tsv

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build-backend = "maturin"

[project]
name = "vstol"
version = "0.1.2"
version = "0.1.3"
requires-python = ">=3.10"
keywords = [
"somatic variants",
Expand Down
17 changes: 10 additions & 7 deletions python/vstolib/cli/cli_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ..default import *
from ..logging import get_logger
from ..main import diff
from ..utilities import str2bool
from ..variants_list import VariantsList


Expand Down Expand Up @@ -99,23 +100,25 @@ def add_cli_diff_arg_parser(
parser_optional.add_argument(
"--match-all-breakpoints", '-b',
dest="match_all_breakpoints",
type=bool,
type=str2bool,
required=False,
default=DIFF_MATCH_ALL_BREAKPOINTS,
help="If true, two VariantCall objects are considered an intersect "
help="If 'yes', two VariantCall objects are considered an intersect "
"if both pairs of breakpoints match (start1==start2 AND end1==end2). "
"If false, two VariantCall objects are considered an intersect "
"if one of the breakpoint pairs matches (start1==start2 OR end1==end2). Default: %r."
"If 'no', two VariantCall objects are considered an intersect "
"if one of the breakpoint pairs matches (start1==start2 OR end1==end2). Default: %s"
% DIFF_MATCH_ALL_BREAKPOINTS
)
parser_optional.add_argument(
"--match-variant-types", '-m',
dest="match_variant_types",
type=bool,
type=str2bool,
required=False,
default=DIFF_MATCH_VARIANT_TYPES,
help="If true, two VariantCall objects are considered an intersect "
"if the (super) variant types are the same (default: %r)."
help="If 'yes', two VariantCall objects are considered an intersect "
"if the (super) variant types are the same. "
"If 'no', two VariantCall objects are considered an intersect "
"even if the (super) variant types are different (default: %s)."
% DIFF_MATCH_VARIANT_TYPES
)
parser.set_defaults(which='diff')
Expand Down
17 changes: 10 additions & 7 deletions python/vstolib/cli/cli_intersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ..default import *
from ..logging import get_logger
from ..main import intersect
from ..utilities import str2bool
from ..variants_list import VariantsList


Expand Down Expand Up @@ -91,23 +92,25 @@ def add_cli_intersect_arg_parser(
parser_optional.add_argument(
"--match-all-breakpoints", '-b',
dest="match_all_breakpoints",
type=bool,
type=str2bool,
required=False,
default=INTERSECT_MATCH_ALL_BREAKPOINTS,
help="If true, two VariantCall objects are considered an intersect "
help="If 'yes', two VariantCall objects are considered an intersect "
"if both pairs of breakpoints match (start1==start2 AND end1==end2). "
"If false, two VariantCall objects are considered an intersect "
"if one of the breakpoint pairs matches (start1==start2 OR end1==end2). Default: %r."
"If 'no', two VariantCall objects are considered an intersect "
"if one of the breakpoint pairs matches (start1==start2 OR end1==end2). Default: %s"
% INTERSECT_MATCH_ALL_BREAKPOINTS
)
parser_optional.add_argument(
"--match-variant-types", '-m',
dest="match_variant_types",
type=bool,
type=str2bool,
required=False,
default=INTERSECT_MATCH_VARIANT_TYPES,
help="If true, two VariantCall objects are considered an intersect "
"if the (super) variant types are the same (default: %r)."
help="If 'yes', two VariantCall objects are considered an intersect "
"if the (super) variant types are the same. "
"If 'no', two VariantCall objects are considered an intersect "
"even if the (super) variant types are different (default: %s)."
% INTERSECT_MATCH_VARIANT_TYPES
)
parser.set_defaults(which='intersect')
Expand Down
21 changes: 13 additions & 8 deletions python/vstolib/cli/cli_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ..default import *
from ..logging import get_logger
from ..main import merge
from ..utilities import str2bool
from ..variants_list import VariantsList


Expand Down Expand Up @@ -88,23 +89,27 @@ def add_cli_merge_arg_parser(
% MERGE_MAX_NEIGHBOR_DISTANCE
)
parser_optional.add_argument(
"--match-all-breakpoints", '-m',
"--match-all-breakpoints", '-b',
dest="match_all_breakpoints",
type=bool,
type=str2bool,
required=False,
default=MERGE_MATCH_ALL_BREAKPOINTS,
help="If true, for two VariantCall objects to be considered "
"intersecting, all breakpoints must match or be near each other (default: %r)."
help="If 'yes', two VariantCall objects are considered an intersect "
"if both pairs of breakpoints match (start1==start2 AND end1==end2). "
"If 'no', two VariantCall objects are considered an intersect "
"if one of the breakpoint pairs matches (start1==start2 OR end1==end2). Default: %s"
% MERGE_MATCH_ALL_BREAKPOINTS
)
parser_optional.add_argument(
"--match-variant-types", '-a',
"--match-variant-types", '-m',
dest="match_variant_types",
type=bool,
type=str2bool,
required=False,
default=MERGE_MATCH_VARIANT_TYPES,
help="If true, for two VariantCall objects to be considered "
"intersecting, the variant types must be the same (default: %r)."
help="If 'yes', two VariantCall objects are considered an intersect "
"if the (super) variant types are the same. "
"If 'no', two VariantCall objects are considered an intersect "
"even if the (super) variant types are different (default: %s)."
% MERGE_MATCH_VARIANT_TYPES
)
parser.set_defaults(which='merge')
Expand Down
12 changes: 6 additions & 6 deletions python/vstolib/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

"""diff"""
DIFF_MAX_NEIGHBOR_DISTANCE = 1000
DIFF_MATCH_ALL_BREAKPOINTS = False
DIFF_MATCH_VARIANT_TYPES = False
DIFF_MATCH_ALL_BREAKPOINTS = 'no'
DIFF_MATCH_VARIANT_TYPES = 'no'


"""filter"""
Expand All @@ -53,16 +53,16 @@
"""intersect"""
# Maximum neighbor distance (bases).
INTERSECT_MAX_NEIGHBOR_DISTANCE = 10
INTERSECT_MATCH_ALL_BREAKPOINTS = True
INTERSECT_MATCH_VARIANT_TYPES = True
INTERSECT_MATCH_ALL_BREAKPOINTS = 'yes'
INTERSECT_MATCH_VARIANT_TYPES = 'yes'



"""merge"""
# Maximum neighbor distance (bases).
MERGE_MAX_NEIGHBOR_DISTANCE = 10
MERGE_MATCH_ALL_BREAKPOINTS = True
MERGE_MATCH_VARIANT_TYPES = True
MERGE_MATCH_ALL_BREAKPOINTS = 'yes'
MERGE_MATCH_VARIANT_TYPES = 'yes'


"""overlap"""
Expand Down
11 changes: 11 additions & 0 deletions python/vstolib/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def retrieve_from_dict(
default_value=default_value,
type=type)


def retrieve_from_list(
lst: list,
index: int,
Expand All @@ -164,3 +165,13 @@ def retrieve_from_list(
return get_typed_value(value=value,
default_value=default_value,
type=type)


def str2bool(v):
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise Exception('Boolean value expected.')

52 changes: 50 additions & 2 deletions test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from vstolib.constants import VariantTypes


def test_diff_sniffles2_variants_list(
def test_diff_1(
sniffles2_variants_list,
cutesv_variants_list,
pbsv_variants_list,
Expand All @@ -24,7 +24,7 @@ def test_diff_sniffles2_variants_list(
)


def test_diff_bnd():
def test_diff_2():
variant_call_11 = VariantCall(
id='variant_call_11',
sample_id='sample1',
Expand Down Expand Up @@ -128,3 +128,51 @@ def test_diff_bnd():
assert 'variant_call_12' in variants_list.variant_call_ids
assert 'variant_call_13' in variants_list.variant_call_ids
assert 'variant_call_14' not in variants_list.variant_call_ids


def test_diff_3():
variant_call_11 = VariantCall(
id='variant_call_11',
sample_id='sample1',
chromosome_1='chr1',
position_1=100,
chromosome_2='chr5',
position_2=500,
variant_type=VariantTypes.TRANSLOCATION,
reference_allele='T',
alternate_allele=''
)

variant_call_21 = VariantCall(
id='variant_call_21',
sample_id='sample2',
chromosome_1='chr1',
position_1=101,
chromosome_2='chr1',
position_2=101,
variant_type=VariantTypes.INSERTION,
reference_allele='C',
alternate_allele='CTACTACTGGT'
)

variant_11 = Variant(id='variant_11')
variant_21 = Variant(id='variant_21')
variant_11.add_variant_call(variant_call=variant_call_11)
variant_21.add_variant_call(variant_call=variant_call_21)

variants_list_1 = VariantsList()
variants_list_2 = VariantsList()
variants_list_1.add_variant(variant=variant_11)
variants_list_2.add_variant(variant=variant_21)

variants_list = diff(
target_variants_list=variants_list_1,
query_variants_lists=[variants_list_2],
max_neighbor_distance=1000,
num_threads=1,
match_all_breakpoints=False,
match_variant_types=False
)

assert 'variant_call_11' not in variants_list.variant_call_ids

0 comments on commit d1daedf

Please sign in to comment.