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

Add '-l' option to just provide sample names instead of bam files #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
33 changes: 22 additions & 11 deletions src/monovar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
The University of Texas MD Anderson Cancer Center
Hamim Zafar and Ken Chen ([email protected])

Copyright (c) 2020 Warren W. Kretzschmar

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
Expand Down Expand Up @@ -79,6 +81,8 @@ def _pickle_method(m):
# Process the inputs
argc = len(sys.argv)
i = 1
bam_file_list = None
cell_name_list = None
while (i < argc):
if (sys.argv[i] == '-n'):
n_cells = int(sys.argv[i + 1]) # Number of input bam files
Expand All @@ -93,7 +97,8 @@ def _pickle_method(m):
input_args['-f'] = 'Provided'
elif (sys.argv[i] == '-b'):
bam_file_list = sys.argv[i + 1] # File containing list of bam files
input_args['-b'] = 'Provided'
elif (sys.argv[i] == '-l'):
cell_name_list = sys.argv[i + 1] # File containing list of cell names
elif (sys.argv[i] == '-o'):
outfile = sys.argv[i + 1] # Output File
input_args['-o'] = 'Provided'
Expand All @@ -114,10 +119,8 @@ def _pickle_method(m):
print "Error: Reference genome file not provided. Use '-f' for reference genome file.\n"
exit(3)

try:
b = input_args['-b']
except KeyError:
print "Error: List of Bam files not provided. Use '-b' for list of Bam files.\n"
if not(bam_file_list or cell_name_list):
print "Error: List of Bam files or list of read groups not provided. Use '-b' or '-l', respectively.\n"
exit(3)

try:
Expand All @@ -131,13 +134,21 @@ def _pickle_method(m):
print "CF_flag can have value 0 or 1. Use '-c' with proper value.\n"
exit(3)

# Obtain the RG IDs from the bam files
bam_id_list = []
f_bam_list = open(bam_file_list)
for filename in f_bam_list:
filename = filename.replace('\n', '')
bam_id = U.Get_BAM_RG(filename)
bam_id_list.append(bam_id)
if bam_file_list:
# Obtain the RG IDs from the bam files
f_bam_list = open(bam_file_list)
for filename in f_bam_list:
filename = filename.replace('\n', '')
bam_id = U.Get_BAM_RG(filename)
bam_id_list.append(bam_id)
elif cell_name_list:
# Obtain the RG IDs from the rg name list
f_bam_list = open(cell_name_list)
for filename in f_bam_list:
bam_id_list.append(filename.rstrip('\n'))
else:
raise Exception("Neither -b nor -l provided")

n_cells = len(bam_id_list)

Expand Down
8 changes: 4 additions & 4 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ def Create_Factorial_List(self, max_allele_cnt):
return factorial_list

def Create_nCr_mat(self, max_allele_cnt, factorial_list):
ncr_mat = np.zeros((max_allele_cnt, max_allele_cnt))
ncr_mat = np.zeros((max_allele_cnt, max_allele_cnt), dtype=np.longdouble)
factorial_list = np.array(factorial_list)
for i in range(max_allele_cnt):
for j in range(max_allele_cnt):
ncr_mat[j, i] = factorial_list[j] / \
(factorial_list[i] * factorial_list[j - i])
ncr_mat[:, i] = factorial_list / \
(factorial_list[i] * np.roll(factorial_list, i))
return ncr_mat

def CheckAltAllele(self, single_cell_dict):
Expand Down