Skip to content

Commit

Permalink
conda
Browse files Browse the repository at this point in the history
  • Loading branch information
lindenb committed Feb 5, 2020
1 parent 5214820 commit 583b6f4
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 18 deletions.
19 changes: 19 additions & 0 deletions conda/jvarkit/Notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Notes about packaging.

See https://docs.conda.io/projects/conda-build/en/latest/user-guide/tutorials/build-pkgs.html

(supprimer `http_proxy` && `https_proxy`)

```
conda create -n ANACONDA conda-build
```

```
conda activate ANACONDA
conda-build jvarkit
conda install --use-local jvarkit
```

```
conda remove --use-local jvarkit
```
8 changes: 8 additions & 0 deletions conda/jvarkit/activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export CONDA_BACKUP_JVARKIT_HOME="${JVARKIT_HOME}"
export CONDA_BACKUP_JVARKIT_DIST="${JVARKIT_DIST}"


export JVARKIT_HOME=${CONDA_PREFIX}
export JVARKIT_DIST="${JVARKIT_HOME}/dist"

echo "[INFO] \${JVARKIT_DIST} is set to ${JVARKIT_DIST}. Example 'java -jar \${JVARKIT_DIST}/vcf2table.jar -h'." 1>&2
16 changes: 16 additions & 0 deletions conda/jvarkit/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e
set -u

ACTIVATE_DIR=$PREFIX/etc/conda/activate.d
DEACTIVATE_DIR=$PREFIX/etc/conda/deactivate.d

cp -v $RECIPE_DIR/activate.sh $ACTIVATE_DIR/jvarkit-activate.sh
cp -v $RECIPE_DIR/deactivate.sh $DEACTIVATE_DIR/jvarkit-deactivate.sh

mkdir -p $PREFIX/dist
./gradlew -Djvarkit.disable.test=true vcfhead vcftail vcffilterjdk vcf2table samjdk bioalcidaejdk vcffilterso sam2tsv mkminibam
mv -v dist/*.jar $PREFIX/dist/


2 changes: 2 additions & 0 deletions conda/jvarkit/deactivate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export JVARKIT_HOME="${CONDA_BACKUP_JVARKIT_HOME}"
export JVARKIT_DIST="${CONDA_BACKUP_JVARKIT_DIST}"
19 changes: 19 additions & 0 deletions conda/jvarkit/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package:
name: jvarkit
version: 20200205

source:
url: https://github.com/lindenb/jvarkit/archive/20200205.zip
md5: 17956e3c734db5503a67a8325a0091a3

requirements:
build:
- openjdk >=8.0
run:
- openjdk >=8.0


about:
summary: jvarkit "Java utilities for Bioinformatics"
home: https://github.com/lindenb/jvarkit
license : MIT
21 changes: 20 additions & 1 deletion docs/VcfToBam.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Usage: vcf2bam [options] Files
Compression Level.
Default: 5
--fragmentsize
fragment size
fragment size (TLEN)
Default: 600
-h, --help
print help and exit
Expand Down Expand Up @@ -45,6 +45,12 @@ Usage: vcf2bam [options] Files
* bam



## See also in Biostars

* [https://www.biostars.org/p/420363](https://www.biostars.org/p/420363)


## Compilation

### Requirements / Dependencies
Expand All @@ -62,6 +68,11 @@ $ ./gradlew vcf2bam

The java jar file will be installed in the `dist` directory.


## Creation Date

20150612

## Source code

[https://github.com/lindenb/jvarkit/tree/master/src/main/java/com/github/lindenb/jvarkit/tools/misc/VcfToBam.java](https://github.com/lindenb/jvarkit/tree/master/src/main/java/com/github/lindenb/jvarkit/tools/misc/VcfToBam.java)
Expand All @@ -88,6 +99,14 @@ The current reference is:
> [http://dx.doi.org/10.6084/m9.figshare.1425030](http://dx.doi.org/10.6084/m9.figshare.1425030)

## Warning

> converting a bcf to a bam is like creating a cow from a steak.
VCF input must be sorted in the same order than the REF sequence.

VCF input must contain some genotypes.

##Example

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ of this software and associated documentation files (the "Software"), to deal
*/
package com.github.lindenb.jvarkit.tools.misc;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParametersDelegate;
import com.github.lindenb.jvarkit.lang.JvarkitException;
import com.github.lindenb.jvarkit.util.jcommander.Launcher;
import com.github.lindenb.jvarkit.util.jcommander.Program;
import com.github.lindenb.jvarkit.util.log.Logger;
import com.github.lindenb.jvarkit.util.log.ProgressFactory;
import com.github.lindenb.jvarkit.util.vcf.VcfTools;
import com.github.lindenb.jvarkit.variant.variantcontext.writer.WritingVariantsDelegate;

import htsjdk.variant.variantcontext.Allele;
import htsjdk.variant.variantcontext.VariantContext;
Expand Down Expand Up @@ -81,12 +83,13 @@ this tool removes unused annotations from SNPEFF(ANN=) and VEP.
public class VcfRemoveUnusedAlt extends Launcher {
private static final Logger LOG=Logger.build(VcfRemoveUnusedAlt.class).make();
@Parameter(names={"-o","--out"},description=OPT_OUPUT_FILE_OR_STDOUT,required=false)
private File output=null;
private Path output=null;
@Parameter(names={"-onespan","--onespan"},description="Don't print the variant if the only remaining allele is '"+Allele.SPAN_DEL_STRING+"'")
private boolean no_span_allele =false;
@Parameter(names={"-neverspan","--neverspan"},description="Remove ALL spanning deletions '"+Allele.SPAN_DEL_STRING+"'. VCF must have no genotype.")
private boolean never_span_allele =false;

@ParametersDelegate
private WritingVariantsDelegate writingVariantsDelegate =new WritingVariantsDelegate();

public VcfRemoveUnusedAlt()
{
Expand Down Expand Up @@ -252,7 +255,7 @@ else if(vcfInfoHeaderLine.getCountType()==VCFHeaderLineCount.A)
LOG.info("number of changes "+ nChanges);
return 0;
}
catch(final Exception err)
catch(final Throwable err)
{
LOG.error(err);
return -1;
Expand All @@ -261,7 +264,7 @@ else if(vcfInfoHeaderLine.getCountType()==VCFHeaderLineCount.A)

@Override
public int doWork(final List<String> args) {
return doVcfToVcf(args,this.output);
return doVcfToVcfPath(args,this.writingVariantsDelegate,this.output);
}

public static void main(final String[] args)
Expand Down
35 changes: 23 additions & 12 deletions src/main/java/com/github/lindenb/jvarkit/tools/misc/VcfToBam.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ of this software and associated documentation files (the "Software"), to deal

import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParametersDelegate;
import com.github.lindenb.jvarkit.util.JVarkitVersion;
import com.github.lindenb.jvarkit.util.jcommander.Launcher;
import com.github.lindenb.jvarkit.util.jcommander.Program;
import com.github.lindenb.jvarkit.util.log.Logger;
Expand All @@ -62,6 +63,14 @@ of this software and associated documentation files (the "Software"), to deal
BEGIN_DOC
## Warning
> converting a bcf to a bam is like creating a cow from a steak.
VCF input must be sorted in the same order than the REF sequence.
VCF input must contain some genotypes.
##Example
```bash
Expand Down Expand Up @@ -101,32 +110,31 @@ of this software and associated documentation files (the "Software"), to deal
name="vcf2bam",
description="vcf to bam",
keywords={"ref","vcf","bam"},
modificationDate="20190926"
creationDate="20150612",
modificationDate="20200205",
biostars=420363
)
public class VcfToBam extends Launcher
{
private static final Logger LOG=Logger.build(VcfToBam.class).make();

@Parameter(names={"-o","--output"},description=OPT_OUPUT_FILE_OR_STDOUT)
private Path outputFile=null;

@Parameter(names={"-r","-R","--reference"},description=INDEXED_FASTA_REFERENCE_DESCRIPTION,required=true)
private Path faidx=null;

@ParametersDelegate
private WritingBamArgs writingBamArgs=new WritingBamArgs();

private ReferenceSequenceFile indexedFastaSequenceFile;
@Parameter(names="--fragmentsize",description="fragment size")
@Parameter(names="--fragmentsize",description="fragment size (TLEN)")
private int fragmentSize=600;
@Parameter(names="--readsize",description="read size")
private int readSize=100;


private ReferenceSequenceFile indexedFastaSequenceFile;




private void run(VCFIterator vcfIterator) throws IOException
private void run(final VCFIterator vcfIterator) throws IOException
{
long id_generator=0L;
SAMFileWriter samFileWriter =null;
Expand All @@ -142,16 +150,19 @@ private void run(VCFIterator vcfIterator) throws IOException
}
final SAMFileHeader samHeader=new SAMFileHeader();
samHeader.setSequenceDictionary(dict);
if(!header.hasGenotypingData()) {
throw new IOException("vcf doesn't have any genotypes");
}
for(final String sample:new TreeSet<>(header.getSampleNamesInOrder()))
{
final SAMReadGroupRecord rg= new SAMReadGroupRecord(sample);
rg.setSample(sample);
rg.setLibrary(sample);
rg.setDescription(sample);
rg.setLibrary("illumina");
rg.setPlatform("illumina");
samHeader.addReadGroup(rg);
}
samHeader.addComment("Generated with "+getProgramCommandLine());
JVarkitVersion.getInstance().addMetaData(this, samHeader);
samHeader.setSortOrder(SortOrder.unsorted);
samFileWriter= this.writingBamArgs.
setReferencePath(this.faidx).
Expand Down Expand Up @@ -405,7 +416,7 @@ public int doWork(final List<String> args)
run(iter);
return 0;
}
catch(final Exception err)
catch(final Throwable err)
{
LOG.error(err);
return -1;
Expand All @@ -418,7 +429,7 @@ public int doWork(final List<String> args)



public static void main(String[] args)
public static void main(final String[] args)
{
new VcfToBam().instanceMainWithExit(args);
}
Expand Down

0 comments on commit 583b6f4

Please sign in to comment.