/*
     * Normalize genomic location:
     *
     * 1. Convert VCF style start,end,ref,alt to MAF by looking for common
     * prefix. (TODO: not sure if this is always a good idea)
     * 2. Normalize chromsome names.
     */
public GenomicLocation normalizeGenomicLocation(GenomicLocation genomicLocation) {
        GenomicLocation normalizedGenomicLocation = new GenomicLocation();
        // if original input is set in the incoming genomic location object then use the same value
        // for the normalized genomic location object returned, otherwise set it to the
        // string representation of the incoming genomic location object
        if (genomicLocation.getOriginalInput() != null && !genomicLocation.getOriginalInput().isEmpty()) {
            normalizedGenomicLocation.setOriginalInput(genomicLocation.getOriginalInput());
        } else {
            normalizedGenomicLocation.setOriginalInput(genomicLocation.toString());
        }
        // normalize chromosome name
        String chr = chromosomeNormalizer(genomicLocation.getChromosome().trim());
        normalizedGenomicLocation.setChromosome(chr);
        // convert vcf style start,end,ref,alt to MAF style
        Integer start = genomicLocation.getStart();
        Integer end = genomicLocation.getEnd();
        String ref = genomicLocation.getReferenceAllele().trim();
        String var = genomicLocation.getVariantAllele().trim();
        String prefix = "";
        if (!ref.equals(var)) {
            prefix = longestCommonPrefix(ref, var);
        }
        // Remove common prefix and adjust variant position accordingly
        if (prefix.length() > 0) {
            ref = ref.substring(prefix.length());
            var = var.substring(prefix.length());
            int nStart = start + prefix.length();
            if (ref.length() == 0) {
                nStart -= 1;
            }
            start = nStart;
        }
        normalizedGenomicLocation.setStart(start);
        normalizedGenomicLocation.setEnd(end);
        normalizedGenomicLocation.setReferenceAllele(ref);
        normalizedGenomicLocation.setVariantAllele(var);
        return normalizedGenomicLocation;
    }
public GenomicLocation normalizeGenomicLocation(GenomicLocation genomicLocation) {
GenomicLocation normalizedGenomicLocation = new GenomicLocation();
// if original input is set in the incoming genomic location object then use the same value
// for the normalized genomic location object returned, otherwise set it to the
// string representation of the incoming genomic location object
if (genomicLocation.getOriginalInput() != null && !genomicLocation.getOriginalInput().isEmpty()) {
normalizedGenomicLocation.setOriginalInput(genomicLocation.getOriginalInput());
} else {
normalizedGenomicLocation.setOriginalInput(genomicLocation.toString());
}
// normalize chromosome name
String chr = chromosomeNormalizer(genomicLocation.getChromosome().trim());
normalizedGenomicLocation.setChromosome(chr);
// convert vcf style start,end,ref,alt to MAF style
Integer start = genomicLocation.getStart();
Integer end = genomicLocation.getEnd();
String ref = genomicLocation.getReferenceAllele().trim();
String var = genomicLocation.getVariantAllele().trim();
String prefix = "";
if (!ref.equals(var)) {
prefix = longestCommonPrefix(ref, var);
}
// Remove common prefix and adjust variant position accordingly
if (prefix.length() > 0) {
ref = ref.substring(prefix.length());
var = var.substring(prefix.length());
int nStart = start + prefix.length();
if (ref.length() == 0) {
nStart -= 1;
}
start = nStart;
}
normalizedGenomicLocation.setStart(start);
normalizedGenomicLocation.setEnd(end);
normalizedGenomicLocation.setReferenceAllele(ref);
normalizedGenomicLocation.setVariantAllele(var);
return normalizedGenomicLocation;
}
public GenomicLocation normalizeGenomicLocation(GenomicLocation genomicLocation) {
GenomicLocation normalizedGenomicLocation = new GenomicLocation();
// if original input is set in the incoming genomic location object then use the same value
// for the normalized genomic location object returned, otherwise set it to the
// string representation of the incoming genomic location object
if (genomicLocation.getOriginalInput() != null && !genomicLocation.getOriginalInput().isEmpty()) {
normalizedGenomicLocation.setOriginalInput(genomicLocation.getOriginalInput());
} else {
normalizedGenomicLocation.setOriginalInput(genomicLocation.toString());
}
// normalize chromosome name
String chr = chromosomeNormalizer(genomicLocation.getChromosome().trim());
normalizedGenomicLocation.setChromosome(chr);
// convert vcf style start,end,ref,alt to MAF style
Integer start = genomicLocation.getStart();
Integer end = genomicLocation.getEnd();
String ref = genomicLocation.getReferenceAllele().trim();
String var = genomicLocation.getVariantAllele().trim();
String prefix = "";
if (!ref.equals(var)) {
prefix = longestCommonPrefix(ref, var);
}
// Remove common prefix and adjust variant position accordingly
if (prefix.length() > 0) {
ref = ref.substring(prefix.length());
var = var.substring(prefix.length());
int nStart = start + prefix.length();
if (ref.length() == 0) {
nStart -= 1;
}
start = nStart;
}
normalizedGenomicLocation.setStart(start);
normalizedGenomicLocation.setEnd(end);
normalizedGenomicLocation.setReferenceAllele(ref);
normalizedGenomicLocation.setVariantAllele(var);
return normalizedGenomicLocation;
}
public GenomicLocation normalizeGenomicLocation(GenomicLocation genomicLocation) {
GenomicLocation normalizedGenomicLocation = new GenomicLocation();
// if original input is set in the incoming genomic location object then use the same value
// for the normalized genomic location object returned, otherwise set it to the
// string representation of the incoming genomic location object
if (genomicLocation.getOriginalInput() != null && !genomicLocation.getOriginalInput().isEmpty()) {
normalizedGenomicLocation.setOriginalInput(genomicLocation.getOriginalInput());
} else {
normalizedGenomicLocation.setOriginalInput(genomicLocation.toString());
}
// normalize chromosome name
String chr = chromosomeNormalizer(genomicLocation.getChromosome().trim());
normalizedGenomicLocation.setChromosome(chr);
// convert vcf style start,end,ref,alt to MAF style
Integer start = genomicLocation.getStart();
Integer end = genomicLocation.getEnd();
String ref = genomicLocation.getReferenceAllele().trim();
String var = genomicLocation.getVariantAllele().trim();
String prefix = "";
if (!ref.equals(var)) {
prefix = longestCommonPrefix(ref, var);
}
// Remove common prefix and adjust variant position accordingly
if (prefix.length() > 0) {
ref = ref.substring(prefix.length());
var = var.substring(prefix.length());
int nStart = start + prefix.length();
if (ref.length() == 0) {
nStart -= 1;
}
start = nStart;
}
normalizedGenomicLocation.setStart(start);
normalizedGenomicLocation.setEnd(end);
normalizedGenomicLocation.setReferenceAllele(ref);
normalizedGenomicLocation.setVariantAllele(var);
return normalizedGenomicLocation;
}