Program: 80635
Project: 80635
Buggy source:
/** 
 * takes a line from a VCF file, parse it, return a Variant object
 * @param line
 * @return
 */
public Variant process_line(String line){
  StringTokenizer toks=new StringTokenizer(line);
  if (line.startsWith("String_Node_Str")) {
    if (_id != null && line.startsWith("String_Node_Str")) {
      chrom_exists=true;
      int index=0;
      while (toks.hasMoreTokens()) {
        index++;
        String tok=toks.nextToken();
        if (tok.equals(_id))         _id_ind=index;
      }
    }
 else     if (_id == null) {
      _id_ind=10;
    }
    return null;
  }
  if (_id_ind < 0 && !chrom_exists) {
    _id_ind=10;
  }
 else   if (_id_ind < 0) {
    _id_ind=10;
    log.warn("String_Node_Str" + _id + "String_Node_Str");
  }
  int index=0, genotype_ind=-1, copynum_ind=-1;
  int pos=-1;
  ChrString chr=null;
  String REF="String_Node_Str", FILTER="String_Node_Str", ALT="String_Node_Str", var_id="String_Node_Str";
  String phase="String_Node_Str", copy_num="String_Node_Str", INFO="String_Node_Str", FORMAT;
  String[] sampleInfo;
  while (toks.hasMoreTokens()) {
    index++;
    if (index == 1) {
      chr=new ChrString(toks.nextToken());
    }
 else     if (index == 2)     pos=Integer.parseInt(toks.nextToken());
 else     if (index == 3)     var_id=toks.nextToken();
 else     if (index == 4)     REF=toks.nextToken();
 else     if (index == 5)     ALT=toks.nextToken();
 else     if (index == 7)     FILTER=toks.nextToken();
 else     if (index == 8)     INFO=toks.nextToken();
 else     if (index == 9) {
      FORMAT=toks.nextToken();
      genotype_ind=getFormatKeyIndex(FORMAT,"String_Node_Str");
      copynum_ind=getFormatKeyIndex(FORMAT,"String_Node_Str");
    }
 else     if (index == _id_ind) {
      sampleInfo=(toks.nextToken()).split("String_Node_Str");
      if (genotype_ind >= 0) {
        phase=sampleInfo[genotype_ind];
      }
      if (copynum_ind >= 0) {
        copy_num=sampleInfo[copynum_ind];
      }
      break;
    }
 else {
      toks.nextToken();
    }
  }
  if (chr == null) {
    log.warn("String_Node_Str" + line);
    return null;
  }
  if (_pass && !(FILTER.contains("String_Node_Str") || FILTER.equals("String_Node_Str"))) {
    return null;
  }
  byte[] phase_val=new byte[2];
  boolean is_phased=splitGeno(phase,phase_val,chr);
  if (genotype_ind >= 0 && phase_val[0] == 0 && phase_val[1] == 0) {
  }
  byte[] copy_num_val=new byte[2];
  boolean is_cn_phased;
  if (copynum_ind >= 0) {
    is_cn_phased=splitGeno(copy_num,copy_num_val,chr);
    if (is_cn_phased != is_phased) {
      log.error("String_Node_Str");
      log.error(line);
      return null;
    }
  }
  REF=REF.toUpperCase();
  ALT=ALT.toUpperCase();
  String ref_deleted="String_Node_Str";
  FlexSeq alts[];
  if (ALT.equals("String_Node_Str")) {
    int inv_lens[]=getSVLen(INFO);
    int end_loc=getEndInfo(INFO);
    ref_deleted=REF;
    byte[] refs=new byte[0];
    pos++;
    if (inv_lens.length > 0) {
      alts=new FlexSeq[inv_lens.length];
      for (int i=0; i < inv_lens.length; i++) {
        int len_val=Math.max(Math.abs(inv_lens[i]),1);
        alts[i]=new FlexSeq(FlexSeq.Type.INV,len_val);
      }
      return new Variant(chr,pos,Math.abs(inv_lens[0]),refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else     if (end_loc > 0) {
      int inv_len=Math.max(Math.abs(end_loc - pos + 1),1);
      alts=new FlexSeq[1];
      alts[0]=new FlexSeq(FlexSeq.Type.INV,inv_len);
      return new Variant(chr,pos,inv_len,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else {
      log.error("String_Node_Str");
      log.error(line);
      log.error("String_Node_Str");
      return null;
    }
  }
 else   if (ALT.equals("String_Node_Str") || ALT.equals("String_Node_Str")) {
    int dup_lens[]=getSVLen(INFO);
    int end_loc=getEndInfo(INFO);
    ref_deleted=REF;
    byte[] refs=new byte[0];
    pos++;
    if (dup_lens.length > 0) {
      alts=new FlexSeq[dup_lens.length];
      for (int i=0; i < dup_lens.length; i++) {
        int copy_val=1;
        for (int j=0; j < 2; j++) {
          if ((i + 1) == phase_val[j]) {
            if (copy_num_val[j] > 0) {
              copy_val=copy_num_val[j];
            }
          }
        }
        int len_val=Math.max(Math.abs(dup_lens[i]),1);
        alts[i]=new FlexSeq(FlexSeq.Type.DUP,len_val,copy_val);
      }
      return new Variant(chr,pos,Math.abs(dup_lens[0]),refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else     if (end_loc > 0) {
      int dup_len=Math.max(Math.abs(end_loc - pos + 1),1);
      alts=new FlexSeq[1];
      alts[0]=new FlexSeq(FlexSeq.Type.DUP,dup_len,Math.max(copy_num_val[0],copy_num_val[1]));
      return new Variant(chr,pos,dup_len,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else {
      log.error("String_Node_Str");
      log.error(line);
      log.error("String_Node_Str");
      return null;
    }
  }
 else   if (ALT.equals("String_Node_Str")) {
    int ins_lens[]=getSVLen(INFO);
    int end_loc=getEndInfo(INFO);
    ref_deleted=REF;
    byte[] refs=new byte[0];
    pos++;
    if (ins_lens.length > 0) {
      alts=new FlexSeq[ins_lens.length];
      for (int i=0; i < ins_lens.length; i++) {
        int len_val;
        if (ins_lens[i] == 0) {
          len_val=Integer.MAX_VALUE;
        }
 else {
          len_val=Math.max(Math.abs(ins_lens[i]),1);
        }
        alts[i]=new FlexSeq(FlexSeq.Type.INS,len_val);
      }
      return new Variant(chr,pos,0,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else     if (end_loc > 0) {
      int ins_len=Math.max(Math.abs(end_loc - pos),1);
      alts=new FlexSeq[1];
      alts[0]=new FlexSeq(FlexSeq.Type.INS,ins_len);
      return new Variant(chr,pos,0,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else {
      log.error("String_Node_Str");
      log.error(line);
      log.error("String_Node_Str");
      return null;
    }
  }
 else   if (ALT.equals("String_Node_Str")) {
    int del_lens[]=getSVLen(INFO);
    int end_loc=getEndInfo(INFO);
    ref_deleted=REF;
    byte[] refs=new byte[0];
    pos++;
    if (del_lens.length > 0) {
      alts=new FlexSeq[del_lens.length];
      for (int i=0; i < del_lens.length; i++) {
        alts[i]=new FlexSeq(FlexSeq.Type.DEL,0);
      }
      return new Variant(chr,pos,Math.abs(del_lens[0]),refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else     if (end_loc > 0) {
      int del_len=end_loc - pos + 1;
      alts=new FlexSeq[1];
      alts[0]=new FlexSeq(FlexSeq.Type.DEL,0);
      return new Variant(chr,pos,del_len,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else {
      log.error("String_Node_Str");
      log.error(line);
      log.error("String_Node_Str");
      return null;
    }
  }
 else   if (ALT.indexOf('<') >= 0) {
    log.warn("String_Node_Str" + line);
    return null;
  }
 else {
    String[] alts_str=ALT.split("String_Node_Str");
    int n=alts_str.length;
    alts=new FlexSeq[n];
    for (int i=0; i < n; i++) {
      byte[] temp=new byte[alts_str[i].length()];
      for (int j=0; j < alts_str[i].length(); j++) {
        temp[j]=(byte)alts_str[i].charAt(j);
      }
      alts[i]=new FlexSeq(temp);
    }
    for (int i=0; i < n; i++) {
      if (REF.length() == 1 && alts[i].length() == 1) {
      }
 else       if (REF.length() == 0 || alts[i].length() == 0) {
        log.warn("String_Node_Str");
        log.warn(line);
        return null;
      }
    }
    if (REF.length() > 0) {
      boolean same=true;
      for (int i=0; i < n; i++) {
        if (alts[i].length() == 0 || REF.charAt(0) != alts[i].charAt(0)) {
          same=false;
          break;
        }
      }
      if (same) {
        pos++;
        ref_deleted=String.valueOf(REF.charAt(0));
        REF=REF.substring(1);
        for (int i=0; i < n; i++) {
          alts[i]=new FlexSeq(alts[i].substring(1));
        }
      }
    }
    if (REF.length() > 0) {
      int ref_len=REF.length();
      int min_clip_len=Integer.MAX_VALUE;
      for (int i=0; i < n; i++) {
        int alt_len=alts[i].length();
        int clip_len=0;
        for (int j=0; j < alt_len; j++) {
          if (ref_len - j <= 0 || alt_len - j <= 0) {
            clip_len=j;
            break;
          }
          if (REF.charAt(ref_len - j - 1) != alts[i].charAt(alt_len - j - 1)) {
            clip_len=j;
            break;
          }
          clip_len=j + 1;
        }
        if (min_clip_len > clip_len) {
          min_clip_len=clip_len;
        }
      }
      if (min_clip_len > 0) {
        REF=REF.substring(0,ref_len - min_clip_len);
        for (int i=0; i < n; i++) {
          alts[i]=new FlexSeq(alts[i].substring(0,alts[i].length() - min_clip_len));
        }
      }
    }
    byte[] refs=new byte[REF.length()];
    for (int i=0; i < REF.length(); i++) {
      refs[i]=(byte)REF.charAt(i);
    }
    return new Variant(chr,pos,refs.length,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
  }
}

Fixed version (ground truth):
/** 
 * takes a line from a VCF file, parse it, return a Variant object
 * @param line
 * @return
 */
public Variant process_line(String line){
  StringTokenizer toks=new StringTokenizer(line);
  if (line.startsWith("String_Node_Str")) {
    if (_id != null && line.startsWith("String_Node_Str")) {
      chrom_exists=true;
      int index=0;
      while (toks.hasMoreTokens()) {
        index++;
        String tok=toks.nextToken();
        if (tok.equals(_id))         _id_ind=index;
      }
    }
 else     if (_id == null) {
      _id_ind=10;
    }
    return null;
  }
  if (_id_ind < 0 && !chrom_exists) {
    _id_ind=10;
  }
 else   if (_id_ind < 0) {
    _id_ind=10;
    log.warn("String_Node_Str" + _id + "String_Node_Str");
  }
  int index=0, genotype_ind=-1, copynum_ind=-1;
  int pos=-1;
  ChrString chr=null;
  String REF="String_Node_Str", FILTER="String_Node_Str", ALT="String_Node_Str", var_id="String_Node_Str";
  String phase="String_Node_Str", copy_num="String_Node_Str", INFO="String_Node_Str", FORMAT;
  String[] sampleInfo;
  while (toks.hasMoreTokens()) {
    index++;
    if (index == 1) {
      chr=new ChrString(toks.nextToken());
    }
 else     if (index == 2)     pos=Integer.parseInt(toks.nextToken());
 else     if (index == 3)     var_id=toks.nextToken();
 else     if (index == 4)     REF=toks.nextToken();
 else     if (index == 5)     ALT=toks.nextToken();
 else     if (index == 7)     FILTER=toks.nextToken();
 else     if (index == 8)     INFO=toks.nextToken();
 else     if (index == 9) {
      FORMAT=toks.nextToken();
      genotype_ind=getFormatKeyIndex(FORMAT,"String_Node_Str");
      copynum_ind=getFormatKeyIndex(FORMAT,"String_Node_Str");
    }
 else     if (index == _id_ind) {
      sampleInfo=(toks.nextToken()).split("String_Node_Str");
      if (genotype_ind >= 0) {
        phase=sampleInfo[genotype_ind];
      }
      if (copynum_ind >= 0) {
        copy_num=sampleInfo[copynum_ind];
      }
      break;
    }
 else {
      toks.nextToken();
    }
  }
  if (chr == null) {
    log.warn("String_Node_Str" + line);
    return null;
  }
  if (_pass && !(FILTER.contains("String_Node_Str") || FILTER.equals("String_Node_Str"))) {
    return null;
  }
  byte[] phase_val=new byte[2];
  boolean is_phased=splitGeno(phase,phase_val,chr);
  if (genotype_ind >= 0 && phase_val[0] == 0 && phase_val[1] == 0) {
  }
  byte[] copy_num_val=new byte[2];
  boolean is_cn_phased;
  if (copynum_ind >= 0) {
    is_cn_phased=splitGeno(copy_num,copy_num_val,chr);
    if (is_cn_phased != is_phased) {
      log.error("String_Node_Str");
      log.error(line);
      return null;
    }
  }
  REF=REF.toUpperCase();
  ALT=ALT.toUpperCase();
  String ref_deleted="String_Node_Str";
  FlexSeq alts[];
  if (ALT.indexOf('<') != -1) {
    String[] alts_str=ALT.split("String_Node_Str");
    int[] inv_lens=getSVLen(INFO);
    if (alts_str.length != inv_lens.length) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    for (int i=0; i < alts_str.length; i++) {
      if (!alts_str[i].startsWith("String_Node_Str")) {
        throw new IllegalArgumentException("String_Node_Str");
      }
    }
  }
  if (ALT.startsWith("String_Node_Str")) {
    int inv_lens[]=getSVLen(INFO);
    int end_loc=getEndInfo(INFO);
    ref_deleted=REF;
    byte[] refs=new byte[0];
    pos++;
    if (inv_lens.length > 0) {
      alts=new FlexSeq[inv_lens.length];
      for (int i=0; i < inv_lens.length; i++) {
        int len_val=Math.max(Math.abs(inv_lens[i]),1);
        alts[i]=new FlexSeq(FlexSeq.Type.INV,len_val);
      }
      return new Variant(chr,pos,Math.abs(inv_lens[0]),refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else     if (end_loc > 0) {
      int inv_len=Math.max(Math.abs(end_loc - pos + 1),1);
      alts=new FlexSeq[1];
      alts[0]=new FlexSeq(FlexSeq.Type.INV,inv_len);
      return new Variant(chr,pos,inv_len,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else {
      log.error("String_Node_Str");
      log.error(line);
      log.error("String_Node_Str");
      return null;
    }
  }
 else   if (ALT.startsWith("String_Node_Str") || ALT.startsWith("String_Node_Str")) {
    int dup_lens[]=getSVLen(INFO);
    int end_loc=getEndInfo(INFO);
    ref_deleted=REF;
    byte[] refs=new byte[0];
    pos++;
    if (dup_lens.length > 0) {
      alts=new FlexSeq[dup_lens.length];
      for (int i=0; i < dup_lens.length; i++) {
        int copy_val=1;
        for (int j=0; j < 2; j++) {
          if ((i + 1) == phase_val[j]) {
            if (copy_num_val[j] > 0) {
              copy_val=copy_num_val[j];
            }
          }
        }
        int len_val=Math.max(Math.abs(dup_lens[i]),1);
        alts[i]=new FlexSeq(FlexSeq.Type.DUP,len_val,copy_val);
      }
      return new Variant(chr,pos,Math.abs(dup_lens[0]),refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else     if (end_loc > 0) {
      int dup_len=Math.max(Math.abs(end_loc - pos + 1),1);
      alts=new FlexSeq[1];
      alts[0]=new FlexSeq(FlexSeq.Type.DUP,dup_len,Math.max(copy_num_val[0],copy_num_val[1]));
      return new Variant(chr,pos,dup_len,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else {
      log.error("String_Node_Str");
      log.error(line);
      log.error("String_Node_Str");
      return null;
    }
  }
 else   if (ALT.startsWith("String_Node_Str")) {
    int ins_lens[]=getSVLen(INFO);
    int end_loc=getEndInfo(INFO);
    ref_deleted=REF;
    byte[] refs=new byte[0];
    pos++;
    if (ins_lens.length > 0) {
      alts=new FlexSeq[ins_lens.length];
      for (int i=0; i < ins_lens.length; i++) {
        int len_val;
        if (ins_lens[i] == 0) {
          len_val=Integer.MAX_VALUE;
        }
 else {
          len_val=Math.max(Math.abs(ins_lens[i]),1);
        }
        alts[i]=new FlexSeq(FlexSeq.Type.INS,len_val);
      }
      return new Variant(chr,pos,0,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else     if (end_loc > 0) {
      int ins_len=Math.max(Math.abs(end_loc - pos),1);
      alts=new FlexSeq[1];
      alts[0]=new FlexSeq(FlexSeq.Type.INS,ins_len);
      return new Variant(chr,pos,0,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else {
      log.error("String_Node_Str");
      log.error(line);
      log.error("String_Node_Str");
      return null;
    }
  }
 else   if (ALT.startsWith("String_Node_Str")) {
    int del_lens[]=getSVLen(INFO);
    int end_loc=getEndInfo(INFO);
    ref_deleted=REF;
    byte[] refs=new byte[0];
    pos++;
    if (del_lens.length > 0) {
      alts=new FlexSeq[del_lens.length];
      for (int i=0; i < del_lens.length; i++) {
        alts[i]=new FlexSeq(FlexSeq.Type.DEL,0);
      }
      return new Variant(chr,pos,Math.abs(del_lens[0]),refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else     if (end_loc > 0) {
      int del_len=end_loc - pos + 1;
      alts=new FlexSeq[1];
      alts[0]=new FlexSeq(FlexSeq.Type.DEL,0);
      return new Variant(chr,pos,del_len,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
    }
 else {
      log.error("String_Node_Str");
      log.error(line);
      log.error("String_Node_Str");
      return null;
    }
  }
 else   if (ALT.indexOf('<') >= 0) {
    log.warn("String_Node_Str" + line);
    return null;
  }
 else {
    String[] alts_str=ALT.split("String_Node_Str");
    int n=alts_str.length;
    alts=new FlexSeq[n];
    for (int i=0; i < n; i++) {
      byte[] temp=new byte[alts_str[i].length()];
      for (int j=0; j < alts_str[i].length(); j++) {
        temp[j]=(byte)alts_str[i].charAt(j);
      }
      alts[i]=new FlexSeq(temp);
    }
    for (int i=0; i < n; i++) {
      if (REF.length() == 1 && alts[i].length() == 1) {
      }
 else       if (REF.length() == 0 || alts[i].length() == 0) {
        log.warn("String_Node_Str");
        log.warn(line);
        return null;
      }
    }
    if (REF.length() > 0) {
      boolean same=true;
      for (int i=0; i < n; i++) {
        if (alts[i].length() == 0 || REF.charAt(0) != alts[i].charAt(0)) {
          same=false;
          break;
        }
      }
      if (same) {
        pos++;
        ref_deleted=String.valueOf(REF.charAt(0));
        REF=REF.substring(1);
        for (int i=0; i < n; i++) {
          alts[i]=new FlexSeq(alts[i].substring(1));
        }
      }
    }
    if (REF.length() > 0) {
      int ref_len=REF.length();
      int min_clip_len=Integer.MAX_VALUE;
      for (int i=0; i < n; i++) {
        int alt_len=alts[i].length();
        int clip_len=0;
        for (int j=0; j < alt_len; j++) {
          if (ref_len - j <= 0 || alt_len - j <= 0) {
            clip_len=j;
            break;
          }
          if (REF.charAt(ref_len - j - 1) != alts[i].charAt(alt_len - j - 1)) {
            clip_len=j;
            break;
          }
          clip_len=j + 1;
        }
        if (min_clip_len > clip_len) {
          min_clip_len=clip_len;
        }
      }
      if (min_clip_len > 0) {
        REF=REF.substring(0,ref_len - min_clip_len);
        for (int i=0; i < n; i++) {
          alts[i]=new FlexSeq(alts[i].substring(0,alts[i].length() - min_clip_len));
        }
      }
    }
    byte[] refs=new byte[REF.length()];
    for (int i=0; i < REF.length(); i++) {
      refs[i]=(byte)REF.charAt(i);
    }
    return new Variant(chr,pos,refs.length,refs,alts,phase_val,is_phased,var_id,FILTER,ref_deleted,_rand);
  }
}