-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ah - use new GT encoding #6822
Merged
Merged
ah - use new GT encoding #6822
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 30 additions & 8 deletions
38
src/main/java/org/broadinstitute/hellbender/tools/variantdb/CommonCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
...in/java/org/broadinstitute/hellbender/tools/variantdb/arrays/ArrayMetadataTsvCreator.java
This file was deleted.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
src/main/java/org/broadinstitute/hellbender/tools/variantdb/arrays/ArraySampleFieldEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package org.broadinstitute.hellbender.tools.variantdb.arrays; | ||
|
||
import htsjdk.variant.variantcontext.VariantContext; | ||
import org.broadinstitute.hellbender.tools.variantdb.CommonCode; | ||
import org.broadinstitute.hellbender.tools.variantdb.arrays.tables.ProbeInfo; | ||
|
||
import java.util.*; | ||
|
||
|
||
|
||
public enum ArraySampleFieldEnum { | ||
sample_id, | ||
sample_name, | ||
|
||
|
||
// This where the validation step (required vs not) lives -- fail if there is missing data for a required field | ||
// and just leave it empty if not required | ||
|
||
NUM_ASSAYS { | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_NON_FILTERED_ASSAYS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_FILTERED_ASSAYS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_ZEROED_OUT_ASSAYS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_SNPS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_INDELS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_CALLS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_AUTOCALL_CALLS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_NO_CALLS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_IN_DB_SNP{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NOVEL_SNPS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
|
||
PCT_DBSNP{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
CALL_RATE{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
AUTOCALL_CALL_RATE{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}, | ||
NUM_SINGLETONS{ | ||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
return metricsMap.get(this.name()); | ||
} | ||
}; | ||
|
||
public String getColumnValue(final Map<String, String> metricsMap) { | ||
throw new IllegalArgumentException("Not implemented"); | ||
} | ||
|
||
} |
110 changes: 110 additions & 0 deletions
110
...main/java/org/broadinstitute/hellbender/tools/variantdb/arrays/ArraySampleTsvCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package org.broadinstitute.hellbender.tools.variantdb.arrays; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.broadinstitute.hellbender.exceptions.UserException; | ||
import org.broadinstitute.hellbender.tools.variantdb.IngestConstants; | ||
import org.broadinstitute.hellbender.utils.tsv.SimpleXSVWriter; | ||
|
||
import java.io.*; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
public class ArraySampleTsvCreator { | ||
|
||
private static final Logger logger = LogManager.getLogger(ArraySampleTsvCreator.class); | ||
|
||
private SimpleXSVWriter sampleMetadataWriter = null; | ||
private Map<String, String> metricsMap; | ||
|
||
|
||
public ArraySampleTsvCreator(String metricsFilepath) { | ||
if (metricsFilepath != null && !metricsFilepath.isEmpty()) { | ||
BufferedReader reader = null; | ||
try { | ||
String columns = null; | ||
String values = null; | ||
reader = new BufferedReader(new FileReader(metricsFilepath)); | ||
String line = reader.readLine(); | ||
while (line != null) { | ||
if (!line.startsWith("#") && !line.trim().isEmpty()) { | ||
if (columns == null) { | ||
columns = line; | ||
} else if (values == null) { | ||
values = line; | ||
} else { | ||
// there are more lines than expected - output a warning | ||
logger.warn("more lines than expected in metrics file: " + line); | ||
} | ||
} | ||
line = reader.readLine(); | ||
} | ||
|
||
List<String> colList = Arrays.asList(columns.split("\t")); | ||
List<String> valList = Arrays.asList(values.split("\t")); | ||
metricsMap = IntStream.range(0, colList.size()).boxed().collect(Collectors.toMap(colList::get, valList::get)); | ||
|
||
} catch (IOException e) { | ||
throw new RuntimeException("could not read metrics file", e); | ||
} | ||
} | ||
} | ||
|
||
public static List<String> getHeaders() { | ||
return Arrays.stream(ArraySampleFieldEnum.values()).map(String::valueOf).collect(Collectors.toList()); | ||
} | ||
|
||
public void createRow(String sampleName, String sampleId, String tableNumberPrefix, File outputDirectory) { | ||
// if the metadata tsvs don't exist yet -- create them | ||
try { | ||
// Create a metadata file to go into the metadata dir for _this_ sample | ||
// TODO--this should just be one file per sample set? | ||
final File sampleMetadataFileName = new File (outputDirectory, IngestConstants.sampleMetadataFilePrefix + tableNumberPrefix + sampleName + IngestConstants.FILETYPE); | ||
// write header to it | ||
List<String> sampleListHeader = ArraySampleTsvCreator.getHeaders(); | ||
sampleMetadataWriter = new SimpleXSVWriter(sampleMetadataFileName.toPath(), IngestConstants.SEPARATOR); | ||
sampleMetadataWriter.setHeaderLine(sampleListHeader); | ||
|
||
final List<String> TSVLineToCreateSampleMetadata = createSampleListRow( | ||
sampleName, | ||
sampleId); | ||
sampleMetadataWriter.getNewLineBuilder().setRow(TSVLineToCreateSampleMetadata).write(); | ||
|
||
} catch (final IOException e) { | ||
throw new UserException("Could not create sample outputs", e); | ||
} | ||
|
||
} | ||
|
||
private List<String> createSampleListRow(String sampleName, String sampleId) { | ||
List<String> row = new ArrayList<>(); | ||
row.add(sampleName); | ||
row.add(sampleId); | ||
|
||
for (final ArraySampleFieldEnum fieldEnum : ArraySampleFieldEnum.values()) { | ||
if (fieldEnum != ArraySampleFieldEnum.sample_id && fieldEnum != ArraySampleFieldEnum.sample_name) { | ||
if (metricsMap == null) { | ||
row.add("null"); | ||
} else { | ||
row.add(fieldEnum.getColumnValue(metricsMap)); | ||
} | ||
} | ||
} | ||
return row; | ||
} | ||
|
||
public void closeTool() { | ||
if (sampleMetadataWriter != null) { | ||
try { | ||
sampleMetadataWriter.close(); | ||
} catch (final Exception e) { | ||
throw new IllegalArgumentException("Couldn't close array sample writer", e); | ||
} | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm so surprised this code doesn't exist anywhere? the VCFWriter must be doing (largely) the same thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but it is very embedded in the actual writing of the output and in htsjdk which for some reason i think it's more difficult for us to modify to make it modular.