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 the option for user-defined sample id allowing dots #69

Open
wants to merge 1 commit 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
18 changes: 13 additions & 5 deletions scripts/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def index_bam(bam):
sys.exit('[extract] Error: unable to index bam file.')


def extract_reads(bam, outdir, paired, unmapped, alts, temp, threads):
def extract_reads(bam, outdir, paired, unmapped, alts, temp, threads, sample):
'''Extracts reads from chromosome 6 and alts/decoys if applicable.'''

log.info(f'[extract] Extracting reads from {bam}')

file_list = []
sample = os.path.splitext(os.path.basename(bam))[0]
#sample = os.path.splitext(os.path.basename(bam))[0]

# Index bam
index_bam(bam)
Expand Down Expand Up @@ -199,7 +199,12 @@ def extract_reads(bam, outdir, paired, unmapped, alts, temp, threads):
action = 'count',
help='keep intermediate files\n\n',
default=False)


parser.add_argument('--sample',
type = str,
help = 'User defined sample id\n',
default='')

parser.add_argument('-t',
'--threads',
type = str,
Expand All @@ -216,7 +221,9 @@ def extract_reads(bam, outdir, paired, unmapped, alts, temp, threads):
temp = create_temp(args.temp)

sample = os.path.basename(args.bam).split('.')[0]

if (args.sample != ""):
sample = args.sample

datDir = os.path.dirname(os.path.realpath(__file__)) + '/../dat/'

# Set up log file
Expand Down Expand Up @@ -260,7 +267,8 @@ def extract_reads(bam, outdir, paired, unmapped, alts, temp, threads):
args.unmapped,
alts,
temp,
args.threads)
args.threads,
sample)

remove_files(temp, args.keep_files)

Expand Down
11 changes: 10 additions & 1 deletion scripts/genotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,16 @@ def arg_check_threshold(parser, arg):
sys.exit('[genotype] Error: FASTQ or alignment.p file required.')

# Set up temporary and output folders, log file
sample = os.path.basename(args.file[0]).split('.')[0]
#sample = os.path.basename(args.file[0]).split('.')[0]
file_name_fields = os.path.basename(args.file[0]).split('.')
sample = ""
for i in range(len(file_name_fields) - 1, -1, -1):
if (file_name_fields[i] == 'extracted' or file_name_fields[i] == 'alignment'):
sample = '.'.join(file_name_fields[0:i])
break
if (sample == ""):
sample = os.path.basename(args.file[0]).split('.')[0]

outdir = check_path(args.outdir)
temp = create_temp(args.temp)
if args.log:
Expand Down
11 changes: 10 additions & 1 deletion scripts/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ def process_genotype(json_files, indir, outdir, run, suffix):

genotypes = dict()
for file in json_files:
sample = file.split('.')[0]
#sample = file.split('.')[0]
file_name_fields = file.split('.')
sample = ""
for i in range(len(file_name_fields) - 1, -1, -1):
if (file_name_fields[i] == 'genotype'):
sample = '.'.join(file_name_fields[0:i])
break
if (sample == ""):
sample = file.split('.')[0]

file_path = indir + file

with open(file_path,'r') as file:
Expand Down