Python function to read multiple FASTA files and merging them into one dictionar - (Nov/17/2012 )
Hi guys, I'm just throwing this function up here to see if there are any Python aces out there,
Any ideas why this collapses???
cheers!
import sys, pdb
def FASTAs_to_dict(files):
+"""Appends FASTA files given as arguments to a dictionary"""
+ID = ""
+SEQ = ""
+for seqfile in files: #goes through each sequence in Sequences
++sequences = open(seqfile, 'r')
++for line in sequences:
+++if line.startswith(">"): #> saves previous entry, set new ID, clears SEQ
++++if ID != "": #only makes entries for ID with values
+++++FASTA_dict
++++ID = line
++++SEQ = ""
+++else:
++++if line != "": #neccesary? ..does adding a "" string affect anything?
+++++SEQ += line
+return FASTA_dict
#main
FASTA_dict = {}
files=sys.argv<1:>
FASTAs_to_dict(files)
files.close
FASTA_dict = FASTAs_to_dict(files)
print FASTA_dict
Are you programming in Python or do you just need to concatenate several fasta files?