[Seqinr-commits] r1777 - in pkg: . R man src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 30 15:39:20 CET 2014
Author: simonpenel
Date: 2014-01-30 15:39:20 +0100 (Thu, 30 Jan 2014)
New Revision: 1777
Modified:
pkg/DESCRIPTION
pkg/R/dist.alignment.R
pkg/man/dist.alignment.Rd
pkg/src/alignment.c
Log:
In function dist.alignment with nucleotides sequences, if gap option is set to 1, gaps will be counted in the identity measure (thanks to Peter Hraber)
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2013-10-07 15:11:49 UTC (rev 1776)
+++ pkg/DESCRIPTION 2014-01-30 14:39:20 UTC (rev 1777)
@@ -1,6 +1,6 @@
Package: seqinr
-Version: 3.0-8
-Date: 2013-10-7
+Version: 3.0-9
+Date: 2014-1-30
Title: Biological Sequences Retrieval and Analysis
Author: Delphine Charif and Jean R. Lobry and Anamaria Necsulea and Leonor Palmeira and Simon Penel and Guy Perriere
Maintainer: Simon Penel <simon.penel at univ-lyon1.fr>
Modified: pkg/R/dist.alignment.R
===================================================================
--- pkg/R/dist.alignment.R 2013-10-07 15:11:49 UTC (rev 1776)
+++ pkg/R/dist.alignment.R 2014-01-30 14:39:20 UTC (rev 1777)
@@ -2,7 +2,7 @@
# Pairwise Distances from Aligned Protein or DNA/RNA Sequences
#
-dist.alignment <- function(x, matrix = c("similarity", "identity") )
+dist.alignment <- function(x, matrix = c("similarity", "identity"),gap )
{
#
# Check arguments:
@@ -26,7 +26,12 @@
#
# Call the C distance function:
#
- dist <- .Call("distance", sequences, nbseq, matNumber, seqtype, PACKAGE = "seqinr")
+ if (missing(gap)) {
+ dist <- .Call("distance", sequences, nbseq, matNumber, seqtype,0, PACKAGE = "seqinr")
+ }
+ else {
+ dist <- .Call("distance", sequences, nbseq, matNumber, seqtype,gap, PACKAGE = "seqinr")
+ }
#
# Convert the result in a object of class dist:
#
Modified: pkg/man/dist.alignment.Rd
===================================================================
--- pkg/man/dist.alignment.Rd 2013-10-07 15:11:49 UTC (rev 1776)
+++ pkg/man/dist.alignment.Rd 2014-01-30 14:39:20 UTC (rev 1777)
@@ -11,12 +11,13 @@
}
\usage{
-dist.alignment(x, matrix = c("similarity", "identity"))
+dist.alignment(x, matrix = c("similarity", "identity"),gap)
}
\arguments{
\item{x}{an object of class \code{alignment}, as returned by
\code{read.alignment} for instance}
\item{matrix}{the matrix distance to be used, partial matching allowed }
+ \item{gap}{-optional- with nucleotides, if set to 1, gaps will be counted in the identity measure }
}
\value{
The distance matrix, object of class \code{dist}, computed by using the
Modified: pkg/src/alignment.c
===================================================================
--- pkg/src/alignment.c 2013-10-07 15:11:49 UTC (rev 1776)
+++ pkg/src/alignment.c 2014-01-30 14:39:20 UTC (rev 1777)
@@ -252,11 +252,12 @@
/*************************************************************************/
-SEXP distance(SEXP sequences,SEXP nbseq, SEXP matNumber, SEXP seqtype){
+SEXP distance(SEXP sequences,SEXP nbseq, SEXP matNumber, SEXP seqtype, SEXP gapoption){
SEXP d;
int MAXNSEQS;
char **seq;
+ int gap_option;
int i, j, k, n,totseqs, seq_long, nbases;
int mat_number, seq_type;
int **ndiff;
@@ -294,6 +295,7 @@
totseqs = INTEGER_VALUE(nbseq);
mat_number= INTEGER_VALUE(matNumber);
seq_type = INTEGER_VALUE(seqtype);
+ gap_option = INTEGER_VALUE(gapoption);
PROTECT(d=NEW_NUMERIC(totseqs*totseqs));
@@ -354,6 +356,23 @@
ndiff[i][j]++;
}
}
+
+ if (gap_option == 1)
+ {
+ if (seq[i][k] == '-' && seq[j][k] != '-' && seq[j][k] != 'N' && seq[j][k] != 'X')
+ {
+ nbases++;
+ ndiff[j][i]++;
+ ndiff[i][j]++;
+ }
+ if (seq[j][k] == '-' && seq[i][k] != '-' && seq[i][k] != 'N' && seq[i][k] != 'X')
+ {
+ nbases++;
+ ndiff[j][i]++;
+ ndiff[i][j]++;
+ }
+
+ }
}
else if(mat_number == 1 && seq_type == 0){
More information about the Seqinr-commits
mailing list