Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python_one_week_4_biologists_solutions
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hub-courses
python_one_week_4_biologists_solutions
Commits
6fd6a91f
Commit
6fd6a91f
authored
6 years ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Adding an example of usage of SeqIO.
parent
ad4915a7
No related branches found
No related tags found
No related merge requests found
Pipeline
#10532
passed
6 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/_static/code/seq_io.py
+25
-0
25 additions, 0 deletions
source/_static/code/seq_io.py
with
25 additions
and
0 deletions
source/_static/code/seq_io.py
0 → 100644
+
25
−
0
View file @
6fd6a91f
#!/usr/bin/env python3
"""
Example of use of SeqIO from biopython
Here, we parse a fasta file, put the records in a list, search for a motif in
the sequence of the first record, and create a subsequence around this motif.
"""
from
Bio
import
SeqIO
records
=
list
(
SeqIO
.
parse
(
fasta_filename
,
"
fasta
"
))
records
# [SeqRecord(seq=Seq('GCCTCGGCCTCTGCATAAATAAAAAAAATTAGTCAGCCATGGGGCGGAGAATGG...GCG', SingleLetterAlphabet()), id='gi|965480|gb|J02400.1|SV4CG', name='gi|965480|gb|J02400.1|SV4CG', description='gi|965480|gb|J02400.1|SV4CG Simian virus 40 complete genome', dbxrefs=[])]
sequence
=
records
[
0
].
seq
sequence
# Seq('GCCTCGGCCTCTGCATAAATAAAAAAAATTAGTCAGCCATGGGGCGGAGAATGG...GCG', SingleLetterAlphabet())
motif
=
"
TAAAT
"
sequence
.
find
(
motif
)
# 15
motif_pos
=
sequence
.
find
(
motif
)
subseq_start
=
motif_pos
-
10
subseq_end
=
motif_pos
+
len
(
motif
)
+
11
subseq
=
sequence
[
subseq_start
:
subseq_end
]
subseq
# Seq('GGCCTCTGCATAAATAAAAAAAATTA', SingleLetterAlphabet())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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