Skip to content

Commit

Permalink
get samples from bam suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Apr 9, 2024
1 parent f4dc7ae commit 6fe56df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions snakePipes/common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,19 @@ def get_sample_names_bam(infiles, bamExt):
s.append(x)
return sorted(list(set(s)))

def get_sample_names_suffix_bam(infiles, bamExt):
"""
Get sample names without file extensions
"""
bamSuff = [x + bamExt for x in ["genome1","genome2","unassigned","allele_flagged"]]
s = []
for x in infiles:
for y in bamSuff:
if y in os.path.basename(x):
x = os.path.basename(x).replace(y, "")
s.append(x)
return sorted(list(set(s)))


def is_paired(infiles, ext, reads):
"""
Expand Down
5 changes: 4 additions & 1 deletion snakePipes/workflows/mRNA-seq/internals.snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ if not fromBAM:
pairedEnd = cf.is_paired(infiles, ext, reads)
else:
infiles = sorted(glob.glob(os.path.join(str(indir or ''), '*' + bamExt)))
samples = cf.get_sample_names_bam(infiles, bamExt)
if mode in "allelic-counting":
samples = cf.get_sample_names_suffix_bam(infiles, bamExt)
else:
samples = cf.get_sample_names_bam(infiles, bamExt)

if formula and not sampleSheet:
print("In order to apply custom formula, please provide a sample sheet!")
Expand Down
1 change: 1 addition & 0 deletions snakePipes/workflows/mRNA-seq/mRNA-seq
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def main():
if "allelic-counting" in modeTemp and not args.fromBAM:
warnings.warn("--fromBAM is required with allelic-counting mode. Setting to True.")
args.fromBAM = True
args.aligner = "EXTERNAL_BAM"
if args.rMats and not args.sampleSheet:
sys.exit("--rMats flag requires a sampleSheet (specified with --sampleSheet).\n")
if "three_prime_seq" in mode:
Expand Down

0 comments on commit 6fe56df

Please sign in to comment.