Search in sources :

Example 6 with SetFileRecord

use of com.github.lindenb.jvarkit.setfile.SetFileRecord in project jvarkit by lindenb.

the class SetFileTools method combine.

private int combine(final List<String> args) throws IOException {
    try (CloseableIterator<SetFileRecord> iter = openSetFileIterator(args)) {
        final List<SetFileRecord> L2 = iter.stream().collect(Collectors.toList());
        try (PrintWriter pw = super.openPathOrStdoutAsPrintWriter(this.outputFile)) {
            for (int i = 0; i + 1 < L2.size(); i++) {
                final SetFileRecord r1 = L2.get(i);
                for (int j = i + 1; j < L2.size(); j++) {
                    final SetFileRecord r2 = L2.get(j);
                    final List<Locatable> L = new ArrayList<>(r1.size() + r2.size());
                    L.addAll(r1);
                    L.addAll(r2);
                    final String name = String.join("_", r1.getName(), r2.getName());
                    print(pw, SetFileRecord.create(name, sortAndMerge(L)));
                }
            }
            pw.flush();
        }
    }
    return 0;
}
Also used : SetFileRecord(com.github.lindenb.jvarkit.setfile.SetFileRecord) ArrayList(java.util.ArrayList) PrintWriter(java.io.PrintWriter) Locatable(htsjdk.samtools.util.Locatable)

Example 7 with SetFileRecord

use of com.github.lindenb.jvarkit.setfile.SetFileRecord in project jvarkit by lindenb.

the class SetFileTools method view.

private int view(final List<String> args) throws IOException {
    try (CloseableIterator<SetFileRecord> iter = openSetFileIterator(args)) {
        try (PrintWriter pw = super.openPathOrStdoutAsPrintWriter(this.outputFile)) {
            while (iter.hasNext()) {
                final SetFileRecord rec = iter.next();
                print(pw, rec);
            }
            pw.flush();
        }
    }
    return 0;
}
Also used : SetFileRecord(com.github.lindenb.jvarkit.setfile.SetFileRecord) PrintWriter(java.io.PrintWriter)

Aggregations

SetFileRecord (com.github.lindenb.jvarkit.setfile.SetFileRecord)7 PrintWriter (java.io.PrintWriter)6 Locatable (htsjdk.samtools.util.Locatable)4 BedLineReader (com.github.lindenb.jvarkit.bed.BedLineReader)3 IntervalExtender (com.github.lindenb.jvarkit.samtools.util.IntervalExtender)3 SetFileReaderFactory (com.github.lindenb.jvarkit.setfile.SetFileReaderFactory)3 BedLine (com.github.lindenb.jvarkit.util.bio.bed.BedLine)3 Parameter (com.beust.jcommander.Parameter)2 ArchiveFactory (com.github.lindenb.jvarkit.io.ArchiveFactory)2 IOUtils (com.github.lindenb.jvarkit.io.IOUtils)2 AbstractCloseableIterator (com.github.lindenb.jvarkit.iterator.AbstractCloseableIterator)2 EqualIterator (com.github.lindenb.jvarkit.iterator.EqualIterator)2 StringUtils (com.github.lindenb.jvarkit.lang.StringUtils)2 DiscreteMedian (com.github.lindenb.jvarkit.math.DiscreteMedian)2 SimpleInterval (com.github.lindenb.jvarkit.samtools.util.SimpleInterval)2 Counter (com.github.lindenb.jvarkit.util.Counter)2 DistanceParser (com.github.lindenb.jvarkit.util.bio.DistanceParser)2 SequenceDictionaryUtils (com.github.lindenb.jvarkit.util.bio.SequenceDictionaryUtils)2 ContigNameConverter (com.github.lindenb.jvarkit.util.bio.fasta.ContigNameConverter)2 Launcher (com.github.lindenb.jvarkit.util.jcommander.Launcher)2