<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://genome.sph.umich.edu/w/index.php?action=history&amp;feed=atom&amp;title=830_-_BasicMapper%3A%3Amain%28%29</id>
	<title>830 - BasicMapper::main() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://genome.sph.umich.edu/w/index.php?action=history&amp;feed=atom&amp;title=830_-_BasicMapper%3A%3Amain%28%29"/>
	<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=830_-_BasicMapper::main()&amp;action=history"/>
	<updated>2026-09-26T17:06:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=830_-_BasicMapper::main()&amp;diff=8889&amp;oldid=prev</id>
		<title>Goncalo: Created page with &quot;&lt;source lang=&quot;cpp&quot;&gt;  int main(int argc, char ** argv) { 	// Record start time for this run 	time_t start = time(NULL);  	// This function summarizes available options and proc...&quot;</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=830_-_BasicMapper::main()&amp;diff=8889&amp;oldid=prev"/>
		<updated>2013-10-28T17:29:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  int main(int argc, char ** argv) { 	// Record start time for this run 	time_t start = time(NULL);  	// This function summarizes available options and proc...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char ** argv)&lt;br /&gt;
{&lt;br /&gt;
	// Record start time for this run&lt;br /&gt;
	time_t start = time(NULL);&lt;br /&gt;
&lt;br /&gt;
	// This function summarizes available options and processes command line parameters&lt;br /&gt;
	GreetUser(argc, argv);&lt;br /&gt;
&lt;br /&gt;
	// This function sets up the reference string, with bases ACGT encoded as 1234. &lt;br /&gt;
	LoadReferenceGenome();&lt;br /&gt;
&lt;br /&gt;
	// This function prints a basic summary of the reference genome&lt;br /&gt;
	DescribeReferenceGenome();&lt;br /&gt;
&lt;br /&gt;
	// Build reference genome indices&lt;br /&gt;
	printf(&amp;quot;Building reference indices...\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	String mask1(&amp;#039;1&amp;#039;, indexComplexity), mask0(&amp;#039;0&amp;#039;, indexComplexity), mask;&lt;br /&gt;
&lt;br /&gt;
	MaqIndex index1(reference, mask = mask1 + mask1); printf(&amp;quot;  Built index with mask %s\n&amp;quot;, (const char *) mask);&lt;br /&gt;
	MaqIndex index2(reference, mask = mask1 + mask0 + mask1); printf(&amp;quot;  Built index with mask %s\n&amp;quot;, (const char *) mask);&lt;br /&gt;
	MaqIndex index3(reference, mask = mask1 + mask0 + mask0 + mask1); printf(&amp;quot;  Built index with mask %s\n&amp;quot;, (const char *) mask);&lt;br /&gt;
	printf(&amp;quot;   Done!\n\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Map reads, one at a time&lt;br /&gt;
	FastQ         reads;&lt;br /&gt;
	BestAlignment best;&lt;br /&gt;
	String        buffer;&lt;br /&gt;
&lt;br /&gt;
	int readCount = 0;&lt;br /&gt;
	int mapCount = 0;&lt;br /&gt;
	int mapMismatchesEq0 = 0;&lt;br /&gt;
	int mapMismatchesEq1 = 0;&lt;br /&gt;
	int progress = 0x100000;&lt;br /&gt;
&lt;br /&gt;
	reads.OpenArchive(shortReadFile);&lt;br /&gt;
	IFILE sam = ifopen(samfile.IsEmpty() ? shortReadFile + &amp;quot;.sam&amp;quot; : samfile, &amp;quot;wb&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;Mapping reads\n&amp;quot;);&lt;br /&gt;
	while (!reads.EndOfFile())&lt;br /&gt;
	{&lt;br /&gt;
		reads.Load();&lt;br /&gt;
		best.MaqAlignment(index1, index2, index3, reads);&lt;br /&gt;
&lt;br /&gt;
		if (reads.Length() == 0) continue;&lt;br /&gt;
&lt;br /&gt;
		if (++readCount == progress)&lt;br /&gt;
			printf(&amp;quot;   %d reads mapped so far ...\n&amp;quot;, readCount), progress += 0x100000;&lt;br /&gt;
&lt;br /&gt;
		ReportAlignment(sam, reads, best);&lt;br /&gt;
&lt;br /&gt;
		if (best.mapQ &amp;gt; 30) mapCount++;&lt;br /&gt;
		if (best.mismatches == 0) mapMismatchesEq0++;&lt;br /&gt;
		if (best.mismatches == 1) mapMismatchesEq1++;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	ifclose(sam);&lt;br /&gt;
	reads.CloseArchive();&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;   %d reads processed\n&amp;quot;, readCount);&lt;br /&gt;
	printf(&amp;quot;   %d reads with mapping quality &amp;gt; 30\n&amp;quot;, mapCount);&lt;br /&gt;
	printf(&amp;quot;   %d reads with zero mismatches\n&amp;quot;, mapMismatchesEq0);&lt;br /&gt;
	printf(&amp;quot;   %d reads with one mismatches\n&amp;quot;, mapMismatchesEq1);&lt;br /&gt;
&lt;br /&gt;
	// Log runtime and run date&lt;br /&gt;
	time_t stop = time(NULL);&lt;br /&gt;
	int seconds = (int) (stop - start);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;Run completed in %d hours, %d mins and %d seconds on %s\n&amp;quot;,&lt;br /&gt;
           seconds / 3600, (seconds % 3600) / 60, seconds % 60, ctime(&amp;amp;stop));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Goncalo</name></author>
	</entry>
</feed>