def get_sequence(self, chrom, start, end, strand='<STR_LIT:+>', indexing=(-<NUM_LIT:1>, <NUM_LIT:0>)):
try:<EOL><INDENT>divisor = int(self.sequence_index[chrom][<NUM_LIT:2>])<EOL><DEDENT>except KeyError:<EOL><INDENT>self.open_fasta_index()<EOL>try:<EOL><INDENT>divisor = int(self.sequence_index[chrom][<NUM_LIT:2>])<EOL><DEDENT>except KeyError:<EOL><INDENT>sys.stderr.write("<STR_LIT>" % chrom)<EOL>return "<STR_LIT>"<EOL><DEDENT><DEDENT>start+=indexing[<NUM_LIT:0>]<EOL>end+=indexing[<NUM_LIT:1>]<EOL>if ( start < <NUM_LIT:0> or end > int(self.sequence_index[chrom][<NUM_LIT:0>] )):<EOL><INDENT>raise ValueError("<STR_LIT>" % (start-indexing[<NUM_LIT:0>], end-indexing[<NUM_LIT:1>], <EOL>int(self.sequence_index[chrom][<NUM_LIT:0>])))<EOL><DEDENT>seekpos = int(self.sequence_index[chrom][<NUM_LIT:1>])<EOL>seekpos += start+start/divisor<EOL>slen = end-start<EOL>endpos = int(slen + (slen/divisor) + <NUM_LIT:1>) <EOL>self.fasta_file.seek(seekpos, <NUM_LIT:0>)<EOL>output = self.fasta_file.read(endpos)<EOL>output = output.replace('<STR_LIT:\n>', '<STR_LIT>')<EOL>out = output[:slen]<EOL>if strand == '<STR_LIT:+>' or strand == <NUM_LIT:1>:<EOL><INDENT>return out<EOL><DEDENT>if strand == '<STR_LIT:->' or strand == -<NUM_LIT:1>:<EOL><INDENT>return _reverse_complement(out)<EOL><DEDENT>
chromosome is entered relative to the file it was built with, so it can be 'chr11' or '11',
start/end are coordinates, which default to python style [0,1) internally. So positions should be
entered with (1,1) indexing. This can be changed with the indexing keyword.
The default is for everything to be relative to the positive strand