Search in sources :

Example 1 with Window

use of com.hartwig.hmftools.common.window.Window in project hmftools by hartwigmedical.

the class PCFFile method readPositions.

@NotNull
public static ListMultimap<String, PCFPosition> readPositions(int windowSize, @NotNull PCFSource source, @NotNull final String filename) throws IOException {
    ListMultimap<String, PCFPosition> result = ArrayListMultimap.create();
    final Window window = new Window(windowSize);
    long end = 0;
    for (String line : Files.readAllLines(new File(filename).toPath())) {
        if (!line.startsWith(HEADER_PREFIX)) {
            String[] values = line.split(DELIMITER);
            final String chromosomeName = values[1];
            long start = window.start(Long.valueOf(values[3]));
            if (start != end) {
                result.put(chromosomeName, position(chromosomeName, start, source));
            }
            end = window.start(Long.valueOf(values[4])) + windowSize;
            result.put(chromosomeName, position(chromosomeName, end, source));
        }
    }
    return result;
}
Also used : Window(com.hartwig.hmftools.common.window.Window) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Window

use of com.hartwig.hmftools.common.window.Window in project hmftools by hartwigmedical.

the class PCFPositionsSupplier method centromeres.

@NotNull
private static Multimap<String, PCFPosition> centromeres(int windowSize) {
    final Window window = new Window(windowSize);
    final Multimap<String, PCFPosition> result = ArrayListMultimap.create();
    for (final Map.Entry<String, GenomeRegion> entry : Centromeres.grch37().entrySet()) {
        final GenomeRegion centromere = entry.getValue();
        result.put(entry.getKey(), create(centromere.chromosome(), window.start(centromere.start())));
        result.put(entry.getKey(), create(centromere.chromosome(), window.start(centromere.end()) + windowSize));
    }
    return result;
}
Also used : Window(com.hartwig.hmftools.common.window.Window) GenomeRegion(com.hartwig.hmftools.common.region.GenomeRegion) Map(java.util.Map) ImmutablePCFPosition(com.hartwig.hmftools.common.pcf.ImmutablePCFPosition) PCFPosition(com.hartwig.hmftools.common.pcf.PCFPosition) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Window (com.hartwig.hmftools.common.window.Window)2 NotNull (org.jetbrains.annotations.NotNull)2 ImmutablePCFPosition (com.hartwig.hmftools.common.pcf.ImmutablePCFPosition)1 PCFPosition (com.hartwig.hmftools.common.pcf.PCFPosition)1 GenomeRegion (com.hartwig.hmftools.common.region.GenomeRegion)1 File (java.io.File)1 Map (java.util.Map)1