[med-svn] [soapsnp] 07/09: New upstream version 1.03

Andreas Tille tille at debian.org
Thu Dec 28 07:17:48 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository soapsnp.

commit 2551b17dac9a39ee457db8b709b1922fa48f8f2d
Author: Andreas Tille <tille at debian.org>
Date:   Thu Dec 28 08:16:33 2017 +0100

    New upstream version 1.03
---
 .cproject                     | 943 ++++++++++++++++++++++++++++++++++++++++++
 .main.cc.swp                  | Bin 0 -> 16384 bytes
 .project                      |  82 ++++
 .soap_snp.h.swp               | Bin 0 -> 4096 bytes
 COPYING                       | 674 ++++++++++++++++++++++++++++++
 call_genotype.cc              | 583 ++++++++++++++++++++++++++
 chromosome.cc                 | 220 ++++++++++
 debian/README.Debian          |  10 -
 debian/changelog              |   9 -
 debian/compat                 |   1 -
 debian/control                |  37 --
 debian/copyright              |  28 --
 debian/docs                   |   1 -
 debian/patches/Makefile.patch |  12 -
 debian/patches/series         |   1 -
 debian/rules                  |  11 -
 debian/source/format          |   1 -
 debian/upstream/metadata      |  14 -
 debian/watch                  |   2 -
 main.cc                       | 332 +++++++++++++++
 makefile                      |  18 +
 matrix.cc                     | 219 ++++++++++
 normal_dis.cc                 |  24 ++
 prior.cc                      |  97 +++++
 rank_sum.cc                   | 128 ++++++
 readme                        | 139 +++++++
 release                       |   5 +
 soap_snp.h                    | 326 +++++++++++++++
 28 files changed, 3790 insertions(+), 127 deletions(-)

diff --git a/.cproject b/.cproject
new file mode 100644
index 0000000..de7f5ff
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,943 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?fileVersion 4.0.0?>
+
+<cproject>
+<storageModule moduleId="org.eclipse.cdt.core.settings">
+<cconfiguration id="cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285">
+<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+<externalSettings/>
+<extensions>
+<extension id="org.eclipse.cdt.core.MachO" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+</extensions>
+</storageModule>
+<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+<configuration artifactName="SOAPsnpZ" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285" name="Debug" parent="cdt.managedbuild.config.gnu.macosx.exe.debug">
+<folderInfo id="cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285." name="/" resourcePath="">
+<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.exe.debug.1978207347" name="MacOSX GCC" superClass="cdt.managedbuild.toolchain.gnu.macosx.exe.debug">
+<targetPlatform id="cdt.managedbuild.target.gnu.platform.macosx.exe.debug.1125777963" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.macosx.exe.debug"/>
+<builder buildPath="${workspace_loc:/SOAPsnpZ/Debug}" id="cdt.managedbuild.target.gnu.builder.macosx.exe.debug.911075082" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.macosx.exe.debug"/>
+<tool id="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.debug.1663747892" name="MacOS X C Linker" superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.debug"/>
+<tool id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug.936196069" name="MacOS X C++ Linker" superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug">
+<option id="macosx.cpp.link.option.libs.708891572" name="Libraries (-l)" superClass="macosx.cpp.link.option.libs"/>
+<option id="macosx.cpp.link.option.paths.680167391" name="Library search path (-L)" superClass="macosx.cpp.link.option.paths"/>
+<option id="macosx.cpp.link.option.flags.1361289177" name="Linker flags" superClass="macosx.cpp.link.option.flags" value="-lz" valueType="string"/>
+<inputType id="cdt.managedbuild.tool.macosx.cpp.linker.input.373483947" superClass="cdt.managedbuild.tool.macosx.cpp.linker.input">
+<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+<additionalInput kind="additionalinput" paths="$(LIBS)"/>
+</inputType>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.assembler.macosx.exe.debug.1174633141" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.macosx.exe.debug">
+<option id="gnu.both.asm.option.include.paths.947709760" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths"/>
+<inputType id="cdt.managedbuild.tool.gnu.assembler.input.187024721" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.archiver.macosx.base.1323916831" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug.1741295117" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug">
+<option id="gnu.cpp.compilermacosx.exe.debug.option.optimization.level.1493041622" name="Optimization Level" superClass="gnu.cpp.compilermacosx.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+<option id="gnu.cpp.compiler.macosx.exe.debug.option.debugging.level.342272204" name="Debug Level" superClass="gnu.cpp.compiler.macosx.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+<option id="gnu.cpp.compiler.option.include.paths.118509540" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths"/>
+<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2026577284" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.1387787664" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug">
+<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.macosx.exe.debug.option.optimization.level.306482370" name="Optimization Level" superClass="gnu.c.compiler.macosx.exe.debug.option.optimization.level" valueType="enumerated"/>
+<option id="gnu.c.compiler.macosx.exe.debug.option.debugging.level.1357001896" name="Debug Level" superClass="gnu.c.compiler.macosx.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+<option id="gnu.c.compiler.option.include.paths.222862540" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/>
+<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1983419444" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+</tool>
+</toolChain>
+</folderInfo>
+</configuration>
+</storageModule>
+
+<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
+<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+<storageModule moduleId="scannerConfiguration">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285;cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285.;cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.1387787664;cdt.managedbuild.tool.gnu.c.compiler.input.1983419444">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285;cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285.;cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug.1741295117;cdt.managedbuild.tool.gnu.cpp.compiler.input.2026577284">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.macosx.exe.release.854453692;cdt.managedbuild.config.macosx.exe.release.854453692.;cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release.1950961291;cdt.managedbuild.tool.gnu.cpp.compiler.input.334931143">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.macosx.exe.release.854453692;cdt.managedbuild.config.macosx.exe.release.854453692.;cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release.1252349963;cdt.managedbuild.tool.gnu.c.compiler.input.206594440">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+</storageModule>
+</cconfiguration>
+<cconfiguration id="cdt.managedbuild.config.macosx.exe.release.854453692">
+<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.macosx.exe.release.854453692" moduleId="org.eclipse.cdt.core.settings" name="Release">
+<externalSettings/>
+<extensions>
+<extension id="org.eclipse.cdt.core.MachO" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+</extensions>
+</storageModule>
+<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+<configuration artifactName="SOAPsnpZ" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.macosx.exe.release.854453692" name="Release" parent="cdt.managedbuild.config.macosx.exe.release">
+<folderInfo id="cdt.managedbuild.config.macosx.exe.release.854453692." name="/" resourcePath="">
+<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.exe.release.1638825850" name="MacOSX GCC" superClass="cdt.managedbuild.toolchain.gnu.macosx.exe.release">
+<targetPlatform id="cdt.managedbuild.target.gnu.platform.macosx.exe.release.811269203" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.macosx.exe.release"/>
+<builder buildPath="${workspace_loc:/SOAPsnpZ/Release}" id="cdt.managedbuild.target.gnu.builder.macosx.exe.release.1747082983" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.macosx.exe.release"/>
+<tool id="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.release.1312065018" name="MacOS X C Linker" superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.release"/>
+<tool id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.release.395406591" name="MacOS X C++ Linker" superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.release">
+<option id="macosx.cpp.link.option.flags.219019078" superClass="macosx.cpp.link.option.flags" value="-lz -lm" valueType="string"/>
+<inputType id="cdt.managedbuild.tool.macosx.cpp.linker.input.1853749044" superClass="cdt.managedbuild.tool.macosx.cpp.linker.input">
+<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+<additionalInput kind="additionalinput" paths="$(LIBS)"/>
+</inputType>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.assembler.macosx.exe.release.1177654527" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.macosx.exe.release">
+<inputType id="cdt.managedbuild.tool.gnu.assembler.input.30706935" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.archiver.macosx.base.991069149" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release.1950961291" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release">
+<option id="gnu.cpp.compiler.macosx.exe.release.option.optimization.level.1366968296" name="Optimization Level" superClass="gnu.cpp.compiler.macosx.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+<option id="gnu.cpp.compiler.macosx.exe.release.option.debugging.level.1703173696" name="Debug Level" superClass="gnu.cpp.compiler.macosx.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+<option id="gnu.cpp.compiler.option.optimization.flags.756448933" superClass="gnu.cpp.compiler.option.optimization.flags" value="-ffast-math -funroll-loops -mmmx -msse -msse2 -msse3 -march=nocona" valueType="string"/>
+<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.334931143" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release.1252349963" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release">
+<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.macosx.exe.release.option.optimization.level.412762460" name="Optimization Level" superClass="gnu.c.compiler.macosx.exe.release.option.optimization.level" valueType="enumerated"/>
+<option id="gnu.c.compiler.macosx.exe.release.option.debugging.level.1071333678" name="Debug Level" superClass="gnu.c.compiler.macosx.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+<option id="gnu.c.compiler.option.optimization.flags.1718992490" superClass="gnu.c.compiler.option.optimization.flags" value="-ffast-math -funroll-loops -mmmx -msse -msse2 -msse3 -march=nocona" valueType="string"/>
+<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.206594440" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+</tool>
+</toolChain>
+</folderInfo>
+</configuration>
+</storageModule>
+
+<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
+<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+<storageModule moduleId="scannerConfiguration">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285;cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285.;cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.1387787664;cdt.managedbuild.tool.gnu.c.compiler.input.1983419444">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285;cdt.managedbuild.config.gnu.macosx.exe.debug.1788307285.;cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug.1741295117;cdt.managedbuild.tool.gnu.cpp.compiler.input.2026577284">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.macosx.exe.release.854453692;cdt.managedbuild.config.macosx.exe.release.854453692.;cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release.1950961291;cdt.managedbuild.tool.gnu.cpp.compiler.input.334931143">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.macosx.exe.release.854453692;cdt.managedbuild.config.macosx.exe.release.854453692.;cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release.1252349963;cdt.managedbuild.tool.gnu.c.compiler.input.206594440">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</scannerConfigBuildInfo>
+</storageModule>
+</cconfiguration>
+</storageModule>
+<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+<project id="SOAPsnpZ.cdt.managedbuild.target.macosx.exe.1112108921" name="Executable" projectType="cdt.managedbuild.target.macosx.exe"/>
+</storageModule>
+</cproject>
diff --git a/.main.cc.swp b/.main.cc.swp
new file mode 100644
index 0000000..9dfdec0
Binary files /dev/null and b/.main.cc.swp differ
diff --git a/.project b/.project
new file mode 100644
index 0000000..4d81a5f
--- /dev/null
+++ b/.project
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>SOAPsnpZ</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+			<triggers>clean,full,incremental,</triggers>
+			<arguments>
+				<dictionary>
+					<key>?name?</key>
+					<value></value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.append_environment</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+					<value>all</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.buildArguments</key>
+					<value></value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.buildCommand</key>
+					<value>make</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.buildLocation</key>
+					<value>${workspace_loc:/SOAPsnpZ/Debug}</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+					<value>clean</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.contents</key>
+					<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+					<value>false</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableFullBuild</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+					<value>all</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.stopOnError</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+					<value>true</value>
+				</dictionary>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+		<nature>org.eclipse.cdt.core.ccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+	</natures>
+</projectDescription>
diff --git a/.soap_snp.h.swp b/.soap_snp.h.swp
new file mode 100644
index 0000000..42989e0
Binary files /dev/null and b/.soap_snp.h.swp differ
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/call_genotype.cc b/call_genotype.cc
new file mode 100644
index 0000000..3d1fddb
--- /dev/null
+++ b/call_genotype.cc
@@ -0,0 +1,583 @@
+#include "soap_snp.h"
+#include <cassert>
+
+int Call_win::initialize(ubit64_t start) {
+	std::string::size_type i;
+	for(i=0; i != read_len + win_size ; i++) {
+		sites[i].pos = i+start;
+	}
+	return 1;
+}
+
+int Call_win::deep_init(ubit64_t start) {
+	int i;
+	for(i=0; i != read_len + win_size ; i++) {
+		sites[i].pos = i+start;
+		sites[i].ori = 0xFF;
+		sites[i].depth = 0;
+		sites[i].repeat_time = 0;
+		sites[i].dep_uni = 0;
+		memset(sites[i].count_uni,0,sizeof(int)*4);
+		memset(sites[i].q_sum,0,sizeof(int)*4);
+		memset(sites[i].base_info,0,sizeof(small_int)*4*2*64*256);
+		memset(sites[i].count_all,0,sizeof(int)*4);
+	}
+	return 1;
+}
+
+int Call_win::recycle() {
+	std::string::size_type i;
+	for(i=0; i != read_len ; i++) {
+		sites[i].pos = sites[i+win_size].pos;
+		sites[i].ori = sites[i+win_size].ori;
+		sites[i].depth = sites[i+win_size].depth;
+		sites[i].repeat_time = sites[i+win_size].repeat_time;
+		sites[i].dep_uni = sites[i+win_size].dep_uni;
+		memcpy(sites[i].base_info, sites[i+win_size].base_info, sizeof(small_int)*4*2*64*256); // 4 types of bases, 2 strands, max quality score is 64, and max read length 256
+		memcpy(sites[i].count_uni, sites[i+win_size].count_uni, sizeof(int)*4);
+		memcpy(sites[i].q_sum, sites[i+win_size].q_sum, sizeof(int)*4);
+		memcpy(sites[i].count_all, sites[i+win_size].count_all, sizeof(int)*4);
+	}
+	for(i=read_len; i != read_len+win_size; i++) {
+		sites[i].ori = 0xFF;
+		sites[i].pos = sites[i-1].pos+1;
+		sites[i].depth = 0;
+		sites[i].repeat_time = 0;
+		sites[i].dep_uni = 0;
+		memset(sites[i].count_uni,0,sizeof(int)*4);
+		memset(sites[i].q_sum,0,sizeof(int)*4);
+		memset(sites[i].base_info,0,sizeof(small_int)*4*2*64*256);
+		memset(sites[i].count_all,0,sizeof(int)*4);
+	}
+	return 1;
+}
+
+
+int Call_win::call_cns(Chr_name call_name, Chr_info* call_chr, ubit64_t call_length, Prob_matrix * mat, Parameter * para, std::ofstream & consensus, std::ofstream & baseinfo) {
+	std::string::size_type coord;
+	small_int k;
+	ubit64_t o_base, strand;
+	char allele1, allele2, genotype, type, type1/*best genotype*/, type2/*suboptimal genotype*/, base1, base2, base3;
+	int i, q_score, q_adjusted, qual1, qual2, qual3, q_cns, all_count1, all_count2, all_count3;
+	int global_dep_count, *pcr_dep_count;
+	pcr_dep_count = new int [para->read_length*2];
+	double  rank_sum_test_value, binomial_test_value;
+	bool is_out;
+	double * real_p_prior = new double [16];
+	double * likelihoods = new double [10];
+	memset(likelihoods, 0, sizeof(double)*10);
+	//std::cerr<<"Call length="<<call_length<<endl;
+	for(std::string::size_type j=0; j != call_length; j++){
+		//cerr<<sites[j].pos<<endl;
+		if(para->region_only) {
+		    if (NULL== call_chr->get_region() ) {
+		    	break;
+		    }
+		    else if (! call_chr->is_in_region(sites[j].pos)) {
+				continue;
+		    }
+		    else {
+		    	;
+		    }
+		}
+		sites[j].ori = (call_chr->get_bin_base(sites[j].pos))&0xF;
+		if( ((sites[j].ori&4) !=0)/*an N*/ && sites[j].depth == 0) {
+			// CNS text format:
+			// ChrID\tPos\tRef\tCns\tQual\tBase1\tAvgQ1\tCountUni1\tCountAll1\tBase2\tAvgQ2\tCountUni2\tCountAll2\tDepth\tRank_sum\tCopyNum\tSNPstauts\n"
+			if(!para->glf_format && ! para->is_snp_only) {
+				consensus<<call_name<<'\t'<<(sites[j].pos+1)<<"\tN\tN\t0\tN\t0\t0\t0\tN\t0\t0\t0\t0\t1.000\t255.000\t0"<<endl;
+			}
+			else if (para->glf_format) {
+				memset(likelihoods, 0, sizeof(double)*10);
+				consensus.write(reinterpret_cast<char*>(likelihoods), sizeof(double)*10);
+				consensus<<flush;
+				if(!consensus.good()) {
+					cerr<<"Broken ofstream after writting Position "<<(sites[j].pos+1)<<" at "<<call_name<<endl;
+					exit(255);
+				}
+				baseinfo<<call_name<<'\t'<<(sites[j].pos+1)<<"\tN\tN\t0\tN\t0\t0\t0\tN\t0\t0\t0\t0\t1.000\t255.000\t0"<<endl;
+			}
+			else {
+				;
+			}
+			continue;
+		}
+		base1 = 0, base2 = 0, base3 = 0;
+		qual1 = -1, qual2= -2, qual3 = -3;
+		all_count1 = 0, all_count2 =0, all_count3 =0;
+		if(sites[j].dep_uni) {
+			// This position is uniquely covered by at least one nucleotide
+			for(i=0;i!=4;i++) {
+				// i is four kind of alleles
+				if(sites[j].q_sum[i] >= qual1) {
+					base3 = base2;
+					qual3 = qual2;
+					base2 = base1;
+					qual2 = qual1;
+					base1 = i;
+					qual1 = sites[j].q_sum[i];
+				}
+				else if (sites[j].q_sum[i]>=qual2) {
+					base3 = base2;
+					qual3 = qual2;
+					base2 = i;
+					qual2  = sites[j].q_sum[i];
+				}
+				else if (sites[j].q_sum[i]>=qual3) {
+					base3 = i;
+					qual3  = sites[j].q_sum[i];
+				}
+				else {
+					;
+				}
+			}
+			if(qual1 == 0) {
+				// Adjust the best base so that things won't look ugly if the pos is not covered
+				base1 = (sites[j].ori&7);
+			}
+			else if(qual2 ==0 && base1 != (sites[j].ori&7)) {
+				base2 = (sites[j].ori&7);
+			}
+			else {
+				;
+			}
+		}
+		else {
+			// This position is covered by all repeats
+			for(i=0;i!=4;i++) {
+				if(sites[j].count_all[i] >= all_count1) {
+					base3 = base2;
+					all_count3 = all_count2;
+					base2 = base1;
+					all_count2 = all_count1;
+					base1 = i;
+					all_count1 = sites[j].count_all[i];
+				}
+				else if (sites[j].count_all[i]>=all_count2) {
+					base3 = base2;
+					all_count3 = all_count2;
+					base2 = i;
+					all_count2  = sites[j].count_all[i];
+				}
+				else if (sites[j].count_all[i]>=all_count3) {
+					base3 = i;
+					all_count3  = sites[j].count_all[i];
+				}
+				else {
+					;
+				}
+			}
+			if(all_count1 ==0) {
+				base1 = (sites[j].ori&7);
+			}
+			else if(all_count2 ==0 && base1 != (sites[j].ori&7)) {
+				base2 = (sites[j].ori&7);
+			}
+			else {
+				;
+			}
+		}
+		// Calculate likelihood
+		for(genotype=0;genotype!=16;genotype++){
+			mat->type_likely[genotype] = 0.0;
+		}
+		for(o_base=0;o_base!=4;o_base++) {
+			//cerr<<o_base<<endl;
+			if(sites[j].count_uni[o_base]==0) {continue;}
+			global_dep_count = -1;
+			memset(pcr_dep_count, 0, sizeof(int)*2*para->read_length);
+			for(q_score=para->q_max-para->q_min; q_score != -1; q_score--) {
+				for(coord=0; coord != para->read_length; coord++) {
+					for(strand=0; strand!=2; strand++) {
+						for(k=0; k!=sites[j].base_info[o_base<<15|strand<<14|q_score<<8|coord];k++) {
+							if(pcr_dep_count[strand*para->read_length+coord]==0) {
+								global_dep_count += 1;
+								//if(sites[j].pos == 250948) {
+								//	cerr<<'g'<<global_dep_count<<'\t';//fprintf(stderr, "Now:%c\t\t%le\t%le\t%le\n", abbv[allele1<<2|allele2], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base], mat->type_likely[allele1<<2|allele2]);
+								//}
+							}
+							pcr_dep_count[strand*para->read_length+coord] += 1;
+							//if(sites[j].pos == 250948) {
+							//	cerr<<'p'<<pcr_dep_count[strand*para->read_length+coord]<<'\t';//fprintf(stderr, "Now:%c\t\t%le\t%le\t%le\n", abbv[allele1<<2|allele2], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base], mat->type_likely[allele1<<2|allele2]);
+							//}
+							q_adjusted = int( pow(10, (log10(q_score) +(pcr_dep_count[strand*para->read_length+coord]-1)*para->pcr_dependency +global_dep_count*para->global_dependency)) +0.5);
+							if(q_adjusted < 1) {
+								q_adjusted = 1;
+							}
+							for(allele1 = 0;allele1 != 4;allele1++ ) {
+								for(allele2 = allele1; allele2 != 4; allele2++) {
+									mat->type_likely[allele1<<2|allele2] += log10(0.5*mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base] +0.5*mat->p_matrix[((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base]);
+									//if(sites[j].pos == 52100) {
+									//	cerr<<"Now:"<<abbv[allele1<<2|allele2]<<'\t'<<mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base]<<'\t'<<mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base]<<'\t'<<mat->type_likely[allele1<<2|allele2]<<endl;
+									//}
+								}
+							}
+							//if(sites[j].pos == 250948) {
+							//	cerr<<q_score<<'\t'<<q_adjusted<<'\t'<<coord<<'_'<<strand<<'\t'<<"ACTG"[o_base]<<'\t'<<mat->type_likely[0]<<'\t'<<mat->type_likely[5]<<'\t'<<mat->type_likely[10]<<'\t'<<mat->type_likely[15]<<endl;//fprintf(stderr, "Now:%c\t\t%le\t%le\t%le\n", abbv[allele1<<2|allele2], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base], mat->type_likely[allele1<<2|allele2]);
+							//}
+						}
+					}
+				}
+			}
+		}
+
+		if(para->glf_format) {
+			for(int i=0; i!=10; i++) {
+				consensus.write(reinterpret_cast<char*>(&mat->type_likely[glf_type_code[i]]), sizeof(double));
+			}
+			consensus<<flush;
+			if(!consensus.good()) {
+				cerr<<"Broken ofstream after writting Position "<<(sites[j].pos+1)<<" at "<<call_name<<endl;
+				exit(255);
+			}
+			//continue;
+		}
+		// Calculate Posterior Probability
+		memcpy(real_p_prior, &mat->p_prior[((ubit64_t)sites[j].ori&0x7)<<4], sizeof(double)*16);
+		if ( (sites[j].ori & 0x8) && para->refine_mode) {
+			// a dbSNP
+			snp_p_prior_gen(real_p_prior, call_chr->find_snp(sites[j].pos), para, sites[j].ori);
+		}
+		memset(mat->type_prob,0,sizeof(rate_t)*17);
+		type2=type1=16;
+		for (allele1=0; allele1!=4; allele1++) {
+			for (allele2=allele1; allele2!=4; allele2++) {
+				genotype = allele1<<2|allele2;
+				if (para->is_monoploid && allele1 != allele2) {
+					continue;
+				}
+				mat->type_prob[genotype] = mat->type_likely[genotype] + log10(real_p_prior[genotype]) ;
+
+				if (mat->type_prob[genotype] >= mat->type_prob[type1] || type1 == 16) {
+					type2 = type1;
+					type1 = genotype;
+				}
+				else if (mat->type_prob[genotype] >= mat->type_prob[type2] || type2 ==16) {
+					type2 = genotype;
+				}
+				else {
+					;
+				}
+			}
+		}
+		is_out = true; // Check if the position needs to be output, useful in snp-only mode
+
+		if (para->rank_sum_mode) {
+			rank_sum_test_value = rank_test(sites[j], type1, mat->p_rank, para);
+		}
+		else {
+			rank_sum_test_value = 1.0;
+		}
+		if(rank_sum_test_value==0.0) {
+			// avoid double genotype overflow
+			q_cns = 0;
+		}
+		else {
+			q_cns = (int)(10*(mat->type_prob[type1]-mat->type_prob[type2])+10*log10(rank_sum_test_value));
+		}
+
+		if ( (type1&3) == ((type1>>2)&3)) { // Called Homozygous
+			if (qual1>0 && base1 != (type1&3)) {
+				//Wired: best base is not the consensus!
+				q_cns = 0;
+			}
+			else if (/*qual2>0 &&*/ q_cns > qual1-qual2) {
+				// Should not bigger than this
+				q_cns = qual1-qual2;
+			}
+			else {
+				;
+			}
+		}
+		else {	// Called Heterozygous
+			if(sites[j].q_sum[base1]>0 && sites[j].q_sum[base2]>0 && type1 == (base1<base2 ? (base1<<2|base2):(base2<<2|base1))) {
+				// The best bases are in the heterozygote
+				if (q_cns > qual2-qual3) {
+					q_cns = qual2-qual3;
+				}
+			}
+			else {	// Ok, wired things happened
+				q_cns = 0;
+			}
+		}
+		if(q_cns>99) {
+			q_cns = 99;
+		}
+		if (q_cns<0) {
+			q_cns = 0;
+		}
+		if(! para->glf_format) {
+			// ChrID\tPos\tRef\tCns\tQual\tBase1\tAvgQ1\tCountUni1\tCountAll1\tBase2\tAvgQ2\tCountUni2\tCountAll2\tDepth\tRank_sum\tCopyNum\tSNPstauts\n"
+			if(! para->is_snp_only || (abbv[type1] != "ACTGNNNN"[(sites[j].ori&0x7)] && sites[j].depth > 0)) {
+				if(base1<4 && base2<4) {
+					consensus<<call_name<<'\t'<<(sites[j].pos+1)<<'\t'<<("ACTGNNNN"[(sites[j].ori&0x7)])<<'\t'<<abbv[type1]<<'\t'<<q_cns<<'\t'
+					<<("ACTGNNNN"[base1])<<'\t'<<(sites[j].q_sum[base1]==0?0:sites[j].q_sum[base1]/sites[j].count_uni[base1])<<'\t'<<sites[j].count_uni[base1]<<'\t'<<sites[j].count_all[base1]<<'\t'
+					<<("ACTGNNNN"[base2])<<'\t'<<(sites[j].q_sum[base2]==0?0:sites[j].q_sum[base2]/sites[j].count_uni[base2])<<'\t'<<sites[j].count_uni[base2]<<'\t'<<sites[j].count_all[base2]<<'\t'
+					<<sites[j].depth<<'\t'<<showpoint<<rank_sum_test_value<<'\t'<<(sites[j].depth==0?255:(double)(sites[j].repeat_time)/sites[j].depth)<<'\t'<<((sites[j].ori&8)?1:0)<<endl;
+				}
+				else if(base1<4) {
+					consensus<<call_name<<'\t'<<(sites[j].pos+1)<<'\t'<<("ACTGNNNN"[(sites[j].ori&0x7)])<<'\t'<<abbv[type1]<<'\t'<<q_cns<<'\t'
+					<<("ACTGNNNN"[base1])<<'\t'<<(sites[j].q_sum[base1]==0?0:sites[j].q_sum[base1]/sites[j].count_uni[base1])<<'\t'<<sites[j].count_uni[base1]<<'\t'<<sites[j].count_all[base1]<<'\t'
+					<<"N\t0\t0\t0\t"
+					<<sites[j].depth<<'\t'<<showpoint<<rank_sum_test_value<<'\t'<<(sites[j].depth==0?255:(double)(sites[j].repeat_time)/sites[j].depth)<<'\t'<<((sites[j].ori&8)?1:0)<<endl;
+				}
+				else {
+					consensus<<call_name<<'\t'<<(sites[j].pos+1)<<"\tN\tN\t0\tN\t0\t0\t0\tN\t0\t0\t0\t0\t1.000\t255.000\t0"<<endl;
+				}
+			}
+		}
+		else {
+			if(base1<4 && base2<4) {
+				baseinfo<<call_name<<'\t'<<(sites[j].pos+1)<<'\t'<<("ACTGNNNN"[(sites[j].ori&0x7)])<<'\t'<<abbv[type1]<<'\t'<<q_cns<<'\t'
+					<<("ACTGNNNN"[base1])<<'\t'<<(sites[j].q_sum[base1]==0?0:sites[j].q_sum[base1]/sites[j].count_uni[base1])<<'\t'<<sites[j].count_uni[base1]<<'\t'<<sites[j].count_all[base1]<<'\t'
+					<<("ACTGNNNN"[base2])<<'\t'<<(sites[j].q_sum[base2]==0?0:sites[j].q_sum[base2]/sites[j].count_uni[base2])<<'\t'<<sites[j].count_uni[base2]<<'\t'<<sites[j].count_all[base2]<<'\t'
+					<<sites[j].depth<<'\t'<<showpoint<<rank_sum_test_value<<'\t'<<(sites[j].depth==0?255:(double)(sites[j].repeat_time)/sites[j].depth)<<'\t'<<((sites[j].ori&8)?1:0)<<endl;
+			}
+			else if(base1<4) {
+				baseinfo<<call_name<<'\t'<<(sites[j].pos+1)<<'\t'<<("ACTGNNNN"[(sites[j].ori&0x7)])<<'\t'<<abbv[type1]<<'\t'<<q_cns<<'\t'
+					<<("ACTGNNNN"[base1])<<'\t'<<(sites[j].q_sum[base1]==0?0:sites[j].q_sum[base1]/sites[j].count_uni[base1])<<'\t'<<sites[j].count_uni[base1]<<'\t'<<sites[j].count_all[base1]<<'\t'
+					<<"N\t0\t0\t0\t"
+					<<sites[j].depth<<'\t'<<showpoint<<rank_sum_test_value<<'\t'<<(sites[j].depth==0?255:(double)(sites[j].repeat_time)/sites[j].depth)<<'\t'<<((sites[j].ori&8)?1:0)<<endl;
+			}
+			else {
+				baseinfo<<call_name<<'\t'<<(sites[j].pos+1)<<"\tN\tN\t0\tN\t0\t0\t0\tN\t0\t0\t0\t0\t1.000\t255.000\t0"<<endl;
+			}
+		}
+		//if(sites[j].pos == 250949) {
+		//	exit(1);
+		//}
+	}
+	delete [] real_p_prior;
+	delete [] pcr_dep_count;
+	delete [] likelihoods;
+	return 1;
+}
+
+int Call_win::soap2cns(std::ifstream & alignment, std::ofstream & consensus, std::ofstream & baseinfo, Genome * genome, Prob_matrix * mat, Parameter * para) {
+	Soap_format soap;
+	map<Chr_name, Chr_info*>::iterator current_chr, prev_chr;
+	current_chr = prev_chr = genome->chromosomes.end();
+	int coord, sub;
+	int last_start(0);
+	bool recycled(false);
+	for(std::string line; getline(alignment, line);) {
+		std::istringstream s(line);
+		if( s>> soap ) {
+			//cerr<<"A"<<soap.get_pos()<<endl;
+			//exit(1);
+			if(soap.get_pos() < 0) {
+				continue;
+			}
+			if (current_chr == genome->chromosomes.end() || current_chr->first != soap.get_chr_name()) {
+				if(current_chr != genome->chromosomes.end() ) {
+					recycled = false;
+					while(current_chr->second->length() > sites[win_size-1].pos) {
+						if (!para->region_only || current_chr->second->is_in_region_win(last_start)) {
+							//cerr<<"at"<<soap.get_pos()<<"Called"<<last_start<<endl;
+							if(last_start > sites[win_size-1].pos) {
+								initialize((last_start/win_size)*win_size);
+							}
+							call_cns(current_chr->first, current_chr->second, win_size, mat, para, consensus, baseinfo);
+							last_start = sites[win_size-1].pos;
+							recycled = false;
+						}
+						if (!para->region_only) {
+							//cerr<<"recycled"<<last_start<<endl;
+							recycle();
+							recycled = true;
+							last_start = sites[win_size-1].pos;
+						}
+						else if (!recycled) {
+							//cerr<<"recycled"<<" "<<last_start<<endl;
+							if (last_start>(sites[win_size-1].pos)) {
+								cerr<<"Unexpected "<<last_start<<">"<<(sites[win_size-1].pos)<<endl;
+								exit(1);
+								if ((last_start+1)%win_size!=0) {
+									cerr<<"Assertion Error!"<<last_start<<">"<<sites[win_size-1].pos<<endl;
+									exit(1);
+								}
+								initialize(last_start-win_size+1);
+							}
+							else {
+								if (current_chr->second->is_in_region_win(sites[win_size].pos)) {
+									recycle();
+								}
+								else {
+									deep_init(sites[win_size].pos);
+								}
+							}
+							recycled = true;
+							last_start = sites[win_size-1].pos;
+						}
+						else {
+							assert((last_start+1)%win_size==0);
+							last_start += win_size;
+						}
+					}
+					// The last window
+					if(last_start > sites[win_size-1].pos) {
+						initialize((last_start/win_size)*win_size);
+					}
+					call_cns(current_chr->first, current_chr->second, current_chr->second->length()%win_size, mat, para, consensus, baseinfo);
+				}
+				current_chr = genome->chromosomes.find(soap.get_chr_name());
+				initialize(0);
+				last_start = 0;
+				cerr<<"Processing "<<current_chr->first<<endl;
+			}
+			else {
+				;
+			}
+			if (soap.get_pos()+soap.get_read_len()>=current_chr->second->length()) {
+				continue;
+			}
+			if (para->region_only && (current_chr->second->get_region() == NULL || !current_chr->second->is_in_region(soap.get_pos()))) {
+				continue;
+			}
+			if(soap.get_pos() < last_start) {
+				cerr<<"Errors in sorting:"<<soap.get_pos()<<"<"<<last_start<<endl;
+				exit(255);
+			}
+			recycled = false;
+			while (soap.get_pos()/win_size > last_start/win_size ) {
+				if (!para->region_only || current_chr->second->is_in_region_win(last_start)) {
+					//cerr<<"at"<<soap.get_pos()<<"Called"<<last_start<<endl;
+					if(last_start > sites[win_size-1].pos) {
+						initialize((last_start/win_size)*win_size);
+					}
+					call_cns(current_chr->first, current_chr->second, win_size, mat, para, consensus, baseinfo);
+					last_start = sites[win_size-1].pos;
+					recycled = false;
+				}
+				if (!para->region_only) {
+					//cerr<<"recycled"<<last_start<<endl;
+					recycle();
+					recycled = true;
+					last_start = sites[win_size-1].pos;
+				}
+				else if (!recycled) {
+					//cerr<<"recycled"<<" "<<last_start<<endl;
+					if (last_start>(sites[win_size-1].pos)) {
+						cerr<<"Unexpected "<<last_start<<">"<<(sites[win_size-1].pos)<<endl;
+						exit(1);
+						if ((last_start+1)%win_size!=0) {
+							cerr<<"Assertion Error!"<<last_start<<">"<<sites[win_size-1].pos<<endl;
+							exit(1);
+						}
+						initialize(last_start-win_size+1);
+					}
+					else {
+						if (current_chr->second->is_in_region_win(sites[win_size].pos)) {
+							recycle();
+						}
+						else {
+							deep_init(sites[win_size].pos);
+						}
+					}
+					recycled = true;
+					last_start = sites[win_size-1].pos;
+				}
+				else {
+					assert((last_start+1)%win_size==0);
+					last_start += win_size;
+				}
+				//if ((last_start+1)/win_size==1000) {
+				//	cerr<<"Called "<<last_start;
+				//}
+			}
+			//cerr<<"die"<<endl;
+			//exit(1);
+			last_start=soap.get_pos();
+			for(coord=0; coord<soap.get_read_len(); coord++){
+				if( (soap.get_pos()+coord)/win_size == soap.get_pos()/win_size ) {
+					// In the same sliding window
+					sub = (soap.get_pos()+coord) % win_size;
+				}
+				else {
+					sub = (soap.get_pos()+coord) % win_size + win_size; // Use the tail to store the info so that it won't intervene the uncalled bases
+				}
+				sites[sub].depth += 1;
+				sites[sub].repeat_time += soap.get_hit();
+				if((soap.is_N(coord)) || soap.get_qual(coord)<para->q_min || sites[sub].dep_uni >= 0xFF) {
+					// An N, low quality or meaningless huge depth
+					continue;
+				}
+				if(soap.get_hit() == 1) {
+					//exit((fprintf(stderr, "Wo Cao!\n")));
+					sites[sub].dep_uni += 1;
+					// Update the covering info: 4x2x64x64 matrix, base x strand x q_score x read_pos, 2-1-6-6 bits for each
+					if(soap.is_fwd()) {
+						// Binary strand: 0 for plus and 1 for minus
+						sites[sub].base_info[(((ubit64_t)(soap.get_base(coord)&0x6)|0))<<14 | ((ubit64_t)(soap.get_qual(coord)-para->q_min))<<8 | coord ] += 1;
+					}
+					else {
+						sites[sub].base_info[(((ubit64_t)(soap.get_base(coord)&0x6)|1))<<14 | ((ubit64_t)(soap.get_qual(coord)-para->q_min))<<8 | (soap.get_read_len()-1-coord) ] += 1;
+
+					}
+					sites[sub].count_uni[(soap.get_base(coord)>>1)&3] += 1;
+					sites[sub].q_sum[(soap.get_base(coord)>>1)&3] += (soap.get_qual(coord)-para->q_min);
+				}
+				else {
+					;// Repeats
+				}
+				sites[sub].count_all[(soap.get_base(coord)>>1)&3] += 1;
+			}
+		}
+	}
+
+//The unprocessed tail of chromosome
+	recycled = false;
+	while(current_chr->second->length() > sites[win_size-1].pos) {
+		if (!para->region_only || current_chr->second->is_in_region_win(last_start)) {
+			//cerr<<"at"<<soap.get_pos()<<"Called"<<last_start<<endl;
+			if(last_start > sites[win_size-1].pos) {
+				initialize((last_start/win_size)*win_size);
+			}
+			call_cns(current_chr->first, current_chr->second, win_size, mat, para, consensus, baseinfo);
+			last_start = sites[win_size-1].pos;
+			recycled = false;
+		}
+		if (!para->region_only) {
+			//cerr<<"recycled"<<last_start<<endl;
+			recycle();
+			recycled = true;
+			last_start = sites[win_size-1].pos;
+		}
+		else if (!recycled) {
+			//cerr<<"recycled"<<" "<<last_start<<endl;
+			if (last_start>(sites[win_size-1].pos)) {
+				cerr<<"Unexpected "<<last_start<<">"<<(sites[win_size-1].pos)<<endl;
+				exit(1);
+				if ((last_start+1)%win_size!=0) {
+					cerr<<"Assertion Error!"<<last_start<<">"<<sites[win_size-1].pos<<endl;
+					exit(1);
+				}
+				initialize(last_start-win_size+1);
+			}
+			else {
+				if (current_chr->second->is_in_region_win(sites[win_size].pos)) {
+					recycle();
+				}
+				else {
+					deep_init(sites[win_size].pos);
+				}
+			}
+			recycled = true;
+			last_start = sites[win_size-1].pos;
+		}
+		else {
+			assert((last_start+1)%win_size==0);
+			last_start += win_size;
+		}
+	}
+// The last window
+	if(last_start > sites[win_size-1].pos) {
+		initialize((last_start/win_size)*win_size);
+	}
+	call_cns(current_chr->first, current_chr->second, current_chr->second->length()%win_size, mat, para, consensus, baseinfo);
+
+	alignment.close();
+	consensus.close();
+	baseinfo.close();
+	return 1;
+}
diff --git a/chromosome.cc b/chromosome.cc
new file mode 100644
index 0000000..056e6fd
--- /dev/null
+++ b/chromosome.cc
@@ -0,0 +1,220 @@
+#include "soap_snp.h"
+
+bool Genome::add_chr(Chr_name & name) {
+	Chr_info * new_chr = new Chr_info;
+	pair<map<Chr_name, Chr_info*>::iterator, bool> insert_pair;
+	insert_pair=chromosomes.insert(pair<Chr_name, Chr_info*>(name,new_chr));
+	return insert_pair.second;
+}
+
+Genome::~Genome(){
+	for( map<Chr_name, Chr_info*>::iterator iter=chromosomes.begin(); iter!= chromosomes.end(); iter++ ){
+		;
+	}
+}
+Chr_info::Chr_info(const Chr_info & other) {
+	dbsnp = other.dbsnp;
+	len = other.len;
+	if (len%capacity==0) {
+		bin_seq = new ubit64_t [len/capacity];
+		memcpy(bin_seq, other.bin_seq, sizeof(ubit64_t)*len/capacity);
+	}
+	else {
+		bin_seq = new ubit64_t [1+len/capacity];
+		memcpy(bin_seq, other.bin_seq, sizeof(ubit64_t)*len/capacity);
+	}
+}
+
+int Chr_info::binarize(std::string & seq) {
+	len = seq.length();
+	//cerr<<len<<endl;
+	// 4bit for each base
+	// Allocate memory
+	if (len%capacity==0) {
+		bin_seq = new ubit64_t [len/capacity];
+		memset(bin_seq,0,sizeof(ubit64_t)*len/capacity);
+	}
+	else {
+		bin_seq = new ubit64_t [1+len/capacity];
+		memset(bin_seq,0,sizeof(ubit64_t)*(1+len/capacity));
+	}
+
+	// Add each base, 7 is 0b111
+	for(std::string::size_type i=0;i!=seq.length();i++) {
+		bin_seq[i/capacity] |= ((((ubit64_t)seq[i]>>1)&7)<<(i%capacity*4));
+	}
+	return 1;
+}
+
+int Chr_info::insert_snp(std::string::size_type pos, Snp_info & snp_form) {
+	Snp_info * new_snp = new Snp_info;
+	*new_snp = snp_form;
+	pair<map<ubit64_t, Snp_info*>::iterator, bool> insert_pair;
+	insert_pair = dbsnp.insert(pair<ubit64_t, Snp_info*>(pos,new_snp));
+	if(insert_pair.second) {
+		// Successful insertion
+		// Modify the binary sequence! Mark SNPs
+		bin_seq[pos/capacity] |= (1ULL<<(pos%capacity*4+3));
+	}
+	else {
+		cerr<<"Warning: Snp insertion failed\t"<<pos<<endl;
+		return 0;
+	}
+	return 1;
+}
+
+int Chr_info::set_region(int start, int end) {
+	if(start<0) {
+		start = 0;
+	}
+	else if (start >= len) {
+		start = len;
+	}
+
+	if(end<0) {
+		end = 0;
+	}
+	else if (end >= len) {
+		end = len;
+	}
+	if (start > end) {
+		cerr<<"Invalid region: "<<start<<"-"<<end<<endl;
+		exit(255);
+	}
+	// Specific mask
+	if(start/64 == end/64) {
+		region_mask[start/64] |= ((~((~(0ULL))<<(end-start+1)))<<(63-end%64));
+	}
+	else {
+		if(start % 64) {
+			region_mask[start/64] |= (~((~(0ULL))<<(64-start%64)));
+		}
+		else {
+			region_mask[start/64] = ~(0ULL);
+		}
+		region_mask[end/64] |= ((~(0ULL))<<(63-end%64));
+		if(end/64-start/64>1) {
+			memset(region_mask+start/64+1, 0xFF, sizeof(ubit64_t)*(end/64-start/64-1));
+		}
+	}
+	// Window mask
+	start /= global_win_size; end /= global_win_size;
+	//cerr<<start<<"\t"<<end<<endl;
+	if(start/64 == end/64) {
+		region_win_mask[start/64] |= ((~((~(0ULL))<<(end-start+1)))<<(63-end%64));
+	}
+	else {
+		if(start % 64) {
+			region_win_mask[start/64] |= (~((~(0ULL))<<(64-start%64)));
+		}
+		else {
+			region_win_mask[start/64] = ~(0ULL);
+		}
+		region_win_mask[end/64] |= ((~(0ULL))<<(63-end%64));
+		if(end/64-start/64>1) {
+			memset(region_win_mask+start/64+1, 0xFF, sizeof(ubit64_t)*(end/64-start/64-1));
+		}
+	}
+	return 1;
+}
+
+int Chr_info::region_mask_ini(){
+	//Specific mask
+	if(len%64==0) {
+		region_mask = new ubit64_t [len/64];
+		memset(region_mask, 0, sizeof(ubit64_t)*(len/64));
+	}
+	else {
+		region_mask = new ubit64_t [len/64+1];
+		memset(region_mask, 0, sizeof(ubit64_t)*(len/64+1));
+	}
+	//Window mask
+	int win_len = len/global_win_size +1;
+	if(win_len%64==0) {
+		region_win_mask = new ubit64_t [win_len/64];
+		memset(region_win_mask, 0, sizeof(ubit64_t)*(win_len/64));
+	}
+	else {
+		region_win_mask = new ubit64_t [win_len/64+1];
+		memset(region_win_mask, 0, sizeof(ubit64_t)*(win_len/64+1));
+	}
+	return 1;
+}
+
+int Genome::read_region(std::ifstream & region, Parameter * para) {
+	Chr_name current_name(""), prev_name("");
+	int start, end;
+	map<Chr_name, Chr_info*>::iterator chr_iter;
+	for(std::string buff;getline(region,buff);) {
+		std::istringstream s(buff);
+		if(s>>current_name>>start>>end) {
+			if(current_name != prev_name) {
+				chr_iter = chromosomes.find(current_name);
+				if(chr_iter == chromosomes.end()) {
+					cerr<<"Unexpected Chromosome:"<<current_name<<endl;
+					continue;
+				}
+				if(NULL == chr_iter->second->get_region()) {
+					chr_iter->second->region_mask_ini();
+				}
+			}
+			chr_iter->second->set_region(start-para->read_length, end-1);
+			prev_name = current_name;
+		}
+		else {
+			cerr<<"Wrong format in target region file"<<endl;
+			return 0;
+		}
+	}
+	return 1;
+}
+
+Genome::Genome(std::ifstream &fasta, std::ifstream & known_snp) {
+	std::string seq("");
+	Chr_name current_name("");
+	map<Chr_name, Chr_info*>::iterator chr_iter;
+	for(std::string buff;getline(fasta,buff);) {
+		if('>' == buff[0]) {
+			// Fasta id
+			// Deal with previous chromosome
+			if( chromosomes.find(current_name) != chromosomes.end()) {
+				chr_iter = chromosomes.find(current_name);
+				chr_iter->second->binarize(seq);
+			}
+			// Insert new chromosome
+			std::string::size_type i;
+			for(i=1;!isspace(buff[i]) && i != buff.length();i++) {
+				;
+			}
+			Chr_name new_chr_name(buff,1,i-1);
+			if(! add_chr(new_chr_name)) {
+				std::cerr<<"Insert Chromosome "<<new_chr_name<<" Failed!\n";
+			}
+			current_name = new_chr_name;
+			seq = "";
+		}
+		else {
+			seq += buff;
+		}
+	}
+	if(seq.length() != 0 && chromosomes.find(current_name) != chromosomes.end()) {
+		chr_iter = chromosomes.find(current_name);
+		chr_iter->second->binarize(seq);
+	}
+	if( known_snp ) {
+		Chr_name current_name;
+		Snp_info snp_form;
+		std::string::size_type pos;
+		for(std::string buff;getline(known_snp, buff);) {
+			// Format: Chr\tPos\thapmap?\tvalidated?\tis_indel?\tA\tC\tT\tG\trsID\n
+			std::istringstream s(buff);
+			s>>current_name>>pos;
+			s>>snp_form;
+			if( chromosomes.find(current_name) != chromosomes.end()) {
+				// The SNP is located on an valid chromosme
+				pos -= 1; // Coordinates starts from 0
+				(chromosomes.find(current_name)->second)->insert_snp(pos, snp_form);
+			}
+		}
+	}
+}
diff --git a/debian/README.Debian b/debian/README.Debian
deleted file mode 100644
index 754e8ef..0000000
--- a/debian/README.Debian
+++ /dev/null
@@ -1,10 +0,0 @@
-soapsnp for Debian
-------------------
-
-** PACKAGING IS NOT YET COMPLETED **
-
-Ideas for improvements of this package:
- * platform-specific optimisations
- * we should have some public use cases together with getData
-
- -- Steffen Moeller <moeller at debian.org>  Sun, 22 Apr 2012 01:26:41 +0200
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 7ed88b8..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,9 +0,0 @@
-soapsnp (1.03-1) UNRELEASED; urgency=low
-
-  [ Steffen Moeller ]
-  * Initial release (Closes: #nnnn)
-
-  [ Andreas Tille ]
-  * cme
-
- -- Steffen Moeller <moeller at debian.org>  Sun, 22 Apr 2012 01:26:41 +0200
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index f599e28..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-10
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 617bccc..0000000
--- a/debian/control
+++ /dev/null
@@ -1,37 +0,0 @@
-Source: soapsnp
-Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
-Uploaders: Steffen Moeller <moeller at debian.org>
-Section: science
-Priority: optional
-Build-Depends: debhelper (>= 10),
-               libboost-iostreams-dev
-Standards-Version: 4.1.2
-Vcs-Browser: https://anonscm.debian.org/viewvc/debian-med/trunk/packages/soap/soapsnp/trunk
-Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/soap/soapsnp/trunk
-Homepage: http://soap.genomics.org.cn/soapsnp.html
-
-Package: soapsnp
-Architecture: any
-Depends: ${shlibs:Depends},
-         ${misc:Depends}
-Suggests: genomics.cn-soapsnp
-Description: <insert up to 60 chars description>
- For getting ideas on the cause of diseases or their response to
- therapy, and for understanding either for a particular patient,
- doctors around the globe are starting to look at the genes or the
- whole genome and how that sequence is different from a healthy /
- well responding individual.
- .
- SOAPsnp is a member of the SOAP (Short Oligonucleotide Analysis
- Package). The program is a resequencing utility. It assembles the
- consensus sequence for the genome of a newly sequenced individual based
- on the alignment of the raw sequencing reads on a known reference. SNPs
- can then be identified on the consensus sequence through the comparison
- with the reference.
- .
- SOAPsnp uses a method based on Bayes' theorem (the reverse probability
- model) to call consensus genotype by carefully considering the data
- quality, alignment, and recurring experimental errors. All these kinds
- of information was integrated into a single quality score for each base
- in PHRED scale to measure the accuracy of consensus calling. Currently,
- it supports the alignment format of SOAPaligner (soap2).
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index b2d0b99..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,28 +0,0 @@
-Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: soapsnp
-Source: <url://example.com>
-
-Files: *
-Copyright: 2008  BGI shenzhen <soap at genomics.org.cn>
-License: GPL-3.0+
-
-Files: debian/*
-Copyright: 2012 Steffen Moeller <moeller at debian.org>
-License: GPL-3.0+
-
-License: GPL-3.0+
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- .
- This package is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
- .
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- .
- On Debian systems, the complete text of the GNU General
- Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index 8178c76..0000000
--- a/debian/docs
+++ /dev/null
@@ -1 +0,0 @@
-readme
diff --git a/debian/patches/Makefile.patch b/debian/patches/Makefile.patch
deleted file mode 100644
index d89a5d0..0000000
--- a/debian/patches/Makefile.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-Index: soapsnp-1.03/makefile
-===================================================================
---- soapsnp-1.03.orig/makefile	2009-05-25 09:49:19.000000000 +0200
-+++ soapsnp-1.03/makefile	2012-04-22 01:27:43.714978426 +0200
-@@ -1,6 +1,6 @@
- DEFINE =
- CXX = g++
--CXXFLAGS = -fomit-frame-pointer -O3 -ffast-math -funroll-loops -mmmx -msse -msse2 -msse3 -fmessage-length=0  #-MMD -MP -MF #-g3 -Wall -maccumulate-outgoing-args
-+CXXFLAGS = -fomit-frame-pointer -O3 -ffast-math -funroll-loops #-mmmx -msse -msse2 -msse3 -fmessage-length=0  #-MMD -MP -MF #-g3 -Wall -maccumulate-outgoing-args
- 
- LFLAGS = -lz
- 
diff --git a/debian/patches/series b/debian/patches/series
deleted file mode 100644
index 5b1c0a4..0000000
--- a/debian/patches/series
+++ /dev/null
@@ -1 +0,0 @@
-Makefile.patch
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index e57588d..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/make -f
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-%:
-	dh $@ 
-
-get-orig-source:
-	mkdir -p ../tarballs
-	uscan --verbose --force-download --destdir=../tarballs
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/upstream/metadata b/debian/upstream/metadata
deleted file mode 100644
index 6651c34..0000000
--- a/debian/upstream/metadata
+++ /dev/null
@@ -1,14 +0,0 @@
-Contact: soap at genomics.org.cn
-Homepage: http://soap.genomics.org.cn/soapsnp.html
-Reference:
- DOI: 10.1101/gr.088013.108
- Eprint: http://genome.cshlp.org/content/19/6/1124.full.pdf+html
- Journal: Genome Res.
- PMID: 19420381
- Author: Li R and Li Y and Fang X and Yang H and Wang J and Kristiansen K and Wang J.
- Title: SNP detection for massively parallel whole-genome resequencing
- URL: http://genome.cshlp.org/content/19/6/1124.long
- Year: 2009
- Volume: 19
- Number: 6
- Pages: 1124-1132
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index 5a50eee..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,2 +0,0 @@
-version=3
-http://soap.genomics.org.cn/soapsnp.html down/SOAPsnp-v(.*)\.tar\.gz
diff --git a/main.cc b/main.cc
new file mode 100644
index 0000000..055537c
--- /dev/null
+++ b/main.cc
@@ -0,0 +1,332 @@
+#include "soap_snp.h"
+#include <getopt.h>
+
+using namespace std;
+
+int usage() {
+	cerr<<"SoapSNP"<<endl;
+	cerr<<"Compulsory Parameters:"<<endl;
+	cerr<<"-i <FILE> Input SORTED Soap Result"<<endl;
+	cerr<<"-d <FILE> Reference Sequence in fasta format"<<endl;
+	cerr<<"-o <FILE> Output consensus file"<<endl;
+	cerr<<"Optional Parameters:(Default in [])"<<endl;
+	cerr<<"-z <Char> ASCII chracter standing for quality==0 [@]"<<endl;
+	cerr<<"-g <Double> Global Error Dependency Coefficient, 0.0(complete dependent)~1.0(complete independent)[0.9]"<<endl;
+	cerr<<"-p <Double> PCR Error Dependency Coefficient, 0.0(complete dependent)~1.0(complete independent)[0.5]"<<endl;
+	cerr<<"-r <Double> novel altHOM prior probability [0.0005]"<<endl;
+	cerr<<"-e <Double> novel HET prior probability [0.0010]"<<endl;
+	cerr<<"-t set transition/transversion ratio to 2:1 in prior probability"<<endl;
+	cerr<<"-s <FILE> Pre-formated dbSNP information"<<endl;
+	cerr<<"-2 specify this option will REFINE SNPs using dbSNPs information [Off]"<<endl;
+	cerr<<"-a <Double> Validated HET prior, if no allele frequency known [0.1]"<<endl;
+	cerr<<"-b <Double> Validated altHOM prior, if no allele frequency known[0.05]"<<endl;
+	cerr<<"-j <Double> Unvalidated HET prior, if no allele frequency known [0.02]"<<endl;
+	cerr<<"-k <Double> Unvalidated altHOM rate, if no allele frequency known[0.01]"<<endl;
+	cerr<<"-u Enable rank sum test to give HET further penalty for better accuracy. [Off]"<<endl;
+	//cerr<<"-n Enable binomial probability calculation to give HET for better accuracy. [Off]"<<endl;
+	cerr<<"-m Enable monoploid calling mode, this will ensure all consensus as HOM and you probably should SPECIFY higher altHOM rate. [Off]"<<endl;
+	cerr<<"-q Only output potential SNPs. Useful in Text output mode. [Off]"<<endl;
+	cerr<<"-M <FILE> Output the quality calibration matrix; the matrix can be reused with -I if you rerun the program"<<endl;
+	cerr<<"-I <FILE> Input previous quality calibration matrix. It cannot be used simutaneously with -M"<<endl;
+	cerr<<"-L <short> maximum length of read [45]"<<endl;
+	cerr<<"-Q <short> maximum FASTQ quality score [40]"<<endl;
+	cerr<<"-F <int> Output format. 0: Text; 1: GLFv2; 2: GPFv2.[0]"<<endl;
+	cerr<<"-E <String> Extra headers EXCEPT CHROMOSOME FIELD specified in GLFv2 output. Format is \"TypeName1:DataName1:TypeName2:DataName2\"[""]"<<endl;
+	cerr<<"-T <FILE> Only call consensus on regions specified in FILE. Format: ChrName\\tStart\\tEnd."<<endl;
+	//cerr<<"-S <FILE> Output summary of consensus"<<endl;
+	cerr<<"-h Display this help"<<endl;
+	exit(1);
+	return 0;
+}
+
+int readme() {
+	return usage();
+}
+
+int main ( int argc, char * argv[]) {
+	// This part is the default values of all parameters
+	Parameter * para = new Parameter;
+	std::string alignment_name, consensus_name("");
+	bool is_matrix_in = false; // Generate the matrix or just read it?
+	int c;
+	Files files;
+	while((c=getopt(argc,argv,"i:d:o:z:g:p:r:e:ts:2a:b:j:k:unmqM:I:L:Q:S:F:E:T:h")) != -1) {
+		switch(c) {
+			case 'i':
+			{
+				// Soap Alignment Result
+				files.soap_result.clear();
+				files.soap_result.open(optarg);
+				if( ! files.soap_result) {
+					cerr<<"No such file or directory:"<<optarg<<endl;
+					exit(1);
+				}
+				alignment_name = optarg;
+				break;
+			}
+			case 'd':
+			{
+				// The reference genome in fasta format
+				files.ref_seq.clear();
+				files.ref_seq.open(optarg);
+				if( ! files.ref_seq) {
+					cerr<<"No such file or directory:"<<optarg<<endl;
+					exit(1);
+				}
+				files.ref_seq.clear();
+				break;
+			}
+			case 'o':
+			{
+				consensus_name = optarg;
+				break;
+			}
+			case 'z':
+			{
+				// The char stands for quality==0 in fastq format
+				para->q_min = optarg[0];
+				if(para->q_min == 33) {
+					clog<<"Standard Fastq System Set"<<endl;
+				}
+				else if(para->q_min == 64) {
+					clog<<"Illumina Fastq System Set"<<endl;
+				}
+				else {
+					clog<<"Other types of Fastq files?? Are you sure?"<<endl;
+				}
+				para->q_max = para->q_min + 40;
+				break;
+			}
+			case 'g':
+			{
+				para->global_dependency= log10(atof(optarg));
+				break;
+			}
+			case 'p':
+			{
+				para->pcr_dependency= log10(atof(optarg));
+				break;
+			}
+			case 'r':
+			{
+				para->althom_novel_r = atof(optarg);
+				break;
+			}
+			case 'e':
+			{
+				para->het_novel_r=atof(optarg);
+				break;
+			}
+			case 't':
+			{
+				para->transition_dominant=true;
+				break;
+			}
+			case 's':
+			{
+				// Optional: A pre-formated dbSNP table
+				files.dbsnp.clear();
+				files.dbsnp.open(optarg);
+				if( ! files.ref_seq) {
+					cerr<<"No such file or directory:"<<optarg<<endl;
+					exit(1);
+				}
+				files.dbsnp.clear();
+				break;
+			}
+			case '2':
+			{
+				// Refine prior probability based on dbSNP information
+				para->refine_mode = true;
+				break;
+			}
+			case 'a':
+			{
+				para->althom_val_r=atof(optarg);
+				break;
+			}
+			case 'b':
+			{
+				para->het_val_r=atof(optarg);
+				break;
+			}
+			case 'j':
+			{
+				para->althom_unval_r=atof(optarg);
+				break;
+			}
+			case 'k':
+			{
+				para->het_unval_r=atof(optarg);
+				break;
+			}
+			case 'u':
+			{
+				para->rank_sum_mode = true;
+				break;
+			}
+			case 'n':
+			{
+				para->binom_mode = true;
+				break;
+			}
+		 	case 'm':
+			{
+				para->is_monoploid=1;
+				break;
+			}
+			case 'q':
+			{
+				para->is_snp_only=1;
+				break;
+			}
+			case 'M':
+			{
+				files.matrix_file.close(); files.matrix_file.clear();
+				// Output the calibration matrix
+				files.matrix_file.open(optarg, fstream::out);
+				if( ! files.matrix_file) {
+					cerr<<"Cannot creat file :"<<optarg<<endl;
+					exit(1);
+				}
+				files.matrix_file.clear();
+				break;
+			}
+			case 'I':
+			{
+				files.matrix_file.close(); files.matrix_file.clear();
+				// Input the calibration matrix
+				files.matrix_file.open(optarg, fstream::in);
+				if( ! files.matrix_file) {
+					cerr<<"No such file or directory:"<<optarg<<endl;
+					exit(1);
+				}
+				files.matrix_file.clear();
+				is_matrix_in = true;
+				break;
+			}
+			case 'S':
+			{
+				//files.summary.open(optarg);
+				//// Output the summary of consensus
+				//if( ! files.summary ) {
+				//	cerr<<"No such file or directory: "<<optarg<<endl;
+				//	exit(1);
+				//}
+				break;
+			}
+			case 'L':
+			{
+				para->read_length = atoi(optarg);
+				break;
+			}
+			case 'Q':
+			{
+				para->q_max = optarg[0];
+				if(para->q_max < para->q_min) {
+					cerr<< "FASTQ quality character error: Q_MAX > Q_MIN" <<endl;
+				}
+				break;
+			}
+			case 'F': {
+				para->glf_format = atoi(optarg);
+				break;
+			}
+			case 'E': {
+				para->glf_header = optarg;
+				break;
+			}
+			case 'T': {
+				files.region.clear();
+				files.region.open(optarg);
+				files.region.clear();
+				para->region_only = true;
+				break;
+			}
+			case 'h':readme();break;
+			case '?':usage();break;
+			default: cerr<<"Unknown error in command line parameters"<<endl;
+		}
+	}
+	if( consensus_name=="" || !files.ref_seq || !files.soap_result ) {
+		// These are compulsory parameters
+		usage();
+	}
+	if ( ! para->glf_format ) {
+		// Normal SOAPsnp tab-delimited text format
+		files.consensus.clear();
+		files.consensus.open(consensus_name.c_str());
+		if( ! files.consensus ) {
+			cerr<<"Cannot creat file:" <<consensus_name<<endl;
+			exit(1);
+		}
+		files.consensus.clear();
+	}
+	else {
+		// SOAPsnp-defined GLF and baseinfo format
+		files.consensus.clear();
+		files.consensus.open(consensus_name.c_str(), ios::binary);
+		if(!files.consensus) {
+			cerr<<"Cannot creat file:" <<consensus_name<<endl;
+			exit(1);
+		}
+		files.consensus.clear();
+
+		files.baseinfo.clear();
+		string baseinfo_name = consensus_name + ".baseinfo";
+		files.baseinfo.open(baseinfo_name.c_str());
+		if(!files.baseinfo) {
+			cerr<<"Cannot creat file:" <<baseinfo_name<<endl;
+			exit(1);
+		}
+		files.baseinfo.clear();
+
+		files.o_region.clear();
+		string o_region_name = consensus_name + ".index";
+		files.o_region.open(o_region_name.c_str());
+		if(!files.o_region) {
+			cerr<<"Cannot creat file:" <<o_region_name<<endl;
+			exit(1);
+		}
+		files.o_region.clear();
+	}
+
+	//Read the chromosomes into memory
+	Genome * genome = new Genome(files.ref_seq, files.dbsnp);
+	files.ref_seq.close();
+	files.dbsnp.close();
+	clog<<"Reading Chromosome and dbSNP information Done."<<endl;
+	if(para->region_only && files.region) {
+		genome->read_region(files.region, para);
+		clog<<"Read target region done."<<endl;
+	}
+
+	Prob_matrix * mat = new Prob_matrix;
+	if( ! is_matrix_in) {
+		//Read the soap result and give the calibration matrix
+		mat->matrix_gen(files.soap_result, para, genome);
+		if (files.matrix_file) {
+			mat->matrix_write(files.matrix_file, para);
+		}
+	}
+	else {
+		mat->matrix_read(files.matrix_file, para);
+	}
+	files.matrix_file.close();
+	clog<<"Correction Matrix Done!"<<endl;
+	mat->prior_gen(para);
+	mat->rank_table_gen();
+	Call_win info(para->read_length);
+	info.initialize(0);
+	//Call the consensus
+	files.soap_result.close();
+	files.soap_result.clear();
+	files.soap_result.open(alignment_name.c_str());
+	files.soap_result.clear();
+	info.soap2cns(files.soap_result, files.consensus, files.baseinfo, genome, mat, para);
+	files.soap_result.close();
+	files.consensus.close();
+	cerr<<"Consensus Done!"<<endl;
+	return 0;
+}
+
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..b92bc7c
--- /dev/null
+++ b/makefile
@@ -0,0 +1,18 @@
+DEFINE =
+CXX = g++
+CXXFLAGS = -fomit-frame-pointer -O3 -ffast-math -funroll-loops -mmmx -msse -msse2 -msse3 -fmessage-length=0  #-MMD -MP -MF #-g3 -Wall -maccumulate-outgoing-args
+
+LFLAGS = -lz
+
+all: soapsnp
+.PHONY: all
+
+objects: call_genotype.o chromosome.o matrix.o normal_dis.o prior.o rank_sum.o main.o
+$(objects): %.o: soap_snp.h makefile
+
+soapsnp: call_genotype.o chromosome.o matrix.o normal_dis.o prior.o rank_sum.o main.o makefile
+	$(CXX) $(CXXFLAGS) call_genotype.o chromosome.o matrix.o normal_dis.o prior.o rank_sum.o main.o -o soapsnp $(LFLAGS)
+
+.PHONY: clean
+clean:
+	rm -f *.o soapsnp
diff --git a/matrix.cc b/matrix.cc
new file mode 100644
index 0000000..f6cbcc5
--- /dev/null
+++ b/matrix.cc
@@ -0,0 +1,219 @@
+#include "soap_snp.h"
+Prob_matrix::Prob_matrix(){
+	int i;
+	p_matrix = new rate_t [256*256*4*4]; // 8bit: q_max, 8bit: read_len, 4bit: number of types of all mismatch/match 4x4
+	p_prior = new rate_t [8*4*4]; // 8(ref ACTGNNNN) * diploid(4x4)
+	base_freq = new rate_t [4]; // 4 base
+	type_likely = new rate_t [16+1]; //The 17th element rate_t[16] will be used in comparison
+	type_prob = new rate_t [16+1];
+	p_rank = new rate_t [64*64*2048]; // 6bit: N; 5bit: n1; 11bit; T1
+	p_binom = new rate_t [256*256]; // Total * case
+	for(i=0;i!=256*256*4*4;i++) {
+		p_matrix[i] = 1.0;
+	}
+	for(i=0;i!=8*4*4;i++) {
+		p_prior[i] = 1.0;
+	}
+	for(i=0;i!=4;i++) {
+		base_freq[i] = 1.0;
+	}
+	for(i=0;i!=16+1;i++) {
+		type_likely[i] = 0.0; // LOG10 Scale
+		type_prob[i] = 0.0; // LOG10 Scale
+	}
+	for(i=0;i!=64*64*2048;i++) {
+		p_rank[i] = 1.0;
+	}
+	for(i=0;i!=256*256;i++) {
+		p_binom[i] = 1.0;
+	}
+}
+
+Prob_matrix::~Prob_matrix(){
+	delete [] p_matrix; // 8bit: q_max, 8bit: read_len, 4bit: number of types of all mismatch/match 4x4
+	delete [] p_prior; // 8(ref ACTGNNNN) * diploid(4x4)
+	delete [] base_freq; // 4 base
+	delete [] type_likely; //The 17th element rate_t[16] will be used in comparison
+	delete [] type_prob;
+	delete [] p_rank; // 6bit: N; 5bit: n1; 11bit; T1
+	delete [] p_binom; // Total * case;
+}
+
+int Prob_matrix::matrix_gen(std::ifstream & alignment, Parameter * para, Genome * genome) {
+	// Read Alignment files
+	Soap_format soap;
+	ubit64_t * count_matrix = new ubit64_t [256*256*4*4];
+	map<Chr_name, Chr_info*>::iterator current_chr;
+	current_chr = genome->chromosomes.end();
+	ubit64_t ref(0);
+	std::string::size_type coord;
+	for(std::string line; getline(alignment, line);) {
+		std::istringstream s(line);
+		if( s>> soap ) {
+			if(soap.get_pos() < 0) {
+				continue;
+			}
+			//cerr<<soap<<endl;
+			// In the overloaded "+" above, soap.position will be substracted by 1 so that coordiates start from 0
+			if (current_chr == genome->chromosomes.end() || current_chr->first != soap.get_chr_name()) {
+				current_chr = genome->chromosomes.find(soap.get_chr_name());
+				if(current_chr == genome->chromosomes.end()) {
+					for(map<Chr_name, Chr_info*>::iterator test = genome->chromosomes.begin();test != genome->chromosomes.end();test++) {
+						cerr<<'!'<<(test->first)<<'!'<<endl;
+					}
+					cerr<<"Assertion Failed: Chromosome: !"<<soap.get_chr_name()<<"! NOT found"<<endl;
+					exit(255);
+				}
+			}
+			else {
+				;
+			}
+			if (soap.get_pos()+soap.get_read_len()>=current_chr->second->length()) {
+				continue;
+			}
+			if (soap.is_unique()) {
+				for(coord = 0; coord != soap.get_read_len(); coord++) {
+					if (soap.is_N(coord)) {
+						;
+					}
+					else {
+						if(! (soap.get_pos()+coord<current_chr->second->length())) {
+							cerr<<soap<<endl;
+							cerr<<"The program found the above read has exceed the reference length:\n";
+							cerr<<"The read is aligned to postion: "<<soap.get_pos()<<" with read length: "<<soap.get_read_len()<<endl;
+							cerr<<"Reference: "<<current_chr->first<<" FASTA Length: "<<current_chr->second->length()<<endl;
+							exit(255);
+						}
+						ref = current_chr->second->get_bin_base(soap.get_pos()+coord);
+						if ( (ref&12) !=0 ) {
+							// This is an N on reference or a dbSNP which should be excluded from calibration
+							;
+						}
+						else {
+							if(soap.is_fwd()) {
+								// forward strand
+								count_matrix[(((ubit64_t)soap.get_qual(coord))<<12) | (coord<<4) | ((ref&0x3)<<2) | (soap.get_base(coord)>>1)&3] += 1;
+							}
+							else {
+								// reverse strand
+								count_matrix[(((ubit64_t)soap.get_qual(coord))<<12) | ((soap.get_read_len()-1-coord)<<4) | ((ref&0x3)<<2) | (soap.get_base(coord)>>1)&3] += 1;
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	ubit64_t o_base/*o_based base*/, t_base/*theorecical(supposed) base*/, type, sum[4], same_qual_count_by_type[16], same_qual_count_by_t_base[4], same_qual_count_total, same_qual_count_mismatch;
+	char q_char/*fastq quality char*/;
+
+	const ubit64_t sta_pow=10; // minimum number to say statistically powerful
+	for(q_char=para->q_min; q_char<=para->q_max ;q_char++) {
+		memset(same_qual_count_by_type, 0, sizeof(ubit64_t)*16);
+		memset(same_qual_count_by_t_base, 0, sizeof(ubit64_t)*4);
+		same_qual_count_total = 0;
+		same_qual_count_mismatch = 0;
+		for(coord=0; coord != para->read_length ; coord++) {
+			for(type=0;type!=16;type++) {
+				// If the sample is small, then we will not consider the effect of read cycle.
+				same_qual_count_by_type[type] += count_matrix[ ((ubit64_t)q_char<<12) | coord <<4 | type];
+				same_qual_count_by_t_base[(type>>2)&3] += count_matrix[ ((ubit64_t)q_char<<12) | coord <<4 | type];
+				same_qual_count_total += count_matrix[ ((ubit64_t)q_char<<12) | coord <<4 | type];
+				//cerr<<(int)type<<'\t'<<same_qual_count_by_type[type]<<'\t'<<same_qual_count_by_t_base[0]<<endl;
+				if(type % 5 != 0) {
+					// Mismatches
+					same_qual_count_mismatch += count_matrix[ ((ubit64_t)q_char<<12) | coord <<4 | type];
+				}
+			}
+		}
+		for(coord=0; coord != para->read_length ; coord++) {
+			//cerr<<(q_char)<<'\t'<<coord;
+			memset(sum, (ubit64_t)0, sizeof(ubit64_t)*4);
+			// Count of all ref base at certain coord and quality
+			for(type=0;type!=16;type++) {
+				sum[(type>>2)&3] += count_matrix[ ((ubit64_t)q_char<<12) | (coord <<4) | type]; // (type>>2)&3: the ref base
+				//cerr<<sum[type&3]<<endl;
+			}
+			for(t_base=0; t_base!=4; t_base++) {
+				for(o_base=0; o_base!=4; o_base++) {
+					//cerr<<'\t'<<count_matrix[ ((ubit64_t)q_char<<12) | (coord <<4) | (t_base<<2) | o_base];
+					if (count_matrix[ ((ubit64_t)q_char<<12) | (coord <<4) | (t_base<<2) | o_base] > sta_pow) {
+						// Statistically powerful
+						p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = ((double)count_matrix[ ((ubit64_t)q_char<<12) | (coord <<4) | (t_base<<2) | o_base]) / sum[t_base];
+					}
+					else if (same_qual_count_by_type[t_base<<2|o_base] > sta_pow) {
+						// Smaller sample, given up effect from read cycle
+						p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] =  ((double)same_qual_count_by_type[t_base<<2|o_base]) / same_qual_count_by_t_base[t_base];
+					}
+					else if (same_qual_count_total > 0){
+						// Too small sample, given up effect of mismatch types
+						if (o_base == t_base) {
+							p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = ((double)(same_qual_count_total-same_qual_count_mismatch))/same_qual_count_total;
+						}
+						else {
+							p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = ((double)same_qual_count_mismatch)/same_qual_count_total;
+						}
+					}
+					else {
+						;
+					}
+
+					// For these cases like:
+					// Ref: G o_base: G x10 Ax5. When calculate the probability of this allele to be A,
+					// If there's no A in reference gives observation of G, then the probability will be zero,
+					// And therefore exclude the possibility of this pos to have an A
+					// These cases should be avoid when the dataset is large enough
+					// If no base with certain quality is o_based, it also doesn't matter
+					if( (p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base]==0) || p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] ==1) {
+						if (o_base == t_base) {
+							p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = (1-pow(10, -((q_char-para->q_min)/10.0)));
+							if(p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base]<0.25) {
+								p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = 0.25;
+							}
+						}
+						else {
+							p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = (pow(10, -((q_char-para->q_min)/10.0))/3);
+							if(p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base]>0.25) {
+								p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = 0.25;
+							}
+						}
+					}
+				}
+			}
+		}
+		//cerr<<'\t'<<same_qual_count_by_type[0]<<'\t'<<same_qual_count_by_t_base[0]<<endl;
+	}
+	delete [] count_matrix;
+
+	//memset(&p_matrix[((ubit64_t)para->q_max-para->q_min+1)<<12], 0, 256*256*4*4 - (para->q_max-para->q_min+1)*256*4*4);
+	// Note: from now on, the first 8 bit of p_matrix is its quality score, not the FASTQ char
+	return 1;
+}
+
+int Prob_matrix::matrix_read(std::fstream &mat_in, Parameter * para) {
+	int q_char, type;
+	std::string::size_type coord;
+	for(std::string line; getline(mat_in, line);) {
+		std::istringstream s(line);
+		s>>q_char>>coord;
+		for(type=0;type!=16;type++) {
+			s>>p_matrix [ ((ubit64_t)q_char<<12) | (coord <<4) | type];
+			//cerr<<q_char<<"|"<<coord<<"|"<<p_matrix [ ((ubit64_t)q_char<<12) | (coord <<4) | type]<<endl;
+			//exit(0);
+		}
+	}
+	return 1;
+}
+
+int Prob_matrix::matrix_write(std::fstream &mat_out, Parameter * para) {
+	for( char q_char = para->q_min; q_char <= para->q_max; q_char++ ) {
+		for( std::string::size_type coord=0; coord != para->read_length; coord++) {
+			mat_out<<((ubit64_t)q_char-para->q_min)<<'\t'<<coord;
+			for(char type=0;type!=16;type++) {
+				mat_out<<'\t'<<scientific<<showpoint<<setprecision(16)<<p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | type];
+			}
+			mat_out<<endl;
+		}
+	}
+	return 1;
+}
diff --git a/normal_dis.cc b/normal_dis.cc
new file mode 100644
index 0000000..2ac0d8d
--- /dev/null
+++ b/normal_dis.cc
@@ -0,0 +1,24 @@
+#include "soap_snp.h"
+
+double Call_win::normal_value(double z) {
+	if (z>6.0 || z<-6.0) {
+		return 0.0;
+	}
+	else {
+		double b1 = 0.31938153;
+		double b2 = -0.356563782;
+		double b3 = 1.781477937;
+		double b4 = -1.821255978;
+		double b5 = 1.330274429;
+		double p = 0.2316419;
+		double c2 = 0.39894228;
+
+		double a = fabs(z);
+		double t = 1.0/(1.0+a*p);
+		double b = c2*exp((-z)*(z/2.0));
+		double n = ((((b5*t+b4)*t+b3)*t+b2)*t+b1)*t;
+		n = 1.0 - b*n;
+		if (z < 0.0) n = 1.0 - n;
+		return n>0.5?1-n:n;
+	}
+}
diff --git a/prior.cc b/prior.cc
new file mode 100644
index 0000000..344900f
--- /dev/null
+++ b/prior.cc
@@ -0,0 +1,97 @@
+#include "soap_snp.h"
+
+int Prob_matrix::prior_gen(Parameter * para) {
+	char t_base, allele1, allele2;
+	// Note, the above parameter should be changed to a more reasonable one
+	for(t_base=0;t_base!=4;t_base++) {
+		for(allele1=0;allele1!=4;allele1++) {
+			for(allele2=allele1;allele2!=4;allele2++) {
+				if(allele1 == t_base && allele2 == t_base) {
+					// refHOM
+					p_prior[t_base<<4|allele1<<2|allele2] = 1;
+				}
+				else if (allele1 == t_base || allele2 == t_base) {
+					// refHET: 1 ref 1 alt
+					p_prior[t_base<<4|allele1<<2|allele2] = para->het_novel_r;
+				}
+				else if (allele1 == allele2) {
+					// altHOM
+					p_prior[t_base<<4|allele1<<2|allele2] = para->althom_novel_r;
+				}
+				else {
+					// altHET: 2 diff alt base
+					p_prior[t_base<<4|allele1<<2|allele2] = para->het_novel_r * para->althom_novel_r;
+				}
+				if( para->transition_dominant && ((allele1^t_base) == 0x3 || (allele2^t_base) == 0x3)) {
+					// transition
+					p_prior[t_base<<4|allele1<<2|allele2] *= 4;
+				}
+				//std::cerr<<"ACTG"[t_base]<<"\t"<<"ACTG"[allele1]<<"ACTG"[allele2]<<"\t"<<p_prior[t_base<<4|allele1<<2|allele2]<<endl;
+			}
+		}
+	}
+	for(allele1=0;allele1!=4;allele1++) {
+		for(allele2=allele1;allele2!=4;allele2++) {
+			// Deal with N
+			p_prior[0x4<<4|allele1<<2|allele2] = (allele1==allele2? 1: (2*para->het_novel_r)) * 0.25 *0.25;
+			p_prior[0x5<<4|allele1<<2|allele2] = (allele1==allele2? 1: (2*para->het_novel_r)) * 0.25 *0.25;
+			p_prior[0x6<<4|allele1<<2|allele2] = (allele1==allele2? 1: (2*para->het_novel_r)) * 0.25 *0.25;
+			p_prior[0x7<<4|allele1<<2|allele2] = (allele1==allele2? 1: (2*para->het_novel_r)) * 0.25 *0.25;
+		}
+	}
+	return 1;
+}
+
+int Call_win::snp_p_prior_gen(double * real_p_prior, Snp_info* snp, Parameter * para, char ref) {
+	if (snp->is_indel()) {
+		return 0;
+	}
+	char base, allele1, allele2;
+	int allele_count;
+	allele_count = 0;
+	for (base=0; base != 4; base ++) {
+		if(snp->get_freq(base)>0) {
+			// The base is found in dbSNP
+			allele_count += 1;
+		}
+	}
+	if(allele_count <= 1) {
+		// Should never occur
+		cerr<<"Previous Extract SNP error."<<endl;
+		exit(255);
+		return -1;
+	}
+	char t_base = (ref&0x3);
+	for(allele1=0;allele1!=4;allele1++) {
+		for(allele2=allele1;allele2!=4;allele2++) {
+			if (! snp->is_hapmap()) {
+				if(snp->get_freq(allele1)>0 && snp->get_freq(allele2)>0) {
+					// Here the frequency is just a tag to indicate SNP alleles in non-HapMap sites
+					if(allele1 == allele2 && allele1 == t_base) {
+						// refHOM
+						real_p_prior[allele1<<2|allele2] = 1;
+					}
+					else if (allele1 == t_base || allele2 == t_base) {
+						// refHET: 1 ref 1 alt
+						real_p_prior[allele1<<2|allele2] = snp->is_validated()?para->het_val_r:para->het_unval_r;
+					}
+					else if (allele1 == allele2) {
+						real_p_prior[allele1<<2|allele2] =  snp->is_validated()?para->althom_val_r:para->althom_unval_r;
+					}
+					else {
+						// altHET: 2 diff alt base
+						real_p_prior[allele1<<2|allele2] = snp->is_validated()?para->het_val_r:para->het_unval_r;
+					}
+				}
+			}
+			else {
+				// Real HapMap Sites
+				if(snp->get_freq(allele1)>0 && snp->get_freq(allele2)>0) {
+					real_p_prior[allele1<<2|allele2] = (allele1==allele2?1:(2*para->het_val_r))*snp->get_freq(allele1)*snp->get_freq(allele2);
+				}
+			}
+			//cerr<<"ACTG"[t_base]<<"\t"<<"ACTG"[allele1]<<"ACTG"[allele2]<<"\t"<<p_prior[t_base<<4|allele1<<2|allele2]<<endl;
+		}
+	}
+	return 1;
+}
diff --git a/rank_sum.cc b/rank_sum.cc
new file mode 100644
index 0000000..249099d
--- /dev/null
+++ b/rank_sum.cc
@@ -0,0 +1,128 @@
+#include "soap_snp.h"
+
+int Prob_matrix::rank_table_gen() {
+	// When N <= 63, (so that n1<=31), use this table to test
+	ubit64_t i, n1, N, T1;
+	rate_t p_left, p_right;
+
+	// Calculate the factorials
+	double * fact = new double [64];
+	fact[0]=(double)1.0;
+	for(i=1;i!=64;i++) {
+		fact[i] = fact[i-1]*i;
+	}
+
+	ubit64_t * rank_sum= new ubit64_t [64*64*2048]; // 6bit: N; 5bit: n1; 11bit; T1
+	memset(rank_sum, 0, sizeof(ubit64_t)*64*64*2048);
+	rank_sum[0]=1;
+	for(N=1;N!=64;N++) {
+		//cerr<<N<<endl;
+		for(n1=0;n1<=N;n1++) {
+			//cerr<<n1<<endl;
+			for(T1=(1+n1)*n1/2;T1<=(N+N-n1+1)*n1/2;T1++) {
+				//cerr<<T1<<endl;
+				// Dynamic programming to generate the table
+				rank_sum[N<<17|n1<<11|T1] = rank_sum[((N-1)<<17)|(n1<<11)|T1] + ((T1>=N && n1>0) ? rank_sum[((N-1)<<17)|((n1-1)<<11)|(T1-N)]:0);
+				// Here, the p_rank is not cumulative
+				p_rank[(N<<17)|(n1<<11)|T1] = rank_sum[N<<17|n1<<11|T1] / (fact[N]/(fact[n1]*fact[N-n1]));
+				//cerr<<p_rank[(N<<17)|(n1<<11)|T1]<<endl;
+			}
+			p_left = 0.0, p_right =1.0;
+			for(T1=(1+n1)*n1/2;T1<=(N+N-n1+1)*n1/2;T1++) {
+				p_right = 1.0 - p_left;
+				p_left += p_rank[(N<<17)|(n1<<11)|T1];
+				p_rank[N<<17|n1<<11|T1] = (p_left<p_right?p_left:p_right);
+				//std::cerr<<N<<"\t"<<n1<<"\t"<<T1<<"\t"<<p_rank[(N<<17)|(n1<<11)|T1]<<endl;
+			}
+		}
+	}
+	delete [] rank_sum;
+	delete [] fact;
+	return 1;
+}
+
+double Call_win::normal_test(int n1, int n2, double T1, double T2) {
+	double u1, u2;
+	u1 = (T1 - n1*(n1+n2+1)/2) / sqrt(n1*n2*(n1+n2+1)/(double)12);
+	u2 = (T2 - n2*(n1+n2+1)/2) / sqrt(n1*n2*(n1+n2+1)/(double)12);
+	return normal_value(fabs(u1)>fabs(u2)?u1:u2);
+}
+
+double Call_win::table_test(double *p_rank, int n1, int n2, double T1, double T2) {
+	if(n1<=n2) {
+		return p_rank[(n1+n2)<<17|n1<<11|(int)(T1)]+(T1-(int)T1)*(p_rank[(n1+n2)<<16|n1<<11|(int)(T1+1)]-p_rank[(n1+n2)<<17|n1<<11|(int)(T1)]);
+	}
+	else {
+		return p_rank[(n1+n2)<<17|n2<<11|(int)(T2)]+(T2-(int)T2)*(p_rank[(n1+n2)<<16|n2<<11|(int)(T2+1)]-p_rank[(n1+n2)<<17|n2<<11|(int)(T2)]);
+	}
+}
+
+double Call_win::rank_test(Pos_info & info, char best_type, double * p_rank, Parameter * para) {
+	if( (best_type&3) == ((best_type>>2)&3) ) {
+		// HOM
+		return 1.0;
+	}
+	if( info.count_uni[best_type&3]==0 || info.count_uni[(best_type>>2)&3]==0) {
+		// HET with one allele...
+		return 0.0;
+	}
+	//cerr<<"RankSum:"<<info.pos<<endl;
+	//int * same_qual_count = new int [para->q_max-para->q_min+1];
+	//memset(same_qual_count, 0, sizeof(int)*(para->q_max-para->q_min+1));
+	//double * rank_array= new double [para->q_max-para->q_min+1];
+	//memset(rank_array, 0, sizeof(double)*(para->q_max-para->q_min+1));
+	int *same_qual_count = new int [64];
+	double *rank_array = new double [64];
+	memset(same_qual_count,0,sizeof(int)*64);
+	memset(rank_array,0,sizeof(double)*64);
+
+	int rank(0);
+	double T[4]={0.0, 0.0, 0.0, 0.0};
+	bool is_need[4] ={false,false,false,false};
+	is_need[(best_type&3)]=true; is_need[((best_type>>2)&3)]=true;
+	std::string::size_type o_base, strand;
+	int  q_score, coord;
+	for(o_base=0;o_base!=4;o_base++) {
+		if(info.count_uni[o_base]==0 || !is_need[o_base]) continue;
+		for(q_score=para->q_max-para->q_min;q_score>=0;q_score--) {
+			for(coord=para->read_length-1;coord>=0;coord--) {
+				for(strand=0;strand<2;strand++) {
+					same_qual_count[q_score] += info.base_info[o_base<<15|strand<<14|q_score<<8|coord];
+					//if(info.pos==1256 && info.base_info[o_base<<13|strand<<12|q_score<<6|coord]!=0) {
+					//	cerr<<info.pos<<"\t"<<q_score<<"\t"<<same_qual_count[q_score]<<"\t"<<int(info.base_info[o_base<<13|strand<<12|q_score<<6|coord])<<endl;
+					//}
+				}
+			}
+		}
+	}
+	rank = 0;
+	for(q_score=0;q_score<=(ubit64_t)(para->q_max-para->q_min+1);q_score++) {
+		rank_array[q_score]= rank+(1+same_qual_count[q_score])/2.0;
+		rank += same_qual_count[q_score];
+	}
+	for(o_base=0;o_base!=4;o_base++) {
+		if(info.count_uni[o_base]==0 || !is_need[o_base]) continue;
+		for(q_score=para->q_max-para->q_min;q_score>=0;q_score--) {
+			for(coord=para->read_length-1;coord>=0;coord--) {
+				for(strand=0;strand<2;strand++) {
+					//cerr<<"ACTG"[o_base]<<endl;
+					T[o_base] += (rank_array[q_score] * info.base_info[o_base<<15|strand<<14|q_score<<8|coord]);
+					//cerr<<T[o_base]<<endl;
+				}
+			}
+		}
+	}
+	delete [] same_qual_count;
+	delete [] rank_array;
+	//for(size_t a=0;a!=4;a++) {
+	//	fprintf(stderr, "%lf\t", T[a]);
+	//}
+	//fprintf(stderr, "\n");
+	//std::cerr<<"%d\t%d\t%lf\t%lf", info.count_uni[best_type&3],  info.count_uni[(best_type>>2)&3], T[best_type&3], T[(best_type>>2)&3]);
+	if (info.count_uni[best_type&3]+info.count_uni[(best_type>>2)&3]<64) {
+		return table_test(p_rank, info.count_uni[best_type&3], info.count_uni[(best_type>>2)&3], T[best_type&3], T[(best_type>>2)&3]);
+	}
+	else {
+		return normal_test(info.count_uni[best_type&3], info.count_uni[(best_type>>2)&3],T[best_type&3], T[(best_type>>2)&3]);
+	}
+}
diff --git a/readme b/readme
new file mode 100644
index 0000000..5a1220d
--- /dev/null
+++ b/readme
@@ -0,0 +1,139 @@
+Program: SOAPsnp (Short Oligonucleotide Analysis Package for Single Nucleotide Polymorphism)
+
+Copyright (C) 2008, BGI Shenzhen.
+
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+
+Author:  BGI shenzhen
+Contact: soap at genomics.org.cn
+
+Introduction
+
+SOAPsnp is a member of the SOAP (Short Oligonucleotide Analysis Package). Despite its name, the program is a resequencing utility that can assemble consensus sequence for the genome of a newly sequenced individual based on the alignment of the raw sequencing reads on the known reference. The SNPs can then be identified on the consensus sequence through the comparison with the reference. In the first Asian genome re-sequencing project, evalution of SOAPsnp result on Illumina HapMap 1M Bea [...]
+
+SOAPsnp uses a method based on Bayesa' theorem (the reverse probability model) to call consensus genotype by carefully considering the data quality, alignment, and recurring experimental errors. All these kinds of information was integrated into a single quality score for each base in PHRED scale to measure the accuracy of consensus calling. Currently, it supports the alignment format of SoapMap.
+
+Download
+
+<Download link>
+
+System requirements
+SOAPsnp is a command line driven program written in C/C++ that generally runs under 64-bit Linux system. The program has been tested on various platforms like x86-64 Xeon with Linux kernel 2.6.9 and Loongson 2E/2F with Linux kernel 2.6.22. It is in principle portable to other architectures/systems as only standard C++ libraries were used. GNU Compiler Collection (version>=3.4) is recommended to compile the codes.
+
+The program needs ~500M or even smaller memory to run. However, its output might be very large that consumes a lot of harddisk space. In text output mode, the output file may be as large as 60 times the genome size (e.g. 180G free space is required to run a human genome). In GLF output format (which is proposed by Prof. R. Durbin in Wellcome Trust Sanger Institute), the output file approximately requires a free disk space of 12 times the genome size to store.
+
+Installation
+1.	Download the tarball of the latest SOAPsnp version from the link above. (For example, SOAPsnp.tar.gz)
+2.	In the Linux console:
+tar zxvf /<PATH_WHERE_YOU_PUT_THE_TARBALL>/SOAPsnp.tar.gz
+cd SOAPsnp/
+3.	Change the 'makefile' if necessary. For example, you may would like to modify the compiler optimization parameters.
+4.	In the Linux console:
+make all
+Then an executable of SOAPsnp will be generated in the directory.
+In the Linux console, type:
+./soapsnp
+or:
+<Absolute path>/soapsnp
+	to run the program. You may copy the executable to /usr/bin/ or other system paths defined in the environment variables so that you can simply run the program by directly typing 'soapsnp' in the console.
+
+Quick Start:
+For diploid genome resequencing:
+soapsnp -i <Alignment.soap.sort.chrN> -d  <chrN.fasta> -o <chrN.consensus> -r 0.00005 e 0.0001 -t -u -L  <Maximum Read Length> -M <chrN.mat>
+
+For monoploid genome resequencing:
+soapsnp -i <Alignment.soap.sort.chrN> -d  <chrN.fasta> -o <chrN.consensus> -r 0.0001 -t -u -L  <Maximum Read Length> -M <chrN.mat> -m
+
+Usage
+Command line options:
+1. Required parameters:
+-i <FILE> Input SORTED SOAPaligner(soap) alignment result
+Note that here we say 'sorted' means alignments of each chromosome are sorted first by chromosome name lexicographically and then by coordinates on each chromosome numerically.
+
+-d <FILE> Reference DNA sequence in FASTA format
+
+-o <FILE> Output consensus file
+
+2. Optional parameters:(default in [])
+
+-z <Char> ASCII character that stands for quality score==0 [@]
+FASTQ files generated by Illumina base-calling pipeline use '@' as 0, but some institutes use '!' as 0.
+
+-g <Double> Global error dependency coefficient, 0.0(complete dependent)~1.0(complete independent)[0.9]
+
+-p <Double> PCR error dependency coefficient, 0.0(complete dependent)~1.0(complete independent)[0.5]
+Sequencing errors are found slightly repeatable (once an error occur, additional errors also tend to occur) due to various reasons. Therefore, observations of sequencing errors are not complete independent. The main source of repeatable errors is believed to be PCR amplification in sequencing process. The proper values of the two parameters rely on wetlab process. Nonetheless, the default value generally work at most time.
+
+-r <Double> novel altHOM prior probability [0.0005]
+
+-e <Double> novel HET prior probability [0.0010]
+The two are prior probabilities of homozygous SNPs (altHOM) and heterozygous SNPs (HET), which are used in Bayes formula calculation. Note these are prior probabilities of a new (novel) SNP. They are expected to be stringent. For different species, the two values should change if necessary.
+
+-t set transition/transversion ratio to 2:1 in prior probability
+
+-s <FILE> Pre-formatted known SNP information.
+The file consist of a lot of lines like this one:
+chr1    201979756       1       1       0       0.161   0       0       0.839   rs568
+The columns from left to right are: name of chromosome, coordinate on the chromosome, whether the SNP has allele frequency information (1 is true, 0 is false), whether the SNP is validated by experiment (1 is true, 0 is false), whether the SNP is actually an indel (1 is true, 0 is false), frequency of A, frequency of C, frequency of T, frequency of G, SNP id. For known SNP sites that do not have allele frequency information, the frequency information can be arbitrarily determined as any  [...]
+
+-2 specify this option will REFINE SNP calling using known SNP information [Off]
+
+-a <Double> Validated HET prior, if no allele frequency known [0.1]
+
+-b <Double> Validated altHOM prior, if no allele frequency known[0.05]
+
+-j <Double> Unvalidated HET prior, if no allele frequency known [0.02]
+
+-k <Double> Unvalidated altHOM rate, if no allele frequency known[0.01]
+The parameters are related to using external SNP information to alter prior probabilities for SNP calling. SOAPsnp will try using allele frequency information as prior probability in calling genotypes for each site. If the allele frequency information is absent, it will use the above 4 parameters as prior probability.
+
+-u Enable rank sum test (that check whether the two allele of a possible HET call have same sequencing quality) to give HET further penalty for better accuracy. [Off]
+
+-n Enable binomial probability calculation (that check whether the two allele are observed equally)to give HET further penalty for better accuracy. [Off]
+
+-m Enable monoploid calling mode, this will ensure all consensus as HOM and you probably should SPECIFY higher altHOM rate. [Off]
+
+-q Only output potential SNPs. Useful in Text output mode. [Off]
+
+-M <FILE> Output the quality calibration matrix; the matrix can be reused with -I if you rerun the program
+
+-I <FILE> Input previous quality calibration matrix. It cannot be used simutaneously with -M
+
+-L <short> maximum length of read [45]
+Please note that once length of some reads exceeds the parameter will probably collapse the program.
+
+-Q <short> maximum FASTQ quality score [40]
+
+-F <int> Output format. 0: Text; 1: GLFv2; 2: GPFv2.[0]
+
+-E <String> Extra headers EXCEPT CHROMOSOME FIELD specified in GLFv2 output. Format is "TypeName1:DataName1:TypeName2:DataName2"[]
+
+-T <FILE> Only call consensus on regions specified in FILE. Format of this file is:
+ChrName\tStart\tEnd
+ChrName\tStart\tEnd
+...
+
+-h Display this help
+
+Output format
+1.	Text format
+The result of SOAPsnp has 17 columns: 
+1)	Chromosome ID
+2)	Coordinate on chromosome, start from 1
+3)	Reference genotype
+4)	Consensus genotype
+5)	Quality score of consensus genotype
+6)	Best base, average quality score of best base
+7)	Count of uniquely mapped best base
+8)	Count of all mapped best base
+9)	Second best bases, average quality score of second best base
+10)	 Count of uniquely mapped second best base
+11)	 Count of all mapped second best base
+12)	 Sequencing depth of the site, rank sum test p_value
+13)	 Average copy number of nearby region
+14)	 Whether the site is a dbSNP. 
+2.	GLFv2 and GPFv2
+GLFv2 (Genome Likelihood Format v2) is a binary file format proposed by Prof. R. Durbin. 
+
diff --git a/release b/release
new file mode 100644
index 0000000..b840459
--- /dev/null
+++ b/release
@@ -0,0 +1,5 @@
+version: SOAPsnpZ
+date: 25 May 2009
+1. a subvertion of SOAPsnp with gziped file IO. You should confirm BOOST 
+   iostream library has been installed in your platform at first. And you can 
+   learn more about BOOST from http://www.boost.org/ .
diff --git a/soap_snp.h b/soap_snp.h
new file mode 100644
index 0000000..e3de1ac
--- /dev/null
+++ b/soap_snp.h
@@ -0,0 +1,326 @@
+#ifndef SOAP_SNP_HH_
+#define SOAP_SNP_HH_
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <string>
+#include <map>
+#include <vector>
+#include <cmath>
+#include <iomanip>
+#include <cassert>
+#include <boost/iostreams/filtering_streambuf.hpp>
+#include <boost/iostreams/copy.hpp>
+#include <boost/iostreams/filter/gzip.hpp>
+typedef unsigned long long ubit64_t;
+typedef unsigned int ubit32_t;
+typedef double rate_t;
+typedef unsigned char small_int;
+using namespace std;
+const size_t capacity = sizeof(ubit64_t)*8/4;
+const char abbv[17]={'A','M','W','R','M','C','Y','S','W','Y','T','K','R','S','K','G','N'};
+const ubit64_t glf_base_code[8]={1,2,8,4,15,15,15,15}; // A C T G
+const ubit64_t glf_type_code[10]={0,5,15,10,1,3,2,7,6,11};// AA,CC,GG,TT,AC,AG,AT,CG,CT,GT
+const int global_win_size = 1000;
+
+// Some global variables
+class Files {
+public:
+	ifstream soap_result, ref_seq, dbsnp, region;
+	ofstream consensus, baseinfo, o_region;
+	fstream matrix_file;
+	Files(){
+		soap_result.close();
+		ref_seq.close();
+		dbsnp.close();
+		consensus.close();
+		baseinfo.close();
+		matrix_file.close();
+		region.close();
+		o_region.close();
+	};
+};
+
+class Parameter {
+public:
+	char q_min; // The char stands for 0 in fastq
+	char q_max; // max quality score
+	small_int read_length; // max read length
+	bool is_monoploid; // Is it an monoploid? chrX,Y,M in man.
+	bool is_snp_only;  // Only output possible SNP sites?
+	bool refine_mode; // Refine prior probability using dbSNP
+	bool rank_sum_mode; // Use rank sum test to refine HET quality
+	bool binom_mode; // Use binomial test to refine HET quality
+	bool transition_dominant; // Consider transition/transversion ratio?
+	int glf_format; // Generate Output in GLF format: New File Definitions! Since May 1, 2009
+	bool region_only; // Only report consensus in specified region
+	std::string glf_header; // Header of GLF format
+	rate_t althom_novel_r, het_novel_r; // Expected novel prior
+	rate_t althom_val_r, het_val_r; // Expected Validated dbSNP prior
+	rate_t althom_unval_r, het_unval_r; // Expected Unvalidated dbSNP prior
+	rate_t global_dependency, pcr_dependency; // Error dependencies, 1 is NO dependency
+// Default onstruction
+	Parameter(){
+		q_min = 64;
+		q_max = 64+40;
+		read_length = 45;
+		is_monoploid = is_snp_only = refine_mode = rank_sum_mode = binom_mode = transition_dominant = region_only =false;
+		glf_format = 0;
+		glf_header = "";
+		althom_novel_r=0.0005, het_novel_r=0.0010;
+		althom_val_r=0.05, het_val_r=0.10;
+		althom_unval_r=0.01, het_unval_r=0.02;
+		global_dependency= log10(0.9), pcr_dependency= log10(0.5); // In Log10 Scale
+	};
+};
+
+class Soap_format {
+	// Soap alignment result
+	std::string read_id, read, qual, chr_name;
+	int hit, read_len, position, mismatch;
+	char ab, strand;
+public:
+	Soap_format(){;};
+	friend std::istringstream & operator>>(std::istringstream & alignment, Soap_format & soap) {
+		alignment>>soap.read_id>>soap.read>>soap.qual>>soap.hit>>soap.ab>>soap.read_len>>soap.strand>>soap.chr_name>>soap.position>>soap.mismatch;
+		//cerr<<soap<<endl;
+		//exit(1);
+		if(soap.mismatch>200) {
+			int indel_pos,indel_len;
+			string temp("");
+			alignment>>indel_pos;
+			indel_len = soap.mismatch-200;
+			for(int i=0; i!=indel_len; i++) {
+				temp = temp+'N';
+			}
+			soap.read = soap.read.substr(0,indel_pos)+temp+soap.read.substr(indel_pos,soap.read_len-indel_pos);
+			soap.qual = soap.qual.substr(0,indel_pos)+temp+soap.qual.substr(indel_pos,soap.read_len-indel_pos);
+			//cerr<<soap<<endl;
+		}
+		else if (soap.mismatch>100) {
+			int indel_pos,indel_len;
+			alignment>>indel_pos;
+			indel_len = soap.mismatch-100;
+			soap.read = soap.read.substr(0,indel_pos) + soap.read.substr(indel_pos+indel_len, soap.read_len-indel_pos-indel_len);
+			soap.qual = soap.qual.substr(0,indel_pos) + soap.qual.substr(indel_pos+indel_len, soap.read_len-indel_pos-indel_len);
+			//cerr<<soap<<endl;
+		}
+		//cerr<<soap.position<<'\t';
+		soap.position -= 1;
+		//cerr<<soap.position<<endl;
+		return alignment;
+	}
+	friend std::ostream & operator<<(std::ostream & o, Soap_format & soap) {
+		o<<soap.read_id<<'\t'<<soap.read<<'\t'<<soap.qual<<'\t'<<soap.hit<<'\t'<<soap.ab<<'\t'<<soap.read_len<<'\t'<<soap.strand<<'\t'<<soap.chr_name<<'\t'<<soap.position<<'\t'<<soap.mismatch;
+		return o;
+	}
+	char get_base(std::string::size_type coord) {
+		return read[coord];
+	}
+	char get_qual(std::string::size_type coord) {
+		return qual[coord];
+	}
+	bool is_fwd(){
+		return (strand=='+');
+	}
+	int get_read_len(){
+		return read_len;
+	}
+	inline int get_pos(){
+		return position;
+	}
+	std::string get_chr_name(){
+		return chr_name;
+	}
+	int get_hit(){
+		return hit;
+	}
+	bool is_unique(){
+		return (hit==1);
+	}
+	bool is_N(int coord) {
+		return (read[coord] == 'N');
+	}
+};
+
+// dbSNP information
+class Snp_info {
+	bool validated;
+	bool hapmap_site;
+	bool indel_site;
+	rate_t * freq; // Arrary of 4 elements recording frequency of ACTG
+public:
+	Snp_info(){
+		validated=hapmap_site=indel_site=false;
+		freq = new rate_t [4];
+		memset(freq,0,sizeof(rate_t)*4);
+	}
+	Snp_info(const Snp_info & other) {
+		validated = other.validated;
+		hapmap_site = other.hapmap_site;
+		indel_site = other.indel_site;
+		freq = new rate_t [4];
+		memcpy(freq, other.freq, sizeof(rate_t)*4);
+	}
+	~Snp_info(){
+		delete [] freq;
+	}
+	friend std::istringstream& operator>>(std::istringstream & s, Snp_info & snp_form) {
+		s>>snp_form.hapmap_site>>snp_form.validated>>snp_form.indel_site>>snp_form.freq[0]>>snp_form.freq[1]>>snp_form.freq[2]>>snp_form.freq[3];
+		return s;
+	}
+	Snp_info & operator=(Snp_info& other) {
+		this->validated = other.validated;
+		this->hapmap_site = other.hapmap_site;
+		this->indel_site = other.indel_site;
+		this->freq = new rate_t [4];
+		memcpy(this->freq, other.freq, sizeof(rate_t)*4);
+		return *this;
+
+	}
+	bool is_validated(){
+		return validated;
+	}
+	bool is_hapmap(){
+		return hapmap_site;
+	}
+	bool is_indel(){
+		return indel_site;
+	}
+	rate_t get_freq(char bin_base_2bit) {
+		return freq[bin_base_2bit];
+	}
+};
+
+// Chromosome(Reference) information
+class Chr_info {
+	ubit32_t len;
+	ubit64_t* bin_seq; // Sequence in binary format
+	ubit64_t* region_mask;
+	ubit64_t* region_win_mask;
+	// 4bits for one base: 1 bit dbSNPstatus, 1bit for N, followed two bit of base A: 00, C: 01, T: 10, G:11,
+	// Every ubit64_t could store 16 bases
+	map<ubit64_t, Snp_info*> dbsnp;
+public:
+	Chr_info(){
+		len = 0;
+		bin_seq = NULL;
+		region_mask = NULL;
+		region_win_mask = NULL;
+	};
+	Chr_info(const Chr_info & other);
+	~Chr_info(){
+		delete [] bin_seq;
+		delete [] region_mask;
+		delete [] region_win_mask;
+	}
+	ubit32_t length() {
+		return len;
+	}
+	ubit64_t get_bin_base(std::string::size_type pos) {
+		return (bin_seq[pos/capacity]>>(pos%capacity*4))&0xF; // All 4 bits
+	}
+	int binarize(std::string & seq);
+	int insert_snp(std::string::size_type pos, Snp_info & new_snp);
+	int region_mask_ini();
+	bool is_in_region(std::string::size_type pos) {
+		return ((region_mask[pos/64]>>(63-pos%64))&1);
+	}
+	bool is_in_region_win(std::string::size_type pos) {
+		pos /= global_win_size; // Calculate in which windows the site is
+		//cerr<<pos<<endl;
+		//exit(1);
+		return ((region_win_mask[pos/64]>>(63-pos%64))&1);
+	}
+	int set_region(int start, int end);
+	Snp_info * find_snp(ubit64_t pos) {
+		return dbsnp.find(pos)->second;
+	}
+	ubit64_t * get_region() {
+		return region_mask;
+	}
+};
+
+typedef std::string Chr_name;
+class Genome {
+public:
+	map<Chr_name, Chr_info*> chromosomes;
+
+	Genome(ifstream & fasta, ifstream & known_snp);
+	~Genome();
+
+	bool add_chr(Chr_name &);
+	int read_region(std::ifstream & region, Parameter * para);
+};
+
+class Prob_matrix {
+public:
+	rate_t *p_matrix, *p_prior; // Calibration matrix and prior probabilities
+	rate_t *base_freq, *type_likely, *type_prob; // Estimate base frequency, conditional probability, and posterior probablity
+	rate_t *p_rank, *p_binom; // Ranksum test and binomial test on HETs
+	Prob_matrix();
+	~Prob_matrix();
+	int matrix_gen(std::ifstream & alignment, Parameter * para, Genome * genome);
+	int matrix_read(std::fstream & mat_in, Parameter * para);
+	int matrix_write(std::fstream & mat_out, Parameter * para);
+	int prior_gen(Parameter * para);
+	int rank_table_gen();
+
+};
+
+class Pos_info {
+public:
+	unsigned char ori;
+	small_int *base_info;
+	int pos, *count_uni, *q_sum, depth, dep_uni, repeat_time, *count_all;
+
+	Pos_info(){
+		ori = 0xFF;
+		base_info = new small_int [4*2*64*256]; // base info : 4x2x64x64 matrix, base x strand x qual x read_pos
+		memset(base_info,0,sizeof(small_int)*4*2*64*256);
+		pos = -1;
+		count_uni = new int [4]; // Count of unique bases
+		memset(count_uni,0,sizeof(int)*4);
+		q_sum = new int [4]; // Sum of quality of unique bases
+		memset(q_sum,0,sizeof(int)*4);
+		depth = 0;
+		dep_uni = 0;
+		repeat_time = 0;
+		count_all = new int [4]; // Count of all bases
+		memset(count_all,0,sizeof(int)*4);
+	}
+	~Pos_info(){
+		delete [] base_info;
+		delete [] count_uni;
+		delete [] q_sum;
+		delete [] count_all;
+	}
+};
+
+class Call_win {
+public:
+	ubit64_t win_size;
+	ubit64_t read_len;
+	Pos_info * sites;
+	Call_win(ubit64_t read_length, ubit64_t window_size=global_win_size) {
+		sites = new Pos_info [window_size+read_length];
+		win_size = window_size;
+		read_len = read_length;
+	}
+	~Call_win(){
+		delete [] sites;
+	}
+
+	int initialize(ubit64_t start);
+	int deep_init(ubit64_t start);
+	int recycle();
+	int call_cns(Chr_name call_name, Chr_info* call_chr, ubit64_t call_length, Prob_matrix * mat, Parameter * para, std::ofstream & consensus, std::ofstream & baseinfo);
+	int soap2cns(std::ifstream & alignment, std::ofstream & consensus, std::ofstream & baseinfo, Genome * genome, Prob_matrix * mat, Parameter * para);
+	int snp_p_prior_gen(double * real_p_prior, Snp_info* snp, Parameter * para, char ref);
+	double rank_test(Pos_info & info, char best_type, double * p_rank, Parameter * para);
+	double normal_value(double z);
+	double normal_test(int n1, int n2, double T1, double T2);
+	double table_test(double *p_rank, int n1, int n2, double T1, double T2);
+};
+
+#endif /*SOAP_SNP_HH_*/

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/soapsnp.git



More information about the debian-med-commit mailing list