<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def count_reads(self, file_name, paired_end):
 """ Count reads in a file. Paired-end reads count as 2 in this function. For paired-end reads, this function assumes that the reads are split into 2 files, so it divides line count by 2 instead of 4. This will thus give an incorrect result if your paired-end fastq files are in only a single file (you must divide by 2 again). :param str file_name: Name/path of file whose reads are to be counted. :param bool paired_end: Whether the file contains paired-end reads. """


        _, ext = os.path.splitext(file_name)
        if not (is_sam_or_bam(file_name) or is_fastq(file_name)):
            # TODO: make this an exception and force caller to handle that
            # rather than relying on knowledge of possibility of negative value.
            return -1

        if is_sam_or_bam(file_name):
            param_text = "-c" if ext == ".bam" else "-c -S"
            return self.samtools_view(file_name, param=param_text)
        else:
            num_lines = self.count_lines_zip(file_name) \
                    if is_gzipped_fastq(file_name) \
                    else self.count_lines(file_name)
            divisor = 2 if paired_end else 4
            return int(num_lines) / divisor