Skip to content

Commit 8e824fc

Browse files
committed
Updating file names and making cigar and bowtie as scripts installed
1 parent 236c63a commit 8e824fc

4 files changed

Lines changed: 31 additions & 12 deletions

File tree

bin/stepRNA

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ from stepRNA.output import make_csv, make_type_csv, write_to_bam, print_hist, re
1717
#Scripts to be used...
1818
import stepRNA.remove_exact as remove_exact
1919
import stepRNA.make_unique as make_unique
20-
import stepRNA.run_bowtie as run_bowtie
20+
import stepRNA.stepRNA-run_bowtie as run_bowtie
2121
import stepRNA.index_bowtie as index_bowtie
22-
import stepRNA.cigar_process as cigar_process
22+
import stepRNA.stepRNA-cigar_process as cigar_process
2323

2424
#Modules that need to be installed
2525
try:
@@ -60,6 +60,7 @@ optional.add_argument('-m', '--min_score', default=-1, type=int, help='Minimum s
6060
flags.add_argument('-e', '--remove_exact', action='store_true', help='Remove exact read matches to the reference sequence')
6161
flags.add_argument('-u', '--make_unique', action='store_true', help='Make FASTA headers unique in reference and reads i.e. >Read_1 >Read_2')
6262
flags.add_argument('-j', '--write_json', action='store_true', help='Write count dictionaries to a JSON file')
63+
flags.add_argument('-V', '--version', action='version', version='stepRNA v1.0.0', help='Print version number then exit.')
6364

6465
#parser._action_groups.append(optional)
6566
#parser._action_groups.append(flags)
@@ -109,13 +110,23 @@ sorted_bam = run_bowtie.main(ref_base, reads, prefix, min_score, logger)
109110
logger.write('Alignment completed')
110111

111112
#Cigar process...
113+
fpath = os.path.join(outdir, prefix + '_AlignmentFiles')
114+
if os.path.isdir(fpath):
115+
logger.write('Removing contents in {}'.format(fpath))
116+
for f in os.listdir(fpath):
117+
try:
118+
os.remove(os.path.join(fpath, f))
119+
except:
120+
logger.log('Could not remove {}'.format(f))
121+
122+
logger.write('Processing Cigar strings...')
112123
right_dic, left_dic, type_dic, read_len_dic, refs_read_dic = cigar_process.main(sorted_bam, prefix, args.write_json)
113124
logger.write('Cigar strings processed')
114125

115126
# Count unique references
116127
right_unique_dic = defaultdict(lambda:0)
117128
left_unique_dic = defaultdict(lambda:0)
118-
fpath = os.path.join(outdir, 'AlignmentFiles')
129+
fpath = os.path.join(outdir, prefix + '_AlignmentFiles')
119130
for f in os.listdir(fpath):
120131
if 'passed' not in f:
121132
key = int(f.split('_')[-2])
@@ -129,14 +140,14 @@ for f in os.listdir(fpath):
129140

130141
#Put overhangs infomation into a csv and print to terminal...
131142
logger.write('\n## Overhang counts ##')
132-
make_csv([right_dic, left_dic], prefix + '_overhang.csv', ['OH','Left','Right'])
143+
make_csv([right_dic, left_dic], prefix + '_overhang.csv', ['Overhang','5prime','3prime'])
133144
logger.write('\n## Unique overhang counts ##')
134-
make_csv([right_unique_dic, left_unique_dic], prefix + '_unique_overhang.csv', ['OH','Left','Right'])
145+
make_csv([right_unique_dic, left_unique_dic], prefix + '_unique_overhang.csv', ['Overhang','3prime','5prime'])
135146
logger.write('\n## Overhang types ##')
136-
make_type_csv(type_dic, prefix + '_type.csv', ['OH_type', 'count'])
147+
make_type_csv(type_dic, prefix + '_overhang_type.csv', ['Classification', 'count'])
137148
logger.write('\n## Read lengths ##')
138-
make_type_csv(read_len_dic, prefix + '_read_len.csv', ['Read_length', 'count'], sort=True)
139-
make_type_csv(refs_read_dic, prefix + '_ref_hits.csv', ['Reference', 'count'], show=False)
149+
make_type_csv(read_len_dic, prefix + '_passenger_length.csv', ['sRNA_read', 'passenger_count'], sort=True)
150+
make_type_csv(refs_read_dic, prefix + '_passenger_number.csv', ['Passenger_length', 'number'], show=False)
140151
print()
141152

142153
def make_hist(csv_in):

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
long_description = fh.read()
55

66
setuptools.setup(name='stepRNA',
7-
version='0.1.10',
7+
version='0.1.11',
88
author='Ben Murcott',
99
author_email='bmm41@bath.ac.uk',
1010
description='Align short RNA seqeuncing reads to determine the length of of overhang.',
@@ -25,6 +25,9 @@
2525
"Bio>=0.3.0",
2626
"numpy>=1.20.1"
2727
],
28-
scripts=["bin/stepRNA"]
28+
scripts=["bin/stepRNA",
29+
"stepRNA/stepRNA-run_bowtie.py",
30+
"stepRNA/stepRNA-cigar_process.py"
31+
]
2932
)
3033

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
from collections import defaultdict
24
import json
35
import os
@@ -50,8 +52,9 @@ def add_to_MakeBam(dic, length, additional, record):
5052
refs_read_dic[line.reference_name] += 1 # number of reads algining to reference
5153
except Exception:
5254
continue
53-
directory = os.path.dirname(filepath)
54-
outdir = os.path.join(directory, 'AlignmentFiles')
55+
#directory = os.path.dirname(filepath)
56+
#outdir = os.path.join(directory, 'AlignmentFiles')
57+
outdir = filepath + '_AlignmentFiles'
5558
check_dir(outdir)
5659
for key in MakeBam_dic:
5760
outfile = os.path.join(outdir, '{}_{}.bam'.format(os.path.basename(filepath), key))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
from stepRNA.processing import sam_to_bam
24
from stepRNA.general import mini_maxi, replace_ext, check_dir
35
from subprocess import run, PIPE

0 commit comments

Comments
 (0)