Search in sources :

Example 1 with InfoWriter

use of com.milaboratory.mixcr.export.InfoWriter in project mixcr by milaboratory.

the class ActionExportClones method go0.

@Override
public void go0() throws Exception {
    CloneExportParameters parameters = (CloneExportParameters) this.parameters;
    try (InputStream inputStream = IOUtil.createIS(parameters.getInputFile());
        InfoWriter<Clone> writer = new InfoWriter<>(parameters.getOutputFile())) {
        CloneSet set = CloneSetIO.readClns(inputStream, VDJCLibraryRegistry.getDefault());
        set = CloneSet.transform(set, parameters.getFilter());
        writer.attachInfoProviders((List) parameters.exporters);
        writer.ensureHeader();
        long limit = parameters.getLimit();
        for (int i = 0; i < set.size(); i++) {
            if (set.get(i).getFraction() < parameters.minFraction || set.get(i).getCount() < parameters.minCount) {
                limit = i;
                break;
            }
        }
        ExportClones exportClones = new ExportClones(set, writer, limit);
        SmartProgressReporter.startProgressReport(exportClones, System.err);
        exportClones.run();
    }
}
Also used : InfoWriter(com.milaboratory.mixcr.export.InfoWriter) CloneSet(com.milaboratory.mixcr.basictypes.CloneSet) InputStream(java.io.InputStream) Clone(com.milaboratory.mixcr.basictypes.Clone)

Example 2 with InfoWriter

use of com.milaboratory.mixcr.export.InfoWriter in project mixcr by milaboratory.

the class ActionExportAlignments method go0.

@Override
public void go0() throws Exception {
    try (VDJCAlignmentsReader reader = new VDJCAlignmentsReader(parameters.getInputFile(), VDJCLibraryRegistry.getDefault());
        InfoWriter<VDJCAlignments> writer = new InfoWriter<>(parameters.getOutputFile())) {
        SmartProgressReporter.startProgressReport("Exporting alignments", reader, System.err);
        writer.attachInfoProviders((List) parameters.exporters);
        writer.ensureHeader();
        VDJCAlignments alignments;
        long count = 0;
        long limit = parameters.getLimit();
        OutputPort<VDJCAlignments> alignmentsPort = new FilteringPort<>(reader, parameters.getFilter());
        while ((alignments = alignmentsPort.take()) != null && count < limit) {
            writer.put(alignments);
            ++count;
        }
    }
}
Also used : InfoWriter(com.milaboratory.mixcr.export.InfoWriter) VDJCAlignmentsReader(com.milaboratory.mixcr.basictypes.VDJCAlignmentsReader) FilteringPort(cc.redberry.pipe.blocks.FilteringPort) VDJCAlignments(com.milaboratory.mixcr.basictypes.VDJCAlignments)

Aggregations

InfoWriter (com.milaboratory.mixcr.export.InfoWriter)2 FilteringPort (cc.redberry.pipe.blocks.FilteringPort)1 Clone (com.milaboratory.mixcr.basictypes.Clone)1 CloneSet (com.milaboratory.mixcr.basictypes.CloneSet)1 VDJCAlignments (com.milaboratory.mixcr.basictypes.VDJCAlignments)1 VDJCAlignmentsReader (com.milaboratory.mixcr.basictypes.VDJCAlignmentsReader)1 InputStream (java.io.InputStream)1