//cout << a_path.size() << endl;
//first entry is the window length of the windows in the path
save_file << a_path.window_size << ":";
- for(size_t i = 0; i != sequence_count(); ++i)
+ for(size_type i = 0; i != sequence_count(); ++i)
{
save_file << a_path[i];
if (i != sequence_count())
}
-size_t
-NwayPaths::sequence_count()
+NwayPaths::size_type NwayPaths::sequence_count() const
{
if (refined_pathz.begin() == refined_pathz.end() )
return 0;
return refined_pathz.begin()->size();
}
+NwayPaths::size_type NwayPaths::size() const
+{
+ return pathz.size();
+}
void
NwayPaths::load(fs::path load_file_path)
// whats our window size?
path_width = file_data_line.substr(0,colon_split_i);
file_data_line = file_data_line.substr(colon_split_i+1);
- for(size_t i = 0; i < species_num; i++)
+ for(size_type i = 0; i < species_num; i++)
{
comma_split_i = file_data_line.find(",");
path_node = file_data_line.substr(0, comma_split_i);
void
-NwayPaths::path_search(vector<vector<FLPs> > all_comparisons, ConservedPath path, size_t depth)
+NwayPaths::path_search(vector<vector<FLPs> > all_comparisons, ConservedPath path, size_type depth)
{
list<int> new_nodes, trans_check_nodes;
list<int>::iterator new_nodes_i, new_nodes_end;
//cout << " * species " << depth << " node: " << *new_nodes_i << endl;
// check transitivity with previous nodes in path
trans_check_good = true;
- for(size_t i = 0; i < depth - 1; i++)
+ for(size_type i = 0; i < depth - 1; i++)
{
trans_check_nodes = all_comparisons[i][depth].match_locations(path[i]);
if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
{
fs::fstream save_file;
list<ConservedPath >::iterator path_i, paths_end;
- size_t i;
+ size_type i;
save_file.open(save_file_path, ios::app);
void progress(const QString& description, int cur, int max);
public:
+ typedef size_t size_type;
typedef std::list<ConservedPath> ConservedPaths;
NwayPaths();
// old recursive transitive nway ... has issues checking all links?
void find_paths_r(std::vector<std::vector<FLPs> > all_comparisons);
- void path_search(std::vector<std::vector<FLPs> > all_comparisons, ConservedPath path, size_t depth);
+ void path_search(std::vector<std::vector<FLPs> > all_comparisons, ConservedPath path, size_type depth);
void simple_refine();
void save(boost::filesystem::path save_file_path);
void add_path(int threshold, std::vector<int>& loaded_path);
void add_path(ConservedPath loaded_path);
//! how many sequences are in our comparison
- size_t sequence_count();
+ size_type sequence_count() const;
void find_paths(std::vector<std::vector<FLPs> > all_comparisons);
void refine();
// they'll have problems when being called from within a const object
ConservedPaths::iterator pbegin() { return pathz.begin() ; }
ConservedPaths::iterator pend() { return pathz.end() ; }
- size_t path_size() const { return refined_pathz.size(); }
+ size_type path_size() const { return pathz.size(); }
ConservedPaths::iterator rpbegin() { return refined_pathz.begin() ; }
ConservedPaths::iterator rpend() { return refined_pathz.end() ; }
- size_t refined_path_size() const { return refined_pathz.size(); }
+ size_type refined_path_size() const { return refined_pathz.size(); }
+ size_type size() const;
// these probably shouldn't be public, but lets start
// simple
ConservedPaths pathz;
protected:
int threshold;
- size_t win_size;
+ size_type win_size;
int soft_thres;
double ent_thres;
std::vector<char *> c_sequences; //used by entropy_path_search
-
};
#endif
analysis.set_threshold(3);
analysis.analyze();
NwayPaths npath = analysis.paths();
+ // we added 3 sequences, but none-matched
+ BOOST_CHECK_EQUAL( npath.sequence_count(), 0);
+ BOOST_CHECK_EQUAL( npath.size(), 0 );
+ BOOST_CHECK_EQUAL( npath.path_size(), 0 );
+ BOOST_CHECK_EQUAL( npath.refined_path_size(), 0 );
// there should be no paths for these sequences
for (std::list<ConservedPath >::iterator pathz_i = npath.pathz.begin();
pathz_i != npath.pathz.end();
analysis.set_threshold(3);
analysis.analyze();
NwayPaths npath = analysis.paths();
+ BOOST_CHECK_EQUAL( npath.sequence_count(), 2);
+ BOOST_CHECK_EQUAL( npath.size(), 2 );
+ BOOST_CHECK_EQUAL( npath.path_size(), 2 );
+ BOOST_CHECK_EQUAL( npath.refined_path_size(), 2 );
for (std::list<ConservedPath >::iterator pathz_i = npath.pathz.begin();
pathz_i != npath.pathz.end();
++pathz_i)
m1.load_mupa_file( mupa_path );
m1.analyze();
const NwayPaths& npath = m1.paths();
- BOOST_CHECK_EQUAL (npath.path_size(), npath.refined_path_size());
+ //BOOST_CHECK_EQUAL (npath.path_size(), npath.refined_path_size());
+ // FIXME: shouldn't these be equal to start with?
+ BOOST_CHECK(npath.path_size() > npath.refined_path_size());
size_t first_refined_size = npath.refined_path_size();
BOOST_CHECK( first_refined_size > 0 );
// we're using a window size 30 (threshold 20) example
m1.set_soft_threshold(22);
m1.nway();
+ BOOST_CHECK_EQUAL( npath.path_size(), npath.size() );
+ BOOST_CHECK( npath.path_size() > 0 );
BOOST_CHECK( npath.refined_path_size() > 0);
BOOST_CHECK( npath.refined_path_size() < first_refined_size);
;*/
py::class_<NwayPaths>("NwayPaths")
- .def("__len__", &NwayPaths::sequence_count)
+ .def("__len__", &NwayPaths::size, "number of paths")
+ .def("sequence_count", &NwayPaths::sequence_count,
+ "number of sequences in this analysis")
.def("clear", &NwayPaths::clear, "remove all paths")
.add_property("threshold", &NwayPaths::get_threshold, "Get hard threshold")
.add_property("soft_threshold", &NwayPaths::get_soft_threshold, &NwayPaths::set_soft_threshold)
.add_property("window_size", &NwayPaths::get_window)
.add_property("pathz", py::range(&NwayPaths::pbegin, &NwayPaths::pend))
+ .def("path_size", &NwayPaths::path_size, "number of nway paths")
.add_property("refinedPathz", py::range(&NwayPaths::rpbegin, &NwayPaths::rpend))
+ .def("refined_path_size", &NwayPaths::refined_path_size,
+ "number of paths that match the soft threshold")
;
}
class TestMussa(unittest.TestCase):
def testSimple(self):
s1 = mussa.Sequence("A"*10)
- s2 = mussa.Sequence("GG"+"A"*8+"GG")
- s3 = mussa.Sequence("T"*10)
+ s2 = mussa.Sequence("GG"+"A"*10)
+ s3 = mussa.Sequence("A"*10)
m = mussa.Mussa()
m.window = 10
- m.threshold = 8
+ m.threshold = 10
m.add_sequence(s1)
m.add_sequence(s2)
m.add_sequence(s3)
m.analyze()
# this could probably be a more thorough test
- self.failUnless( len(m.paths()), 3 )
+ paths = m.paths()
+ self.failUnlessEqual( len(paths), 1 )
+ pathz_list = [ x for x in paths.pathz ]
+ self.failUnlessEqual( len(paths), len(pathz_list) )
def suite():
return unittest.makeSuite(TestMussa, 'test')
if __name__ == "__main__":
- sys.exit(unittest.main(defaultTest='suite'))
\ No newline at end of file
+ sys.exit(unittest.main(defaultTest='suite'))