A library for working with phylogenetic and population genetic data.
v0.27.0
functions/genome_region.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_POPULATION_FUNCTIONS_GENOME_REGION_H_
2 #define GENESIS_POPULATION_FUNCTIONS_GENOME_REGION_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2022 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lczech@carnegiescience.edu>
23  Department of Plant Biology, Carnegie Institution For Science
24  260 Panama Street, Stanford, CA 94305, USA
25 */
26 
36 
37 #ifdef GENESIS_HTSLIB
38 
40 
41 #endif // htslib guard
42 
43 #include <iosfwd>
44 #include <string>
45 #include <vector>
46 
47 namespace genesis {
48 namespace population {
49 
50 // =================================================================================================
51 // Comparion Operators
52 // =================================================================================================
53 
57 bool operator ==( GenomeRegion const& a, GenomeRegion const& b );
58 
62 bool operator !=( GenomeRegion const& a, GenomeRegion const& b );
63 
64 // =================================================================================================
65 // Parsing & Printing
66 // =================================================================================================
67 
68 std::string to_string( GenomeRegion const& region );
69 std::ostream& operator<<( std::ostream& os, GenomeRegion const& region );
70 
80 GenomeRegion parse_genome_region(
81  std::string const& region,
82  bool zero_based = false,
83  bool end_exclusive = false
84 );
85 
93 GenomeRegionList parse_genome_regions(
94  std::string const& regions,
95  bool zero_based = false,
96  bool end_exclusive = false
97 );
98 
99 // =================================================================================================
100 // Region Coverage
101 // =================================================================================================
102 
106 bool is_covered( GenomeRegion const& region, std::string const& chromosome, size_t position );
107 
111 bool is_covered( GenomeRegionList const& regions, std::string const& chromosome, size_t position );
112 
120 template<class T>
121 bool is_covered( GenomeRegion const& region, T const& locus )
122 {
123  return is_covered( region, locus.chromosome, locus.position );
124 }
125 
134 template<class T>
135 bool is_covered( GenomeRegionList const& regions, T const& locus )
136 {
137  return is_covered( regions, locus.chromosome, locus.position );
138 }
139 
140 #ifdef GENESIS_HTSLIB
141 
142 bool is_covered( GenomeRegion const& region, VcfRecord const& variant );
143 bool is_covered( GenomeRegionList const& regions, VcfRecord const& variant );
144 
145 #endif // htslib guard
146 
147 } // namespace population
148 } // namespace genesis
149 
150 #endif // include guard
genesis::population::operator!=
bool operator!=(GenomeLocus const &l, GenomeLocus const &r)
Inequality comparison (!=) for two loci in a genome.
Definition: functions/genome_locus.hpp:261
genesis::population::operator==
bool operator==(GenomeLocus const &l, GenomeLocus const &r)
Equality comparison (==) for two loci in a genome.
Definition: functions/genome_locus.hpp:209
genesis::population::GenomeRegionList
List of regions in a genome, for each chromosome.
Definition: genome_region_list.hpp:82
genesis::population::is_covered
bool is_covered(GenomeRegion const &region, std::string const &chromosome, size_t position)
Test whether the chromosome/position is within a given genomic region.
Definition: genome_region.cpp:190
genesis::population::GenomeRegion::chromosome
std::string chromosome
Definition: genome_region.hpp:64
genesis::population::operator<<
std::ostream & operator<<(std::ostream &os, BaseCounts const &bs)
Output stream operator for BaseCounts instances.
Definition: population/functions/functions.cpp:486
genesis::population::to_string
std::string to_string(GenomeLocus const &locus)
Definition: functions/genome_locus.hpp:48
genome_region.hpp
genome_region_list.hpp
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::population::parse_genome_regions
GenomeRegionList parse_genome_regions(std::string const &regions, bool zero_based, bool end_exclusive)
Parse a set/list of genomic regions.
Definition: genome_region.cpp:173
genesis::population::GenomeRegion
A region (between two positions) on a chromosome.
Definition: genome_region.hpp:60
vcf_record.hpp
genesis::population::parse_genome_region
GenomeRegion parse_genome_region(std::string const &region, bool zero_based, bool end_exclusive)
Parse a genomic region.
Definition: genome_region.cpp:104