Skip to content

Commit

Permalink
read entire genome, regardless of newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
jy19 committed Dec 3, 2015
1 parent b112bd3 commit 259d7fa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Mapping Project/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ def get_position_range(self, char, list_type, start, end):
return positions

def map(self, pattern):
"""find a given pattern in the genome"""
found_positions = []
rev_pattern = pattern[::-1]
current_positions = self.get_position_range(rev_pattern[0], self.first_col, 0, len(self.first_col) - 1)
for i in range(1, len(rev_pattern)):
bwt_positions = self.get_position_range(rev_pattern[i], self.bwt, current_positions[0], current_positions[-1])
ltof_positions = range(self.ltof[bwt_positions[0]], self.ltof[bwt_positions[-1]] + 1)
current_positions = ltof_positions
try:
ltof_positions = range(self.ltof[bwt_positions[0]], self.ltof[bwt_positions[-1]] + 1)
current_positions = ltof_positions
except IndexError:
print 'Index Error out of range', bwt_positions
# after last char, push every position in SA to found_positions
for i in current_positions:
found_positions.append(self.suffix_array[i])
Expand Down Expand Up @@ -79,7 +83,7 @@ def output_to_SAM(position, pattern, pattern_name, genome_name):
genome_name = genome_fasta.next().strip()[1:]
dna = ""
for line in genome_fasta:
dna = line.strip().upper()
dna += line.strip().upper()
dna += '$'

with open(sys.argv[2]) as read_fasta:
Expand Down

0 comments on commit 259d7fa

Please sign in to comment.