Skip to content

Commit c729a69

Browse files
authored
Add files via upload
added -s and -m to specify the number of threads and the memory.
1 parent a415a7f commit c729a69

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

bam2intron

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ intronbed=$2
77
output=$3
88
purename=$4
99
MAPQ=$5
10+
threads=$6
11+
mem=$7
12+
1013

1114
# prepare out directory
1215
if [ ! -d $output ];then
@@ -33,11 +36,11 @@ if [ ! -e "$bai" ]; then
3336
fi
3437

3538
# pre-filter bam using intron bed files
36-
samtools view -b -q $MAPQ -@ 20 -L $intronbed $bam > $umapbam
39+
samtools view -b -q $MAPQ -@ $threads -L $intronbed $bam > $umapbam
3740

3841
# covert to bed format
3942
#echo '---> Converting bam to bed file'
40-
bam2bed —input bam -r tmp -m 30G < "${umapbam}" |bedscore > $bambed
43+
bam2bed —input bam -r tmp -m $mem < "${umapbam}" |bedscore > $bambed
4144

4245
# get intron-spanning reads
4346
bedmap --bp-ovr 1 --skip-unmapped --echo --sum --echo-overlap-size --echo-map-id-uniq $intronbed $bambed > $overlap

iread.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
parser.add_argument('-t','--total_reads',help="The total number of mapped reads/fragments from read aligners, say 50 million. This is used to calculate FPKM. Users can use samtools to calculate the number of mapped reads from the input bam file. It's needed to be provided by user.")
2525
parser.add_argument('-k','--n_cores',help="The number of CPU cores to use. Default to n-2, where n is the total number of cores available.")
2626
parser.add_argument('-q','--MAPQ',help="The MAPQ score for retrieving uniquely mapped reads. Default to 255, which is the score for unique mapping reads in STAR. If other aligners such as Hisat or TopHat are used, change this score accordingly.")
27+
parser.add_argument('-s','--threads', help="Number of threads to use. Default to 20.")
28+
parser.add_argument('-m','--mem', help="memory to use (unit: G). Default to 30.")
2729
parser.add_argument('-b','--bias',help="an intron-length correction term for calculating FPKM of introns. This means that the length of intron used for calculating FPKM will be the true intron length plus this correction term. This is used to prevent very high FPKM for short introns. Default: 100.")
2830

2931
args = parser.parse_args() # parse command-line arguments
@@ -109,17 +111,30 @@
109111
MAPQ = args.MAPQ
110112
else:
111113
MAPQ = 255 # 255 for STAR
114+
# number of threads
115+
if args.threads:
116+
threads = args.threads
117+
else:
118+
threads = 20
119+
112120

113121

114122

123+
# memory settings
124+
if args.mem:
125+
mem = args.mem
126+
else:
127+
mem = 30
128+
115129
# correction term for intron lengths
116130
if args.bias:
117131
bias = args.bias
118132
else:
119133
bias = 100
120134

121135
# reduce bam to intronic regions
122-
cmd_reduce = 'bam2intron ' + ' ' + bam_file + ' ' + intron_file + ' ' + output_folder + ' ' + pure_file_name + ' ' +str(MAPQ)
136+
cmd_reduce = 'bam2intron ' + ' ' + bam_file + ' ' + intron_file + ' ' + output_folder + ' ' + pure_file_name + ' ' +str(MAPQ) + ' '+str(threads)+' '+str(mem)+'G'
137+
#print(cmd_reduce)
123138
os.system(cmd_reduce)
124139

125140
# count intronic reads

0 commit comments

Comments
 (0)