Skip to content

Commit

Permalink
Merge pull request #289 from apregier/downloader
Browse files Browse the repository at this point in the history
Changes for release
  • Loading branch information
apregier authored Sep 5, 2019
2 parents 9287ed9 + 03c545f commit 79e3320
Show file tree
Hide file tree
Showing 17 changed files with 798 additions and 38 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ install:
- deps='libgfortran pip nose coverage statsmodels numpy pandas=0.19.2 scipy'
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION $deps
- source activate test-environment
- pip install logzero
- pip install svtyper

# command to run tests
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
packages=find_packages(exclude=['tests']),
include_package_data=True,

install_requires=['svtyper==0.7.0', 'numpy', 'scipy', 'statsmodels', 'pandas', 'setuptools'],
install_requires=['svtyper==0.7.1', 'numpy', 'scipy', 'statsmodels', 'pandas', 'setuptools',
'google-auth',
'google-cloud-storage',
'google-compute-engine',
'crcmod',
'logzero'],
scripts=['scripts/create_coordinates'],

entry_points={
Expand Down
3 changes: 2 additions & 1 deletion svtools/afreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def epilog():

def add_arguments_to_parser(parser):
parser.add_argument(metavar='<VCF>', dest='input_vcf', nargs='?', default=None, help='VCF input')
parser.add_argument('-t', '--tempdir', metavar='<DIR>', required=False, default=None, help='Directory for temp file downloads')
parser.set_defaults(entry_point=run_from_args)

def command_parser():
Expand All @@ -111,7 +112,7 @@ def command_parser():
return parser

def run_from_args(args):
with su.InputStream(args.input_vcf) as input_stream:
with su.InputStream(args.input_vcf, args.tempdir) as input_stream:
updater = UpdateInfo(input_stream)
updater.execute()

Expand Down
3 changes: 2 additions & 1 deletion svtools/bedpetobed12.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def add_arguments_to_parser(parser):
parser.add_argument('-o', '--output', metavar='<BED12>', type=argparse.FileType('w'), default=sys.stdout, help='Output BED12 to write (default: stdout)')
parser.add_argument('-n', '--name', metavar='<STRING>', default='BEDPE', help="The name of the track. Default is 'BEDPE'")
parser.add_argument('-d', '--maxdist', metavar='<INT>', dest='dist', default=1000000, type=int, help='The minimum distance for drawing intrachromosomal features as if they are interchromosomal (i.e., without a line spanning the two footprints). Default is 1Mb.')
parser.add_argument('-t', '--tempdir', metavar='<DIR>', required=False, default=None, help='Directory for temp file downloads')
parser.set_defaults(entry_point=run_from_args)

def command_parser():
Expand All @@ -203,7 +204,7 @@ def command_parser():
return parser

def run_from_args(args):
with su.InputStream(args.input) as stream:
with su.InputStream(args.input, args.tempdir) as stream:
processBEDPE(stream, args.name, args.dist, args.output)

if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion svtools/bedpetovcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def epilog():
def add_arguments_to_parser(parser):
parser.add_argument('-i', '--input', metavar='<BEDPE>', default=None, help='BEDPE input (default: stdin)')
parser.add_argument('-o', '--output', metavar='<VCF>', type=argparse.FileType('w'), default=sys.stdout, help='Output VCF to write (default: stdout)')
parser.add_argument('-t', '--tempdir', metavar='<DIR>', required=False, default=None, help='Directory for temp file downloads')
parser.set_defaults(entry_point=run_from_args)

def command_parser():
Expand All @@ -68,7 +69,7 @@ def command_parser():
return parser

def run_from_args(args):
with su.InputStream(args.input) as stream:
with su.InputStream(args.input, args.tempdir) as stream:
bedpeToVcf(stream, args.output)

if __name__ == '__main__':
Expand Down
2 changes: 2 additions & 0 deletions svtools/breakpoint.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import l_bp
from exceptions import MissingProbabilitiesException

Expand Down
3 changes: 2 additions & 1 deletion svtools/copynumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def add_arguments_to_parser(parser):
parser.add_argument('--cnvnator', metavar='<PATH>', required=True, help='path to cnvnator binary for the cnvnator used by speedseq (required)')
parser.add_argument('-i', '--input', metavar='<VCF>', default=None, help='VCF input')
parser.add_argument('-o', '--output', metavar='<PATH>', type=argparse.FileType('w'), default=sys.stdout, help='output VCF to write (default: stdout)')
parser.add_argument('-t', '--tempdir', metavar='<DIR>', required=False, default=None, help='Directory for temp file downloads')
parser.set_defaults(entry_point=run_from_args)

def command_parser():
Expand All @@ -110,7 +111,7 @@ def command_parser():
return parser

def run_from_args(args):
with su.InputStream(args.input) as stream:
with su.InputStream(args.input, args.tempdir) as stream:
sv_readdepth(stream, args.sample, args.root, args.window, args.output, args.cnvnator, args.coordinates)

# initialize the script
Expand Down
14 changes: 11 additions & 3 deletions svtools/l_bp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import sys, re, os

ar=os.path.dirname(os.path.realpath(__file__)).split('/')
svtpath='/'.join(ar[0:(len(ar)-1)])
sys.path.insert(1, svtpath)
from svtools.utils import parse_bnd_alt_string
import re


def find_all(a_str, sub):
'''
Expand Down Expand Up @@ -64,8 +69,9 @@ def parse_vcf(vcf_file_stream, vcf_lines, vcf_headers, add_sname=True, include_r
mid=A[7][pos_s:pos_e]
post=A[7][pos_e:]
A[7] = pre + mid + ',--:0' + post

A[7] = 'SVTYPE=INV' + A[7][10:] + ';END=' + o_pos
if ';END=' not in A[7]:
A[7] = A[7] + ';END=' + o_pos
A[7]=A[7].replace('SVTYPE=BND', 'SVTYPE=INV')
A[4] = '<INV>'
l = '\t'.join(A) + '\n'
vcf_lines.append(l)
Expand Down Expand Up @@ -119,6 +125,8 @@ def split_v(l):
sep, chr_r, pos_r = parse_bnd_alt_string(A[4])
m['END'] = pos_r
pos_r = int(pos_r)
elif m['SVTYPE'] == 'INS':
pos_r=pos_l+int(m['SVLEN'])
else:
pos_r = int(m['END'])

Expand Down
12 changes: 9 additions & 3 deletions svtools/lmerge.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import svtools.l_bp as l_bp
from svtools.breakpoint import Breakpoint
import svtools.logspace as ls
Expand Down Expand Up @@ -291,6 +293,8 @@ def create_merged_variant(BP, c, v_id, vcf, use_product, weighting_scheme='unwei

if var.get_info('SVTYPE') == 'BND':
var.set_info('EVENT', str(v_id))
elif var.get_info('SVTYPE') == 'INS':
var.set_info('END', new_pos_L)
else:
var.set_info('END', new_pos_R )

Expand Down Expand Up @@ -419,7 +423,7 @@ def write_var(var, vcf_out, include_genotypes=False):

invtobnd(var)

if var.alt not in ['<DEL>', '<DUP>', '<INV>']:
if var.alt not in ['<DEL>', '<DUP>', '<INV>', '<INS>']:

var.var_id=str(v_id)+'_1'
var.set_info('EVENT', v_id)
Expand Down Expand Up @@ -537,7 +541,7 @@ def r_cluster(BP_l, sample_order, v_id, use_product, vcf, vcf_out, include_genot



def l_cluster_by_line(file_name, percent_slop=0, fixed_slop=0, use_product=False, include_genotypes=False, weighting_scheme='unweighted'):
def l_cluster_by_line(file_name, tempdir, percent_slop=0, fixed_slop=0, use_product=False, include_genotypes=False, weighting_scheme='unweighted'):

v_id = 0

Expand All @@ -546,7 +550,7 @@ def l_cluster_by_line(file_name, percent_slop=0, fixed_slop=0, use_product=False
vcf = Vcf()
vcf_out=sys.stdout

with InputStream(file_name) as vcf_stream:
with InputStream(file_name, tempdir) as vcf_stream:

BP_l = []
BP_sv_type = ''
Expand Down Expand Up @@ -616,6 +620,7 @@ def add_arguments_to_parser(parser):
parser.add_argument('--sum', dest='use_product', action='store_false', default=True, help='calculate breakpoint PDF and position using sum algorithm instead of product')
parser.add_argument('-g', dest='include_genotypes', action='store_true', default=False, help='include original genotypes in output. When multiple variants are merged, the last will dictate the genotype field')
parser.add_argument('-w', dest='weighting_scheme', metavar='<STRING>', default="unweighted", choices=['carrier_wt', 'evidence_wt'], help='weighting scheme (intended for use in tiered merging), options: unweighted, carrier_wt, evidence_wt')
parser.add_argument('-t', '--tempdir', metavar='<DIR>', required=False, default=None, help='Directory for temp file downloads')
parser.set_defaults(entry_point=run_from_args)

def command_parser():
Expand All @@ -625,6 +630,7 @@ def command_parser():

def run_from_args(args):
l_cluster_by_line(args.inFile,
args.tempdir,
percent_slop=args.percent_slop,
fixed_slop=args.fixed_slop,
use_product=args.use_product,
Expand Down
Loading

0 comments on commit 79e3320

Please sign in to comment.