diff --git a/README.md b/README.md index 95b3679..176fca6 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ positional arguments: optional arguments: -h, --help show this help message and exit --csv_N Include Ns in sample variant CSVs + --no_trim_terminal_N Don't trim Ns from sequence terminus. Default behaviour is to trim Ns and gaps BEFORE analysis --no_gzip_json Don't gzip typing JSON files --output_unclassified Retain unclassified samples in summary CSV diff --git a/aln2type/aln2type.py b/aln2type/aln2type.py index 93ae619..3e9505a 100644 --- a/aln2type/aln2type.py +++ b/aln2type/aln2type.py @@ -573,6 +573,9 @@ def write_sample_variant_csv(name, variants, sample_csv_outdir, csv_N=False): def remove_terminal_gapns(seq): return re.sub(r'(N|-)*$', '', seq) +def remove_terminal_gaps(seq): + return re.sub(r'-*$', '', seq) + def go(args): refseq = get_ref_seq(args.msa, args.ref_name) @@ -592,7 +595,10 @@ def go(args): if name == args.ref_name: continue else: - variants = update_variants(remove_terminal_gapns(seq.upper()), refseq) + if args.no_trim_terminal_N: + variants = update_variants(remove_terminal_gaps(seq.upper()), refseq) + else: + variants = update_variants(remove_terminal_gapns(seq.upper()), refseq) print(name) if variants: diff --git a/aln2type/cli.py b/aln2type/cli.py index 1506a62..bae59e6 100644 --- a/aln2type/cli.py +++ b/aln2type/cli.py @@ -4,6 +4,7 @@ def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("--csv_N", action='store_true', required=False, help="Include Ns in sample variant CSVs") + parser.add_argument("--no_trim_terminal_N", action='store_true', required=False, help="Don't trim Ns from sequence terminus. Default behaviour is to trim Ns and gaps BEFORE analysis") parser.add_argument("--no_gzip_json", action='store_true', required=False, help="Don't gzip typing JSON files") parser.add_argument("--output_unclassified", action='store_true', required=False, help="Retain unclassified samples in summary CSV") parser.add_argument("--no_call_deletion", action='store_true', required=False, help="Allow deleted positions to be treated as no-calls not ref") diff --git a/aln2type/version.py b/aln2type/version.py index 3b93d0b..27fdca4 100644 --- a/aln2type/version.py +++ b/aln2type/version.py @@ -1 +1 @@ -__version__ = "0.0.2" +__version__ = "0.0.3"