ythuang0522 / homopolish

High-quality Nanopore-only genome polisher
GNU General Public License v3.0
65 stars 12 forks source link

Creating debug folders impossible if '/' present in the FASTA header #31

Closed cchapus closed 3 years ago

cchapus commented 3 years ago

System : tried on a workstation with Ubuntu 20.04 LTS and a computer using a CentOS 7 WSL

Installation method:

git clone https://github.com/ythuang0522/homopolish.git cd homopolish conda env create -f environment.yml conda activate homopolish

Results: Installation successful.

Command used:

python3 homopolish.py polish -a /pth_seq/CoVID_trom_artic.consensus.fasta -l /path_DB/custom_CoVID_DB.fasta -m R9.4.pkl -o test2 --minimap_args asm10

Error Obtained:

[2021/05/03 10:45] INFO: RUN-ID: ID_SEQ/ARTIC/medaka Traceback (most recent call last): File "homopolish.py", line 55, in main() File "homopolish.py", line 41, in main FLAGS.output_dir, FLAGS.minimap_args, FLAGS.mash_threshold, FLAGS.download_contig_nums, FLAGS.debug, FLAGS.meta, FLAGS.local_DB_path) File "/path_homopolish/homopolish/modules/polish_interface.py", line 308, in polish_genome out = local_DB(out, assembly_name, output_dir_debug, mash_screen, assembly, model_path, sketch_path, genus_species, threads, output_dir, minimap_args, mash_threshold, download_contig_nums, debug, meta, local_DB_path) File "/path_homopolish/homopolish/modules/polish_interface.py", line 277, in local_DB contig_name, contig_output_dir = write_for_new_fasta(contig, output_dir_debug) File "/path_homopolish/homopolish/modules/polish_interface.py", line 114, in write_for_new_fasta SeqIO.write(contig, contig_name, "fasta") File "/home/XXXX/anaconda3/envs/homopolish/lib/python3.7/site-packages/Bio/SeqIO/init.py", line 551, in write with as_handle(handle, mode) as fp: File "/home/XXXX/anaconda3/envs/homopolish/lib/python3.7/contextlib.py", line 112, in enter return next(self.gen) File "/home/XXXX/anaconda3/envs/homopolish/lib/python3.7/site-packages/Bio/File.py", line 120, in as_handle with open(handleish, mode, **kwargs) as fp: FileNotFoundError: [Errno 2] No such file or directory: '/test2/debug/ID_SEQ/ARTIC/medaka/ID_SEQ/ARTIC/medaka.fasta'

Solution: Thought it was a "os.mkdir()" error. In fact, it's the FASTA format from ARTIC pipeline which return a FASTA name with "/". Homopolish doesn't like it. Correcting the header resolved the issues.

Perhaps add a check at the beginning to deal with these kind of names.

ythuang0522 commented 3 years ago

@cchapus Thank you for letting us know. Indeed we didn't expect the file separator "/" embedded in the file name. Will fix it in the next release. Thanks.

ythuang0522 commented 3 years ago

We have pushed a new version which replaced "/" with "_" in the contig IDs. Your problem should be solved.