# -*- coding: utf-8 -*- #Luc Abate IRD URM224 MIVEGEC 05/02/2013 #fixFAS.py info sur l'auteur pour FSAconverter #Plateforme Seq-Gen Erick Desmarais et Frédérique Cerqueira from Tkinter import * from tkFileDialog import * from re import * #from string import maketrans import os ######fonctions de base def selectfolder(): global foldername foldername = askdirectory(parent=root, title='Please select a directory') if foldername: print "Folder selected : " print foldername return foldername def selectfile(): global filename filename = askopenfilename(parent=root, title='Please select a file') if filename: print "File selected : " print filename return filename def saveas(): global filenameout myFormats=[ ('Text','*.txt') ] filenameout = asksaveasfilename(parent=root,filetypes=myFormats,title="Save output as...") if len(filenameout) > 0: print "Now saving as %s" % (filenameout) if search('.txt$',filenameout): return filenameout else: filenameout=filenameout+".txt" return filenameout ######Pour menu sous fenetre def help1(): filewin = Toplevel(root) filewin.title('Help') tex = Label(filewin, text='******FSAconverter utility :******\nConvert .fsa files (from 3500 sequencer)\nfor compatibillty to genemapper previous to version 5\nNew files will be created in FSAconverter folder\nwithin the folder selected\n\n**********G2G utility :**********\nTo formate a genemapper exported genotype table\nin a genepop file\n\n**********G2S utility :**********\nTo formate a genepop file to a structure file\n') tex.pack() button = Button(filewin, text="Close window", command=filewin.destroy) button.pack() def about(): filewin = Toplevel(root) filewin.title('About') tex = Label(filewin, text='pyFSAconverter is a python program\nderived from fixFSA script\n\nMore info at :\nSeqGen platform - UMII\nBat 24 1°étage\ncc 63 - Pl. E Bataillon\n34095 Montpellier Cedex 5') tex.pack() button = Button(filewin, text="Close window", command=filewin.destroy) button.pack() ######pour FSAconverter def findAddress(mystring): """convertit les octets lus en decimal""" result = 0 n=len(mystring) taille=range(n) taille.reverse() for i in taille: result=result+ord(mystring[i])*(16**(2*n-2*i-2)) return result ###### def FSAconverter(): print " ************************************************" print " FSAconverter" print " FSAconverter v.1 (2013-02)" print " ************************************************" print " Beta version, l.Abate, MIVEGEC, IRD" print " based on fixFSA.py script provided by CeMEB" print " ************************************************" selectfolder() if foldername: liste=os.listdir(foldername) print '%i file(s) in selected folder' % (len(liste)) tbl_fsa=[] compteurfsa=0 for s in liste: if search('\.fsa', s): tbl_fsa.append(s) compteurfsa=compteurfsa+1 if compteurfsa==0: print "No fsa file found!" else: if compteurfsa==1: print "in which ", compteurfsa, "is a .fsa files!" else: print "in which ", compteurfsa, "are .fsa files!" try: os.mkdir(foldername+"\FSAconverted") except OSError: pass i=0 while i