Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for 7 digit sequences
  • Loading branch information
dubslow committed Nov 2, 2017
1 parent f46adc6 commit abed160
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions scripts/allseq.py
Expand Up @@ -126,12 +126,12 @@ def get_reservations(pids):
for pid in pids:
page = blogotubes(reservation_page + '?p={}&postcount=1'.format(str(pid)),
hdrs={'User-Agent': 'Dubslow/AliquotSequences'})
update = re.search(r'<!-- edit note -->.*Last fiddled with by [A-Za-z_0-9 -]+? on ([0-9a-zA-Z ]+) at <span class="time">([0-9:]{5})</span>', page, flags=re.DOTALL)
update = re.search(r'<!-- edit note -->.*Last fiddled with by [A-Za-z_0-9 -]+? on ([0-9a-zA-Z -]+) at <span class="time">([0-9:]{5})</span>', page, flags=re.DOTALL)
updated = update.group(1)+' '+update.group(2)
# Isolate the [code] block with the reservations
page = re.search(r'<pre.*?>(.*?)</pre>', page, flags=re.DOTALL).group(1)
for line in page.splitlines():
herp = re.match(r' {0,3}([0-9]{3,6}) ([0-9A-Za-z_@. -]{1,16})', line) # "seq name"
herp = re.match(r' {0,3}([0-9]{3,7}) ([0-9A-Za-z_@. -]{1,16})', line) # "seq name"
try:
name = herp.group(2)
except: pass # Ignore non-matching lines
Expand Down
8 changes: 5 additions & 3 deletions scripts/reservations.py
Expand Up @@ -333,6 +333,7 @@ def spider(last_pid):
backup()
db = read_db()
spider_msg = []
seq_regex = re.compile(r'(?<![0-9])[0-9]{5,7}(?![0-9])') # matches only 5-7 digit numbers

###############################################################################################
# First the standalone func that processes mass text file reservations
Expand All @@ -342,7 +343,7 @@ def parse_text_file(reservee, url):
txt = blogotubes(url)
current = set()
for line in txt.splitlines():
if re.match(r'(?<![0-9])[0-9]{5,6}(?![0-9])', line):
if seq_regex.match(line):
seq = int(line)
if seq in current:
string = "Duplicate sequence? {} {}".format(seq, url)
Expand All @@ -368,12 +369,13 @@ def parse_text_file(reservee, url):
def process_msg(pid, name, msg):
add = []; addkws = ('Reserv', 'reserv', 'Add', 'add', 'Tak', 'tak')
drop = []; dropkws = ('Unreserv', 'unreserv', 'Drop', 'drop', 'Releas', 'releas')

for line in msg.splitlines():
if any(kw in line for kw in dropkws):
for s in re.findall(r'(?<![0-9])[0-9]{5,6}(?![0-9])', line): # matches only 5/6 digit numbers
for s in seq_regex.findall(line):
drop.append(int(s))
elif any(kw in line for kw in addkws):
for s in re.findall(r'(?<![0-9])[0-9]{5,6}(?![0-9])', line):
for s in seq_regex.findall(line):
add.append(int(s))
la = len(add)
ld = len(drop)
Expand Down
2 changes: 1 addition & 1 deletion website/html/template.html
Expand Up @@ -116,7 +116,7 @@
$("div.check").html('Exclude sequences with a 3: <input type="checkbox" id="three"> &nbsp;'+
'Exclude drivers: <input type="checkbox" id="driver"> &nbsp;'+
'Exclude reserved sequences: <input type="checkbox" id="reserve"><br>'+
'Range-filter sequence leaders: <input type="text" id="min" maxlength=6 size=6> - <input type="text" id="max" maxlength=6 size=6> <!--button type="button" id="button">Filter</button-->' );
'Range-filter sequence leaders: <input type="text" id="min" maxlength=7 size=7> - <input type="text" id="max" maxlength=7 size=7> <!--button type="button" id="button">Filter</button-->' );
function redraw() {{ oTable.fnDraw(); }}
$('#three').change( redraw );
$('#driver').change( redraw );
Expand Down

0 comments on commit abed160

Please sign in to comment.