added support for Picard IntervalList files to --interval_file
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@334 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
295c269a64
commit
0b81a76420
|
|
@ -4,6 +4,8 @@ import edu.mit.broad.picard.filter.FilteringIterator;
|
||||||
import edu.mit.broad.picard.filter.SamRecordFilter;
|
import edu.mit.broad.picard.filter.SamRecordFilter;
|
||||||
import edu.mit.broad.picard.reference.ReferenceSequence;
|
import edu.mit.broad.picard.reference.ReferenceSequence;
|
||||||
import edu.mit.broad.picard.sam.SamFileHeaderMerger;
|
import edu.mit.broad.picard.sam.SamFileHeaderMerger;
|
||||||
|
import edu.mit.broad.picard.directed.IntervalList;
|
||||||
|
import edu.mit.broad.picard.util.Interval;
|
||||||
import net.sf.functionalj.Function1;
|
import net.sf.functionalj.Function1;
|
||||||
import net.sf.functionalj.FunctionN;
|
import net.sf.functionalj.FunctionN;
|
||||||
import net.sf.functionalj.Functions;
|
import net.sf.functionalj.Functions;
|
||||||
|
|
@ -207,6 +209,21 @@ public abstract class TraversalEngine {
|
||||||
* @param file_name
|
* @param file_name
|
||||||
*/
|
*/
|
||||||
public void setLocationFromFile(final String file_name) {
|
public void setLocationFromFile(final String file_name) {
|
||||||
|
|
||||||
|
// first try to read it as an interval file since that's well structured
|
||||||
|
// we'll fail quickly if it's not a valid file. Then try to parse it as
|
||||||
|
// a location string file
|
||||||
|
try {
|
||||||
|
IntervalList il = IntervalList.fromFile(new File(file_name));
|
||||||
|
|
||||||
|
// iterate through the list of merged intervals and add then as GenomeLocs
|
||||||
|
ArrayList<GenomeLoc> locList = new ArrayList<GenomeLoc>();
|
||||||
|
for(Interval interval : il.getUniqueIntervals()) {
|
||||||
|
locList.add(new GenomeLoc(interval.getSequence(), interval.getStart(), interval.getEnd()));
|
||||||
|
}
|
||||||
|
this.locs = locList;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
try {
|
try {
|
||||||
xReadLines reader = new xReadLines(new File(file_name));
|
xReadLines reader = new xReadLines(new File(file_name));
|
||||||
List<String> lines = reader.readLines();
|
List<String> lines = reader.readLines();
|
||||||
|
|
@ -214,11 +231,12 @@ public abstract class TraversalEngine {
|
||||||
String locStr = Utils.join(";", lines);
|
String locStr = Utils.join(";", lines);
|
||||||
logger.debug("locStr: " + locStr);
|
logger.debug("locStr: " + locStr);
|
||||||
setLocation(locStr);
|
setLocation(locStr);
|
||||||
} catch (Exception e) {
|
} catch (Exception e2) {
|
||||||
e.printStackTrace();
|
e2.printStackTrace();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue