Skip to content

Commit

Permalink
Minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
francois-a committed Nov 2, 2024
1 parent 7ea6544 commit 0527487
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
31 changes: 7 additions & 24 deletions python/rnaseqc/legacy_exon_remap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from agutil import status_bar
from tqdm import tqdm
import subprocess
import csv
import shutil
Expand All @@ -10,7 +10,7 @@ def run(args):
print("Parsing GTF")
gtf = Annotation(args.gtf.name)
print("Parsing GCT")
numRows = int(subprocess.check_output("wc -l %s" % args.gct.name, shell=True).decode().strip().split()[0]) - 3
numRows = int(subprocess.check_output(f"wc -l {args.gct.name}", shell=True).decode().strip().split()[0]) - 3
header = ''.join([next(args.gct), next(args.gct)])
reader = csv.DictReader(args.gct, delimiter='\t')
w = tempfile.NamedTemporaryFile('w')
Expand All @@ -19,7 +19,7 @@ def run(args):
writer.writeheader()
current = None
features = []
for line in status_bar.iter(reader, maximum=numRows):
for line in tqdm(reader, total=numRows):
gene = '_'.join(line['Name'].split('_')[:-1])
if gene != current:
if current is not None:
Expand Down Expand Up @@ -88,31 +88,14 @@ def run(args):
print("Cleaning up")
w.flush()
args.gct.close()
shutil.copyfile(
args.gct.name,
args.gct.name+'.bak'
)
shutil.copyfile(
w.name,
args.gct.name
)
shutil.copyfile(args.gct.name, args.gct.name+'.bak')
shutil.copyfile(w.name, args.gct.name)


def main():
parser = argparse.ArgumentParser('flipper')

parser.add_argument(
'gct',
type=argparse.FileType('r'),
help="RNA-SeQC 2 Exon reads gct file"
)

parser.add_argument(
'gtf',
type=argparse.FileType('r'),
help="Reference GTF for the exons"
)

parser.add_argument('gct', type=argparse.FileType('r'), help="RNA-SeQC 2 Exon reads gct file")
parser.add_argument('gtf', type=argparse.FileType('r'), help="Reference GTF for the exons")
args = parser.parse_args()
run(args)

Expand Down
16 changes: 8 additions & 8 deletions python/rnaseqc/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ def test_rnaseqc(path):

print('['+datetime.now().strftime("%b %d %H:%M:%S")+'] Running RNA-SeQC', flush=True)

cmd = '{} {} {} {}'.format(locate_rnaseqc(), args.genes_gtf, args.bam_file, args.output_dir) \
+ ' -s '+args.prefix \
cmd = f"{locate_rnaseqc()} {args.genes_gtf} {args.bam_file} {args.output_dir}" \
+ f" -s {args.prefix}" \
+ ' -vv'
if args.stranded is not None:
cmd += ' --stranded '+args.stranded
cmd += f" --stranded {args.stranded}"
if args.bed is not None:
cmd += ' --bed '+args.bed
cmd += f" --bed {args.bed}"
if args.mapping_quality is not None:
cmd += ' --mapping-quality {}'.format(args.mapping_quality)
cmd += f" --mapping-quality {args.mapping_quality}"
if args.mismatch_threshold is not None:
cmd += ' --base-mismatch {}'.format(args.mismatch_threshold)
cmd += f" --base-mismatch {args.mismatch_threshold}"
if args.coverage:
cmd += ' --coverage'
print(' * command: "{}"'.format(cmd), flush=True)
print(f' * command: "{cmd}"', flush=True)
subprocess.check_call(cmd, shell=True)

# gzip GCTs
subprocess.check_call('gzip {0}.exon_reads.gct {0}.gene_tpm.gct {0}.gene_reads.gct {0}.gene_fragments.gct'.format(args.prefix), shell=True)
if args.coverage:
subprocess.check_call('gzip {}.coverage.tsv'.format(args.prefix), shell=True)
subprocess.check_call(f'gzip {args.prefix}.coverage.tsv', shell=True)

print('['+datetime.now().strftime("%b %d %H:%M:%S")+'] Finished RNA-SeQC', flush=True)

0 comments on commit 0527487

Please sign in to comment.