Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
6db7ca4c
Commit
6db7ca4c
authored
Apr 04, 2019
by
Piotr Gawron
Browse files
heuristic for checking if SBML file is Cellesigner or not
parent
1d81650b
Pipeline
#9657
passed with stage
in 11 minutes and 36 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
6db7ca4c
...
...
@@ -29,6 +29,8 @@ minerva (12.3.0~alpha.0) unstable; urgency=low
*
Small
improvement
:
Info
tab
provides
information
about
model
annotations
and
submap
tabs
provide
information
about
submaps
annotations
if
applicable
(#
591
)
*
Small
improvement
:
uploading
sbml
file
should
automatically
discover
a
file
type
(#
784
)
*
Bug
fix
:
progress
bar
of
gene
genome
mapping
upload
is
refreshing
properly
(#
728
)
*
Bug
fix
:
when
editing
project
Disease
and
Organism
could
not
be
removed
...
...
frontend-js/package-lock.json
View file @
6db7ca4c
...
...
@@ -4958,6 +4958,15 @@
}
}
},
"stream-to-blob"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npmjs.org/stream-to-blob/-/stream-to-blob-1.0.1.tgz"
,
"integrity"
:
"sha512-aRy4neA4rf+qMtLT9fCRLPGWdrsIKtCx4kUdNTIPgPQ2hkHkdxbViVAvABMx9oRM6yCWfngHx6pwXfbYkVuPuw=="
,
"dev"
:
true
,
"requires"
:
{
"once"
:
"1.4.0"
}
},
"string-width"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz"
,
...
...
frontend-js/package.json
View file @
6db7ca4c
...
...
@@ -37,6 +37,7 @@
"mocha"
:
"^3.5.3"
,
"mock-local-storage"
:
"^1.1.8"
,
"molart"
:
"1.3.1"
,
"stream-to-blob"
:
"^1.0.1"
,
"uglifyjs"
:
"^2.4.10"
},
"dependencies"
:
{
...
...
frontend-js/src/main/js/gui/admin/AddProjectDialog.js
View file @
6db7ca4c
...
...
@@ -171,7 +171,24 @@ AddProjectDialog.prototype.createGeneralTabContent = function () {
});
self
.
addListener
(
"
onFileUpload
"
,
function
(
e
)
{
var
file
=
e
.
arg
;
return
self
.
setFileParserForFilename
(
file
.
name
);
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
reader
=
new
FileReader
();
reader
.
readAsText
(
file
);
reader
.
onload
=
function
(
e
)
{
try
{
resolve
(
e
.
target
.
result
);
}
catch
(
error
)
{
reject
(
error
);
}
};
reader
.
onerror
=
function
()
{
reject
(
new
Error
(
"
Problem reading file
"
));
};
}).
then
(
function
(
content
)
{
return
self
.
setFileParserForFilename
(
file
.
name
,
content
);
})
});
var
manualUrl
=
self
.
getConfiguration
().
getOption
(
ConfigurationType
.
USER_MANUAL_FILE
).
getValue
();
...
...
@@ -1083,25 +1100,46 @@ AddProjectDialog.prototype.isSemanticZoomingContainsMultipleOverlays = function
/**
*
* @param {string} filename
* @param {string} content
*/
AddProjectDialog
.
prototype
.
setFileParserForFilename
=
function
(
filename
)
{
AddProjectDialog
.
prototype
.
setFileParserForFilename
=
function
(
filename
,
content
)
{
var
self
=
this
;
self
.
_filename
=
filename
;
var
select
=
$
(
"
[name='project-format']
"
,
self
.
getElement
)[
0
];
var
options
=
select
.
options
;
var
optionId
=
0
;
var
isCellDesigner
=
self
.
isCellDesignerContent
(
content
);
for
(
var
i
=
0
;
i
<
options
.
length
;
i
++
)
{
var
option
=
options
[
i
];
if
(
option
.
value
!==
undefined
)
{
var
extension
=
option
.
data
;
if
(
filename
.
endsWith
(
extension
)
&&
optionId
<=
0
)
{
optionId
=
i
;
if
(
extension
===
"
xml
"
)
{
//for xml we need to check if it's CellDesigner option
if
(
isCellDesigner
)
{
optionId
=
i
;
}
else
if
(
option
.
innerHTML
.
indexOf
(
"
CellDesigner
"
)
===
-
1
)
{
optionId
=
i
;
}
}
else
{
optionId
=
i
;
}
}
}
}
options
[
optionId
].
selected
=
true
;
};
/**
*
* @param {string} content
* @return {boolean}
*/
AddProjectDialog
.
prototype
.
isCellDesignerContent
=
function
(
content
)
{
return
content
.
indexOf
(
"
xmlns:celldesigner=
\"
http://www.sbml.org/2001/ns/celldesigner
\"
"
)
>=
0
;
};
/**
*
* @returns {*}
...
...
@@ -1336,19 +1374,20 @@ AddProjectDialog.prototype.createZipEntry = function (jsZipEntry, zipObject) {
}
if
(
type
===
"
MAP
"
)
{
var
name
=
jsZipEntry
.
name
.
toLowerCase
();
this
.
setFileParserForFilename
(
name
);
if
(
name
.
indexOf
(
"
.
"
)
>
0
)
{
name
=
name
.
substr
(
0
,
name
.
indexOf
(
"
.
"
));
}
if
(
name
.
lastIndexOf
(
"
\\
"
)
>=
0
)
{
name
=
name
.
substr
(
name
.
lastIndexOf
(
"
\\
"
)
+
1
);
}
if
(
name
.
lastIndexOf
(
"
/
"
)
>=
0
)
{
name
=
name
.
substr
(
name
.
lastIndexOf
(
"
/
"
)
+
1
);
}
data
.
name
=
name
;
processingPromise
=
processingPromise
.
then
(
function
()
{
processingPromise
=
zipObject
.
file
(
jsZipEntry
.
name
).
async
(
"
string
"
).
then
(
function
(
content
)
{
self
.
setFileParserForFilename
(
name
,
content
);
if
(
name
.
indexOf
(
"
.
"
)
>
0
)
{
name
=
name
.
substr
(
0
,
name
.
indexOf
(
"
.
"
));
}
if
(
name
.
lastIndexOf
(
"
\\
"
)
>=
0
)
{
name
=
name
.
substr
(
name
.
lastIndexOf
(
"
\\
"
)
+
1
);
}
if
(
name
.
lastIndexOf
(
"
/
"
)
>=
0
)
{
name
=
name
.
substr
(
name
.
lastIndexOf
(
"
/
"
)
+
1
);
}
data
.
name
=
name
;
}).
then
(
function
()
{
var
configuration
=
self
.
getConfiguration
();
var
mapTypes
=
configuration
.
getMapTypes
();
for
(
var
i
=
0
;
i
<
mapTypes
.
length
;
i
++
)
{
...
...
frontend-js/src/test/js/gui/admin/AddProjectDialog-test.js
View file @
6db7ca4c
...
...
@@ -6,13 +6,13 @@ var AddProjectDialog = require('../../../../main/js/gui/admin/AddProjectDialog')
var
ServerConnector
=
require
(
'
../../ServerConnector-mock
'
);
var
ValidationError
=
require
(
'
../../../../main/js/ValidationError
'
);
var
Promise
=
require
(
'
bluebird
'
);
var
logger
=
require
(
'
../../logger
'
);
var
fs
=
require
(
"
fs
"
);
var
chai
=
require
(
'
chai
'
);
var
assert
=
chai
.
assert
;
var
toBlob
=
require
(
'
stream-to-blob
'
);
describe
(
'
AddProjectDialog
'
,
function
()
{
/**
...
...
@@ -75,6 +75,49 @@ describe('AddProjectDialog', function () {
return
dialog
.
destroy
();
});
});
it
(
'
sbml file
'
,
function
()
{
var
dialog
=
createDialog
();
var
file
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
toBlob
(
fs
.
createReadStream
(
'
testFiles/map/sbml.xml
'
),
function
(
err
,
blob
)
{
if
(
err
)
return
reject
(
err
.
message
);
file
=
blob
;
file
.
name
=
"
sbml.xml
"
;
resolve
(
blob
);
})
}).
then
(
function
()
{
return
dialog
.
init
();
}).
then
(
function
()
{
return
dialog
.
callListeners
(
"
onFileUpload
"
,
file
);
}).
then
(
function
()
{
var
converter
=
dialog
.
getConverter
();
assert
.
equal
(
"
sbml
"
,
converter
.
name
.
toLowerCase
());
return
dialog
.
destroy
();
});
});
it
(
'
CellDesigner file
'
,
function
()
{
var
dialog
=
createDialog
();
var
file
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
toBlob
(
fs
.
createReadStream
(
'
testFiles/map/cell_designer.xml
'
),
function
(
err
,
blob
)
{
if
(
err
)
return
reject
(
err
.
message
);
file
=
blob
;
file
.
name
=
"
sbml.xml
"
;
resolve
(
blob
);
})
}).
then
(
function
()
{
return
dialog
.
init
();
}).
then
(
function
()
{
return
dialog
.
callListeners
(
"
onFileUpload
"
,
file
);
}).
then
(
function
()
{
var
converter
=
dialog
.
getConverter
();
assert
.
notEqual
(
"
sbml
"
,
converter
.
name
.
toLowerCase
());
return
dialog
.
destroy
();
});
});
});
describe
(
'
setZipFileContent
'
,
function
()
{
...
...
frontend-js/testFiles/map/cell_designer.xml
0 → 100644
View file @
6db7ca4c
<?xml version="1.0" encoding="UTF-8"?>
<sbml
xmlns=
"http://www.sbml.org/sbml/level2/version4"
xmlns:celldesigner=
"http://www.sbml.org/2001/ns/celldesigner"
level=
"2"
version=
"4"
>
<model
metaid=
"untitled"
id=
"untitled"
>
<annotation>
<celldesigner:extension>
<celldesigner:modelVersion>
4.0
</celldesigner:modelVersion>
<celldesigner:modelDisplay
sizeX=
"600"
sizeY=
"400"
/>
<celldesigner:listOfCompartmentAliases/>
<celldesigner:listOfComplexSpeciesAliases/>
<celldesigner:listOfSpeciesAliases/>
<celldesigner:listOfGroups/>
<celldesigner:listOfProteins/>
<celldesigner:listOfGenes/>
<celldesigner:listOfRNAs/>
<celldesigner:listOfAntisenseRNAs/>
<celldesigner:listOfLayers/>
<celldesigner:listOfBlockDiagrams/>
</celldesigner:extension>
</annotation>
<listOfUnitDefinitions>
<unitDefinition
metaid=
"substance"
id=
"substance"
name=
"substance"
>
<listOfUnits>
<unit
metaid=
"CDMT00001"
kind=
"mole"
/>
</listOfUnits>
</unitDefinition>
<unitDefinition
metaid=
"volume"
id=
"volume"
name=
"volume"
>
<listOfUnits>
<unit
metaid=
"CDMT00002"
kind=
"litre"
/>
</listOfUnits>
</unitDefinition>
<unitDefinition
metaid=
"area"
id=
"area"
name=
"area"
>
<listOfUnits>
<unit
metaid=
"CDMT00003"
kind=
"metre"
exponent=
"2"
/>
</listOfUnits>
</unitDefinition>
<unitDefinition
metaid=
"length"
id=
"length"
name=
"length"
>
<listOfUnits>
<unit
metaid=
"CDMT00004"
kind=
"metre"
/>
</listOfUnits>
</unitDefinition>
<unitDefinition
metaid=
"time"
id=
"time"
name=
"time"
>
<listOfUnits>
<unit
metaid=
"CDMT00005"
kind=
"second"
/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment
metaid=
"default"
id=
"default"
size=
"1"
units=
"volume"
/>
</listOfCompartments>
</model>
</sbml>
frontend-js/testFiles/map/sbml.xml
0 → 100644
View file @
6db7ca4c
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!-- Created by minerva version 12.2.1 on 2019-04-04 at 12:55:58 CEST with JSBML version 1.4. -->
<sbml
xmlns=
"http://www.sbml.org/sbml/level3/version2/core"
layout:required=
"false"
level=
"3"
multi:required=
"true"
render:required=
"false"
version=
"2"
xmlns:layout=
"http://www.sbml.org/sbml/level3/version1/layout/version1"
xmlns:multi=
"http://www.sbml.org/sbml/level3/version1/multi/version1"
xmlns:render=
"http://www.sbml.org/sbml/level3/version1/render/version1"
>
<model
areaUnits=
"area"
extentUnits=
"mole"
id=
"untitled"
lengthUnits=
"metre"
name=
"NEW DISEASE MAP"
substanceUnits=
"mole"
timeUnits=
"second"
volumeUnits=
"litre"
>
<notes>
<body
xmlns=
"http://www.w3.org/1999/xhtml"
>
<p/>
</body>
</notes>
<layout:listOfLayouts
xmlns:layout=
"http://www.sbml.org/sbml/level3/version1/layout/version1"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
>
<layout:layout
layout:id=
"minerva_layout"
>
<layout:dimensions
layout:height=
"400"
layout:width=
"600"
/>
<layout:listOfCompartmentGlyphs>
<layout:compartmentGlyph
layout:compartment=
"default"
layout:id=
"default_compartment"
>
<layout:boundingBox>
<layout:position
layout:x=
"0"
layout:y=
"0"
/>
<layout:dimensions
layout:height=
"400"
layout:width=
"600"
/>
</layout:boundingBox>
</layout:compartmentGlyph>
</layout:listOfCompartmentGlyphs>
</layout:layout>
</layout:listOfLayouts>
<listOfUnitDefinitions>
<unitDefinition
id=
"substance"
name=
"substance"
>
<listOfUnits>
<unit
exponent=
"1"
kind=
"mole"
multiplier=
"1"
scale=
"0"
/>
</listOfUnits>
</unitDefinition>
<unitDefinition
id=
"area"
name=
"area"
>
<listOfUnits>
<unit
exponent=
"2"
kind=
"metre"
multiplier=
"1"
scale=
"0"
/>
</listOfUnits>
</unitDefinition>
<unitDefinition
id=
"time"
name=
"time"
>
<listOfUnits>
<unit
exponent=
"1"
kind=
"second"
multiplier=
"1"
scale=
"0"
/>
</listOfUnits>
</unitDefinition>
<unitDefinition
id=
"length"
name=
"length"
>
<listOfUnits>
<unit
exponent=
"1"
kind=
"metre"
multiplier=
"1"
scale=
"0"
/>
</listOfUnits>
</unitDefinition>
<unitDefinition
id=
"volume"
name=
"volume"
>
<listOfUnits>
<unit
exponent=
"1"
kind=
"litre"
multiplier=
"1"
scale=
"0"
/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment
constant=
"false"
id=
"default"
multi:isType=
"false"
size=
"1"
spatialDimensions=
"3"
>
<notes>
<body
xmlns=
"http://www.w3.org/1999/xhtml"
>
<p/>
</body>
</notes>
<annotation>
<rdf:RDF
xmlns:rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:dcterms=
"http://purl.org/dc/terms/"
xmlns:vCard=
"http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:bqbiol=
"http://biomodels.net/biology-qualifiers/"
xmlns:bqmodel=
"http://biomodels.net/model-qualifiers/"
>
<rdf:Description
rdf:about=
"#"
>
</rdf:Description>
</rdf:RDF>
</annotation>
</compartment>
</listOfCompartments>
</model>
</sbml>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment