Skip to content

Commit

Permalink
Add GPML import/export support
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanbalci committed Dec 11, 2023
1 parent d80fda0 commit 384cba4
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 15 deletions.
45 changes: 42 additions & 3 deletions app/js/app-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,11 @@ module.exports = function() {
$("#import-experimental-data").click(function () {
$("#overlay-data").trigger('click');
});

$("#import-SBML-file").click(function () {
$("#sbml-file").trigger('click');
});

$("#import-simple-af-file").click(function () {
$("#simple-af-file-input").trigger('click');
});
Expand All @@ -409,6 +411,10 @@ module.exports = function() {
$("#sif-layout-input").trigger('click');
});

$("#import-GPML-file").click(function () {
$("#gpml-file-input").trigger('click');
});

$("#overlay-data").change(function () {
var chiseInstance = appUtilities.getActiveChiseInstance();
var cy = appUtilities.getActiveCy();
Expand Down Expand Up @@ -488,6 +494,34 @@ module.exports = function() {
$(this).val("");
}
});

$("#gpml-file-input").change(function () {

var chiseInstance = appUtilities.getActiveChiseInstance();
var cy = appUtilities.getActiveCy();
if ($(this).val() != "") {
var file = this.files[0];
appUtilities.setFileContent(file.name);
chiseInstance.loadGpml(file, success = function(data){
if (cy.elements().length !== 0) {
promptConfirmationView.render(function () {
chiseInstance.loadSBGNMLText(data.message, false, file.name, cy);
});
}
else {
chiseInstance.loadSBGNMLText(data.message, false, file.name, cy);
}
},
error = function(data){
promptFileConversionErrorView.render();
document.getElementById("file-conversion-error-message").innerText = "Conversion service is not available!";

});

$(this).val("");
}
});

$("#simple-af-file-input").change(function () {
var chiseInstance = appUtilities.getActiveChiseInstance();

Expand Down Expand Up @@ -1454,14 +1488,19 @@ module.exports = function() {
$("#export-as-sbgnml-plain-file").click(function (evt) {
fileSaveView.render("sbgn", "plain");
});

$("#export-as-sbgnml3-plain-file").click(function (evt) {
fileSaveView.render("sbgn", "plain3");
});

$("#export-as-sbml").click(function (evt) {
fileSaveView.render("sbml", null, null);

$("#export-as-sbml").click(function (evt) {
fileSaveView.render("sbml", null, null);
});

$("#export-as-gpml").click(function (evt) {
fileSaveView.render("gpml", null, null);
});

$("#add-complex-for-selected").click(function (e) {

// use active chise instance
Expand Down
34 changes: 22 additions & 12 deletions app/js/app-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -2647,16 +2647,30 @@ appUtilities.launchWithModelFile = function() {
loadFcn();

}

if (fileExtension === "gpml") {
chiseInstance.loadGpml(file, success = async function (data) {
if (cyInstance.elements().length !== 0) {
promptConfirmationView.render( function () {
chiseInstance.loadSBGNMLText(data, false, filename, cy, paramObj);
chiseInstance.endSpinner('paths-byURL-spinner');
});

chiseInstance.endSpinner("paths-byURL-spinner");
}
else {
await chiseInstance.loadSBGNMLText(data.message, false, filename, cy, paramObj);
chiseInstance.endSpinner("paths-byURL-spinner");
}
});
}
else if (fileExtension === "xml" || fileExtension === "sbml") {

// CD file
if (xmlObject.children.item(0).getAttribute('xmlns:celldesigner')) {
chiseInstance.loadCellDesigner(file, success = async function (data) {
if (cyInstance.elements().length !== 0) {
promptConfirmationView.render( function () {
chiseInstance.loadSBGNMLText(data, false, filename, cy, paramObj);
chiseInstance.endSpinner('paths-byURL-spinner')
promptConfirmationView.render( function () {
chiseInstance.loadSBGNMLText(data, false, filename, cy, paramObj);
chiseInstance.endSpinner('paths-byURL-spinner');
});

chiseInstance.endSpinner("paths-byURL-spinner");
Expand All @@ -2674,18 +2688,14 @@ appUtilities.launchWithModelFile = function() {
await promptConfirmationView.render(async function () {
await chiseInstance.loadSBGNMLText(data.message, false, filename, cy, paramObj);
});
chiseInstance.endSpinner('paths-byURL-spinner')

chiseInstance.endSpinner('paths-byURL-spinner');
}
else {
await chiseInstance.loadSBGNMLText(data.message, false, filename, cy, paramObj);
chiseInstance.endSpinner('paths-byURL-spinner')


await chiseInstance.loadSBGNMLText(data.message, false, filename, cy, paramObj);
chiseInstance.endSpinner('paths-byURL-spinner');
}
});
}

}
else {
await chiseInstance.loadNwtFile(file, loadCallbackSBGNMLValidity, loadCallbackInvalidityWarning, paramObj);
Expand Down
13 changes: 13 additions & 0 deletions app/js/backbone-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,9 @@ var FileSaveView = Backbone.View.extend({
case 'sbml':
fExt = 'sbml'
break;
case 'gpml':
fExt = 'gpml'
break;
case 'sif':
fExt = 'sif'
break;
Expand Down Expand Up @@ -2712,6 +2715,16 @@ var FileSaveView = Backbone.View.extend({
});

}
else if(fileformat === "gpml")
{
chiseInstance.saveAsGpml(filename, function(data,errorMessage){

var promptSbmlConversionErrorView = new PromptSbmlConversionErrorView({el: '#prompt-sbmlConversionError-table'});
promptSbmlConversionErrorView.render(data,errorMessage);
//document.getElementById("file-conversion-error-message").innerText = "Conversion service is not available!";
});

}
else if(fileformat === "sif")
{
chiseInstance.saveAsPlainSif( filename, true );
Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@
<input id="sif-layout-input" type="file" style="display:none" />
<input id="sbml-file" type="file" style="display:none" />
<input id="celldesigner-file-input" type="file" style="display:none" />
<input id="gpml-file-input" type="file" style="display:none" />
<li><a href="#" id="import-simple-af-file">Simple AF</a></li>
<li><a href="#" id="import-sif-file">SIF</a></li>
<li><a href="#" id="import-sif-style">SIF Style</a></li>
<li><a href="#" id="import-sif-layout">SIF Layout</a></li>
<li><a href="#" id="import-SBML-file">SBML</a></li>
<li><a href="#" id="import-celldesigner-file">CellDesigner</a></li>
<li><a href="#" id="import-GPML-file">GPML</a></li>
</ul>
</li>
<li class="dropdown-submenu">
Expand All @@ -123,6 +125,7 @@
<li><a href="#" id="export-to-sif-layout">SIF Layout</a></li>
<li><a href="#" id="export-as-sbml">SBML</a></li>
<li><a href="#" id="export-as-celldesigner-file">CellDesigner</a></li>
<li><a href="#" id="export-as-gpml">GPML</a></li>
</ul>
</li>
<li class="dropdown-submenu">
Expand Down

0 comments on commit 384cba4

Please sign in to comment.