Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
4b63adc8
Commit
4b63adc8
authored
Jan 25, 2018
by
Piotr Gawron
Browse files
allow user to upload overlay and filter by model_name
parent
28e88325
Pipeline
#3081
passed with stage
in 48 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java
View file @
4b63adc8
...
...
@@ -792,6 +792,8 @@ public class LayoutService implements ILayoutService {
sb
.
append
(
"\t"
);
}
else
if
(
column
.
equals
(
ColorSchemaColumn
.
NAME
))
{
sb
.
append
(
schema
.
getName
()
+
"\t"
);
}
else
if
(
column
.
equals
(
ColorSchemaColumn
.
MODEL_NAME
))
{
sb
.
append
(
schema
.
getModelName
()
+
"\t"
);
}
else
if
(
column
.
equals
(
ColorSchemaColumn
.
VALUE
))
{
sb
.
append
(
schema
.
getValue
()
+
"\t"
);
}
else
if
(
column
.
equals
(
ColorSchemaColumn
.
COMPARTMENT
))
{
...
...
@@ -847,6 +849,8 @@ public class LayoutService implements ILayoutService {
sb
.
append
(
"\t"
);
}
else
if
(
column
.
equals
(
ColorSchemaColumn
.
NAME
))
{
sb
.
append
(
schema
.
getName
()
+
"\t"
);
}
else
if
(
column
.
equals
(
ColorSchemaColumn
.
MODEL_NAME
))
{
sb
.
append
(
schema
.
getModelName
()
+
"\t"
);
}
else
if
(
column
.
equals
(
ColorSchemaColumn
.
VALUE
))
{
sb
.
append
(
schema
.
getValue
()
+
"\t"
);
}
else
if
(
column
.
equals
(
ColorSchemaColumn
.
COMPARTMENT
))
{
...
...
service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java
View file @
4b63adc8
...
...
@@ -157,6 +157,7 @@ public class ColorSchemaReader {
Integer
colorColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
COLOR
);
Integer
contigColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
CONTIG
);
Integer
nameColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
NAME
);
Integer
modelNameColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
MODEL_NAME
);
Integer
identifierColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
IDENTIFIER
);
Integer
variantIdentifierColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
VARIANT_IDENTIFIER
);
Integer
allelFrequencyColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
ALLEL_FREQUENCY
);
...
...
@@ -202,6 +203,9 @@ public class ColorSchemaReader {
if
(
nameColumn
!=
null
)
{
processNameColumn
(
schema
,
values
[
nameColumn
]);
}
if
(
modelNameColumn
!=
null
)
{
processModelNameColumn
(
schema
,
values
[
modelNameColumn
]);
}
if
(
compartmentColumn
!=
null
)
{
processCompartmentColumn
(
schema
,
values
[
compartmentColumn
]);
}
...
...
@@ -328,6 +332,12 @@ public class ColorSchemaReader {
schema
.
setName
(
content
);
}
}
private
void
processModelNameColumn
(
ColorSchema
schema
,
String
content
)
{
if
(!
content
.
isEmpty
())
{
schema
.
setModelName
(
content
);
}
}
/**
* Sets proper compartment names to {@link ColorSchema} from cell content.
...
...
@@ -463,6 +473,7 @@ public class ColorSchemaReader {
Integer
valueColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
VALUE
);
Integer
colorColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
COLOR
);
Integer
nameColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
NAME
);
Integer
modelNameColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
MODEL_NAME
);
Integer
identifierColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
IDENTIFIER
);
Integer
reactionIdentifierColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
REACTION_IDENTIFIER
);
Integer
compartmentColumn
=
schemaColumns
.
get
(
ColorSchemaColumn
.
COMPARTMENT
);
...
...
@@ -499,6 +510,9 @@ public class ColorSchemaReader {
if
(
nameColumn
!=
null
)
{
processNameColumn
(
schema
,
values
[
nameColumn
]);
}
if
(
modelNameColumn
!=
null
)
{
processModelNameColumn
(
schema
,
values
[
modelNameColumn
]);
}
if
(
valueColumn
!=
null
)
{
schema
.
setValue
(
parseValueColumn
(
values
[
valueColumn
],
errorPrefix
));
}
...
...
@@ -729,6 +743,9 @@ public class ColorSchemaReader {
if
(
schema
.
getName
()
!=
null
)
{
result
.
add
(
ColorSchemaColumn
.
NAME
);
}
if
(
schema
.
getModelName
()
!=
null
)
{
result
.
add
(
ColorSchemaColumn
.
MODEL_NAME
);
}
if
(
schema
.
getReactionIdentifier
()
!=
null
)
{
result
.
add
(
ColorSchemaColumn
.
REACTION_IDENTIFIER
);
}
...
...
service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaXlsxReader.java
View file @
4b63adc8
...
...
@@ -58,7 +58,8 @@ public class ColorSchemaXlsxReader {
* @throws InvalidColorSchemaException
* invalid color schema exception.
*/
public
Collection
<
ColorSchema
>
readColorSchema
(
String
fileName
,
String
sheetName
)
throws
IOException
,
InvalidColorSchemaException
{
public
Collection
<
ColorSchema
>
readColorSchema
(
String
fileName
,
String
sheetName
)
throws
IOException
,
InvalidColorSchemaException
{
ColorParser
colorParser
=
new
ColorParser
();
List
<
ColorSchema
>
result
=
new
ArrayList
<>();
FileInputStream
file
=
null
;
...
...
@@ -89,6 +90,7 @@ public class ColorSchemaXlsxReader {
Integer
valueColumn
=
null
;
Integer
colorColumn
=
null
;
Integer
nameColumn
=
null
;
Integer
modelNameColumn
=
null
;
Integer
identifierColumn
=
null
;
Integer
reactionIdentifierColumn
=
null
;
Integer
compartmentColumn
=
null
;
...
...
@@ -135,7 +137,8 @@ public class ColorSchemaXlsxReader {
}
if
(!
found
)
{
if
(
acceptableIdentifiers
.
keySet
().
contains
(
value
.
toLowerCase
()))
{
foundCustomIdentifiers
.
add
(
new
Pair
<
MiriamType
,
Integer
>(
acceptableIdentifiers
.
get
(
value
.
toLowerCase
()),
columnIndex
-
1
));
foundCustomIdentifiers
.
add
(
new
Pair
<
MiriamType
,
Integer
>(
acceptableIdentifiers
.
get
(
value
.
toLowerCase
()),
columnIndex
-
1
));
}
else
{
String
columnNames
=
""
;
for
(
ColorSchemaColumn
schemaColumn
:
ColorSchemaColumn
.
values
())
{
...
...
@@ -144,13 +147,15 @@ public class ColorSchemaXlsxReader {
for
(
String
string
:
acceptableIdentifiers
.
keySet
())
{
columnNames
+=
", "
+
string
;
}
throw
new
InvalidColorSchemaException
(
"Unknown column type: "
+
value
+
". Acceptable column name: "
+
columnNames
);
throw
new
InvalidColorSchemaException
(
"Unknown column type: "
+
value
+
". Acceptable column name: "
+
columnNames
);
}
}
}
valueColumn
=
foundSchemaColumns
.
get
(
ColorSchemaColumn
.
VALUE
);
colorColumn
=
foundSchemaColumns
.
get
(
ColorSchemaColumn
.
COLOR
);
nameColumn
=
foundSchemaColumns
.
get
(
ColorSchemaColumn
.
NAME
);
modelNameColumn
=
foundSchemaColumns
.
get
(
ColorSchemaColumn
.
MODEL_NAME
);
identifierColumn
=
foundSchemaColumns
.
get
(
ColorSchemaColumn
.
IDENTIFIER
);
reactionIdentifierColumn
=
foundSchemaColumns
.
get
(
ColorSchemaColumn
.
REACTION_IDENTIFIER
);
compartmentColumn
=
foundSchemaColumns
.
get
(
ColorSchemaColumn
.
COMPARTMENT
);
...
...
@@ -162,8 +167,10 @@ public class ColorSchemaXlsxReader {
throw
new
InvalidColorSchemaException
(
"Schema can contain only one of these two columns: "
);
}
if
(
nameColumn
==
null
&&
identifierColumn
==
null
&&
foundCustomIdentifiers
.
size
()
==
0
&&
reactionIdentifierColumn
==
null
)
{
throw
new
InvalidColorSchemaException
(
"One of these columns is obligatory: name, identifier, reactionIdentifier"
);
if
(
nameColumn
==
null
&&
identifierColumn
==
null
&&
foundCustomIdentifiers
.
size
()
==
0
&&
reactionIdentifierColumn
==
null
)
{
throw
new
InvalidColorSchemaException
(
"One of these columns is obligatory: name, identifier, reactionIdentifier"
);
}
if
(
valueColumn
==
null
&&
colorColumn
==
null
)
{
...
...
@@ -175,17 +182,21 @@ public class ColorSchemaXlsxReader {
if
(
nameColumn
!=
null
)
{
schema
.
setName
(
row
.
getCell
(
nameColumn
).
getStringCellValue
());
}
if
(
modelNameColumn
!=
null
)
{
schema
.
setModelName
(
row
.
getCell
(
modelNameColumn
).
getStringCellValue
());
}
if
(
valueColumn
!=
null
)
{
try
{
cell
=
row
.
getCell
(
valueColumn
);
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
schema
.
setValue
(
Double
.
parseDouble
(
cell
.
getStringCellValue
().
replace
(
","
,
"."
)));
}
catch
(
Exception
e
)
{
throw
new
InvalidColorSchemaException
(
"[Line "
+
lineIndex
+
"] Problem with parsing value for value column. Cell value"
+
cell
);
throw
new
InvalidColorSchemaException
(
"[Line "
+
lineIndex
+
"] Problem with parsing value for value column. Cell value"
+
cell
);
}
if
(
schema
.
getValue
()
>
1
+
Configuration
.
EPSILON
||
schema
.
getValue
()
<
-
1
-
Configuration
.
EPSILON
)
{
throw
new
InvalidColorSchemaException
(
"[Line "
+
lineIndex
+
"] Value "
+
schema
.
getValue
()
+
" out of range. Only values between -1 and 1 are allowed."
);
throw
new
InvalidColorSchemaException
(
"[Line "
+
lineIndex
+
"] Value "
+
schema
.
getValue
()
+
" out of range. Only values between -1 and 1 are allowed."
);
}
}
if
(
compartmentColumn
!=
null
)
{
...
...
@@ -223,7 +234,8 @@ public class ColorSchemaXlsxReader {
try
{
schema
.
setLineWidth
(
Double
.
parseDouble
(
value
.
replace
(
","
,
"."
)));
}
catch
(
NumberFormatException
e
)
{
throw
new
InvalidColorSchemaException
(
"[Line "
+
lineIndex
+
"] Problem with parsing value: \""
+
value
+
"\""
);
throw
new
InvalidColorSchemaException
(
"[Line "
+
lineIndex
+
"] Problem with parsing value: \""
+
value
+
"\""
);
}
}
}
...
...
@@ -253,13 +265,15 @@ public class ColorSchemaXlsxReader {
}
}
if
((
schema
.
getValue
()
!=
null
&&
schema
.
getColor
()
!=
null
)
||
(
schema
.
getValue
()
==
null
&&
schema
.
getColor
()
==
null
))
{
if
((
schema
.
getValue
()
!=
null
&&
schema
.
getColor
()
!=
null
)
||
(
schema
.
getValue
()
==
null
&&
schema
.
getColor
()
==
null
))
{
throw
new
InvalidColorSchemaException
(
"Value or Color is needed not both"
);
}
if
(
schema
.
getName
()
==
null
&&
schema
.
getGeneralIdentifier
()
==
null
&&
foundCustomIdentifiers
.
size
()
==
0
&&
schema
.
getReactionIdentifier
()
==
null
)
{
throw
new
InvalidColorSchemaException
(
"One of these columns values is obligatory: name, identifier, reactionIdentifier"
);
throw
new
InvalidColorSchemaException
(
"One of these columns values is obligatory: name, identifier, reactionIdentifier"
);
}
result
.
add
(
schema
);
}
...
...
@@ -306,6 +320,9 @@ public class ColorSchemaXlsxReader {
if
(
schema
.
getName
()
!=
null
)
{
result
.
add
(
ColorSchemaColumn
.
NAME
);
}
if
(
schema
.
getModelName
()
!=
null
)
{
result
.
add
(
ColorSchemaColumn
.
MODEL_NAME
);
}
if
(
schema
.
getReactionIdentifier
()
!=
null
)
{
result
.
add
(
ColorSchemaColumn
.
REACTION_IDENTIFIER
);
}
...
...
service/src/main/java/lcsb/mapviewer/services/utils/data/ColorSchemaColumn.java
View file @
4b63adc8
...
...
@@ -3,7 +3,6 @@ package lcsb.mapviewer.services.utils.data;
import
java.util.HashSet
;
import
java.util.Set
;
import
lcsb.mapviewer.model.map.layout.ReferenceGenome
;
import
lcsb.mapviewer.model.map.layout.ReferenceGenomeType
;
...
...
@@ -21,6 +20,11 @@ public enum ColorSchemaColumn {
*/
NAME
(
"name"
,
new
ColorSchemaType
[]
{
ColorSchemaType
.
GENERIC
,
ColorSchemaType
.
GENETIC_VARIANT
}),
//
/**
* Name of the element.
*/
MODEL_NAME
(
"model_name"
,
new
ColorSchemaType
[]
{
ColorSchemaType
.
GENERIC
,
ColorSchemaType
.
GENETIC_VARIANT
}),
//
/**
* Value that will be transformed into new color.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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