#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//#include "nrutil.h"
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <malloc.h>

void usage();


void usage()
{
	printf("usage: produceAln alignment name\n");
	exit(1);
}

int main(int argc, char **argv)
{
	int i,j,k;
	char alnName[20];
	if(argc<2) usage();
	else strcpy(alnName,argv[1]);
	for(i=1;i<=7;i++){
		for(j=1;j<=4;j++){
			char mkdir[20];
			strcpy(mkdir,"mkdir ");
			strcat(mkdir,alnName);
			sprintf(mkdir+strlen(mkdir),"%d",i);
			sprintf(mkdir+strlen(mkdir),"%d",j);
			system(mkdir);
//			printf("%s\n",mkdir);
		}
	}
	for(i=1;i<=7;i++){
		for(j=1;j<=4;j++){
			char chooseSeq[100];
			strcpy(chooseSeq,"/home1/UTSW/wcai/likelihood/chooseSeq -H -i ");
			strcat(chooseSeq,alnName);
			strcat(chooseSeq,".aln -L ");
			sprintf(chooseSeq+strlen(chooseSeq),"%d",i);
			strcat(chooseSeq," -C ");
			sprintf(chooseSeq+strlen(chooseSeq),"%d",j);
			strcat(chooseSeq," -o ");
			strcat(chooseSeq,alnName);
			sprintf(chooseSeq+strlen(chooseSeq),"%d",i);
			sprintf(chooseSeq+strlen(chooseSeq),"%d",j);
			strcat(chooseSeq,"/");
			strcat(chooseSeq,alnName);
			sprintf(chooseSeq+strlen(chooseSeq),"%d",i);
			sprintf(chooseSeq+strlen(chooseSeq),"%d",j);
			strcat(chooseSeq,".aln");
			printf("%s\n",chooseSeq);
			system(chooseSeq);
		}
	}

}
