Skip to content

Commit f70cb72

Browse files
authored
Swap reformat for reformat2 (#44)
1 parent 507bfa5 commit f70cb72

3 files changed

Lines changed: 120 additions & 122 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [Unreleased]
6+
7+
### Changed
8+
- Swapped `taxonkit reformat` for `taxonkit reformat2` to restore sane default behaviors after NBCI shuffled ranks near the root of the taxonomy database (#43, #44)
9+
10+
511
## [0.9.1] 2024-08-05
612

713
### Changed

README.md

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Execute `help(pytaxonkit.name2taxid)` (and so on) from the Python interpreter fo
2323
`pytaxonkit` provides convenient access to TaxonKit operations from Python for use in the interactive interpreter, IPython, Jupyter notebooks, or custom Python code.
2424

2525
> **NOTES**
26-
> - The `reformat` operation is automatically run by `pytaxonkit.lineage` and cannot be invoked independently.
26+
> - The `reformat2` operation is automatically run by `pytaxonkit.lineage` and cannot be invoked independently.
2727
> - The `genautocomplete` operation is specific to the shell and is not supported.
2828
> - Several other operations are not supported, including `cami-filter`, `create-taxdump`, `profile2cami`, and `taxid-changelog`.
2929
> - The `pytaxonkit.__version__` variable refers to the version number of the Python bindings, while the `pytaxonkit.__taxonkitversion__` variable corresponds to the version of the installed TaxonKit program. These version numbers are not necessarily equal.
@@ -32,7 +32,7 @@ Execute `help(pytaxonkit.name2taxid)` (and so on) from the Python interpreter fo
3232

3333
```python
3434
>>> import pytaxonkit
35-
>>> names = ['Phyllobolus spinuliferus', 'Alteromonas putrefaciens', 'Rexia erectus']
35+
>>> names = ["Phyllobolus spinuliferus", "Alteromonas putrefaciens", "Rexia erectus"]
3636
>>> pytaxonkit.name2taxid(names)
3737
Name TaxID Rank
3838
0 Phyllobolus spinuliferus 359607 species
@@ -43,51 +43,55 @@ Execute `help(pytaxonkit.name2taxid)` (and so on) from the Python interpreter fo
4343
0 Phyllobolus spinuliferus <NA> <NA>
4444
1 Alteromonas putrefaciens <NA> <NA>
4545
2 Rexia erectus <NA> <NA>
46+
"""
4647
```
4748
4849
### lineage
4950
5051
```python
5152
>>> import pytaxonkit
52-
>>> result = pytaxonkit.lineage([7399, 1973489])
53+
>>> result = pytaxonkit.lineage([1325911, 1649473, 1401311])
5354
>>> result.columns
54-
Index(['TaxID', 'Code', 'Name', 'Lineage', 'LineageTaxIDs', 'Rank',
55-
'FullLineage', 'FullLineageTaxIDs', 'FullLineageRanks'],
56-
dtype='object')
57-
>>> result[['TaxID', 'Lineage', 'LineageTaxIDs']]
58-
TaxID Lineage LineageTaxIDs
59-
0 7399 Eukaryota;Arthropoda;Insecta;Hymenoptera;;; 2759;6656;50557;7399;;;
60-
1 1973489 Bacteria;Firmicutes;Bacilli;Bacillales;Bacilla... 2;1239;91061;1385;186817;1386;1973489
61-
>>> result = pytaxonkit.lineage(['1382510', '929505', '390333'], formatstr='{f};{g};{s};{S}')
62-
>>> result['Lineage'].iloc[2]
63-
'Lactobacillaceae;Lactobacillus;Lactobacillus delbrueckii;Lactobacillus delbrueckii subsp. bulgaricus'
55+
Index(['TaxID', 'Code', 'Name', 'Lineage', 'LineageTaxIDs', 'Rank', 'FullLineage', 'FullLineageTaxIDs', 'FullLineageRanks'], dtype='object')
56+
>>> result[["TaxID", "Lineage", "LineageTaxIDs"]]
57+
TaxID Lineage LineageTaxIDs
58+
0 1325911 Eukaryota;Arthropoda;Insecta;Hymenoptera;Eucharitidae;Pogonocharis; 2759;6656;50557;7399;216140;1325911;
59+
1 1649473 Bacteria;Bacteroidota;Cytophagia;Cytophagales;Spirosomataceae;Nibrella; 2;976;768503;768507;2896860;1649473;
60+
2 1401311 Eukaryota;Arthropoda;Insecta;Coleoptera;Staphylinidae;Styngetus; 2759;6656;50557;7041;29026;1401311;
61+
>>> result = pytaxonkit.lineage(["1382510", "929505", "390333"], formatstr="{family};{genus};{species};{subspecies|strain}")
62+
>>> result[["TaxID", "Lineage", "LineageTaxIDs"]]
63+
TaxID Lineage LineageTaxIDs
64+
0 1382510 Enterobacteriaceae;Salmonella;Salmonella bongori;Salmonella bongori serovar 48:z41:-- str. RKS3044 543;590;54736;1382510
65+
1 929505 Clostridiaceae;Clostridium;Clostridium botulinum;Clostridium botulinum C str. Stockholm 31979;1485;1491;929505
66+
2 390333 Lactobacillaceae;Lactobacillus;Lactobacillus delbrueckii;Lactobacillus delbrueckii subsp. bulgaricus 33958;1578;1584;1585
6467
```
6568
6669
### name
6770
6871
```python
6972
>>> import pytaxonkit
70-
>>> pytaxonkit.name(['274127', 511170])
71-
TaxID Name
72-
0 274127 Distathma
73-
1 511170 Delicatula
73+
>>> name(["151837", "2216222", "517824"])
74+
TaxID Name
75+
0 151837 Hiraea smilacina
76+
1 2216222 Paramyia sp. BIOUG21706-A10
77+
2 517824 soil bacterium Cipr-S1N-M1LLLSSL-1
7478
```
7579
7680
### list
7781
7882
```python
7983
>>> import pytaxonkit
80-
>>> result = pytaxonkit.list([13685, 9903])
84+
>>> result = pytaxonkit.list([268197, 9903])
8185
>>> for taxon, tree in result:
8286
... subtaxa = [t for t in tree.traverse]
8387
... print(f'Top level result: {taxon.name} ({taxon.taxid}); {len(subtaxa)} related taxa')
8488
...
85-
Top level result: Solenopsis (13685); 293 related taxa
86-
Top level result: Bos (9903); 29 related taxa
89+
Top level result: Polistes comanchus (268197); 2 related taxa
90+
Top level result: Bos (9903); 33 related taxa
8791
>>> subtaxa[0]
8892
BasicTaxon(taxid=9904, rank='species', name='Bos gaurus')
8993
>>> pytaxonkit.list([9605], raw=True)
90-
{'9605 [genus] Homo': {'9606 [species] Homo sapiens': {'63221 [subspecies] Homo sapiens neanderthalensis': {}, "741158 [subspecies] Homo sapiens subsp. 'Denisova'": {}}, '1425170 [species] Homo heidelbergensis': {}, '2665952 [no rank] environmental samples': {'2665953 [species] Homo sapiens environmental sample': {}}}}
94+
{'9605 [genus] Homo': {'9606 [species] Homo sapiens': {'63221 [subspecies] Homo sapiens neanderthalensis': {}, "741158 [subspecies] Homo sapiens subsp. 'Denisova'": {}}, '1425170 [species] Homo heidelbergensis': {}, '2665952 [no rank] environmental samples': {'2665953 [species] Homo sapiens environmental sample': {}}, '2813598 [no rank] unclassified Homo': {'2813599 [species] Homo sp.': {}}}}
9195
```
9296
9397
### filter
@@ -97,10 +101,20 @@ BasicTaxon(taxid=9904, rank='species', name='Bos gaurus')
97101
>>> taxids = [131567, 2759, 33154, 33208, 6072, 33213, 33317, 1206794, 88770, 6656, 197563, 197562, 6960, 50557, 85512, 7496, 33340, 33392, 85604, 7088]
98102
>>> result = pytaxonkit.filter(taxids, equal_to='phylum', higher_than='phylum')
99103
>>> pytaxonkit.name(result)
100-
TaxID Name
101-
0 2759 Eukaryota
102-
1 33208 Metazoa
103-
2 6656 Arthropoda
104+
TaxID Name
105+
0 131567 cellular organisms
106+
1 2759 Eukaryota
107+
2 33154 Opisthokonta
108+
3 33208 Metazoa
109+
4 6072 Eumetazoa
110+
5 33213 Bilateria
111+
6 33317 Protostomia
112+
7 1206794 Ecdysozoa
113+
8 88770 Panarthropoda
114+
9 6656 Arthropoda
115+
10 197563 Mandibulata
116+
11 197562 Pancrustacea
117+
12 85512 Dicondylia
104118
>>> taxids = [131567, 2759, 33154, 33208, 6072, 33213, 33317, 1206794, 88770, 6656, 197563, 197562, 6960, 50557, 85512, 7496, 33340, 33342, 7524]
105119
>>> result = pytaxonkit.filter(taxids, lower_than='phylum', discard_norank=True)
106120
>>> pytaxonkit.name(result)
@@ -126,16 +140,20 @@ BasicTaxon(taxid=9904, rank='species', name='Bos gaurus')
126140
>>> pytaxonkit.name([ancestor])
127141
TaxID Name
128142
0 7400 Apocrita
143+
>>> pytaxonkit.lca([239934, 239935, 349741])
144+
239934
145+
>>> pytaxonkit.lca([[63221, 2665953], [63221, 741158]], multi=True)
146+
[9605, 9606]
129147
```
130148
131149
### version
132150
133151
```python
134152
>>> import pytaxonkit
135153
>>> pytaxonkit.__version__
136-
'0.7.2'
154+
'0.9.1'
137155
>>> pytaxonkit.__taxonkitversion__
138-
'taxonkit v0.7.2'
156+
'taxonkit v0.20.0'
139157
```
140158
141159

0 commit comments

Comments
 (0)