Commit 5550cc84 authored by Michael Menzel's avatar Michael Menzel

Distance track support for batch analysis. Caller code and convert method

parent 26cb3628
......@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
/**
* Collection of utils for track objects.
......@@ -496,6 +497,17 @@ public final class Tracks {
return TrackFactory.getInstance().createInOutTrack(start, end, track.getName() + " as inout ", track.getDescription(), track.getAssembly());
}
public static DistanceTrack createDistFromInOut(InOutTrack track) {
List<Long> midpoints = IntStream.range(0, track.getStarts().length)
.mapToLong(p -> track.getEnds()[p] - track.getStarts()[p])
.boxed()
.collect(Collectors.toList());
return TrackFactory.getInstance().createDistanceTrack(midpoints, "Distance from " + track.getName(), "Distance from " + track.getName(), Genome.Assembly.hg19, track.getCellLine());
}
/**
* Returns a track created from given sites object.
......
......@@ -234,6 +234,19 @@ class AnalysisHelper {
logger.warn(e.toString());
}
/*
//TODO Use to call create distance tracks and call for batch result histogram
// TODO build to work with hg38 -> change id's
if(packages.contains("Genetic") && command.getAssembly().equals(Genome.Assembly.hg19)){
Track cpg_distance = Tracks.createDistFromInOut((InOutTrack) TrackFactory.getInstance().getTrackByDbId(1376));
Track tss = Tracks.createDistFromInOut((InOutTrack) TrackFactory.getInstance().getTrackByDbId(1386));
tracks.add(tss);
tracks.add(cpg_distance);
}
*/
tracks = tracks.stream().filter(distinctByKey(Track::getName)).collect(Collectors.toList());
for (Sites sites : batchSites) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment