<p>Hi everyone; this is my first question on the forum.</p>

<p>How can I compare if two fasta files contain the same sequence headers?  </p>

<p>Does any BioPython module exist for doing this?</p>

<p>Thanks in advance,
peixe </p>

<p>In BioPython you could do the following:</p>
<pre><code>from Bio import SeqIO

def get_ids(fname):
    reader = SeqIO.parse(fname, 'fasta')
    ids = map(lambda x: x.id, reader)
    return set(ids)

s1 = get_ids('f1.fasta')
s2 = get_ids('f2.fasta')

print 'Common:', s1 &amp; s2
print 'In f1 and not f2:', s1 - s2
print 'In f2 and not f1:', s2 - s1
</code></pre>
<p>prints for my testcase:</p>
<pre><code>Common: set(['a', 'c', 'b'])
In f1 and not f2: set(['x'])
In f2 and not f1: set(['y'])
</code></pre>