[med-svn] [Git][med-team/libssw][upstream] New upstream version 1.2.4+git20190312.cabdab1

Andreas Tille gitlab at salsa.debian.org
Sat Apr 11 10:41:24 BST 2020



Andreas Tille pushed to branch upstream at Debian Med / libssw


Commits:
373215c6 by Andreas Tille at 2020-04-11T10:22:24+02:00
New upstream version 1.2.4+git20190312.cabdab1
- - - - -


26 changed files:

- README.md
- + demo/new.txt
- + demo/old.txt
- + demo/output.sam
- + demo/pRead.fa
- + demo/pRef.fa
- + demo/query.fa
- + demo/query.fastq
- + demo/query1.fa
- + demo/query2.fa
- + demo/r1.fa
- + demo/r1_query.fq
- + demo/target.fa
- + demo/target.fastq
- + demo/target1.fa
- + demo/target2.fa
- − src/.gitignore
- src/Makefile
- src/example.cpp
- src/main.c
- src/pyssw.py
- src/ssw.c
- src/ssw.h
- src/ssw_cpp.cpp
- src/ssw_cpp.h
- + src/ssw_lib.pyc


Changes:

=====================================
README.md
=====================================
@@ -1,4 +1,6 @@
-#SSW Library: An SIMD Smith-Waterman C/C++/Python/Java Library for Use in Genomic Applications
+# SSW Library
+
+## An SIMD Smith-Waterman C/C++/Python/Java Library for Use in Genomic Applications
 
 License: MIT
 
@@ -10,21 +12,22 @@ The above copyright notice and this permission notice shall be included in all c
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-Author:  
-C implementation: Mengyao Zhao  
-C++ wrapper: Wan-Ping Lee  
-Python wrapper: Yongan Zhao  
-Java wrapper: Daniel Cameron
+Authors:
+* C implementation: Mengyao Zhao
+* C++ wrapper: Wan-Ping Lee
+* Python wrapper: Yongan Zhao
+* Java wrapper: Daniel Cameron
 
-Contact:  
-Mengyao Zhao <zhaomengyao at gmail.com>  
-Wan-Ping Lee <wanping.lee at gmail.com>  
-Yongan Zhao <zhaoyanswill at gmail.com>   
-Daniel Cameron <cameron.d at wehi.edu.au>  
+Contact:
+* Mengyao Zhao <zhaomengyao at gmail.com>
+* Wan-Ping Lee <wanping.lee at gmail.com>
+* Yongan Zhao <zhaoyanswill at gmail.com>
+* Daniel Cameron <cameron.d at wehi.edu.au>
 
 Last revision: 06/29/2016
 
-##Overview
+## Overview
+
 SSW is a fast implementation of the Smith-Waterman algorithm, which uses the Single-Instruction Multiple-Data (SIMD) instructions to parallelize the algorithm at the instruction level. SSW library provides an API that can be flexibly used by programs written in C, C++ and other languages. We also provide a software that can do protein and genome alignment directly. Current version of our implementation is ~50 times faster than an ordinary Smith-Waterman. It can return the Smith-Waterman score, alignment location and traceback path (cigar) of the optimal alignment accurately; and return the sub-optimal alignment score and location heuristically.
 
 The Debian package of this library can be achieved here:
@@ -34,45 +37,49 @@ Note: When SSW open a gap, the gap open penalty alone is applied.
 
 ## C/C++ interface
 
-###How to use the API
-The API files include ssw.h and ssw.c, which can be directly used by any C or C++ program. For the C++ users who are more comfortable to use a C++ style interface, an additional C++ wrapper is provided with the file ssw_cpp.cpp and ssw_cpp.h.
+### How to use the API
+
+The API files include `ssw.h` and `ssw.c`, which can be directly used by any C or C++ program. For the C++ users who are more comfortable to use a C++ style interface, an additional C++ wrapper is provided with the file `ssw_cpp.cpp` and `ssw_cpp.h`.
 
 To use the C style API, please:
 
-1. Download ssw.h and ssw.c, and put them in the same folder of your own program files.
-2. Write #include "ssw.h" into your file that will call the API functions.
+1. Download `ssw.h` and `ssw.c`, and put them in the same folder of your own program files.
+2. Write `#include "ssw.h"` into your file that will call the API functions.
 3. The API files are ready to be compiled together with your own C/C++ files.
 
-The API function descriptions are in the file ssw.h. One simple example of the API usage is example.c. The Smith-Waterman penalties need to be integers. Small penalty numbers such as: match: 2, mismatch: -1, gap open (the total penalty when one gap is opened): -3, gap extension: -1 are recommended, which will lead to shorter running time.  
+The API function descriptions are in the file `ssw.h`. One simple example of the API usage is `example.c`. The Smith-Waterman penalties need to be integers. Small penalty numbers such as: match: 2, mismatch: -1, gap open (the total penalty when one gap is opened): -3, gap extension: -1 are recommended, which will lead to shorter running time.
 
 To use the C++ style API, please:
 
-1. Download ssw.h, ssw.c, ssw_cpp.cpp and ssw_cpp.h and put them in the same folder of your own program files.
-2. Write #include "ssw_cpp.h" into your file that will call the API functions.
+1. Download `ssw.h`, `ssw.c`, `ssw_cpp.cpp` and `ssw_cpp.h`, put them in the same folder of your own program files.
+2. Write `#include "ssw_cpp.h"` into your file that will call the API functions.
 3. The API files are ready to be compiled together with your own C/C++ files.
 
-The API function descriptions are in the file ssw_cpp.h. A simple example of using the C++ API is example.cpp.
+The API function descriptions are in the file `ssw_cpp.h`. A simple example of using the C++ API is `example.cpp`.
 
-###Speed and memory usage of the API
-Test data set: 
-Target sequence: reference genome of E. coli strain 536 (4,938,920 nucleotides) from NCBI
-Query sequences: 1000 reads of Ion Torrent sequenced E. coli strain DH10B (C23-140, 318 PGM Run, 11/2011), read length: ~25-540 bp, most reads are ~200 bp
+### Speed and memory usage of the API
+
+Test data set:
+
+* Target sequence: reference genome of _E. coli_ strain 536 (4,938,920 nucleotides) from NCBI
+* Query sequences: 1000 reads of Ion Torrent sequenced _E. coli_ strain DH10B (C23-140, 318 PGM Run, 11/2011), read length: ~25-540 bp, most reads are ~200 bp
 
 CPU time:
 
 * AMD CPU: default penalties: ~880 seconds; -m1 -x3 -o5 -e2: ~460 seconds
-* Intel CPU: default penalties: ~960 seconds; -m1 -x3 -o5 -e2: ~500 seconds 
+* Intel CPU: default penalties: ~960 seconds; -m1 -x3 -o5 -e2: ~500 seconds
 
 Memory usage: ~40MB
- 
-###Install the software
+
+### Install the software
 
 1. Download the software from https://github.com/mengyao/Complete-Striped-Smith-Waterman-Library.
-2. cd src
-3. make
-4. The executable file will be ssw_test.
+2. `cd src`
+3. `make`
+4. The executable file will be `ssw_test`.
+
+### Run the software
 
-###Run the software
 ```
 Usage: ssw_test [options] ... <target.fasta> <query.fasta>(or <query.fastq>)
 Options:
@@ -89,15 +96,18 @@ Options:
 	-h	If -s is used, include header in SAM output.
 ```
 
-###Software input
+### Software input
+
 The input files can be in FASTA or FASTQ format. Both target and query files can contain multiple sequences. Each sequence in the query file will be aligned with all sequences in the target file. If your target file has N sequences and your query file has M sequences, the results will have M*N alignments.
 
-###Software output
-The software can output SAM format or BLAST like format results. 
+### Software output
+
+The software can output SAM format or BLAST like format results.
 
 1. SAM format output:
 
 Example:
+
 ```
 @HD VN:1.4  SO:queryname
 @SQ SN:chr1 LN:1001
@@ -111,7 +121,9 @@ Y:26750420:R:-132;None;None/1   0   chr1    120 4   2M1I4M3D3M1I7M2I9M2D6M1I8M
 ```
 
 What is the output?
-Please check the document "The SAM Format Specification" at: http://samtools.sourceforge.net/SAM1.pdf for the full description.
+
+Please check the document "The SAM Format Specification" at: http://samtools.github.io/hts-specs/SAMv1.pdf for the full description.
+
 The additional optional field "ZS" indicates the suboptimal alignment score. For example, the 1st record in the upper example means the optimal alignment score of the given sequence is 37; the suboptimal alignment score is 28; the mismatch and INDEL base count within the aligned fragment of the read is 11.
 
 2. An example of the BLAST like output:
@@ -135,24 +147,33 @@ Query:         3    GA-AGAGTTAATTTAAGTCACTTCAAACAGATTAC-GTA-TCTTTT-TTTTCCCT    5
 ...
 ```
 
-##Python interface
+## Python interface
 
-###How to use the python wrapper ssw_lib.py
+### How to use the Python wrapper `ssw_lib.py`
 
-ssw_lib.py is a Python wrapper that fully supports APIs of the C library. To use this Python library, C programming knowledge is not required.
+`ssw_lib.py` is a Python wrapper that fully supports APIs of the C library. To use this Python library, C programming knowledge is not required.
 
-To use the python wrapper, please:
+To use the Python wrapper, please:
+
+1. Compile the `src` folder by either using the `makefile` or by compiling a dynamic shared library with `gcc`:
+
+```
+gcc -Wall -O3 -pipe -fPIC -shared -rdynamic -o libssw.so ssw.c ssw.h
+```
+
+2. Put `libssw.so` and `ssw_lib.py` in the same directory of your own program files or directories in sys.paths.
+
+3. The `LD_LIBRARY_PATH` environment variable may need to be modified to include the directory of the dynamic library `libssw.so` by one of the two following mathods:
 
-1. Compile the src folder by either using the makefile or by compiling a dynamic shared library with gcc  
-```gcc -Wall -O3 -pipe -fPIC -shared -rdynamic -o libssw.so ssw.c ssw.h```
-2. Put libssw.so and ssw_lib.py in the same directory of your own program files or directories in sys.paths.
-3. The LD_LIBRARY_PATH environment variable may need to be modified to include the directory of the dynamic library libssw.so by one of the two following mathods:
     * ```export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path_of_libssw.so```
-    * For a definitive inclusion edit /etc/ld.so.conf and add the path of the libssw.so. Then, update the cache by ```/sbin/ldconfig```.
-4. In a python script or in a interactive interpreter, import the CSsw class by: ```from ssw_lib import CSsw``` or ```import ssw_lib``` and then call ```ssw_lib.CSsw```
-5. Call APIs with input parameters and parse the results (Please see pyssw.py as an example).
+    * For a definitive inclusion edit `/etc/ld.so.conf` and add the path of the `libssw.so`. Then, update the cache by `/sbin/ldconfig`.
+
+4. In a Python script or in a interactive interpreter, import the CSsw class by: `from ssw_lib import CSsw` or `import ssw_lib` and then call `ssw_lib.CSsw`.
+
+5. Call APIs with input parameters and parse the results (Please see `pyssw.py` as an example).
+
+### Run pyssw standalone
 
-###Run pyssw standalone 
 ```
 usage: pyssw.py [-h] [-l SLIBPATH] [-m NMATCH] [-x NMISMATCH] [-o NOPEN]
                 [-e NEXT] [-p] [-a SMATRIX] [-c] [-f NTHR] [-r] [-s] [-header]
@@ -193,38 +214,41 @@ optional arguments:
   -header, --bHeader    If -s is used, include header in SAM output.
 ```
 
-###pyssw output
+### pyssw output
 
-The software can output SAM format or BLAST like format results. 
+The software can output SAM format or BLAST like format results.
 
-###Speed and memory usage of pyssw
+### Speed and memory usage of pyssw
 
-The speed and memory are about the same as the c library.
-	
-##Java interface
+The speed and memory are about the same as the C library.
 
-The java wrapper is a thin JNI (Java Native Interface) wrapper around the native C implementation.
+## Java interface
 
-###Building
+The Java wrapper is a thin JNI (Java Native Interface) wrapper around the native C implementation.
 
-Only the C, C++ and C shared libraries are generated from the default make goal, and as such, the java interface must be built explicitly.
+### Building
 
-1. Ensure `javac` and `jar` are on path
-2. Ensure JAVA_HOME is set to an installed JRE or JDK, or the JNI include directory is included in the C system library search path
+Only the C, C++, and C shared libraries are generated from the default make goal, and as such, the Java interface must be built explicitly.
+
+1. Ensure `javac` and `jar` are in `PATH`.
+2. Ensure `JAVA_HOME` is set to an installed JRE or JDK, or the JNI include directory is included in the C system library search path.
 3. `make java` from the src directory.
-4. libsswjni.so and ssw.jar should be built.
+4. `libsswjni.so` and `ssw.jar` should be built.
+
+### How to use the Java wrapper
+
+The Java wrapper consist of the following components:
 
-###How to use the java wrapper
+* `libsswjni.so`: native C library exposing the JNI entry points
+* `ssw.jar` is a Java library containing the Java interface to the native C library. This small wrapper library is composed of:
 
-The java wrapper consist of the following components:
+    * `ssw.Aligner` Java class: a thread-safe static class that exposes two `align()` methods. The first exposes the SSW C library directly. No error checking is performed on arguments passed to this method and misuse is highly likely to crash the JVM. The second `align()` method is a more user-friendly entry point that exposes a simpler API and performs some basic error checking.
+    * `ssw.Alignment` Java class: this class stores alignment results. Each each field has a direct correspondence and identical meaning to the C s_align struct.
+    * `ssw.Example` Java class: Java version of the example_c sample code. Run `java -jar ssw.jar` to execute the sample.
 
-* libsswjni.so: native C library exposing the JNI entry points
-* ssw.jar is a java library containing the Java interface to the native C library. This small wrapper library is composed of:
-    * ssw.Aligner java class: a thread-safe static class that exposes two `align()` methods. The first exposes the SSW C library directly. No error checking is performed on arguments passed to this method and misuse is highly likely to crash the JVM. The second align() method is a more user-friendly entry point that exposes a simpler API and performs some basic error checking.
-    * ssw.Alignment java class: this class stores alignment results. Each each field has a direct correspondence and identical meaning to the C s_align struct.
-    * ssw.Example java class: java version of the example_c sample code. Run `java -jar ssw.jar` to execute the sample.
+To use the library, either reference the `ssw.jar` or including the Aligner and Alignment classes directly. As for any JNI library, the native library must be loaded (using `System.loadLibrary("sswjni")` or similar) before invokation of native methods. For the JVM to find the library, ensure that either the library is included in the `LD_LIBRARY_PATH` environment variable, or `-Djava.library.path=<directory containing libsswjni.so>` is set on the Java command line.
 
-To use the library, either reference the ssw.jar or including the Aligner and Alignment classes directly. As for any JNI library, the native library must be loaded (using `System.loadLibrary("sswjni")` or similar) before invokation of native methods. For the JVM to find the library, ensure that either the library is included in the LD_LIBRARY_PATH environment variable, or `-Djava.library.path=<directory containing libsswjni.so>` is set on the java command line.
+## Citation
 
-###Please cite this paper, if you need:
-http://dx.plos.org/10.1371/journal.pone.0082138
+Please cite this paper, if you need:
+https://doi.org/10.1371/journal.pone.0082138


=====================================
demo/new.txt
=====================================
@@ -0,0 +1,400 @@
+target_name: chr3
+query_name: 6:163296599:F:198;None;None/1
+optimal_alignment_score: 53	suboptimal_alignment_score: 52	strand: +	target_end: 745864	query_end: 54
+
+target_name: chr3
+query_name: 3:153409880:F:224;None;3,153410143,G,A/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 45	strand: +	target_end: 350986	query_end: 53
+
+target_name: chr3
+query_name: Y:26750420:R:-132;None;None/1
+optimal_alignment_score: 50	suboptimal_alignment_score: 49	strand: +	target_end: 319376	query_end: 52
+
+target_name: chr3
+query_name: 13:91170622:R:-276;None;None/1
+optimal_alignment_score: 49	suboptimal_alignment_score: 48	strand: +	target_end: 353946	query_end: 49
+
+target_name: chr3
+query_name: 15:37079528:R:-240;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 39	strand: +	target_end: 257705	query_end: 53
+
+target_name: chr3
+query_name: 9:92308501:R:-176;None;None/1
+optimal_alignment_score: 80	suboptimal_alignment_score: 70	strand: +	target_end: 105983	query_end: 48
+
+target_name: chr3
+query_name: 3:109533106:R:-128;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 42	strand: +	target_end: 198965	query_end: 47
+
+target_name: chr3
+query_name: 16:32366683:R:-158;16,32366730,G,A;None/1
+optimal_alignment_score: 50	suboptimal_alignment_score: 46	strand: +	target_end: 823370	query_end: 52
+
+target_name: chr3
+query_name: 13:111809970:R:-237;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 40	strand: +	target_end: 509164	query_end: 53
+
+target_name: chr3
+query_name: 3:38871305:F:159;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 37	strand: +	target_end: 841259	query_end: 54
+
+target_name: chr3
+query_name: 19:8434785:F:295;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 43	strand: +	target_end: 330617	query_end: 53
+
+target_name: chr3
+query_name: 8:132563397:R:-144;None;None/1
+optimal_alignment_score: 49	suboptimal_alignment_score: 40	strand: +	target_end: 54827	query_end: 54
+
+target_name: chr3
+query_name: 3:190507952:R:-57;3,190507958,G,A;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 41	strand: +	target_end: 138110	query_end: 54
+
+target_name: chr3
+query_name: 10:59883855:R:-120;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 43	strand: +	target_end: 244247	query_end: 53
+
+target_name: chr3
+query_name: 6:148630669:R:-271;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 39	strand: +	target_end: 658593	query_end: 54
+
+target_name: chr3
+query_name: 3:64518566:R:-93;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 45	strand: +	target_end: 881546	query_end: 44
+
+target_name: chr3
+query_name: 14:42514746:R:-187;None;None/1
+optimal_alignment_score: 58	suboptimal_alignment_score: 58	strand: +	target_end: 206906	query_end: 48
+
+target_name: chr3
+query_name: 7:126497810:R:-191;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 40	strand: +	target_end: 232372	query_end: 54
+
+target_name: chr3
+query_name: 21:15123085:R:-140;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 43	strand: +	target_end: 492310	query_end: 51
+
+target_name: chr3
+query_name: 2:217172401:R:-226;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 41	strand: +	target_end: 261738	query_end: 54
+
+target_name: chr3
+query_name: 6:129456169:R:-167;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 39	strand: +	target_end: 750865	query_end: 53
+
+target_name: chr3
+query_name: 4:160333309:R:-131;None;4,160333230,T,G/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 41	strand: +	target_end: 465814	query_end: 54
+
+target_name: chr3
+query_name: 3:37890126:R:-228;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 40	strand: +	target_end: 661952	query_end: 53
+
+target_name: chr3
+query_name: 17:49899522:F:154;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 46	strand: +	target_end: 94043	query_end: 51
+
+target_name: chr3
+query_name: 8:138662818:R:-211;None;8,138662609,C,T/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 41	strand: +	target_end: 175380	query_end: 50
+
+target_name: chr3
+query_name: 3:97260940:R:-254;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 38	strand: +	target_end: 903012	query_end: 54
+
+target_name: chr3
+query_name: 7:14401638:F:350;None;None/1
+optimal_alignment_score: 50	suboptimal_alignment_score: 47	strand: +	target_end: 265434	query_end: 48
+
+target_name: chr3
+query_name: 13:19068477:F:246;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 45	strand: +	target_end: 628991	query_end: 54
+
+target_name: chr3
+query_name: 3:179655047:F:206;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 44	strand: +	target_end: 476787	query_end: 51
+
+target_name: chr3
+query_name: 20:15001091:F:174;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 226051	query_end: 51
+
+target_name: chr3
+query_name: 2:54967337:R:-153;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 42	strand: +	target_end: 689523	query_end: 54
+
+target_name: chr3
+query_name: 18:39435195:F:202;None;None/1
+optimal_alignment_score: 51	suboptimal_alignment_score: 45	strand: +	target_end: 998370	query_end: 53
+
+target_name: chr3
+query_name: X:68133790:F:167;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 40	strand: +	target_end: 612440	query_end: 50
+
+target_name: chr3
+query_name: 9:18241281:F:267;None;None/1
+optimal_alignment_score: 53	suboptimal_alignment_score: 49	strand: +	target_end: 872860	query_end: 53
+
+target_name: chr3
+query_name: 7:141812631:F:239;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 40	strand: +	target_end: 510995	query_end: 44
+
+target_name: chr3
+query_name: 15:54133744:R:-269;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 40	strand: +	target_end: 725603	query_end: 53
+
+target_name: chr3
+query_name: 4:66588719:R:-245;None;None/1
+optimal_alignment_score: 58	suboptimal_alignment_score: 58	strand: +	target_end: 163129	query_end: 54
+
+target_name: chr3
+query_name: 1:217587184:F:229;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 46	strand: +	target_end: 196793	query_end: 52
+
+target_name: chr3
+query_name: 2:119213044:R:-184;None;None/1
+optimal_alignment_score: 49	suboptimal_alignment_score: 44	strand: +	target_end: 552663	query_end: 50
+
+target_name: chr3
+query_name: 2:36811349:F:265;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 945971	query_end: 52
+
+target_name: chr3
+query_name: 1:68786835:F:349;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 45	strand: +	target_end: 528144	query_end: 52
+
+target_name: chr3
+query_name: 4:126634771:F:185;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 42	strand: +	target_end: 745309	query_end: 50
+
+target_name: chr3
+query_name: 4:114171402:R:-296;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 751541	query_end: 53
+
+target_name: chr3
+query_name: 9:125206364:R:-140;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 39	strand: +	target_end: 932480	query_end: 50
+
+target_name: chr3
+query_name: X:25208394:F:245;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 41	strand: +	target_end: 696734	query_end: 52
+
+target_name: chr3
+query_name: 2:222217158:F:227;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 40	strand: +	target_end: 704921	query_end: 53
+
+target_name: chr3
+query_name: 1:196837088:F:230;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 45	strand: +	target_end: 563639	query_end: 53
+
+target_name: chr3
+query_name: 7:24300836:R:-208;7,24300863,*,+1T;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 239063	query_end: 54
+
+target_name: chr3
+query_name: 1:76948473:F:230;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 45	strand: +	target_end: 386767	query_end: 54
+
+target_name: chr3
+query_name: 8:62727783:F:135;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 46	strand: +	target_end: 406541	query_end: 54
+
+target_name: chr3
+query_name: 7:94677617:R:-155;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 46	strand: +	target_end: 345086	query_end: 54
+
+target_name: chr3
+query_name: 4:10707991:F:305;None;None/1
+optimal_alignment_score: 94	suboptimal_alignment_score: 86	strand: +	target_end: 198089	query_end: 53
+
+target_name: chr3
+query_name: 1:183203391:R:-141;None;None/1
+optimal_alignment_score: 48	suboptimal_alignment_score: 45	strand: +	target_end: 344874	query_end: 53
+
+target_name: chr3
+query_name: 15:63526307:R:-83;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 40	strand: +	target_end: 78739	query_end: 52
+
+target_name: chr3
+query_name: 8:79068236:F:137;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 42	strand: +	target_end: 326507	query_end: 47
+
+target_name: chr3
+query_name: 9:1290219:R:-251;None;None/1
+optimal_alignment_score: 84	suboptimal_alignment_score: 80	strand: +	target_end: 537411	query_end: 54
+
+target_name: chr3
+query_name: 5:122248402:R:-212;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 39	strand: +	target_end: 40834	query_end: 52
+
+target_name: chr3
+query_name: X:153897575:R:-263;None;None/1
+optimal_alignment_score: 75	suboptimal_alignment_score: 74	strand: +	target_end: 223405	query_end: 49
+
+target_name: chr3
+query_name: 6:95453360:F:204;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 42	strand: +	target_end: 182708	query_end: 52
+
+target_name: chr3
+query_name: 10:6951101:R:-212;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 38	strand: +	target_end: 897043	query_end: 47
+
+target_name: chr3
+query_name: 13:59325230:F:98;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 38	strand: +	target_end: 773481	query_end: 54
+
+target_name: chr3
+query_name: 3:37059536:F:184;None;None/1
+optimal_alignment_score: 49	suboptimal_alignment_score: 44	strand: +	target_end: 899262	query_end: 54
+
+target_name: chr3
+query_name: 9:91156368:F:149;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 42	strand: +	target_end: 606747	query_end: 51
+
+target_name: chr3
+query_name: 12:55970708:R:-246;12,55970762,C,T;None/1
+optimal_alignment_score: 92	suboptimal_alignment_score: 88	strand: +	target_end: 771042	query_end: 54
+
+target_name: chr3
+query_name: 3:120828442:F:203;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 41	strand: +	target_end: 595794	query_end: 50
+
+target_name: chr3
+query_name: 19:60104965:R:-147;None;None/1
+optimal_alignment_score: 65	suboptimal_alignment_score: 64	strand: +	target_end: 866783	query_end: 52
+
+target_name: chr3
+query_name: 11:98782460:R:-46;None;None/1
+optimal_alignment_score: 56	suboptimal_alignment_score: 42	strand: +	target_end: 819223	query_end: 51
+
+target_name: chr3
+query_name: 12:91111930:F:209;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 42	strand: +	target_end: 679515	query_end: 51
+
+target_name: chr3
+query_name: 3:192601514:F:196;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 40	strand: +	target_end: 392672	query_end: 40
+
+target_name: chr3
+query_name: X:47989386:R:-46;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 36	strand: +	target_end: 793950	query_end: 54
+
+target_name: chr3
+query_name: 2:39824446:R:-127;None;None/1
+optimal_alignment_score: 72	suboptimal_alignment_score: 70	strand: +	target_end: 972352	query_end: 54
+
+target_name: chr3
+query_name: 1:227528596:F:219;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 869543	query_end: 51
+
+target_name: chr3
+query_name: X:4440324:R:-90;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 40	strand: +	target_end: 100289	query_end: 52
+
+target_name: chr3
+query_name: X:73634281:F:88;None;None/1
+optimal_alignment_score: 52	suboptimal_alignment_score: 41	strand: +	target_end: 922600	query_end: 49
+
+target_name: chr3
+query_name: 3:53909823:F:239;None;3,53910104,T,C/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 44	strand: +	target_end: 640897	query_end: 47
+
+target_name: chr3
+query_name: 3:170059370:R:-173;None;3,170059212,G,C/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 483764	query_end: 54
+
+target_name: chr3
+query_name: 20:8823533:F:251;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 38	strand: +	target_end: 887639	query_end: 49
+
+target_name: chr3
+query_name: 5:106802036:F:200;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 137797	query_end: 53
+
+target_name: chr3
+query_name: 5:74632980:R:-252;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 297976	query_end: 54
+
+target_name: chr3
+query_name: 12:84751900:F:268;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 42	strand: +	target_end: 183485	query_end: 48
+
+target_name: chr3
+query_name: X:135811790:R:-164;None;None/1
+optimal_alignment_score: 48	suboptimal_alignment_score: 44	strand: +	target_end: 178654	query_end: 54
+
+target_name: chr3
+query_name: 10:53108829:R:-138;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 42	strand: +	target_end: 625392	query_end: 50
+
+target_name: chr3
+query_name: 11:83660431:R:-245;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 44	strand: +	target_end: 226749	query_end: 54
+
+target_name: chr3
+query_name: 10:119650756:F:207;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 529549	query_end: 41
+
+target_name: chr3
+query_name: 2:154848222:R:-185;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 43	strand: +	target_end: 585761	query_end: 54
+
+target_name: chr3
+query_name: 3:63918850:F:276;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 41	strand: +	target_end: 345340	query_end: 50
+
+target_name: chr3
+query_name: 10:11447534:F:239;None;None/1
+optimal_alignment_score: 38	suboptimal_alignment_score: 38	strand: +	target_end: 114931	query_end: 52
+
+target_name: chr3
+query_name: 1:57651555:R:-316;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 44	strand: +	target_end: 104219	query_end: 54
+
+target_name: chr3
+query_name: X:91671697:R:-206;None;X,91671506,G,A/1
+optimal_alignment_score: 48	suboptimal_alignment_score: 47	strand: +	target_end: 771479	query_end: 49
+
+target_name: chr3
+query_name: 12:101622421:R:-187;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 44	strand: +	target_end: 361502	query_end: 49
+
+target_name: chr3
+query_name: 13:43163355:R:-200;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 42	strand: +	target_end: 167308	query_end: 53
+
+target_name: chr3
+query_name: 19:37349825:R:-160;None;None/1
+optimal_alignment_score: 70	suboptimal_alignment_score: 68	strand: +	target_end: 261459	query_end: 54
+
+target_name: chr3
+query_name: 8:41173199:R:-175;None;8,41173056,T,C/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 644612	query_end: 47
+
+target_name: chr3
+query_name: 16:29068055:R:-232;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 40	strand: +	target_end: 934198	query_end: 53
+
+target_name: chr3
+query_name: 1:4694340:F:179;None;None/1
+optimal_alignment_score: 48	suboptimal_alignment_score: 45	strand: +	target_end: 140768	query_end: 54
+
+target_name: chr3
+query_name: 17:76451446:F:221;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 40	strand: +	target_end: 561765	query_end: 54
+
+target_name: chr3
+query_name: 1:242817485:F:158;None;None/1
+optimal_alignment_score: 52	suboptimal_alignment_score: 46	strand: +	target_end: 396383	query_end: 50
+
+target_name: chr3
+query_name: 18:29611708:R:-146;None;18,29611585,G,A/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 40	strand: +	target_end: 157255	query_end: 47
+
+target_name: chr3
+query_name: 9:36493018:F:206;None;None/1
+optimal_alignment_score: 82	suboptimal_alignment_score: 80	strand: +	target_end: 872774	query_end: 54
+
+target_name: chr3
+query_name: 9:16274705:F:129;9,16274709,C,A:9,16274719,C,G:9,16274741,A,T;9,16274862,A,G/1
+optimal_alignment_score: 72	suboptimal_alignment_score: 64	strand: +	target_end: 524699	query_end: 54
+


=====================================
demo/old.txt
=====================================
@@ -0,0 +1,400 @@
+target_name: chr3
+query_name: 6:163296599:F:198;None;None/1
+optimal_alignment_score: 53	suboptimal_alignment_score: 52	strand: +	target_end: 745864	query_end: 54
+
+target_name: chr3
+query_name: 3:153409880:F:224;None;3,153410143,G,A/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 45	strand: +	target_end: 350986	query_end: 53
+
+target_name: chr3
+query_name: Y:26750420:R:-132;None;None/1
+optimal_alignment_score: 50	suboptimal_alignment_score: 49	strand: +	target_end: 319376	query_end: 52
+
+target_name: chr3
+query_name: 13:91170622:R:-276;None;None/1
+optimal_alignment_score: 49	suboptimal_alignment_score: 48	strand: +	target_end: 353946	query_end: 49
+
+target_name: chr3
+query_name: 15:37079528:R:-240;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 39	strand: +	target_end: 257705	query_end: 53
+
+target_name: chr3
+query_name: 9:92308501:R:-176;None;None/1
+optimal_alignment_score: 80	suboptimal_alignment_score: 70	strand: +	target_end: 105983	query_end: 48
+
+target_name: chr3
+query_name: 3:109533106:R:-128;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 42	strand: +	target_end: 198965	query_end: 47
+
+target_name: chr3
+query_name: 16:32366683:R:-158;16,32366730,G,A;None/1
+optimal_alignment_score: 50	suboptimal_alignment_score: 46	strand: +	target_end: 823370	query_end: 52
+
+target_name: chr3
+query_name: 13:111809970:R:-237;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 40	strand: +	target_end: 509164	query_end: 53
+
+target_name: chr3
+query_name: 3:38871305:F:159;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 37	strand: +	target_end: 841259	query_end: 54
+
+target_name: chr3
+query_name: 19:8434785:F:295;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 43	strand: +	target_end: 330617	query_end: 53
+
+target_name: chr3
+query_name: 8:132563397:R:-144;None;None/1
+optimal_alignment_score: 49	suboptimal_alignment_score: 40	strand: +	target_end: 54827	query_end: 54
+
+target_name: chr3
+query_name: 3:190507952:R:-57;3,190507958,G,A;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 41	strand: +	target_end: 138110	query_end: 54
+
+target_name: chr3
+query_name: 10:59883855:R:-120;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 43	strand: +	target_end: 244247	query_end: 53
+
+target_name: chr3
+query_name: 6:148630669:R:-271;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 39	strand: +	target_end: 658593	query_end: 54
+
+target_name: chr3
+query_name: 3:64518566:R:-93;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 45	strand: +	target_end: 881546	query_end: 44
+
+target_name: chr3
+query_name: 14:42514746:R:-187;None;None/1
+optimal_alignment_score: 58	suboptimal_alignment_score: 58	strand: +	target_end: 206906	query_end: 48
+
+target_name: chr3
+query_name: 7:126497810:R:-191;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 40	strand: +	target_end: 232372	query_end: 54
+
+target_name: chr3
+query_name: 21:15123085:R:-140;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 43	strand: +	target_end: 492310	query_end: 51
+
+target_name: chr3
+query_name: 2:217172401:R:-226;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 41	strand: +	target_end: 261738	query_end: 54
+
+target_name: chr3
+query_name: 6:129456169:R:-167;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 39	strand: +	target_end: 750865	query_end: 53
+
+target_name: chr3
+query_name: 4:160333309:R:-131;None;4,160333230,T,G/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 41	strand: +	target_end: 465814	query_end: 54
+
+target_name: chr3
+query_name: 3:37890126:R:-228;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 40	strand: +	target_end: 661952	query_end: 53
+
+target_name: chr3
+query_name: 17:49899522:F:154;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 46	strand: +	target_end: 94043	query_end: 51
+
+target_name: chr3
+query_name: 8:138662818:R:-211;None;8,138662609,C,T/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 41	strand: +	target_end: 175380	query_end: 50
+
+target_name: chr3
+query_name: 3:97260940:R:-254;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 38	strand: +	target_end: 903012	query_end: 54
+
+target_name: chr3
+query_name: 7:14401638:F:350;None;None/1
+optimal_alignment_score: 50	suboptimal_alignment_score: 47	strand: +	target_end: 265434	query_end: 48
+
+target_name: chr3
+query_name: 13:19068477:F:246;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 45	strand: +	target_end: 628991	query_end: 54
+
+target_name: chr3
+query_name: 3:179655047:F:206;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 44	strand: +	target_end: 476787	query_end: 51
+
+target_name: chr3
+query_name: 20:15001091:F:174;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 226051	query_end: 51
+
+target_name: chr3
+query_name: 2:54967337:R:-153;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 42	strand: +	target_end: 689523	query_end: 54
+
+target_name: chr3
+query_name: 18:39435195:F:202;None;None/1
+optimal_alignment_score: 51	suboptimal_alignment_score: 45	strand: +	target_end: 998370	query_end: 53
+
+target_name: chr3
+query_name: X:68133790:F:167;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 40	strand: +	target_end: 612440	query_end: 50
+
+target_name: chr3
+query_name: 9:18241281:F:267;None;None/1
+optimal_alignment_score: 53	suboptimal_alignment_score: 49	strand: +	target_end: 872860	query_end: 53
+
+target_name: chr3
+query_name: 7:141812631:F:239;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 40	strand: +	target_end: 510995	query_end: 44
+
+target_name: chr3
+query_name: 15:54133744:R:-269;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 40	strand: +	target_end: 725603	query_end: 53
+
+target_name: chr3
+query_name: 4:66588719:R:-245;None;None/1
+optimal_alignment_score: 58	suboptimal_alignment_score: 58	strand: +	target_end: 163129	query_end: 54
+
+target_name: chr3
+query_name: 1:217587184:F:229;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 46	strand: +	target_end: 196793	query_end: 52
+
+target_name: chr3
+query_name: 2:119213044:R:-184;None;None/1
+optimal_alignment_score: 49	suboptimal_alignment_score: 44	strand: +	target_end: 552663	query_end: 50
+
+target_name: chr3
+query_name: 2:36811349:F:265;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 945971	query_end: 52
+
+target_name: chr3
+query_name: 1:68786835:F:349;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 45	strand: +	target_end: 528144	query_end: 52
+
+target_name: chr3
+query_name: 4:126634771:F:185;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 42	strand: +	target_end: 745309	query_end: 50
+
+target_name: chr3
+query_name: 4:114171402:R:-296;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 751541	query_end: 53
+
+target_name: chr3
+query_name: 9:125206364:R:-140;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 39	strand: +	target_end: 932480	query_end: 50
+
+target_name: chr3
+query_name: X:25208394:F:245;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 41	strand: +	target_end: 696734	query_end: 52
+
+target_name: chr3
+query_name: 2:222217158:F:227;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 40	strand: +	target_end: 704921	query_end: 53
+
+target_name: chr3
+query_name: 1:196837088:F:230;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 45	strand: +	target_end: 563639	query_end: 53
+
+target_name: chr3
+query_name: 7:24300836:R:-208;7,24300863,*,+1T;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 239063	query_end: 54
+
+target_name: chr3
+query_name: 1:76948473:F:230;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 45	strand: +	target_end: 386767	query_end: 54
+
+target_name: chr3
+query_name: 8:62727783:F:135;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 46	strand: +	target_end: 406541	query_end: 54
+
+target_name: chr3
+query_name: 7:94677617:R:-155;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 46	strand: +	target_end: 345086	query_end: 54
+
+target_name: chr3
+query_name: 4:10707991:F:305;None;None/1
+optimal_alignment_score: 94	suboptimal_alignment_score: 86	strand: +	target_end: 198089	query_end: 53
+
+target_name: chr3
+query_name: 1:183203391:R:-141;None;None/1
+optimal_alignment_score: 48	suboptimal_alignment_score: 45	strand: +	target_end: 344874	query_end: 53
+
+target_name: chr3
+query_name: 15:63526307:R:-83;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 40	strand: +	target_end: 78739	query_end: 52
+
+target_name: chr3
+query_name: 8:79068236:F:137;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 42	strand: +	target_end: 326507	query_end: 47
+
+target_name: chr3
+query_name: 9:1290219:R:-251;None;None/1
+optimal_alignment_score: 84	suboptimal_alignment_score: 80	strand: +	target_end: 537411	query_end: 54
+
+target_name: chr3
+query_name: 5:122248402:R:-212;None;None/1
+optimal_alignment_score: 40	suboptimal_alignment_score: 39	strand: +	target_end: 40834	query_end: 52
+
+target_name: chr3
+query_name: X:153897575:R:-263;None;None/1
+optimal_alignment_score: 75	suboptimal_alignment_score: 74	strand: +	target_end: 223405	query_end: 49
+
+target_name: chr3
+query_name: 6:95453360:F:204;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 42	strand: +	target_end: 182708	query_end: 52
+
+target_name: chr3
+query_name: 10:6951101:R:-212;None;None/1
+optimal_alignment_score: 41	suboptimal_alignment_score: 38	strand: +	target_end: 897043	query_end: 47
+
+target_name: chr3
+query_name: 13:59325230:F:98;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 38	strand: +	target_end: 773481	query_end: 54
+
+target_name: chr3
+query_name: 3:37059536:F:184;None;None/1
+optimal_alignment_score: 49	suboptimal_alignment_score: 44	strand: +	target_end: 899262	query_end: 54
+
+target_name: chr3
+query_name: 9:91156368:F:149;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 42	strand: +	target_end: 606747	query_end: 51
+
+target_name: chr3
+query_name: 12:55970708:R:-246;12,55970762,C,T;None/1
+optimal_alignment_score: 92	suboptimal_alignment_score: 88	strand: +	target_end: 771042	query_end: 54
+
+target_name: chr3
+query_name: 3:120828442:F:203;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 41	strand: +	target_end: 595794	query_end: 50
+
+target_name: chr3
+query_name: 19:60104965:R:-147;None;None/1
+optimal_alignment_score: 65	suboptimal_alignment_score: 64	strand: +	target_end: 866783	query_end: 52
+
+target_name: chr3
+query_name: 11:98782460:R:-46;None;None/1
+optimal_alignment_score: 56	suboptimal_alignment_score: 42	strand: +	target_end: 819223	query_end: 51
+
+target_name: chr3
+query_name: 12:91111930:F:209;None;None/1
+optimal_alignment_score: 43	suboptimal_alignment_score: 42	strand: +	target_end: 679515	query_end: 51
+
+target_name: chr3
+query_name: 3:192601514:F:196;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 40	strand: +	target_end: 392672	query_end: 40
+
+target_name: chr3
+query_name: X:47989386:R:-46;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 36	strand: +	target_end: 793950	query_end: 54
+
+target_name: chr3
+query_name: 2:39824446:R:-127;None;None/1
+optimal_alignment_score: 72	suboptimal_alignment_score: 70	strand: +	target_end: 972352	query_end: 54
+
+target_name: chr3
+query_name: 1:227528596:F:219;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 869543	query_end: 51
+
+target_name: chr3
+query_name: X:4440324:R:-90;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 40	strand: +	target_end: 100289	query_end: 52
+
+target_name: chr3
+query_name: X:73634281:F:88;None;None/1
+optimal_alignment_score: 52	suboptimal_alignment_score: 41	strand: +	target_end: 922600	query_end: 49
+
+target_name: chr3
+query_name: 3:53909823:F:239;None;3,53910104,T,C/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 44	strand: +	target_end: 640897	query_end: 47
+
+target_name: chr3
+query_name: 3:170059370:R:-173;None;3,170059212,G,C/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 483764	query_end: 54
+
+target_name: chr3
+query_name: 20:8823533:F:251;None;None/1
+optimal_alignment_score: 39	suboptimal_alignment_score: 38	strand: +	target_end: 887639	query_end: 49
+
+target_name: chr3
+query_name: 5:106802036:F:200;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 137797	query_end: 53
+
+target_name: chr3
+query_name: 5:74632980:R:-252;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 297976	query_end: 54
+
+target_name: chr3
+query_name: 12:84751900:F:268;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 42	strand: +	target_end: 183485	query_end: 48
+
+target_name: chr3
+query_name: X:135811790:R:-164;None;None/1
+optimal_alignment_score: 48	suboptimal_alignment_score: 44	strand: +	target_end: 178654	query_end: 54
+
+target_name: chr3
+query_name: 10:53108829:R:-138;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 42	strand: +	target_end: 625392	query_end: 50
+
+target_name: chr3
+query_name: 11:83660431:R:-245;None;None/1
+optimal_alignment_score: 47	suboptimal_alignment_score: 44	strand: +	target_end: 226749	query_end: 54
+
+target_name: chr3
+query_name: 10:119650756:F:207;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 42	strand: +	target_end: 529549	query_end: 41
+
+target_name: chr3
+query_name: 2:154848222:R:-185;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 43	strand: +	target_end: 585761	query_end: 54
+
+target_name: chr3
+query_name: 3:63918850:F:276;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 41	strand: +	target_end: 345340	query_end: 50
+
+target_name: chr3
+query_name: 10:11447534:F:239;None;None/1
+optimal_alignment_score: 38	suboptimal_alignment_score: 38	strand: +	target_end: 114931	query_end: 52
+
+target_name: chr3
+query_name: 1:57651555:R:-316;None;None/1
+optimal_alignment_score: 46	suboptimal_alignment_score: 44	strand: +	target_end: 104219	query_end: 54
+
+target_name: chr3
+query_name: X:91671697:R:-206;None;X,91671506,G,A/1
+optimal_alignment_score: 48	suboptimal_alignment_score: 47	strand: +	target_end: 771479	query_end: 49
+
+target_name: chr3
+query_name: 12:101622421:R:-187;None;None/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 44	strand: +	target_end: 361502	query_end: 49
+
+target_name: chr3
+query_name: 13:43163355:R:-200;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 42	strand: +	target_end: 167308	query_end: 53
+
+target_name: chr3
+query_name: 19:37349825:R:-160;None;None/1
+optimal_alignment_score: 70	suboptimal_alignment_score: 68	strand: +	target_end: 261459	query_end: 54
+
+target_name: chr3
+query_name: 8:41173199:R:-175;None;8,41173056,T,C/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 43	strand: +	target_end: 644612	query_end: 47
+
+target_name: chr3
+query_name: 16:29068055:R:-232;None;None/1
+optimal_alignment_score: 44	suboptimal_alignment_score: 40	strand: +	target_end: 934198	query_end: 53
+
+target_name: chr3
+query_name: 1:4694340:F:179;None;None/1
+optimal_alignment_score: 48	suboptimal_alignment_score: 45	strand: +	target_end: 140768	query_end: 54
+
+target_name: chr3
+query_name: 17:76451446:F:221;None;None/1
+optimal_alignment_score: 42	suboptimal_alignment_score: 40	strand: +	target_end: 561765	query_end: 54
+
+target_name: chr3
+query_name: 1:242817485:F:158;None;None/1
+optimal_alignment_score: 52	suboptimal_alignment_score: 46	strand: +	target_end: 396383	query_end: 50
+
+target_name: chr3
+query_name: 18:29611708:R:-146;None;18,29611585,G,A/1
+optimal_alignment_score: 45	suboptimal_alignment_score: 40	strand: +	target_end: 157255	query_end: 47
+
+target_name: chr3
+query_name: 9:36493018:F:206;None;None/1
+optimal_alignment_score: 82	suboptimal_alignment_score: 80	strand: +	target_end: 872774	query_end: 54
+
+target_name: chr3
+query_name: 9:16274705:F:129;9,16274709,C,A:9,16274719,C,G:9,16274741,A,T;9,16274862,A,G/1
+optimal_alignment_score: 72	suboptimal_alignment_score: 64	strand: +	target_end: 524699	query_end: 54
+


=====================================
demo/output.sam
=====================================


=====================================
demo/pRead.fa
=====================================
@@ -0,0 +1,3 @@
+>read
+AGGTAGGTAGGTAGGTAGGTAGGTAGGTAGGTAGGTAGGT
+


=====================================
demo/pRef.fa
=====================================
@@ -0,0 +1,3 @@
+>ref
+CCCAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCTAGCT
+


=====================================
demo/query.fa
=====================================
@@ -0,0 +1,2 @@
+>query
+CTTG


=====================================
demo/query.fastq
=====================================
@@ -0,0 +1,8 @@
+ at 6:163296599:F:198;None;None/1
+GTGTGAGCCACCACGCCCAGCCCAAAATCTGTTTTAATGGTGGATTTGTGTTTC
++
+%/978679:99788::8888689788888888986637/%/*%--/11,%*/*%
+ at 3:153409880:F:224;None;3,153410143,G,A/1
+AGGAAGAGTTAATTTAAGTCACTTCAAACAGATTACGTATCTTTTTTTTCCCTC
++
+%-;;8;;9289.73697758:5,2984,54687/*8,'.001/550'+'.(9((


=====================================
demo/query1.fa
=====================================
@@ -0,0 +1,2 @@
+>query1
+GATTGTGCGTCAATAAAGTGTGGGATAGTTGA


=====================================
demo/query2.fa
=====================================
@@ -0,0 +1,3 @@
+>query2
+CTTTCCTCCCCCTTGCCCTCTAGCAGGGGCCACCGGAGGAGGAGGGAGGGCAAACGAAGGATGGGGGAAGATGTG
+


=====================================
demo/r1.fa
=====================================
@@ -0,0 +1,2 @@
+>HLA-B*08:01:01_2 AC:HLA00146.1 CR:AJ295294.1,AL669854.0,D84394.0,DQ249172.0,DQ249174.0,HG794374.0,L76093.1,LN624507.0,LN877354.0,LT220237.0,M24036.1,M28204.1,M59841.1
+gctcccactccatgaggtatttcgacaccgccatgtcccggcccggccgcggggagccccgcttcatctcagtgggctacgtggacgacacgcagttcgtgaggttcgacagcgacgccgcgagtccgagagaggagccgcgggcgccgtggatagagcaggaggggccggagtattgggaccggaacacacagatcttcaagaccaacacacagactgaccgagagagcctgcggaacctgcgcggctactacaaccagagcgaggccg


=====================================
demo/r1_query.fq
=====================================
@@ -0,0 +1,4 @@
+ at ST-E00185:49:H5LVWCCXX:5:1101:18001:19276 1:N:0:0
+GGATCCCAGACCCGGAGACTCGGGAGTACCCGGGGCGTCCGTGGGGCATGGAGGTGGGGGGTCGTGATCTGCGCCCTGGGCCGGGGTTACTCACTGGCCTCGCTCTGGTTGTAGTAGCCGCGCAGGGTCTGCAGGTTCATTCTGTCAGTC
++
+AAFFFKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKFKKFKKKKKKKKKKKKKKKKKKKKAKKKKKKKKKKKKKKKKFKAAKAKKKKKKKKKKKKKKKKKKFKKKKKKKAFFKKKKAK<FFA<K


=====================================
demo/target.fa
=====================================
@@ -0,0 +1,2 @@
+>target
+CATTG


=====================================
demo/target.fastq
=====================================
@@ -0,0 +1,8 @@
+ at 20:8823533:F:251;None;None/1
+GTGGTGGATGTCTCAGCAGAGGCCTGCATAGAAAGACGACATTGAGGATCAGTG
++
+CEEECEA?AEEEEE;>CEA5AEEEEB5?EEEEEEEAE>EE=AD at E?B>BBD at BB
+ at 5:106802036:F:200;None;None/1
+TTTTGCTCTCAGTTGTGTCCCAGCAACCATGAGCTGGAAATCCAGAGACTCCTT
++
+EECEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEED?.<EAABCBD=@>AB?D?=


=====================================
demo/target1.fa
=====================================
@@ -0,0 +1,2 @@
+>target1
+GGTCGTGCATCAAAAAAGTGTGGGTTTGTTAA


=====================================
demo/target2.fa
=====================================
@@ -0,0 +1,2 @@
+TATCTCTCTCAACAACAACAACGGAGGAGGAGGAAAAGAGAGAGATATCTCTCTCAACAACAACAACGGAGGAGGAGGAAAAGAGAGAGA
+


=====================================
src/.gitignore deleted
=====================================
@@ -1,12 +0,0 @@
-*.*~
-example_c
-example_cpp
-libssw.so
-libsswjni.so
-ssw.jar
-ssw.o
-ssw/Aligner.class
-ssw/Alignment.class
-ssw/Example.class
-ssw_cpp.o
-ssw_test 


=====================================
src/Makefile
=====================================
@@ -15,6 +15,8 @@ JAVA_OBJ = ssw/Aligner.class ssw/Alignment.class ssw/Example.class
 
 .PHONY: all default java clean
 
+core: $(PROG)
+
 default: $(PROG) $(EXAMPLE) $(EXAMPLE_CPP) $(LIB) 
 
 all: default java


=====================================
src/example.cpp
=====================================
@@ -5,10 +5,11 @@
 // 1) g++ -Wall ssw_cpp.cpp ssw.c example.cpp
 // 2) ./a.out
 // Created by Wan-Ping Lee on 09/04/12.
+// Last revision by Mengyao Zhao on 2017-06-05
 // ==========================
 
 #include <iostream>
-#include <string>
+#include <string.h>
 
 #include "ssw_cpp.h"
 
@@ -21,6 +22,8 @@ static void PrintAlignment(const StripedSmithWaterman::Alignment& alignment);
 int main() {
   const string ref   = "CAGCCTTTCTGACCCGGAAATCAAAATAGGCACAACAAA";
   const string query = "CTGAGCCGGTAAATC";
+  int32_t maskLen = strlen(query.c_str())/2;
+  maskLen = maskLen < 15 ? 15 : maskLen;
   //const string ref   = "CCGTTTATCGCA";
   //const string query = "CCTTTTATCGCA";
 
@@ -31,7 +34,7 @@ int main() {
   // Declares an alignment that stores the result
   StripedSmithWaterman::Alignment alignment;
   // Aligns the query to the ref
-  aligner.Align(query.c_str(), ref.c_str(), ref.size(), filter, &alignment);
+  aligner.Align(query.c_str(), ref.c_str(), ref.size(), filter, &alignment, maskLen);
 
   PrintAlignment(alignment);
 


=====================================
src/main.c
=====================================
@@ -1,7 +1,7 @@
 /*  main.c
  *  Created by Mengyao Zhao on 06/23/11.
- *	Version 1.0
- *  Last revision by Mengyao Zhao on 07/19/16.
+ *	Version 1.2.2
+ *  Last revision by Mengyao Zhao on 2017-05-30.
  */
 
 #include <stdlib.h>
@@ -60,6 +60,8 @@ static void ssw_write (s_align* a,
 			const kseq_t* ref_seq,
 			const kseq_t* read,
 			const char* read_seq,	// strand == 0: original read; strand == 1: reverse complement read
+			const int8_t* ref_num,
+			const int8_t* read_num,
 			const int8_t* table,
 			int8_t strand,	// 0: forward aligned ; 1: reverse complement aligned
 			int8_t sam) {	// 0: Blast like output; 1: Sam format output
@@ -155,56 +157,28 @@ end:
 		fprintf(stdout, "%s\t", read->name.s);
 		if (a->score1 == 0) fprintf(stdout, "4\t*\t0\t255\t*\t*\t0\t0\t*\t*\n");
 		else {
-			int32_t c, l = a->read_end1 - a->read_begin1 + 1, qb = a->ref_begin1, pb = a->read_begin1, p;
+			int32_t c, p;
 			uint32_t mapq = -4.343 * log(1 - (double)abs(a->score1 - a->score2)/(double)a->score1);
 			mapq = (uint32_t) (mapq + 4.99);
 			mapq = mapq < 254 ? mapq : 254;
 			if (strand) fprintf(stdout, "16\t");
 			else fprintf(stdout, "0\t");
 			fprintf(stdout, "%s\t%d\t%d\t", ref_seq->name.s, a->ref_begin1 + 1, mapq);
-			mismatch = mark_mismatch(a->ref_begin1, a->read_begin1, a->read_end1, ref_seq->seq.s, read_seq, read->seq.l, &a->cigar, &a->cigarLen);
+			mismatch = mark_mismatch(a->ref_begin1, a->read_begin1, a->read_end1, ref_num, read_num, read->seq.l, &a->cigar, &a->cigarLen);
 			for (c = 0; c < a->cigarLen; ++c) {
 				char letter = cigar_int_to_op(a->cigar[c]);
 				uint32_t length = cigar_int_to_len(a->cigar[c]);
 				fprintf(stdout, "%lu%c", (unsigned long)length, letter);
 			}
-	//		fprintf(stderr, "%s\tmismatch: %d\n", read->name.s, mismatch);
 			fprintf(stdout, "\t*\t0\t0\t");
-			for (c = a->read_begin1; c <= a->read_end1; ++c) fprintf(stdout, "%c", read_seq[c]);
+			fprintf(stdout, "%s", read_seq);
 			fprintf(stdout, "\t");
 			if (read->qual.s && strand) {
-				p = a->read_end1;
-				for (c = 0; c < l; ++c) {
-					fprintf(stdout, "%c", read->qual.s[p]);
-					--p;
-				}
-			}else if (read->qual.s){
-				p = a->read_begin1;
-				for (c = 0; c < l; ++c) {
-					fprintf(stdout, "%c", read->qual.s[p]);
-					++p;
-				}
-			} else fprintf(stdout, "*");
+				for (p = read->qual.l - 1; p >= 0; --p) fprintf(stdout, "%c", read->qual.s[p]);
+			}else if (read->qual.s) fprintf (stdout, "%s", read->qual.s);
+			else fprintf(stdout, "*");
 			fprintf(stdout, "\tAS:i:%d", a->score1);
-			mapq = 0;	// counter of difference
-			for (c = 0; c < a->cigarLen; ++c) {
-				char letter = cigar_int_to_op(a->cigar[c]);
-				uint32_t length = cigar_int_to_len(a->cigar[c]);
-				if (letter == 'M') {
-					for (p = 0; p < length; ++p){
-						if (table[(int)*(ref_seq->seq.s + qb)] != table[(int)*(read_seq + pb)]) ++mapq;
-						++qb;
-						++pb;
-					}
-				} else if (letter == 'I') {
-					pb += length;
-					mapq += length;
-				} else {
-					qb += length;
-					mapq += length;
-				}
-			}
-			fprintf(stdout,"\tNM:i:%d\t", mapq);
+			fprintf(stdout,"\tNM:i:%d\t", mismatch);
 			if (a->score2 > 0) fprintf(stdout, "ZS:i:%d\n", a->score2);
 			else fprintf(stdout, "\n");
 		}
@@ -367,7 +341,6 @@ int main (int argc, char * const argv[]) {
 		mat = mata;
 	}
 
-	//fprintf(stderr, "query: %s\n", argv[optind + 1]);
 	read_fp = gzopen(argv[optind + 1], "r");
 
     if (! read_fp) {
@@ -436,11 +409,11 @@ int main (int argc, char * const argv[]) {
 			if (reverse == 1 && protein == 0)
 				result_rc = ssw_align(p_rc, ref_num, refLen, gap_open, gap_extension, flag, filter, 0, maskLen);
 			if (result_rc && result_rc->score1 > result->score1 && result_rc->score1 >= filter) {
-				if (sam) ssw_write (result_rc, ref_seq, read_seq, read_rc, table, 1, 1);
-				else ssw_write (result_rc, ref_seq, read_seq, read_rc, table, 1, 0);
+				if (sam) ssw_write (result_rc, ref_seq, read_seq, read_rc, ref_num, num_rc, table, 1, 1);
+				else ssw_write (result_rc, ref_seq, read_seq, read_rc, ref_num, num_rc, table, 1, 0);
 			}else if (result && result->score1 >= filter){
-				if (sam) ssw_write(result, ref_seq, read_seq, read_seq->seq.s, table, 0, 1);
-				else ssw_write(result, ref_seq, read_seq, read_seq->seq.s, table, 0, 0);
+				if (sam) ssw_write(result, ref_seq, read_seq, read_seq->seq.s, ref_num, num, table, 0, 1);
+				else ssw_write(result, ref_seq, read_seq, read_seq->seq.s, ref_num, num, table, 0, 0);
 			} else if (! result) return 1;
 			if (result_rc) align_destroy(result_rc);
 			align_destroy(result);


=====================================
src/pyssw.py
=====================================
@@ -242,7 +242,7 @@ def main(args):
 # print sam head
     if args.bSam and args.bHeader and args.bPath:
         print '@HD\tVN:1.4\tSO:queryname'
-        for sRId,sRSeq,_ in read(sTarget):
+        for sRId,sRSeq,_ in read(args.target):
             print '@SQ\tSN:{}\tLN:{}'.format(sRId, len(sRSeq))
     elif args.bSam and not args.bPath:
         print >> sys.stderr, 'SAM format output is only available together with option -c.\n'


=====================================
src/ssw.c
=====================================
@@ -1,6 +1,6 @@
 /* The MIT License
 
-   Copyright (c) 2012-1015 Boston College.
+   Copyright (c) 2012-2015 Boston College.
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
@@ -23,18 +23,50 @@
    SOFTWARE.
 */
 
-/* Contact: Mengyao Zhao <zhangmp at bc.edu> */
+/* The 2-clause BSD License
+
+   Copyright 2006 Michael Farrar.  
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+   
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+   
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
 
 /*
  *  ssw.c
  *
  *  Created by Mengyao Zhao on 6/22/10.
  *  Copyright 2010 Boston College. All rights reserved.
- *	Version 0.1.4
- *	Last revision by Mengyao Zhao on 07/19/16.
+ *	Version 1.2.4
+ *	Last revision by Mengyao Zhao on 2019-03-04.
+ *
+ *  The lazy-F loop implementation was derived from SWPS3, which is
+ *  MIT licensed under ETH Zürich, Institute of Computational Science.
  *
+ *  The core SW loop referenced the swsse2 implementation, which is
+ *  BSD licensed under Micharl Farrar.
  */
 
+//#include <nmmintrin.h>
 #include <emmintrin.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -85,6 +117,43 @@ struct _profile{
 	uint8_t bias;
 };
 
+/* array index is an ASCII character value from a CIGAR, 
+   element value is the corresponding integer opcode between 0 and 8 */
+const uint8_t encoded_ops[] = {
+	0,         0,         0,         0,
+	0,         0,         0,         0,
+	0,         0,         0,         0,
+	0,         0,         0,         0,
+	0,         0,         0,         0,
+	0,         0,         0,         0,
+	0,         0,         0,         0,
+	0,         0,         0,         0,
+	0 /*   */, 0 /* ! */, 0 /* " */, 0 /* # */,
+	0 /* $ */, 0 /* % */, 0 /* & */, 0 /* ' */,
+	0 /* ( */, 0 /* ) */, 0 /* * */, 0 /* + */,
+	0 /* , */, 0 /* - */, 0 /* . */, 0 /* / */,
+	0 /* 0 */, 0 /* 1 */, 0 /* 2 */, 0 /* 3 */,
+	0 /* 4 */, 0 /* 5 */, 0 /* 6 */, 0 /* 7 */,
+	0 /* 8 */, 0 /* 9 */, 0 /* : */, 0 /* ; */,
+	0 /* < */, 7 /* = */, 0 /* > */, 0 /* ? */,
+	0 /* @ */, 0 /* A */, 0 /* B */, 0 /* C */,
+	2 /* D */, 0 /* E */, 0 /* F */, 0 /* G */,
+	5 /* H */, 1 /* I */, 0 /* J */, 0 /* K */,
+	0 /* L */, 0 /* M */, 3 /* N */, 0 /* O */,
+	6 /* P */, 0 /* Q */, 0 /* R */, 4 /* S */,
+	0 /* T */, 0 /* U */, 0 /* V */, 0 /* W */,
+	8 /* X */, 0 /* Y */, 0 /* Z */, 0 /* [ */,
+	0 /* \ */, 0 /* ] */, 0 /* ^ */, 0 /* _ */,
+	0 /* ` */, 0 /* a */, 0 /* b */, 0 /* c */,
+	0 /* d */, 0 /* e */, 0 /* f */, 0 /* g */,
+	0 /* h */, 0 /* i */, 0 /* j */, 0 /* k */,
+	0 /* l */, 0 /* m */, 0 /* n */, 0 /* o */,
+	0 /* p */, 0 /* q */, 0 /* r */, 0 /* s */,
+	0 /* t */, 0 /* u */, 0 /* v */, 0 /* w */,
+	0 /* x */, 0 /* y */, 0 /* z */, 0 /* { */,
+	0 /* | */, 0 /* } */, 0 /* ~ */, 0 /*  */
+};
+
 /* Generate query profile rearrange query sequence & calculate the weight of match/mismatch. */
 static __m128i* qP_byte (const int8_t* read_num,
 				  const int8_t* mat,
@@ -134,6 +203,7 @@ static alignment_end* sw_sse2_byte (const int8_t* ref,
 	 						 uint8_t bias,  /* Shift 0 point to a positive value. */
 							 int32_t maskLen) {
 
+// Put the largest number of the 16 numbers in vm into m.
 #define max16(m, vm) (vm) = _mm_max_epu8((vm), _mm_srli_si128((vm), 8)); \
 					  (vm) = _mm_max_epu8((vm), _mm_srli_si128((vm), 4)); \
 					  (vm) = _mm_max_epu8((vm), _mm_srli_si128((vm), 2)); \
@@ -159,7 +229,7 @@ static alignment_end* sw_sse2_byte (const int8_t* ref,
 	__m128i* pvE = (__m128i*) calloc(segLen, sizeof(__m128i));
 	__m128i* pvHmax = (__m128i*) calloc(segLen, sizeof(__m128i));
 
-	int32_t i, j;
+	int32_t i, j, k;
 	/* 16 byte insertion begin vector */
 	__m128i vGapO = _mm_set1_epi8(weight_gapO);
 
@@ -223,39 +293,21 @@ static alignment_end* sw_sse2_byte (const int8_t* ref,
 			vH = _mm_load_si128(pvHLoad + j);
 		}
 
-		/* Lazy_F loop: has been revised to disallow adjecent insertion and then deletion, so don't update E(i, j), learn from SWPS3 */
-        /* reset pointers to the start of the saved data */
-        j = 0;
-        vH = _mm_load_si128 (pvHStore + j);
-
-        /*  the computed vF value is for the given column.  since */
-        /*  we are at the end, we need to shift the vF value over */
-        /*  to the next column. */
-        vF = _mm_slli_si128 (vF, 1);
-        vTemp = _mm_subs_epu8 (vH, vGapO);
-		vTemp = _mm_subs_epu8 (vF, vTemp);
-		vTemp = _mm_cmpeq_epi8 (vTemp, vZero);
-		cmp  = _mm_movemask_epi8 (vTemp);
-
-        while (cmp != 0xffff)
-        {
-            vH = _mm_max_epu8 (vH, vF);
-			vMaxColumn = _mm_max_epu8(vMaxColumn, vH);
-            _mm_store_si128 (pvHStore + j, vH);
-            vF = _mm_subs_epu8 (vF, vGapE);
-            j++;
-            if (j >= segLen)
-            {
-                j = 0;
-                vF = _mm_slli_si128 (vF, 1);
-            }
-            vH = _mm_load_si128 (pvHStore + j);
-
-            vTemp = _mm_subs_epu8 (vH, vGapO);
-            vTemp = _mm_subs_epu8 (vF, vTemp);
-            vTemp = _mm_cmpeq_epi8 (vTemp, vZero);
-            cmp  = _mm_movemask_epi8 (vTemp);
-        }
+/* Lazy_F loop: has been revised to disallow adjecent insertion and then deletion, so don't update E(i, j), learn from SWPS3 */
+		for (k = 0; LIKELY(k < 16); ++k) {
+			vF = _mm_slli_si128 (vF, 1);
+			for (j = 0; LIKELY(j < segLen); ++j) {
+				vH = _mm_load_si128(pvHStore + j);
+				vH = _mm_max_epu8(vH, vF);
+				vMaxColumn = _mm_max_epu8(vMaxColumn, vH);	// newly added line
+				_mm_store_si128(pvHStore + j, vH);
+				vH = _mm_subs_epu8(vH, vGapO);
+				vF = _mm_subs_epu8(vF, vGapE);
+				if (UNLIKELY(! _mm_movemask_epi8(_mm_cmpgt_epi8(vF, vH)))) goto end;
+			}
+		}
+
+end:		
 
 		vMaxScore = _mm_max_epu8(vMaxScore, vMaxColumn);
 		vTemp = _mm_cmpeq_epi8(vMaxMark, vMaxScore);
@@ -529,37 +581,6 @@ end:
 	return bests;
 }
 
-/*!     @function               Produce CIGAR 32-bit unsigned integer from CIGAR operation and CIGAR length
-        @param  length          length of CIGAR
-        @param  op_letter       CIGAR operation character ('M', 'I', etc)
-        @return                 32-bit unsigned integer, representing encoded CIGAR operation and length
-*/
-uint32_t to_cigar_int (uint32_t length, char op_letter)
-{
-        switch (op_letter) {
-                case 'M': /* alignment match (can be a sequence match or mismatch */
-                default:
-                        return length << BAM_CIGAR_SHIFT;
-                case 'S': /* soft clipping (clipped sequences present in SEQ) */
-                        return (length << BAM_CIGAR_SHIFT) | (4u);
-                case 'D': /* deletion from the reference */
-                        return (length << BAM_CIGAR_SHIFT) | (2u);
-                case 'I': /* insertion to the reference */
-                        return (length << BAM_CIGAR_SHIFT) | (1u);
-                case 'H': /* hard clipping (clipped sequences NOT present in SEQ) */
-                        return (length << BAM_CIGAR_SHIFT) | (5u);
-                case 'N': /* skipped region from the reference */
-                        return (length << BAM_CIGAR_SHIFT) | (3u);
-                case 'P': /* padding (silent deletion from padded reference) */
-                        return (length << BAM_CIGAR_SHIFT) | (6u);
-                case '=': /* sequence match */
-                        return (length << BAM_CIGAR_SHIFT) | (7u);
-                case 'X': /* sequence mismatch */
-                        return (length << BAM_CIGAR_SHIFT) | (8u);
-        }
-        return (uint32_t)-1; // This never happens
-}
-
 static cigar* banded_sw (const int8_t* ref,
 				 const int8_t* read,
 				 int32_t refLen,
@@ -925,8 +946,8 @@ uint32_t* store_previous_m (int8_t choice,	// 0: current not M, 1: current match
 int32_t mark_mismatch (int32_t ref_begin1,
 					   int32_t read_begin1,
 					   int32_t read_end1,
-					   const char* ref,
-					   const char* read,
+					   const int8_t* ref,
+					   const int8_t* read,
 					   int32_t readLen,
 					   uint32_t** cigar,
 					   int32_t* cigarLen) {
@@ -943,10 +964,8 @@ int32_t mark_mismatch (int32_t ref_begin1,
 		length = cigar_int_to_len((*cigar)[i]);
 		if (op == 'M') {
 			for (j = 0; j < length; ++j) {
-				fprintf(stderr, "ref[%d]: %c\tread[%d]: %c\n", j, *ref, j, *read);
 				if (*ref != *read) {
 					++ mismatch_length;
-					fprintf(stderr, "length_m: %d\n", length_m);
 					// the previous is match; however the current one is mismatche
 					new_cigar = store_previous_m (2, &length_m, &length_x, &p, &s, new_cigar);			
 					++ length_x;


=====================================
src/ssw.h
=====================================
@@ -3,8 +3,8 @@
  *
  *  Created by Mengyao Zhao on 6/22/10.
  *  Copyright 2010 Boston College. All rights reserved.
- *	Version 0.1.4
- *	Last revision by Mengyao Zhao on 07/19/16.
+ *	Version 1.2.3
+ *	Last revision by Mengyao Zhao on 11/29/16.
  *
  */
 
@@ -25,6 +25,7 @@ extern "C" {
 #define BAM_CIGAR_SHIFT 4u
 #endif
 
+extern const uint8_t encoded_ops[];
 
 /*!	@typedef	structure of the query profile	*/
 struct _profile;
@@ -148,8 +149,8 @@ void align_destroy (s_align* a);
 int32_t mark_mismatch (int32_t ref_begin1,
 					   int32_t read_begin1,
 					   int32_t read_end1,
-					   const char* ref,
-					   const char* read,
+					   const int8_t* ref,
+					   const int8_t* read,
 					   int32_t readLen,
 					   uint32_t** cigar, 
 					   int32_t* cigarLen);
@@ -159,28 +160,27 @@ int32_t mark_mismatch (int32_t ref_begin1,
 	@param	op_letter	CIGAR operation character ('M', 'I', etc)
 	@return			32-bit unsigned integer, representing encoded CIGAR operation and length
 */
-uint32_t to_cigar_int (uint32_t length, char op_letter);
+static inline uint32_t to_cigar_int (uint32_t length, char op_letter) {
+	return (length << BAM_CIGAR_SHIFT) | (encoded_ops[(int)op_letter]);
+}
 
 /*!	@function		Extract CIGAR operation character from CIGAR 32-bit unsigned integer
 	@param	cigar_int	32-bit unsigned integer, representing encoded CIGAR operation and length
 	@return			CIGAR operation character ('M', 'I', etc)
 */
 //char cigar_int_to_op (uint32_t cigar_int);
-static inline char cigar_int_to_op(uint32_t cigar_int) 
-{
+static inline char cigar_int_to_op(uint32_t cigar_int) {
 	return (cigar_int & 0xfU) > 8 ? 'M': MAPSTR[cigar_int & 0xfU];
 }
 
-
 /*!	@function		Extract length of a CIGAR operation from CIGAR 32-bit unsigned integer
 	@param	cigar_int	32-bit unsigned integer, representing encoded CIGAR operation and length
 	@return			length of CIGAR operation
 */
-//uint32_t cigar_int_to_len (uint32_t cigar_int);
-static inline uint32_t cigar_int_to_len (uint32_t cigar_int)
-{
+static inline uint32_t cigar_int_to_len (uint32_t cigar_int) {
 	return cigar_int >> BAM_CIGAR_SHIFT;
 }
+
 #ifdef __cplusplus
 }
 #endif	// __cplusplus


=====================================
src/ssw_cpp.cpp
=====================================
@@ -1,3 +1,7 @@
+// ssw_cpp.cpp
+// Created by Wan-Ping Lee
+// Last revision by Mengyao Zhao on 2017-05-30
+
 #include "ssw_cpp.h"
 #include "ssw.h"
 
@@ -323,7 +327,7 @@ int Aligner::TranslateBase(const char* bases, const int& length,
 
 
 bool Aligner::Align(const char* query, const Filter& filter,
-                    Alignment* alignment) const
+                    Alignment* alignment, const int32_t maskLen) const
 {
   if (!translation_matrix_) return false;
   if (reference_length_ == 0) return false;
@@ -342,7 +346,7 @@ bool Aligner::Align(const char* query, const Filter& filter,
   s_align* s_al = ssw_align(profile, translated_reference_, reference_length_,
                                  static_cast<int>(gap_opening_penalty_),
 				 static_cast<int>(gap_extending_penalty_),
-				 flag, filter.score_filter, filter.distance_filter, query_len);
+				 flag, filter.score_filter, filter.distance_filter, maskLen);
 
   alignment->Clear();
   ConvertAlignment(*s_al, query_len, alignment);
@@ -359,7 +363,7 @@ bool Aligner::Align(const char* query, const Filter& filter,
 
 
 bool Aligner::Align(const char* query, const char* ref, const int& ref_len,
-                    const Filter& filter, Alignment* alignment) const
+                    const Filter& filter, Alignment* alignment, const int32_t maskLen) const
 {
   if (!translation_matrix_) return false;
 
@@ -369,9 +373,6 @@ bool Aligner::Align(const char* query, const char* ref, const int& ref_len,
   TranslateBase(query, query_len, translated_query);
 
   // calculate the valid length
-  //int calculated_ref_length = static_cast<int>(strlen(ref));
-  //int valid_ref_len = (calculated_ref_length > ref_len)
-  //                    ? ref_len : calculated_ref_length;
   int valid_ref_len = ref_len;
   int8_t* translated_ref = new int8_t[valid_ref_len];
   TranslateBase(ref, valid_ref_len, translated_ref);
@@ -386,7 +387,7 @@ bool Aligner::Align(const char* query, const char* ref, const int& ref_len,
   s_align* s_al = ssw_align(profile, translated_ref, valid_ref_len,
                                  static_cast<int>(gap_opening_penalty_),
 				 static_cast<int>(gap_extending_penalty_),
-				 flag, filter.score_filter, filter.distance_filter, query_len);
+				 flag, filter.score_filter, filter.distance_filter, maskLen);
 
   alignment->Clear();
   ConvertAlignment(*s_al, query_len, alignment);


=====================================
src/ssw_cpp.h
=====================================
@@ -1,3 +1,7 @@
+// ssw_cpp.h
+// Created by Wan-Ping Lee
+// Last revision by Mengyao Zhao on 2017-05-30
+
 #ifndef COMPLETE_STRIPED_SMITH_WATERMAN_CPP_H_
 #define COMPLETE_STRIPED_SMITH_WATERMAN_CPP_H_
 
@@ -127,9 +131,12 @@ class Aligner {
   // @param    query     The query sequence.
   // @param    filter    The filter for the alignment.
   // @param    alignment The container contains the result.
+  // @param    maskLen   The distance between the optimal and suboptimal alignment ending position will >= maskLen. We suggest to 
+  //                     use readLen/2, if you don't have special concerns. Note: maskLen has to be >= 15, otherwise this function 
+  //                     will NOT return the suboptimal alignment information.
   // @return   True: succeed; false: fail.
   // =========
-  bool Align(const char* query, const Filter& filter, Alignment* alignment) const;
+  bool Align(const char* query, const Filter& filter, Alignment* alignment, const int32_t maskLen) const;
 
   // =========
   // @function Align the query againt the reference.
@@ -141,10 +148,13 @@ class Aligner {
   // @param    ref_len   The length of the reference sequence.
   // @param    filter    The filter for the alignment.
   // @param    alignment The container contains the result.
+  // @param    maskLen   The distance between the optimal and suboptimal alignment ending position will >= maskLen. We suggest to 
+  //                     use readLen/2, if you don't have special concerns. Note: maskLen has to be >= 15, otherwise this function 
+  //                     will NOT return the suboptimal alignment information.
   // @return   True: succeed; false: fail.
   // =========
   bool Align(const char* query, const char* ref, const int& ref_len,
-             const Filter& filter, Alignment* alignment) const;
+             const Filter& filter, Alignment* alignment, const int32_t maskLen) const;
 
   // @function Clear up all containers and thus the aligner is disabled.
   //             To rebuild the aligner please use Build functions.


=====================================
src/ssw_lib.pyc
=====================================
Binary files /dev/null and b/src/ssw_lib.pyc differ



View it on GitLab: https://salsa.debian.org/med-team/libssw/-/commit/373215c6a0be239c29f88a6fa8b958ce6ade73aa

-- 
View it on GitLab: https://salsa.debian.org/med-team/libssw/-/commit/373215c6a0be239c29f88a6fa8b958ce6ade73aa
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200411/51e53a23/attachment-0001.html>


More information about the debian-med-commit mailing list