This is an automated email from the git hooks/post-receive script. gregoa pushed a commit to branch master in repository libbio-samtools-perl.
commit da8fa4c7fe2b280b774334bac8a4a676451a195f Author: gregor herrmann <gre...@debian.org> Date: Thu Dec 10 17:59:19 2015 +0100 Imported Upstream version 1.42 --- Changes | 4 + INSTALL.pl | 127 ---------- LICENSE | 523 +++++++++++++++++++++++++++------------- MANIFEST | 1 - META.json | 6 +- META.yml | 6 +- README | 21 +- lib/Bio/DB/Bam/AlignWrapper.pm | 53 ++-- lib/Bio/DB/Bam/Alignment.pm | 22 +- lib/Bio/DB/Bam/Pileup.pm | 11 +- lib/Bio/DB/Bam/PileupWrapper.pm | 11 +- lib/Bio/DB/Bam/Query.pm | 25 +- lib/Bio/DB/Sam.pm | 13 +- lib/Bio/DB/Sam/Constants.pm | 13 +- t/01sam.t | 168 +++++++++++-- 15 files changed, 601 insertions(+), 403 deletions(-) diff --git a/Changes b/Changes index 9f21337..0694211 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +Version 1.42 + * Software is now triply-licensed via Apache 2.0, + Artistic 2.0 or GPL v1 or higher. + Version 1.41 * Added missing INSTALL.pl script. * Make it clear that this library only works up through diff --git a/INSTALL.pl b/INSTALL.pl deleted file mode 100755 index 442d03e..0000000 --- a/INSTALL.pl +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/perl - -use strict; -use File::Temp 'tempdir'; - -prompt_yn("This will install Bio::DB::Sam and its dependencies. Continue?") or exit 0; - -# STEP 0: various dependencies -my $git = `which git`; -$git or die <<END; -'git' command not in path. Please install git and try again. -On Debian/Ubuntu systems you can do this with the command: - - apt-get install git -END - - -`which cc` or die <<END; -'cc' command not in path. Please install it and try again. -On Debian/Ubuntu systems you can do this with the command: - - apt-get install build-essential -END - -`which make` or die <<END; -'make' command not in path. Please install it and try again. -On Debian/Ubuntu systems you can do this with the command: - - apt-get install build-essential -END - --e '/usr/include/zlib.h' or die <<END; -zlib.h library header not found in /usr/include. Please install it and try again. -On Debian/Ubuntu systems you can do this with the command: - - apt-get install zlib1g-dev -END - ; - -eval "require Bio::SeqFeature::Lite" or die <<END; -BioPerl does not seem to be installed. Please install it and try again. -On Debian/Ubuntu systems you can do this with the command: - - apt-get install bioperl - -On other systems use the CPAN shell: - - perl -MCPAN -e 'install Bio::Perl' -END - ; - -# STEP 1: Create a clean directory for building -my $install_dir = tempdir(CLEANUP => 1); -info("Performing build in $install_dir"); - - -# STEP 2: Check out samtools -info("Checking out samtools 0.1.19"); -chdir $install_dir; -system "git clone https://github.com/samtools/samtools.git"; --d './samtools' or die "git clone seems to have failed. Could not find $install_dir/samtools directory"; -chdir './samtools'; -system "git checkout 0.1.19"; - -# STEP 3: Check out Bio-SamTools -info("Checking out Bio-SamTools"); -chdir $install_dir; -system "git clone https://github.com/GMOD/GBrowse-Adaptors.git"; --d './GBrowse-Adaptors' or die "git clone seems to have failed. Could not find $install_dir/GBrowse-Adaptors directory"; -chdir "./GBrowse-Adaptors/Bio-SamTools"; -system "git checkout release-1_39"; - -# Step 4: Build libbam.a -info("Building samtools"); -chdir "$install_dir/samtools"; -# patch makefile -open my $in, '<','Makefile' or die "Couldn't open Makefile for reading: $!"; -open my $out,'>','Makefile.new' or die "Couldn't open Makefile.new for writing: $!"; -while (<$in>) { - chomp; - if (/^CFLAGS/ && !/-fPIC/) { - s/#.+//; # get rid of comments - $_ .= " -fPIC -Wno-unused -Wno-unused-result"; - } -} continue { - print $out $_,"\n"; -} - -close $in; -close $out; -rename 'Makefile.new','Makefile' or die "Couldn't rename Makefile.new to Makefile: $!"; -system "make"; --e 'libbam.a' or die "Compile didn't complete. No libbam.a library file found"; - -# Step 5: Build Bio::DB::Sam -info("Building Bio::DB::Sam"); -chdir "$install_dir/GBrowse-Adaptors/Bio-SamTools"; -system "env SAMTOOLS=$install_dir/samtools perl Build.PL"; --e "./Build" or die "Build.PL didn't execute properly: no Build file found"; -system "./Build"; -`./Build test` =~ /Result: PASS/ or die "Build test failed. Not continuing"; - -# Step 6: Install -info("Installing Bio::DB::Sam using sudo. You will be asked for your password."); -info("If this step fails because sudo isn't installed, go back and run this script again as superuser."); -system "sudo ./Build install"; - -# Step 7: Yay! -info("Bio::DB::Sam is now installed."); -chdir '/'; - -exit 0; - -sub prompt_yn { - my $msg = shift; - print STDERR "$msg [Y/n]: "; - my $input = <>; - chomp $input; - return 1 unless $input; - return $input =~ /^[yY]/; -} - -sub info { - my $msg = shift; - chomp $msg; - print STDERR "\n*** $msg ***\n"; -} diff --git a/LICENSE b/LICENSE index bd7cc67..be0fdb6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,355 @@ +This software and its accompanying documentation is licensed under any +of the following open source licenses: + +a) the Artistic License 2.0 +b) the Apache License 2.0 a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or -b) the "Artistic License 2.0" + +---------------------------------------------------------------------------- +Artistic License 2.0 + +Copyright (c) 2000-2006, The Perl Foundation. + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + + +Preamble +This license establishes the terms under which a given free software Package may +be copied, modified, distributed, and/or redistributed. The intent is that the +Copyright Holder maintains some artistic control over the development of that +Package while still keeping the Package available as open source and free +software. + +You are always permitted to make arrangements wholly outside of this license +directly with the Copyright Holder of a given Package. If the terms of this +license do not permit the full use that you propose to make of the Package, you +should contact the Copyright Holder and seek a different licensing arrangement. + + +Definitions +"Copyright Holder" means the individual(s) or organization(s) named in the +copyright notice for the entire Package. + +"Contributor" means any party that has contributed code or other material to the +Package, in accordance with the Copyright Holder's procedures. + +"You" and "your" means any person who would like to copy, distribute, or modify +the Package. + +"Package" means the collection of files distributed by the Copyright Holder, and +derivatives of that collection and/or of those files. A given Package may +consist of either the Standard Version, or a Modified Version. + +"Distribute" means providing a copy of the Package or making it accessible to +anyone else, or in the case of a company or organization, to others outside of +your company or organization. + +"Distributor Fee" means any fee that you charge for Distributing this Package or +providing support for this Package to another party. It does not mean licensing +fees. + +"Standard Version" refers to the Package if it has not been modified, or has +been modified only in ways explicitly requested by the Copyright Holder. + +"Modified Version" means the Package, if it has been changed, and such changes +were not explicitly requested by the Copyright Holder. + +"Original License" means this Artistic License as Distributed with the Standard +Version of the Package, in its current version or as it may be modified by The +Perl Foundation in the future. + +"Source" form means the source code, documentation source, and configuration +files for the Package. + +"Compiled" form means the compiled bytecode, object code, binary, or any other +form resulting from mechanical transformation or translation of the Source form. + + +Permission for Use and Modification Without Distribution +(1) You are permitted to use the Standard Version and create and use Modified +Versions for any purpose without restriction, provided that you do not +Distribute the Modified Version. + + +Permissions for Redistribution of the Standard Version +(2) You may Distribute verbatim copies of the Source form of the Standard +Version of this Package in any medium without restriction, either gratis or for +a Distributor Fee, provided that you duplicate all of the original copyright +notices and associated disclaimers. At your discretion, such verbatim copies may +or may not include a Compiled form of the Package. + +(3) You may apply any bug fixes, portability changes, and other modifications +made available from the Copyright Holder. The resulting Package will still be +considered the Standard Version, and as such will be subject to the Original +License. + + +Distribution of Modified Versions of the Package as Source +(4) You may Distribute your Modified Version as Source (either gratis or for a +Distributor Fee, and with or without a Compiled form of the Modified Version) +provided that you clearly document how it differs from the Standard Version, +including, but not limited to, documenting any non-standard features, +executables, or modules, and provided that you do at least ONE of the +following: + +(a) make the Modified Version available to the Copyright Holder of the Standard +Version, under the Original License, so that the Copyright Holder may include +your modifications in the Standard Version. +(b) ensure that installation of your Modified Version does not prevent the user +installing or running the Standard Version. In addition, the Modified Version +must bear a name that is different from the name of the Standard Version. +(c) allow anyone who receives a copy of the Modified Version to make the Source +form of the Modified Version available to others under +(i) the Original License or +(ii) a license that permits the licensee to freely copy, modify and redistribute +the Modified Version using the same licensing terms that apply to the copy that +the licensee received, and requires that the Source form of the Modified +Version, and of any works derived from it, be made freely available in that +license fees are prohibited but Distributor Fees are allowed. + +Distribution of Compiled Forms of the Standard Version or Modified Versions +without the Source + +(5) You may Distribute Compiled forms of the Standard Version without the +Source, provided that you include complete instructions on how to get the +Source of the Standard Version. Such instructions must be valid at the time of +your distribution. If these instructions, at any time while you are carrying out +such distribution, become invalid, you must provide new instructions on demand +or cease further distribution. If you provide valid instructions or cease +distribution within thirty days after you become aware that the instructions are +invalid, then you do not forfeit any of your rights under this license. + +(6) You may Distribute a Modified Version in Compiled form without the Source, +provided that you comply with Section 4 with respect to the Source of the +Modified Version. + + +Aggregating or Linking the Package +(7) You may aggregate the Package (either the Standard Version or Modified +Version) with other packages and Distribute the resulting aggregation provided +that you do not charge a licensing fee for the Package. Distributor Fees are +permitted, and licensing fees for other components in the aggregation are +permitted. The terms of this license apply to the use and Distribution of the +Standard or Modified Versions as included in the aggregation. + +(8) You are permitted to link Modified and Standard Versions with other works, +to embed the Package in a larger work of your own, or to build stand-alone +binary or bytecode versions of applications that include the Package, and +Distribute the result without restriction, provided the result does not expose a +direct interface to the Package. + + +Items That are Not Considered Part of a Modified Version +(9) Works (including, but not limited to, modules and scripts) that merely +extend or make use of the Package, do not, by themselves, cause the Package to +be a Modified Version. In addition, such works are not considered parts of the +Package itself, and are not subject to the terms of this license. + + +General Provisions +(10) Any use, modification, and distribution of the Standard or Modified +Versions is governed by this Artistic License. By using, modifying or +distributing the Package, you accept this license. Do not use, modify, or +distribute the Package, if you do not accept this license. + +(11) If your Modified Version has been derived from a Modified Version made by +someone other than you, you are nevertheless required to ensure that your +Modified Version complies with the requirements of this license. + +(12) This license does not grant you the right to use any trademark, service +mark, tradename, or logo of the Copyright Holder. + +(13) This license includes the non-exclusive, worldwide, free-of-charge patent +license to make, have made, use, offer to sell, sell, import and otherwise +transfer the Package with respect to any patent claims licensable by the +Copyright Holder that are necessarily infringed by the Package. If you institute +patent litigation (including a cross-claim or counterclaim) against any party +alleging that the Package constitutes direct or contributory patent +infringement, then this Artistic License to you shall terminate on the date that +such litigation is filed. + +(14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND +CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR +NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. +UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY +OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +---------------------------------------------------------------------------- +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the +copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other +entities that control, are controlled by, or are under common control +with that entity. For the purposes of this definition, "control" means +(i) the power, direct or indirect, to cause the direction or +management of such entity, whether by contract or otherwise, or (ii) +ownership of fifty percent (50%) or more of the outstanding shares, or +(iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but not +limited to compiled object code, generated documentation, and +conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object +form, made available under the License, as indicated by a copyright +notice that is included in or attached to the work (an example is +provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the +purposes of this License, Derivative Works shall not include works +that remain separable from, or merely link (or bind by name) to the +interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the +original version of the Work and any modifications or additions to +that Work or Derivative Works thereof, that is intentionally submitted +to Licensor for inclusion in the Work by the copyright owner or by an +individual or Legal Entity authorized to submit on behalf of the +copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent to +the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control +systems, and issue tracking systems that are managed by, or on behalf +of, the Licensor for the purpose of discussing and improving the Work, +but excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, publicly +display, publicly perform, sublicense, and distribute the Work and +such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except +as stated in this section) patent license to make, have made, use, +offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work to +which such Contribution(s) was submitted. If You institute patent +litigation against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent +infringement, then any patent licenses granted to You under this +License for that Work shall terminate as of the date such litigation +is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work +or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You meet +the following conditions: + +You must give any other recipients of the Work or Derivative Works a +copy of this License; and You must cause any modified files to carry +prominent notices stating that You changed the files; and You must +retain, in the Source form of any Derivative Works that You +distribute, all copyright, patent, trademark, and attribution notices +from the Source form of the Work, excluding those notices that do not +pertain to any part of the Derivative Works; and If the Work includes +a "NOTICE" text file as part of its distribution, then any Derivative +Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those +notices that do not pertain to any part of the Derivative Works, in at +least one of the following places: within a NOTICE text file +distributed as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, within +a display generated by the Derivative Works, if and wherever such +third-party notices normally appear. The contents of the NOTICE file +are for informational purposes only and do not modify the License. You +may add Your own attribution notices within Derivative Works that You +distribute, alongside or as an addendum to the NOTICE text from the +Work, provided that such additional attribution notices cannot be +construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may +provide additional or different license terms and conditions for use, +reproduction, or distribution of Your modifications, or for any such +Derivative Works as a whole, provided Your use, reproduction, and +distribution of the Work otherwise complies with the conditions stated +in this License. 5. Submission of Contributions. Unless You +explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the +terms and conditions of this License, without any additional terms or +conditions. Notwithstanding the above, nothing herein shall supersede +or modify the terms of any separate license agreement you may have +executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed +to in writing, Licensor provides the Work (and each Contributor +provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied, including, without +limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, +MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely +responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your +exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, unless +required by applicable law (such as deliberate and grossly negligent +acts) or agreed to in writing, shall any Contributor be liable to You +for damages, including any direct, indirect, special, incidental, or +consequential damages of any character arising as a result of this +License or out of the use or inability to use the Work (including but +not limited to damages for loss of goodwill, work stoppage, computer +failure or malfunction, or any and all other commercial damages or +losses), even if such Contributor has been advised of the possibility +of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, and +charge a fee for, acceptance of support, warranty, indemnity, or other +liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only on +Your own behalf and on Your sole responsibility, not on behalf of any +other Contributor, and only if You agree to indemnify, defend, and +hold each Contributor harmless for any liability incurred by, or +claims asserted against, such Contributor by reason of your accepting +any such warranty or additional liability. + +END OF TERMS AND CONDITIONS ---------------------------------------------------------------------------- @@ -267,176 +615,3 @@ BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ----------------------------------------------------------------------------- -Artistic License 2.0 - -Copyright (c) 2000-2006, The Perl Foundation. - -Everyone is permitted to copy and distribute verbatim copies of this license -document, but changing it is not allowed. - - -Preamble -This license establishes the terms under which a given free software Package may -be copied, modified, distributed, and/or redistributed. The intent is that the -Copyright Holder maintains some artistic control over the development of that -Package while still keeping the Package available as open source and free -software. - -You are always permitted to make arrangements wholly outside of this license -directly with the Copyright Holder of a given Package. If the terms of this -license do not permit the full use that you propose to make of the Package, you -should contact the Copyright Holder and seek a different licensing arrangement. - - -Definitions -"Copyright Holder" means the individual(s) or organization(s) named in the -copyright notice for the entire Package. - -"Contributor" means any party that has contributed code or other material to the -Package, in accordance with the Copyright Holder's procedures. - -"You" and "your" means any person who would like to copy, distribute, or modify -the Package. - -"Package" means the collection of files distributed by the Copyright Holder, and -derivatives of that collection and/or of those files. A given Package may -consist of either the Standard Version, or a Modified Version. - -"Distribute" means providing a copy of the Package or making it accessible to -anyone else, or in the case of a company or organization, to others outside of -your company or organization. - -"Distributor Fee" means any fee that you charge for Distributing this Package or -providing support for this Package to another party. It does not mean licensing -fees. - -"Standard Version" refers to the Package if it has not been modified, or has -been modified only in ways explicitly requested by the Copyright Holder. - -"Modified Version" means the Package, if it has been changed, and such changes -were not explicitly requested by the Copyright Holder. - -"Original License" means this Artistic License as Distributed with the Standard -Version of the Package, in its current version or as it may be modified by The -Perl Foundation in the future. - -"Source" form means the source code, documentation source, and configuration -files for the Package. - -"Compiled" form means the compiled bytecode, object code, binary, or any other -form resulting from mechanical transformation or translation of the Source form. - - -Permission for Use and Modification Without Distribution -(1) You are permitted to use the Standard Version and create and use Modified -Versions for any purpose without restriction, provided that you do not -Distribute the Modified Version. - - -Permissions for Redistribution of the Standard Version -(2) You may Distribute verbatim copies of the Source form of the Standard -Version of this Package in any medium without restriction, either gratis or for -a Distributor Fee, provided that you duplicate all of the original copyright -notices and associated disclaimers. At your discretion, such verbatim copies may -or may not include a Compiled form of the Package. - -(3) You may apply any bug fixes, portability changes, and other modifications -made available from the Copyright Holder. The resulting Package will still be -considered the Standard Version, and as such will be subject to the Original -License. - - -Distribution of Modified Versions of the Package as Source -(4) You may Distribute your Modified Version as Source (either gratis or for a -Distributor Fee, and with or without a Compiled form of the Modified Version) -provided that you clearly document how it differs from the Standard Version, -including, but not limited to, documenting any non-standard features, -executables, or modules, and provided that you do at least ONE of the -following: - -(a) make the Modified Version available to the Copyright Holder of the Standard -Version, under the Original License, so that the Copyright Holder may include -your modifications in the Standard Version. -(b) ensure that installation of your Modified Version does not prevent the user -installing or running the Standard Version. In addition, the Modified Version -must bear a name that is different from the name of the Standard Version. -(c) allow anyone who receives a copy of the Modified Version to make the Source -form of the Modified Version available to others under -(i) the Original License or -(ii) a license that permits the licensee to freely copy, modify and redistribute -the Modified Version using the same licensing terms that apply to the copy that -the licensee received, and requires that the Source form of the Modified -Version, and of any works derived from it, be made freely available in that -license fees are prohibited but Distributor Fees are allowed. - -Distribution of Compiled Forms of the Standard Version or Modified Versions -without the Source - -(5) You may Distribute Compiled forms of the Standard Version without the -Source, provided that you include complete instructions on how to get the -Source of the Standard Version. Such instructions must be valid at the time of -your distribution. If these instructions, at any time while you are carrying out -such distribution, become invalid, you must provide new instructions on demand -or cease further distribution. If you provide valid instructions or cease -distribution within thirty days after you become aware that the instructions are -invalid, then you do not forfeit any of your rights under this license. - -(6) You may Distribute a Modified Version in Compiled form without the Source, -provided that you comply with Section 4 with respect to the Source of the -Modified Version. - - -Aggregating or Linking the Package -(7) You may aggregate the Package (either the Standard Version or Modified -Version) with other packages and Distribute the resulting aggregation provided -that you do not charge a licensing fee for the Package. Distributor Fees are -permitted, and licensing fees for other components in the aggregation are -permitted. The terms of this license apply to the use and Distribution of the -Standard or Modified Versions as included in the aggregation. - -(8) You are permitted to link Modified and Standard Versions with other works, -to embed the Package in a larger work of your own, or to build stand-alone -binary or bytecode versions of applications that include the Package, and -Distribute the result without restriction, provided the result does not expose a -direct interface to the Package. - - -Items That are Not Considered Part of a Modified Version -(9) Works (including, but not limited to, modules and scripts) that merely -extend or make use of the Package, do not, by themselves, cause the Package to -be a Modified Version. In addition, such works are not considered parts of the -Package itself, and are not subject to the terms of this license. - - -General Provisions -(10) Any use, modification, and distribution of the Standard or Modified -Versions is governed by this Artistic License. By using, modifying or -distributing the Package, you accept this license. Do not use, modify, or -distribute the Package, if you do not accept this license. - -(11) If your Modified Version has been derived from a Modified Version made by -someone other than you, you are nevertheless required to ensure that your -Modified Version complies with the requirements of this license. - -(12) This license does not grant you the right to use any trademark, service -mark, tradename, or logo of the Copyright Holder. - -(13) This license includes the non-exclusive, worldwide, free-of-charge patent -license to make, have made, use, offer to sell, sell, import and otherwise -transfer the Package with respect to any patent claims licensable by the -Copyright Holder that are necessarily infringed by the Package. If you institute -patent litigation (including a cross-claim or counterclaim) against any party -alleging that the Package constitutes direct or contributory patent -infringement, then this Artistic License to you shall terminate on the date that -such litigation is filed. - -(14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND -CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR -NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. -UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY -OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - diff --git a/MANIFEST b/MANIFEST index 147c6a0..1120481 100644 --- a/MANIFEST +++ b/MANIFEST @@ -6,7 +6,6 @@ c_bin/bam2bedgraph.c c_bin/makefile Changes DISCLAIMER -INSTALL.pl lib/Bio/DB/Bam/Alignment.pm lib/Bio/DB/Bam/AlignWrapper.pm lib/Bio/DB/Bam/FetchIterator.pm diff --git a/META.json b/META.json index b3684eb..1c92b9c 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Lincoln Stein <lincoln.st...@gmail.com>" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.421", + "generated_by" : "Module::Build version 0.4211", "license" : [ "perl_5" ], @@ -64,7 +64,7 @@ }, "Bio::DB::Sam" : { "file" : "lib/Bio/DB/Sam.pm", - "version" : "1.41" + "version" : "1.42" }, "Bio::DB::Sam::Constants" : { "file" : "lib/Bio/DB/Sam/Constants.pm" @@ -91,5 +91,5 @@ "http://dev.perl.org/licenses/" ] }, - "version" : "1.41" + "version" : "1.42" } diff --git a/META.yml b/META.yml index b2dfb31..9cf02ab 100644 --- a/META.yml +++ b/META.yml @@ -7,7 +7,7 @@ build_requires: configure_requires: Module::Build: '0.42' dynamic_config: 1 -generated_by: 'Module::Build version 0.421, CPAN::Meta::Converter version 2.142690' +generated_by: 'Module::Build version 0.4211, CPAN::Meta::Converter version 2.143240' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -36,7 +36,7 @@ provides: file: lib/Bio/DB/Bam/Target.pm Bio::DB::Sam: file: lib/Bio/DB/Sam.pm - version: '1.41' + version: '1.42' Bio::DB::Sam::Constants: file: lib/Bio/DB/Sam/Constants.pm Bio::DB::Sam::Fai: @@ -54,4 +54,4 @@ requires: perl: '5.008' resources: license: http://dev.perl.org/licenses/ -version: '1.41' +version: '1.42' diff --git a/README b/README index f165905..c53897c 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ This is a Perl interface to the SAMtools sequence alignment -interface. It ONLY works on versions of Samtools up to 0.1.19. It does +interface. It ONLY works on versions of Samtools up to 0.1.17. It does not work on version 1.0 or higher due to major changes in the library structure. @@ -17,11 +17,10 @@ install. Simply run: * MULTI-STEP INSTALLATION The more traditional install requires you to separately download, -unpack and compile SAMtools 0.1.4 or higher in some accessible -directory. FOR SAMTOOLS VERSION 0.1.4, YOU MUST RUN "make -f -makefile.generic" IN THE DISTRIBUTION DIRECTORY IN ORDER TO CREATE THE -REQUIRED libbam.a LIBRARY FILE. For other versions, just "make" will -usually work. +unpack and compile SAMtools 0.1.10 through 0.1.17 in some accessible +directory. Typing "make" in the samtools directory will usually +work. SAMtools versions 0.1.18 and higher do not work with this +library. Then set the environment variable SAMTOOLS to point to this directory. @@ -73,9 +72,9 @@ AUTHOR: Lincoln D. Stein <lincoln.st...@gmail.com> -Copyright (c) 2009 Ontario Institute for Cancer Research +Copyright (c) 2009-2015 Ontario Institute for Cancer Research -This package and its accompanying libraries is free software; you can -redistribute it and/or modify it under the terms of the GPL (either -version 1, or at your option, any later version) or the Artistic -License 2.0. Refer to LICENSE for the full license text. +This package and its accompanying libraries are free software; you can +redistribute it and/or modify it under the terms of the Artistic +License 2.0, the Apache 2.0 License, or the GNU General Public License +(version 1 or higher). Refer to LICENSE for the full license text. diff --git a/lib/Bio/DB/Bam/AlignWrapper.pm b/lib/Bio/DB/Bam/AlignWrapper.pm index 8b48ed7..99bf4a7 100644 --- a/lib/Bio/DB/Bam/AlignWrapper.pm +++ b/lib/Bio/DB/Bam/AlignWrapper.pm @@ -40,13 +40,12 @@ L<Bio::Perl>, L<Bio::DB::Sam>, L<Bio::DB::Bam::Constants> Lincoln Stein E<lt>lincoln.st...@oicr.on.cae<gt>. E<lt>lincoln.st...@bmail.come<gt> -Copyright (c) 2009 Ontario Institute for Cancer Research. +Copyright (c) 2009-2015 Ontario Institute for Cancer Research. -This package and its accompanying libraries is free software; you can -redistribute it and/or modify it under the terms of the GPL (either -version 1, or at your option, any later version) or the Artistic -License 2.0. Refer to LICENSE for the full license text. In addition, -please see DISCLAIMER.txt for disclaimers of warranty. +This package and its accompanying libraries are free software; you can +redistribute it and/or modify it under the terms of the Artistic +License 2.0, the Apache 2.0 License, or the GNU General Public License +(version 1 or higher). Refer to LICENSE for the full license text. =cut @@ -67,7 +66,7 @@ sub new { $self->add_segment($self->split_splices) if $sam->split_splices && $align->cigar_str =~ /N/; - return $self; + return $self; } sub AUTOLOAD { @@ -148,7 +147,7 @@ sub split_splices { } else { $partial_cigar .= "$operation$count"; } - $end += $count if $operation =~ /^[MDSHP]/i; + $end += $count if $operation =~ /^[MDSHP=X]/i; $skip += $count if $operation eq 'N'; if ($operation eq 'H' and $start == 0) { $qseq = 'N' x $count . $qseq; @@ -219,13 +218,15 @@ sub subseq { sub padded_alignment { my $self = shift; - my $cigar = $self->cigar_array; + my $real_ref = 0; + $real_ref = 1 if($self->{sam}->force_refseq || !$self->has_tag('MD')); my $sdna = $self->dna; my $tdna = $self->query->dna; - my ($pad_source,$pad_target,$pad_match); + + my ($pad_source,$pad_target,$pad_match, $char_source, $char_target); for my $event (@$cigar) { my ($op,$count) = @$event; if ($op eq 'I' || $op eq 'S') { @@ -233,11 +234,21 @@ sub padded_alignment { $pad_target .= substr($tdna,0,$count,''); $pad_match .= ' ' x $count; } - elsif ($op eq 'D' || $op eq 'N') { + elsif ($op eq 'D') { $pad_source .= substr($sdna,0,$count,''); $pad_target .= '-' x $count; $pad_match .= ' ' x $count; } + elsif ($op eq 'N') { + if($real_ref) { + $pad_source .= substr($sdna,0,$count,''); + } + else { + $pad_source .= '-' x $count; + } + $pad_target .= '-' x $count; + $pad_match .= ' ' x $count; + } elsif ($op eq 'P') { $pad_source .= '*' x $count; $pad_target .= '*' x $count; @@ -245,10 +256,14 @@ sub padded_alignment { } elsif ($op eq 'H') { # nothing needs to be done in this case - } else { # everything else is assumed to be a match -- revisit - $pad_source .= substr($sdna,0,$count,''); - $pad_target .= substr($tdna,0,$count,''); - $pad_match .= '|' x $count; + } else { # everything else is assumed to be a match + while($count-- > 0) { + $char_source = substr($sdna,0,1,''); + $char_target = substr($tdna,0,1,''); + $pad_source .= $char_source; + $pad_target .= $char_target; + $pad_match .= $char_source eq $char_target ? '|' : ' '; + } } } return ($pad_source,$pad_match,$pad_target); @@ -267,7 +282,7 @@ sub dna { my $seq = ''; for my $op (@$cigar) { my ($operation,$count) = @$op; - if ($operation eq 'M') { + if ($operation eq 'M' || $operation eq '=' || $operation eq 'X') { $seq .= substr($qseq,0,$count,''); # include these residues } elsif ($operation eq 'S' or $operation eq 'I') { substr($qseq,0,$count,''); # skip soft clipped and inserted residues @@ -321,7 +336,7 @@ sub get_tag_values { my $tag = shift; defined $tag or return; - return $self->{align}->get_tag_values($tag) + return $self->{align}->get_tag_values($tag) if $self->expand_flags; if ($tag eq 'FLAGS') { $self->flag_str; @@ -334,7 +349,7 @@ sub has_tag { my $self = shift; my $tag = shift; defined $tag or return; - $self->{align}->get_tag_values($tag) + $self->{align}->get_tag_values($tag) if $self->expand_flags; if ($tag eq 'FLAGS') { return 1; @@ -373,7 +388,7 @@ sub gff3_string { map {$_->gff3_string($id)} @rsf); } -sub phase { return } +sub phase { return } sub escape { my $self = shift; diff --git a/lib/Bio/DB/Bam/Alignment.pm b/lib/Bio/DB/Bam/Alignment.pm index 536dd24..cbb177e 100644 --- a/lib/Bio/DB/Bam/Alignment.pm +++ b/lib/Bio/DB/Bam/Alignment.pm @@ -586,11 +586,11 @@ sub mate_len { my $len = $self->length; my $adjust = 0; - my @cigar = $self->cigar_str =~ /(\d+)(\w)/g; - while (@cigar) { - my ($len,$op) = splice(@cigar,0,2); - $adjust += $len if $op eq 'I'; - $adjust -= $len if $op eq 'D'; + my @cigar = $self->cigar_array; + for my $event (@cigar) { + my ($op,$len) = @$event; + $adjust += $len if $op eq 'I'; + $adjust -= $len if $op eq 'D'; } return $adjust + $ins_len + ($self->start-$self->mate_start) if $ins_len > 0; @@ -634,13 +634,13 @@ L<Bio::Perl>, L<Bio::DB::Sam>, L<Bio::DB::Bam::Constants> Lincoln Stein E<lt>lincoln.st...@oicr.on.cae<gt>. E<lt>lincoln.st...@bmail.come<gt> -Copyright (c) 2009 Ontario Institute for Cancer Research. +Copyright (c) 2009-2015 Ontario Institute for Cancer Research. + +This package and its accompanying libraries are free software; you can +redistribute it and/or modify it under the terms of the Artistic +License 2.0, the Apache 2.0 License, or the GNU General Public License +(version 1 or higher). Refer to LICENSE for the full license text. -This package and its accompanying libraries is free software; you can -redistribute it and/or modify it under the terms of the GPL (either -version 1, or at your option, any later version) or the Artistic -License 2.0. Refer to LICENSE for the full license text. In addition, -please see DISCLAIMER.txt for disclaimers of warranty. =cut diff --git a/lib/Bio/DB/Bam/Pileup.pm b/lib/Bio/DB/Bam/Pileup.pm index 7ca1762..d63e472 100644 --- a/lib/Bio/DB/Bam/Pileup.pm +++ b/lib/Bio/DB/Bam/Pileup.pm @@ -81,12 +81,11 @@ L<Bio::Perl>, L<Bio::DB::Sam>, L<Bio::DB::Bam::Alignment>, L<Bio::DB::Bam::Const Lincoln Stein E<lt>lincoln.st...@oicr.on.cae<gt>. E<lt>lincoln.st...@bmail.come<gt> -Copyright (c) 2009 Ontario Institute for Cancer Research. +Copyright (c) 2009-2015 Ontario Institute for Cancer Research. -This package and its accompanying libraries is free software; you can -redistribute it and/or modify it under the terms of the GPL (either -version 1, or at your option, any later version) or the Artistic -License 2.0. Refer to LICENSE for the full license text. In addition, -please see DISCLAIMER.txt for disclaimers of warranty. +This package and its accompanying libraries are free software; you can +redistribute it and/or modify it under the terms of the Artistic +License 2.0, the Apache 2.0 License, or the GNU General Public License +(version 1 or higher). Refer to LICENSE for the full license text. =cut diff --git a/lib/Bio/DB/Bam/PileupWrapper.pm b/lib/Bio/DB/Bam/PileupWrapper.pm index 4fbd31e..094da5d 100644 --- a/lib/Bio/DB/Bam/PileupWrapper.pm +++ b/lib/Bio/DB/Bam/PileupWrapper.pm @@ -25,13 +25,12 @@ L<Bio::Perl>, L<Bio::DB::Sam>, L<Bio::DB::Bam::Constants> Lincoln Stein E<lt>lincoln.st...@oicr.on.cae<gt>. E<lt>lincoln.st...@bmail.come<gt> -Copyright (c) 2009 Ontario Institute for Cancer Research. +Copyright (c) 2009-2015 Ontario Institute for Cancer Research. -This package and its accompanying libraries is free software; you can -redistribute it and/or modify it under the terms of the GPL (either -version 1, or at your option, any later version) or the Artistic -License 2.0. Refer to LICENSE for the full license text. In addition, -please see DISCLAIMER.txt for disclaimers of warranty. +This package and its accompanying libraries are free software; you can +redistribute it and/or modify it under the terms of the Artistic +License 2.0, the Apache 2.0 License, or the GNU General Public License +(version 1 or higher). Refer to LICENSE for the full license text. =cut diff --git a/lib/Bio/DB/Bam/Query.pm b/lib/Bio/DB/Bam/Query.pm index 235b0b2..6fd90f3 100644 --- a/lib/Bio/DB/Bam/Query.pm +++ b/lib/Bio/DB/Bam/Query.pm @@ -119,8 +119,9 @@ sub low { my $cigar_arry = $$self->cigar_array; my $start = 1; for my $c (@$cigar_arry) { - last unless CIGAR_SKIP->{$c->[0]}; - $start += $c->[1]; + next if CIGAR_SYMBOLS->[BAM_CHARD_CLIP] eq $c->[0]; + last unless CIGAR_SKIP->{$c->[0]}; + $start += $c->[1]; } $start; } @@ -133,8 +134,9 @@ sub high { # alignment stops at first non-clip CIGAR position my $i = $len - 1; for my $c (reverse @$cigar_arry) { - last unless CIGAR_SKIP->{$c->[0]}; - $len -= $c->[1]; + next if CIGAR_SYMBOLS->[BAM_CHARD_CLIP] eq $c->[0]; + last unless CIGAR_SKIP->{$c->[0]}; + $len -= $c->[1]; } return $len; } @@ -158,7 +160,7 @@ orientation. =cut -sub seq { +sub seq { my $self = shift; my $dna = $self->dna; return Bio::PrimarySeq->new(-seq => $dna, @@ -196,7 +198,7 @@ If the query was reversed to align it, -1. Otherwise +1. =cut -sub strand { +sub strand { my $self = shift; return $$self->reversed ? -1 : 1; } @@ -234,12 +236,11 @@ L<Bio::Perl>, L<Bio::DB::Sam>, L<Bio::DB::Bam::Alignment>, L<Bio::DB::Bam::Const Lincoln Stein E<lt>lincoln.st...@oicr.on.cae<gt>. E<lt>lincoln.st...@bmail.come<gt> -Copyright (c) 2009 Ontario Institute for Cancer Research. +Copyright (c) 2009-2015 Ontario Institute for Cancer Research. -This package and its accompanying libraries is free software; you can -redistribute it and/or modify it under the terms of the GPL (either -version 1, or at your option, any later version) or the Artistic -License 2.0. Refer to LICENSE for the full license text. In addition, -please see DISCLAIMER.txt for disclaimers of warranty. +This package and its accompanying libraries are free software; you can +redistribute it and/or modify it under the terms of the Artistic +License 2.0, the Apache 2.0 License, or the GNU General Public License +(version 1 or higher). Refer to LICENSE for the full license text. =cut diff --git a/lib/Bio/DB/Sam.pm b/lib/Bio/DB/Sam.pm index ef76c48..f6a87c7 100644 --- a/lib/Bio/DB/Sam.pm +++ b/lib/Bio/DB/Sam.pm @@ -1,6 +1,6 @@ package Bio::DB::Sam; -our $VERSION = '1.41'; +our $VERSION = '1.42'; =head1 NAME @@ -2399,13 +2399,12 @@ L<Bio::Perl>, L<Bio::DB::Bam::Alignment>, L<Bio::DB::Bam::Constants> Lincoln Stein E<lt>lincoln.st...@oicr.on.cae<gt>. E<lt>lincoln.st...@bmail.come<gt> -Copyright (c) 2009 Ontario Institute for Cancer Research. +Copyright (c) 2009-2015 Ontario Institute for Cancer Research. -This package and its accompanying libraries is free software; you can -redistribute it and/or modify it under the terms of the GPL (either -version 1, or at your option, any later version) or the Artistic -License 2.0. Refer to LICENSE for the full license text. In addition, -please see DISCLAIMER.txt for disclaimers of warranty. +This package and its accompanying libraries are free software; you can +redistribute it and/or modify it under the terms of the Artistic +License 2.0, the Apache 2.0 License, or the GNU General Public License +(version 1 or higher). Refer to LICENSE for the full license text. =cut diff --git a/lib/Bio/DB/Sam/Constants.pm b/lib/Bio/DB/Sam/Constants.pm index d7a4993..cdbd2fe 100644 --- a/lib/Bio/DB/Sam/Constants.pm +++ b/lib/Bio/DB/Sam/Constants.pm @@ -53,13 +53,12 @@ L<Bio::Perl>, L<Bio::DB::Sam>, L<Bio::DB::Bam::Alignment> Lincoln Stein E<lt>lincoln.st...@oicr.on.cae<gt>. E<lt>lincoln.st...@bmail.come<gt> -Copyright (c) 2009 Ontario Institute for Cancer Research. +Copyright (c) 2009-2015 Ontario Institute for Cancer Research. -This package and its accompanying libraries is free software; you can -redistribute it and/or modify it under the terms of the GPL (either -version 1, or at your option, any later version) or the Artistic -License 2.0. Refer to LICENSE for the full license text. In addition, -please see DISCLAIMER.txt for disclaimers of warranty. +This package and its accompanying libraries are free software; you can +redistribute it and/or modify it under the terms of the Artistic +License 2.0, the Apache 2.0 License, or the GNU General Public License +(version 1 or higher). Refer to LICENSE for the full license text. =cut @@ -73,7 +72,7 @@ our @EXPORT = qw(CIGAR_SYMBOLS BAM_CIGAR_SHIFT BAM_CIGAR_MASK BAM_CSOFT_CLIP BAM_CHARD_CLIP BAM_CPAD FLAGS RFLAGS); our @EXPORT_OK = @EXPORT; -use constant CIGAR_SYMBOLS => [qw(M I D N S H P)]; +use constant CIGAR_SYMBOLS => [qw(M I D N S H P = X)]; use constant BAM_CIGAR_SHIFT => 4; use constant BAM_CIGAR_MASK => (1 << BAM_CIGAR_SHIFT) - 1; use constant BAM_CMATCH => 0; diff --git a/t/01sam.t b/t/01sam.t index 7c55f11..452b166 100644 --- a/t/01sam.t +++ b/t/01sam.t @@ -7,7 +7,7 @@ use strict; use ExtUtils::MakeMaker; use File::Temp qw(tempfile); use FindBin '$Bin'; -use constant TEST_COUNT => 170; +use constant TEST_COUNT => 268; use lib "$Bin/../lib","$Bin/../blib/lib","$Bin/../blib/arch"; @@ -24,6 +24,142 @@ BEGIN { } use Bio::DB::Sam; +use Bio::DB::Bam::AlignWrapper; + +{ + ## Tests by keiranmra...@gmail.com (k...@sanger.ac.uk) for fixing alignments with hard + soft clips + # 49 tests + + # !! not-forced ref-seq + + my @read_pos = ([1,120], # 120M + [61,120], # 60S60M + [1,60], # 60M60H + [1,120], # 120M + [31,90], # 30H30S60M + [1,30], # 30M30S60H + [1,30], # 10M10N20M30S60H (N ref skip) + ); + my @ref_pos = ( [61, 180], + [1081, 1140], + [961, 1020], + [61, 180], + [1081, 1140], + [961, 990], + [961, 1000], + ); + my @read_padded = ( + [ 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG', + '||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG'], + [ '------------------------------------------------------------TGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA', + ' ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGATGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA'], + [ 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGA', + '||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGA'], + [ 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG', + '||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG'], + [ '------------------------------TGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA', + ' ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'CATAACTATGAAGAGACTATTGCCAGATGATGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA'], + [ 'ACATGAGATTATTAGGAAATGCTTTACTGT------------------------------', + '|||||||||||||||||||||||||||||| ', + 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGA'], + [ 'ACATGAGATT----------GCTTTACTGTCATAACTATG------------------------------', + '|||||||||| |||||||||||||||||||| ', + 'ACATGAGATT----------GCTTTACTGTCATAACTATGGAAGAGACTATTGCCAGATGATGTCCATGT'], + ); + + my $sam = Bio::DB::Sam->new( -bam => "$Bin/data/ex2.bam", + -fasta => "$Bin/data/ex1.fa", + ); + my $bam = $sam->bam; + my $record=0; + while(my $a = $bam->read1) { + ok($a->query->start, $read_pos[$record]->[0], "Check query start $record"); + ok($a->query->end, $read_pos[$record]->[1], "Check query end $record"); + + ok($a->start, $ref_pos[$record]->[0], "Check ref pos start $record"); + ok($a->start, $ref_pos[$record]->[0], "Check ref pos end $record"); + + my $aw = Bio::DB::Bam::AlignWrapper->new($a, $sam); + my ($ref, $match, $query) = $aw->padded_alignment; + ok($ref, $read_padded[$record]->[0], "Check padded_alignment ref $record"); + ok($match, $read_padded[$record]->[1], "Check padded_alignment match $record"); + ok($query, $read_padded[$record]->[2], "Check padded_alignment query $record"); + $record++; + } +} + +{ + ## Tests by keiranmra...@gmail.com (k...@sanger.ac.uk) for fixing alignments with hard + soft clips + # 49 tests + + # !! FORCED refseq ref-seq + + my @read_pos = ([1,120], # 120M + [61,120], # 60S60M + [1,60], # 60M60H + [1,120], # 120M + [31,90], # 30H30S60M + [1,30], # 30M30S60H + [1,30], # 10M10N20M30S60H (N ref skip) # changes + ); + my @ref_pos = ( [61, 180], + [1081, 1140], + [961, 1020], + [61, 180], + [1081, 1140], + [961, 990], + [961, 1000], + ); + my @read_padded = ( + [ 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG', + '||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG'], + [ '------------------------------------------------------------TGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA', + ' ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGATGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA'], + [ 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGA', + '||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGA'], + [ 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG', + '||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGGGGCTTAACCTCTGGTGACTGCCAGAGCTGCTGGCAAGCTAGAG'], + [ '------------------------------TGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA', + ' ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||', + 'CATAACTATGAAGAGACTATTGCCAGATGATGTCCATGTACACACGCTGTCCTATGTACTTATCATGACTCTATCCCAAATTCCCAATTA'], + [ 'ACATGAGATTATTAGGAAATGCTTTACTGT------------------------------', + '|||||||||||||||||||||||||||||| ', + 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATGAAGAGACTATTGCCAGATGA'], + [ 'ACATGAGATTATTAGGAAATGCTTTACTGTCATAACTATG------------------------------', + '|||||||||| |||||||||||||||||||| ', + 'ACATGAGATT----------GCTTTACTGTCATAACTATGGAAGAGACTATTGCCAGATGATGTCCATGT'], + ); + + my $sam = Bio::DB::Sam->new( -bam => "$Bin/data/ex2.bam", + -fasta => "$Bin/data/ex1.fa", + -force_refseq => 1, + ); + my $bam = $sam->bam; + my $record=0; + while(my $a = $bam->read1) { + ok($a->query->start, $read_pos[$record]->[0], "Check query start $record"); + ok($a->query->end, $read_pos[$record]->[1], "Check query end $record"); + + ok($a->start, $ref_pos[$record]->[0], "Check ref pos start $record"); + ok($a->start, $ref_pos[$record]->[0], "Check ref pos end $record"); + + my $aw = Bio::DB::Bam::AlignWrapper->new($a, $sam); + my ($ref, $match, $query) = $aw->padded_alignment; + ok($ref, $read_padded[$record]->[0], "Check padded_alignment ref $record"); + ok($match, $read_padded[$record]->[1], "Check padded_alignment match $record"); + ok($query, $read_padded[$record]->[2], "Check padded_alignment query $record"); + $record++; + } +} { ## Following tests added by malcolm_c...@stowers.org while @@ -31,7 +167,7 @@ use Bio::DB::Sam; ## processing of multi-gaps" ## (https://sourceforge.net/tracker/?func=detail&aid=3083769&group_id=27707&atid=391291) my $bamfile = "$Bin/data/dm3_3R_4766911_4767130.sam.sorted.bam"; - my $sam = Bio::DB::Sam->new( -bam => $bamfile, + my $sam = Bio::DB::Sam->new( -bam => $bamfile, -split_splices => 1, -autoindex => 1, ); @@ -64,7 +200,7 @@ use Bio::DB::Sam; "split alignments having a part (exon) that starts at 4767130 (the acceptor of the downstream exon)" ); } -# low level tests (defined in lib/Bio/DB/Sam.xs) +# low level tests (defined in lib/Bio/DB/Sam.xs) { my $bamfile = "$Bin/data/ex1.bam"; my $bam = Bio::DB::Bam->open($bamfile); @@ -78,19 +214,19 @@ use Bio::DB::Sam; ok($target_names); ok(scalar @$target_names,2); ok($target_names->[0],'seq1'); - + my $target_lens = $header->target_len; ok($target_lens); ok(scalar @$target_lens,2); ok($target_lens->[0],1575); - + my $text = $header->text; ok(length $text > 0); my $c = "\@CO\tThis is a comment\n"; $header->text($c); ok($header->text,$c); - + my $fai = Bio::DB::Sam::Fai->open("$Bin/data/ex1.fa"); my $seq = $fai->fetch('seq2:51-1000'); ok(length $seq,950); @@ -100,13 +236,13 @@ use Bio::DB::Sam; $count++; } ok($count,3307); - + my @result = $header->parse_region('seq2:51-1000'); ok($result[0],1); ok($result[1],50); @result = $header->parse_region('seq_invalid:51-1000'); ok(scalar @result,0); - + my $index = Bio::DB::Bam->index($bamfile,1); ok($index); @@ -135,7 +271,7 @@ use Bio::DB::Sam; $matches{total}++; } }; - + $index->pileup($bam,$header->parse_region('seq2:1-100'),$fetch_back); ok($matches{matched}/$matches{total} > 0.99); @@ -196,7 +332,7 @@ use Bio::DB::Sam; ok($target_names); ok(scalar @$target_names,2); ok($target_names->[0],'seq1'); - + $target_lens = $header->target_len; ok($target_lens); ok(scalar @$target_lens,2); @@ -251,8 +387,8 @@ for my $use_fasta (0,1) { -bam =>"invalid_path.txt")}; ok($dummy,undef); ok($@ =~ /does not exist/); - - my @alignments = + + my @alignments = $sam->get_features_by_location( -seq_id => 'seq2', -start => 500, @@ -264,11 +400,11 @@ for my $use_fasta (0,1) { ok(scalar @{$alignments[0]->qscore},length $alignments[0]->dna); my @keys = $alignments[0]->get_all_tags; - ok(scalar @keys >= 17); # later versions of samtools returns 18 attributes, earlier versions return 17 - ok($alignments[0]->get_tag_values('MF') >= 17); + ok(scalar @keys,18); + ok($alignments[0]->get_tag_values('MF'),18); my %att = $alignments[0]->attributes; - ok(scalar(keys %att) >= 17); + ok(scalar(keys %att),18); ok($alignments[0]->cigar_str,'35M'); $sam->expand_flags(0); @@ -389,7 +525,7 @@ for my $use_fasta (0,1) { $matches{total}++; } }; - + $sam->pileup('seq2:1-100',$fetch_back); ok($matches{matched}/$matches{total} > 0.99); } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libbio-samtools-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits