bedapub/besca

Warning when running bc.st.per_cell_normalize. Non execution of C script

Closed this issue · 3 comments

Hello,

There is a warning when running the per_cell_normalize function (See attached image)

image (3)

The warning comes from here:

def write__MMFILE( C_path, E, outpath):
    #check if executable is actually executable on the system
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
    if is_exe(C_path):
        #create a temporary file to pipe the output from io.mmwrite to
        f_in = BytesIO()
        
        #write out temporary matrix to created pipe
        io.mmwrite(target=f_in, a=E, precision = 2)

        from subprocess import run
        f_out = open(os.path.join(outpath, 'matrix.mtx'), "w")
        run([C_path, "-"], input=f_in.getvalue(), stdout=f_out)

        print('adata.X successfully written to matrix.mtx')

    else:
        MMFileFixedFormat().write(os.path.join(outpath, 'matrix.mtx'), a=E, precision = 2) 
        print('adata.X successfully written to matrix.mtx. \n Warning: could not use reformat script.')

So, something is missing/not working properly with the C_path, which by default comes from here:

    if C_path is None:
        C_path = pkg_resources.resource_filename('besca', 'export/reformat')

The warning seems not to be very relevant since the MMFileFixedFormat seems to be working properly and doing the job. However, it may be worthy to check why the C script is not running.

Best,
Alberto.

Hi @alberto-valdeolivas ,
the C is usually not running because by default it is not executable when you download the repo.

It was historically there for speed reason by MMFileFixedFormat should be fast enough on its own.
Did you experience additional issues ?

I would propose to only keep MMFileFixedFormat and get rid of the C script To reduce the complexity here.
@alberto-valdeolivas , @swalpe , @hatjek , what do you think?
do you have strong feelings against getting rid of the C exe ?

Hi @ajulienla !

This point was raised by Martin (If I remember correctly, he developed the C script and was surprised that it was not running ). I just posted it here to be aware and keep track.

In my opinion, MMFileFixedFormat does the work quite efficiently so we can get rid of the C script.

Fix in d1fe332 and dc85305