Skip to content

Commit

Permalink
Write base quality to VCF
Browse files Browse the repository at this point in the history
  • Loading branch information
seppinho committed Mar 3, 2024
1 parent e08a03b commit b465d3b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/genepi/mut/objects/Variant.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Variant {
private double minorLevel;
private int coverage;
private int type;
private double meanBaseQualiy;

public int getPos() {
return pos;
Expand Down Expand Up @@ -117,4 +118,12 @@ public Filter getFilter() {
public void setFilter(Filter filter) {
this.filter = filter;
}

public double getMeanBaseQualiy() {
return meanBaseQualiy;
}

public void setMeanBaseQualiy(double meanBaseQualiy) {
this.meanBaseQualiy = meanBaseQualiy;
}
}
5 changes: 5 additions & 0 deletions src/main/java/genepi/mut/pileup/VcfWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void createVCF(String in, String out, String reference, String chromosome
final GenotypeBuilder gb = new GenotypeBuilder(sample.getId(), Arrays.asList(varAllele));
gb.DP(variant.getCoverage());
gb.attribute("AF", variant.getLevel());
gb.attribute("BQ", variant.getMeanBaseQualiy());

genotypes.add(gb.make());

Expand Down Expand Up @@ -197,6 +198,7 @@ public void createVCF(String in, String out, String reference, String chromosome
}

gb.attribute("AF", alleleFreq);
gb.attribute("BQ", variant.getMeanBaseQualiy());

genotypes.add(gb.make());

Expand Down Expand Up @@ -239,6 +241,9 @@ private VCFHeader generateHeader(String chromosome, int length, String command)
header.addMetaDataLine(new VCFFormatHeaderLine("AF", 1, VCFHeaderLineType.String,
"Inferred Allele Frequency of top (non-reference) allele"));

header.addMetaDataLine(new VCFFormatHeaderLine("BQ", 1, VCFHeaderLineType.String,
"Mean Base Quality of ALT Allele"));

header.addMetaDataLine(new VCFFormatHeaderLine("DP", 1, VCFHeaderLineType.Integer, "Read Depth"));

return header;
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/genepi/mut/util/MutationServerReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public HashMap<String, Sample> parse(double requiredHetLevel) {

double majorLevel = 0;
double minorLevel = 0;
double meanBaseQuality = 0;
int coverage = -1;
int pos;

Expand Down Expand Up @@ -72,6 +73,10 @@ public HashMap<String, Sample> parse(double requiredHetLevel) {
if (reader.hasColumn("Coverage")) {
coverage = reader.getInteger("Coverage");
}

if (reader.hasColumn("MeanBaseQuality")) {
meanBaseQuality = Double.valueOf(reader.getString("MeanBaseQuality"));
}

sample.setId(id);

Expand All @@ -88,7 +93,7 @@ public HashMap<String, Sample> parse(double requiredHetLevel) {
variant.setMinor(minor);
variant.setMajorLevel(majorLevel);
variant.setMinorLevel(minorLevel);
variant.setCoverage(coverage);
variant.setMeanBaseQualiy(meanBaseQuality);
variant.setType(type);

sample.addVariant(variant);
Expand Down

0 comments on commit b465d3b

Please sign in to comment.