* @return The found locus, null if not found
*/
public static Locus getLocus(String searchString, int flankingRegion) {
SearchCommand cmd = new SearchCommand(getDefaultFrame(), searchString);
List<SearchCommand.SearchResult> results = cmd.runSearch(searchString);
Locus locus = null;
for (SearchCommand.SearchResult result : results) {
if (result.getType() != SearchCommand.ResultType.ERROR) {
int delta = 0;
if (result.getType() != SearchCommand.ResultType.LOCUS) {
if (flankingRegion < 0) {
delta = (-flankingRegion * (result.getEnd() - result.getStart())) / 100;
} else {
delta = flankingRegion;
}
}
int start = result.getStart() - delta;
//Don't allow flanking region to extend past origin
//There are some circumstances in which we render before origin (e.g. soft-clips)
//so we are conservative
if (start < 0 && result.getStart() >= -1) {
start = 0;
}
locus = new Locus(
result.getChr(),
start,
result.getEnd() + delta);
//We just take the first result
break;