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] = SEQ
++++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
Python function to read multiple FASTA files and merging them into one dictionar
Started by mordiano, Nov 17 2012 03:44 AM
Python
No replies to this topic
#1
Posted 17 November 2012 - 03:44 AM













