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

import rmatspipeline: ImportError: rmats_turbo_v4_3_0/rmatspipeline.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNK8BamTools12BamAlignment10GetTagTypeERKSsRc #390

Open
danli349 opened this issue Mar 28, 2024 · 4 comments

Comments

@danli349
Copy link

danli349 commented Mar 28, 2024

Hello

I installed rMATS by ./build_rmats --conda, and activate the rMATS conda evironment

$conda activate /home/lid/rmats_turbo_v4_3_0/conda_envs/rmats
$ls
bamtools                            Dockerfile                           python_conda_requirements.txt                  rMATS_R
build_rmats                         docs                                 README.md                                      run_rmats
conda_envs                          install_r_deps.R                     rMATS_C                                        setup_environment.sh
conda_requirements.txt              LICENSE                              rMATS_P                                        test_rmats
cp_with_prefix.py                   Makefile                             rMATS_pipeline                                 tests
DARTS                               PAIRADISE                            rmatspipeline.cpython-310-x86_64-linux-gnu.so

But python can't import rmatspipeline:

$python
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rmatspipeline
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /lila/home/lid/rmats_turbo_v4_3_0/rmatspipeline.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNK8BamTools12BamAlignment10GetTagTypeERKSsRc
>>>

How should I solve this problem?
Thanks

@EricKutschera
Copy link
Contributor

undefined symbol: _ZNK8BamTools12BamAlignment10GetTagTypeERKSsRc was also reported in this post: #30

The user didn't reply, but I think the error was due to different compilers being used for building bamtools and then building rmatspipeline similar to this older post: #21 (comment)

The build sets compiler environment variables based on the gfortran, gcc, and g++ it finds: https://github.com/Xinglab/rmats-turbo/blob/v4.3.0/build_rmats#L71

Potentially this issue could happen if ./build_rmats is run multiple times for example with and without --conda

Can you try running from a fresh copy of the source code? The build output should show which compilers are being used

@danli349
Copy link
Author

danli349 commented Apr 2, 2024

@EricKutschera
I delete the old install folder rmats_turbo_v4_3_0, and unzip the file rmats_turbo_v4_3_0.tar.gz and run ./build_rmats --conda again in my base environment:

...
installing to ~/rmats_turbo_v4_3_0/conda_envs/rmats/lib/R/library/00LOCK-Darts/00new/Darts/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (Darts)
Loading required package: Darts
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘Darts’

Then the build stopped and the bash is out of the base environment.
Then I source ~/.bashrc to enter the base environment, run
conda activate ~/rmats_turbo_v4_3_0/conda_envs/rmats to enter the rmats environment, and run R, I found all the dependent R packages are installed:

$which R
~/rmats_turbo_v4_3_0/conda_envs/rmats/bin/R
> library(Darts)
> library(PAIRADISE)
Loading required package: nloptr
Loading required package: doParallel
Loading required package: foreach
Loading required package: iterators
Loading required package: parallel
> library(Matrix)
> library(mixtools)
mixtools package, version 2.0.0, Released 2022-12-04
This package is based upon work supported by the National Science Foundation under Grant No. SES-0518772 and the Chan Zuckerberg Initiative: Essential Open Source Software for Science (Grant No. 2020-255193).

and the python ImportError still exists:

$which python
~/rmats_turbo_v4_3_0/conda_envs/rmats/bin/python 

$python rmats.py
Traceback (most recent call last):
  File "/lila/data/chen/dan/bin/rmats_turbo_v4_3_0/rmats.py", line 19, in <module>
    from rmatspipeline import run_pipe
ImportError: /lila/data/chen/dan/bin/rmats_turbo_v4_3_0/rmatspipeline.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNK8BamTools12BamAlignment10GetTagTypeERKSsRc

@EricKutschera
Copy link
Contributor

I think the error undefined symbol: _ZNK8BamTools12BamAlignment10GetTagTypeERKSsRc could happen if there was an error during the bamtools compile step or the rmatspipeline cython compile step or if different compilers were used for bamtools and cython. Can you post the full output from ./build_rmats? Specifically I think there may be error messages or it will show different compiler versions. My output includes these lines:

-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /scr1/users/kutscherae/rmats-turbo/tmp_del/rmats_turbo_v4_3_0/conda_envs/rmats/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /scr1/users/kutscherae/rmats-turbo/tmp_del/rmats_turbo_v4_3_0/conda_envs/rmats/bin/g++ - skipped

That is the expected behavior where gcc and g++ are the same version (13.2.0) and both found in conda_envs/rmats/

Can you also post the output of these commands:

readelf --all --wide ./bamtools/lib/libbamtools.a | grep GetTagType
readelf --all --wide ./rmatspipeline*.so | grep GetTagType

My output shows _ZNK8BamTools12BamAlignment10GetTagTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERc in both files:

readelf --all --wide ./bamtools/lib/libbamtools.a | grep GetTagType
    21: 000000000000011e    48 FUNC    LOCAL  DEFAULT    9 _ZNK8BamTools12BamAlignment10GetTagTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERc.cold
    99: 00000000000019d0   603 FUNC    GLOBAL DEFAULT    5 _ZNK8BamTools12BamAlignment10GetTagTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERc

readelf --all --wide ./rmatspipeline*.so | grep GetTagType
000000000012c1a8  000003f400000007 R_X86_64_JUMP_SLOT     00000000000ccd70 _ZNK8BamTools12BamAlignment10GetTagTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERc + 0
  1012: 00000000000ccd70   603 FUNC    GLOBAL DEFAULT   12 _ZNK8BamTools12BamAlignment10GetTagTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERc
   657: 0000000000034c02    48 FUNC    LOCAL  DEFAULT   12 _ZNK8BamTools12BamAlignment10GetTagTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERc.cold
  2093: 00000000000ccd70   603 FUNC    GLOBAL DEFAULT   12 _ZNK8BamTools12BamAlignment10GetTagTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERc

The build specifies the location of the bamtools library for the cython compile step: https://github.com/Xinglab/rmats-turbo/blob/v4.3.0/rMATS_pipeline/setup.py#L9

If your readelf commands show consistent function names then maybe the build somehow found some other version of the bamtools library on your system due to environment variables

@danli349
Copy link
Author

danli349 commented Apr 3, 2024

@EricKutschera
I commented out gcc and gfortran in my .bashrc file, and reinstall, then this error disappeared

#export CC=/bin/gcc
#export FC=/bin/gfortran
python rmats.py
ERROR: BAM/FASTQ required. Please check b1, b2, s1 and s2.

@danli349 danli349 changed the title import rmatspipeline: ImportError: /lila/home/lid/rmats_turbo_v4_3_0/rmatspipeline.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNK8BamTools12BamAlignment10GetTagTypeERKSsRc import rmatspipeline: ImportError: rmats_turbo_v4_3_0/rmatspipeline.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNK8BamTools12BamAlignment10GetTagTypeERKSsRc Apr 3, 2024
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