Skip to content

Commit

Permalink
Azure: fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
jwcodee committed Aug 6, 2019
2 parents b588402 + 0bf248f commit d1c440a
Show file tree
Hide file tree
Showing 121 changed files with 23,366 additions and 2,711 deletions.
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ jobs:
./configure CC=gcc-8 CXX=g++-8 --with-mpi=/usr/lib/openmpi
- run: make -j12 distcheck

clang-format:
docker:
- image: *docker_image
steps:
- run: *install_common
- run: |
apt-get install --yes --force-yes sudo
sudo apt-get install --yes --force-yes curl
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main"
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang-format-8
sudo ln -s clang-format-8 /usr/bin/clang-format
- checkout
- run: |
./autogen.sh
./configure
- run: make clang-format

workflows:
version: 2
abyss_builds:
Expand All @@ -85,3 +104,4 @@ workflows:
- linux_gcc6
- linux_gcc5
- linux_clang6
- clang-format
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BasedOnStyle: Mozilla
AlignAfterOpenBracket: AlwaysBreak
AlignOperands: true
ColumnLimit: 100
ContinuationIndentWidth: 4
IndentCaseLabels: false
IndentWidth: 4
TabWidth: 4
UseTab: ForIndentation
5 changes: 4 additions & 1 deletion Assembly/Options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ using namespace std;

#define PROGRAM "ABYSS"

#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)

namespace opt {

static const char VERSION_MESSAGE[] =
Expand Down Expand Up @@ -48,7 +51,7 @@ static const char USAGE_MESSAGE[] =
" --SS assemble in strand-specific mode\n"
" --no-SS do not assemble in strand-specific mode\n"
" -o, --out=FILE write the contigs to FILE\n"
" -k, --kmer=N the length of a k-mer (when -K is not set)\n"
" -k, --kmer=N the length of a k-mer (when -K is not set) [<=" STR(MAX_KMER) "]\n"
" or the span of a k-mer pair (when -K is set)\n"
" -K, --single-kmer=N the length of a single k-mer in a k-mer pair\n"
" -t, --trim-length=N maximum length of blunt contigs to trim [k]\n"
Expand Down
21 changes: 5 additions & 16 deletions Bloom/Bloom.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@ namespace Bloom {
/** Print a progress message after loading this many seqs */
static const unsigned LOAD_PROGRESS_STEP = 100000;
/** file format version number */
static const unsigned BLOOM_VERSION = 4;
static const unsigned BLOOM_VERSION = 5;

/** Return the hash value of this object. */
inline static size_t hash(const key_type& key)
{
if (key.isCanonical())
return hashmem(&key, sizeof key);
return hashmem(&key, key.bytes());

key_type copy(key);
copy.reverseComplement();
return hashmem(&copy, sizeof copy, 0);
return hashmem(&copy, copy.bytes(), 0);
}

/** Return the hash value of this object given seed. */
inline static size_t hash(const key_type& key, size_t seed)
{
if (key.isCanonical())
return hashmem(&key, sizeof key, seed);
return hashmem(&key, key.bytes(), seed);

key_type copy(key);
copy.reverseComplement();
return hashmem(&copy, sizeof copy, seed);
return hashmem(&copy, copy.bytes(), seed);
}

template <typename BF>
Expand Down Expand Up @@ -190,17 +190,6 @@ namespace Bloom {
return header;
}

//TODO: Bloom filter calculation methods
//static double calcApproxFPR(size_t numBucket, size_t numEntr,
// unsigned numHash) const;
//static double calcRedunancyFPR(size_t numBucket, size_t numEntr,
// unsigned numHash) const;
//static size_t calcOptimalSize(size_t numEle, double fpr) const;
//static size_t calcOptimalSize(size_t numEle, double fpr,
// unsigned numHash) const;
//static unsigned calcOptimalNumHash(double fpr);
//static unsigned calcOptimalNumHash(size_t numBucket, size_t numEle);

};

#endif /* BLOOM_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef HASH_AGNOSTIC_CASCADING_BLOOM_H
#define HASH_AGNOSTIC_CASCADING_BLOOM_H 1

#include "lib/bloomfilter/BloomFilter.hpp"
#include "vendor/btl_bloomfilter/BloomFilter.hpp"
#include <vector>

/**
Expand All @@ -26,9 +26,11 @@
class HashAgnosticCascadingBloom
{
public:

/** Default constructor */
HashAgnosticCascadingBloom() : m_k(0), m_hashes(0) {}
HashAgnosticCascadingBloom()
: m_k(0)
, m_hashes(0)
{}

/**
* Constructor.
Expand All @@ -37,8 +39,9 @@ class HashAgnosticCascadingBloom
* @param levels number of levels in Cascading Bloom filter
* @param k k-mer size
*/
HashAgnosticCascadingBloom(size_t size, unsigned hashes,
size_t levels, unsigned k) : m_k(k), m_hashes(hashes)
HashAgnosticCascadingBloom(size_t size, unsigned hashes, size_t levels, unsigned k)
: m_k(k)
, m_hashes(hashes)
{
m_data.reserve(levels);
for (unsigned i = 0; i < levels; i++)
Expand All @@ -50,16 +53,10 @@ class HashAgnosticCascadingBloom
* files. This is used to make BloomFilter support the
* same interface as HashAgnosticCascadingBloom.
*/
HashAgnosticCascadingBloom(const string& bloomPath)
{
loadFilter(bloomPath);
}
HashAgnosticCascadingBloom(const string& bloomPath) { loadFilter(bloomPath); }

/** Destructor */
~HashAgnosticCascadingBloom()
{
clear();
}
~HashAgnosticCascadingBloom() { clear(); }

/** Return k-mer size used by Bloom filter. */
unsigned getKmerSize() const { return m_k; }
Expand All @@ -74,6 +71,9 @@ class HashAgnosticCascadingBloom
return m_data.back()->getFilterSize();
}

/** Return the size of the bit array. */
size_t getFilterSize() const { return size(); }

/** Return the number of elements with count >= levels. */
size_t popcount() const
{
Expand All @@ -82,16 +82,10 @@ class HashAgnosticCascadingBloom
}

/** Return number of levels in cascading Bloom filter */
unsigned levels() const
{
return m_data.size();
}
unsigned levels() const { return m_data.size(); }

/** Return the estimated false positive rate */
double FPR() const
{
return pow((double)popcount()/size(), m_hashes);
}
double FPR() const { return pow((double)popcount() / size(), m_hashes); }

/**
* Return true if the element with the given hash values
Expand Down Expand Up @@ -145,8 +139,7 @@ class HashAgnosticCascadingBloom
}

/** Operator for writing the Bloom filter to a stream */
friend std::ostream& operator<<(std::ostream& out,
const HashAgnosticCascadingBloom& o)
friend std::ostream& operator<<(std::ostream& out, const HashAgnosticCascadingBloom& o)
{
assert(o.m_data.size() > 0);
assert(o.m_data.back() != NULL);
Expand All @@ -166,7 +159,6 @@ class HashAgnosticCascadingBloom
}

private:

/** Free all allocated memory and reset parameters to defaults */
void clear()
{
Expand Down
6 changes: 4 additions & 2 deletions Bloom/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ bin_PROGRAMS = abyss-bloom

abyss_bloom_CPPFLAGS = -I$(top_srcdir) \
-I$(top_srcdir)/Common \
-I$(top_srcdir)/DataLayer
-I$(top_srcdir)/DataLayer \
-I$(top_srcdir)/vendor

abyss_bloom_CXXFLAGS = $(AM_CXXFLAGS) $(OPENMP_CXXFLAGS)

Expand All @@ -18,4 +19,5 @@ abyss_bloom_SOURCES = bloom.cc \
ConcurrentBloomFilter.h \
CascadingBloomFilter.h \
CascadingBloomFilterWindow.h \
RollingBloomDBGVisitor.h
RollingBloomDBGVisitor.h \
HashAgnosticCascadingBloom.h
66 changes: 42 additions & 24 deletions Bloom/RollingBloomDBGVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#define _ROLLING_BLOOM_DBG_VISITOR_H_ 1

#include "Common/UnorderedMap.h"
#include "Common/UnorderedSet.h"
#include "Graph/BreadthFirstSearch.h"
#include "vendor/btl_bloomfilter/BloomFilter.hpp"

#include <iostream>

Expand All @@ -11,32 +13,44 @@
* a bounded breadth first traversal. An instance of this class may be passed
* as an argument to the `breadthFirstSearch` function.
*/
template <typename GraphT>
template<typename GraphT>
class RollingBloomDBGVisitor : public DefaultBFSVisitor<GraphT>
{
public:

public:
typedef typename boost::graph_traits<GraphT>::vertex_descriptor VertexT;
typedef typename boost::graph_traits<GraphT>::edge_descriptor EdgeT;

typedef unordered_map<VertexT, unsigned> DepthMap;
typedef typename DepthMap::const_iterator DepthMapConstIt;
typedef typename DepthMap::iterator DepthMapIt;

typedef std::vector<std::pair<std::string, unordered_set<VertexT> > >
KmerProperties;
typedef std::vector<std::pair<std::string, unordered_set<VertexT>>> KmerProperties;
typedef typename KmerProperties::const_iterator KmerPropertiesIt;

typedef std::vector<std::pair<std::string, BloomFilter*>> BloomProperties;
typedef typename BloomProperties::const_iterator BloomPropertiesIt;

/** Constructor */
RollingBloomDBGVisitor(const VertexT& root, unsigned maxDepth,
const KmerProperties& kmerProperties, std::ostream& out)
: m_root(root), m_maxDepth(maxDepth),
m_kmerProperties(kmerProperties), m_out(out)
template<typename VertexSetT>
RollingBloomDBGVisitor(
const VertexSetT& roots,
unsigned maxDepth,
const KmerProperties& kmerProperties,
const BloomProperties& bloomProperties,
std::ostream& out)
: m_maxDepth(maxDepth)
, m_kmerProperties(kmerProperties)
, m_bloomProperties(bloomProperties)
, m_out(out)
{
m_depthMap[root] = 0;
typedef typename VertexSetT::const_iterator RootIt;

for (RootIt it = roots.begin(); it != roots.end(); ++it)
m_depthMap[*it] = 0;

/* start directed graph (GraphViz) */
m_out << "digraph " << root.kmer().c_str() << " {\n";
m_out << "digraph "
<< " {\n";
}

/** Called when graph search completes */
Expand Down Expand Up @@ -64,8 +78,7 @@ class RollingBloomDBGVisitor : public DefaultBFSVisitor<GraphT>

DepthMapIt childIt;
bool inserted;
boost::tie(childIt, inserted) = m_depthMap.insert(
std::make_pair(child, parentDepth + 1));
boost::tie(childIt, inserted) = m_depthMap.insert(std::make_pair(child, parentDepth + 1));
assert(inserted);

/*
Expand All @@ -90,13 +103,22 @@ class RollingBloomDBGVisitor : public DefaultBFSVisitor<GraphT>
assert(depthIt != m_depthMap.end());
unsigned depth = depthIt->second;

m_out << "depth=" << depth;
m_out << "depth=" << depth;

for (KmerPropertiesIt it = m_kmerProperties.begin();
it != m_kmerProperties.end(); ++it) {
for (KmerPropertiesIt it = m_kmerProperties.begin(); it != m_kmerProperties.end(); ++it) {
if (it->second.find(v) != it->second.end())
m_out << "," << it->first;
}

size_t hashes[MAX_HASHES];
v.rollingHash().getHashes(hashes);

for (BloomPropertiesIt it = m_bloomProperties.begin(); it != m_bloomProperties.end();
++it) {
if (it->second->contains(hashes))
m_out << "," << it->first;
}

m_out << "];\n";

return BFS_SUCCESS;
Expand Down Expand Up @@ -126,8 +148,7 @@ class RollingBloomDBGVisitor : public DefaultBFSVisitor<GraphT>
/** Return if the current edge is a forward edge */
bool isForwardEdge(const EdgeT& e, const GraphT& g)
{
assert(source(e, g) == m_currentVertex
|| target(e, g) == m_currentVertex);
assert(source(e, g) == m_currentVertex || target(e, g) == m_currentVertex);
return source(e, g) == m_currentVertex;
}

Expand All @@ -138,20 +159,17 @@ class RollingBloomDBGVisitor : public DefaultBFSVisitor<GraphT>
const VertexT& v = target(e, g);

/* declare edge (GraphViz) */
m_out << '\t' << u.kmer().c_str() << " -> "
<< v.kmer().c_str() << ";\n";
m_out << '\t' << u.kmer().c_str() << " -> " << v.kmer().c_str() << ";\n";
}

protected:

protected:
VertexT m_currentVertex;
DepthMap m_depthMap;

const VertexT& m_root;
const unsigned m_maxDepth;
const KmerProperties& m_kmerProperties;
const BloomProperties& m_bloomProperties;
std::ostream& m_out;
};


#endif
Loading

0 comments on commit d1c440a

Please sign in to comment.