Handling sequence files

To merge (concatenate) individual sequence files into one file:

cat *.seq > combined.seq

To reverse complement the sequences:
Save the code below as

from Bio.SeqRecord import SeqRecord

def make_rc_record(record):
"""Returns a new SeqRecord with the reverse complement sequence."""
return SeqRecord(seq = record.seq.reverse_complement(), \
id = "rc_" +, \
description = "reverse complement")

from Bio import SeqIO

# I added the following line:
filename = raw_input('Please give the file name: ')
in_handle = open(filename)

# in_handle = open(input('Enter an integer : '))
records = map(make_rc_record, SeqIO.parse(in_handle, "fasta"))

out_handle = open("rev_comp.fasta", "w")
SeqIO.write(records, out_handle, "fasta")

and run it in Pyhton. The script requires biopython installation. The script will ask you for the file name, hence it would be best to copy the merged file into the same folder where the python script file is residing.

Multiple alignment
It is getting old but I still like using the MultiAlin web page for alignments.
UPDATE: Rather use T-Coffee for multiple alignment.

Leave a Reply

Your email address will not be published. Required fields are marked *