Florent Angly
and 1 contributors


Bio::Community::Tools::IdConverter - Various methods to convert member ID


  use Bio::Community::Tools::IdConverter;

  # Add member description to its ID
  my $converter = Bio::Community::Tools::IdConverter->new(
     -metacommunity     => $meta,
     -member_attr       => 'desc',
     -conversion_method => 'append',
  my $meta_by_otu = $converter->get_converted_meta;

  # Replace by IDs given in a file
  $converter = Bio::Community::Tools::IdConverter->new(
     -metacommunity => $meta,
     -cluster_file  => 'gg_99_otu_map.txt',
  $meta_by_otu = $converter->get_converted_meta;


Convert the ID of members given in a metacommunity based on another member attribute, such as its description, or based on IDs provided in a file. This file can be a Greengenes OTU cluster file, a BLAST file, or a QIIME taxonomic assignment file. A new metacommunity containing members with converted IDs is returned.

Note that when given a files, this script expects high-quality results. No quality processing is done and only the first match assigned to a member is kept.


Florent Angly florent.angly@gmail.com


User feedback is an integral part of the evolution of this and other Bioperl modules. Please direct usage questions or support issues to the mailing list, bioperl-l@bioperl.org, rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

If you have found a bug, please report it on the BioPerl bug tracking system to help us keep track the bugs and their resolution: https://redmine.open-bio.org/projects/bioperl/


Copyright 2011-2014 by Florent Angly <florent.angly@gmail.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.


The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


 Function: Create a new Bio::Community::Tool::IdConverter object
 Usage   : my $converter = Bio::Community::Tool::IdConverter->new(
              -metacommunity => $meta,
              -member_attr   => 'desc',
           # or
           my $converter = Bio::Community::Tool::IdConverter->new(
              -metacommunity => $meta,
              -cluster_file  => '99_otu_map.txt',
           # or
           my $converter = Bio::Community::Tool::IdConverter->new(
              -metacommunity => $meta,
              -blast_file    => 'blast_res.tab',
           # or
           my $converter = Bio::Community::Tool::IdConverter->new(
              -metacommunity  => $meta,
              -taxassign_file => 'rep_set_tax_assignments.txt',
 Args    : -metacommunity  : See metacommunity().
           And ones of:
           -member_attr    : See member_attr().
           -cluster_file   : See cluster_file().
           -blast_file     : See blast_file().
           -taxassign_file : See taxassign_file().
 Returns : a Bio::Community::Tools::IdConverter object


 Function: Get/set communities, given as metacommunity, to summarize.
 Usage   : my $meta = $converter->metacommunity;
 Args    : A Bio::Community::Meta object
 Returns : A Bio::Community::Meta object


 Function: Get / set whether member ID should be converted using the value of
           another attribute, e.g. the member's description. Replacing member ID
           by its description is useful when importing data from formats that do
           not explicitly represent member ID, e.g. from 'generic' to 'qiime'.
 Usage   : $converter->member_attr('id');
 Args    : member attribute, e.g. 'desc' (see C<Bio::Community::Member>)
 Returns : member attribute


 Function: Get / set the tab-delimited file that defines the OTU clusters. The
           columns are: OTU ID, ID of the representative sequence, IDs of the
           other sequences in the OTU. For example:

               0        367523
               1        187144
               2        544886  544649
               3        310669
               4        355095  310677  347705  563209

           The OTU files distributed by Greengenes use this format (e.g.,
 Usage   : $converter->cluster_file('99_otu_map.txt');
 Args    : OTU cluster file name
 Returns : OTU cluster file name


 Function: Get / set the tab-delimited BLAST file that defines the best
           similarity. This type of file generally has 12 columns and the first
           two should be the member ID and the ID of sequence with the best
           similarity. For example:

           OTU_4   JN647692.1.1869 99.6    250     1       0       1       250     1       250     *       *
           OTU_12  655879  94.4    250     14      0       1       250     1       250     *       *

 Usage   : $converter->blast_file('blastn_res.tab');
 Args    : BLAST file name
 Returns : BLAST file name


 Function: Get / set the tab-delimited file that defines the OTU taxonomic
           assignemts. The first four columns (out of 12) should be: OTU ID,
           taxonomic string, E-value, taxonomic ID. For example:

           345     k__Bacteria; p__Actinobacteria; c__Actinobacteria; o__Actinomycetales; f__Propionibacteriaceae; g__Propionibacterium; s__acnes  5e-138  1042485 95.67   300     13      0       1       300     878     579
           346     k__Bacteria; p__Firmicutes; c__Bacilli; o__; f__; g__; s__      8e-134  1064834 99.59   245     1       0       1       245     909     665
           347     k__Bacteria; p__Proteobacteria; c__Gammaproteobacteria; o__Pseudomonadales; f__Pseudomonadaceae; g__Pseudomonas; s__    2e-103  959954  98.99   198     2       0       103     300     718     521

           The taxonomic assignment files generated by QIIME (rep_set_tax_assignments.txt)
           follow this format.
 Usage   : $converter->taxassign_file('rep_set_tax_assignments.txt');
 Args    : taxonomic assignment file name
 Returns : taxonomic assignment file name


 Function: Get / set how to convert IDs, i.e. either replace the existing ID
           (the default), prepend in front of it, or append after it.
 Usage   : $converter->conversion_method('prepend');
 Args    : conversion method, 'replace', 'prepend' or 'append'
 Returns : conversion method


 Function: Get / set the string used to construct the ID when using the 'append'
           or 'prepend' conversion method, '_' by default
 Usage   : $converter->conversion_separator(' ');
 Args    : any string to use as conversion separator
 Returns : the string used as conversion method


 Function: Convert the communities and return the corresponding metacommunity.
 Usage   : my $meta_by_otu = $converter->get_converted_meta;
 Args    : None
 Returns : A Bio::Community::Meta object