@Override public Set<String> fetchID(BioPAXElement ele) { if (ele instanceof SmallMoleculeReference) { SmallMoleculeReference smr = (SmallMoleculeReference) ele; String name = null; if (smr.getDisplayName() != null) name = smr.getDisplayName(); else if (smr.getStandardName() != null) name = smr.getStandardName(); else if (!smr.getName().isEmpty()) name = smr.getName().iterator().next(); if (name != null) { name = name.toLowerCase(); if (nameMap != null && nameMap.containsKey(name)) name = nameMap.get(name); return Collections.singleton(name); } } return super.fetchID(ele); } }
private boolean isGeneric(SmallMoleculeReference smr) { if (!smr.getMemberEntityReference().isEmpty()) return true; for (SimplePhysicalEntity sm : smr.getEntityReferenceOf()) { if (!sm.getMemberPhysicalEntity().isEmpty()) return true; } return false; }
String name = smr.getDisplayName(); if (name == null) continue; name = name.toLowerCase(); blacklist.addEntry(smr.getUri(), 1, knownNames.get(name)); for (SimplePhysicalEntity spe : smr.getEntityReferenceOf())
for (String name : smr.getName()) for (SimplePhysicalEntity sm : smr.getEntityReferenceOf())
/** * Gets the name of the small molecule to use in SIF. * @param smr small molecule ref * @return a name */ protected String getCompoundName(SmallMoleculeReference smr) { return smr.getDisplayName(); } }
if (smr.getUri().startsWith("http://identifiers")) standard.add(smr); else other.add(smr); if (smr.getDisplayName().length() <= m.getDisplayName().length()) System.out.print(smr.getDisplayName() + " matched more than one"); for (SmallMoleculeReference match : matches) System.out.print("\t" + match.getDisplayName()); System.out.println("Already matched " + match.getDisplayName() + " to " + map.get(match).getDisplayName() + ". This one is " + rep.getDisplayName()); System.out.println(match.getDisplayName() + " was mapped from another chem");
blacklist.addEntry(smr.getUri(), decider.getScore(neighSize, upstrOnly, dwstrOnly), decider.getContext(neighSize, upstrOnly, dwstrOnly));
private Map<SmallMoleculeReference, Set<SmallMoleculeReference>> getSelfMatching( Set<SmallMoleculeReference> smrs, Map<SmallMoleculeReference, Set<String>> smrNames, Map<SmallMoleculeReference, Set<String>> smNames, boolean normalizeName) { Map<SmallMoleculeReference, Set<SmallMoleculeReference>> map = new HashMap<SmallMoleculeReference, Set<SmallMoleculeReference>>(); for (SmallMoleculeReference smr : smrs) { Set<SmallMoleculeReference> matching = normalizeName ? getNameNormalizedMatching(smr, smrs) : getMatching(smr, smrs, smrNames, smNames); // it should at least detect itself, if it has a name assert normalizeName || !matching.isEmpty() || smr.getName().isEmpty(); matching.remove(smr); if (!matching.isEmpty()) map.put(smr, matching); } return map; }
private Set<Set<String>> collectNameSets(Model model) { Set<Set<String>> bag = new HashSet<Set<String>>(); for (SmallMoleculeReference smr : model.getObjects(SmallMoleculeReference.class)) { Set<String> set = new HashSet<String>(); for (String name : smr.getName()) { set.add(name.toLowerCase()); } for (SimplePhysicalEntity sm : smr.getEntityReferenceOf()) { for (String name : sm.getName()) { set.add(name.toLowerCase()); } } doSomeCleaning(set); enrichWithModifications(set); bag.add(set); } return bag; }
/** * Gets the standard name of the small molecule. * @param smr the molecule to check standard name * @return standard name */ public String getName(SmallMoleculeReference smr) { if (map.containsKey(smr)) return map.get(smr).getDisplayName(); else return smr.getDisplayName(); }
blacklist.addEntry(smr.getUri(), decider.getScore(neighSize, upstrOnly, dwstrOnly), decider.getContext(neighSize, upstrOnly, dwstrOnly));
@Override public int compare(SmallMoleculeReference o1, SmallMoleculeReference o2) { if (map.containsValue(o1)) { if (!map.containsValue(o2)) return -1; } else { if (map.containsValue(o2)) return 1; } if (!cnt.get(o1).equals(cnt.get(o2))) return cnt.get(o2).compareTo(cnt.get(o1)); if (o1.getDisplayName().endsWith(")")) { if (!o2.getDisplayName().endsWith(")")) return -1; } else if (o2.getDisplayName().endsWith(")")) return 1; return o1.getDisplayName().compareTo(o2.getDisplayName()); } });
/** * Gets IDs of the small molecule reference and its physical entities. * @param smr small molecule reference * @return related IDs */ private String getRelatedIDs(SmallMoleculeReference smr) { String ids = smr.getUri(); for (Object o : new PathAccessor( "SmallMoleculeReference/entityReferenceOf").getValueFromBean(smr)) { SimplePhysicalEntity spe = (SimplePhysicalEntity) o; ids += "\n" + spe.getUri(); } return ids; } }
private Set<SmallMoleculeReference> getNameNormalizedMatching(SmallMoleculeReference smr, Set<SmallMoleculeReference> smrs) { String name = null; String dispName = smr.getDisplayName().toLowerCase(); if (dispName.endsWith("-)") || dispName.endsWith("+)")) { name = dispName.substring(0, dispName.lastIndexOf("(")).trim(); } else if (dispName.endsWith(" zwitterion")) { name = dispName.substring(0, dispName.lastIndexOf(" ")).trim(); } if (name == null) return Collections.emptySet(); Set<SmallMoleculeReference> matching = new HashSet<SmallMoleculeReference>(); for (SmallMoleculeReference ref : smrs) { if (ref.getDisplayName().toLowerCase().equals(name)) matching.add(ref); } return matching; }
private void printTopPart(String listName, Set<SmallMoleculeReference> smrs, int upTo) { Map<SmallMoleculeReference, Integer> cnt = getInteractionCounts(smrs); List<SmallMoleculeReference> list = getSortedList(smrs, cnt); int i = 0; System.out.println(listName + "\n--------------"); for (SmallMoleculeReference smr : list) { System.out.println(cnt.get(smr) + "\t" + smr.getDisplayName()); if (++i == upTo) break; } System.out.println(); }
private void printTopPart(String listName, Map<SmallMoleculeReference, Set<SmallMoleculeReference>> smrMap, int upTo) { Map<SmallMoleculeReference, Integer> cnt = getInteractionCounts(smrMap.keySet()); List<SmallMoleculeReference> list = getSortedList(smrMap.keySet(), cnt); int i = 0; System.out.println(listName + "\n--------------"); for (SmallMoleculeReference smr : list) { System.out.print(cnt.get(smr) + "\t" + smr.getDisplayName() + "\t"); for (SmallMoleculeReference match : smrMap.get(smr)) { System.out.print("\t" + match.getDisplayName()); } System.out.println(); if (++i == upTo) break; } System.out.println(); }
if (std.getDisplayName() != null && smr.getDisplayName() != null && std.getDisplayName().toLowerCase().equals(smr.getDisplayName().toLowerCase())) matching.add(std);