Skip to content

Commit

Permalink
output csv table
Browse files Browse the repository at this point in the history
  • Loading branch information
maxibor committed Oct 8, 2018
1 parent dfc6128 commit 4c3a487
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 19 additions & 2 deletions bin/plotAndReport
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def get_args():
default=None,
help='coproID version'
)
parser.add_argument(
"-csv",
dest="csv",
default=None,
help="csv filename output. Default = coproid.csv"
)
parser.add_argument(
'-o',
dest="output",
Expand All @@ -42,8 +48,9 @@ def get_args():
identity = float(str(args.identity))
version = str(args.version)
outfile = args.output
csv = args.csv

return(countFile, identity, version, outfile)
return(countFile, identity, version, outfile, csv)


def getBasename(file_name):
Expand All @@ -62,8 +69,16 @@ def getFile(path):
return(filename)


def write_csv(adict, CSV):
with open(CSV, "w") as f:
f.write("Sample_name,Organism_name1,Organism_name2,Genome1_size,Genome2_size,nb_aDNA_bp_aligned_genome1,nb_aDNA_bp_aligned_genome2,NormalizedReadRatio\n")
for akey in adict:
f.write(akey + "," + adict[akey]["orga1"] + "," + adict[akey]
["orga2"] + "," + str(adict[akey]["gs1"]) + "," + str(adict[akey]["gs2"]) + str(adict[akey]["nbp1"]) + "," + str(adict[akey]["nbp2"]) + "," + str(adict[akey]["nrr"]) + "\n")


if __name__ == "__main__":
CF, ID, VERSION, OUTFILE = get_args()
CF, ID, VERSION, OUTFILE, CSV = get_args()

identity = ID * 100

Expand Down Expand Up @@ -98,6 +113,8 @@ if __name__ == "__main__":
d[sample]["nbp2"] = nbp2
d[sample]["nrr"] = nrr

write_csv(d, CSV)

orga1_clean = organism1.replace("_", " ")
orga2_clean = organism2.replace("_", " ")

Expand Down
6 changes: 5 additions & 1 deletion main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,19 @@ process proportionAndReport {

label 'ristretto'

publishDir "${params.results}", mode: 'copy', pattern: '*.csv'

input:
file(count) from coproid_count
output:
file("*.md") into coproidmd
file("*.png") into plot
file("*.csv") into csv_out
script:
outfile = "coproID_result.md"
csvout = "coproid_result.csv"
"""
plotAndReport -c $count -i ${params.identity} -v $version -o $outfile
plotAndReport -c $count -i ${params.identity} -v $version -csv $csvout -o $outfile
"""
}

Expand Down

0 comments on commit 4c3a487

Please sign in to comment.