def open_fasta_index(self):
index = self.fasta_index<EOL>try:<EOL><INDENT>handle = open(index, '<STR_LIT:rb>')<EOL><DEDENT>except (IOError, TypeError):<EOL><INDENT>sys.stderr.write('<STR_LIT>')<EOL>try:<EOL><INDENT>self.build_fasta_index()<EOL>return<EOL><DEDENT>except IOError:<EOL><INDENT>raise IOError("<STR_LIT>"+self.fasta_index+"<STR_LIT>")<EOL><DEDENT><DEDENT>self.sequence_index = {}<EOL>_seq_dict = self.sequence_index<EOL>for row in handle:<EOL><INDENT>entry = row.decode('<STR_LIT:utf-8>').strip().split('<STR_LIT:\t>')<EOL>_seq_dict[entry[<NUM_LIT:0>]] = (entry[<NUM_LIT:1>], entry[<NUM_LIT:2>], entry[<NUM_LIT:3>], entry[<NUM_LIT:4>])<EOL><DEDENT>
custom type for file made w/ buildFastaIndex, fai for ones made with samtools