Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GenDB3
lib.dbxref
Commits
3096da1d
Commit
3096da1d
authored
Apr 04, 2016
by
Lukas Jelonek
Browse files
Replaced Provider classes with CompositeProvider that is configured by a json file
parent
933f53da
Pipeline
#134
skipped
Changes
18
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
3096da1d
...
...
@@ -96,6 +96,11 @@
<artifactId>
commons-io
</artifactId>
<version>
2.4
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.6.2
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/de/cebitec/common/dbxref/api/GenericResource.java
View file @
3096da1d
...
...
@@ -77,4 +77,8 @@ public class GenericResource implements Resource {
}
}
@Override
public
String
toString
()
{
return
"GenericResource{"
+
"type="
+
type
+
", dbxref="
+
dbxref
+
", uri="
+
uri
+
'}'
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/CompositeProvider.java
0 → 100644
View file @
3096da1d
/*
* Copyright (C) 2016 Lukas Jelonek - Lukas.Jelonek at computational.bio.uni-giessen.de
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
com.google.common.collect.Iterables
;
import
com.google.gson.Gson
;
import
de.cebitec.common.dbxref.api.DbXRef
;
import
de.cebitec.common.dbxref.api.Resource
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
org.kohsuke.MetaInfServices
;
/**
*
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
CompositeProvider
implements
DbXRefResolver
{
private
final
List
<
DbXRefResolver
>
providers
=
new
ArrayList
<>();
public
CompositeProvider
()
{
Gson
gson
=
new
Gson
();
InputStream
is
=
this
.
getClass
().
getResourceAsStream
(
"providers.json"
);
InputStreamReader
isr
=
new
InputStreamReader
(
is
);
List
<
Map
<
String
,
List
<
String
>>>
fromJson
=
gson
.
fromJson
(
isr
,
List
.
class
);
for
(
Map
<
String
,
List
<
String
>>
entry
:
fromJson
)
{
GenericDbXRefProvider
.
ResolverData
data
=
new
GenericDbXRefProvider
.
ResolverData
();
for
(
String
prefix
:
entry
.
get
(
"prefixes"
))
{
data
.
addPrefix
(
prefix
);
}
if
(
entry
.
containsKey
(
"html"
))
{
for
(
String
template
:
entry
.
get
(
"html"
))
{
data
.
addResourceTemplate
(
Resource
.
Type
.
Html
,
template
);
}
}
if
(
entry
.
containsKey
(
"xml"
))
{
for
(
String
template
:
entry
.
get
(
"xml"
))
{
data
.
addResourceTemplate
(
Resource
.
Type
.
Xml
,
template
);
}
}
if
(
entry
.
containsKey
(
"text"
))
{
for
(
String
template
:
entry
.
get
(
"text"
))
{
data
.
addResourceTemplate
(
Resource
.
Type
.
Text
,
template
);
}
}
GenericDbXRefProvider
provider
=
new
GenericDbXRefProvider
(
data
);
providers
.
add
(
provider
);
}
}
@Override
public
Iterable
<
String
>
getDatabasePrefixes
()
{
List
<
String
>
prefixes
=
new
ArrayList
<>();
for
(
DbXRefResolver
provider
:
providers
)
{
Iterables
.
addAll
(
prefixes
,
provider
.
getDatabasePrefixes
());
}
return
prefixes
;
}
@Override
public
boolean
canHandle
(
DbXRef
ref
)
{
for
(
DbXRefResolver
provider
:
providers
)
{
if
(
provider
.
canHandle
(
ref
))
{
return
true
;
}
}
return
false
;
}
@Override
public
Collection
<?
extends
Resource
>
resolve
(
DbXRef
ref
)
{
for
(
DbXRefResolver
provider
:
providers
)
{
if
(
provider
.
canHandle
(
ref
))
{
return
provider
.
resolve
(
ref
);
}
}
return
Collections
.<
Resource
>
emptyList
();
}
}
src/main/java/de/cebitec/common/dbxref/providers/ECProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2014 Lukas Jelonek <ljelonek at cebitec.uni-bielefeld.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author Lukas Jelonek {@literal <ljelonek at cebitec.uni-bielefeld.de>}
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
ECProvider
extends
GenericDbXRefProvider
{
public
ECProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"EC"
,
"Enzyme"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://enzyme.expasy.org/EC/%i"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/GIProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2012 cb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author cb
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
GIProvider
extends
GenericDbXRefProvider
{
public
GIProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"GI"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://www.ncbi.nlm.nih.gov/protein/GI:%i"
);
resolverData
.
addResourceTemplate
(
Type
.
Xml
,
"http://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?tool=portal&db=protein&dopt=xml&sort=&val=%i&retmode=file"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/GOProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2012 cb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author cb
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
GOProvider
extends
GenericDbXRefProvider
{
public
GOProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"GO"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://www.ebi.ac.uk/QuickGO/GTerm?id=GO:%i"
);
resolverData
.
addResourceTemplate
(
Type
.
Xml
,
"http://www.ebi.ac.uk/QuickGO/GTerm?id=GO:%i&format=oboxml"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/GeneIDProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2012 cb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author cb
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
GeneIDProvider
extends
GenericDbXRefProvider
{
public
GeneIDProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"GeneID"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://www.ncbi.nlm.nih.gov/gene/%i"
);
resolverData
.
addResourceTemplate
(
Type
.
Xml
,
"http://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?tool=portal&db=gene&dopt=xml&sort=&val=%i&retmode=file"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/PDBProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2012 cb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author cb
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
PDBProvider
extends
GenericDbXRefProvider
{
public
PDBProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"PDB"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://www.rcsb.org/pdb/explore/explore.do?structureId=%i"
);
resolverData
.
addResourceTemplate
(
Type
.
Xml
,
"http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=xml&compression=NO&structureId=%i"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/PFamProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2012 cb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author cb
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
PFamProvider
extends
GenericDbXRefProvider
{
public
PFamProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"PFAM"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://pfam.xfam.org/family/%i"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/PubMedProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2013 amaier
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author amaier
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
PubMedProvider
extends
GenericDbXRefProvider
{
public
PubMedProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"pubmed"
,
"Pubmed"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://www.ncbi.nlm.nih.gov/pubmed/%i"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/RFamProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2012 cb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author cb
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
RFamProvider
extends
GenericDbXRefProvider
{
public
RFamProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"RFAM"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://rfam.sanger.ac.uk/family/%i"
);
resolverData
.
addResourceTemplate
(
Type
.
Xml
,
"http://rfam.sanger.ac.uk/family/%i?content-type=text%2Fxml"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/SOProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2014 Lukas Jelonek <ljelonek at cebitec.uni-bielefeld.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author Lukas Jelonek {@literal <ljelonek at cebitec.uni-bielefeld.de>}
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
SOProvider
extends
GenericDbXRefProvider
{
public
SOProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"SO"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://www.sequenceontology.org/browser/current_svn/term/SO:%i"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/TaxonomyProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2012 cb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author cb
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
TaxonomyProvider
extends
GenericDbXRefProvider
{
public
TaxonomyProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"Taxon"
,
"taxon"
,
"taxid"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://www.uniprot.org/taxonomy/%i"
);
resolverData
.
addResourceTemplate
(
Type
.
Xml
,
"http://www.uniprot.org/taxonomy/%i.rdf"
);
return
resolverData
;
}
}
src/main/java/de/cebitec/common/dbxref/providers/UniProtProvider.java
deleted
100644 → 0
View file @
933f53da
/*
* Copyright (C) 2012 cb
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.dbxref.providers
;
import
de.cebitec.common.dbxref.api.Resource.Type
;
import
de.cebitec.common.dbxref.spi.DbXRefResolver
;
import
org.kohsuke.MetaInfServices
;
/**
*
* @author cb
*/
@MetaInfServices
(
DbXRefResolver
.
class
)
public
class
UniProtProvider
extends
GenericDbXRefProvider
{
public
UniProtProvider
()
{
super
(
createResolverData
());
}
public
static
ResolverData
createResolverData
()
{
ResolverData
resolverData
=
new
ResolverData
(
"UniProtKB/TrEMBL"
,
"UniProtKB/Swiss-Prot"
);
resolverData
.
addResourceTemplate
(
Type
.
Html
,
"http://www.uniprot.org/uniprot/%i"
);
resolverData
.
addResourceTemplate
(
Type
.
Xml
,
"http://www.uniprot.org/uniprot/%i.xml"
);
return
resolverData
;
}
}
\ No newline at end of file
src/main/resources/de/cebitec/common/dbxref/providers/providers.json
0 → 100644
View file @
3096da1d
[
{
"prefixes"
:
[
"EC"
,
"Enzyme"
],
"html"
:
[
"http://enzyme.expasy.org/EC/%i"
]
},
{
"prefixes"
:
[
"GI"
],
"html"
:
[
"http://www.ncbi.nlm.nih.gov/protein/GI:%i"
],
"xml"
:
[
"http://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?tool=portal&db=protein&dopt=xml&sort=&val=%i&retmode=file"
]
},
{
"prefixes"
:
[
"UniProtKB/TrEMBL"
,
"UniProtKB/Swiss-Prot"
],