Skip to content

Commit 8d9f5fe

Browse files
committed
Update with new NCBI ranks and make v1 alias of v2
1 parent 7fa81c5 commit 8d9f5fe

File tree

12 files changed

+76
-156
lines changed

12 files changed

+76
-156
lines changed

api/src/controllers/api/pept2lca.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async fn handler(
8787
}
8888

8989
generate_handlers! (
90-
[ V1, V2 ]
90+
[ V2 ]
9191
async fn json_handler(
9292
state => State<AppState>,
9393
params => Parameters,

api/src/controllers/api/pept2taxa.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async fn handler(
120120
}
121121

122122
generate_handlers! (
123-
[ V1, V2 ]
123+
[ V2 ]
124124
async fn json_handler(
125125
state => State<AppState>,
126126
params => Parameters,

api/src/controllers/api/peptinfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async fn handler(
110110
}
111111

112112
generate_handlers! (
113-
[ V1, V2 ]
113+
[ V2 ]
114114
async fn json_handler(
115115
state => State<AppState>,
116116
params => Parameters,

api/src/controllers/api/protinfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ async fn handler(
105105
}
106106

107107
generate_handlers! (
108-
[ V1, V2 ]
108+
[ V2 ]
109109
async fn json_handler(
110110
state => State<AppState>,
111111
params => Parameters,

api/src/controllers/api/taxa2lca.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async fn handler(
8080
}
8181

8282
generate_handlers! (
83-
[ V1, V2 ]
83+
[ V2 ]
8484
async fn json_handler(
8585
state => State<AppState>,
8686
params => Parameters,

api/src/controllers/api/taxa2tree.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn handler(
8383
}
8484

8585
generate_handlers!(
86-
[ V1, V2 ]
86+
[ V2 ]
8787
async fn json_handler(
8888
state => State<AppState>,
8989
GetContent(params) => GetContent<GetParameters>,
@@ -94,7 +94,7 @@ generate_handlers!(
9494
);
9595

9696
generate_handlers!(
97-
[ V1, V2 ]
97+
[ V2 ]
9898
async fn json_handler(
9999
state => State<AppState>,
100100
PostContent(params) => PostContent<PostParameters>,
@@ -105,7 +105,7 @@ generate_handlers!(
105105
);
106106

107107
generate_handlers!(
108-
[ V1, V2 ]
108+
[ V2 ]
109109
async fn html_handler(
110110
state => State<AppState>,
111111
GetContent(params) => GetContent<GetParameters>,
@@ -123,7 +123,7 @@ generate_handlers!(
123123
);
124124

125125
generate_handlers!(
126-
[ V1, V2 ]
126+
[ V2 ]
127127
async fn html_handler(
128128
state => State<AppState>,
129129
PostContent(params) => PostContent<PostParameters>,

api/src/controllers/api/taxonomy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async fn handler(
197197
}
198198

199199
generate_handlers!(
200-
[ V1, V2 ]
200+
[ V2 ]
201201
async fn json_handler(
202202
state => State<AppState>,
203203
params => Parameters,

api/src/helpers/lineage_helper/mod.rs

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub mod v1;
21
pub mod v2;
32

43
use datastore::{LineageStore, TaxonStore};
@@ -96,43 +95,36 @@ pub(crate) use create_lineages;
9695

9796
#[derive(Clone, Copy)]
9897
pub enum LineageVersion {
99-
V1,
10098
V2
10199
}
102100

103101
#[derive(Serialize, Debug)]
104102
#[serde(untagged)]
105103
pub enum Lineage {
106-
DefaultV1(v1::Lineage),
107-
NamesV1(v1::LineageWithNames),
108104
DefaultV2(v2::Lineage),
109105
NamesV2(v2::LineageWithNames)
110106
}
111107

112108
pub fn get_lineage(taxon_id: u32, version: LineageVersion, lineage_store: &LineageStore) -> Option<Lineage> {
113109
match version {
114-
LineageVersion::V1 => v1::get_lineage(taxon_id, lineage_store).map(Lineage::DefaultV1),
115110
LineageVersion::V2 => v2::get_lineage(taxon_id, lineage_store).map(Lineage::DefaultV2)
116111
}
117112
}
118113

119114
pub fn get_empty_lineage(version: LineageVersion) -> Option<Lineage> {
120115
match version {
121-
LineageVersion::V1 => v1::get_empty_lineage().map(Lineage::DefaultV1),
122116
LineageVersion::V2 => v2::get_empty_lineage().map(Lineage::DefaultV2)
123117
}
124118
}
125119

126120
pub fn get_lineage_array(taxon_id: u32, version: LineageVersion, lineage_store: &LineageStore) -> Vec<Option<i32>> {
127121
match version {
128-
LineageVersion::V1 => v1::get_lineage_array(taxon_id, lineage_store),
129122
LineageVersion::V2 => v2::get_lineage_array(taxon_id, lineage_store)
130123
}
131124
}
132125

133126
pub fn get_lineage_array_numeric(taxon_id: u32, version: LineageVersion, lineage_store: &LineageStore) -> Vec<i32> {
134127
match version {
135-
LineageVersion::V1 => v1::get_lineage_array_numeric(taxon_id, lineage_store),
136128
LineageVersion::V2 => v2::get_lineage_array_numeric(taxon_id, lineage_store)
137129
}
138130
}
@@ -144,35 +136,30 @@ pub fn get_lineage_with_names(
144136
taxon_store: &TaxonStore
145137
) -> Option<Lineage> {
146138
match version {
147-
LineageVersion::V1 => v1::get_lineage_with_names(taxon_id, lineage_store, taxon_store).map(Lineage::NamesV1),
148139
LineageVersion::V2 => v2::get_lineage_with_names(taxon_id, lineage_store, taxon_store).map(Lineage::NamesV2)
149140
}
150141
}
151142

152143
pub fn get_empty_lineage_with_names(version: LineageVersion) -> Option<Lineage> {
153144
match version {
154-
LineageVersion::V1 => v1::get_empty_lineage_with_names().map(Lineage::NamesV1),
155145
LineageVersion::V2 => v2::get_empty_lineage_with_names().map(Lineage::NamesV2)
156146
}
157147
}
158148

159149
pub fn get_amount_of_ranks(version: LineageVersion) -> u8 {
160150
match version {
161-
LineageVersion::V1 => 28,
162-
LineageVersion::V2 => 27
151+
LineageVersion::V2 => 28
163152
}
164153
}
165154

166155
pub fn get_genus_index(version: LineageVersion) -> u8 {
167156
match version {
168-
LineageVersion::V1 => 20,
169-
LineageVersion::V2 => 18
157+
LineageVersion::V2 => 19
170158
}
171159
}
172160

173161
pub fn get_species_index(version: LineageVersion) -> u8 {
174162
match version {
175-
LineageVersion::V1 => 24,
176-
LineageVersion::V2 => 22
163+
LineageVersion::V2 => 23
177164
}
178165
}

api/src/helpers/lineage_helper/v1.rs

-36
This file was deleted.

api/src/helpers/lineage_helper/v2.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use serde::Serialize;
55
use super::create_lineages;
66

77
create_lineages!(
8-
superkingdom,
8+
domain,
9+
realm,
910
kingdom,
1011
subkingdom,
1112
superphylum,

api/src/routes.rs

+1-31
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn create_router(state: AppState) -> Router {
4444
}
4545

4646
fn create_api_routes() -> Router<AppState> {
47-
Router::new().nest("/v1", create_api_v1_routes()).nest("/v2", create_api_v2_routes())
47+
Router::new().nest("/v1", create_api_v2_routes()).nest("/v2", create_api_v2_routes())
4848
}
4949

5050
macro_rules! define_routes {
@@ -65,36 +65,6 @@ macro_rules! define_routes {
6565

6666
pub(crate) use define_routes;
6767

68-
fn create_api_v1_routes() -> Router<AppState> {
69-
define_routes!(
70-
"/pept2ec",
71-
get(pept2ec::get_json_handler).post(pept2ec::post_json_handler),
72-
"/pept2funct",
73-
get(pept2funct::get_json_handler).post(pept2funct::post_json_handler),
74-
"/pept2go",
75-
get(pept2go::get_json_handler).post(pept2go::post_json_handler),
76-
"/pept2interpro",
77-
get(pept2interpro::get_json_handler).post(pept2interpro::post_json_handler),
78-
"/pept2lca",
79-
get(pept2lca::get_json_handler_v1).post(pept2lca::post_json_handler_v1),
80-
"/pept2prot",
81-
get(pept2prot::get_json_handler).post(pept2prot::post_json_handler),
82-
"/pept2taxa",
83-
get(pept2taxa::get_json_handler_v1).post(pept2taxa::post_json_handler_v1),
84-
"/peptinfo",
85-
get(peptinfo::get_json_handler_v1).post(peptinfo::post_json_handler_v1),
86-
"/protinfo",
87-
get(protinfo::get_json_handler_v1).post(protinfo::post_json_handler_v1),
88-
"/taxa2lca",
89-
get(taxa2lca::get_json_handler_v1).post(taxa2lca::post_json_handler_v1),
90-
"/taxa2tree",
91-
get(taxa2tree::get_json_handler_v1).post(taxa2tree::post_json_handler_v1),
92-
"/taxonomy",
93-
get(taxonomy::get_json_handler_v1).post(taxonomy::post_json_handler_v1)
94-
)
95-
.route("/taxa2tree.html", get(taxa2tree::get_html_handler_v1).post(taxa2tree::post_html_handler_v1))
96-
}
97-
9868
fn create_api_v2_routes() -> Router<AppState> {
9969
define_routes!(
10070
"/pept2ec",

0 commit comments

Comments
 (0)