'See if the input BAM file is sorted from the header information.'

def _is_coordinate_sorted(self, file_name):

    params = ['samtools', 'view', '-H', file_name]
    output = subprocess.Popen(params, stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
    return ((output.find('SO:coordinate') != (-1)) or (output.find('SO:sorted') != (-1)))
