Commit ccd58bb6 authored by Mathieu Giraud's avatar Mathieu Giraud

ncbi.py, split-from-imgt.py: move 'additional_length' to ncbi.get_gene_sequence()

parent 2ad7d54d
......@@ -18,10 +18,15 @@ from xml.dom import minidom, Node
# The two following functions should be refactored as one (used in split-from-imgt and get-CD)
def get_gene_sequence(gene, other_gene_name, start, end):
def get_gene_sequence(gene, other_gene_name, start, end, additional_length):
'''
Return the gene sequences between positions start and end (included).
'''
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()
return re.sub('(>\S*) ', r'\1|'+other_gene_name+'|', fasta_string)
......
......@@ -120,11 +120,7 @@ def retrieve_genes(f, genes, tag, additional_length, gene_list):
start = coord['from']
end = coord['to']
if additional_length > 0:
end += additional_length
elif additional_length < 0:
start = max(1, start + additional_length)
gene_data = ncbi.get_gene_sequence(target, coord['imgt_data'] + tag, start, end)
gene_data = ncbi.get_gene_sequence(target, coord['imgt_data'] + tag, start, end, additional_length)
if coord['imgt_data'].split('|')[-1] == FEATURE_J_REGION:
gene_lines = gene_data.split('\n')
gene_lines[1] = gap_j(gene_lines[1].lower())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment