Skip to content

Commit

Permalink
Update for more recent pybind11.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbaker committed Sep 9, 2024
1 parent 4569aae commit c6395d1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 0 additions & 4 deletions bioseq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import cbioseq
from cbioseq import *
#from .tax import get_taxid
#import bioseq.tax as tax
#import bioseq.decoders as decoders
#import bioseq.hattn as hattn
import bioseq.poa_util as poa_util
import bioseq.softmax as softmax
import bioseq.loaders as loaders
Expand Down
6 changes: 5 additions & 1 deletion bioseq/poa_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import networkx as nx
import torch
import pytorch_geometric as pyg

class FastxSeq:
trans = str.maketrans("U", "T")
Expand Down Expand Up @@ -61,6 +60,11 @@ def __init__(self, tok, emb_dim=128):

# Takes the output of bioseq.SequenceGraph().matrix() and creates the data for GAT
def embed_graph(self, mat):
try:
import pytorch_geometric as pyg
except ImportError:
print("Cannot import pytorch_geometric")
raise
x, data = self.to_x_data(mat)
return pyg.Data(x, data)

Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
linear_attention_transformer
fast_transformer_pytorch
einops
numpy
torch
x-transformers>=0.19
entmax
product-key-memory
local-attention
numpy
pybind11==2.7.1
feedback-transformer-pytorch
memcnn
e2cnn
pysam
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def cpp_flag(compiler):
raise RuntimeError('Unsupported compiler -- at least C++11 support '
'is needed!')

#full_gomp_path = subprocess.check_output("realpath `$CXX --print-file-name=libgomp.a`", shell=True).decode('utf-8')
full_gomp_path = subprocess.check_output("realpath `$CXX --print-file-name=libgomp.a`", shell=True).decode('utf-8').strip()

extra_compile_args = ['-march=native',
'-Wno-char-subscripts', '-Wno-unused-function', '-Wno-ignored-qualifiers',
Expand All @@ -54,7 +54,7 @@ def cpp_flag(compiler):
'-lz', '-fopenmp',
"-pipe", '-O0', '-DNDEBUG']

extra_link_opts = ["-fopenmp", "-lz", "-lgomp"]
extra_link_opts = ["-fopenmp", "-lz"]


class BuildExt(build_ext):
Expand Down Expand Up @@ -90,7 +90,7 @@ def build_extensions(self):
ext.extra_compile_args = opts
ext.extra_compile_args += extra_compile_args
ext.extra_link_args = link_opts + extra_link_opts
# ext.extra_objects = [full_gomp_path]
ext.extra_objects = [full_gomp_path, "spoa/lib/libspoa.a"]
build_ext.build_extensions(self)


Expand All @@ -104,7 +104,7 @@ def build_spoa():
__version__ = "0.1.8"
build_spoa()
include_dirs = [get_pybind_include(), get_pybind_include(True), "./", "spoa/include"]
ext_modules = [Extension("cbioseq", ["src/bioseq.cpp", "src/poa.cpp", "src/tokenize.cpp", "src/omp.cpp", 'src/fxstats.cpp'], include_dirs=include_dirs, language='c++', extra_objects=["spoa/lib/libspoa.a"])]
ext_modules = [Extension("cbioseq", ["src/bioseq.cpp", "src/poa.cpp", "src/tokenize.cpp", "src/omp.cpp", 'src/fxstats.cpp'], include_dirs=include_dirs, language='c++')]
setup(
name='bioseq',
version=__version__,
Expand Down
2 changes: 1 addition & 1 deletion src/poa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct SequenceGroup {
*destPtr++ = (edge.first << 32) >> 32;
*destPtr++ = edge.second;
}
matrixCOOPy = matrixCOOPy.reshape(std::vector<int64_t>{{static_cast<int64_t>(edges.size()), 3}});
matrixCOOPy.resize(std::vector<int64_t>{{static_cast<int64_t>(edges.size()), 3}});

std::transform(std::cbegin(bases), std::cend(bases), std::begin(bases), [&](const char base) -> char {return graph->decoder(base);});

Expand Down

0 comments on commit c6395d1

Please sign in to comment.