Skip to content

Commit

Permalink
Check that CpG positions are on chromosome
Browse files Browse the repository at this point in the history
  • Loading branch information
cangermueller committed Mar 2, 2017
1 parent 70a0ec5 commit 953cf73
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/dcpg_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ def extract_seq_windows(seq, pos, wlen, seq_index=1, assert_cpg=False):

for i in range(nb_win):
p = pos[i] - seq_index
if p < 0 or p >= len(seq):
raise ValueError('Position %d not on chromosome!' % (p + seq_index))
if seq[p:p + 2] != 'CG':
warnings.warn('No CpG site at position %d!' % p)
warnings.warn('No CpG site at position %d!' % (p + seq_index))
win = seq[max(0, p - delta): min(len(seq), p + delta + 1)]
if len(win) < wlen:
win = max(0, delta - p) * 'N' + win
Expand Down

0 comments on commit 953cf73

Please sign in to comment.