/// Filters gene map according to the list of requested genes.
///
/// Here are the possible combinations:
///
/// | --genemap  | --genes |                 behavior                   |
/// |------------|---------|--------------------------------------------|
/// |     +      |    +    | Take only specified genes                  |
/// |     +      |         | Take all genes                             |
/// |            |    +    | Error                                      |
/// |            |         | Skip translation and codon penalties       |
Filters gene map according to the list of requested genes.
Here are the possible combinations.


Filters gene map according to the list of requested genes . Here are the possible combinations .
pub fn filter_gene_map(gene_map: Option<GeneMap>, genes: Option<Vec<String>>) -> Result<GeneMap, Report> {
  match (gene_map, genes) {
    // Both gene map and list of genes are provided. Retain only requested genes.
    (Some(gene_map), Some(genes)) => {
      let gene_map: GeneMap = gene_map
        .into_iter()
        .filter(|(gene_name, ..)| genes.contains(gene_name))
        .collect();
      let requested_genes_not_in_genemap = get_requested_genes_not_in_genemap(&gene_map, &genes);
      if !requested_genes_not_in_genemap.is_empty() {
        warn!(
          "The following genes were requested through `--genes` \
           but not found in the gene map: \
           `{requested_genes_not_in_genemap}`",
        );
      }
      Ok(gene_map)
    }
    // Only gene map is provided. Take all the genes.
    (Some(gene_map), None) => Ok(gene_map),
    // Gene list is provided, but no gene map. This is illegal.
    (None, Some(_)) => {
      make_error!(
        "List of genes via '--genes' can only be specified \
         when a gene map (genome annotation) is provided"
      )
    }
    // Nothing is provided. Create an empty gene map.
    // This disables codon-aware alignment, translation, AA mutations, frame shifts, and everything else that relies
    // on gene information.
    (None, None) => Ok(GeneMap::new()),
  }
}
pub fn filter_gene_map ( gene_map : Option < GeneMap > , genes : Option < Vec < String > > ) -> Result < GeneMap , Report > { match ( gene_map , genes ) { // Both gene map and list of genes are provided. Retain only requested genes. ( Some ( gene_map ) , Some ( genes ) ) => { let gene_map : GeneMap = gene_map . into_iter ( ) . filter ( | ( gene_name , .. ) | genes . contains ( gene_name ) ) . collect ( ) ; let requested_genes_not_in_genemap = get_requested_genes_not_in_genemap ( & gene_map , & genes ) ; if ! requested_genes_not_in_genemap . is_empty ( ) { warn ! ( " \
 \
 " ) ; } Ok ( gene_map ) } // Only gene map is provided. Take all the genes. ( Some ( gene_map ) , None ) => Ok ( gene_map ) , // Gene list is provided, but no gene map. This is illegal. ( None , Some ( _ ) ) => { make_error ! ( " \
 " ) } // Nothing is provided. Create an empty gene map. // This disables codon-aware alignment, translation, AA mutations, frame shifts, and everything else that relies // on gene information. ( None , None ) => Ok ( GeneMap :: new ( ) ) , } }
Filters gene map according to the list of requested genes.
Filters gene map according to the list of requested genes .
gene_map
Option<GeneMap>
genes
Option<Vec<String>>