Skip to content

Commit 9ea6868

Browse files
committed
average_nucleotide_identity.py: added --write_excel option.
This was necessary to handle an incompatibility between pandas and openpyxl. See http://stackoverflow.com/questions/30102232/pandas-can-not-write-to-excel-file and pandas-dev/pandas#10125
1 parent ae557d6 commit 9ea6868

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

average_nucleotide_identity.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ def parse_cmdline(args):
242242
action="store",
243243
default=pyani_config.FORMATDB_DEFAULT,
244244
help="Path to BLAST formatdb executable")
245+
parser.add_argument("--write_excel", dest="write_excel",
246+
action="store_true",
247+
default=False,
248+
help="Write Excel format output tables")
245249
return parser.parse_args()
246250

247251

@@ -522,15 +526,16 @@ def write(results, filestems):
522526
523527
- results - tuple of dataframes from analysis
524528
525-
Each dataframe is written to an Excel-format file, and plain text
526-
tab-separated file in the output directory. The order of result output
527-
must be reflected in the order of filestems.
529+
Each dataframe is written to an Excel-format file (if args.write_excel is
530+
True), and plain text tab-separated file in the output directory. The
531+
order of result output must be reflected in the order of filestems.
528532
"""
529533
logger.info("Writing %s results to %s" % (args.method, args.outdirname))
530534
for df, filestem in zip(results, filestems):
531535
logger.info("\t%s" % filestem)
532-
df.to_excel(os.path.join(args.outdirname, filestem) + '.xlsx',
533-
index=True)
536+
if args.write_excel:
537+
df.to_excel(os.path.join(args.outdirname, filestem) + '.xlsx',
538+
index=True)
534539
df.to_csv(os.path.join(args.outdirname, filestem) + '.tab',
535540
index=True, sep="\t")
536541

0 commit comments

Comments
 (0)