use of org.broadinstitute.hellbender.utils.tsv.TableWriter in project gatk by broadinstitute.
the class ReadCountCollectionUtils method createReadCountRecordTableWriterWithoutIntervals.
private static TableWriter<ReadCountRecord> createReadCountRecordTableWriterWithoutIntervals(final Writer writer, List<String> columnNames) throws IOException {
final TableColumnCollection columns = new TableColumnCollection(columnNames);
return new TableWriter<ReadCountRecord>(writer, columns) {
@Override
protected void composeLine(final ReadCountRecord record, final DataLine dataLine) {
dataLine.append(record.getTarget().getName());
record.appendCountsTo(dataLine);
}
};
}
use of org.broadinstitute.hellbender.utils.tsv.TableWriter in project gatk-protected by broadinstitute.
the class ReadCountCollectionUtils method writerWithIntervals.
/**
* Creates a new table writer that will output the target intervals.
* @param writer where to output the table formatted content.
* @param countColumnNames list of count column names.
* @return never {@code null}.
* @throws IOException if there is some low level IO problem creating the writer.
* @throws IllegalArgumentException if {@code countColumnNames} is {@code null}, contains
* {@code null} or a non valid count column name (e.g. a reserved word).
*/
public static TableWriter<ReadCountRecord> writerWithIntervals(final Writer writer, final List<String> countColumnNames) throws IOException {
final List<String> columnNames = new ArrayList<>();
columnNames.add(TargetTableColumn.CONTIG.toString());
columnNames.add(TargetTableColumn.START.toString());
columnNames.add(TargetTableColumn.END.toString());
columnNames.add(TargetTableColumn.NAME.toString());
columnNames.addAll(Utils.nonNull(countColumnNames));
final TableColumnCollection columns = new TableColumnCollection(columnNames);
return new TableWriter<ReadCountRecord>(writer, columns) {
@Override
protected void composeLine(final ReadCountRecord record, final DataLine dataLine) {
final SimpleInterval interval = record.getTarget().getInterval();
if (interval == null) {
throw new IllegalStateException("invalid combination of targets with and without intervals defined");
}
dataLine.append(interval.getContig()).append(interval.getStart()).append(interval.getEnd()).append(record.getTarget().getName());
record.appendCountsTo(dataLine);
}
};
}
use of org.broadinstitute.hellbender.utils.tsv.TableWriter in project gatk-protected by broadinstitute.
the class ReadCountCollectionUtils method createReadCountRecordTableWriterWithoutIntervals.
private static TableWriter<ReadCountRecord> createReadCountRecordTableWriterWithoutIntervals(final Writer writer, List<String> columnNames) throws IOException {
final TableColumnCollection columns = new TableColumnCollection(columnNames);
return new TableWriter<ReadCountRecord>(writer, columns) {
@Override
protected void composeLine(final ReadCountRecord record, final DataLine dataLine) {
dataLine.append(record.getTarget().getName());
record.appendCountsTo(dataLine);
}
};
}
use of org.broadinstitute.hellbender.utils.tsv.TableWriter in project gatk-protected by broadinstitute.
the class XHMMSegmentCallerBaseIntegrationTest method writeChainInTempFile.
public static File writeChainInTempFile(final XHMMData chain) {
final File result = createTempFile("chain-", ".tab");
//final File result = new File("/tmp/input");
final List<String> sampleNames = IntStream.range(0, chain.data.size()).mapToObj(a -> "SAMPLE_" + a).collect(Collectors.toList());
final List<String> columnNames = new ArrayList<>(sampleNames.size() + 4);
columnNames.addAll(Arrays.asList(TargetTableColumn.CONTIG.toString(), TargetTableColumn.START.toString(), TargetTableColumn.END.toString(), TargetTableColumn.NAME.toString()));
columnNames.addAll(sampleNames);
try (final TableWriter<Integer> writer = new TableWriter<Integer>(result, new TableColumnCollection(columnNames)) {
@Override
protected void composeLine(final Integer record, final DataLine dataLine) {
dataLine.append(chain.targets.get(record).getContig()).append(chain.targets.get(record).getStart()).append(chain.targets.get(record).getEnd()).append(chain.targets.get(record).getName());
for (final List<Double> sampleData : chain.data) {
dataLine.append(sampleData.get(record));
}
}
}) {
writer.writeAllRecords(IntStream.range(0, chain.targets.size()).boxed().collect(Collectors.toList()));
} catch (final IOException ex) {
throw new UncheckedIOException(ex);
}
return result;
}
use of org.broadinstitute.hellbender.utils.tsv.TableWriter in project gatk by broadinstitute.
the class XHMMSegmentCallerBaseIntegrationTest method writeChainInTempFile.
public static File writeChainInTempFile(final XHMMData chain) {
final File result = createTempFile("chain-", ".tab");
//final File result = new File("/tmp/input");
final List<String> sampleNames = IntStream.range(0, chain.data.size()).mapToObj(a -> "SAMPLE_" + a).collect(Collectors.toList());
final List<String> columnNames = new ArrayList<>(sampleNames.size() + 4);
columnNames.addAll(Arrays.asList(TargetTableColumn.CONTIG.toString(), TargetTableColumn.START.toString(), TargetTableColumn.END.toString(), TargetTableColumn.NAME.toString()));
columnNames.addAll(sampleNames);
try (final TableWriter<Integer> writer = new TableWriter<Integer>(result, new TableColumnCollection(columnNames)) {
@Override
protected void composeLine(final Integer record, final DataLine dataLine) {
dataLine.append(chain.targets.get(record).getContig()).append(chain.targets.get(record).getStart()).append(chain.targets.get(record).getEnd()).append(chain.targets.get(record).getName());
for (final List<Double> sampleData : chain.data) {
dataLine.append(sampleData.get(record));
}
}
}) {
writer.writeAllRecords(IntStream.range(0, chain.targets.size()).boxed().collect(Collectors.toList()));
} catch (final IOException ex) {
throw new UncheckedIOException(ex);
}
return result;
}
Aggregations