Skip to content

Commit

Permalink
Merge pull request #76 from CenterForMedicalGeneticsGhent/bug/cram_su…
Browse files Browse the repository at this point in the history
…pport

Bug/cram support
  • Loading branch information
matthdsm authored Mar 31, 2021
2 parents 5c9f1f1 + b520919 commit c1d8057
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ WisecondorX convert input.sam/bam/cram output.npz [--optional arguments]

<br>Optional argument <br><br> | Function
:--- | :---
`--reference x` | Fasta reference to be used with cram inputs
`--binsize x` | Size per bin in bp; the reference bin size should be a multiple of this value. Note that this parameter does not impact the resolution, yet it can be used to optimize processing speed (default: x=5e3)
`--normdup` | Use this flag to avoid duplicate removal

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python
from setuptools import setup, find_packages

version = '1.2.2'
version = '1.2.3'
dl_version = 'master' if 'dev' in version else '{}'.format(version)

setup(
Expand Down
6 changes: 5 additions & 1 deletion wisecondorX/convert_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def convert_reads(args):
elif args.infile.endswith(".bam"):
reads_file = pysam.AlignmentFile(args.infile, 'rb')
elif args.infile.endswith(".cram"):
reads_file = pysam.AlignmentFile(args.infile, 'rc')
if args.reference is not None:
reads_file = pysam.AlignmentFile(args.infile, 'rc', reference_filename=args.reference)
else:
logging.error("Cram support requires a reference file, please use the --reference argument")
sys.exit(1)
else:
logging.error(
"Unsupported input file type. Make sure your input filename has a correct extension (sam/bam/cram)")
Expand Down
9 changes: 6 additions & 3 deletions wisecondorX/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,22 +264,25 @@ def output_gender(args):
def main():
warnings.filterwarnings('ignore')

parser = argparse.ArgumentParser(description='wisecondorX')
parser = argparse.ArgumentParser(description='WisecondorX')
parser.add_argument('--loglevel',
type=str,
default='INFO',
choices=['info', 'warning', 'debug', 'error', 'critical'])
subparsers = parser.add_subparsers()

parser_convert = subparsers.add_parser('convert',
description='Convert and filter a .bam file to a .npz',
description='Convert and filter a aligned reads to .npz',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser_convert.add_argument('infile',
type=str,
help='.bam input file for conversion')
help='aligned reads input for conversion')
parser_convert.add_argument('outfile',
type=str,
help='Output .npz file')
parser_convert.add_argument('-r', '--reference',
type=str,
help='Fasta reference to be used during cram conversion')
parser_convert.add_argument('--binsize',
type=float,
default=5e3,
Expand Down

0 comments on commit c1d8057

Please sign in to comment.