
org.snpeff.gtex.IdMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SnpEff Show documentation
Show all versions of SnpEff Show documentation
Variant annotation and effect prediction package.
The newest version!
package org.snpeff.gtex;
import java.util.LinkedList;
import java.util.List;
import org.snpeff.collections.AutoHashMap;
/**
* Maps many IDs to many Names
* I.e. a mapping id <-> name where neither is unique
*
* @author pcingola
*/
public class IdMap {
AutoHashMap> id2names;
AutoHashMap> name2ids;
public IdMap() {
id2names = new AutoHashMap>(new LinkedList());
name2ids = new AutoHashMap>(new LinkedList());
}
/**
* Add a mapping id <-> name
* @param id
* @param name
*/
public void add(String id, String name) {
// Do not add nulls or empties
if ((id == null) || id.isEmpty()) return;
if ((name == null) || name.isEmpty()) return;
id2names.getOrCreate(id).add(name);
name2ids.getOrCreate(name).add(id);
}
/**
* Get all IDs corresponding to this name
* @param name
* @return
*/
public List getIds(String name) {
return name2ids.get(name);
}
/**
* Get all names corresponding to this Id
* @param name
* @return
*/
public List getNames(String id) {
return id2names.get(id);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy