HiCAssembler
HiCAssembler copied to clipboard
object of type 'int' has no len() in Scaffolds.py _remove_weakest len(path)
One of my former colleague is trying to use HiCAssembler. He launched the following command:
assemble -m hic_corrected.h5 -o ./assembly_output --min_scaffold_length 10000 --bin_size 5000 --misassembly_zscore_threshold -1.0 --num_iterations 3 --num_processors 16 --fasta assembly.fa
And received this error:
Traceback (most recent call last):
File "/groups/bipaa/env/HiCExplorer_2.1.4/bin/assemble", line 312, in <module>
main(args)
File "/groups/bipaa/env/HiCExplorer_2.1.4/bin/assemble", line 306, in main
super_contigs = assembl.assemble_contigs()
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/hicassembler/HiCAssembler.py", line 201, in assemble_contigs
hub_solving_method='remove weakest')
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/hicassembler/Scaffolds.py", line 27, in wrapper
f_result = func(*args, **kwds)
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/hicassembler/Scaffolds.py", line 1803, in join_paths_max_span_tree
self._remove_weakest(nxG)
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/hicassembler/Scaffolds.py", line 2002, in _remove_weakest
if len(path) < 5:
TypeError: object of type 'int' has no len()
When checking the code of Scaffolds.py, between lines 1997 and 2006, I saw that path
is defined as the length of something, so it is an integer that of course doesn't have a length itself so if len(path) < 5:
is crashing.
# adj node is hub. In this case remove the node and the scaffold it belongs
# to from the graph
path = len(self.pg_base[node])
# only remove if the path is not longer than 5. Otherwise
# a quite large scaffold can be removed.
if len(path) < 5:
for node_id in path:
G.remove_node(node_id)
self._remove_bin_path(self.pg_base.node[node]['initial_path'], split_scaffolds=True)
continue
I told him to replace line 1999 of Scaffolds.py path = len(self.pg_base[node])
by path = self.pg_base[node]
. Then he received a different error:
Traceback (most recent call last):
File "/groups/bipaa/env/HiCExplorer_2.1.4/bin/assemble", line 312, in <module>
main(args)
File "/groups/bipaa/env/HiCExplorer_2.1.4/bin/assemble", line 306, in main
super_contigs = assembl.assemble_contigs()
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/hicassembler/HiCAssembler.py", line 201, in assemble_contigs
hub_solving_method='remove weakest')
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/hicassembler/Scaffolds.py", line 27, in wrapper
f_result = func(*args, **kwds)
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/hicassembler/Scaffolds.py", line 1803, in join_paths_max_span_tree
self._remove_weakest(nxG)
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/hicassembler/Scaffolds.py", line 1968, in _remove_weakest
adj_degree = sorted([(x, node_degree_mst[x]) for x in G.adj[node].keys()], key=lambda(k, v): v)[::-1]
File "/groups/bipaa/env/HiCExplorer_2.1.4/lib/python2.7/site-packages/networkx/classes/coreviews.py", line 81, in __getitem__
return AtlasView(self._atlas[name])
KeyError: 19322
He installed HiCAssembler and HiCExplorer with the following commands:
conda create -p /groups/bipaa/env/HiCExplorer_2.1.4 HiCExplorer=2.1.4 biopython=1.73 python=2.7
source activate /groups/bipaa/env/HiCExplorer_2.1.4
pip install hicassembler
Looks like a corner condition was reached and the code was not prepared to handle it. Path, in this case is a list of id, that define continuity of a sequence. It should not be an integer. I would need some sample data to debug that.
Ok, so path = len(self.pg_base[node])
should definitely be path = self.pg_base[node]
?
Corner would mean what? The following?
---o---------o
/ \
/ \
o-----o-----o-----o-----o-----o-----o
Any idea about the cause of this?
For the sample data you would need the whole h5 matrix + fasta?
Thanks a bunch for the answer.
@gtrichard Hi I also face this error. How you can fix it ?
I got the same error.
`INFO:Scaffolds:Entering join_paths_max_span_tree /public1/home/ruifeng/anaconda3/envs/hicexplorer/lib/python3.6/site-packages/scipy/sparse/compressed.py:742: SparseEfficiencyWarning: Changing the sparsity structure of a csr_matrix is expensive. lil_matrix is more efficient. SparseEfficiencyWarning) INFO:Scaffolds:320 hubs were found WARNING:Scaffolds:
Hub-hub contact for bin_id:20481 scaffold: scaffold_177_1 degree: 4 with bin_id: 20358 scaffold: scaffold_115/2_2 degree:4
############## these cases could introduce problems in the assembly. Thus, node is being removed from the graph. ##############
Traceback (most recent call last):
File "/public1/home/ruifeng/anaconda3/envs/hicexplorer/bin/assemble", line 312, in
Hi @gtrichard @wangxinbio, how did you solve it?
Hi @fidelram, is there any software update regarding this error?
Thanks!
I didn't solve it.
Has someone solved this issue?
@gtrichard you did solve it in the end, thank you for the comment, that was the solution, cheers