From 91e34844f4dca670d04549aa86a7ac32e1c60778 Mon Sep 17 00:00:00 2001 From: Pierre Lindenbaum Date: Mon, 9 Dec 2024 20:54:08 +0100 Subject: [PATCH] https://github.com/lindenb/jvarkit/issues/257 --- docs/JvarkitCentral.md | 4 +- docs/TViewCmd.md | 171 ------------------ docs/index.md | 5 +- mkdocs.yml | 1 + .../jvarkit/tools/jvarkit/JvarkitCentral.java | 2 + .../lindenb/jvarkit/tools/tview/TViewCmd.java | 18 +- 6 files changed, 22 insertions(+), 179 deletions(-) diff --git a/docs/JvarkitCentral.md b/docs/JvarkitCentral.md index 793660730..46bf0080e 100644 --- a/docs/JvarkitCentral.md +++ b/docs/JvarkitCentral.md @@ -2,8 +2,8 @@ JVARKIT ======= Author : Pierre Lindenbaum Phd. Institut du Thorax. Nantes. France. -Version : 11c49f43b -Compilation : 20241209180931 +Version : e746be9d5 +Compilation : 20241209205319 Github : https://github.com/lindenb/jvarkit Issues : https://github.com/lindenb/jvarkit/issues diff --git a/docs/TViewCmd.md b/docs/TViewCmd.md index 6dd698c22..e69de29bb 100644 --- a/docs/TViewCmd.md +++ b/docs/TViewCmd.md @@ -1,171 +0,0 @@ -# TViewCmd - -![Last commit](https://img.shields.io/github/last-commit/lindenb/jvarkit.png) - -equivalent of samtools tview - - -## Usage - -``` -Usage: tview [options] Files - Options: - --clip - Show clip - Default: false - --coverage, --depth - Number of rows for coverage (hide:<=0) - Default: 10 - --filter - A filter expression. Reads matching the expression will be filtered-out. - Empty String means 'filter out nothing/Accept all'. See https://github.com/lindenb/jvarkit/blob/master/src/main/resources/javacc/com/github/lindenb/jvarkit/util/bio/samfilter/SamFilterParser.jj - for a complete syntax. 'default' is 'mapqlt(1) || Duplicate() || - FailsVendorQuality() || NotPrimaryAlignment() || - SupplementaryAlignment()' - Default: mapqlt(1) || Duplicate() || FailsVendorQuality() || NotPrimaryAlignment() || SupplementaryAlignment() - --groupby - Group Reads by. Data partitioning using the SAM Read Group (see - https://gatkforums.broadinstitute.org/gatk/discussion/6472/ ) . It can - be any combination of sample, library.... - Default: sample - Possible Values: [readgroup, sample, library, platform, center, sample_by_platform, sample_by_center, sample_by_platform_by_center, any] - -h, --help - print help and exit - --helpFormat - What kind of help. One of [usage,markdown,xml]. - --hideBases - Hide bases - Default: false - --hideHomRef - Hide HOM_REF variations - Default: false - --hideNoCall - Hide NO_CALL variations - Default: false - --insert - Show insertions - Default: false - -layout, --layout - Layout reads - Default: pileup - Possible Values: [pileup, name] - -left, --leftmargin - left margin width - Default: 15 - -maxrows, --maxrowss - maximum number of rows per read group. -1 == all - Default: -1 - --noconsensus - Hide Consensus line - Default: false - --nodefaultinterval - if no interval was provided, don't try to create a default one. - Default: false - -o, --out - Output file. Optional . Default: stdout - --format, --outputformat - Output format - Default: tty - Possible Values: [tty, plain, html] - --readName - Show read name - Default: false - -R, --reference - Indexed fasta Reference file. This file must be indexed with samtools - faidx and with picard CreateSequenceDictionary - -r, --region - Interval list - Default: [] - -V, --variant, --variants, --vcf - Variant file. if filename ends with '.list' it is interpreted as a list - of file (one file per line) - --version - print version and exit - -width, --width - default screen width - Default: -1 - -``` - - -## Keywords - - * sam - * bam - * visualization - * terminal - - -## Compilation - -### Requirements / Dependencies - -* java [compiler SDK 11](https://jdk.java.net/11/). Please check that this java is in the `${PATH}`. Setting JAVA_HOME is not enough : (e.g: https://github.com/lindenb/jvarkit/issues/23 ) - - -### Download and Compile - -```bash -$ git clone "https://github.com/lindenb/jvarkit.git" -$ cd jvarkit -$ ./gradlew tview -``` - -The java jar file will be installed in the `dist` directory. - -## Source code - -[https://github.com/lindenb/jvarkit/tree/master/src/main/java/com/github/lindenb/jvarkit/tools/tview/TViewCmd.java](https://github.com/lindenb/jvarkit/tree/master/src/main/java/com/github/lindenb/jvarkit/tools/tview/TViewCmd.java) - -### Unit Tests - -[https://github.com/lindenb/jvarkit/tree/master/src/test/java/com/github/lindenb/jvarkit/tools/tview/TViewCmdTest.java](https://github.com/lindenb/jvarkit/tree/master/src/test/java/com/github/lindenb/jvarkit/tools/tview/TViewCmdTest.java) - - -## Contribute - -- Issue Tracker: [http://github.com/lindenb/jvarkit/issues](http://github.com/lindenb/jvarkit/issues) -- Source Code: [http://github.com/lindenb/jvarkit](http://github.com/lindenb/jvarkit) - -## License - -The project is licensed under the MIT license. - -## Citing - -Should you cite **tview** ? [https://github.com/mr-c/shouldacite/blob/master/should-I-cite-this-software.md](https://github.com/mr-c/shouldacite/blob/master/should-I-cite-this-software.md) - -The current reference is: - -[http://dx.doi.org/10.6084/m9.figshare.1425030](http://dx.doi.org/10.6084/m9.figshare.1425030) - -> Lindenbaum, Pierre (2015): JVarkit: java-based utilities for Bioinformatics. figshare. -> [http://dx.doi.org/10.6084/m9.figshare.1425030](http://dx.doi.org/10.6084/m9.figshare.1425030) - - -## Example - -``` -$ java -jar dist/tview.jar -R toy.fa toy.bam --clip --groupby sample --insert --plain - -ref:1-61 - POS: 1.......^^..11..^^^^....^^..21........31...^.....41........51 - REF: AGCATGTT**AGATAA****GATA**GCTGTGCTAGTAGGCAG*TCAGCGCCATNNNNNNN - -ndefined_sample TT**AGATAAAGAGGATA**-CTG cagcgccat - AAAAGATAAGG**GATAAA NNNNNNtaggc - NNNNN**AGCTAA - ATA**GCT--------------CTCAGC -ample CONSENSUS TTAAAGNTAANGAGGATAAAGCTG TAGGC CTCAGCGCCAT -efined_sample 3 ******** **** ** **** - ******** **** ** **** - ******** **** ** **** - ************************ ***** *********** - ************************ ***** *********** - ************************ ***** *********** - ****************************************************** - ****************************************************** - ****************************************************** - 0 ****************************************************** -``` - diff --git a/docs/index.md b/docs/index.md index d8a584a48..80ef2b592 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,8 +2,8 @@ JVARKIT ======= Author : Pierre Lindenbaum Phd. Institut du Thorax. Nantes. France. -Version : 11c49f43b -Compilation : 20241209180931 +Version : e746be9d5 +Compilation : 20241209205319 Github : https://github.com/lindenb/jvarkit Issues : https://github.com/lindenb/jvarkit/issues @@ -351,5 +351,6 @@ Please, read [how to run and install jvarkit](JvarkitCentral.md) | [swingbamcov](SwingBamCov.md) | Bam coverage viewer using Java Swing UI | 20210420 | 20220513 | | [swingbamview](SwingBamView.md) | Read viewer using Java Swing UI | 20220503 | 20230427 | | [texbam](TextBam.md) | Write text in a bam. Mostly for fun... | 20220708 | 20220708 | +| [tview](TViewCmd.md) | equivalent of samtools tview | 20130613 | 20241209 | diff --git a/mkdocs.yml b/mkdocs.yml index a4a80d651..a007b652c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -220,6 +220,7 @@ nav: - "texbam" : TextBam.md - "translategff3" : TranslateGff3.md - "tssenrich" : TSSEnrichment.md + - "tview" : TViewCmd.md - "ukbiobanksamples" : UKBiobankSelectSamples.md - "uniprot2svg" : UniprotToSvg.md - "variantsinwindow" : VariantsInWindow.md diff --git a/src/main/java/com/github/lindenb/jvarkit/tools/jvarkit/JvarkitCentral.java b/src/main/java/com/github/lindenb/jvarkit/tools/jvarkit/JvarkitCentral.java index 0bbba42e9..4204c784a 100644 --- a/src/main/java/com/github/lindenb/jvarkit/tools/jvarkit/JvarkitCentral.java +++ b/src/main/java/com/github/lindenb/jvarkit/tools/jvarkit/JvarkitCentral.java @@ -268,6 +268,7 @@ of this software and associated documentation files (the "Software"), to deal import com.github.lindenb.jvarkit.tools.textbam.TextBam; import com.github.lindenb.jvarkit.tools.translategff3.TranslateGff3; import com.github.lindenb.jvarkit.tools.tss.TSSEnrichment; +import com.github.lindenb.jvarkit.tools.tview.TViewCmd; import com.github.lindenb.jvarkit.tools.ukbiobank.UKBiobankSelectSamples; import com.github.lindenb.jvarkit.tools.uniprot.UniprotToSvg; import com.github.lindenb.jvarkit.tools.upstreamorf.Gff3UpstreamOrf; @@ -836,6 +837,7 @@ private void run(final String[] args) { command(SvToSVG.class); command(VCFSVAnnotator.class); command(TextBam.class); + command(TViewCmd.class); command(TranslateGff3.class); command(UniprotToSvg.class); command(UKBiobankSelectSamples.class); diff --git a/src/main/java/com/github/lindenb/jvarkit/tools/tview/TViewCmd.java b/src/main/java/com/github/lindenb/jvarkit/tools/tview/TViewCmd.java index b7f0b5b11..89a85fe50 100644 --- a/src/main/java/com/github/lindenb/jvarkit/tools/tview/TViewCmd.java +++ b/src/main/java/com/github/lindenb/jvarkit/tools/tview/TViewCmd.java @@ -46,7 +46,6 @@ of this software and associated documentation files (the "Software"), to deal import htsjdk.samtools.SAMSequenceDictionary; import htsjdk.samtools.SamInputResource; import htsjdk.samtools.SamReader; -import htsjdk.samtools.util.CloserUtil; import htsjdk.samtools.util.Interval; /* BEGIN_DOC @@ -82,7 +81,7 @@ of this software and associated documentation files (the "Software"), to deal @Program(name="tview", description="equivalent of samtools tview", keywords={"sam","bam","visualization","terminal"}, - modificationDate = "20230707", + modificationDate = "20241209", creationDate = "20130613", jvarkit_amalgamion = true, menu="BAM Manipulation" @@ -92,6 +91,8 @@ public class TViewCmd extends Launcher private static final Logger LOG = Logger.build(TViewCmd.class).make(); @Parameter(names={"-o","--out"},description=OPT_OUPUT_FILE_OR_STDOUT) private Path outputFile = null; + @Parameter(names={"-R","--reference"},description=CRAM_INDEXED_REFENCE) + private Path faidx = null; @Parameter(names={"-r","--region"},description="Interval list") private Set intervalStr = new HashSet<>(); @Parameter(names={"-width","--width"},description="default screen width") @@ -178,7 +179,9 @@ public int doWork(List args) { final List intervals= this.intervalStr.stream().map(S->parseInterval(S) ).collect(Collectors.toList()); if(!nodefaultinterval && intervals.isEmpty() && !args.isEmpty()) { - final SamReader samReader = super.createSamReaderFactory().open(SamInputResource.of(args.get(0))); + final SamReader samReader = super.createSamReaderFactory(). + referenceSequence(this.faidx). + open(SamInputResource.of(args.get(0))); final SAMSequenceDictionary dict= samReader.getFileHeader()!=null && samReader.getFileHeader().getSequenceDictionary()!=null ? samReader.getFileHeader().getSequenceDictionary() : null @@ -205,7 +208,14 @@ public int doWork(List args) { } finally { - CloserUtil.close(tview); + if(tview!=null) { + try { + tview.close(); + } + catch(Throwable err) { + + } + } } }