Skip to content

Commit

Permalink
Add status of taxon samples variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphrasiologist committed Jan 13, 2022
1 parent 41722c4 commit a8aef29
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A command line interface for GoaT (Genomes on a Tree). GoaT presents metadata for taxa across the tree of life.

The CLI here builds URLs to query the <b><a href="https://goat.genomehubs.org/api-docs/">Goat API</a></b>. The underlying API is very powerful, but complex. The aim of this CLI is to remove some of the complexity for the end user. TSV's are returned.
The CLI here builds URLs to query the <b><a href="https://goat.genomehubs.org/api-docs/">Goat API</a></b>. The underlying API is very powerful, but complex. The aim of this CLI is to remove some of the complexity for the end user. Only TSV files are returned.

This CLI is actively being built so no guarantees are made for stability or bugs.

Expand Down Expand Up @@ -100,6 +100,9 @@ FLAGS:
-P, --ploidy Print ploidy estimates.
-r, --raw Print raw values (i.e. no aggregation/summary).
-S, --sex-determination Print sex determination data.
--status Print all data associated with how far this taxon has progressed with genomic sequencing.
This includes sample collection, acquisition, progress in sequencing, and whether
submitted to INSDC.
-t, --target-lists Print target list data associated with each taxon.
-T, --tidy Print data in tidy format.
-u, --url Print the underlying GoaT API URL(s). Useful for debugging.
Expand Down
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ async fn main() -> Result<()> {
.long("include-estimates")
.conflicts_with("raw")
.help("Include ancestral estimates. Omitting this flag includes only direct estimates from a taxon. Cannot be used with --raw.")
)
.arg(
Arg::with_name("status")
.long("status")
.help("Print all data associated with how far this taxon has progressed with genomic sequencing.\nThis includes sample collection, acquisition, progress in sequencing, and whether submitted to INSDC.")
),
)
// copy of the above.
Expand Down Expand Up @@ -363,6 +368,11 @@ async fn main() -> Result<()> {
.long("include-estimates")
.conflicts_with("raw")
.help("Include ancestral estimates. Omitting this flag includes only direct estimates from a taxon. Cannot be used with --raw.")
)
.arg(
Arg::with_name("status")
.long("status")
.help("Print all data associated with how far this taxon has progressed with genomic sequencing.\nThis includes sample collection, acquisition, progress in sequencing, and whether submitted to INSDC.")
),
)
.subcommand(
Expand Down
2 changes: 1 addition & 1 deletion src/progress/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub async fn progress_bar<'a>(matches: &clap::ArgMatches<'a>, api: &str) -> Resu

bar.set_position(progress_x_total);

if progress_x_total == progress_total_total {
if progress_x_total >= progress_total_total {
break;
}

Expand Down
3 changes: 3 additions & 0 deletions src/utils/cli_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub fn process_cli_args(
let country_list = matches.is_present("country-list");
// including estimates
let include_estimates = matches.is_present("include-estimates");
// status
let status = matches.is_present("status");

// merge the field flags
let fields = url::FieldBuilder {
Expand All @@ -69,6 +71,7 @@ pub fn process_cli_args(
plastid,
ploidy,
sex_determination,
status,
target_lists,
tidy,
};
Expand Down
43 changes: 37 additions & 6 deletions src/utils/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,25 @@ pub struct FieldBuilder {
pub busco: bool,
pub country_list: bool,
pub cvalues: bool,
pub date: bool,
pub gene_count: bool,
pub gs: bool,
pub karyotype: bool,
pub legislation: bool,
pub mitochondrion: bool,
pub n50: bool,
pub names: bool,
pub plastid: bool,
pub ploidy: bool,
pub sex_determination: bool,
pub legislation: bool,
pub names: bool,
pub status: bool,
pub target_lists: bool,
pub n50: bool,
pub tidy: bool,
pub gene_count: bool,
pub date: bool,
}

impl FieldBuilder {
// private fn used below in build_fields_string
fn as_array(&self) -> [bool; 19] {
fn as_array(&self) -> [bool; 20] {
[
self.all,
self.assembly,
Expand All @@ -90,11 +91,13 @@ impl FieldBuilder {
self.plastid,
self.ploidy,
self.sex_determination,
self.status,
self.target_lists,
self.tidy,
]
}

// add
pub fn build_fields_string(&self) -> String {
let base = "&fields=";
let delimiter = "%2C";
Expand Down Expand Up @@ -137,6 +140,16 @@ impl FieldBuilder {
let ebp_metric_date = "ebp_metric_date";
// country list
let country_list = "country_list";
// sequencing status of the taxon
// lump all these together at the moment.
let sequencing_status = "sequencing_status";
let sample_collected = "sample_collected";
let sample_acquired = "sample_acquired";
let in_progress = "in_progress";
let insdc_submitted = "insdc_submitted";
let insdc_open = "insdc_open";
let published = "published";
let sample_collected_by = "sample_collected_by";

let field_array = self.as_array();
let mut field_string = String::new();
Expand Down Expand Up @@ -244,6 +257,24 @@ impl FieldBuilder {
field_string += country_list;
field_string += delimiter;
}
if self.status || self.all {
field_string += sequencing_status;
field_string += delimiter;
field_string += sample_collected;
field_string += delimiter;
field_string += sample_acquired;
field_string += delimiter;
field_string += in_progress;
field_string += delimiter;
field_string += insdc_submitted;
field_string += delimiter;
field_string += insdc_open;
field_string += delimiter;
field_string += published;
field_string += delimiter;
field_string += sample_collected_by;
field_string += delimiter;
}

// remove the last three chars == '&2C'
field_string.drain(field_string.len() - 3..);
Expand Down

0 comments on commit a8aef29

Please sign in to comment.