Search in sources :

Example 1 with GenotypeDataException

use of org.molgenis.genotype.GenotypeDataException in project molgenis by molgenis.

the class VcfToEntity method vcfReaderFormatToMolgenisType.

private static AttributeType vcfReaderFormatToMolgenisType(VcfMetaInfo vcfMetaInfo) {
    String number = vcfMetaInfo.getNumber();
    boolean isListValue;
    try {
        isListValue = number.equals("A") || number.equals("R") || number.equals("G") || number.equals(".") || Integer.parseInt(number) > 1;
    } catch (NumberFormatException ex) {
        throw new GenotypeDataException("Error parsing length of vcf info field. " + number + " is not a valid int or expected preset (A, R, G, .)", ex);
    }
    switch(vcfMetaInfo.getType()) {
        case CHARACTER:
            if (isListValue) {
                // TODO support list of primitives datatype
                return STRING;
            }
            return STRING;
        case FLAG:
            return BOOL;
        case FLOAT:
            if (isListValue) {
                // TODO support list of primitives datatype
                return STRING;
            }
            return DECIMAL;
        case INTEGER:
            if (isListValue) {
                // TODO support list of primitives datatype
                return STRING;
            }
            return INT;
        case STRING:
            if (isListValue) {
                // TODO support list of primitives datatype
                return TEXT;
            }
            return TEXT;
        default:
            throw new UnexpectedEnumException(vcfMetaInfo.getType());
    }
}
Also used : UnexpectedEnumException(org.molgenis.util.UnexpectedEnumException) GenotypeDataException(org.molgenis.genotype.GenotypeDataException)

Example 2 with GenotypeDataException

use of org.molgenis.genotype.GenotypeDataException in project molgenis by molgenis.

the class VcfToEntity method vcfFieldTypeToMolgenisFieldType.

private static AttributeType vcfFieldTypeToMolgenisFieldType(VcfMetaFormat format) {
    String number = format.getNumber();
    boolean isListValue;
    try {
        isListValue = number.equals("A") || number.equals("R") || number.equals("G") || number.equals(".") || Integer.parseInt(number) > 1;
    } catch (NumberFormatException ex) {
        throw new GenotypeDataException("Error parsing length of vcf info field. " + number + " is not a valid int or expected preset (A, R, G, .)", ex);
    }
    switch(format.getType()) {
        case CHARACTER:
            if (isListValue) {
                // TODO support list of primitives datatype
                return STRING;
            }
            return STRING;
        case FLOAT:
            if (isListValue) {
                // TODO support list of primitives datatype
                return STRING;
            }
            return DECIMAL;
        case INTEGER:
            if (isListValue) {
                // TODO support list of primitives datatype
                return STRING;
            }
            return INT;
        case STRING:
            if (isListValue) {
                // TODO support list of primitives datatype
                return STRING;
            }
            return STRING;
        default:
            throw new UnexpectedEnumException(format.getType());
    }
}
Also used : UnexpectedEnumException(org.molgenis.util.UnexpectedEnumException) GenotypeDataException(org.molgenis.genotype.GenotypeDataException)

Aggregations

GenotypeDataException (org.molgenis.genotype.GenotypeDataException)2 UnexpectedEnumException (org.molgenis.util.UnexpectedEnumException)2