Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix front-end skipping "Incertae sedis" leaf nodes #11

Open
wants to merge 4 commits into
base: catalogue_of_life_3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions back_end/refresh_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def list_flip(original_list):
orders_fixed = 0

modified = True
wrong_order_nodes = []
while modified:
modified = False

Expand All @@ -257,6 +258,12 @@ def list_flip(original_list):
if parent_tsn not in rows:
continue

if row[1] <= rows[parent_tsn][1]:
if row not in wrong_order_nodes:
print("Skipping node with wrong rank order. Child:", row, "Parent: ", rows[parent_tsn])
wrong_order_nodes.append(row)
continue

del row[3]
rows[parent_tsn][2].append(tsn)
modified = True
Expand Down
62 changes: 28 additions & 34 deletions front_end/generate_tree/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,28 @@ function truthy($val){


//Output the header row
$line = '';
$line = [];
foreach($ranks[$kingdom] as $rank_id => $rank_data){

if(!in_array($rank_id, $selected_ranks))
continue;

if($line != '')
$line .= $column_separator;

$rank_name = $rank_data[0];
$line .= $rank_name;
$line .= $column_separator.$rank_name.' GUID';
$line []= $rank_name;
$line []= $rank_name.' GUID';

if($include_authors)
$line .= $column_separator . $rank_name . ' Author';
$line []= $rank_name . ' Author';

if($include_common_names)
$line .= $column_separator . $rank_name . ' Common Name';
$line []= $rank_name . ' Common Name';

//if($fill_in_links)
$line .= $column_separator . $rank_name . ' Source';
$line []= $rank_name . ' Source';

}

$header_line = $line . $line_separator;
$header_line = implode($column_separator, $line) . $line_separator;

//send stats data
if(STATS_URL!=''){
Expand Down Expand Up @@ -230,7 +227,7 @@ function show_node(
$node,
$parent_choice_tree = [],
$parent_rank = FALSE,
$line = ''
$line = []
){

global $column_separator;
Expand Down Expand Up @@ -272,38 +269,35 @@ function show_node(
$local_result = '';
if(in_array($rank, $selected_ranks)){//the rank of this element is selected

if($line != '')
$line .= $column_separator;

if($parent_rank !== FALSE && $ranks[$kingdom][$rank][1] != $parent_rank){//if current $rank is not a direct parent of $parent_rank
//var_dump('<br><br>',$node);
$line .= handle_missing_ranks($rank, $parent_rank);
$line = array_merge($line, handle_missing_ranks($rank, $parent_rank));

}

$line .= $node_name.$column_separator.$taxon_number;
$line []= $node_name;
$line []= $taxon_number;

if($include_authors)
$line .= $column_separator . $node[0][2];
$line []= $node[0][2];

if($include_common_names)
$line .= $column_separator . $node[0][1];
$line []= $node[0][1];

if($fill_in_links)
$line .= $column_separator . 'https://www.catalogueoflife.org/data/taxon/'. $taxon_number;
$line []= 'https://www.catalogueoflife.org/data/taxon/'. $taxon_number;
else
$line .= $column_separator . $node[0][3];
$line []= $node[0][3];

$local_result .= $line . $line_separator;
$local_result .= implode($column_separator, $line) . $line_separator;

$lines_count++;

}

if($line_limit !== FALSE){
if($line_limit !== FALSE && $lines_count >= $line_limit){
$result .= $local_result;
if($lines_count >= $line_limit)
save_result();
save_result();
}


Expand Down Expand Up @@ -332,7 +326,6 @@ function handle_missing_ranks(
global $kingdom;
global $ranks;
global $selected_ranks;
global $column_separator;
global $include_authors;
global $include_common_names;
global $required_ranks;
Expand All @@ -341,31 +334,32 @@ function handle_missing_ranks(
if($rank == 0)
return '';

$line = '';
$line = [];
if(!$direct_call && in_array($rank, $selected_ranks)){

if(in_array($rank, $required_ranks))//show required && missing ranks
$line .= 'incertae sedis';
$line[]= 'incertae sedis';
else
$line[] = '';

$count = 2;
// For GUID
$line[] = '';

if($include_authors)
$count++;
$line[] = '';

if($include_common_names)
$count++;
$line[] = '';

if($fill_in_links)
$count++;

$line .= str_repeat($column_separator, $count);
$line[] = '';

}

$parent_rank = $ranks[$kingdom][$rank][1];

if($parent_rank != $target_rank)
$line = handle_missing_ranks($parent_rank, $target_rank, FALSE) . $line;
$line = array_merge(handle_missing_ranks($parent_rank, $target_rank, FALSE), $line);

return $line;

Expand Down
4 changes: 2 additions & 2 deletions front_end/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

//Show the tree and other options

$display_down_to = 'Order'; ?>
$display_down_to = 'Family'; ?>

<h3>Step 2: Choose export data type</h3>
<label>
Expand All @@ -95,7 +95,7 @@

foreach($ranks[$kingdom] as $rank_id => &$rank_data){

if($rank_data[0]==$display_down_to)
if(ucfirst($rank_data[0])==ucfirst($display_down_to))
$stop_rank = $rank_id;

if($parent_rank_id!=0)
Expand Down
2 changes: 1 addition & 1 deletion front_end/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $( function () {
const ul = child.find('> ul');
//if(child_name.substr(0,4)==='(no ')
if(child_name==='incertae sedis')
tree = get_children(ul);
tree = {...tree, ...get_children(ul)};

else if(child.hasClass('mixed')){
if(ul.length===1)
Expand Down