Skip to content

Commit

Permalink
Merge pull request #3741 from solgenomics/topic/migrate_tools_brapiv2
Browse files Browse the repository at this point in the history
Topic/migrate tools brapiv2 - pedigree tool
  • Loading branch information
lukasmueller authored Sep 27, 2021
2 parents 7c55439 + acafcdb commit fcd4678
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 34 deletions.
59 changes: 39 additions & 20 deletions js/source/legacy/brapi/PedigreeViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,46 @@ function PedigreeViewer(server,auth,version,urlFunc){
}).map(function(ped_pro_germId){
var mother = null,
father = null;
if(ped_pro_germId[0].parent1Type=="FEMALE"){
mother = ped_pro_germId[0].parent1DbId;
}
if(ped_pro_germId[0].parent1Type=="MALE"){
father = ped_pro_germId[0].parent1DbId;
}
if(ped_pro_germId[0].parent2Type=="FEMALE"){
mother = ped_pro_germId[0].parent2DbId;
}
if(ped_pro_germId[0].parent2Type=="MALE"){
father = ped_pro_germId[0].parent2DbId;

if(version=='v1.3'){
if(ped_pro_germId[0].parent1Type=="FEMALE"){
mother = ped_pro_germId[0].parent1DbId;
}
if(ped_pro_germId[0].parent1Type=="MALE"){
father = ped_pro_germId[0].parent1DbId;
}
if(ped_pro_germId[0].parent2Type=="FEMALE"){
mother = ped_pro_germId[0].parent2DbId;
}
if(ped_pro_germId[0].parent2Type=="MALE"){
father = ped_pro_germId[0].parent2DbId;
}
return {
'id':ped_pro_germId[2],
'mother_id':mother,
'father_id':father,
'name':ped_pro_germId[1].defaultDisplayName,
'children':ped_pro_germId[1].progeny.filter(Boolean).map(function(d){
return d.germplasmDbId;
})
};
} else {
var i = ped_pro_germId[0].parents.map(function(e) { return e.parentType; }).indexOf('FEMALE');
var j = ped_pro_germId[0].parents.map(function(e) { return e.parentType; }).indexOf('MALE');

if(i>=0) mother = ped_pro_germId[0].parents[i].germplasmDbId;
if(j>=0) father = ped_pro_germId[0].parents[j].germplasmDbId;

return {
'id':ped_pro_germId[2],
'mother_id':mother,
'father_id':father,
'name':ped_pro_germId[1].germplasmName,
'children':ped_pro_germId[1].progeny.filter(Boolean).map(function(d){
return d.germplasmDbId;
})
};
}
return {
'id':ped_pro_germId[2],
'mother_id':mother,
'father_id':father,
'name':ped_pro_germId[1].defaultDisplayName,
'children':ped_pro_germId[1].progeny.filter(Boolean).map(function(d){
return d.germplasmDbId;
})
};
}).each(function(node){
loaded_nodes[node.id] = node;
}).all(callback);
Expand Down
4 changes: 2 additions & 2 deletions js/source/legacy/d3/d3-pedigree-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

function pdgtree(){
//create working nodes from input data (we dont want to modify the input)

var node_list = _wrap_nodes(data);
node_list.forEach(function(d){_setNodeLevels(d);});
_setBestRootNodeLevels(node_list);

//create intermediate nodes for intergenerational links
var intermediates = {};
for (var n = node_list.length-1; n > -1; n--) {
Expand Down
24 changes: 14 additions & 10 deletions lib/CXGN/BrAPI/v2/Germplasm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@ sub germplasm_pedigree {
};
}
$cross_plan = $cross_type;
$mother = $female_parent_name ? $female_parent_name : "NA";
$father = $male_parent_name ? $male_parent_name : "NA";
}

#Cross information
Expand Down Expand Up @@ -368,18 +366,24 @@ sub germplasm_pedigree {
}
}

my $parent = [
{
germplasmDbId=>qq|$female_parent_stock_id|,
#Add parents:
my $parent = [];
if ($female_parent_stock_id){
push @$parent, {
germplasmDbId=>$female_parent_stock_id ? qq|$female_parent_stock_id| : $female_parent_stock_id ,
germplasmName=>$mother,
parentType=>'FEMALE',
},
{
germplasmDbId=>qq|$male_parent_stock_id|,
};
}
if ($male_parent_stock_id){
push @$parent, {
germplasmDbId=>$male_parent_stock_id ? qq|$male_parent_stock_id| : $male_parent_stock_id,
germplasmName=>$father,
parentType=>'MALE',
},
];
}

}

%result = (
crossingProjectDbId=>$membership_info[0][0],
crossingYear=>$membership_info[0][5],
Expand Down
4 changes: 2 additions & 2 deletions mason/pedigree/stock_pedigree.mas
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ $stock_id
(function() {
'use strict';
var STOCK_ID = "<% $stock_id %>";
var base_url="/brapi/v1";
var base_url="/brapi/v2";
var auth_token;
var require_login = "<% $c->get_conf('brapi_require_login') %>";
if (require_login === '1'){
Expand All @@ -225,7 +225,7 @@ $stock_id
}
}

var pdg = PedigreeViewer(base_url,auth_token,'v1.3',function(dbId){
var pdg = PedigreeViewer(base_url,auth_token,'v2.0',function(dbId){
return "/stock/"+dbId+"/view";
});
pdg.newTree(STOCK_ID,function(){
Expand Down

0 comments on commit fcd4678

Please sign in to comment.