<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://genome.sph.umich.edu/w/index.php?action=history&amp;feed=atom&amp;title=LiftRsNumber.py</id>
	<title>LiftRsNumber.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://genome.sph.umich.edu/w/index.php?action=history&amp;feed=atom&amp;title=LiftRsNumber.py"/>
	<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=LiftRsNumber.py&amp;action=history"/>
	<updated>2026-09-29T19:35:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=LiftRsNumber.py&amp;diff=3493&amp;oldid=prev</id>
		<title>Zhanxw at 15:33, 10 August 2011</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=LiftRsNumber.py&amp;diff=3493&amp;oldid=prev"/>
		<updated>2011-08-10T15:33:18Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:33, 10 August 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight &lt;/del&gt;lang=&quot;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;python&lt;/del&gt;&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source &lt;/ins&gt;lang=&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;php&lt;/ins&gt;&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#!/usr/bin/python&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#!/usr/bin/python&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import sys, os&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import sys, os&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l71&quot;&gt;Line 71:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 71:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		break&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		break&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Zhanxw</name></author>
	</entry>
	<entry>
		<id>http://genome.sph.umich.edu/w/index.php?title=LiftRsNumber.py&amp;diff=3492&amp;oldid=prev</id>
		<title>Zhanxw: Created page with &#039;&lt;syntaxhighlight lang=&quot;python&quot;&gt; #!/usr/bin/python import sys, os  def usage():     print(&quot;%s file: lift over rs number. &quot; % sys.argv[0] )     print(&quot;file should look like:&quot;)     …&#039;</title>
		<link rel="alternate" type="text/html" href="http://genome.sph.umich.edu/w/index.php?title=LiftRsNumber.py&amp;diff=3492&amp;oldid=prev"/>
		<updated>2011-08-10T15:31:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt; #!/usr/bin/python import sys, os  def usage():     print(&amp;quot;%s file: lift over rs number. &amp;quot; % sys.argv[0] )     print(&amp;quot;file should look like:&amp;quot;)     …&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/python&lt;br /&gt;
import sys, os&lt;br /&gt;
&lt;br /&gt;
def usage():&lt;br /&gt;
    print(&amp;quot;%s file: lift over rs number. &amp;quot; % sys.argv[0] )&lt;br /&gt;
    print(&amp;quot;file should look like:&amp;quot;)&lt;br /&gt;
    print(&amp;quot;11111&amp;quot;)&lt;br /&gt;
    print(&amp;quot;11112&amp;quot;)&lt;br /&gt;
    print(&amp;quot;...&amp;quot;)&lt;br /&gt;
def myopen(fn):&lt;br /&gt;
    import gzip&lt;br /&gt;
    try:&lt;br /&gt;
        h = gzip.open(fn)&lt;br /&gt;
        ln = h.read(2) # read arbitrary bytes so check if @param fn is a gzipped file&lt;br /&gt;
    except:&lt;br /&gt;
        # cannot read in gzip format&lt;br /&gt;
        return open(fn)&lt;br /&gt;
    h.close()&lt;br /&gt;
    return gzip.open(fn)&lt;br /&gt;
&lt;br /&gt;
RS_HISTORY = set() # store rs&lt;br /&gt;
RS_MERGE = dict() # high_rs -&amp;gt; (lower_rs, current_rs)&lt;br /&gt;
if __name__ == &amp;#039;__main__&amp;#039;:&lt;br /&gt;
    if len(sys.argv) != 2:&lt;br /&gt;
	usage()&lt;br /&gt;
	sys.exit(1)&lt;br /&gt;
	&lt;br /&gt;
    # record obsolete rs number&lt;br /&gt;
    for ln in myopen(&amp;#039;/net/wonderland/home/zhanxw/mydata/dbSNP/SNPHistory.bcp.gz&amp;#039;):&lt;br /&gt;
	fd = ln.strip().split(&amp;#039;\t&amp;#039;)&lt;br /&gt;
	if ln.find(&amp;#039;re-activ&amp;#039;) &amp;lt; 0:&lt;br /&gt;
	    RS_HISTORY.add(fd[0])&lt;br /&gt;
&lt;br /&gt;
    # record rs number merge history&lt;br /&gt;
    for ln in myopen(&amp;#039;/net/wonderland/home/zhanxw/mydata/dbSNP/RsMergeArch.bcp.gz&amp;#039;):&lt;br /&gt;
	fd = ln.strip().split(&amp;#039;\t&amp;#039;)&lt;br /&gt;
	h, l = fd[0], fd[1]&lt;br /&gt;
	c = fd[6]&lt;br /&gt;
	# print &amp;#039;c=&amp;#039;, c&lt;br /&gt;
	RS_MERGE[h] = (l, c)&lt;br /&gt;
&lt;br /&gt;
    # # find some retracted SNPs for fun&lt;br /&gt;
    # for h, v in RS_MERGE.iteritems():&lt;br /&gt;
    # 	l, c = v&lt;br /&gt;
    # 	if c in RS_HISTORY:&lt;br /&gt;
    # 	    print h, &amp;#039;-&amp;gt;&amp;#039;, l&lt;br /&gt;
&lt;br /&gt;
    import re&lt;br /&gt;
    rsPattern = re.compile(r&amp;#039;[0-9]*&amp;#039;)&lt;br /&gt;
    for ln in myopen(sys.argv[1]):&lt;br /&gt;
    	rs = ln.strip()&lt;br /&gt;
	if not rsPattern.match(rs):&lt;br /&gt;
	    print &amp;#039;ERROR: rs number should be like &amp;quot;1000&amp;quot;&amp;#039;&lt;br /&gt;
	    sys.exit(2)&lt;br /&gt;
	# rs number not appear in RS_MERGE -&amp;gt; there is no merge on this rs&lt;br /&gt;
	if rs not in RS_MERGE:&lt;br /&gt;
	    print &amp;quot;unchanged\t&amp;quot;, rs&lt;br /&gt;
	    continue&lt;br /&gt;
	# lift rs number&lt;br /&gt;
	while True:&lt;br /&gt;
	    if rs in RS_MERGE:&lt;br /&gt;
		rsLow, rsCurrent = RS_MERGE[rs]&lt;br /&gt;
		if rsCurrent not in RS_HISTORY:&lt;br /&gt;
		    print &amp;quot;lifted\t&amp;quot;, rsCurrent&lt;br /&gt;
		    break&lt;br /&gt;
		else:&lt;br /&gt;
		    rs = rsLow&lt;br /&gt;
	    else:&lt;br /&gt;
		print &amp;quot;unlifted\t&amp;quot;, rs&lt;br /&gt;
		break&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhanxw</name></author>
	</entry>
</feed>