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:
depristo 2010-07-17 22:30:08 +00:00
parent 14b21e487b
commit 414ec6f20a
4 changed files with 28 additions and 39 deletions

View File

@ -39,7 +39,6 @@ public abstract class VCFCompoundHeaderLine extends VCFHeaderLine implements VCF
SupportedHeaderLineType(boolean flagValues) {
allowFlagValues = flagValues;
}
}
// the field types
@ -79,15 +78,7 @@ public abstract class VCFCompoundHeaderLine extends VCFHeaderLine implements VCF
this.type = type;
this.description = description;
this.lineType = lineType;
}
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;
validate();
}
/**
@ -107,8 +98,20 @@ public abstract class VCFCompoundHeaderLine extends VCFHeaderLine implements VCF
type = VCFHeaderLineType.valueOf(mapping.get("Type"));
if (type == VCFHeaderLineType.Flag && !allowFlagValues())
throw new IllegalArgumentException("Flag is an unsupported type for this kind of field");
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;
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 ));
}
/**

View File

@ -25,6 +25,9 @@ public class VCFFilterHeaderLine extends VCFHeaderLine implements VCFNamedHeader
super("FILTER", "");
this.name = name;
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"));
name = mapping.get("ID");
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() {

View File

@ -38,8 +38,9 @@ import java.util.Map;
* A class representing a key=value entry in the VCF header
*/
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 mValue = null;
@ -51,6 +52,8 @@ public class VCFHeaderLine implements Comparable {
* @param value the value for this header line
*/
public VCFHeaderLine(String key, String value) {
if ( key == null )
throw new IllegalArgumentException("VCFHeaderLine: key cannot be null: key = " + key);
mKey = key;
mValue = value;
}
@ -64,16 +67,6 @@ public class VCFHeaderLine implements Comparable {
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
*
@ -83,22 +76,15 @@ public class VCFHeaderLine implements Comparable {
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() {
if ( stringRep == null )
stringRep = toStringEncoding();
return stringRep;
return toStringEncoding();
}
/**
* Should be overloaded in sub classes to do subclass specific
*
* @return
*/
protected String toStringEncoding() {
return mKey + "=" + mValue;
}

View File

@ -9,11 +9,6 @@ package org.broad.tribble.vcf;
* A class representing a key=value entry for INFO fields in the VCF header
*/
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) {
super(name, count, type, description, SupportedHeaderLineType.INFO);
}