#!/usr/bin/env python

# Standard packages
import sys
import argparse

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('-i', '--input', help="Input SamplesSheet")
    parser.add_argument('-o', '--output', help="Output samples configuration file name")
    parser.add_argument('-p', '--panel', help="Panel name")
    parser.add_argument('-s', '--sequencer', help="Sequencer name")
    parser.add_argument('-r', '--run_id', help="Run ID")
    args = parser.parse_args()
    args.logLevel = "INFO"

    num_samples = 0
    sample_lines = list()
    with open(args.input, 'r') as samples_file:
        for sample_line in samples_file:
            num_samples += 1
            sample_lines.append(sample_line)

    with open(args.output, 'w') as output:
        lib_num = 1
        for sample_line in sample_lines:
            sys.stdout.write("Processing sample line: {}\n".format(sample_line))
            info = sample_line.split(',')
            sample_name = info[1]
            library_name = "{}_S{}".format(sample_name, lib_num)

            sys.stdout.write("Processing library {}\n".format(library_name))
            output.write("[{lib}]\nfastq1: {lib}_L001_R1_001.fastq.gz\n"
                         "fastq2: {lib}_L001_R2_001.fastq.gz\nlibrary_name: {lib}\n"
                         "sample_name: {sample}\nextraction: default\npanel: {panel}\n"
                         "target_pool: {pool}\nsequencer: {seq}\nrun_id: {run}\nnum_libraries_in_run: {num}\n"
                         "".format(lib=library_name, sample=sample_name, panel=args.panel, pool=info[-2],
                                   seq=args.sequencer, run=args.run_id, num=num_samples))

            if info[-2] == 'PoolA':
                output.write("regions: /mnt/shared-data/Resources/MiSeqPanels/tst15-regionsA.bed\n")
                output.write("vcfanno_config: /mnt/shared-data/ddb-configs/annotation/vcfanno_ts15A.conf\n")
            elif info[-2] == 'PoolB':
                output.write("regions: /mnt/shared-data/Resources/MiSeqPanels/tst15-regionsB.bed\n")
                output.write("vcfanno_config: /mnt/shared-data/ddb-configs/annotation/vcfanno_ts15B.conf\n")
            else:
                sys.stderr.write("Sample line {} has unknown pool {}\n".format(sample_line, info[-2]))

            output.write("\n")

            lib_num += 1

@@ -1703,48 +1703,9 @@
 ))%0A%0A
-            if info%5B-2%5D == 'PoolA':%0A    
+%0A
     
@@ -1779,269 +1779,23 @@
 ls/t
-st15-regionsA.bed%5Cn%22)%0A                output.write(%22vcfanno_config: /mnt/shared-data/ddb-configs/annotation/vcfanno_ts15A.conf%5Cn%22)%0A            elif info%5B-2%5D == 'PoolB':%0A                output.write(%22regions: /mnt/shared-data/Resources/MiSeqPanels/tst15-regionsB
+rusight-myeloid
 .bed
@@ -1795,28 +1795,24 @@
 oid.bed%5Cn%22)%0A
-    
             
@@ -1892,143 +1892,26 @@
 anno
-_ts15B.conf%5Cn%22)%0A            else:%0A                sys.stderr.write(%22Sample line %7B%7D has unknown pool %7B%7D%5Cn%22.format(sample_line, info%5B-2%5D)
+-tsmyeloid.conf%5Cn%22
 )%0A%0A 

Add myeloid config creation script