# Gather all j2me trace filenames
cd j2meTraces
ls $PWD/*/*/data.parsed.txt | sort > filenames
cd ..
# Gather all android trace filenames
cd androidTraces
ls $PWD/*/*/data.trimm.txt | sort > filenames
cd ..

cd j2meTraces
# for each j2me trace file, run the following command to modify the file to append '*' at the start of each line:
$ sh ../bin/append_star.sh TT/0/data.parsed.txt
$ sh ../bin/append_star.sh TT/1/data.parsed.txt
... and so on....
cd ..

For BBs:
# Generate the BBs for j2me and android
$ python bin/common_substring.py j2meTraces/filenames > j2meTraces/bb
$ python bin/common_substring.py androidTraces/filenames > androidTraces/bb

For single line BBs:
python bin/append_start.py j2meTraces/j2meIndpFilenames
python bin/write_single_BB.py j2meTraces/j2meIndpFilenames j2me_indp_bb
python bin/write_single_BB.py androidTraces/androidIndpFileNames android_indp_bb

# Create the script
python create_fullsequence_script.py $PWD/androidTraces/androidIndpFileNames $PWD/j2meTraces/j2meIndpFilenames $PWD/android_indp_bb $PWD/j2me_indp_bb $PWD/output > script.sh

# Run the script for all games
sh script.sh

# ------------------------------------------------------
# If using aggregation, run the aggregate script
# Write the names of num**.txt files in a text file 
$ python bin/script_r.py filenames > allnums

# -------------------- OR ------------------------------

# If using intersection, run the combine script to combine mappings across traces.
# Create an "init" file, having num00n.txt and num00.txt for the first game
# The format is: first line: num00n.txt
# 		second line: num00.txt
# Get the remaining names of num**n.txt num**.txt file in specified format and write those in a text file
# The format is: first line: num**n.txt
# 		second line: num**.txt
$ python bin/combine_across.py ./filenames_all ./init_file cmb_nums cmb_nums_n
# ------------------------------------------------------

# Run the print script to print the mappings in text form.
$ python bin/all_runs_print_mappings_r.py allnums androidTraces/bb j2meTraces/bb allmaps allmapsnums
# -------------------- OR ------------------------------
$ python bin/all_runs_print_mappings_r.py cmb_nums androidTraces/bb j2meTraces/bb cmb_maps cmb_mapsnums
# ------------------------------------------------------

# To find "total number of mappings discovered" by the tool, print the J2ME BB for each mapping, and count unique instances.
$ awk '{ print $1 }' cmb_nums  | sort -u
# To number the building blocks :
$ awk '{ if ($1 ~ /\*\*\*\*\*\*/) { print "**********************", i,  "**********************" ; i = i + 1; } else print $0;  }' j2meTraces/bb > tmp

