#!/usr/bin/env python
 
import re

#Initialization of important variables
OrderList = ['2589010','2589908','2596389','2622209','2623352']
NameOligos = []
SeqOligos = []
LineNumber = 0

for OrderNumber in OrderList: # Grosse boucle qui ouvre une part une les commandes et va chercher les infos sur les oligos
	
	InFileName = "order%s.html" % (OrderNumber)
	InFile = open(InFileName, 'r')
	InFileTwo = open(InFileName, 'r')
	FileLines = InFileTwo.readlines()
	
	for Line in InFile:
		GoodLine = re.search("bp", Line)
		if GoodLine != None:
			
			# Ajout de la sequence dans la liste des Oligos
			SearchOligo = re.search("<td>([\w, ]+)", Line)
			SeqOligo = str(SearchOligo.group(1)).replace(" ","")
			SeqOligos += [SeqOligo] 
			
			# Ajout du nom de la sequence dans la liste des noms
			SearchName = re.search("<td>([\w, ,/,-]+)", FileLines[LineNumber - 5])
			NameOligo = str(SearchName.group(1)).strip()
			NameOligos += [NameOligo]
			
		#Incrementation des lignes
		LineNumber += 1
	
	ListNbOligos += [NbOligos]		
	InFile.close()
	InFileTwo.close()
	LineNumber = 0