#!/usr/bin/perl
use strict;


###################################################
#
# placeholder, just creates a placeholder page
#   
#
#
#
################################################





###############################################

my $out = "placeholder";
use Getopt::Long;
GetOptions( 
    "out=s"=> \$out,

   "help!"=> \my $help,
 );


if ($help){
    print "usage: $0 daner-file (zipped)

      options:
#        --out           outname

	--help          print this message and exit


 created by Stephan Ripke 2011 at MGH, Boston, MA
 in the frame of the PGC
\n";
    exit 2;
}




###################################################
###  system call with test if successfull
###################################################

sub mysystem(){
    my ($systemstr)="@_";
    system($systemstr);
    my $status = ($? >> 8);
    die "$systemstr\n->system call failed: $status" if ($status != 0);
}



#####################################
# print array to file
####################################

sub a2file {
    my ($file, @lines)=@_;
    die $! unless open FILE, "> $file";
    foreach (@lines){
	print FILE $_;
    }
    close FILE;
}



#############################################
## BEGIN
###############################################

if (-e "/psych/genetics_data/ripke/references_outdated/hapmap_ref/placeholder/placeholder.pdf") {
    print "placeholder.pdf found just copy over\n";
    &mysystem ("cp /psych/genetics_data/ripke/references_outdated/hapmap_ref/placeholder/placeholder.pdf .");
    exit;

}


my $empty_txt = '\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}

\fancyhead{}
\fancyhead[CO,CE]{PLACEHOLDER}

\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage{color}
%\usepackage{ngerman}
\date{\today}
\author{PLACEHOLDER}
\title{PLACEHOLDER}
\begin{document}
\maketitle
\begin{abstract}
{\small This is an empty pdf to keep structure of multi-page pdf-documents; Stephan Ripke, MGH, Boston; ripke (at) atgu mgh harvard edu
}
\end{abstract}

\end{document}' ;


 &a2file ("placeholder.tex",$empty_txt);
 my $systemtex="pdflatex -halt-on-error placeholder.tex ";
 &mysystem ($systemtex);

#exit;
