Skip to content

Commit

Permalink
disabled deep copying for cuffnorm
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrapnell committed May 6, 2014
1 parent 75617c9 commit 566ebd3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
5 changes: 4 additions & 1 deletion cufflinks.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = NO;
GCC_WARN_ABOUT_MISSING_NEWLINE = NO;
GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = NO;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_SHADOW = NO;
GCC_WARN_UNINITIALIZED_AUTOS = NO;
GCC_WARN_UNUSED_FUNCTION = NO;
Expand Down Expand Up @@ -2092,6 +2092,7 @@
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_UNROLL_LOOPS = YES;
GCC_VERSION = "";
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
HEADER_SEARCH_PATHS = (
/opt/local/include,
/usr/include,
Expand Down Expand Up @@ -2744,6 +2745,7 @@
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = NO;
HEADER_SEARCH_PATHS = (
/opt/local/include,
Expand Down Expand Up @@ -2783,6 +2785,7 @@
GCC_UNROLL_LOOPS = YES;
GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GENERATE_PROFILING_CODE = YES;
HEADER_SEARCH_PATHS = (
Expand Down
17 changes: 13 additions & 4 deletions src/bundles.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class BundleFactory
_rg_props = boost::shared_ptr<ReadGroupProperties>(new ReadGroupProperties(fac->read_group_properties()));
}

virtual ~BundleFactory() {}
boost::shared_ptr<const HitFactory> hit_factory() const { return _hit_fac; }

bool bundles_remain()
Expand Down Expand Up @@ -260,16 +261,24 @@ class BundleFactory
}

// This function NEEDS to deep copy the ref_mRNAs, otherwise cuffdiff'd
// samples will clobber each other
void set_ref_rnas(const vector<boost::shared_ptr<Scaffold> >& mRNAs)
// samples will clobber each other. Deep copying is necessary whenever
// you need to set fpkm or num fragments in Scaffold objects (e.g. during bias correction or multiread correction)
void set_ref_rnas(const vector<boost::shared_ptr<Scaffold> >& mRNAs, bool deep_copy = true)
{
#if ENABLE_THREADS
boost::mutex::scoped_lock lock(_factory_lock);
#endif
ref_mRNAs.clear();
for (vector<boost::shared_ptr<Scaffold> >::const_iterator i = mRNAs.begin(); i < mRNAs.end(); ++i)
if (deep_copy)
{
ref_mRNAs.push_back(boost::shared_ptr<Scaffold>(new Scaffold(**i)));
for (vector<boost::shared_ptr<Scaffold> >::const_iterator i = mRNAs.begin(); i < mRNAs.end(); ++i)
{
ref_mRNAs.push_back(boost::shared_ptr<Scaffold>(new Scaffold(**i)));
}
}
else
{
ref_mRNAs = mRNAs;
}

RefID last_id = 0;
Expand Down
5 changes: 4 additions & 1 deletion src/cuffnorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,10 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, FILE* contrast_file, FILE* norm_stand

BOOST_FOREACH (boost::shared_ptr<ReplicatedBundleFactory> fac, bundle_factories)
{
fac->set_ref_rnas(ref_mRNAs);
// NOTE: we aren't deep copying here to save memory. We can pull this off
// because unless bias correction or multiread correction is enabled,
// we don't need to write into Scaffold objects.
fac->set_ref_rnas(ref_mRNAs, false);
if (mask_gtf)
fac->set_mask_rnas(mask_rnas);
}
Expand Down
11 changes: 11 additions & 0 deletions src/differential.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ struct TestLauncher
{
}

virtual ~TestLauncher() {}

void operator()();

void register_locus(const string& locus_id);
Expand Down Expand Up @@ -239,6 +241,7 @@ class TrackingDataWriter : public TestLauncher
}
}
fprintf(fout, "\n");
fflush(fout);
}

void print_count_tracking_header(FILE* fout,
Expand All @@ -256,6 +259,7 @@ class TrackingDataWriter : public TestLauncher
}
}
fprintf(fout, "\n");
fflush(fout);
}

void print_FPKM_simple_table_header(FILE* fout,
Expand All @@ -277,6 +281,7 @@ class TrackingDataWriter : public TestLauncher
fprintf(fout, "\t%s_%d", condition_name.c_str(), rep_num);
}
}
fflush(fout);
}
}

Expand All @@ -299,6 +304,7 @@ class TrackingDataWriter : public TestLauncher
fprintf(fout, "\t%s_%d", condition_name.c_str(), rep_num);
}
}
fflush(fout);
}
}

Expand Down Expand Up @@ -380,6 +386,7 @@ class TrackingDataWriter : public TestLauncher
}

fprintf(fout, "\n");
fflush(fout);
}
}

Expand Down Expand Up @@ -437,6 +444,7 @@ class TrackingDataWriter : public TestLauncher
}

fprintf(fout, "\n");
fflush(fout);
}
}

Expand All @@ -462,6 +470,7 @@ class TrackingDataWriter : public TestLauncher
fprintf(fout, "\t%lg", FPKM);
}
}
fflush(fout);
}
}

Expand All @@ -487,6 +496,7 @@ class TrackingDataWriter : public TestLauncher
fprintf(fout, "\t%lg", count);
}
}
fflush(fout);
}
}

Expand Down Expand Up @@ -567,6 +577,7 @@ class TrackingDataWriter : public TestLauncher
status_str);
}
}
fflush(fout);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/replicates.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,14 @@ class ReplicatedBundleFactory

// This function NEEDS to deep copy the ref_mRNAs, otherwise cuffdiff'd
// samples will clobber each other
void set_ref_rnas(const vector<boost::shared_ptr<Scaffold> >& mRNAs)
void set_ref_rnas(const vector<boost::shared_ptr<Scaffold> >& mRNAs, bool deep_copy = true)
{
#if ENABLE_THREADS
boost::mutex::scoped_lock lock(_rep_factory_lock);
#endif
BOOST_FOREACH(boost::shared_ptr<BundleFactory> fac, _factories)
{
fac->set_ref_rnas(mRNAs);
fac->set_ref_rnas(mRNAs, deep_copy);
}
}

Expand Down

0 comments on commit 566ebd3

Please sign in to comment.