Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nextflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
nlecouvr
nextflow
Commits
e8997bda
Commit
e8997bda
authored
3 years ago
by
nlecouvr
Browse files
Options
Downloads
Patches
Plain Diff
made finder runnable
parent
0b77a330
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GATC_finder.py
+35
-0
35 additions, 0 deletions
GATC_finder.py
src/GATC_analysis.py
+7
-1
7 additions, 1 deletion
src/GATC_analysis.py
src/GATC_finder.py
+22
-17
22 additions, 17 deletions
src/GATC_finder.py
with
64 additions
and
18 deletions
GATC_finder.py
0 → 100644
+
35
−
0
View file @
e8997bda
import
re
from
Bio
import
SeqIO
def
main
(
genome_file
,
out_file_path
):
"""
[Gets all the GATC file from the given genome or sequence and puts them in a .bed file]
Args:
genome_file ([string]): [full path to the fasta file]
out_file_path ([string]): [full path to the output file]
"""
# Opening the file to write the positions in
f
=
open
(
out_file_path
,
"
w
"
)
motif
=
"
GATC
"
# Cycles through the parsed chromosomes from the fasta file
for
seq_record
in
SeqIO
.
parse
(
genome_file
,
"
fasta
"
):
# Gets the id of the chormosome in the file
chrom
=
seq_record
.
id
# Cycle throught all the motif that are found in the chromosome
for
match
in
re
.
finditer
(
motif
,
str
(
seq_record
.
seq
)):
start_pos
=
match
.
start
()
+
1
end_pos
=
match
.
end
()
+
1
# Writes the position in the .bed file (chro/start/end)
line
=
f
"
{
chrom
}
\t
{
start_pos
}
\t
{
end_pos
}
\n
"
f
.
write
(
line
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
src/GATC_analysis.py
+
7
−
1
View file @
e8997bda
...
...
@@ -69,9 +69,15 @@ for chrom, regions, name in zip(chromosomes, chrom_regions, id_list):
if
j
>=
5
:
j
=
0
i
+=
1
pos
=
np
.
arange
(
1
,
int
(
max
(
regions
)),
1
)
y
=
np
.
full
(
len
(
pos
),
39
)
print
(
len
(
pos
))
print
(
len
(
y
))
axes
[
i
,
j
].
set_title
(
name
)
axes
[
i
,
j
].
set_ylabel
(
"
site number / bin
"
)
axes
[
i
,
j
].
plot
(
pos
,
y
,
color
=
"
black
"
)
axes
[
i
,
j
].
plot
(
regions
,
chrom
)
j
+=
1
...
...
This diff is collapsed.
Click to expand it.
src/GATC_finder.py
+
22
−
17
View file @
e8997bda
import
re
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
pandas
from
Bio
import
SeqIO
,
motifs
from
Bio.Seq
import
Seq
from
Bio.SeqRecord
import
SeqRecord
from
Bio
import
SeqIO
def
main
():
def
main
(
genome_file
,
out_file_path
):
"""
[Gets all the GATC file from the given genome or sequence and puts them in a .bed file]
Args:
genome_file ([string]): [full path to the fasta file]
out_file_path ([string]): [full path to the output file]
"""
# Opening the file to write the positions in
f
=
open
(
out_file_path
,
"
w
"
)
f
=
open
(
"
/home/nathan/projects/vscode_nextflow/nextflow-nathan/results/GATC/sites.bed
"
,
"
w
"
)
motif
=
"
GATC
"
pos_list
=
list
()
for
seq_record
in
SeqIO
.
parse
(
"
/home/nathan/projects/vscode_nextflow/nextflow-nathan/data/genome/data_G.fasta
"
,
"
fasta
"
):
chrom
=
seq_record
.
id
# Cycles through the parsed chromosomes from the fasta file
for
seq_record
in
SeqIO
.
parse
(
genome_file
,
"
fasta
"
):
# Gets the id of the chormosome in the file
chrom
=
seq_record
.
id
# Cycle throught all the motif that are found in the chromosome
for
match
in
re
.
finditer
(
motif
,
str
(
seq_record
.
seq
)):
start_pos
=
match
.
start
()
+
1
end_pos
=
match
.
end
()
+
1
line
=
f
"
{
chrom
}
\t
{
start_pos
}
\t
{
end_pos
}
\n
"
f
.
write
(
line
)
# Writes the position in the .bed file (chro/start/end)
line
=
f
"
{
chrom
}
\t
{
start_pos
}
\t
{
end_pos
}
\n
"
f
.
write
(
line
)
if
__name__
==
"
__main__
"
:
main
()
\ No newline at end of file
main
()
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