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
0e6b2279
Commit
0e6b2279
authored
Aug 11, 2021
by
Piotr Gawron
Browse files
Merge branch '1528-cazy-issue' into 'devel_15.1.x'
cazy db was updated and contains different data See merge request
!1325
parents
6c244f17
e7e8b624
Pipeline
#45977
failed with stage
in 28 minutes and 5 seconds
Changes
2
Pipelines
16
Hide whitespace changes
Inline
Side-by-side
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/CazyAnnotator.java
View file @
0e6b2279
package
lcsb.mapviewer.annotation.services.annotators
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -12,15 +16,23 @@ import org.springframework.stereotype.Service;
import
lcsb.mapviewer.annotation.cache.GeneralCacheInterface
;
import
lcsb.mapviewer.annotation.cache.WebPageDownloader
;
import
lcsb.mapviewer.annotation.services.*
;
import
lcsb.mapviewer.annotation.services.ExternalServiceStatus
;
import
lcsb.mapviewer.annotation.services.ExternalServiceStatusType
;
import
lcsb.mapviewer.annotation.services.IExternalService
;
import
lcsb.mapviewer.annotation.services.WrongResponseCodeIOException
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.model.LogMarker
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.species.*
;
import
lcsb.mapviewer.model.user.annotator.*
;
import
lcsb.mapviewer.model.map.species.Gene
;
import
lcsb.mapviewer.model.map.species.GenericProtein
;
import
lcsb.mapviewer.model.map.species.Protein
;
import
lcsb.mapviewer.model.map.species.Rna
;
import
lcsb.mapviewer.model.user.annotator.AnnotatorData
;
import
lcsb.mapviewer.model.user.annotator.AnnotatorInputParameter
;
import
lcsb.mapviewer.model.user.annotator.AnnotatorOutputParameter
;
/**
* This is a class that implements a backend to CAZy.
...
...
@@ -120,7 +132,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
@Override
public
MiriamData
getExampleValidAnnotation
()
{
return
new
MiriamData
(
MiriamType
.
UNIPROT
,
"Q
9SG95
"
);
return
new
MiriamData
(
MiriamType
.
UNIPROT
,
"Q
00012
"
);
}
/**
...
...
@@ -143,7 +155,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
* @return CAZy family identifier found on the page
*/
private
Collection
<
MiriamData
>
parseCazy
(
String
pageContent
)
{
Collection
<
MiriamData
>
result
=
new
HashSet
<
MiriamData
>();
Collection
<
MiriamData
>
result
=
new
HashSet
<>();
Matcher
m
=
cazyIdMatcher
.
matcher
(
pageContent
);
if
(
m
.
find
())
{
result
.
add
(
new
MiriamData
(
MiriamType
.
CAZY
,
m
.
group
(
1
)));
...
...
@@ -176,12 +188,16 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
if
(
collection
.
size
()
>
0
)
{
return
collection
.
iterator
().
next
();
}
else
{
marker
.
getEntry
().
setType
(
ProjectLogEntryType
.
INVALID_IDENTIFIER
);
if
(
marker
!=
null
)
{
marker
.
getEntry
().
setType
(
ProjectLogEntryType
.
INVALID_IDENTIFIER
);
}
logger
.
warn
(
marker
,
"Cannot find CAZy data for UniProt id: "
+
uniprot
.
getResource
());
return
null
;
}
}
catch
(
WrongResponseCodeIOException
exception
)
{
marker
.
getEntry
().
setType
(
ProjectLogEntryType
.
OTHER
);
if
(
marker
!=
null
)
{
marker
.
getEntry
().
setType
(
ProjectLogEntryType
.
OTHER
);
}
logger
.
warn
(
marker
,
"Wrong response code when retrieving CAZy data for UniProt id: "
+
uniprot
.
getResource
());
return
null
;
}
catch
(
IOException
exception
)
{
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/CazyAnnotatorTest.java
View file @
0e6b2279
...
...
@@ -36,14 +36,14 @@ public class CazyAnnotatorTest extends AnnotationTestFunctions {
@Test
public
void
testUniprotToCazy
()
throws
Exception
{
assertEquals
(
new
MiriamData
(
MiriamType
.
CAZY
,
"GH5_7"
),
cazyAnnotator
.
uniprotToCazy
(
new
MiriamData
(
MiriamType
.
UNIPROT
,
"Q
9SG95
"
),
null
));
cazyAnnotator
.
uniprotToCazy
(
new
MiriamData
(
MiriamType
.
UNIPROT
,
"Q
00012
"
),
null
));
}
@Test
public
void
testAnnotateFromUniprot
()
throws
Exception
{
Species
protein
=
new
GenericProtein
(
"id"
);
protein
.
setName
(
"bla"
);
protein
.
addMiriamData
(
new
MiriamData
(
MiriamType
.
UNIPROT
,
"Q
9SG95
"
));
protein
.
addMiriamData
(
new
MiriamData
(
MiriamType
.
UNIPROT
,
"Q
00012
"
));
cazyAnnotator
.
annotateElement
(
protein
);
...
...
@@ -85,8 +85,8 @@ public class CazyAnnotatorTest extends AnnotationTestFunctions {
public
void
testAnnotateMultipleUniprots
()
throws
Exception
{
Species
protein
=
new
GenericProtein
(
"id"
);
protein
.
setName
(
"bla"
);
protein
.
addMiriamData
(
new
MiriamData
(
MiriamType
.
UNIPROT
,
"Q
9SG95
"
));
protein
.
addMiriamData
(
new
MiriamData
(
MiriamType
.
UNIPROT
,
"
Q12540
"
));
protein
.
addMiriamData
(
new
MiriamData
(
MiriamType
.
UNIPROT
,
"Q
00012
"
));
protein
.
addMiriamData
(
new
MiriamData
(
MiriamType
.
UNIPROT
,
"
A8MCI6
"
));
cazyAnnotator
.
annotateElement
(
protein
);
...
...
@@ -98,7 +98,7 @@ public class CazyAnnotatorTest extends AnnotationTestFunctions {
}
}
assert
True
(
"Wrong number of CAZy identifiers extracted from CAZy annotator"
,
cntMDs
==
2
);
assert
Equals
(
"Wrong number of CAZy identifiers extracted from CAZy annotator"
,
2
,
cntMDs
);
}
@Test
...
...
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