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
f3239d87
Commit
f3239d87
authored
Nov 10, 2017
by
Piotr Gawron
Browse files
Merge branch 'devel_11.0.x' into devel_11.1.x
parents
c9192e1c
1a00e9ce
Changes
10
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
f3239d87
minerva (11.0.4) stable; urgency=medium
* Bug fix: fix on connection to taxonomy database
* Bug fix: color coding for reactions (wrong color was chosen)
* Bug fix: overlays with many reactions did not work properly
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 09 Nov 2017 14:50:00 +0200
minerva (11.0.3) stable; urgency=medium
* Bug fix: removing empty project removed images from all projects
* Bug fix: clicking on map when left panel was hidden threw error
* Bug fix: links to invalid annotations were opening invalid web page
* Bug fix: service resolving miriam resources doesn't work
i
over http
* Bug fix: service resolving miriam resources doesn't work over http
anymore
* Bug f
u
x: chebi annotator doesn't work over http anymore
* Bug f
i
x: chebi annotator doesn't work over http anymore
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 19 Oct 2017 13:50:00 +0200
...
...
@@ -20,8 +27,8 @@ minerva (11.0.1) stable; urgency=medium
minerva (11.0.0) stable; urgency=medium
* Bug fix: security issue - access to specific map can be restricted
by the userlogin
* Bug fix: security issue - access to specific map can be restricted
by the user
login
* Bug fix: sbgn import
* Bug fix: mesh connector
* Rest API (documentation can be found here:
...
...
@@ -107,7 +114,7 @@ minerva (9) stable; urgency=medium
minerva (8) stable; urgency=medium
* Micro RNA interface
* Toxic chemicals inter
d
ace
* Toxic chemicals inter
f
ace
* Data sets (layouts) visualized dynamically in the browser
* Reverse query for drugs, chemicals, micro RNAs interfaces
* Small bug fixes
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/TaxonomyBackend.java
View file @
f3239d87
...
...
@@ -180,9 +180,8 @@ public class TaxonomyBackend extends CachableInterface implements IExternalServi
try
{
String
url
=
"https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id="
+
miriamData
.
getResource
();
logger
.
debug
(
url
);
String
page
=
getWebPageContent
(
url
);
Pattern
idPattern
=
Pattern
.
compile
(
"<
h2>
([A-Za-z0-9\\ \\.]+)
</h2
>"
);
Pattern
idPattern
=
Pattern
.
compile
(
"<
title>Taxonomy browser \\(
([A-Za-z0-9\\ \\.]+)
\\)</title
>"
);
Matcher
matcher
=
idPattern
.
matcher
(
page
);
if
(!
matcher
.
find
())
{
logger
.
warn
(
"Unknown organism: "
+
miriamData
);
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/TaxonomyBackendTest.java
View file @
f3239d87
...
...
@@ -27,313 +27,314 @@ import lcsb.mapviewer.model.map.MiriamData;
import
lcsb.mapviewer.model.map.MiriamType
;
public
class
TaxonomyBackendTest
extends
AnnotationTestFunctions
{
Logger
logger
=
Logger
.
getLogger
(
TaxonomyBackendTest
.
class
);
@Autowired
TaxonomyBackend
taxonomyBackend
;
GeneralCacheInterface
cache
;
@Before
public
void
setUp
()
throws
Exception
{
cache
=
taxonomyBackend
.
getCache
();
// exclude first cached value
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
}
@After
public
void
tearDown
()
throws
Exception
{
taxonomyBackend
.
setCache
(
cache
);
}
@Test
public
void
testByName
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"Human"
);
assertTrue
(
md
.
equals
(
TaxonomyBackend
.
HUMAN_TAXONOMY
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByComplexName
()
throws
Exception
{
try
{
assertNotNull
(
taxonomyBackend
.
getByName
(
"Aplysia californica (Sea Hare)"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByCommonName
()
throws
Exception
{
try
{
assertNotNull
(
taxonomyBackend
.
getByName
(
"Rat"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByEmptyName
()
throws
Exception
{
try
{
assertNull
(
taxonomyBackend
.
getByName
(
null
));
assertNull
(
taxonomyBackend
.
getByName
(
""
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByAbreviationName
()
throws
Exception
{
try
{
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
assertNotNull
(
taxonomyBackend
.
getByName
(
"C. elegans"
));
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
assertNotNull
(
taxonomyBackend
.
getByName
(
"D. sechellia"
));
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
assertNotNull
(
taxonomyBackend
.
getByName
(
"P. pacificus"
));
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
assertNotNull
(
taxonomyBackend
.
getByName
(
"T. castaneum"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testGetName
()
throws
Exception
{
try
{
String
name
=
taxonomyBackend
.
getNameForTaxonomy
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"9606"
));
assertTrue
(
name
.
contains
(
"Homo sapiens"
));
assertNotNull
(
taxonomyBackend
.
getNameForTaxonomy
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"9605"
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testGetNameWhenProblemWithDb
()
throws
Exception
{
WebPageDownloader
downloader
=
taxonomyBackend
.
getWebPageDownloader
();
try
{
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
())).
thenThrow
(
new
IOException
());
taxonomyBackend
.
setWebPageDownloader
(
mockDownloader
);
taxonomyBackend
.
setCache
(
null
);
taxonomyBackend
.
getNameForTaxonomy
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"9606"
));
fail
(
"Exception expected"
);
}
catch
(
TaxonomySearchException
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
taxonomyBackend
.
setWebPageDownloader
(
downloader
);
}
}
@Test
public
void
testGetNameForInvalidTax
()
throws
Exception
{
try
{
String
name
=
taxonomyBackend
.
getNameForTaxonomy
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"-a-"
));
assertNull
(
name
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testGetNameForInvalidInputData
()
throws
Exception
{
try
{
String
name
=
taxonomyBackend
.
getNameForTaxonomy
(
null
);
assertNull
(
name
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByName2
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"homo sapiens"
);
assertTrue
(
md
.
equals
(
TaxonomyBackend
.
HUMAN_TAXONOMY
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByName3
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"bla bla kiwi"
);
assertNull
(
md
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByMusMusculusName
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"Mus musculus"
);
assertTrue
(
md
.
equals
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"10090"
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByMouseName
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"Mouse"
);
assertTrue
(
md
.
equals
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"10090"
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshCacheQuery
()
throws
Exception
{
try
{
String
result
=
taxonomyBackend
.
refreshCacheQuery
(
TaxonomyBackend
.
TAXONOMY_CACHE_PREFIX
+
"homo sapiens"
);
assertNotNull
(
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshCacheQuery2
()
throws
Exception
{
try
{
String
result
=
taxonomyBackend
.
refreshCacheQuery
(
TaxonomyBackend
.
TAXONOMY_NAME_CACHE_PREFIX
+
TaxonomyBackend
.
HUMAN_TAXONOMY
.
getResource
());
assertNotNull
(
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshCacheQuery3
()
throws
Exception
{
try
{
String
result
=
taxonomyBackend
.
refreshCacheQuery
(
"http://google.pl/"
);
assertNotNull
(
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshInvalidCacheQuery
()
throws
Exception
{
try
{
taxonomyBackend
.
refreshCacheQuery
(
"unk_query"
);
}
catch
(
InvalidArgumentException
e
)
{
assertTrue
(
e
.
getMessage
().
contains
(
"Don't know what to"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshInvalidCacheQuery2
()
throws
Exception
{
try
{
taxonomyBackend
.
refreshCacheQuery
(
new
Object
());
}
catch
(
InvalidArgumentException
e
)
{
assertTrue
(
e
.
getMessage
().
contains
(
"Don't know what to"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshCacheQueryNotAvailable
()
throws
Exception
{
WebPageDownloader
downloader
=
taxonomyBackend
.
getWebPageDownloader
();
try
{
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
())).
thenThrow
(
new
IOException
());
taxonomyBackend
.
setWebPageDownloader
(
mockDownloader
);
taxonomyBackend
.
refreshCacheQuery
(
"http://google.pl/"
);
fail
(
"Exception expected"
);
}
catch
(
SourceNotAvailable
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
taxonomyBackend
.
setWebPageDownloader
(
downloader
);
}
}
@Test
public
void
testStatus
()
throws
Exception
{
try
{
assertEquals
(
ExternalServiceStatusType
.
OK
,
taxonomyBackend
.
getServiceStatus
().
getStatus
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testSimulateDownStatus
()
throws
Exception
{
WebPageDownloader
downloader
=
taxonomyBackend
.
getWebPageDownloader
();
try
{
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
())).
thenThrow
(
new
IOException
());
taxonomyBackend
.
setWebPageDownloader
(
mockDownloader
);
assertEquals
(
ExternalServiceStatusType
.
DOWN
,
taxonomyBackend
.
getServiceStatus
().
getStatus
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
taxonomyBackend
.
setWebPageDownloader
(
downloader
);
}
}
@Test
public
void
testSimulateChangedStatus
()
throws
Exception
{
WebPageDownloader
downloader
=
taxonomyBackend
.
getWebPageDownloader
();
try
{
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
())).
thenReturn
(
""
);
taxonomyBackend
.
setWebPageDownloader
(
mockDownloader
);
assertEquals
(
ExternalServiceStatusType
.
CHANGED
,
taxonomyBackend
.
getServiceStatus
().
getStatus
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
taxonomyBackend
.
setWebPageDownloader
(
downloader
);
}
}
@Test
public
void
testSimulateChangedStatus2
()
throws
Exception
{
WebPageDownloader
downloader
=
taxonomyBackend
.
getWebPageDownloader
();
try
{
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
())).
thenReturn
(
"<em>Taxonomy ID: </em>1234"
);
taxonomyBackend
.
setWebPageDownloader
(
mockDownloader
);
assertEquals
(
ExternalServiceStatusType
.
CHANGED
,
taxonomyBackend
.
getServiceStatus
().
getStatus
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
taxonomyBackend
.
setWebPageDownloader
(
downloader
);
}
}
Logger
logger
=
Logger
.
getLogger
(
TaxonomyBackendTest
.
class
);
@Autowired
TaxonomyBackend
taxonomyBackend
;
GeneralCacheInterface
cache
;
@Before
public
void
setUp
()
throws
Exception
{
cache
=
taxonomyBackend
.
getCache
();
// exclude two first cached values
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
2
));
}
@After
public
void
tearDown
()
throws
Exception
{
taxonomyBackend
.
setCache
(
cache
);
}
@Test
public
void
testByName
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"Human"
);
assertTrue
(
md
.
equals
(
TaxonomyBackend
.
HUMAN_TAXONOMY
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByComplexName
()
throws
Exception
{
try
{
assertNotNull
(
taxonomyBackend
.
getByName
(
"Aplysia californica (Sea Hare)"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByCommonName
()
throws
Exception
{
try
{
assertNotNull
(
taxonomyBackend
.
getByName
(
"Rat"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByEmptyName
()
throws
Exception
{
try
{
assertNull
(
taxonomyBackend
.
getByName
(
null
));
assertNull
(
taxonomyBackend
.
getByName
(
""
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByAbreviationName
()
throws
Exception
{
try
{
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
assertNotNull
(
taxonomyBackend
.
getByName
(
"C. elegans"
));
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
assertNotNull
(
taxonomyBackend
.
getByName
(
"D. sechellia"
));
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
assertNotNull
(
taxonomyBackend
.
getByName
(
"P. pacificus"
));
taxonomyBackend
.
setCache
(
new
GeneralCacheWithExclusion
(
cache
,
1
));
assertNotNull
(
taxonomyBackend
.
getByName
(
"T. castaneum"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testGetName
()
throws
Exception
{
try
{
String
name
=
taxonomyBackend
.
getNameForTaxonomy
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"9606"
));
assertTrue
(
name
.
contains
(
"Homo sapiens"
));
assertNotNull
(
taxonomyBackend
.
getNameForTaxonomy
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"9605"
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testGetNameWhenProblemWithDb
()
throws
Exception
{
WebPageDownloader
downloader
=
taxonomyBackend
.
getWebPageDownloader
();
try
{
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
())).
thenThrow
(
new
IOException
());
taxonomyBackend
.
setWebPageDownloader
(
mockDownloader
);
taxonomyBackend
.
setCache
(
null
);
taxonomyBackend
.
getNameForTaxonomy
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"9606"
));
fail
(
"Exception expected"
);
}
catch
(
TaxonomySearchException
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
taxonomyBackend
.
setWebPageDownloader
(
downloader
);
}
}
@Test
public
void
testGetNameForInvalidTax
()
throws
Exception
{
try
{
String
name
=
taxonomyBackend
.
getNameForTaxonomy
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"-a-"
));
assertNull
(
name
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testGetNameForInvalidInputData
()
throws
Exception
{
try
{
String
name
=
taxonomyBackend
.
getNameForTaxonomy
(
null
);
assertNull
(
name
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByName2
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"homo sapiens"
);
assertTrue
(
md
.
equals
(
TaxonomyBackend
.
HUMAN_TAXONOMY
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByName3
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"bla bla kiwi"
);
assertNull
(
md
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByMusMusculusName
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"Mus musculus"
);
assertTrue
(
md
.
equals
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"10090"
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testByMouseName
()
throws
Exception
{
try
{
MiriamData
md
=
taxonomyBackend
.
getByName
(
"Mouse"
);
assertTrue
(
md
.
equals
(
new
MiriamData
(
MiriamType
.
TAXONOMY
,
"10090"
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshCacheQuery
()
throws
Exception
{
try
{
String
result
=
taxonomyBackend
.
refreshCacheQuery
(
TaxonomyBackend
.
TAXONOMY_CACHE_PREFIX
+
"homo sapiens"
);
assertNotNull
(
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshCacheQuery2
()
throws
Exception
{
try
{
String
result
=
taxonomyBackend
.
refreshCacheQuery
(
TaxonomyBackend
.
TAXONOMY_NAME_CACHE_PREFIX
+
TaxonomyBackend
.
HUMAN_TAXONOMY
.
getResource
());
assertNotNull
(
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshCacheQuery3
()
throws
Exception
{
try
{
String
result
=
taxonomyBackend
.
refreshCacheQuery
(
"http://google.pl/"
);
assertNotNull
(
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testRefreshInvalidCacheQuery
()
throws
Exception
{