def run_mafft(mafftdir, outputDir, fastaFileList, outputFileNameList,
               startNum, endNum, algorithm):
     # Set up
     import platform
     for i in range(startNum, endNum):
         # Run MAFFT
         if platform.system() == 'Windows':
             mafft_cline = MafftCommandline(os.path.join(
                 mafftdir, 'mafft.bat'),
                                            input=fastaFileList[i])
         else:
             mafft_cline = MafftCommandline(os.path.join(mafftdir, 'mafft'),
                                            input=fastaFileList[i])
         if algorithm != None:
             if algorithm.lower() == 'genafpair':
                 mafft_cline.genafpair = True
             elif algorithm.lower() == 'localpair':
                 mafft_cline.localpair = True
             elif algorithm.lower() == 'globalpair':
                 mafft_cline.globalpair = True
         stdout, stderr = mafft_cline()
         if stdout == '':
             raise Exception('MAFFT error text below' + str(stderr))
         # Process MAFFT output
         stdout = stdout.split('\n')
         while stdout[-1] == '\n' or stdout[-1] == '' or stdout[
                 -1] == 'Terminate batch job (Y/N)?\n':  # Remove junk, sometimes MAFFT will have the 'Terminate ...' line
             del stdout[-1]
         stdout = '\n'.join(stdout)
         # Create output alignment files
         with open(outputFileNameList[i], 'w') as fileOut:
             fileOut.write(stdout)