<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def input_to_fastq( self, input_file, sample_name, paired_end, fastq_folder, output_file=None, multiclass=False):
 """ Builds a command to convert input file to fastq, for various inputs. Takes either .bam, .fastq.gz, or .fastq input and returns commands that will create the .fastq file, regardless of input type. This is useful to made your pipeline easily accept any of these input types seamlessly, standardizing you to the fastq which is still the most common format for adapter trimmers, etc. It will place the output fastq file in given `fastq_folder`. :param str input_file: filename of input you want to convert to fastq :return str: A command (to be run with PipelineManager) that will ensure your fastq file exists. """


        fastq_prefix = os.path.join(fastq_folder, sample_name)
        self.make_sure_path_exists(fastq_folder)

        # this expects a list; if it gets a string, convert it to a list.
        if type(input_file) != list:
            input_file = [input_file]

        if len(input_file) > 1:
            cmd = []
            output_file = []
            for in_i, in_arg in enumerate(input_file):
                output = fastq_prefix + "_R" + str(in_i + 1) + ".fastq"
                result_cmd, uf, result_file = \
                    self.input_to_fastq(in_arg, sample_name, paired_end,
                                        fastq_folder, output, multiclass=True)
                cmd.append(result_cmd)
                output_file.append(result_file)

        else:
            # There was only 1 input class.
            # Convert back into a string
            input_file = input_file[0]
            if not output_file:
                output_file = fastq_prefix + "_R1.fastq"
            input_ext = self.get_input_ext(input_file)

            if input_ext == ".bam":
                print("Found .bam file")
                #cmd = self.bam_to_fastq(input_file, fastq_prefix, paired_end)
                cmd, fq1, fq2 = self.bam_to_fastq_awk(input_file, fastq_prefix, paired_end)
                # pm.run(cmd, output_file, follow=check_fastq)
            elif input_ext == ".fastq.gz":
                print("Found .fastq.gz file")
                if paired_end and not multiclass:
                    # For paired-end reads in one fastq file, we must split the file into 2.
                    script_path = os.path.join(
                            self.tools.scripts_dir, "fastq_split.py")
                    cmd = self.tools.python + " -u " + script_path
                    cmd += " -i " + input_file
                    cmd += " -o " + fastq_prefix
                    # Must also return the set of output files
                    output_file = [fastq_prefix + "_R1.fastq", fastq_prefix + "_R2.fastq"]
                else:
                    # For single-end reads, we just unzip the fastq.gz file.
                    # or, paired-end reads that were already split.
                    cmd = self.ziptool + " -d -c " + input_file + " > " + output_file
                    # a non-shell version
                    # cmd1 = "gunzip --force " + input_file
                    # cmd2 = "mv " + os.path.splitext(input_file)[0] + " " + output_file
                    # cmd = [cmd1, cmd2]
            elif input_ext == ".fastq":
                cmd = "ln -sf " + input_file + " " + output_file
                print("Found .fastq file; no conversion necessary")

        return [cmd, fastq_prefix, output_file]