Removing version argument constructors that shouldn't be used. Temporary allow -- with global variant to indicate this should be removed -- header records without description fields. Real error checking in the headers.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3818 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
14b21e487b
commit
414ec6f20a
|
|
@ -39,7 +39,6 @@ public abstract class VCFCompoundHeaderLine extends VCFHeaderLine implements VCF
|
||||||
SupportedHeaderLineType(boolean flagValues) {
|
SupportedHeaderLineType(boolean flagValues) {
|
||||||
allowFlagValues = flagValues;
|
allowFlagValues = flagValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// the field types
|
// the field types
|
||||||
|
|
@ -79,15 +78,7 @@ public abstract class VCFCompoundHeaderLine extends VCFHeaderLine implements VCF
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.lineType = lineType;
|
this.lineType = lineType;
|
||||||
}
|
validate();
|
||||||
|
|
||||||
protected VCFCompoundHeaderLine(String name, int count, VCFHeaderLineType type, String description, SupportedHeaderLineType lineType, VCFHeaderVersion version) {
|
|
||||||
super(lineType.toString(), "");
|
|
||||||
this.name = name;
|
|
||||||
this.count = count;
|
|
||||||
this.type = type;
|
|
||||||
this.description = description;
|
|
||||||
this.lineType = lineType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -107,8 +98,20 @@ public abstract class VCFCompoundHeaderLine extends VCFHeaderLine implements VCF
|
||||||
type = VCFHeaderLineType.valueOf(mapping.get("Type"));
|
type = VCFHeaderLineType.valueOf(mapping.get("Type"));
|
||||||
if (type == VCFHeaderLineType.Flag && !allowFlagValues())
|
if (type == VCFHeaderLineType.Flag && !allowFlagValues())
|
||||||
throw new IllegalArgumentException("Flag is an unsupported type for this kind of field");
|
throw new IllegalArgumentException("Flag is an unsupported type for this kind of field");
|
||||||
|
|
||||||
description = mapping.get("Description");
|
description = mapping.get("Description");
|
||||||
|
if ( description == null && ALLOW_UNBOUND_DESCRIPTIONS ) // handle the case where there's no description provided
|
||||||
|
description = UNBOUND_DESCRIPTION;
|
||||||
|
|
||||||
this.lineType = lineType;
|
this.lineType = lineType;
|
||||||
|
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validate() {
|
||||||
|
if ( name == null || type == null || description == null || lineType == null )
|
||||||
|
throw new IllegalArgumentException(String.format("Invalid VCFCompoundHeaderLine: key=%s name=%s type=%s desc=%s lineType=%s",
|
||||||
|
super.getKey(), name, type, description, lineType ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ public class VCFFilterHeaderLine extends VCFHeaderLine implements VCFNamedHeader
|
||||||
super("FILTER", "");
|
super("FILTER", "");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|
||||||
|
if ( name == null || description == null )
|
||||||
|
throw new IllegalArgumentException(String.format("Invalid VCFCompoundHeaderLine: key=%s name=%s desc=%s", super.getKey(), name, description ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -38,6 +41,8 @@ public class VCFFilterHeaderLine extends VCFHeaderLine implements VCFNamedHeader
|
||||||
Map<String,String> mapping = VCFHeaderLineTranslator.parseLine(version,line, Arrays.asList("ID","Description"));
|
Map<String,String> mapping = VCFHeaderLineTranslator.parseLine(version,line, Arrays.asList("ID","Description"));
|
||||||
name = mapping.get("ID");
|
name = mapping.get("ID");
|
||||||
description = mapping.get("Description");
|
description = mapping.get("Description");
|
||||||
|
if ( description == null && ALLOW_UNBOUND_DESCRIPTIONS ) // handle the case where there's no description provided
|
||||||
|
description = UNBOUND_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String toStringEncoding() {
|
protected String toStringEncoding() {
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,9 @@ import java.util.Map;
|
||||||
* A class representing a key=value entry in the VCF header
|
* A class representing a key=value entry in the VCF header
|
||||||
*/
|
*/
|
||||||
public class VCFHeaderLine implements Comparable {
|
public class VCFHeaderLine implements Comparable {
|
||||||
|
protected static boolean ALLOW_UNBOUND_DESCRIPTIONS = true;
|
||||||
|
protected static String UNBOUND_DESCRIPTION = "Not provided in original VCF header";
|
||||||
|
|
||||||
private String stringRep = null;
|
|
||||||
private String mKey = null;
|
private String mKey = null;
|
||||||
private String mValue = null;
|
private String mValue = null;
|
||||||
|
|
||||||
|
|
@ -51,6 +52,8 @@ public class VCFHeaderLine implements Comparable {
|
||||||
* @param value the value for this header line
|
* @param value the value for this header line
|
||||||
*/
|
*/
|
||||||
public VCFHeaderLine(String key, String value) {
|
public VCFHeaderLine(String key, String value) {
|
||||||
|
if ( key == null )
|
||||||
|
throw new IllegalArgumentException("VCFHeaderLine: key cannot be null: key = " + key);
|
||||||
mKey = key;
|
mKey = key;
|
||||||
mValue = value;
|
mValue = value;
|
||||||
}
|
}
|
||||||
|
|
@ -64,16 +67,6 @@ public class VCFHeaderLine implements Comparable {
|
||||||
return mKey;
|
return mKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the key
|
|
||||||
*
|
|
||||||
* @param key the key for this header line
|
|
||||||
*/
|
|
||||||
public void setKey(String key) {
|
|
||||||
mKey = key;
|
|
||||||
stringRep = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value
|
* Get the value
|
||||||
*
|
*
|
||||||
|
|
@ -83,22 +76,15 @@ public class VCFHeaderLine implements Comparable {
|
||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value
|
|
||||||
*
|
|
||||||
* @param value the value for this header line
|
|
||||||
*/
|
|
||||||
public void setValue(String value) {
|
|
||||||
mValue = value;
|
|
||||||
stringRep = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if ( stringRep == null )
|
return toStringEncoding();
|
||||||
stringRep = toStringEncoding();
|
|
||||||
return stringRep;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should be overloaded in sub classes to do subclass specific
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
protected String toStringEncoding() {
|
protected String toStringEncoding() {
|
||||||
return mKey + "=" + mValue;
|
return mKey + "=" + mValue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,6 @@ package org.broad.tribble.vcf;
|
||||||
* A class representing a key=value entry for INFO fields in the VCF header
|
* A class representing a key=value entry for INFO fields in the VCF header
|
||||||
*/
|
*/
|
||||||
public class VCFInfoHeaderLine extends VCFCompoundHeaderLine {
|
public class VCFInfoHeaderLine extends VCFCompoundHeaderLine {
|
||||||
|
|
||||||
public VCFInfoHeaderLine(String name, int count, VCFHeaderLineType type, String description, VCFHeaderVersion version) {
|
|
||||||
super(name, count, type, description, SupportedHeaderLineType.INFO, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VCFInfoHeaderLine(String name, int count, VCFHeaderLineType type, String description) {
|
public VCFInfoHeaderLine(String name, int count, VCFHeaderLineType type, String description) {
|
||||||
super(name, count, type, description, SupportedHeaderLineType.INFO);
|
super(name, count, type, description, SupportedHeaderLineType.INFO);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue