Skip to content

AttributeError("'PyCall.jlwrap' object has no attribute 'encode'") #917

Closed
@TheBiotech42

Description

@TheBiotech42

I am trying to send a string to the module mappy but I get this error: AttributeError("'PyCall.jlwrap' object has no attribute 'encode'"). I am using julia 1.4.

Here is my code:

using PyCall
using FASTX
using CodecZlib

py"""
import mappy as mp

def aligner(name,preset,threads):
    aligner = mp.Aligner(name,preset=preset,n_threads = threads)
    return aligner

def mappy(seq,aligner):
    try:
        line = next(aligner.map(seq))
        return False
    except StopIteration:
        return True
"""
aligner = py"aligner"("genome.idx","sr",4)
for record in FASTQ.Reader(GzipDecompressorStream(open("data_file.fastq.gz")))
    check = py"mappy"(sequence(record),aligner)
    
end
close(reader)

Here is the error:

ERROR: LoadError: PyError ($(Expr(:escape, :(ccall(#= /home/cedric/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'AttributeError'>
AttributeError("'PyCall.jlwrap' object has no attribute 'encode'")
  File "/home/cedric/.julia/packages/PyCall/BD546/src/pyeval.jl", line 9, in mappy
    if m === Main
  File "python/mappy.pyx", line 184, in map

Stacktrace:
 [1] pyerr_check at /home/cedric/.julia/packages/PyCall/BD546/src/exception.jl:62 [inlined]
 [2] pyerr_check at /home/cedric/.julia/packages/PyCall/BD546/src/exception.jl:66 [inlined]
 [3] _handle_error(::String) at /home/cedric/.julia/packages/PyCall/BD546/src/exception.jl:83
 [4] macro expansion at /home/cedric/.julia/packages/PyCall/BD546/src/exception.jl:97 [inlined]
 [5] #107 at /home/cedric/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 [inlined]
 [6] disable_sigint at ./c.jl:446 [inlined]
 [7] __pycall! at /home/cedric/.julia/packages/PyCall/BD546/src/pyfncall.jl:42 [inlined]
 [8] _pycall!(::PyObject, ::PyObject, ::Tuple{BioSequences.LongSequence{BioSequences.DNAAlphabet{4}},PyObject}, ::Int64, ::Ptr{Nothing}) at /home/cedric/.julia/packages/PyCall/BD546/src/pyfncall.jl:29
 [9] _pycall!(::PyObject, ::PyObject, ::Tuple{BioSequences.LongSequence{BioSequences.DNAAlphabet{4}},PyObject}, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/cedric/.julia/packages/PyCall/BD546/src/pyfncall.jl:11
 [10] (::PyObject)(::BioSequences.LongSequence{BioSequences.DNAAlphabet{4}}, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/cedric/.julia/packages/PyCall/BD546/src/pyfncall.jl:86
 [11] (::PyObject)(::BioSequences.LongSequence{BioSequences.DNAAlphabet{4}}, ::Vararg{Any,N} where N) at /home/cedric/.julia/packages/PyCall/BD546/src/pyfncall.jl:86
 [12] top-level scope at /home/cedric/julia_fasto/fastolyse.jl:32
 [13] include(::Module, ::String) at ./Base.jl:377
 [14] exec_options(::Base.JLOptions) at ./client.jl:288
 [15] _start() at ./client.jl:484
in expression starting at /home/cedric/julia_fasto/fastolyse.jl:31

thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions