// Path: src/external/AlignmentResults.java
// public class AlignmentResults
// {
// 	public AlignmentResults()
// 	{
// 		positives = new TreeMap<Integer, Integer>();
// 		negatives = new TreeMap<Integer, Integer>();
// 	}
// 
// 	/**
// 	 * Quality values of alignments that are at the correct location in the
// 	 * genome
// 	 */
// 	public Map<Integer, Integer> positives;
// 	/**
// 	 * Quality values of alignments that are at an incorrect location in the
// 	 * genome.
// 	 */
// 	public Map<Integer, Integer> negatives;
// 	/**
// 	 * Number of fragments that were missing from the tool's output. Always
// 	 * added to false negative counts.
// 	 */
// 	public int missingFragments = 0;
// 	/**
// 	 * Stores time for each operation
// 	 */
// 	public Map<AlignmentOperation, Long> timeMap;
// 
// 	public FilteredAlignmentResults filter(int threshold)
// 	{
// 		int tp = 0;
// 		int tn = 0;
// 		int fp = 0;
// 		int fn = missingFragments;
// 		for (Map.Entry<Integer, Integer> p : positives.entrySet())
// 		{
// 			if (p.getKey() >= threshold)
// 			{
// 				tp += p.getValue();
// 			}
// 			else
// 			{
// 				fn += p.getValue();
// 			}
// 		}
// 		for (Map.Entry<Integer, Integer> n : negatives.entrySet())
// 		{
// 			if (n.getKey() >= threshold)
// 			{
// 				fp += n.getValue();
// 			}
// 			else
// 			{
// 				tn += n.getValue();
// 			}
// 		}
// 		return new FilteredAlignmentResults(threshold, tp, tn, fp, fn);
// 	}
// 
// }
// 
// Path: src/external/AlignmentToolInterface.java
// public static class Options
// {
// 	/**
// 	 * TODO: Examine how good an idea this was
// 	 *
// 	 * @author mruffalo
// 	 */
// 	public static class Reads
// 	{
// 		public Reads(int index_)
// 		{
// 			index = index_;
// 		}
// 
// 		public final int index;
// 		/**
// 		 * The original reads that will be linked into this tool's directory
// 		 */
// 		public File orig_reads;
// 		/**
// 		 * The read file that is used by this tool
// 		 */
// 		public File reads;
// 		/**
// 		 * Not used for every tool
// 		 */
// 		public File binary_reads;
// 		public File aligned_reads;
// 	}
// 
// 	public Options(boolean is_paired_end_, double error_rate_)
// 	{
// 		is_paired_end = is_paired_end_;
// 		error_rate = error_rate_;
// 	}
// 
// 	public File tool_path;
// 	public final boolean is_paired_end;
// 	/**
// 	 * This might be the base call error rate, or the indel size or indel frequency. Always specified as a double even
// 	 * though indel size is an integer -- don't want any NumberFormatExceptions while printing this
// 	 */
// 	public final double error_rate;
// 	/**
// 	 * This is the original genome file that is hardlinked to each tool's directory
// 	 */
// 	public File orig_genome;
// 	/**
// 	 * This is the genome file that is used by each tool
// 	 */
// 	public File genome;
// 	public File binary_genome;
// 	public List<Reads> reads = new ArrayList<Reads>(2);
// 	public File raw_output;
// 	public File sam_output;
// 	public File index;
// 	/**
// 	 * Produced by this code, not the alignment tool
// 	 */
// 	public File converted_output;
// 	public File unmapped_output;
// 	public File roc_output;
// 	public boolean penalize_duplicate_mappings = true;
// 
// 	/**
// 	 * Only used for paired-end. XXX Move this
// 	 */
// 	public int readLength;
// 	/**
// 	 * Only used for paired-end. XXX move this
// 	 */
// 	public double readLengthSd;
// }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import external.AlignmentResults;
import external.AlignmentToolInterface.Options;
import org.apache.log4j.Logger;
				String[] pieces = line.split("\\s+");
				if (pieces.length <= 3)
				{
					continue;
				}
				String fragmentIdentifier = pieces[0];
				int readPosition = -1;
				Matcher m = Constants.READ_POSITION_HEADER.matcher(pieces[0]);
				if (m.matches())
				{
					readPosition = Integer.parseInt(m.group(2));
				}
				int alignedPosition = Integer.parseInt(pieces[3]) - 1;
				if (readPosition == alignedPosition)
				{
					correctlyMappedFragments.add(fragmentIdentifier);
				}
			}
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		return correctlyMappedFragments;
	}

// Path: src/external/AlignmentResults.java
// public class AlignmentResults
// {
// 	public AlignmentResults()
// 	{
// 		positives = new TreeMap<Integer, Integer>();
// 		negatives = new TreeMap<Integer, Integer>();
// 	}
// 
// 	/**
// 	 * Quality values of alignments that are at the correct location in the
// 	 * genome
// 	 */
// 	public Map<Integer, Integer> positives;
// 	/**
// 	 * Quality values of alignments that are at an incorrect location in the
// 	 * genome.
// 	 */
// 	public Map<Integer, Integer> negatives;
// 	/**
// 	 * Number of fragments that were missing from the tool's output. Always
// 	 * added to false negative counts.
// 	 */
// 	public int missingFragments = 0;
// 	/**
// 	 * Stores time for each operation
// 	 */
// 	public Map<AlignmentOperation, Long> timeMap;
// 
// 	public FilteredAlignmentResults filter(int threshold)
// 	{
// 		int tp = 0;
// 		int tn = 0;
// 		int fp = 0;
// 		int fn = missingFragments;
// 		for (Map.Entry<Integer, Integer> p : positives.entrySet())
// 		{
// 			if (p.getKey() >= threshold)
// 			{
// 				tp += p.getValue();
// 			}
// 			else
// 			{
// 				fn += p.getValue();
// 			}
// 		}
// 		for (Map.Entry<Integer, Integer> n : negatives.entrySet())
// 		{
// 			if (n.getKey() >= threshold)
// 			{
// 				fp += n.getValue();
// 			}
// 			else
// 			{
// 				tn += n.getValue();
// 			}
// 		}
// 		return new FilteredAlignmentResults(threshold, tp, tn, fp, fn);
// 	}
// 
// }
// 
// Path: src/external/AlignmentToolInterface.java
// public static class Options
// {
// 	/**
// 	 * TODO: Examine how good an idea this was
// 	 *
// 	 * @author mruffalo
// 	 */
// 	public static class Reads
// 	{
// 		public Reads(int index_)
// 		{
// 			index = index_;
// 		}
// 
// 		public final int index;
// 		/**
// 		 * The original reads that will be linked into this tool's directory
// 		 */
// 		public File orig_reads;
// 		/**
// 		 * The read file that is used by this tool
// 		 */
// 		public File reads;
// 		/**
// 		 * Not used for every tool
// 		 */
// 		public File binary_reads;
// 		public File aligned_reads;
// 	}
// 
// 	public Options(boolean is_paired_end_, double error_rate_)
// 	{
// 		is_paired_end = is_paired_end_;
// 		error_rate = error_rate_;
// 	}
// 
// 	public File tool_path;
// 	public final boolean is_paired_end;
// 	/**
// 	 * This might be the base call error rate, or the indel size or indel frequency. Always specified as a double even
// 	 * though indel size is an integer -- don't want any NumberFormatExceptions while printing this
// 	 */
// 	public final double error_rate;
// 	/**
// 	 * This is the original genome file that is hardlinked to each tool's directory
// 	 */
// 	public File orig_genome;
// 	/**
// 	 * This is the genome file that is used by each tool
// 	 */
// 	public File genome;
// 	public File binary_genome;
// 	public List<Reads> reads = new ArrayList<Reads>(2);
// 	public File raw_output;
// 	public File sam_output;
// 	public File index;
// 	/**
// 	 * Produced by this code, not the alignment tool
// 	 */
// 	public File converted_output;
// 	public File unmapped_output;
// 	public File roc_output;
// 	public boolean penalize_duplicate_mappings = true;
// 
// 	/**
// 	 * Only used for paired-end. XXX Move this
// 	 */
// 	public int readLength;
// 	/**
// 	 * Only used for paired-end. XXX move this
// 	 */
// 	public double readLengthSd;
// }


// Path: src/io/SamReader.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import external.AlignmentResults;
import external.AlignmentToolInterface.Options;
import org.apache.log4j.Logger;

				String[] pieces = line.split("\\s+");
				if (pieces.length <= 3)
				{
					continue;
				}
				String fragmentIdentifier = pieces[0];
				int readPosition = -1;
				Matcher m = Constants.READ_POSITION_HEADER.matcher(pieces[0]);
				if (m.matches())
				{
					readPosition = Integer.parseInt(m.group(2));
				}
				int alignedPosition = Integer.parseInt(pieces[3]) - 1;
				if (readPosition == alignedPosition)
				{
					correctlyMappedFragments.add(fragmentIdentifier);
				}
			}
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		return correctlyMappedFragments;
	}

	public static AlignmentResults readAlignment(Logger log, Options o, int fragmentCount,