Skip to content

Commit

Permalink
variants --> variant, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
heuermh committed Sep 23, 2019
2 parents 14d0223 + 1c20d01 commit 3423c71
Show file tree
Hide file tree
Showing 17 changed files with 408 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: java
jdk:
- oraclejdk8
- openjdk8
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# convert Changelog #

### Version 0.8.0 ###

**Closed issues:**

- Bump bdg-formats dependency version to 0.14.0 [\#74](https://github.com/bigdatagenomics/convert/issues/74)

**Merged and closed pull requests:**

- [CONVERT-74] Bump bdg-formats dependency version to 0.14.0 [\#75](https://github.com/bigdatagenomics/convert/pull/75) ([heuermh](https://github.com/heuermh))


### Version 0.6.0 ###

**Closed issues:**
Expand Down
2 changes: 1 addition & 1 deletion convert-ga4gh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.bdgenomics.convert</groupId>
<artifactId>convert-parent</artifactId>
<version>0.8.0-SNAPSHOT</version>
<version>0.9.0-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public ReadAlignment convert(final AlignmentRecord alignmentRecord,
builder.setNextMatePosition(matePosition);
}

if (isNotEmpty(alignmentRecord.getQuality())) {
List<Integer> alignedQuality = new ArrayList<Integer>(alignmentRecord.getQuality().length());
for (char c : alignmentRecord.getQuality().toCharArray()) {
if (isNotEmpty(alignmentRecord.getQualityScores())) {
List<Integer> alignedQuality = new ArrayList<Integer>(alignmentRecord.getQualityScores().length());
for (char c : alignmentRecord.getQualityScores().toCharArray()) {
alignedQuality.add(((int) c) - 33);
}
builder.addAllAlignedQuality(alignedQuality);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void setUp() {
.setReadMapped(true)
.setCigar("10M")
.setSequence("AAAAAAAAAA")
.setQuality("**********")
.setQualityScores("**********")
.setReadNegativeStrand(false)
.setMappingQuality(60)
.setMismatchingPositions("10")
Expand Down Expand Up @@ -147,7 +147,7 @@ public void testConvertNoMapq() {
.setReadMapped(true)
.setCigar("10M")
.setSequence("AAAAAAAAAA")
.setQuality("**********")
.setQualityScores("**********")
.setReadNegativeStrand(false)
.setMismatchingPositions("10")
.setOriginalStart(12L)
Expand Down
2 changes: 1 addition & 1 deletion convert-htsjdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.bdgenomics.convert</groupId>
<artifactId>convert-parent</artifactId>
<version>0.8.0-SNAPSHOT</version>
<version>0.9.0-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public SAMRecord convert(final AlignmentRecord alignmentRecord,
builder.setReadName(alignmentRecord.getReadName());
builder.setReadString(alignmentRecord.getSequence());

if (alignmentRecord.getQuality() == null) {
if (alignmentRecord.getQualityScores() == null) {
builder.setBaseQualityString("*");
}
else {
builder.setBaseQualityString(alignmentRecord.getQuality());
builder.setBaseQualityString(alignmentRecord.getQualityScores());
}

String readGroupId = alignmentRecord.getReadGroupId();
Expand Down Expand Up @@ -178,8 +178,8 @@ public SAMRecord convert(final AlignmentRecord alignmentRecord,
if (alignmentRecord.getMismatchingPositions() != null) {
builder.setAttribute("MD", alignmentRecord.getMismatchingPositions());
}
if (alignmentRecord.getOriginalQuality() != null) {
builder.setOriginalBaseQualities(SAMUtils.fastqToPhred(alignmentRecord.getOriginalQuality()));
if (alignmentRecord.getOriginalQualityScores() != null) {
builder.setOriginalBaseQualities(SAMUtils.fastqToPhred(alignmentRecord.getOriginalQualityScores()));
}
if (alignmentRecord.getOriginalCigar() != null) {
builder.setAttribute("OC", alignmentRecord.getOriginalCigar());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import htsjdk.variant.variantcontext.VariantContext;

import htsjdk.variant.vcf.VCFHeader;
import htsjdk.variant.vcf.VCFHeaderLine;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
Expand Down Expand Up @@ -63,8 +64,8 @@ protected void configure() {
.build(GenotypesToVariantContextFactory.class));

install(new FactoryModuleBuilder()
.implement(new TypeLiteral<Converter<List<Variant>, VariantContext>>() {}, VariantsToVariantContext.class)
.build(VariantsToVariantContextFactory.class));
.implement(new TypeLiteral<Converter<Variant, VariantContext>>() {}, VariantToVariantContext.class)
.build(VariantToVariantContextFactory.class));

install(new FactoryModuleBuilder()
.implement(new TypeLiteral<Converter<VariantContext, List<Genotype>>>() {}, VariantContextToGenotypes.class)
Expand Down Expand Up @@ -129,4 +130,9 @@ Converter<VCFHeader, List<Reference>> createVcfHeaderToReferences(final Converte
Converter<VCFHeader, List<Sample>> createVcfHeaderToSamples() {
return new VcfHeaderToSamples();
}

@Provides @Singleton
Converter<VCFHeader, List<VCFHeaderLine>> createVcfHeaderToVcfHeaderLines() {
return new VcfHeaderToVcfHeaderLines();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public AlignmentRecord convert(final SAMRecord samRecord,
}

if (samRecord.getBaseQualityString() != "*") {
builder.setQuality(samRecord.getBaseQualityString());
builder.setQualityScores(samRecord.getBaseQualityString());
}
if (samRecord.getOriginalBaseQualities() != null) {
builder.setOriginalQuality(SAMUtils.phredToFastq(samRecord.getOriginalBaseQualities()));
builder.setOriginalQualityScores(SAMUtils.phredToFastq(samRecord.getOriginalBaseQualities()));
}

int readReference = samRecord.getReferenceIndex();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Licensed to Big Data Genomics (BDG) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The BDG licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bdgenomics.convert.htsjdk;

import com.google.inject.Inject;

import com.google.inject.assistedinject.Assisted;

import htsjdk.variant.variantcontext.VariantContext;

import htsjdk.variant.vcf.VCFHeader;

import org.bdgenomics.convert.AbstractConverter;
import org.bdgenomics.convert.ConversionException;
import org.bdgenomics.convert.ConversionStringency;

import org.bdgenomics.formats.avro.Variant;

import org.slf4j.Logger;

/**
* Convert a Variant to a VariantContext.
*/
public final class VariantToVariantContext extends AbstractConverter<Variant, VariantContext> {

/** Header. */
private final VCFHeader header;


/**
* Create a new Variant to VariantContext converter with the specified header.
*
* @param header header, must not be null
*/
@Inject
public VariantToVariantContext(@Assisted final VCFHeader header) {
super(Variant.class, VariantContext.class);

checkNotNull(header);
this.header = header;
}


@Override
public VariantContext convert(final Variant variant,
final ConversionStringency stringency,
final Logger logger) throws ConversionException {

if (variant == null) {
warnOrThrow(variant, "must not be null", null, stringency, logger);
return null;
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Licensed to Big Data Genomics (BDG) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The BDG licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bdgenomics.convert.htsjdk;

import htsjdk.variant.variantcontext.VariantContext;

import htsjdk.variant.vcf.VCFHeader;

import org.bdgenomics.convert.Converter;

import org.bdgenomics.formats.avro.Variant;

/**
* Factory for creating Variant to VariantContext converters, which
* require late binding for a VCFHeader.
*/
public interface VariantToVariantContextFactory {

/**
* Create a new Variant to VariantContext converter with the specified header.
*
* @param header header, must not be null
*/
Converter<Variant, VariantContext> create(VCFHeader header);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Licensed to Big Data Genomics (BDG) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The BDG licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bdgenomics.convert.htsjdk;

import java.util.ArrayList;
import java.util.List;

import htsjdk.variant.vcf.VCFHeader;
import htsjdk.variant.vcf.VCFHeaderLine;

import org.bdgenomics.convert.AbstractConverter;
import org.bdgenomics.convert.ConversionException;
import org.bdgenomics.convert.ConversionStringency;

import org.slf4j.Logger;

/**
* Convert a VCFHeader to a list of VCFHeaderLines.
*/
public final class VcfHeaderToVcfHeaderLines extends AbstractConverter<VCFHeader, List<VCFHeaderLine>> {

/**
* Create a new VCFHeader to a list of VCFHeaderLines converter.
*/
public VcfHeaderToVcfHeaderLines() {
super(VCFHeader.class, VCFHeaderLine.class);
}


@Override
public List<VCFHeaderLine> convert(final VCFHeader header,
final ConversionStringency stringency,
final Logger logger) throws ConversionException {

if (header == null) {
warnOrThrow(header, "must not be null", null, stringency, logger);
return null;
}

List<VCFHeaderLine> headerLines = new ArrayList<VCFHeaderLine>();
headerLines.addAll(header.getFilterLines());
headerLines.addAll(header.getFormatHeaderLines());
headerLines.addAll(header.getInfoHeaderLines());
headerLines.addAll(header.getOtherHeaderLines());
return headerLines;
}
}
Loading

0 comments on commit 3423c71

Please sign in to comment.