Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
8592f2b5
Commit
8592f2b5
authored
17 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
make dna search selectable for one or both strands. Add general revcomp function.
parent
f7c7a252
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/ZMap/zmapDNA.h
+6
-4
6 additions, 4 deletions
src/include/ZMap/zmapDNA.h
src/zmapUtils/zmapDNA.c
+124
-16
124 additions, 16 deletions
src/zmapUtils/zmapDNA.c
with
130 additions
and
20 deletions
src/include/ZMap/zmapDNA.h
+
6
−
4
View file @
8592f2b5
...
...
@@ -25,16 +25,16 @@
* Description: DNA manipulation functions.
*
* HISTORY:
* Last edited:
Jan
5
1
6:58
2007 (edgrif)
* Last edited:
Aug
9
1
1:09
2007 (edgrif)
* Created: Fri Oct 6 14:26:08 2006 (edgrif)
* CVS info: $Id: zmapDNA.h,v 1.
4
2007-0
1-09
1
4
:3
3:2
5 edgrif Exp $
* CVS info: $Id: zmapDNA.h,v 1.
5
2007-0
8-13
1
2
:3
8:1
5 edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_DNA_H
#define ZMAP_DNA_H
#include
<glib.h>
#include
<ZMap/zmapFeature.h>
/* Holds information about any DNA matches found by the match functions.
*
...
...
@@ -44,6 +44,7 @@
typedef
struct
{
char
*
match
;
ZMapStrand
strand
;
int
start
;
int
end
;
int
screen_start
;
...
...
@@ -54,7 +55,8 @@ typedef struct
gboolean
zMapDNAValidate
(
char
*
dna
)
;
gboolean
zMapDNAFindMatch
(
char
*
cp
,
char
*
end
,
char
*
tp
,
int
maxError
,
int
maxN
,
char
**
start_out
,
char
**
end_out
,
char
**
match_str
)
;
GList
*
zMapDNAFindAllMatches
(
char
*
dna
,
char
*
query
,
int
from
,
int
length
,
GList
*
zMapDNAFindAllMatches
(
char
*
dna
,
char
*
query
,
ZMapStrand
strand
,
int
from
,
int
length
,
int
max_errors
,
int
max_Ns
,
gboolean
return_matches
)
;
void
zMapDNAReverseComplement
(
char
*
sequence
,
int
length
)
;
#endif
/* ZMAP_DNA_H */
This diff is collapsed.
Click to expand it.
src/zmapUtils/zmapDNA.c
+
124
−
16
View file @
8592f2b5
...
...
@@ -26,9 +26,9 @@
*
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited:
Oct 11
1
0
:3
1
200
6
(edgrif)
* Last edited:
Aug 9
1
4
:3
6
200
7
(edgrif)
* Created: Fri Oct 6 11:41:38 2006 (edgrif)
* CVS info: $Id: zmapDNA.c,v 1.
2
200
6-11-08 09:24:42
edgrif Exp $
* CVS info: $Id: zmapDNA.c,v 1.
3
200
7-08-13 12:38:15
edgrif Exp $
*-------------------------------------------------------------------
*/
...
...
@@ -130,7 +130,9 @@ gboolean zMapDNAFindMatch(char *cp, char *end, char *tp, int maxError, int maxN,
}
GList
*
zMapDNAFindAllMatches
(
char
*
dna
,
char
*
query
,
int
from
,
int
length
,
/* Looks for dna matches on either or both strand (if strand == ZMAPSTRAND_NONE it does both). */
GList
*
zMapDNAFindAllMatches
(
char
*
dna
,
char
*
query
,
ZMapStrand
strand
,
int
from
,
int
length
,
int
max_errors
,
int
max_Ns
,
gboolean
return_matches
)
{
GList
*
sites
=
NULL
;
...
...
@@ -144,7 +146,7 @@ GList *zMapDNAFindAllMatches(char *dna, char *query, int from, int length,
if
(
return_matches
)
match_ptr
=
&
match
;
/* rationalise coords.... */
/* rationalise coords
, they are always given in terms of the forward strand
.... */
n
=
strlen
(
dna
)
;
if
(
from
<
0
)
from
=
0
;
...
...
@@ -158,23 +160,129 @@ GList *zMapDNAFindAllMatches(char *dna, char *query, int from, int length,
search_start
=
dna
+
from
;
search_end
=
search_start
+
length
-
1
;
start
=
end
=
cp
=
search_start
;
while
(
zMapDNAFindMatch
(
cp
,
search_end
,
query
,
max_errors
,
max_Ns
,
&
start
,
&
end
,
match_ptr
))
{
ZMapDNAMatch
match
;
/* Record this match. */
match
=
g_new0
(
ZMapDNAMatchStruct
,
1
)
;
match
->
start
=
start
-
dna
;
match
->
end
=
end
-
dna
;
if
(
return_matches
)
match
->
match
=
*
match_ptr
;
if
(
strand
==
ZMAPSTRAND_NONE
||
strand
==
ZMAPSTRAND_FORWARD
)
{
while
(
zMapDNAFindMatch
(
cp
,
search_end
,
query
,
max_errors
,
max_Ns
,
&
start
,
&
end
,
match_ptr
))
{
ZMapDNAMatch
match
;
/* Record this match. */
match
=
g_new0
(
ZMapDNAMatchStruct
,
1
)
;
match
->
strand
=
ZMAPSTRAND_FORWARD
;
match
->
start
=
start
-
dna
;
match
->
end
=
end
-
dna
;
if
(
return_matches
)
match
->
match
=
*
match_ptr
;
sites
=
g_list_append
(
sites
,
match
)
;
/* Move pointers on. */
cp
=
end
+
1
;
}
}
if
(
strand
==
ZMAPSTRAND_NONE
||
strand
==
ZMAPSTRAND_REVERSE
)
{
char
*
revcomp_dna
;
int
offset
;
offset
=
search_start
-
dna
;
/* Make a revcomp'd copy of the forward strand section. */
revcomp_dna
=
g_memdup
(
search_start
,
length
)
;
zMapDNAReverseComplement
(
revcomp_dna
,
length
)
;
sites
=
g_list_append
(
sites
,
match
)
;
/* Set the pointers and search. */
search_start
=
revcomp_dna
;
search_end
=
search_start
+
length
-
1
;
start
=
end
=
cp
=
search_start
;
/* Move pointers on. */
cp
=
end
+
1
;
while
(
zMapDNAFindMatch
(
cp
,
search_end
,
query
,
max_errors
,
max_Ns
,
&
start
,
&
end
,
match_ptr
))
{
ZMapDNAMatch
match
;
int
tmp
;
/* Record this match. */
match
=
g_new0
(
ZMapDNAMatchStruct
,
1
)
;
match
->
strand
=
ZMAPSTRAND_REVERSE
;
match
->
start
=
(
length
-
(
start
-
revcomp_dna
))
+
offset
-
1
;
match
->
end
=
(
length
-
(
end
-
revcomp_dna
))
+
offset
-
1
;
tmp
=
match
->
start
;
match
->
start
=
match
->
end
;
match
->
end
=
tmp
;
if
(
return_matches
)
match
->
match
=
*
match_ptr
;
sites
=
g_list_append
(
sites
,
match
)
;
/* Move pointers on. */
cp
=
end
+
1
;
}
g_free
(
revcomp_dna
)
;
}
return
sites
;
}
/* Reverse complement the DNA. This function is fast enough for now, if it proves too slow
* then rewrite it !
*
* It works by starting at each end and swopping the bases and then complementing the bases
* so that the whole thing is done in place.
* */
void
zMapDNAReverseComplement
(
char
*
sequence
,
int
length
)
{
char
*
s
,
*
e
;
int
i
;
for
(
s
=
sequence
,
e
=
(
sequence
+
length
-
1
),
i
=
0
;
i
<
length
/
2
;
s
++
,
e
--
,
i
++
)
{
char
tmp
;
tmp
=
*
s
;
*
s
=
*
e
;
*
e
=
tmp
;
switch
(
*
s
)
{
case
'a'
:
*
s
=
't'
;
break
;
case
't'
:
*
s
=
'a'
;
break
;
case
'c'
:
*
s
=
'g'
;
break
;
case
'g'
:
*
s
=
'c'
;
break
;
}
switch
(
*
e
)
{
case
'a'
:
*
e
=
't'
;
break
;
case
't'
:
*
e
=
'a'
;
break
;
case
'c'
:
*
e
=
'g'
;
break
;
case
'g'
:
*
e
=
'c'
;
break
;
}
}
return
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment