Skip to content

Commit

Permalink
Renamed makeBedpe function
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfeil committed Aug 31, 2017
1 parent 548277e commit 9041900
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions star_fusion_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import tarfile


def untargz(input_targz_file, untar_to_dir):
"""
This module accepts a tar.gz archive and untars it.
Expand All @@ -27,7 +28,8 @@ def untargz(input_targz_file, untar_to_dir):
tarball.close()
return return_value

def makeBedpe(infile, outfile):

def make_bedpe(infile, outfile):
"""
Takes star-fusion-non-filtered.final or star-fusion-gene-list-filtered.final and creates bedpe format
"""
Expand All @@ -36,6 +38,7 @@ def makeBedpe(infile, outfile):
with open(outfile, 'w') as o:
o.write(bedpe)


def pipeline(args):
"""
STAR-Fusion and FusionInspector pipeline
Expand Down Expand Up @@ -72,7 +75,7 @@ def pipeline(args):
os.rename(output, results)

# Create bedpe format
makeBedpe(results, os.path.abspath('%s/star-fusion-non-filtered.final.bedpe' % args.output_dir))
make_bedpe(results, os.path.abspath('%s/star-fusion-non-filtered.final.bedpe' % args.output_dir))

if args.skip_filter:
print('Skipping filter.', file=sys.stderr)
Expand Down Expand Up @@ -107,7 +110,7 @@ def pipeline(args):
results = out_f.name

# Create bedpe format
makeBedpe(results, os.path.abspath('%s/star-fusion-gene-list-filtered.final.bedpe' % args.output_dir))
make_bedpe(results, os.path.abspath('%s/star-fusion-gene-list-filtered.final.bedpe' % args.output_dir))

if args.run_fusion_inspector:
# Check input file for at least one fusion prediction
Expand Down Expand Up @@ -139,7 +142,7 @@ def fusion_inspector(results, args):
'--prep_for_IGV',
'--CPU', args.CPU]

fi_output = 'FusionInspector.fusion_predictions.final.abridged.FFPM'
fi_output = os.path.join(fi_path, 'FusionInspector.fusion_predictions.final.abridged.FFPM')

if args.test:
cmd = ['echo'] + cmd
Expand All @@ -154,12 +157,11 @@ def fusion_inspector(results, args):
subprocess.check_call(cmd)

# Rename the output so it is a little clearer
fi_results = 'fusion-inspector-results.final'
os.rename(os.path.join(fi_path, fi_output),
os.path.join(fi_path, fi_results))
fi_rename = os.path.join(fi_path, 'fusion-inspector-results.final')
os.rename(fi_output, fi_rename)

# Create bedpe format
makeBedpe(fi_results, os.path.abspath('%s/fusion-inspector-results.final.bedpe' % args.output_dir))
make_bedpe(fi_rename, os.path.join(fi_path, 'fusion-inspector-results.final.bedpe'))


def main():
Expand Down Expand Up @@ -255,7 +257,7 @@ def main():
# Check if FusionInspector directory still exists
fi_path = os.path.abspath(os.path.join(args.output_dir, 'FI-output'))
if os.path.exists(fi_path):
# FusionInspector requires a sub-directory fo run correctly
# FusionInspector requires a sub-directory to run correctly
# Here, I move the FI-output files into the parent directory
for f in os.listdir(fi_path):
shutil.move(os.path.join(fi_path, f),
Expand Down

0 comments on commit 9041900

Please sign in to comment.