tanlongzhi / dip-c

Tools to analyze Dip-C (or other 3C/Hi-C) data
61 stars 18 forks source link

'str' error when convert 3dg file to cif file #55

Closed Xuyuch closed 1 year ago

Xuyuch commented 1 year ago

Hi @tanlongzhi
Thanks for your powerful hickit and dip-c package. It is great. I met the same problem as issue3 when I tried to convert my .3dg file to a cif file using this code dip-c color -n color/hg19.chr.txt cell.3dg | dip-c vis -c /dev/stdin cell.3dg > cell.n.cif And get an error like

python ./dip-c/dip-c color -n hg19.chr.txt clear_pbmc.3dg
Traceback (most recent call last):
  File ".../dip-c", line 130, in <module>
    main()
  File ".../dip-c/dip-c", line 75, in main
    return_value = color.color(sys.argv[1:])
  File ".../dip-c/color.py", line 218, in color
    g3d_data = file_to_g3d_data(open(args[0], "rb"))
  File ".../dip-c/classes.py", line 1427, in file_to_g3d_data
    g3d_data.add_g3d_particle(string_to_g3d_particle(g3d_file_line.strip()))
  File ".../dip-c/classes.py", line 1214, in string_to_g3d_particle
    hom_name, ref_locus, x, y, z = g3d_particle_string.split("\t")
TypeError: a bytes-like object is required, not 'str'

I have already used the grep -v "^#" hickit.3dg ' > dip-c.3dg code to delete the headers and I am using diploid data. I try to use NXT-43.250kb.hickit.3dg.zip from tarak77 to figure out the problem. After using his file and grep -v "^#" hickit.3dg | awk -F'[\t,]' -v OFS='\t' '{print $1 "(pat)",$2,$3,$4,$5}' > dip-c.3dg. I still get the same error. I also download the Dip-c original dataset from GSM3271347 and process the "GSM3271347_gm12878_01.impute3.round4.clean.3dg.txt.gz" file to figure out the issue and the problem still exists when I want to convert this file to a cif file.

 python ./dip-c/dip-c color -n hg19.chr.txt impute3.round4.clean.3dg.txt
Traceback (most recent call last):
  File "../dip-c/dip-c", line 130, in <module>
    main()
  File ".../dip-c/dip-c", line 75, in main
    return_value = color.color(sys.argv[1:])
  File ".../dip-c/color.py", line 218, in color
    g3d_data = file_to_g3d_data(open(args[0], "rb"))
  File ".../dip-c/classes.py", line 1427, in file_to_g3d_data
    g3d_data.add_g3d_particle(string_to_g3d_particle(g3d_file_line.strip()))
  File ".../dip-c/classes.py", line 1214, in string_to_g3d_particle
    hom_name, ref_locus, x, y, z = g3d_particle_string.split("\t")
TypeError: a bytes-like object is required, not 'str'

Could you please help me with that? Any kind of help is really appreciated. Wish you a great day.

Xuyuch commented 1 year ago

Problem solved. It is because the version of Python I used is Python3 instead of Python 2.7.1. After changing python3 to python2, it works properly.