Skip to content

Commit

Permalink
better countBP output file name
Browse files Browse the repository at this point in the history
  • Loading branch information
maxibor committed Oct 8, 2018
1 parent f1b1ad5 commit ed580e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
29 changes: 25 additions & 4 deletions bin/normalizedReadCount
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ def get_args():
default=None,
help="Output file basename. Default = {BAM_GENOME}.out"
)
parser.add_argument(
'-ob1',
dest="output_bam1",
default=None,
help="Output bam 1 filename. Default = {BAM1_INPUT}.filtered.bam"
)
parser.add_argument(
'-ob2',
dest="output_bam2",
default=None,
help="Output bam 2 filename. Default = {BAM2_INPUT}.filtered.bam"
)
parser.add_argument(
'-p',
dest="processes",
Expand All @@ -93,9 +105,11 @@ def get_args():
sname = args.name
identity = float(str(args.identity))
outfile = args.output
obam1 = args.output_bam1
obam2 = args.output_bam2
processes = int(args.processes)

return(bam1, genome1, size1, organame1, bam2, genome2, size2, organame2, sname, identity, processes, outfile)
return(bam1, genome1, size1, organame1, bam2, genome2, size2, organame2, sname, identity, processes, outfile, obam1, obam2)


def getBasename(file_name):
Expand Down Expand Up @@ -195,7 +209,7 @@ def getCommonReads(readsBam1, readsBam2):

if __name__ == "__main__":
# bam1, genome1, size1, organame1, outfile1, bam2, genome2, size2, organame2, outfile2, sname, identity, processes
BAM1, GENOME1, SIZE1, ORGANAME1, BAM2, GENOME2, SIZE2, ORGANAME2, SNAME, ID, PROCESSES, OUTFILE = get_args()
BAM1, GENOME1, SIZE1, ORGANAME1, BAM2, GENOME2, SIZE2, ORGANAME2, SNAME, ID, PROCESSES, OUTFILE, OBAM1, OBAM2 = get_args()

if BAM1 is None:
print("Missing BAM file")
Expand Down Expand Up @@ -236,8 +250,15 @@ if __name__ == "__main__":
nb2 = getNumberMappedReadsMultiprocess(
bam=BAM2, processes=PROCESSES, id=ID, commonReads=commonReads)["bpCnt"]

outbam1 = bam_basename1 + ".filtered.bam"
outbam2 = bam_basename2 + ".filtered.bam"
if OBAM1 is None:
outbam1 = bam_basename1 + ".filtered.bam"
else:
outbam1 = OBAM1
if OBAM2 is None:
outbam2 = bam_basename2 + ".filtered.bam"
else:
outbam2 = OBAM2

writeBam(inbam=BAM1, outbam=outbam1, commonReads=commonReads)
writeBam(inbam=BAM2, outbam=outbam2, commonReads=commonReads)

Expand Down
4 changes: 3 additions & 1 deletion main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,12 @@ process countBp{
outfile = name+".out"
organame1 = params.name1
organame2 = params.name2
obam1 = name+"_"+organame1+".filtered.bam"
obam2 = name+"_"+organame2+".filtered.bam"
"""
samtools index $bam1
samtools index $bam2
normalizedReadCount -n $name -b1 $bam1 -b2 $bam2 -g1 $genome1 -g2 $genome2 -r1 $organame1 -r2 $organame2 -i ${params.identity} -o $outfile -p ${task.cpus}
normalizedReadCount -n $name -b1 $bam1 -b2 $bam2 -g1 $genome1 -g2 $genome2 -r1 $organame1 -r2 $organame2 -i ${params.identity} -o $outfile -ob1 $obam1 -ob2 $obam2 -p ${task.cpus}
"""
}

Expand Down

0 comments on commit ed580e6

Please sign in to comment.