Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vidjil
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1,696
Issues
1,696
List
Boards
Labels
Service Desk
Milestones
Merge Requests
88
Merge Requests
88
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vidjil
vidjil
Commits
a90864e5
Commit
a90864e5
authored
Jul 12, 2018
by
Mikaël Salson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split-from-imgt.py: Code factorization
Between get_updownstream_sequences and get_gene_sequence
parent
da462732
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
germline/ncbi.py
germline/ncbi.py
+10
-10
No files found.
germline/ncbi.py
View file @
a90864e5
...
...
@@ -10,7 +10,7 @@ API_EUTILS = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?'
API_EUTILS
+=
'api_key='
+
os
.
environ
[
'NCBI_KEY'
]
+
'&'
if
'NCBI_KEY'
in
os
.
environ
else
''
API_NUCCORE_ID
=
API_EUTILS
+
'db=nuccore&rettype=fasta&retmode=text'
+
'&id=%s'
API_NUCCORE_ID_FROM_TO
=
API_EUTILS
+
'db=nuccore&rettype=fasta&retmode=text'
+
'&id=%s'
+
'&from=%s&to=%s'
API_NUCCORE_ID_FROM_TO
=
API_EUTILS
+
'db=nuccore&rettype=fasta&retmode=text'
+
'&id=%s'
+
'&from=%s&to=%s
&strand=%d
'
API_GENE_ID_XML
=
API_EUTILS
+
'db=gene&retmode=xml&rettype=docsum'
+
'&id=%s'
...
...
@@ -25,12 +25,19 @@ def get_gene_sequence(gene, other_gene_name, start, end, additional_length):
'''
Return the gene sequences between positions start and end (included).
'''
reversed
=
False
if
end
<
start
:
tmp
=
end
end
=
start
start
=
tmp
reversed
=
True
if
additional_length
>
0
:
end
+=
additional_length
elif
additional_length
<
0
:
start
=
max
(
1
,
start
+
additional_length
)
fasta_string
=
urllib
.
urlopen
(
API_NUCCORE_ID_FROM_TO
%
(
gene
,
start
,
end
)).
read
()
fasta_string
=
urllib
.
urlopen
(
API_NUCCORE_ID_FROM_TO
%
(
gene
,
start
,
end
,
2
if
reversed
else
1
)).
read
()
return
re
.
sub
(
'(>\S*) '
,
r
'\1|'
+
other_gene_name
+
'|'
,
fasta_string
)
def
ncbi_and_write
(
ncbi
,
additional_header
,
outs
):
...
...
@@ -69,16 +76,9 @@ def get_updownstream_sequences(gene, start, end, additional_length):
end
=
start
-
1
*
reversed
start
=
max
(
1
,
start
+
additional_length
*
reversed
)
if
start
>
end
:
tmp
=
start
start
=
end
end
=
tmp
updown_fasta
=
urllib
.
urlopen
(
API_NUCCORE_ID_FROM_TO
%
(
gene
,
start
,
end
)).
read
()
updown_fasta
=
get_gene_sequence
(
gene
,
''
,
start
,
end
,
0
)
updown_raw
=
'
\n
'
.
join
(
updown_fasta
.
split
(
'
\n
'
)[
1
:]).
strip
()
if
reversed
==
-
1
:
updown_raw
=
fasta
.
revcomp
(
updown_raw
.
upper
())
if
additional_length
>
0
:
return
(
''
,
updown_raw
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment