2024-10-21 12:22:35 -04:00
# include <filesystem>
# include <fstream>
2024-10-21 11:16:15 -04:00
# include <string>
2024-10-21 12:22:35 -04:00
# include "tree.hpp"
# include "vxheaven_parse.hpp"
2024-10-21 11:16:15 -04:00
2024-10-21 12:22:35 -04:00
int main ( ) {
2024-10-21 12:27:40 -04:00
std : : ifstream ifs ( " ./testdata/samples.sort " ) ;
2024-10-21 12:22:35 -04:00
vxorg : : VxHeavenTree tree ;
2024-10-21 11:16:15 -04:00
2024-10-21 12:22:35 -04:00
vxorg : : parse_into_tree ( tree , ifs ) ;
2024-10-21 11:16:15 -04:00
2024-10-21 20:50:52 -04:00
std : : filesystem : : path root = std : : filesystem : : current_path ( ) / " testdata " ;
std : : filesystem : : path unorg = root / " unorg " ;
std : : filesystem : : path org = root / " org " ;
if ( ! std : : filesystem : : exists ( org ) )
std : : filesystem : : create_directories ( org ) ;
2024-10-21 12:22:35 -04:00
// walk the resulting tree
2024-10-21 20:50:52 -04:00
tree . walk ( [ & ] ( auto * node ) {
2024-10-21 12:38:39 -04:00
auto tabulation_level = node - > parent_count ( ) ;
2024-10-21 12:22:35 -04:00
auto & data = node - > data ( ) ;
2024-10-21 11:16:15 -04:00
2024-10-21 20:50:52 -04:00
#if 0
2024-10-21 12:38:39 -04:00
if ( tabulation_level ! = 0 ) {
for ( auto i = 0 ; i < tabulation_level ; + + i ) {
std : : printf ( " \t " ) ;
}
}
2024-10-21 11:16:15 -04:00
2024-10-21 19:56:43 -04:00
if ( node - > is_root ( ) ) {
2024-10-21 12:22:35 -04:00
std : : printf ( " (root) \n " ) ;
} else {
if ( data . is_sample ) {
2024-10-21 12:27:40 -04:00
std : : string sample_name = vxorg : : get_sample_name ( node ) ;
2024-10-21 12:22:35 -04:00
std : : printf ( " %s (sample %s) \n " , data . name . c_str ( ) , sample_name . c_str ( ) ) ;
} else {
std : : printf ( " %s \n " , data . name . c_str ( ) ) ;
}
}
2024-10-21 20:50:52 -04:00
# endif
# if 1
if ( ! node - > is_root ( ) ) {
if ( data . is_sample ) {
std : : string sample_name = vxorg : : get_sample_name ( node ) ;
// paths
auto path = org / vxorg : : get_sample_path ( node ) ;
auto source_path = unorg / vxorg : : get_sample_name ( node ) ;
if ( ! std : : filesystem : : exists ( source_path ) ) {
std : : printf ( " WARNING: sample %s/%s in tree (source disk file %s) does not exist \n " , path . string ( ) . c_str ( ) , sample_name . c_str ( ) , source_path . string ( ) . c_str ( ) ) ;
}
//std::printf("sample %s/%s in tree (source disk file %s)\n", path.string().c_str(), sample_name.c_str(), source_path.string().c_str());
}
}
# endif
2024-10-21 12:22:35 -04:00
} ) ;
return 0 ;
2024-10-21 11:16:15 -04:00
}