#!/bin/bash

fileItemString=$(cat  "sample_file_names.txt" |tr "\n" " ")
sample=($fileItemString)
len=${#sample[@]}
len=$((len-1))

for i in $(seq 0 2 $len); do
        j=$((i+1))
        in1="$PWD/Read_files/${sample[i]}"
        echo $in1
        in2="$PWD/Read_files/${sample[j]}"
	o1="$PWD/mosaik_outputs/s_${sample[i]}.mkb"
	o2="$PWD/mosaik_outputs/ss_${sample[i]}.mka"
        ./MosaikBuild -q $in1 -q2 $in2 -st illumina -out $o1 #-mfl 300  add this parameter for insert size of paired ene data
        ./MosaikAligner -in $o1 -out $o2 -ia main_ref_gene.dat -j main_ref_gene_catalog -p 1 -annpe 2.1.26.pe.100.0065.ann -annse 2.1.26.se.100.005.ann
        o3="$PWD/mosaik_outputs/ss_${sample[i]}.mka.bam"
        o4="$PWD/mosaik_outputs/${sample[i]}.sam"
        samtools view -h -F 4 $o3 > $o4
        rm $o1
        rm $o2
        rm $o3
        o1="$PWD/mosaik_outputs/s_${sample[i]}.mkb.bam"
        rm $o1
        o1="$PWD/mosaik_outputs/ss_${sample[i]}.mka.stat"
        rm $o1
done
echo ""
echo ""
echo ""
echo "This script was successfully run."
echo ""
echo ""

