Merge branch 'master' of ssh://nickel.broadinstitute.org/humgen/gsa-scr1/gsa-engineering/git/unstable
This commit is contained in:
commit
5c38a9cfd6
|
|
@ -222,8 +222,33 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> implements Ann
|
||||||
if ( isUniqueHeaderLine(line, hInfo) )
|
if ( isUniqueHeaderLine(line, hInfo) )
|
||||||
hInfo.add(line);
|
hInfo.add(line);
|
||||||
}
|
}
|
||||||
for ( String expression : expressionsToUse )
|
// for the expressions, pull the info header line from the header of the resource rod
|
||||||
hInfo.add(new VCFInfoHeaderLine(expression, VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, "Value transferred from another external VCF resource"));
|
for ( VariantAnnotatorEngine.VAExpression expression : engine.getRequestedExpressions() ) {
|
||||||
|
// special case the ID field
|
||||||
|
if ( expression.fieldName.equals("ID") ) {
|
||||||
|
hInfo.add(new VCFInfoHeaderLine(expression.fullName, 1, VCFHeaderLineType.String, "ID field transferred from external VCF resource"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
VCFInfoHeaderLine targetHeaderLine = null;
|
||||||
|
for ( VCFHeaderLine line : VCFUtils.getHeaderFields(getToolkit(), Arrays.asList(expression.binding.getName())) ) {
|
||||||
|
if ( line instanceof VCFInfoHeaderLine ) {
|
||||||
|
VCFInfoHeaderLine infoline = (VCFInfoHeaderLine)line;
|
||||||
|
if ( infoline.getName().equals(expression.fieldName) ) {
|
||||||
|
targetHeaderLine = infoline;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( targetHeaderLine != null ) {
|
||||||
|
if ( targetHeaderLine.getCountType() == VCFHeaderLineCount.INTEGER )
|
||||||
|
hInfo.add(new VCFInfoHeaderLine(expression.fullName, targetHeaderLine.getCount(), targetHeaderLine.getType(), targetHeaderLine.getDescription()));
|
||||||
|
else
|
||||||
|
hInfo.add(new VCFInfoHeaderLine(expression.fullName, targetHeaderLine.getCountType(), targetHeaderLine.getType(), targetHeaderLine.getDescription()));
|
||||||
|
} else {
|
||||||
|
hInfo.add(new VCFInfoHeaderLine(expression.fullName, VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, "Value transferred from another external VCF resource"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
engine.invokeAnnotationInitializationMethods(hInfo);
|
engine.invokeAnnotationInitializationMethods(hInfo);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,20 +49,20 @@ public class VariantAnnotatorEngine {
|
||||||
private AnnotatorCompatibleWalker walker;
|
private AnnotatorCompatibleWalker walker;
|
||||||
private GenomeAnalysisEngine toolkit;
|
private GenomeAnalysisEngine toolkit;
|
||||||
|
|
||||||
private static class VAExpression {
|
protected static class VAExpression {
|
||||||
|
|
||||||
public String fullName, fieldName;
|
public String fullName, fieldName;
|
||||||
public RodBinding<VariantContext> binding;
|
public RodBinding<VariantContext> binding;
|
||||||
|
|
||||||
public VAExpression(String fullEpression, List<RodBinding<VariantContext>> bindings) {
|
public VAExpression(String fullExpression, List<RodBinding<VariantContext>> bindings) {
|
||||||
int indexOfDot = fullEpression.lastIndexOf(".");
|
int indexOfDot = fullExpression.lastIndexOf(".");
|
||||||
if ( indexOfDot == -1 )
|
if ( indexOfDot == -1 )
|
||||||
throw new UserException.BadArgumentValue(fullEpression, "it should be in rodname.value format");
|
throw new UserException.BadArgumentValue(fullExpression, "it should be in rodname.value format");
|
||||||
|
|
||||||
fullName = fullEpression;
|
fullName = fullExpression;
|
||||||
fieldName = fullEpression.substring(indexOfDot+1);
|
fieldName = fullExpression.substring(indexOfDot+1);
|
||||||
|
|
||||||
String bindingName = fullEpression.substring(0, indexOfDot);
|
String bindingName = fullExpression.substring(0, indexOfDot);
|
||||||
for ( RodBinding<VariantContext> rod : bindings ) {
|
for ( RodBinding<VariantContext> rod : bindings ) {
|
||||||
if ( rod.getName().equals(bindingName) ) {
|
if ( rod.getName().equals(bindingName) ) {
|
||||||
binding = rod;
|
binding = rod;
|
||||||
|
|
@ -97,6 +97,8 @@ public class VariantAnnotatorEngine {
|
||||||
requestedExpressions.add(new VAExpression(expression, walker.getResourceRodBindings()));
|
requestedExpressions.add(new VAExpression(expression, walker.getResourceRodBindings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<VAExpression> getRequestedExpressions() { return requestedExpressions; }
|
||||||
|
|
||||||
private void initializeAnnotations(List<String> annotationGroupsToUse, List<String> annotationsToUse, List<String> annotationsToExclude) {
|
private void initializeAnnotations(List<String> annotationGroupsToUse, List<String> annotationsToUse, List<String> annotationsToExclude) {
|
||||||
AnnotationInterfaceManager.validateAnnotations(annotationGroupsToUse, annotationsToUse);
|
AnnotationInterfaceManager.validateAnnotations(annotationGroupsToUse, annotationsToUse);
|
||||||
requestedInfoAnnotations = AnnotationInterfaceManager.createInfoFieldAnnotations(annotationGroupsToUse, annotationsToUse);
|
requestedInfoAnnotations = AnnotationInterfaceManager.createInfoFieldAnnotations(annotationGroupsToUse, annotationsToUse);
|
||||||
|
|
@ -211,8 +213,13 @@ public class VariantAnnotatorEngine {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
VariantContext vc = VCs.iterator().next();
|
VariantContext vc = VCs.iterator().next();
|
||||||
if ( vc.hasAttribute(expression.fieldName) )
|
// special-case the ID field
|
||||||
|
if ( expression.fieldName.equals("ID") ) {
|
||||||
|
if ( vc.hasID() )
|
||||||
|
infoAnnotations.put(expression.fullName, vc.getID());
|
||||||
|
} else if ( vc.hasAttribute(expression.fieldName) ) {
|
||||||
infoAnnotations.put(expression.fullName, vc.getAttribute(expression.fieldName));
|
infoAnnotations.put(expression.fullName, vc.getAttribute(expression.fieldName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
||||||
public void testUsingExpressionWithID() {
|
public void testUsingExpressionWithID() {
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(
|
WalkerTestSpec spec = new WalkerTestSpec(
|
||||||
baseTestString() + " --resource:foo " + validationDataLocation + "targetAnnotations.vcf -G Standard --variant:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -E foo.ID -L " + validationDataLocation + "vcfexample3empty.vcf", 1,
|
baseTestString() + " --resource:foo " + validationDataLocation + "targetAnnotations.vcf -G Standard --variant:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -E foo.ID -L " + validationDataLocation + "vcfexample3empty.vcf", 1,
|
||||||
Arrays.asList("4a6f0675242f685e9072c1da5ad9e715"));
|
Arrays.asList("1b4921085b26cbfe07d53b7c947de1e5"));
|
||||||
executeTest("using expression with ID", spec);
|
executeTest("using expression with ID", spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue