pyfastani
pyfastani copied to clipboard
mapper.query_sequence doesn't exist
When I run the sample code:
import pyfastani
import Bio.SeqIO
sketch = pyfastani.Sketch()
# add a single draft genome to the mapper, and index it
ref = list(
Bio.SeqIO.parse(
"/Users/ahmadian/Documents/projects/pani/data/Shigella_flexneri_2a_01.fna",
"fasta",
)
)
sketch.add_draft("S. flexneri", (bytes(record.seq) for record in ref))
# index the sketch and get a mapper
mapper = sketch.index()
# read the query and query the mapper
query = Bio.SeqIO.read(
"/Users/ahmadian/Documents/projects/pani/data/Escherichia_coli_str_K12_MG1655.fna",
"fasta",
)
hits = mapper.query_sequence(bytes(query.seq))
for hit in hits:
print("E. coli K12 MG1655", hit.name, hit.identity, hit.matches, hit.fragments)
I receive this error:
AttributeError Traceback (most recent call last)
Cell In[6], [line 23](vscode-notebook-cell:?execution_count=6&line=23)
18 # read the query and query the mapper
19 query = Bio.SeqIO.read(
20 "/Users/ahmadian/Documents/projects/pani/data/Escherichia_coli_str_K12_MG1655.fna",
21 "fasta",
22 )
---> [23](vscode-notebook-cell:?execution_count=6&line=23) hits = mapper.query_sequence(bytes(query.seq))
25 for hit in hits:
26 print("E. coli K12 MG1655", hit.name, hit.identity, hit.matches, hit.fragments)
AttributeError: 'pyfastani._fastani.Mapper' object has no attribute 'query_sequence'
Ah I forgot to update the example 🙈 You should use mapper.query_genome instead!