code: func IsValidRecord(r *Record) bool {
  	if (r.Ref == nil || r.Pos == -1) && r.Flags&Unmapped == 0 {
  		return false
  	}
  	if r.Flags&Paired != 0 && (r.MateRef == nil || r.MatePos == -1) && r.Flags&MateUnmapped == 0 {
  		return false
  	}
  	if r.Flags&(Unmapped|ProperPair) == Unmapped|ProperPair {
  		return false
  	}
  	if r.Flags&(Paired|MateUnmapped|ProperPair) == Paired|MateUnmapped|ProperPair {
  		return false
  	}
  	if len(r.Qual) != 0 && r.Seq.Length != len(r.Qual) {
  		return false
  	}
  	if cigarLen := r.Len(); cigarLen < 0 || (r.Seq.Length != 0 && r.Seq.Length != cigarLen) {
  		return false
  	}
  	return true
  }
docs: // IsValidRecord returns whether the record satisfies the conditions that
  // it has the Unmapped flag set if it not placed; that the MateUnmapped
  // flag is set if it paired its mate is unplaced; that the CIGAR length
  // matches the sequence and quality string lengths if they are non-zero; and
  // that the Paired, ProperPair, Unmapped and MateUnmapped flags are consistent.