~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to Bio/Taxon.pm

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
  # Typically you will get a Taxon from a Bio::DB::Taxonomy object
23
23
  # but here is how you initialize one
24
24
  my $taxon = Bio::Taxon->new(-name      => $name,
25
 
                             -id        => $id,
26
 
                             -rank      => $rank,
27
 
                             -division  => $div);
 
25
                              -id        => $id,
 
26
                              -rank      => $rank,
 
27
                              -division  => $div);
28
28
 
29
29
  # Get one from a database
30
30
  my $dbh = Bio::DB::Taxonomy->new(-source   => 'flatfile',
31
 
                                  -directory=> '/tmp',
32
 
                                  -nodesfile=> '/path/to/nodes.dmp',
33
 
                                  -namesfile=> '/path/to/names.dmp');
 
31
                                   -directory=> '/tmp',
 
32
                                   -nodesfile=> '/path/to/nodes.dmp',
 
33
                                   -namesfile=> '/path/to/names.dmp');
34
34
  my $human = $dbh->get_taxon(-name => 'Homo sapiens');
35
35
  $human = $dbh->get_taxon(-taxonid => '9606');
36
36
 
45
45
  my @ranks = qw(superkingdom class genus species);
46
46
  my @h_lineage = ('Eukaryota', 'Mammalia', 'Homo', 'Homo sapiens');
47
47
  my $list_dbh = Bio::DB::Taxonomy->new(-source => 'list', -names => \@h_lineage,
48
 
                                                          -ranks => \@ranks);
 
48
                                                           -ranks => \@ranks);
49
49
  $human = $list_dbh->get_taxon(-name => 'Homo sapiens');
50
50
  my @names = $human->common_names; # @names is empty
51
51
  $human->common_names('woman');
72
72
  use Bio::Tree::Tree;
73
73
  my $tree_functions = Bio::Tree::Tree->new();
74
74
  my @lineage = $tree_functions->get_lineage_nodes($human);
 
75
  my $lineage = $tree_functions->get_lineage_string($human);
75
76
  my $lca = $tree_functions->get_lca($human, $mouse);
76
77
 
77
78
  # b) for other methods, create a tree using your Taxon object
146
147
 
147
148
=cut
148
149
 
 
150
 
149
151
package Bio::Taxon;
150
152
use strict;
151
153
use Scalar::Util qw(blessed);
154
156
 
155
157
use base qw(Bio::Tree::Node Bio::IdentifiableI);
156
158
 
 
159
 
157
160
=head2 new
158
161
 
159
162
 Title   : new
234
237
    return $self;
235
238
}
236
239
 
 
240
 
237
241
=head1 Bio::IdentifiableI interface 
238
242
 
239
243
Also see L<Bio::IdentifiableI>
253
257
    return $self->{'version'};
254
258
}
255
259
 
 
260
 
256
261
=head2 authority
257
262
 
258
263
 Title   : authority
268
273
    return $self->{'authority'};
269
274
}
270
275
 
 
276
 
271
277
=head2 namespace
272
278
 
273
279
 Title   : namespace
283
289
    return $self->{'namespace'};
284
290
}
285
291
 
 
292
 
286
293
=head1 Bio::Taxonomy::Node implementation
287
294
 
288
295
=head2 db_handle
317
324
    return $self->{'db_handle'};
318
325
}
319
326
 
 
327
 
320
328
=head2 rank
321
329
 
322
330
 Title   : rank
333
341
    return $self->{'rank'};
334
342
}
335
343
 
 
344
 
336
345
=head2 id
337
346
 
338
347
 Title   : id
351
360
 
352
361
*object_id = \&id;
353
362
 
 
363
 
354
364
=head2 ncbi_taxid
355
365
 
356
366
 Title   : ncbi_taxid
377
387
    return;
378
388
}
379
389
 
 
390
 
380
391
=head2 parent_id
381
392
 
382
393
 Title   : parent_id
400
411
 
401
412
*parent_taxon_id = \&parent_id;
402
413
 
 
414
 
403
415
=head2 genetic_code
404
416
 
405
417
 Title   : genetic_code
416
428
    return $self->{'genetic_code'};
417
429
}
418
430
 
 
431
 
419
432
=head2 mitochondrial_genetic_code
420
433
 
421
434
 Title   : mitochondrial_genetic_code
432
445
    return $self->{'mitochondrial_genetic_code'};
433
446
}
434
447
 
 
448
 
435
449
=head2 create_date
436
450
 
437
451
 Title   : create_date
448
462
    return $self->{'create_date'};
449
463
}
450
464
 
 
465
 
451
466
=head2 update_date
452
467
 
453
468
 Title   : update_date
464
479
    return $self->{'update_date'};
465
480
}
466
481
 
 
482
 
467
483
=head2 pub_date
468
484
 
469
485
 Title   : pub_date
480
496
    return $self->{'pub_date'};
481
497
}
482
498
 
 
499
 
483
500
=head2 ancestor
484
501
 
485
502
 Title   : ancestor
513
530
    return $dbh->ancestor($definitely_from_dbh);
514
531
}
515
532
 
 
533
 
516
534
=head2 get_Parent_Node
517
535
 
518
536
 Title   : get_Parent_Node
527
545
    return $self->ancestor(@_);
528
546
}
529
547
 
 
548
 
530
549
=head2 each_Descendent
531
550
 
532
551
 Title   : each_Descendent
550
569
 
551
570
=cut
552
571
 
 
572
 
553
573
# implemented by Bio::Tree::Node
554
574
 
555
575
=head2 get_Children_Nodes
566
586
    return $self->each_Descendent(@_);
567
587
}
568
588
 
 
589
 
569
590
=head2 name
570
591
 
571
592
  Title:    name
581
602
                scientific name and common name, respectively. 'scientific' and
582
603
                'division' are treated specially, allowing only the first value
583
604
                in the Arg2 list to be set.
584
 
            Arg2 .. => list of names
 
605
            Arg2 ... => list of names
585
606
 
586
607
=cut
587
608
 
599
620
    return $self->{'_names_hash'}->{$name_class} || return;
600
621
}
601
622
 
 
623
 
602
624
=head2 node_name
603
625
 
604
626
 Title   : node_name
619
641
 
620
642
*scientific_name = \&node_name;
621
643
 
 
644
 
622
645
=head2 common_names
623
646
 
624
647
 Title   : common_names
639
662
 
640
663
*common_name = \&common_names;
641
664
 
 
665
 
642
666
=head2 division
643
667
 
644
668
 Title   : division
656
680
    return pop @v;
657
681
}
658
682
 
 
683
 
659
684
# get a node from the database that is like the supplied node
660
685
sub _get_similar_taxon_from_db {
661
686
    #*** not really happy with this having to be called so much; there must be
685
710
    return $db_taxon;
686
711
}
687
712
 
 
713
 
688
714
# merge data from supplied Taxon into self
689
715
sub _merge_taxa {
690
716
    my ($self, $taxon) = @_;
716
742
    #*** haven't merged the other things in names() hash, could do above much easier with direct access to object data
717
743
}
718
744
 
 
745
 
719
746
=head2 remove_Descendent
720
747
 
721
748
 Title   : remove_Descendent
745
772
    return $c;
746
773
}
747
774
 
 
775
 
748
776
1;