Skip to content

Commit

Permalink
VSEARCH 2.8.3: Fix segfault bug for derep_fulllength with uc
Browse files Browse the repository at this point in the history
  • Loading branch information
torognes committed Aug 31, 2018
1 parent 15f715a commit c9a4099
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 19 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Most of the nucleotide based commands and options in USEARCH version 7 are suppo

## Getting Help

If you can't find an answer in the [VSEARCH documentation](https://github.com/torognes/vsearch/releases/download/v2.8.2/vsearch_manual.pdf), please visit the [VSEARCH Web Forum](https://groups.google.com/forum/#!forum/vsearch-forum) to post a question or start a discussion.
If you can't find an answer in the [VSEARCH documentation](https://github.com/torognes/vsearch/releases/download/v2.8.3/vsearch_manual.pdf), please visit the [VSEARCH Web Forum](https://groups.google.com/forum/#!forum/vsearch-forum) to post a question or start a discussion.

## Example

Expand All @@ -37,9 +37,9 @@ In the example below, VSEARCH will identify sequences in the file database.fsa t
**Source distribution** To download the source distribution from a [release](https://github.com/torognes/vsearch/releases) and build the executable and the documentation, use the following commands:

```
wget https://github.com/torognes/vsearch/archive/v2.8.2.tar.gz
tar xzf v2.8.2.tar.gz
cd vsearch-2.8.2
wget https://github.com/torognes/vsearch/archive/v2.8.3.tar.gz
tar xzf v2.8.3.tar.gz
cd vsearch-2.8.3
./autogen.sh
./configure
make
Expand Down Expand Up @@ -70,36 +70,36 @@ Binary distributions are provided for x86-64 systems running GNU/Linux, macOS (v
Download the appropriate executable for your system using the following commands if you are using a Linux x86_64 system:

```sh
wget https://github.com/torognes/vsearch/releases/download/v2.8.2/vsearch-2.8.2-linux-x86_64.tar.gz
tar xzf vsearch-2.8.2-linux-x86_64.tar.gz
wget https://github.com/torognes/vsearch/releases/download/v2.8.3/vsearch-2.8.3-linux-x86_64.tar.gz
tar xzf vsearch-2.8.3-linux-x86_64.tar.gz
```

Or these commands if you are using a Linux ppc64le system:

```sh
wget https://github.com/torognes/vsearch/releases/download/v2.8.2/vsearch-2.8.2-linux-ppc64le.tar.gz
tar xzf vsearch-2.8.2-linux-ppc64le.tar.gz
wget https://github.com/torognes/vsearch/releases/download/v2.8.3/vsearch-2.8.3-linux-ppc64le.tar.gz
tar xzf vsearch-2.8.3-linux-ppc64le.tar.gz
```

Or these commands if you are using a Mac:

```sh
wget https://github.com/torognes/vsearch/releases/download/v2.8.2/vsearch-2.8.2-macos-x86_64.tar.gz
tar xzf vsearch-2.8.2-macos-x86_64.tar.gz
wget https://github.com/torognes/vsearch/releases/download/v2.8.3/vsearch-2.8.3-macos-x86_64.tar.gz
tar xzf vsearch-2.8.3-macos-x86_64.tar.gz
```

Or if you are using Windows, download and extract (unzip) the contents of this file:

```
https://github.com/torognes/vsearch/releases/download/v2.8.2/vsearch-2.8.2-win-x86_64.zip
https://github.com/torognes/vsearch/releases/download/v2.8.3/vsearch-2.8.3-win-x86_64.zip
```

Linux and Mac: You will now have the binary distribution in a folder called `vsearch-2.8.2-linux-x86_64` or `vsearch-2.8.2-macos-x86_64` in which you will find three subfolders `bin`, `man` and `doc`. We recommend making a copy or a symbolic link to the vsearch binary `bin/vsearch` in a folder included in your `$PATH`, and a copy or a symbolic link to the vsearch man page `man/vsearch.1` in a folder included in your `$MANPATH`. The PDF version of the manual is available in `doc/vsearch_manual.pdf`.
Linux and Mac: You will now have the binary distribution in a folder called `vsearch-2.8.3-linux-x86_64` or `vsearch-2.8.3-macos-x86_64` in which you will find three subfolders `bin`, `man` and `doc`. We recommend making a copy or a symbolic link to the vsearch binary `bin/vsearch` in a folder included in your `$PATH`, and a copy or a symbolic link to the vsearch man page `man/vsearch.1` in a folder included in your `$MANPATH`. The PDF version of the manual is available in `doc/vsearch_manual.pdf`.

Windows: You will now have the binary distribution in a folder called `vsearch-2.8.2-win-x86_64`. The vsearch executable is called `vsearch.exe`. The manual in PDF format is called `vsearch_manual.pdf`.
Windows: You will now have the binary distribution in a folder called `vsearch-2.8.3-win-x86_64`. The vsearch executable is called `vsearch.exe`. The manual in PDF format is called `vsearch_manual.pdf`.


**Documentation** The VSEARCH user's manual is available in the `man` folder in the form of a [man page](https://github.com/torognes/vsearch/blob/master/man/vsearch.1). A pdf version ([vsearch_manual.pdf](https://github.com/torognes/vsearch/releases/download/v2.8.2/vsearch_manual.pdf)) will be generated by `make`. To install the manpage manually, copy the `vsearch.1` file or a create a symbolic link to `vsearch.1` in a folder included in your `$MANPATH`. The manual in both formats is also available with the binary distribution. The manual in PDF form ([vsearch_manual.pdf](https://github.com/torognes/vsearch/releases/download/v2.8.2/vsearch_manual.pdf)) is also attached to the latest [release](https://github.com/torognes/vsearch/releases).
**Documentation** The VSEARCH user's manual is available in the `man` folder in the form of a [man page](https://github.com/torognes/vsearch/blob/master/man/vsearch.1). A pdf version ([vsearch_manual.pdf](https://github.com/torognes/vsearch/releases/download/v2.8.3/vsearch_manual.pdf)) will be generated by `make`. To install the manpage manually, copy the `vsearch.1` file or a create a symbolic link to `vsearch.1` in a folder included in your `$MANPATH`. The manual in both formats is also available with the binary distribution. The manual in PDF form ([vsearch_manual.pdf](https://github.com/torognes/vsearch/releases/download/v2.8.3/vsearch_manual.pdf)) is also attached to the latest [release](https://github.com/torognes/vsearch/releases).


## Plugins, packages, and wrappers
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
AC_INIT([vsearch], [2.8.2], [[email protected]])
AC_INIT([vsearch], [2.8.3], [[email protected]])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([subdir-objects])
AC_LANG([C++])
Expand Down
5 changes: 4 additions & 1 deletion man/vsearch.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\" ============================================================================
.TH vsearch 1 "August 21, 2018" "version 2.8.2" "USER COMMANDS"
.TH vsearch 1 "August 31, 2018" "version 2.8.3" "USER COMMANDS"
.\" ============================================================================
.SH NAME
vsearch \(em chimera detection, clustering, dereplication and
Expand Down Expand Up @@ -3406,6 +3406,9 @@ for full-length dereplication in cases with many duplicate sequences.
Improved wording of fastq_mergepairs report. Updated manual regarding
use of sizein and sizeout with dereplication. Changed a compiler
option.
.TP
.BR v2.8.3\~ "released August 31st, 2018"
Fix for segmentation fault for \-\-derep_fulllength with \-\-uc.
.RE
.LP
.\" ============================================================================
Expand Down
31 changes: 28 additions & 3 deletions src/derep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,15 @@ void derep_fulllength()
const unsigned int terminal = (unsigned int)(-1);
memset(nextseqtab, terminal, sizeof(unsigned int) * alloc_seqs);

/* alloc and init table of pointers to the headers */

char ** headertab = 0;
if (opt_uc)
{
headertab = (char **) xmalloc(sizeof(char*) * alloc_seqs);
memset(headertab, 0, sizeof(char*) * alloc_seqs);
}

show_rusage();

char * match_strand = (char *) xmalloc(alloc_seqs);
Expand Down Expand Up @@ -329,6 +338,13 @@ void derep_fulllength()
terminal,
sizeof(unsigned int) * alloc_seqs);

if (opt_uc)
{
headertab = (char**) xrealloc(headertab,
sizeof(char*) * new_alloc_seqs);
memset(headertab + alloc_seqs, 0, sizeof(char*) * alloc_seqs);
}

match_strand = (char *) xrealloc(match_strand, new_alloc_seqs);
memset(match_strand + alloc_seqs, 0, alloc_seqs);

Expand Down Expand Up @@ -406,6 +422,7 @@ void derep_fulllength()
}
}

char * header = fastx_get_header(h);
int abundance = fastx_get_abundance(h);
int64_t ab = opt_sizein ? abundance : 1;
sumsize += ab;
Expand All @@ -417,12 +434,12 @@ void derep_fulllength()
unsigned int last = bp->seqno_last;
nextseqtab[last] = sequencecount;
bp->seqno_last = sequencecount;
if (opt_uc)
headertab[sequencecount] = xstrdup(header);
}
else
{
/* no identical sequences yet */
char * header = fastx_get_header(h);

bp->size = ab;
bp->hash = hash;
bp->seqno_first = sequencecount;
Expand Down Expand Up @@ -631,7 +648,7 @@ void derep_fulllength()
"H\t%" PRId64 "\t%" PRId64 "\t%.1f\t%s\t0\t0\t*\t%s\t%s\n",
i, len, 100.0,
(match_strand[next] ? "-" : "+"),
db_getheader(next), h);
headertab[next], h);

progress_update(i);
}
Expand Down Expand Up @@ -682,6 +699,14 @@ void derep_fulllength()
}
}

if (opt_uc)
{
for (uint64_t i=0; i<alloc_seqs; i++)
if (headertab[i])
xfree(headertab[i]);
xfree(headertab);
}

show_rusage();

xfree(match_strand);
Expand Down

1 comment on commit c9a4099

@torognes
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes issue #333.

Please sign in to comment.