Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pybedtools/include/fileType.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@
#include <unistd.h>
#include <sstream>

#if !defined(S_ISREG) && defined(_S_IFMT) && defined(_S_IFREG)
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#endif
#if !defined(S_ISDIR) && defined(_S_IFMT) && defined(_S_IFDIR)
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#endif

using namespace std;

/*****************************************************************************
Convenience functions to detect whether a given file is
Convenience functions to detect whether a given file is
"regular" and/or "gzipped".

Kindly contributed by Assaf Gordon.
******************************************************************************/
string string_error(int errnum);
Expand Down
39 changes: 38 additions & 1 deletion pybedtools/include/lineFileUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ std::string ToString(const T & value) {
return ss.str();
}

#ifndef _MSVC_LANG
// tokenize into a list of strings.
inline
void Tokenize(const string &str, vector<string> &elems, const string &delimiter = "\t")
void Tokenize(const string &str, vector<string> &elems, const string &delimiter = "\t")
{
char* tok;
char cchars [str.size()+1];
Expand All @@ -46,6 +47,42 @@ void Tokenize(const string &str, vector<int> &elems, const string &delimiter = "
tok = strtok(NULL, delimiter.c_str());
}
}
#else
inline void Tokenize(const string &str, vector<string> &tokens, const string &delimiter = "\t")
{
// Skip delimiters at beginning.
string::size_type lastPos = str.find_first_not_of(delimiter, 0);
// Find first "non-delimiter".
string::size_type pos = str.find_first_of(delimiter, lastPos);

while (string::npos != pos || string::npos != lastPos)
{
// Found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiter, pos);
// Find next "non-delimiter"
pos = str.find_first_of(delimiter, lastPos);
}
}
inline void Tokenize(const string &str, vector<int> &tokens, const string &delimiter = "\t")
{
// Skip delimiters at beginning.
string::size_type lastPos = str.find_first_not_of(delimiter, 0);
// Find first "non-delimiter".
string::size_type pos = str.find_first_of(delimiter, lastPos);

while (string::npos != pos || string::npos != lastPos)
{
// Found a token, add it to the vector.
tokens.push_back(atoi(str.substr(lastPos, pos - lastPos).c_str()));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiter, pos);
// Find next "non-delimiter"
pos = str.find_first_of(delimiter, lastPos);
}
}
#endif

#endif /* LINEFILEUTILITIES_H */

3 changes: 3 additions & 0 deletions requirements-win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
numpy
pandas
pysam @ "git+https://github.com/theAeon/pysam.git@pysam-mingw"
60 changes: 42 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,48 @@ def run(self):

EXT = '.pyx' if USE_CYTHON else '.cpp'

extensions = [
Extension(
'pybedtools.cbedtools',
depends=glob.glob('pybedtools/include/*h'),
libraries=['stdc++', 'z'],
include_dirs=['pybedtools/include/'],
sources=['pybedtools/cbedtools' + EXT] + sorted(glob.glob('pybedtools/include/*.cpp')),
language='c++'),

Extension(
'pybedtools.featurefuncs',
depends=glob.glob('pybedtools/include/*h'),
libraries=['stdc++', 'z'],
include_dirs=['pybedtools/include/'],
sources=['pybedtools/featurefuncs' + EXT] + sorted(glob.glob('pybedtools/include/*.cpp')),
language='c++'),
]

if sys.platform == "win32":
extensions = [
Extension(
'pybedtools.cbedtools',
depends=glob.glob('pybedtools/include/*h'),
library_dirs=[ os.environ.get("ZLIB_ROOT") + '/lib'],
libraries=['zlib'],
#extra_compile_args=["/std:c++17"],
include_dirs=['pybedtools/include/', os.environ.get("ZLIB_ROOT") + '/include', 'win32'],
sources=['pybedtools/cbedtools' + EXT] + sorted(glob.glob('pybedtools/include/*.cpp')),
language='c++'),

Extension(
'pybedtools.featurefuncs',
depends=glob.glob('pybedtools/include/*h'),
library_dirs=[ os.environ.get("ZLIB_ROOT") + '/lib'],
libraries=['zlib'],
include_dirs=['pybedtools/include/', os.environ.get("ZLIB_ROOT") + '/include', 'win32'],
sources=['pybedtools/featurefuncs' + EXT] + sorted(glob.glob('pybedtools/include/*.cpp')),
language='c++'),
]
else:
extensions = [
Extension(
"pybedtools.cbedtools",
depends=glob.glob("pybedtools/include/*h"),
libraries=["stdc++", "z"],
include_dirs=["pybedtools/include/"],
sources=["pybedtools/cbedtools" + EXT]
+ sorted(glob.glob("pybedtools/include/*.cpp")),
language="c++",
),
Extension(
"pybedtools.featurefuncs",
depends=glob.glob("pybedtools/include/*h"),
libraries=["stdc++", "z"],
include_dirs=["pybedtools/include/"],
sources=["pybedtools/featurefuncs" + EXT]
+ sorted(glob.glob("pybedtools/include/*.cpp")),
language="c++",
),
]

cmdclass = {
'clean': CleanCommand,
Expand Down
Loading
Loading