// NOTE -- THIS CODE IS SYNCHRONIZED WITH CODE IN THE SAMTOOLS REPOSITORY. CHANGES TO THIS CODE SHOULD BE
// NOTE -- PUSHED BACK TO HENG LI
//
// ####################################################################################################
public int hmm_glocal(final byte[] ref, final byte[] query, int qstart, int l_query, final byte[] _iqual, int[] state, byte[] q) {
if ( ref == null ) throw new ReviewedGATKException("BUG: ref sequence is null");
if ( query == null ) throw new ReviewedGATKException("BUG: query sequence is null");
if ( _iqual == null ) throw new ReviewedGATKException("BUG: query quality vector is null");
if ( query.length != _iqual.length ) throw new ReviewedGATKException("BUG: read sequence length != qual length");
if ( l_query < 1 ) throw new ReviewedGATKException("BUG: length of query sequence < 0: " + l_query);
if ( qstart < 0 ) throw new ReviewedGATKException("BUG: query sequence start < 0: " + qstart);
//if ( q != null && q.length != state.length ) throw new ReviewedGATKException("BUG: BAQ quality length != read sequence length");
//if ( state != null && state.length != l_query ) throw new ReviewedGATKException("BUG: state length != read sequence length");
int i, k;