Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error with add_annotation_from_dat.py #3

Open
Wanliwill opened this issue Jun 9, 2023 · 4 comments
Open

error with add_annotation_from_dat.py #3

Wanliwill opened this issue Jun 9, 2023 · 4 comments

Comments

@Wanliwill
Copy link

Hi,
When I run :python add_annotation_from_dat.py expanded_dup.blastp.best uniprot_plants.dat
there is such an error:
Traceback (most recent call last):
File "add_annotation_from_dat.py", line 22, in
GO_RECORD = re.findall(r"GO; (GO:\d+); ([F|P|C]):.?; (.):",record)
File "/pub/anaconda3/envs/py36/lib/python3.6/re.py", line 222, in findall
return _compile(pattern, flags).findall(string)
TypeError: cannot use a string pattern on a bytes-like object

I do not know what is wrong, please help, thank you very much

@lin0yuan
Copy link

Hi, I also got a similar error message when I run "python3 add_annotation_from_dat.py BRA1306.matches.m6.best uniprot_invertebrates.dat"

Traceback (most recent call last):
File "add_annotation_from_dat.py", line 22, in
GO_RECORD = re.findall(r"GO; (GO:\d+); ([F|P|C]):.?; (.):",record)
File "/usr/lib/python3.8/re.py", line 241, in findall
return _compile(pattern, flags).findall(string)
TypeError: cannot use a string pattern on a bytes-like object

Would you mind giving some suggestions? Thanks a lot!

@Wanliwill
Copy link
Author

I don't know how to solve it either, and I eventually gave up using this script.

@lin0yuan
Copy link

lin0yuan commented Jun 29, 2023

Hi there @Wanliwill, I successfully got rid of the error by adding a line "record = record.decode(‘utf-8’)". Maybe you can have a try.

if not uniprot.get(acc.strip(";")):
    continue
record = uniprot.get_raw(acc.strip(";"))

# need to add a command here to tackle with the unicode string inconsistency between python2 and python3
record = record.decode(‘utf-8’)

GO_RECORD = re.findall(r"GO; (GO:\d+); ([F|P|C]):.*?; (.*):",record)

@Wanliwill
Copy link
Author

Great. I'll give it a try. Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants