Here's a quick GUI in python
#!/usr/bin/env python
import Tkinter, tkFileDialog
from Tkinter import *
from Bio import SeqIO
class App(object):
def __init__(self):
self.root = Tk()
self.root.wm_title("Format Fasta")
self.inp = StringVar(self.root)
Label(self.root, text = "\nPlease provide the FASTA file containing your sequences.").pack()
Button(self.root, text = "FASTA", command=lambda:self.inp.set(tkFileDialog.askopenfilename())).pack()
self.output = StringVar(self.root)
Label(self.root, text = "\nPlease enter a prefix for your output file.").pack()
Entry(self.root, textvariable=self.output).pack()
Label(self.root, text = "").pack()
self.request = StringVar(self.root)
Label(self.root, text = "\nPlease enter the min. length of a sequence to keep.").pack()
Entry(self.root, textvariable = self.request).pack()
Label(self.root, text = "").pack()
Label(self.root, text = "").pack()
Button(self.root, text = "Run", command = self.clickedrun).pack()
Button(self.root, text = "Exit", command = sys.exit).pack()
self.root.geometry("375x425")
self.root.mainloop()
def clickedrun(self):
length = self.request.get()
prefix = self.output.get()
Label(self.root, text = "\nTrimming sequences to first " + length + " bp..", fg='blue').pack()
inpfile = self.inp.get()
outfile = prefix + '.fasta'
with open(inpfile, 'rU') as f:
records = list(SeqIO.parse(f, "fasta"))
with open(outfile, 'w') as out:
for r in range(len(records)):
if len(records[r].seq) > length:
print >> out, '>' + records[r].id, '\n', records[r].seq
Label(self.root, text="\nDone!", fg='blue').pack()
App()
Copy/paste, save as Python file. Click the 'FASTA' button to provide the path to the input fasta. Then there are two entry fields, one for the output file prefix, and another for the desired minimum length. Click 'Run', and you will get a new file in the same directory as your input file.
Hi, welcome to Biostars.
In this forum, showing that one spent some time to search for a solution beforehand (what has been tried / which language...? ) is much appreciated. Moreover, whereas this request is quite clear, paying a bit attention to the form makes the forum easier and more pleasant to browse.
Feel free to edit your own question in order to fullfill these expectations. Thanks.