##################################
#                                #
# Last modified 2023/09/02       # 
#                                #
# Georgi Marinov                 #
#                                # 
##################################

import sys
import string
import os

def run():

    if len(sys.argv) < 2:
        print 'usage: python %s list outfile' % sys.argv[0]
        sys.exit(1)

    TFlist = sys.argv[1]
    outfilename = sys.argv[2]

    outfile = open(outfilename,'w')

    print TFlist, outfilename

    linelist = open(TFlist)
    for line in linelist:
        TF = line.strip()
        print TF
        outline = '\begin{figure*}[!ht]'
        outfile.write(outline + '\n')
        outline = '\begin{center}'
        outfile.write(outline + '\n')
        outline = '\includegraphics[width=18.5cm]{FigS-atlas-' + TF + '.png}'
        outfile.write(outline + '\n')
        outline = '\end{center}'
        outfile.write(outline + '\n')
        outline = '\captionsetup{singlelinecheck=off,justification=justified}'
        outfile.write(outline + '\n')
        outline = '\caption{'
        outfile.write(outline + '\n')
        outline = '{\bf Properties and genomic distribution of motifs identified for the ' + TF + ' transcription factor}. '
        outfile.write(outline + '\n')
        outline = '(A) Distribution of ChIP-seq peaks over chromHMM states;'
        outfile.write(outline + '\n')
        outline = '(B) Distribution of ChIP-seq peaks over repetitive elements;'
        outfile.write(outline + '\n')
        outline = '(C) TF-MoDISco motifs;'
        outfile.write(outline + '\n')
        outline = '(D) Alignment of TF-MoDISco motifs with the B1H recognition code predictions;'
        outfile.write(outline + '\n')
        outline = '(E) Predicted ChIP-exo profiles around TF-MoDISco motifs;'
        outfile.write(outline + '\n')
        outline = '(F) Distribution of TF-MoDISco motifs over chromHMM states;'
        outfile.write(outline + '\n')
        outline = '(G) Distribution of TF-MoDISco motifs over repetitive elements;'
        outfile.write(outline + '\n')
        outline = '(H) Conservation of TF-MoDISco motifs.'
        outfile.write(outline + '\n')
        outline = '}'
        outfile.write(outline + '\n')
        outline = '\label{FigS-atlas-' + TF + '}'
        outfile.write(outline + '\n')
        outline = '\end{figure*}'
        outfile.write(outline + '\n')
        outfile.write('\n')
        outfile.write('\n')

    outfile.close()


run()

