Commit 9ca41336 authored by David Hoksza's avatar David Hoksza
Browse files

new MiriamData converted to createMiriamData (situations like addPubchemMiriam...

new MiriamData converted to createMiriamData (situations like addPubchemMiriam or addCogMiriam still need to be addressed)
parent fb11f771
......@@ -83,7 +83,7 @@ public class BiocompendiumAnnotator extends ElementAnnotator implements IExterna
try {
if (query instanceof String) {
String name = (String) query;
result = getAnnotation(new MiriamData(MiriamType.HGNC_SYMBOL, name));
result = getAnnotation(createMiriamData(MiriamType.HGNC_SYMBOL, name));
} else {
throw new InvalidArgumentException("Don't know what to do with class: " + query.getClass());
}
......@@ -109,7 +109,7 @@ public class BiocompendiumAnnotator extends ElementAnnotator implements IExterna
throw new InvalidArgumentException("Only " + MiriamType.HGNC_SYMBOL.getCommonName() + " miriam registry is supported.");
}
MiriamData miriamData = new MiriamData(md);
MiriamData miriamData = createMiriamData(md);
miriamData.setResource(miriamData.getResource().replaceAll("[\n\r]+", " "));
String annotation = getCacheValue(miriamData.getResource());
......@@ -282,7 +282,7 @@ public class BiocompendiumAnnotator extends ElementAnnotator implements IExterna
this.setCache(null);
try {
String annotations = getAnnotation(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA"));
String annotations = getAnnotation(createMiriamData(MiriamType.HGNC_SYMBOL, "SNCA"));
status.setStatus(ExternalServiceStatusType.OK);
if (annotations == null) {
......@@ -302,7 +302,7 @@ public class BiocompendiumAnnotator extends ElementAnnotator implements IExterna
public void annotateElement(BioEntity element) throws AnnotatorException {
if (isAnnotatable(element)) {
try {
String annotationString = getAnnotation(new MiriamData(MiriamType.HGNC_SYMBOL, element.getName()));
String annotationString = getAnnotation(createMiriamData(MiriamType.HGNC_SYMBOL, element.getName()));
if (annotationString != null) {
if (element.getMiriamData().size() == 0) {
element.addMiriamData(rap.getMiriamData(annotationString));
......
......@@ -66,7 +66,7 @@ public class BrendaAnnotator extends ElementAnnotator implements IExternalServic
this.setCache(null);
try {
Collection<MiriamData> mds = uniprotToBrenda(new MiriamData(MiriamType.UNIPROT, "P12345"));
Collection<MiriamData> mds = uniprotToBrenda(createMiriamData(MiriamType.UNIPROT, "P12345"));
status.setStatus(ExternalServiceStatusType.OK);
List<String> ecs = new ArrayList<>();
......@@ -148,7 +148,7 @@ public class BrendaAnnotator extends ElementAnnotator implements IExternalServic
Collection<MiriamData> result = new HashSet<MiriamData>();
Matcher m = uniprotECMatcher.matcher(pageContent);
while (m.find()) {
result.add(new MiriamData(MiriamType.BRENDA, m.group(1)));
result.add(createMiriamData(MiriamType.BRENDA, m.group(1)));
}
return result;
}
......
......@@ -66,7 +66,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
this.setCache(null);
try {
MiriamData md = uniprotToCazy(new MiriamData(MiriamType.UNIPROT, "Q9SG95"));
MiriamData md = uniprotToCazy(createMiriamData(MiriamType.UNIPROT, "Q9SG95"));
status.setStatus(ExternalServiceStatusType.OK);
if (md == null || !md.getResource().equalsIgnoreCase("GH5_7")) {
......@@ -144,7 +144,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
Collection<MiriamData> result = new HashSet<MiriamData>();
Matcher m = cazyIdMatcher.matcher(pageContent);
if (m.find()) {
result.add(new MiriamData(MiriamType.CAZY, m.group(1)));
result.add(createMiriamData(MiriamType.CAZY, m.group(1)));
}
return result;
}
......
......@@ -91,10 +91,10 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
String name = (String) query;
if (name.startsWith(ID_PREFIX)) {
String id = name.substring(ID_PREFIX_LENGTH);
result = chebiSerializer.objectToString(getChebiElementForChebiId(new MiriamData(MiriamType.CHEBI, id)));
result = chebiSerializer.objectToString(getChebiElementForChebiId(createMiriamData(MiriamType.CHEBI, id)));
} else if (name.startsWith(ONTOLOGY_PREFIX)) {
String id = name.substring(ONTOLOGY_PREFIX.length());
result = miriamListToStringList(getOntologyChebiIdsForChebi(new MiriamData(MiriamType.CHEBI, id)));
result = miriamListToStringList(getOntologyChebiIdsForChebi(createMiriamData(MiriamType.CHEBI, id)));
} else if (name.startsWith(NAME_PREFIX)) {
name = name.substring(NAME_PREFIX_LENGTH);
MiriamData md = getChebiForChebiName(name);
......@@ -158,7 +158,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
String id = getCacheValue("name: " + name);
if (id != null) {
return new MiriamData(MiriamType.CHEBI, id);
return createMiriamData(MiriamType.CHEBI, id);
}
try {
ChebiWebServiceClient client = getClient();
......@@ -172,7 +172,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
String chebiName = entity.getChebiAsciiName();
if (chebiName.trim().equalsIgnoreCase(name)) {
setCacheValue("name: " + name, entity.getChebiId());
return new MiriamData(MiriamType.CHEBI, entity.getChebiId());
return createMiriamData(MiriamType.CHEBI, entity.getChebiId());
}
for (DataItem dataItem : entity.getFormulae()) {
String synonym = dataItem.getData();
......@@ -265,7 +265,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
queue.add(md.getResource());
while (!queue.isEmpty()) {
String element = queue.poll();
result.add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, element));
result.add(createMiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, element));
Entity entity = client.getCompleteEntity(element);
for (OntologyDataItem di : entity.getOntologyChildren()) {
if (!children.contains(di.getChebiId()) && "is a".equals(di.getType())) {
......@@ -284,7 +284,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
Entity entity = client.getCompleteEntity(element);
for (OntologyDataItem di : entity.getOntologyParents()) {
if (!parents.contains(di.getChebiId()) && "is a".equals(di.getType())) {
result.add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, di.getChebiId()));
result.add(createMiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, di.getChebiId()));
parents.add(di.getChebiId());
queue.add(di.getChebiId());
}
......@@ -331,7 +331,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
String[] tmp = res.split(",");
List<MiriamData> result = new ArrayList<MiriamData>();
for (String string : tmp) {
result.add(new MiriamData(MiriamType.CHEBI, string));
result.add(createMiriamData(MiriamType.CHEBI, string));
}
return result;
}
......
......@@ -245,7 +245,7 @@ public abstract class ElementAnnotator extends CachableInterface {
* annotation identifier
*/
protected void addHmdbMiriam(BioEntity element, String value) {
element.addMiriamData(new MiriamData(MiriamType.HMDB, value));
element.addMiriamData(createMiriamData(MiriamType.HMDB, value));
}
/**
......@@ -317,7 +317,7 @@ public abstract class ElementAnnotator extends CachableInterface {
if (!value.startsWith("CHEBI:")) {
value = "CHEBI:" + value;
}
element.addMiriamData(new MiriamData(MiriamType.CHEBI, value));
element.addMiriamData(createMiriamData(MiriamType.CHEBI, value));
}
/**
......@@ -349,7 +349,7 @@ public abstract class ElementAnnotator extends CachableInterface {
* annotation identifier
*/
protected void addPubchemMiriam(BioEntity element, String value) {
element.addMiriamData(new MiriamData(MiriamType.PUBCHEM, value));
element.addMiriamData(createMiriamData(MiriamType.PUBCHEM, value));
}
/**
......@@ -361,7 +361,7 @@ public abstract class ElementAnnotator extends CachableInterface {
* annotation identifier
*/
protected void addCogMiriam(BioEntity element, String value) {
element.addMiriamData(new MiriamData(MiriamType.COG, value));
element.addMiriamData(createMiriamData(MiriamType.COG, value));
}
/**
......@@ -391,7 +391,7 @@ public abstract class ElementAnnotator extends CachableInterface {
* annotation identifier
*/
protected void addEcMiriam(BioEntity element, String value) {
element.addMiriamData(new MiriamData(MiriamType.EC, value));
element.addMiriamData(createMiriamData(MiriamType.EC, value));
}
/**
......@@ -407,13 +407,13 @@ public abstract class ElementAnnotator extends CachableInterface {
*/
protected void addKeggMiriam(BioEntity element, String value, String prefix) {
if (value.startsWith("C")) {
MiriamData md = new MiriamData(MiriamType.KEGG_COMPOUND, value);
MiriamData md = createMiriamData(MiriamType.KEGG_COMPOUND, value);
element.addMiriamData(md);
} else if (value.startsWith("R")) {
MiriamData md = new MiriamData(MiriamType.KEGG_REACTION, value);
MiriamData md = createMiriamData(MiriamType.KEGG_REACTION, value);
element.addMiriamData(md);
} else if (value.startsWith("K")) {
MiriamData md = new MiriamData(MiriamType.KEGG_ORTHOLOGY, value);
MiriamData md = createMiriamData(MiriamType.KEGG_ORTHOLOGY, value);
element.addMiriamData(md);
} else {
logger.warn(prefix + "Unknown Kegg identifier type (only Kegg compounds and reactions are supported): \"" + value + "\"");
......
......@@ -110,7 +110,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi
try {
GenericProtein proteinAlias = new GenericProtein("mock_id");
proteinAlias.addMiriamData(new MiriamData(MiriamType.ENSEMBL, "ENSG00000157764"));
proteinAlias.addMiriamData(createMiriamData(MiriamType.ENSEMBL, "ENSG00000157764"));
annotateElement(proteinAlias);
if (proteinAlias.getFullName() == null || proteinAlias.getFullName().isEmpty()) {
......@@ -208,7 +208,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi
if ("EntrezGene".equals(dbname)) {
String entrezId = super.getNodeAttr("primary_id", node);
if (entrezId != null && !entrezId.isEmpty()) {
annotatedObject.addMiriamData(new MiriamData(MiriamType.ENTREZ, entrezId));
annotatedObject.addMiriamData(createMiriamData(MiriamType.ENTREZ, entrezId));
}
String symbol = super.getNodeAttr("display_id", node);
if (symbol != null) {
......
......@@ -86,10 +86,10 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
result = getWebPageContent(name);
} else if (name.startsWith(ENTREZ_DATA_PREFIX)) {
String id = name.replace(ENTREZ_DATA_PREFIX, "");
result = entrezSerializer.objectToString(getEntrezForMiriamData(new MiriamData(MiriamType.ENTREZ, id), null));
result = entrezSerializer.objectToString(getEntrezForMiriamData(createMiriamData(MiriamType.ENTREZ, id), null));
} else if (name.startsWith(CACHE_HGNC_ID_PREFIX)) {
String id = name.replace(CACHE_HGNC_ID_PREFIX, "");
MiriamData md = getHgncIdFromEntrez(new MiriamData(MiriamType.ENTREZ, id));
MiriamData md = getHgncIdFromEntrez(createMiriamData(MiriamType.ENTREZ, id));
if (md != null) {
result = md.getResource();
}
......@@ -131,7 +131,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
try {
GenericProtein proteinAlias = new GenericProtein("id");
proteinAlias.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.ENTREZ, "9999"));
proteinAlias.addMiriamData(createMiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.ENTREZ, "9999"));
annotateElement(proteinAlias);
if (proteinAlias.getFullName() == null || proteinAlias.getFullName().equals("")) {
......@@ -271,11 +271,11 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
if ("HGNC".equals(dbName)) {
if (dbId != null && !dbId.isEmpty()) {
dbId = dbId.replaceAll("HGNC:", "");
result.addMiriamData(new MiriamData(MiriamType.HGNC, dbId));
result.addMiriamData(createMiriamData(MiriamType.HGNC, dbId));
}
} else if ("Ensembl".equals(dbName)) {
if (dbId != null && !dbId.isEmpty()) {
result.addMiriamData(new MiriamData(MiriamType.ENSEMBL, dbId));
result.addMiriamData(createMiriamData(MiriamType.ENSEMBL, dbId));
}
}
......@@ -359,7 +359,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
} else if (value.equals("null")) {
return null;
} else {
return new MiriamData(MiriamType.HGNC, value);
return createMiriamData(MiriamType.HGNC, value);
}
}
......
......@@ -69,7 +69,7 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService {
String name = (String) query;
if (name.startsWith(GO_TERM_CACHE_PREFIX)) {
String term = name.substring(GO_TERM_CACHE_PREFIX.length());
MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.GO, term);
MiriamData md = createMiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.GO, term);
result = goSerializer.objectToString(getGoElement(md));
} else if (name.startsWith("http")) {
result = getWebPageContent(name);
......@@ -174,7 +174,7 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService {
try {
Compartment compartmentAlias = new Compartment("some_id");
compartmentAlias.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.GO, "GO:0046902"));
compartmentAlias.addMiriamData(createMiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.GO, "GO:0046902"));
annotateElement(compartmentAlias);
if (compartmentAlias.getFullName() == null || compartmentAlias.getFullName().equals("")) {
......
......@@ -100,7 +100,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
try {
GenericProtein proteinAlias = new GenericProtein("id");
proteinAlias
.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.HGNC_SYMBOL, "SNCA"));
.addMiriamData(createMiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.HGNC_SYMBOL, "SNCA"));
annotateElement(proteinAlias);
if (proteinAlias.getFullName() == null || proteinAlias.getFullName().equals("")) {
......@@ -182,16 +182,16 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
// add hgnc id only when there was no hgnc_id in the element
String id = getNodeValue(node);
id = id.replaceAll("HGNC:", "");
element.addMiriamData(new MiriamData(MiriamType.HGNC, id));
element.addMiriamData(createMiriamData(MiriamType.HGNC, id));
} else if (type.equals("ensembl_gene_id")) {
element.addMiriamData(new MiriamData(MiriamType.ENSEMBL, getNodeValue(node)));
element.addMiriamData(createMiriamData(MiriamType.ENSEMBL, getNodeValue(node)));
} else if (type.equals("entrez_id")) {
element.addMiriamData(new MiriamData(MiriamType.ENTREZ, getNodeValue(node)));
element.addMiriamData(createMiriamData(MiriamType.ENTREZ, getNodeValue(node)));
} else if (type.equals("symbol")) {
if (symbols.size() == 0) {
// add hgnc symbol annnotation only when there was no
// hgnc_symbol in the element
element.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, getNodeValue(node)));
element.addMiriamData(createMiriamData(MiriamType.HGNC_SYMBOL, getNodeValue(node)));
}
setSymbol(element, getNodeValue(node), prefix);
} else if (type.equals("name")) {
......@@ -204,7 +204,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
for (int j = 0; j < sublist.getLength(); j++) {
Node subnode = sublist.item(j);
if (subnode.getNodeType() == Node.ELEMENT_NODE) {
element.addMiriamData(new MiriamData(MiriamType.REFSEQ, getNodeValue(subnode)));
element.addMiriamData(createMiriamData(MiriamType.REFSEQ, getNodeValue(subnode)));
}
}
} else if (type.equals("prev_symbol")) {
......@@ -316,7 +316,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
Node uniprotNode = uniprotList.item(j);
if (uniprotNode.getNodeType() == Node.ELEMENT_NODE) {
if (uniprotNode.getNodeName().equals("str")) {
result.add(new MiriamData(MiriamType.UNIPROT, uniprotNode.getTextContent()));
result.add(createMiriamData(MiriamType.UNIPROT, uniprotNode.getTextContent()));
}
}
}
......@@ -332,7 +332,6 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
} catch (Exception e) {
throw new AnnotatorException(e);
}
}
/**
......@@ -372,7 +371,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
if (node.getNodeName().equals("str")) {
String type = getNodeAttr("name", node);
if (type.equals("symbol")) {
return new MiriamData(MiriamType.HGNC_SYMBOL, node.getTextContent());
return createMiriamData(MiriamType.HGNC_SYMBOL, node.getTextContent());
}
}
}
......@@ -444,7 +443,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
String type = getNodeAttr("name", node);
if (type.equals("entrez_id")) {
String id = getNodeValue(node);
return new MiriamData(MiriamType.ENTREZ, id);
return createMiriamData(MiriamType.ENTREZ, id);
}
}
}
......
......@@ -82,7 +82,7 @@ public class PdbAnnotator extends ElementAnnotator implements IExternalService {
this.setCache(null);
try {
Collection<Structure> structures = uniProtToPdb(new MiriamData(MiriamType.UNIPROT, "P29373"));
Collection<Structure> structures = uniProtToPdb(createMiriamData(MiriamType.UNIPROT, "P29373"));
if (structures.size() > 0){
if (structures.iterator().next().getPdbId() != null) { //TODO - is this id?
......@@ -147,7 +147,7 @@ public class PdbAnnotator extends ElementAnnotator implements IExternalService {
//do not have the concept of hierarchy or complex data types)
Set<MiriamData> annotations = new HashSet<MiriamData>();
for (Structure s : structures) {
annotations.add(new MiriamData(MiriamType.PDB, s.getPdbId()));
annotations.add(createMiriamData(MiriamType.PDB, s.getPdbId()));
}
bioEntity.addMiriamData(annotations);
......
......@@ -85,7 +85,7 @@ public class StitchAnnotator extends ElementAnnotator implements IExternalServic
return;
}
object.addMiriamData(new MiriamData(MiriamType.STITCH, inchiKeyExtractMainLayer(inchiKey)));
object.addMiriamData(createMiriamData(MiriamType.STITCH, inchiKeyExtractMainLayer(inchiKey)));
} catch(ChebiSearchException exception) {
logger.warn("No ChEBI element retrieved fro ChEBI ID: " + mdChebi.getResource());
}
......
......@@ -95,7 +95,7 @@ public class StringAnnotator extends ElementAnnotator implements IExternalServic
throw new InvalidArgumentException(MiriamType.UNIPROT + " expected.");
}
return new MiriamData(MiriamType.STRING, uniprot.getResource());
return createMiriamData(MiriamType.STRING, uniprot.getResource());
}
@Override
......
......@@ -68,7 +68,7 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi
this.setCache(null);
try {
MiriamData md = uniProtToHgnc(new MiriamData(MiriamType.UNIPROT, "P37840"));
MiriamData md = uniProtToHgnc(createMiriamData(MiriamType.UNIPROT, "P37840"));
status.setStatus(ExternalServiceStatusType.OK);
if (md == null) {
......@@ -109,7 +109,7 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi
annotations.addAll(parseHgnc(pageContent));
annotations.addAll(parseEntrez(pageContent));
if (!uniprotFound) {
annotations.add(new MiriamData(MiriamType.UNIPROT, uniprotId));
annotations.add(createMiriamData(MiriamType.UNIPROT, uniprotId));
}
object.addMiriamData(annotations);
} else {
......@@ -149,7 +149,7 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi
Collection<MiriamData> result = new HashSet<MiriamData>();
Matcher m = uniprotToEntrez.matcher(pageContent);
if (m.find()) {
result.add(new MiriamData(MiriamType.ENTREZ, m.group(1)));
result.add(createMiriamData(MiriamType.ENTREZ, m.group(1)));
}
return result;
}
......@@ -166,7 +166,7 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi
Collection<MiriamData> result = new HashSet<MiriamData>();
Matcher m = uniprotToHgnc.matcher(pageContent);
if (m.find()) {
result.add(new MiriamData(MiriamType.HGNC_SYMBOL, m.group(1)));
result.add(createMiriamData(MiriamType.HGNC_SYMBOL, m.group(1)));
}
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment