Program: 80603
Project: 80603
Buggy source:
/** 
 * takes a line from a VCF file, parse it, return a Variant object right now the meta-info lines (beginning with ##) are not tied with data line parsing. This will be corrected in the future (perhaps with help of HTSJDK).
 * @param line
 * @return
 */
public Variant processLine(String line) throws UnexpectedException {
  List<String> toks=Lists.newArrayList(Splitter.on('\t').split(line));
  if (line.startsWith("String_Node_Str")) {
    if (sampleId != null && line.startsWith("String_Node_Str")) {
      chromLineSeen=true;
      int index=0;
      for (      String tok : toks) {
        index++;
        if (tok.equals(sampleId))         sampleIndex=index;
      }
    }
 else     if (sampleId == null) {
      sampleIndex=10;
      if (line.startsWith("String_Node_Str") && toks.size() >= sampleIndex) {
        sampleId=toks.get(sampleIndex - 1);
      }
    }
    return null;
  }
  if (sampleIndex < 0 && !chromLineSeen) {
    sampleIndex=10;
  }
 else   if (sampleIndex < 0) {
    sampleIndex=10;
    log.warn("String_Node_Str" + sampleId + "String_Node_Str");
  }
  int index=0, genotypeIndex=-1, copyNumberIndex=-1;
  int pos=-1;
  ChrString chr=null;
  String REF="String_Node_Str", FILTER="String_Node_Str", ALT="String_Node_Str", variantId="String_Node_Str";
  String phase="String_Node_Str", copyNumber="String_Node_Str", infoString="String_Node_Str", FORMAT;
  String[] sampleInfo;
  for (  String tok : toks) {
    index++;
    if (index == 1) {
      chr=new ChrString(tok);
    }
 else     if (index == 2)     pos=Integer.parseInt(tok);
 else     if (index == 3)     variantId=tok;
 else     if (index == 4)     REF=tok;
 else     if (index == 5)     ALT=tok;
 else     if (index == 7)     FILTER=tok;
 else     if (index == 8)     infoString=tok;
 else     if (index == 9) {
      FORMAT=tok;
      genotypeIndex=getFormatKeyIndex(FORMAT,"String_Node_Str");
      copyNumberIndex=getFormatKeyIndex(FORMAT,"String_Node_Str");
    }
 else     if (index == sampleIndex) {
      sampleInfo=tok.split("String_Node_Str");
      if (genotypeIndex >= 0) {
        phase=sampleInfo[genotypeIndex];
      }
      if (copyNumberIndex >= 0) {
        copyNumber=sampleInfo[copyNumberIndex];
      }
      break;
    }
  }
  if (chr == null) {
    log.warn("String_Node_Str" + line);
    return null;
  }
  if (isPassFilterRequired && !(FILTER.contains("String_Node_Str") || FILTER.equals(DEFAULT_FILTER))) {
    log.warn("String_Node_Str" + line);
    return null;
  }
  byte[] genotypeArray=new byte[2];
  boolean isGenotypePhased=isPhased(phase,genotypeArray,chr);
  if (genotypeIndex >= 0 && genotypeArray[0] == 0 && genotypeArray[1] == 0) {
    return null;
  }
  if (!REF.matches("String_Node_Str")) {
    log.warn("String_Node_Str");
    return null;
  }
  byte[] copyNumberArray=new byte[2];
  boolean isCopyNumberPhased;
  if (copyNumberIndex >= 0) {
    isCopyNumberPhased=isPhased(copyNumber,copyNumberArray,chr);
    if (isCopyNumberPhased != isGenotypePhased) {
      log.warn("String_Node_Str");
      log.warn("String_Node_Str" + line);
      return null;
    }
  }
  REF=REF.toUpperCase();
  ALT=ALT.toUpperCase();
  String deletedReference="String_Node_Str";
  VCFInfo info=new VCFInfo(infoString);
  if (ALT.indexOf('<') != -1) {
    String[] alternativeAlleles=ALT.split("String_Node_Str");
    int[] svlen=info.getValue("String_Node_Str",int[].class);
    if (alternativeAlleles.length != svlen.length) {
      throw new IllegalArgumentException("String_Node_Str" + line);
    }
    for (int i=0; i < alternativeAlleles.length; i++) {
      if (!alternativeAlleles[i].startsWith("String_Node_Str")) {
        throw new IllegalArgumentException("String_Node_Str" + line);
      }
    }
  }
  Alt[] alts=null;
  try {
    alts=string2Alt(ALT);
  }
 catch (  IllegalArgumentException e) {
    log.warn("String_Node_Str" + e.getMessage() + "String_Node_Str"+ line);
    return null;
  }
  if (alts[0].getSymbolicAllele() != null) {
    int[] end=info.getValue("String_Node_Str",int[].class);
    int[] svlen=info.getValue("String_Node_Str",int[].class);
    int[] end2=info.getValue("String_Node_Str",int[].class);
    int[] pos2=info.getValue("String_Node_Str",int[].class);
    Boolean isinv=info.getValue("String_Node_Str",Boolean.class);
    Boolean isLengthImprecise=info.getValue("String_Node_Str",Boolean.class);
    isLengthImprecise=isLengthImprecise == null ? false : isLengthImprecise;
    String[] traid=info.getValue("String_Node_Str",String[].class);
    String[] chr2=info.getValue("String_Node_Str",String[].class);
    deletedReference=REF;
    byte[] refs=new byte[0];
    pos++;
    if (Alt.SVType.SVSubtype.TRA.equals(alts[0].getSymbolicAllele().getMinor())) {
      if (traid == null || traid.length == 0) {
        throw new IllegalArgumentException("String_Node_Str" + line);
      }
    }
    Variant.Builder template=new Variant.Builder().chr(chr).pos(pos).ref(refs).phase(genotypeArray).isPhased(isGenotypePhased).varId(variantId).filter(FILTER).refDeleted(deletedReference).isLengthImprecise(isLengthImprecise).randomNumberGenerator(random);
    if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.INV) {
      if (svlen.length > 0) {
        for (int i=0; i < svlen.length; i++) {
          if (i > 0 && svlen[i] != svlen[i - 1]) {
            log.warn("String_Node_Str" + line);
            return null;
          }
          int alternativeAlleleLength=Math.max(Math.abs(svlen[i]),1);
          alts[i].setSeq(new FlexSeq(FlexSeq.Type.INV,alternativeAlleleLength));
        }
        return template.referenceAlleleLength(Math.abs(svlen[0])).alts(alts).build();
      }
 else       if (end != null && end.length > 0 && end[0] > 0) {
        int alternativeAlleleLength=Math.max(Math.abs(end[0] - pos + 1),1);
        alts[0].setSeq(new FlexSeq(FlexSeq.Type.INV,alternativeAlleleLength));
        return template.referenceAlleleLength(alternativeAlleleLength).alts(alts).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else     if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.DUP && ((alts[0].getSymbolicAllele().getMinor() != Alt.SVType.SVSubtype.TRA && alts[0].getSymbolicAllele().getMinor() != Alt.SVType.SVSubtype.ISP && info.getValue("String_Node_Str",getType("String_Node_Str")) == null) || alts[0].getSymbolicAllele().getMinor() == Alt.SVType.SVSubtype.TANDEM)) {
      if (svlen.length > 0) {
        for (int i=0; i < svlen.length; i++) {
          if (i > 0 && svlen[i] != svlen[i - 1]) {
            log.warn("String_Node_Str" + line);
            return null;
          }
          int currentCopyNumber=2;
          for (int j=0; j < 2; j++) {
            if ((i + 1) == genotypeArray[j]) {
              if (copyNumberArray[j] > 0) {
                currentCopyNumber=copyNumberArray[j];
              }
            }
          }
          int alternativeAlleleLength=Math.max(Math.abs(svlen[i]),1);
          alts[i].setSeq(new FlexSeq(FlexSeq.Type.TANDEM_DUP,alternativeAlleleLength,currentCopyNumber));
        }
        return template.referenceAlleleLength(Math.abs(svlen[0])).alts(alts).build();
      }
 else       if (end != null && end.length > 0 && end[0] > 0) {
        int alternativeAlleleLength=Math.max(Math.abs(end[0] - pos + 1),1);
        alts[0].setSeq(new FlexSeq(FlexSeq.Type.TANDEM_DUP,alternativeAlleleLength,Math.max(copyNumberArray[0],copyNumberArray[1])));
        return template.referenceAlleleLength(alternativeAlleleLength).alts(alts).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else     if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.INS) {
      if (svlen.length > 0) {
        for (int i=0; i < svlen.length; i++) {
          int alternativeAlleleLength=svlen[i] == 0 ? Integer.MAX_VALUE : Math.max(Math.abs(svlen[i]),1);
          alts[i].setSeq(new FlexSeq(FlexSeq.Type.INS,alternativeAlleleLength));
        }
        return template.referenceAlleleLength(0).alts(alts).build();
      }
 else       if (end != null && end.length > 0 && end[0] > 0) {
        int alternativeAlleleLength=Math.max(Math.abs(end[0] - pos),1);
        alts[0].setSeq(new FlexSeq(FlexSeq.Type.INS,alternativeAlleleLength));
        return template.referenceAlleleLength(0).alts(alts).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else     if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.DEL) {
      template=template.traid(traid == null ? null : traid[0]);
      if (svlen.length > 0) {
        for (int i=0; i < svlen.length; i++) {
          if (i > 0 && svlen[i] != svlen[i - 1]) {
            log.warn("String_Node_Str" + line);
            return null;
          }
          if (Alt.SVType.SVSubtype.TRA == alts[i].getSymbolicAllele().getMinor()) {
            alts[i].setSeq(new FlexSeq(FlexSeq.Type.TRA_DEL,svlen[i]));
          }
 else {
            alts[i].setSeq(new FlexSeq(FlexSeq.Type.DEL,0));
          }
        }
        return template.alts(alts).referenceAlleleLength(Math.abs(svlen[0])).build();
      }
 else       if (end != null && end.length > 0 && end[0] > 0) {
        int alternativeAlleleLength=end[0] - pos + 1;
        if (Alt.SVType.SVSubtype.TRA == alts[0].getSymbolicAllele().getMinor()) {
          alts[0].setSeq(new FlexSeq(FlexSeq.Type.TRA_DEL,-alternativeAlleleLength));
        }
 else {
          alts[0].setSeq(new FlexSeq(FlexSeq.Type.DEL,0));
        }
        return template.alts(alts).referenceAlleleLength(alternativeAlleleLength).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else     if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.DUP && (alts[0].getSymbolicAllele().getMinor() == Alt.SVType.SVSubtype.TRA || alts[0].getSymbolicAllele().getMinor() == Alt.SVType.SVSubtype.ISP || info.getValue("String_Node_Str",getType("String_Node_Str")) != null)) {
      if (svlen.length > 0) {
        for (int altAlleleIndex=1; altAlleleIndex <= svlen.length; altAlleleIndex++) {
          int currentCopyNumber=2;
          if (altAlleleIndex == genotypeArray[0]) {
            currentCopyNumber=copyNumberArray[0];
          }
          if (altAlleleIndex == genotypeArray[1]) {
            currentCopyNumber=copyNumberArray[1];
          }
          currentCopyNumber=Math.max(1,currentCopyNumber);
          int altAllelelength=Math.max(Math.abs(svlen[altAlleleIndex - 1]),1);
          alts[altAlleleIndex - 1].setSeq(new FlexSeq(alts[altAlleleIndex - 1].getSymbolicAllele().getMinor() == Alt.SVType.SVSubtype.TRA ? FlexSeq.Type.TRA_DUP : FlexSeq.Type.ISP_DUP,altAllelelength,currentCopyNumber));
        }
        for (int i=1; i < svlen.length; i++) {
          if (svlen[i] != svlen[0]) {
            throw new IllegalArgumentException("String_Node_Str" + line);
          }
        }
        return template.referenceAlleleLength(0).alts(alts).chr2(ChrString.string2ChrString(chr2)).pos2(pos2).end2(end2).isinv(isinv).traid(traid == null ? null : traid[0]).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else {
      log.warn("String_Node_Str" + line);
      return null;
    }
  }
 else   if (alts[0].getSeq() != null) {
    for (int i=0; i < alts.length; i++) {
      if (REF.length() == 1 && alts[i].length() == 1) {
      }
 else       if (REF.length() == 0 || alts[i].length() == 0) {
        log.warn("String_Node_Str" + line);
        return null;
      }
    }
    while (REF.length() > 0) {
      boolean same=true;
      for (int i=0; i < alts.length; i++) {
        if (alts[i].length() == 0 || REF.charAt(0) != alts[i].byteAt(0)) {
          same=false;
          break;
        }
      }
      if (same) {
        pos++;
        deletedReference=String.valueOf(REF.charAt(0));
        REF=REF.substring(1);
        for (int i=0; i < alts.length; i++) {
          alts[i].setSeq(new FlexSeq(alts[i].getSeq().substring(1)));
        }
      }
 else {
        break;
      }
    }
    String clippedSequence="String_Node_Str";
    if (REF.length() > 0) {
      int referenceAlleleLength=REF.length();
      int minClipLength=Integer.MAX_VALUE;
      for (int i=0; i < alts.length; i++) {
        int alternativeAlleleLength=alts[i].length();
        int clipLength=0;
        for (int j=0; j < Math.min(alternativeAlleleLength,referenceAlleleLength); j++) {
          if (REF.charAt(referenceAlleleLength - j - 1) != alts[i].byteAt(alternativeAlleleLength - j - 1)) {
            clipLength=j;
            break;
          }
          clipLength=j + 1;
        }
        minClipLength=Math.min(clipLength,minClipLength);
      }
      if (minClipLength > 0) {
        clippedSequence=REF.substring(referenceAlleleLength - minClipLength,referenceAlleleLength);
        REF=REF.substring(0,Math.max(0,referenceAlleleLength - minClipLength));
        for (int i=0; i < alts.length; i++) {
          if (!clippedSequence.equals(new String(alts[i].getSeq().substring(alts[i].getSeq().length() - minClipLength,alts[i].getSeq().length())))) {
            log.warn("String_Node_Str" + line);
            return null;
          }
          alts[i].setSeq(new FlexSeq(alts[i].getSeq().substring(0,Math.max(0,alts[i].length() - minClipLength))));
        }
      }
    }
    byte[] refs=new byte[REF.length()];
    for (int i=0; i < REF.length(); i++) {
      refs[i]=(byte)REF.charAt(i);
    }
    return new Variant.Builder().chr(chr).pos(pos).referenceAlleleLength(refs.length).ref(refs).alts(alts).phase(genotypeArray).isPhased(isGenotypePhased).varId(variantId).filter(FILTER).refDeleted(deletedReference).randomNumberGenerator(random).clippedSequence(clippedSequence).build();
  }
 else {
    log.warn("String_Node_Str" + line);
    return null;
  }
}

Fixed version (ground truth):
/** 
 * takes a line from a VCF file, parse it, return a Variant object right now the meta-info lines (beginning with ##) are not tied with data line parsing. This will be corrected in the future (perhaps with help of HTSJDK).
 * @param line
 * @return
 */
public Variant processLine(String line) throws UnexpectedException {
  List<String> toks=Lists.newArrayList(Splitter.on('\t').split(line));
  if (line.startsWith("String_Node_Str")) {
    if (sampleId != null && line.startsWith("String_Node_Str")) {
      chromLineSeen=true;
      int index=0;
      for (      String tok : toks) {
        index++;
        if (tok.equals(sampleId))         sampleIndex=index;
      }
    }
 else     if (sampleId == null) {
      sampleIndex=10;
      if (line.startsWith("String_Node_Str") && toks.size() >= sampleIndex) {
        sampleId=toks.get(sampleIndex - 1);
      }
    }
    return null;
  }
  if (sampleIndex < 0 && !chromLineSeen) {
    sampleIndex=10;
  }
 else   if (sampleIndex < 0) {
    sampleIndex=10;
    log.warn("String_Node_Str" + sampleId + "String_Node_Str");
  }
  int index=0, genotypeIndex=-1, copyNumberIndex=-1;
  int pos=-1;
  ChrString chr=null;
  String REF="String_Node_Str", FILTER="String_Node_Str", ALT="String_Node_Str", variantId="String_Node_Str";
  String phase="String_Node_Str", copyNumber="String_Node_Str", infoString="String_Node_Str", FORMAT;
  String[] sampleInfo;
  for (  String tok : toks) {
    index++;
    if (index == 1) {
      chr=new ChrString(tok);
    }
 else     if (index == 2)     pos=Integer.parseInt(tok);
 else     if (index == 3)     variantId=tok;
 else     if (index == 4)     REF=tok;
 else     if (index == 5)     ALT=tok;
 else     if (index == 7)     FILTER=tok;
 else     if (index == 8)     infoString=tok;
 else     if (index == 9) {
      FORMAT=tok;
      genotypeIndex=getFormatKeyIndex(FORMAT,"String_Node_Str");
      copyNumberIndex=getFormatKeyIndex(FORMAT,"String_Node_Str");
    }
 else     if (index == sampleIndex) {
      sampleInfo=tok.split("String_Node_Str");
      if (genotypeIndex >= 0) {
        phase=sampleInfo[genotypeIndex];
      }
      if (copyNumberIndex >= 0) {
        copyNumber=sampleInfo[copyNumberIndex];
      }
      break;
    }
  }
  if (chr == null) {
    log.warn("String_Node_Str" + line);
    return null;
  }
  if (isPassFilterRequired && !(FILTER.contains("String_Node_Str") || FILTER.equals(DEFAULT_FILTER))) {
    log.warn("String_Node_Str" + line);
    return null;
  }
  byte[] genotypeArray=new byte[2];
  boolean isGenotypePhased=isPhased(phase,genotypeArray,chr);
  if (genotypeIndex >= 0 && genotypeArray[0] == 0 && genotypeArray[1] == 0) {
    log.warn("String_Node_Str" + line);
    return null;
  }
  if (!REF.matches("String_Node_Str")) {
    log.warn("String_Node_Str" + line);
    return null;
  }
  byte[] copyNumberArray=new byte[2];
  boolean isCopyNumberPhased;
  if (copyNumberIndex >= 0) {
    isCopyNumberPhased=isPhased(copyNumber,copyNumberArray,chr);
    if (isCopyNumberPhased != isGenotypePhased) {
      log.warn("String_Node_Str");
      log.warn("String_Node_Str" + line);
      return null;
    }
  }
  REF=REF.toUpperCase();
  ALT=ALT.toUpperCase();
  String deletedReference="String_Node_Str";
  VCFInfo info=new VCFInfo(infoString);
  if (ALT.indexOf('<') != -1) {
    String[] alternativeAlleles=ALT.split("String_Node_Str");
    int[] svlen=info.getValue("String_Node_Str",int[].class);
    if (alternativeAlleles.length != svlen.length) {
      throw new IllegalArgumentException("String_Node_Str" + line);
    }
    for (int i=0; i < alternativeAlleles.length; i++) {
      if (!alternativeAlleles[i].startsWith("String_Node_Str")) {
        throw new IllegalArgumentException("String_Node_Str" + line);
      }
    }
  }
  Alt[] alts=null;
  try {
    alts=string2Alt(ALT);
  }
 catch (  IllegalArgumentException e) {
    log.warn("String_Node_Str" + e.getMessage() + "String_Node_Str"+ line);
    return null;
  }
  if (alts[0].getSymbolicAllele() != null) {
    int[] end=info.getValue("String_Node_Str",int[].class);
    int[] svlen=info.getValue("String_Node_Str",int[].class);
    int[] end2=info.getValue("String_Node_Str",int[].class);
    int[] pos2=info.getValue("String_Node_Str",int[].class);
    Boolean isinv=info.getValue("String_Node_Str",Boolean.class);
    Boolean isLengthImprecise=info.getValue("String_Node_Str",Boolean.class);
    isLengthImprecise=isLengthImprecise == null ? false : isLengthImprecise;
    String[] traid=info.getValue("String_Node_Str",String[].class);
    String[] chr2=info.getValue("String_Node_Str",String[].class);
    deletedReference=REF;
    byte[] refs=new byte[0];
    pos++;
    if (Alt.SVType.SVSubtype.TRA.equals(alts[0].getSymbolicAllele().getMinor())) {
      if (traid == null || traid.length == 0) {
        throw new IllegalArgumentException("String_Node_Str" + line);
      }
    }
    Variant.Builder template=new Variant.Builder().chr(chr).pos(pos).ref(refs).phase(genotypeArray).isPhased(isGenotypePhased).varId(variantId).filter(FILTER).refDeleted(deletedReference).isLengthImprecise(isLengthImprecise).randomNumberGenerator(random);
    if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.INV) {
      if (svlen.length > 0) {
        for (int i=0; i < svlen.length; i++) {
          if (i > 0 && svlen[i] != svlen[i - 1]) {
            log.warn("String_Node_Str" + line);
            return null;
          }
          int alternativeAlleleLength=Math.max(Math.abs(svlen[i]),1);
          alts[i].setSeq(new FlexSeq(FlexSeq.Type.INV,alternativeAlleleLength));
        }
        return template.referenceAlleleLength(Math.abs(svlen[0])).alts(alts).build();
      }
 else       if (end != null && end.length > 0 && end[0] > 0) {
        int alternativeAlleleLength=Math.max(Math.abs(end[0] - pos + 1),1);
        alts[0].setSeq(new FlexSeq(FlexSeq.Type.INV,alternativeAlleleLength));
        return template.referenceAlleleLength(alternativeAlleleLength).alts(alts).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else     if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.DUP && ((alts[0].getSymbolicAllele().getMinor() != Alt.SVType.SVSubtype.TRA && alts[0].getSymbolicAllele().getMinor() != Alt.SVType.SVSubtype.ISP && info.getValue("String_Node_Str",getType("String_Node_Str")) == null) || alts[0].getSymbolicAllele().getMinor() == Alt.SVType.SVSubtype.TANDEM)) {
      if (svlen.length > 0) {
        for (int i=0; i < svlen.length; i++) {
          if (i > 0 && svlen[i] != svlen[i - 1]) {
            log.warn("String_Node_Str" + line);
            return null;
          }
          int currentCopyNumber=2;
          for (int j=0; j < 2; j++) {
            if ((i + 1) == genotypeArray[j]) {
              if (copyNumberArray[j] > 0) {
                currentCopyNumber=copyNumberArray[j];
              }
            }
          }
          int alternativeAlleleLength=Math.max(Math.abs(svlen[i]),1);
          alts[i].setSeq(new FlexSeq(FlexSeq.Type.TANDEM_DUP,alternativeAlleleLength,currentCopyNumber));
        }
        return template.referenceAlleleLength(Math.abs(svlen[0])).alts(alts).build();
      }
 else       if (end != null && end.length > 0 && end[0] > 0) {
        int alternativeAlleleLength=Math.max(Math.abs(end[0] - pos + 1),1);
        alts[0].setSeq(new FlexSeq(FlexSeq.Type.TANDEM_DUP,alternativeAlleleLength,Math.max(copyNumberArray[0],copyNumberArray[1])));
        return template.referenceAlleleLength(alternativeAlleleLength).alts(alts).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else     if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.INS) {
      if (svlen.length > 0) {
        for (int i=0; i < svlen.length; i++) {
          int alternativeAlleleLength=svlen[i] == 0 ? Integer.MAX_VALUE : Math.max(Math.abs(svlen[i]),1);
          alts[i].setSeq(new FlexSeq(FlexSeq.Type.INS,alternativeAlleleLength));
        }
        return template.referenceAlleleLength(0).alts(alts).build();
      }
 else       if (end != null && end.length > 0 && end[0] > 0) {
        int alternativeAlleleLength=Math.max(Math.abs(end[0] - pos),1);
        alts[0].setSeq(new FlexSeq(FlexSeq.Type.INS,alternativeAlleleLength));
        return template.referenceAlleleLength(0).alts(alts).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else     if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.DEL) {
      template=template.traid(traid == null ? null : traid[0]);
      if (svlen.length > 0) {
        for (int i=0; i < svlen.length; i++) {
          if (i > 0 && svlen[i] != svlen[i - 1]) {
            log.warn("String_Node_Str" + line);
            return null;
          }
          if (Alt.SVType.SVSubtype.TRA == alts[i].getSymbolicAllele().getMinor()) {
            alts[i].setSeq(new FlexSeq(FlexSeq.Type.TRA_DEL,svlen[i]));
          }
 else {
            alts[i].setSeq(new FlexSeq(FlexSeq.Type.DEL,0));
          }
        }
        return template.alts(alts).referenceAlleleLength(Math.abs(svlen[0])).build();
      }
 else       if (end != null && end.length > 0 && end[0] > 0) {
        int alternativeAlleleLength=end[0] - pos + 1;
        if (Alt.SVType.SVSubtype.TRA == alts[0].getSymbolicAllele().getMinor()) {
          alts[0].setSeq(new FlexSeq(FlexSeq.Type.TRA_DEL,-alternativeAlleleLength));
        }
 else {
          alts[0].setSeq(new FlexSeq(FlexSeq.Type.DEL,0));
        }
        return template.alts(alts).referenceAlleleLength(alternativeAlleleLength).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else     if (alts[0].getSymbolicAllele().getMajor() == Alt.SVType.DUP && (alts[0].getSymbolicAllele().getMinor() == Alt.SVType.SVSubtype.TRA || alts[0].getSymbolicAllele().getMinor() == Alt.SVType.SVSubtype.ISP || info.getValue("String_Node_Str",getType("String_Node_Str")) != null)) {
      if (svlen.length > 0) {
        for (int altAlleleIndex=1; altAlleleIndex <= svlen.length; altAlleleIndex++) {
          int currentCopyNumber=2;
          if (altAlleleIndex == genotypeArray[0]) {
            currentCopyNumber=copyNumberArray[0];
          }
          if (altAlleleIndex == genotypeArray[1]) {
            currentCopyNumber=copyNumberArray[1];
          }
          currentCopyNumber=Math.max(1,currentCopyNumber);
          int altAllelelength=Math.max(Math.abs(svlen[altAlleleIndex - 1]),1);
          alts[altAlleleIndex - 1].setSeq(new FlexSeq(alts[altAlleleIndex - 1].getSymbolicAllele().getMinor() == Alt.SVType.SVSubtype.TRA ? FlexSeq.Type.TRA_DUP : FlexSeq.Type.ISP_DUP,altAllelelength,currentCopyNumber));
        }
        for (int i=1; i < svlen.length; i++) {
          if (svlen[i] != svlen[0]) {
            throw new IllegalArgumentException("String_Node_Str" + line);
          }
        }
        return template.referenceAlleleLength(0).alts(alts).chr2(ChrString.string2ChrString(chr2)).pos2(pos2).end2(end2).isinv(isinv).traid(traid == null ? null : traid[0]).build();
      }
 else {
        log.error("String_Node_Str");
        log.error(line);
        log.error("String_Node_Str");
        return null;
      }
    }
 else {
      log.warn("String_Node_Str" + line);
      return null;
    }
  }
 else   if (alts[0].getSeq() != null) {
    for (int i=0; i < alts.length; i++) {
      if (REF.length() == 1 && alts[i].length() == 1) {
      }
 else       if (REF.length() == 0 || alts[i].length() == 0) {
        log.warn("String_Node_Str" + line);
        return null;
      }
    }
    while (REF.length() > 0) {
      boolean same=true;
      for (int i=0; i < alts.length; i++) {
        if (alts[i].length() == 0 || REF.charAt(0) != alts[i].byteAt(0)) {
          same=false;
          break;
        }
      }
      if (same) {
        pos++;
        deletedReference=String.valueOf(REF.charAt(0));
        REF=REF.substring(1);
        for (int i=0; i < alts.length; i++) {
          alts[i].setSeq(new FlexSeq(alts[i].getSeq().substring(1)));
        }
      }
 else {
        break;
      }
    }
    String clippedSequence="String_Node_Str";
    if (REF.length() > 0) {
      int referenceAlleleLength=REF.length();
      int minClipLength=Integer.MAX_VALUE;
      for (int i=0; i < alts.length; i++) {
        int alternativeAlleleLength=alts[i].length();
        int clipLength=0;
        for (int j=0; j < Math.min(alternativeAlleleLength,referenceAlleleLength); j++) {
          if (REF.charAt(referenceAlleleLength - j - 1) != alts[i].byteAt(alternativeAlleleLength - j - 1)) {
            clipLength=j;
            break;
          }
          clipLength=j + 1;
        }
        minClipLength=Math.min(clipLength,minClipLength);
      }
      if (minClipLength > 0) {
        clippedSequence=REF.substring(referenceAlleleLength - minClipLength,referenceAlleleLength);
        REF=REF.substring(0,Math.max(0,referenceAlleleLength - minClipLength));
        for (int i=0; i < alts.length; i++) {
          if (!clippedSequence.equals(new String(alts[i].getSeq().substring(alts[i].getSeq().length() - minClipLength,alts[i].getSeq().length())))) {
            log.warn("String_Node_Str" + line);
            return null;
          }
          alts[i].setSeq(new FlexSeq(alts[i].getSeq().substring(0,Math.max(0,alts[i].length() - minClipLength))));
        }
      }
    }
    byte[] refs=new byte[REF.length()];
    for (int i=0; i < REF.length(); i++) {
      refs[i]=(byte)REF.charAt(i);
    }
    return new Variant.Builder().chr(chr).pos(pos).referenceAlleleLength(refs.length).ref(refs).alts(alts).phase(genotypeArray).isPhased(isGenotypePhased).varId(variantId).filter(FILTER).refDeleted(deletedReference).randomNumberGenerator(random).clippedSequence(clippedSequence).build();
  }
 else {
    log.warn("String_Node_Str" + line);
    return null;
  }
}