44 namespace population {
51 std::shared_ptr< utils::BaseInputSource > source
61 std::shared_ptr< utils::BaseInputSource > source,
70 std::shared_ptr< utils::BaseInputSource > source,
83 void GenomeRegionReader::read_(
84 std::shared_ptr< utils::BaseInputSource > source,
85 std::function<
void(
GenomeRegion const& region )> callback
91 auto throw_invalid_arg_ = [&](
InputStream const& it ){
92 throw std::invalid_argument(
93 "Invalid genomic region in " + it.source_name() +
" at " + it.at()
104 return is_print(c) && c !=
':' && c !=
' ' && c !=
'\t' && c !=
'\n';
106 if( region.chromosome.empty() || region.chromosome ==
"-" || region.chromosome ==
".." ) {
107 throw_invalid_arg_( it );
113 if( !it || *it ==
'\n' ) {
122 }
else if( *it ==
':' ) {
124 }
else if( *it ==
' ' || *it ==
'\t' ) {
127 throw_invalid_arg_( it );
132 region.start = parse_unsigned_integer<size_t>( it );
134 if( !it || *it ==
'\n' ) {
137 region.end = region.start;
141 if( *it ==
'-' || *it ==
'.' ) {
143 throw_invalid_arg_( it );
147 if( !it || *it !=
'.' ) {
148 throw_invalid_arg_( it );
151 }
else if( *it ==
' ' || *it ==
'\t' ) {
153 throw_invalid_arg_( it );
156 throw_invalid_arg_( it );
161 region.end = parse_unsigned_integer<size_t>( it );
165 if( it && *it !=
'\n' ) {
166 throw_invalid_arg_( it );
174 if( end_exclusive_ ) {
175 if( region.end == 0 ) {
176 throw_invalid_arg_( it );
182 if( ! region.specified() ) {
183 throw_invalid_arg_( it );
190 assert( !it || *it ==
'\n' );