comparison GAFA.py @ 3:e17a3470c70a draft

planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/GAFA/ commit 988b1fc1cb8739e45648465adbf099f3fdaf87f8
author earlhaminst
date Fri, 03 Mar 2017 07:20:23 -0500
parents fc8ca4ade638
children 117fc7414307
comparison
equal deleted inserted replaced
2:0c2f9172334a 3:e17a3470c70a
10 10
11 Sequence = collections.namedtuple('Sequence', ['header', 'sequence']) 11 Sequence = collections.namedtuple('Sequence', ['header', 'sequence'])
12 12
13 13
14 def FASTAReader_gen(fasta_filename): 14 def FASTAReader_gen(fasta_filename):
15 fasta_file = open(fasta_filename) 15 with open(fasta_filename) as fasta_file:
16 line = fasta_file.readline()
17 while True:
18 if not line:
19 return
20 assert line.startswith('>'), "FASTA headers must start with >"
21 header = line.rstrip()
22 sequence_parts = []
23 line = fasta_file.readline() 16 line = fasta_file.readline()
24 while line and line[0] != '>': 17 while True:
25 sequence_parts.append(line.rstrip()) 18 if not line:
19 return
20 assert line.startswith('>'), "FASTA headers must start with >"
21 header = line.rstrip()
22 sequence_parts = []
26 line = fasta_file.readline() 23 line = fasta_file.readline()
27 sequence = "".join(sequence_parts) 24 while line and line[0] != '>':
28 yield Sequence(header, sequence) 25 sequence_parts.append(line.rstrip())
26 line = fasta_file.readline()
27 sequence = "".join(sequence_parts)
28 yield Sequence(header, sequence)
29 29
30 30
31 FASTA_MATCH_RE = re.compile(r'[^-]') 31 FASTA_MATCH_RE = re.compile(r'[^-]')
32 32
33 33