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
78dc42fd
Commit
78dc42fd
authored
19 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
functions for processing dna
parent
d5c256b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/zmapUtils/zmapDNAUtils.c
+111
-0
111 additions, 0 deletions
src/zmapUtils/zmapDNAUtils.c
with
111 additions
and
0 deletions
src/zmapUtils/zmapDNAUtils.c
0 → 100755
+
111
−
0
View file @
78dc42fd
/* File: zmapDNAUtils.c
* Author: Ed Griffiths (edgrif@sanger.ac.uk)
* Copyright (c) Sanger Institute, 2005
*-------------------------------------------------------------------
* ZMap is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the ZMap genome database package
* originated by
* Ed Griffiths (Sanger Institute, UK) edgrif@sanger.ac.uk,
* Roy Storey (Sanger Institute, UK) rds@sanger.ac.uk
*
* Description: General functions for doing stuff with DNA strings.
*
* Exported functions: See XXXXXXXXXXXXX.h
* HISTORY:
* Last edited: Nov 8 16:33 2005 (edgrif)
* Created: Tue Nov 8 13:47:27 2005 (edgrif)
* CVS info: $Id: zmapDNAUtils.c,v 1.1 2005-11-08 17:06:15 edgrif Exp $
*-------------------------------------------------------------------
*/
#include
<string.h>
#include
<ZMap/zmapUtils.h>
#include
<ZMap/zmapUtilsDNA.h>
/* FASTA files can lines of any length but 50 is convenient for terminal display
* and counting... */
enum
{
FASTA_CHARS
=
50
}
;
/* This code is lifted from the code that I wrote for acedb - EG
* Given a sequence name and its dna sequence, will dump the data in FastA
* format.
* Routine could be extended to find the sequence length but tedious/trivial really. */
gboolean
zmapDNADumpFASTA
(
GIOChannel
*
file
,
char
*
seq_name
,
int
seq_len
,
char
*
dna
,
GError
**
error_out
)
{
gboolean
result
=
TRUE
;
GIOStatus
status
;
gsize
bytes_written
=
0
;
char
*
header
;
char
buffer
[
FASTA_CHARS
+
2
]
;
/* FastA chars + \n + \0 */
int
dna_length
=
0
;
int
lines
=
0
,
chars_left
=
0
;
char
*
cp
=
NULL
;
int
i
;
zMapAssert
(
file
&&
seq_name
&&
seq_len
>
0
&&
dna
&&
error_out
)
;
header
=
g_strdup_printf
(
">%s
\n
"
,
seq_name
)
;
if
((
status
=
g_io_channel_write_chars
(
file
,
header
,
-
1
,
&
bytes_written
,
error_out
))
!=
G_IO_STATUS_NORMAL
)
{
result
=
FALSE
;
}
else
{
dna_length
=
strlen
(
dna
)
;
lines
=
dna_length
/
FASTA_CHARS
;
chars_left
=
dna_length
%
FASTA_CHARS
;
cp
=
dna
;
/* Do the full length lines. */
if
(
lines
!=
0
)
{
buffer
[
FASTA_CHARS
]
=
'\n'
;
buffer
[
FASTA_CHARS
+
1
]
=
'\0'
;
for
(
i
=
0
;
i
<
lines
&&
result
;
i
++
)
{
memcpy
(
&
buffer
[
0
],
cp
,
FASTA_CHARS
)
;
cp
+=
FASTA_CHARS
;
if
((
status
=
g_io_channel_write_chars
(
file
,
&
buffer
[
0
],
-
1
,
&
bytes_written
,
error_out
))
!=
G_IO_STATUS_NORMAL
)
result
=
FALSE
;
}
}
/* Do the last line. */
if
(
chars_left
!=
0
)
{
memcpy
(
&
buffer
[
0
],
cp
,
chars_left
)
;
buffer
[
chars_left
]
=
'\n'
;
buffer
[
chars_left
+
1
]
=
'\0'
;
if
((
status
=
g_io_channel_write_chars
(
file
,
&
buffer
[
0
],
-
1
,
&
bytes_written
,
error_out
))
!=
G_IO_STATUS_NORMAL
)
result
=
FALSE
;
}
}
g_free
(
header
)
;
return
result
;
}
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