Remove SNPs with wrong alleles
<p>I have two files that look like this:</p>

<ol>
<li><p>The reference panel (<strong>ReferencePanel.csv</strong>)</p>

<blockquote>
<pre><code>"id","position","allele0","allele1","allele1_frequency"
"seq-rs1010355",55102179,"T","C",0.098
"seq-rs272408",55103603,"C","T",0.787
"seq-rs11669899",55104559,"A","T",0.029
"imm_19_59798585",55106773,"A","G",0.499
</code></pre>
</blockquote></li>
<li><p>A BIM file (<strong>myfile.bim</strong>)</p>

<blockquote>
<pre><code>19    19:55102179    0    55102179    C    T
19    19:55103603    0    55103603    C    T
19    19:55104559    0    55104559    G    C
19    19:55106773    0    55106773    A    T
</code></pre>
</blockquote></li>
</ol>

<p>I would like to <strong>delete</strong> in the BIM file all the rows where the two alleles are different from the reference panel. In other words, I would like to keep only the rows that have exactly the same alleles as the reference panel - the order does not matter.</p>

<p><strong>EXAMPLE</strong>:</p>

<p>Reference allele:</p>

<blockquote>
<pre><code>"seq-rs1010355",55102179,"T","C",0.098
"seq-rs272408",55103603,"C","T",0.787
"seq-rs11669899",55104559,"A","T",0.029
"imm_19_59798585",55106773,"A","G",0.499
</code></pre>
</blockquote>

<p>BIM file (myfile.bim)</p>

<blockquote>
<pre><code>19    19:55102179 0   55102179    C   T
19    19:55103603 0   55103603    C   T
19    19:55104559 0   55104559    G   C
19    19:55106773 0   55106773    A   T
</code></pre>
</blockquote>

<p>Keep only the following rows:</p>

<blockquote>
<pre><code>19    19:55102179 0   55102179    C   T
19    19:55103603 0   55103603    C   T
</code></pre>
</blockquote>

<p>I managed to extract all the positions from the reference panel using these lines:</p>

<pre><code>#Create an empty list 
positions=[]

#Populate list with positions 
for line in open("ReferencePanel.csv"):
    columns = line.split(",")
    positions.append(columns[1])
#Remove first element which corresponds to the header
positions.pop(0)
</code></pre>

<p>But I am stuck here. I hope someone can help me. 
Thank you in advance!</p>