Skip to content

Commit

Permalink
https://github.com/lindenb/jvarkit/issues/257
Browse files Browse the repository at this point in the history
  • Loading branch information
lindenb committed Dec 9, 2024
1 parent e746be9 commit 91e3484
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 179 deletions.
4 changes: 2 additions & 2 deletions docs/JvarkitCentral.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
171 changes: 0 additions & 171 deletions docs/TViewCmd.md
Original file line number Diff line number Diff line change
@@ -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 ******************************************************
```
5 changes: 3 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 |


1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/com/github/lindenb/jvarkit/tools/tview/TViewCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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<String> intervalStr = new HashSet<>();
@Parameter(names={"-width","--width"},description="default screen width")
Expand Down Expand Up @@ -178,7 +179,9 @@ public int doWork(List<String> args) {
final List<Interval> 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
Expand All @@ -205,7 +208,14 @@ public int doWork(List<String> args) {
}
finally
{
CloserUtil.close(tview);
if(tview!=null) {
try {
tview.close();
}
catch(Throwable err) {

}
}
}

}
Expand Down

0 comments on commit 91e3484

Please sign in to comment.