bacpop / PopPUNK

PopPUNK 👨‍🎤 (POPulation Partitioning Using Nucleotide Kmers)
https://www.bacpop.org/poppunk
Apache License 2.0
88 stars 18 forks source link

poppunk_visualise failed to parse a long path to the model directory #179

Closed wanyuac closed 2 years ago

wanyuac commented 3 years ago

Versions poppunk v2.4.0

Command used and output returned poppunk_visualise --ref-db database --model-dir database/model/dbscan_D7_refine --microreact --info-csv heatmap_data_20210803.csv --output microreact/heatmap_dbscan_D7_refine_20210803 --threads 4

Describe the bug When a long path was given to the argument --model-dir, an error arose: FileNotFoundError: [Errno 2] No such file or directory: 'dbscan_D7_refine/dbscan_D7_refine_clusters.csv'. The script finished correctly after cd to database/model. In other words, command poppunk_visualise --ref-db database --model-dir dbscan_D7_refine --microreact --info-csv heatmap_data_20210803.csv --output microreact/heatmap_dbscan_D7_refine_20210803 --threads 4 worked for me.

My file structure: $Home ---- database/ -------- database.h5 -------- model/ ------------- dbscan_D7_refine/ ----------------- dbscan_D7_refine_clusters.csv

Complete error message:

Graph-tools OpenMP parallelisation enabled: with 4 threads
PopPUNK: visualise
Loading previously refined model
Completed model loading
Traceback (most recent call last):
  File "/home/yu/anaconda3/envs/poppunk/bin/poppunk_visualise", line 11, in <module>
    sys.exit(main())
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/PopPUNK/visualise.py", line 452, in main
    generate_visualisations(args.query_db,
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/PopPUNK/visualise.py", line 328, in generate_visualisations
    isolateClustering = readIsolateTypeFromCsv(prev_clustering,
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/PopPUNK/utils.py", line 346, in readIsolateTypeFromCsv
    clustersCsv = pd.read_csv(clustCSV, index_col = 0, quotechar='"')
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 586, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 482, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 811, in __init__
    self._engine = self._make_engine(self.engine)
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1040, in _make_engine
    return mapping[engine](self.f, **self.options)  # type: ignore[call-arg]
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/pandas/io/parsers/c_parser_wrapper.py", line 51, in __init__
    self._open_handles(src, kwds)
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/pandas/io/parsers/base_parser.py", line 222, in _open_handles
    self.handles = get_handle(
  File "/home/yu/anaconda3/envs/poppunk/lib/python3.9/site-packages/pandas/io/common.py", line 701, in get_handle
    handle = open(
FileNotFoundError: [Errno 2] No such file or directory: 'dbscan_D7_refine/dbscan_D7_refine_clusters.csv'

Best wishes

nickjcroucher commented 3 years ago

Hi @wanyuac - there's a problem with getting the CSV path in the visualise script it seems - I would recommend providing the full path to the CSV with the --previous-clustering flag at the moment, and I'll put in a fix soon.

wanyuac commented 3 years ago

Thank you @nickjcroucher so much for solving my problem.

nickjcroucher commented 3 years ago

Fixed in e9d04e7.