After thinking about this a bit more, it makes sense to pull this functionality out of my walker and into the GenomeLocParser where everyone else can benefit from it...
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1677 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
7bfb5fad27
commit
5ce42cbab3
|
|
@ -56,7 +56,7 @@ public class IntervalMergerWalker extends ReadWalker<Integer,Integer> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
intervals = parseIntervals(intervalsSource);
|
intervals = new LinkedList<GenomeLoc>(GenomeLocParser.parseIntervals(intervalsSource));
|
||||||
currentInterval = (intervals.size() > 0 ? intervals.removeFirst() : null);
|
currentInterval = (intervals.size() > 0 ? intervals.removeFirst() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,16 +109,5 @@ public class IntervalMergerWalker extends ReadWalker<Integer,Integer> {
|
||||||
currentInterval.getStop() - currentInterval.getStart() < maxIntervalSize)
|
currentInterval.getStop() - currentInterval.getStart() < maxIntervalSize)
|
||||||
out.println(currentInterval);
|
out.println(currentInterval);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the intervals directly from the command-line or from file, as appropriate.
|
|
||||||
* Merge overlapping intervals.
|
|
||||||
* @param intervalsSource Source of intervals.
|
|
||||||
* @return a linked list of sorted, merged intervals.
|
|
||||||
*/
|
|
||||||
private LinkedList<GenomeLoc> parseIntervals(List<String> intervalsSource) {
|
|
||||||
List<GenomeLoc> parsedIntervals = GenomeAnalysisEngine.parseIntervalRegion(intervalsSource);
|
|
||||||
Collections.sort(parsedIntervals);
|
|
||||||
return new LinkedList<GenomeLoc>(GenomeLocParser.mergeOverlappingLocations(parsedIntervals));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,17 @@ public class GenomeLocParser {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load one or more intervals sources, sorting and merging overlapping intervals.
|
||||||
|
* @param intervalsSource Source of intervals.
|
||||||
|
* @return a list of sorted, merged intervals.
|
||||||
|
*/
|
||||||
|
public static List<GenomeLoc> parseIntervals(List<String> intervalsSource) {
|
||||||
|
List<GenomeLoc> parsedIntervals = GenomeAnalysisEngine.parseIntervalRegion(intervalsSource);
|
||||||
|
Collections.sort(parsedIntervals);
|
||||||
|
return GenomeLocParser.mergeOverlappingLocations(parsedIntervals);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parse a genome location, from a location string
|
* parse a genome location, from a location string
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue