Skip to content

Commit

Permalink
bugfix/ganon build verbose mode (#139)
Browse files Browse the repository at this point in the history
* bug fix ganon build with verbose mode

* better code mutex
  • Loading branch information
pirovc authored Sep 15, 2020
1 parent 363075d commit 6fd4af9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# =============================================================================

cmake_minimum_required( VERSION 3.10 FATAL_ERROR )
project( ganon VERSION 0.3.0 LANGUAGES CXX )
project( ganon VERSION 0.3.1 LANGUAGES CXX )

# -----------------------------------------------------------------------------
# build setup
Expand Down
33 changes: 18 additions & 15 deletions src/ganon-build/GanonBuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,32 +246,35 @@ bool run( Config config )
}
catch ( seqan::Exception const& e )
{
mtx.lock();
std::scoped_lock lock( mtx );
std::cerr << "ERROR: Problems parsing the file: " << reference_file << "[" << e.what() << "]"
<< std::endl;
mtx.unlock();
}

for ( uint64_t i = 0; i < seqan::length( ids ); ++i )
{
stats.totalSeqsFile += 1;
if ( config.verbose && seqan::length( seqs[i] ) < config.kmer_size )
{ // sequence too small
mtx.lock();
std::cerr << "WARNING: sequence smaller than k-mer size"
<< " [" << ids[i] << "]" << std::endl;
mtx.unlock();
if ( seqan::length( seqs[i] ) < config.kmer_size )
{
if ( config.verbose )
{
std::scoped_lock lock( mtx );
std::cerr << "WARNING: sequence smaller than k-mer size"
<< " [" << ids[i] << "]" << std::endl;
}
stats.invalidSeqs += 1;
continue;
}
std::string cid = seqan::toCString( ids[i] );
std::string seqid = cid.substr( 0, cid.find( ' ' ) );
if ( config.verbose && seq_bin.count( seqid ) == 0 )
if ( seq_bin.count( seqid ) == 0 )
{
mtx.lock();
std::cerr << "WARNING: sequence not defined on seqid-bin-file"
<< " [" << seqid << "]" << std::endl;
mtx.unlock();
if ( config.verbose )
{
std::scoped_lock lock( mtx );
std::cerr << "WARNING: sequence not defined on seqid-bin-file"
<< " [" << seqid << "]" << std::endl;
}
stats.invalidSeqs += 1;
continue;
}
Expand Down Expand Up @@ -300,9 +303,9 @@ bool run( Config config )
detail::Seqs val = queue_refs.pop();
if ( val.seqid != "" )
{
for ( uint64_t i = 0; i < seq_bin[val.seqid].size(); i++ )
for ( uint64_t i = 0; i < seq_bin.at( val.seqid ).size(); i++ )
{
auto [fragstart, fragend, binid] = seq_bin[val.seqid][i];
auto [fragstart, fragend, binid] = seq_bin.at( val.seqid )[i];
// For infixes, we have to provide both the including start and the excluding end position.
// fragstart -1 to fix offset
// fragend -1+1 to fix offset and not exclude last position
Expand Down
2 changes: 1 addition & 1 deletion src/ganon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Config:

version = '0.3.0'
version = '0.3.1'
path_exec = {'build': "", 'classify': "", 'get_len_taxid': ""}
empty = False

Expand Down

0 comments on commit 6fd4af9

Please sign in to comment.