Skip to content

Fix missing column separator in the file #5

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

Open
wants to merge 3 commits into
base: worms
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
5 changes: 4 additions & 1 deletion back_end/refresh_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def list_flip(original_list):
print('Finding parent nodes')

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

Expand All @@ -249,7 +250,9 @@ def list_flip(original_list):
continue

if row[1] < rows[parent_tsn][1]:
print("Skipping node with wrong rank order: " + row[0][3])
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]
Expand Down
65 changes: 30 additions & 35 deletions front_end/generate_tree/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,30 @@ 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';

$line .= $column_separator . $rank_name . ' Remarks';
$line[] = $rank_name . ' Remarks';

//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 @@ -231,7 +228,7 @@ function show_node(
$node,
$parent_choice_tree = [],
$parent_rank = FALSE,
$line = ''
$line = []
){

global $column_separator;
Expand Down Expand Up @@ -273,35 +270,33 @@ 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
$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 . substr($node[0][2], 0, 128);
$line[] = substr($node[0][2], 0, 128);

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

$line .= $column_separator . 'WoRMS Editorial Board (2021). World Register of Marine Species. Available from https://www.marinespecies.org at VLIZ. Accessed 10-22-2021. http://doi.org/10.14284/170';
$line[] = 'WoRMS Editorial Board (2021). World Register of Marine Species. Available from https://www.marinespecies.org at VLIZ. Accessed 10-22-2021. http://doi.org/10.14284/170';

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++;

}
else
// Handle cases when one of the required ranks is not selected/missing in the data
$line .= handle_missing_ranks($rank, $parent_rank);
$line = array_merge($line, handle_missing_ranks($rank, $parent_rank));

if($line_limit !== FALSE){
$result .= $local_result;
Expand Down Expand Up @@ -344,35 +339,35 @@ 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[] = '';

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

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

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

// Remarks
$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