<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>柳城 &#187; perl</title>
	<atom:link href="http://liucheng.name/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://liucheng.name</link>
	<description>_SEO&#124;摄影&#124;WordPress&#124;博客</description>
	<lastBuildDate>Tue, 31 Jan 2012 01:56:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>用Perl打印序列</title>
		<link>http://liucheng.name/1418/</link>
		<comments>http://liucheng.name/1418/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 02:04:39 +0000</pubDate>
		<dc:creator>柳城</dc:creator>
				<category><![CDATA[Biocompute]]></category>
		<category><![CDATA[length]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[strlen]]></category>

		<guid isPermaLink="false">http://liucheng.name/1418/</guid>
		<description><![CDATA[我也用perl玩玩，不怎么漂亮的打印序列。用php也神奇地相似。把perl的length函数换为php的strlen函数就得了。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="收到《Perl语言编程（第三版）》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F859%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1215716.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">收到《Perl语言编程（第三版）》</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速提取序列的Perl脚本" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1202%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速提取序列的Perl脚本</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl:FastQ与FastA格式的相互转换" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F868%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl:FastQ与FastA格式的相互转换</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Bioperl:获取序列数据" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F394%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Bioperl:获取序列数据</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chdir函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1101%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chdir函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>azalea用Python漂亮地打印<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/entrez/" title="序列" target="_blank">序列</a></span>：http://i.azpala.com/2010/07/15/print-sequence-beatifully-using-python/</p>
<p>我也用<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="perl">perl</a></span>玩玩，不怎么漂亮的打印序列。</p>
<p>代码写得不咋得。<span id="more-1418"></span></p>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>

$seq = 'ATGGAGCCTAATGATAGTACCAGTACCGCTGTGGAGGAGCCTGACAGCTTGGAGGTGTTGGTGAAGACCTTGGACTCTCAAACTCGTACCTTTATTGTGGGGGCCCAGATGAATGTAAAAGAGTTTAAGGAGCACATTGCTGCCTCTGTCAGCATCCCAT';

$step = 10;

$group = 5;

$count = 0;

for ($i=0; $i*$step&lt;<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/length/" title="查看 length 中的全部文章" target="_blank">length</a></span>($seq); $i++) {

    $count++;

    print substr($seq, $i*$step, $step);

    if ($count == $group){

        print "\n";

        $count = 0;

    }else{

       print " ";

    }

}</pre>
<p>结果：</p>
<pre>atggagccta atgatagtac cagtaccgct gtggaggagc ctgacagctt
ggaggtgttg gtgaagacct tggactctca aactcgtacc tttattgtgg
gggcccagat gaatgtaaaa gagtttaagg agcacattgc tgcctctgtc</pre>
<p>用php也神奇地相似。把perl的length函数换为php的<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/strlen/" title="查看 strlen 中的全部文章" target="_blank">strlen</a></span>函数就得了。</p>
<pre>&lt;?php

$seq = 'ATGGAGCCTAATGATAGTACCAGTACCGCTGTGGAGGAGCCTGACAGCTTGGAGGTGTTGGTGAAGACCTTGGACTCTCAAACTCGTACCTTTATTGTGGGGGCCCAGATGAATGTAAAAGAGTTTAAGGAGCACATTGCTGCCTCTGTCAGCATCCCAT';

$step = 10;

$group = 5;

$count = 0;

for ($i=0; $i*$step&lt;<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/strlen/" title="查看 strlen 中的全部文章" target="_blank">strlen</a></span>($seq); $i++) {

    $count++;

    print substr($seq, $i*$step, $step);

    if ($count == $group){

        print "\n";

        $count = 0;

    }else{

       print " ";

    }

}

?&gt;</pre>
<p>~完</p>
<div class="similarity"><h3>有点相关的文章</h3><ul><li><a href="http://liucheng.name/477/">如何用perl处理测序文件</a> (1.000)</li><li><a href="http://liucheng.name/496/">perl常用的内置特殊变量</a> (1.000)</li><li><a href="http://liucheng.name/497/">perl:使用system函数</a> (1.000)</li><li><a href="http://liucheng.name/786/">用Perl下载NCBI的Blast库（Blastdb）</a> (1.000)</li><li><a href="http://liucheng.name/849/">用Perl创建UTF-8的文件</a> (1.000)</li><li><a href="http://liucheng.name/872/">Perl:关于标准输出STDOUT和标准错误STDERR</a> (RANDOM - 0.500)</li></ul></div><!-- Mix --><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="收到《Perl语言编程（第三版）》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F859%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1215716.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">收到《Perl语言编程（第三版）》</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速提取序列的Perl脚本" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1202%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速提取序列的Perl脚本</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl:FastQ与FastA格式的相互转换" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F868%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl:FastQ与FastA格式的相互转换</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Bioperl:获取序列数据" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F394%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Bioperl:获取序列数据</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chdir函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1101%2F&from=http%3A%2F%2Fliucheng.name%2F1418%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chdir函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://liucheng.name/1418/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
		<item>
		<title>用perl统计一个六种类型的数据</title>
		<link>http://liucheng.name/1286/</link>
		<comments>http://liucheng.name/1286/#comments</comments>
		<pubDate>Sun, 09 May 2010 04:30:43 +0000</pubDate>
		<dc:creator>柳城</dc:creator>
				<category><![CDATA[数据分析]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[统计]]></category>

		<guid isPermaLink="false">http://liucheng.name/1286/</guid>
		<description><![CDATA[ rebecca 童鞋还是第一次问我数据处理的问题阿。其实我对这种问题是比较感兴趣的。同一个基因可能有几类转录因子的结合位点，因此，统计不同的情况。幸好最后还是想出了这样一个用hash来完成的办法。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Entrez所有数据库的最新数据统计" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F429%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1214796.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Entrez所有数据库的最新数据统计</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chdir函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1101%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chdir函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="收到《Perl语言编程（第三版）》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F859%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1215716.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">收到《Perl语言编程（第三版）》</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="perl:使用system函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F497%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">perl:使用system函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p> <a title="由 rebeccajiejie 发表" href="http://yunbio.com/author/rebeccajiejie/">rebecca</a> 童鞋还是第一次问我数据处理的问题阿。其实我对这种问题是比较感兴趣的。</p>
<p>数据是这样子的。<span id="more-1286"></span></p>
<h3>例子文件，只取了一小部分数据：get2_nr.out</h3>
<pre>ZM_BFa0062B01	bzip
ZM_BFa0063A16	bzip
ZM_BFa0063M13	myc
ZM_BFa0063N22	myc
ZM_BFa0063O17	bzip
ZM_BFa0066C13	myb
ZM_BFa0066F21	bzip
ZM_BFa0068F07	bzip
ZM_BFa0068F15	myb
ZM_BFa0068N18	myb
ZM_BFa0068P14	bzip
ZM_BFa0069B08	myb
ZM_BFa0070G13	myb
ZM_BFa0071G19	bzip
ZM_BFa0071G21	myb
ZM_BFa0072O19	bzip
ZM_BFa0073F20	myb
ZM_BFa0073F20	myc
ZM_BFa0073O09	myb
ZM_BFa0073O09	myc
ZM_BFa0078K13	dre
ZM_BFa0078M22	bzip
ZM_BFa0079N03	erf
ZM_BFa0079P04	erf
ZM_BFa0083F19	myb
ZM_BFa0086H17	myb
ZM_BFa0087C10	bzip
ZM_BFa0090M23	bzip
ZM_BFa0090M23	erf
ZM_BFa0090M23	myc
ZM_BFa0097N21	bzip
ZM_BFa0098A07	erf
ZM_BFb0001A15	bzip
ZM_BFb0001A21	abf
ZM_BFb0001A21	erf
ZM_BFb0001A22	bzip
ZM_BFb0001B09	bzip
ZM_BFb0001B09	erf
ZM_BFb0001B13	bzip</pre>
<h4>Rebecca给出的分析是这样子的：</h4>
<p>第一列是基因名称，第二列是转录因子</p>
<p>同一个基因可能有几类转录因子的结合位点，因此，<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/%e7%bb%9f%e8%ae%a1/" title="查看 统计 中的全部文章" target="_blank">统计</a></span>不同的情况</p>
<ul>
<li>1. 一个基因只有一个转录因子，且这个转录因子是bzip。同理，<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/%e7%bb%9f%e8%ae%a1/" title="查看 统计 中的全部文章" target="_blank">统计</a></span>，myb，myc，erf，abf，dre，6种情况</li>
<li>2. 一个基因有2个转录因子，那么就可能是6个中任意2个的组合，15种情况</li>
<li>3.一个基因上有3个转录因子，就是6个中任意三个，20种情况</li>
<li>4.一个基因上有4个转录因子，就是15种</li>
<li>5.一个基因上有5个转录因子，6种情况</li>
</ul>
<p>如果枚举的话，貌似太多了</p>
<p><strong>输出的结果是：直接的每种类型的基因个数就行了（即类型-》个数）</strong></p>
<h3>例子代码:temp.pl</h3>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="perl">perl</a></span>

while(&lt;&gt;){
	chop;
	($id,$type) = split("\t");
	chop($type);  #要用两次chop才能把换行符去掉。奇异。。(较旧的<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>版本可能得改为chomp($type);)
	$gene{$id} .= $type . "\t"; #丢给hash了
}

undef @arr;
foreach $id (sort keys %gene) {
	@type = sort(split("\t", $gene{$id})); #把type变为数组。用sort函数。避免不必要的重复
	$type = join("-",@type);
	push (@arr,$type); #再把所有的type丢进一个数组里
}

$hash{$_}++ for @arr; #从type的数组里统计重复和个数
print "$_\t$hash{$_}\n" for (keys %hash); #输出</pre>
<p>如果按Rebecca的思路枚举的话。的确是需要更加的代码来完成。</p>
<p>幸好最后还是想出了这样一个用hash来完成的办法。也算是可喜，最主要的参考还是  <span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>语言编程 里的一段代码。求平均值的。也有着类似的求解过程。</p>
<div class="similarity"><h3>有点相关的文章</h3><ul><li><a href="http://liucheng.name/1205/">Perl处理Fasta序列的又一实例</a> (0.535)</li><li><a href="http://liucheng.name/1236/">用Perl抓取网页和提交表格</a> (0.535)</li><li><a href="http://liucheng.name/1285/">用perl匹配字符串并返回该匹配的位置</a> (0.535)</li><li><a href="http://liucheng.name/935/">两种办法批量去掉重复数据</a> (0.500)</li><li><a href="http://liucheng.name/1055/">Linux下大文件的排序和去重复</a> (0.500)</li><li><a href="http://liucheng.name/1112/">Perl chmod函数</a> (RANDOM - 0.035)</li></ul></div><!-- Mix --><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Entrez所有数据库的最新数据统计" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F429%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1214796.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Entrez所有数据库的最新数据统计</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chdir函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1101%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chdir函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="收到《Perl语言编程（第三版）》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F859%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1215716.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">收到《Perl语言编程（第三版）》</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="perl:使用system函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F497%2F&from=http%3A%2F%2Fliucheng.name%2F1286%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">perl:使用system函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://liucheng.name/1286/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>用perl匹配字符串并返回该匹配的位置</title>
		<link>http://liucheng.name/1285/</link>
		<comments>http://liucheng.name/1285/#comments</comments>
		<pubDate>Sat, 08 May 2010 04:30:52 +0000</pubDate>
		<dc:creator>柳城</dc:creator>
				<category><![CDATA[数据分析]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[正则表达式]]></category>

		<guid isPermaLink="false">http://liucheng.name/1285/</guid>
		<description><![CDATA[这次讲讲perl里跟模式匹配或叫正则表达式有关的东西。比如说，给出一个序列文件，里面都是Fasta格式的序列。 然后序列里面有一些NNNNNN的连续字符。问题就是要得出这些NNNN的一段字符在该序列的具体位置。就是匹配某字符串。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="收到《Perl语言编程（第三版）》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F859%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1215716.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">收到《Perl语言编程（第三版）》</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="PHP 正则表达式" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F115%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PHP 正则表达式</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl grep函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1251%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl grep函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl abs函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F998%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl abs函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>这次讲讲<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="perl">perl</a></span>里跟模式匹配或叫<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/regular-expression/" title="查看 正则表达式 中的全部文章" target="_blank">正则表达式</a></span>有关的东西。</p>
<p>最近 <a title="由 ghxiao 发表" href="http://yunbio.com/author/ghxiao/">ghxiao</a> 童鞋常常问我用<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>处理数据的问题。今天来分享一段代码吧。</p>
<p>比如说，给出一个<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/entrez/" title="序列" target="_blank">序列</a></span>文件，里面都是<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/770/" title="Fasta" target="_blank">Fasta</a></span>格式的序列。 然后序列里面有一些NNNNNN的连续字符。</p>
<p>问题就是要得出这些NNNN的一段字符在该序列的具体位置。（就是匹配某字符串）<span id="more-1285"></span></p>
<h3>例子文件：seq.fasta</h3>
<pre>&gt;CMM_00532
CGCGCGCTGTGCTACGCAGGCCTCTTCCAGGCCCATCTCCCGGCGGCGTGCACCACTACC
AGGATGGTGTGCGTGGGCGGGGGCGCCGCCGAGCTGGTCGCCTTTGCCAGCTTCTTGGGC
GACGACGACGACGACGACGGGGCGCACAGCAGCAGGCGCGGGGAGCTGACGCTNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGGTCGACGCGGCGCCGTGGGAGGGCGT
CGCGGACACGGTGCTGCGCGCGCTCACGACGCCGCTGCCGCTGTCCCCAGTCCGGAGCAG
&gt;CMM_00589
ACGGGCGTGTTCCTGGCGTACGGCGGCAGCGACGATGCGCTGCCGGAGGCGGGCCTCGCG
GTGCGCATGAACGACGGGCCTTCGGGCCCTGCGTTTTGGCCGCAGCCGCGCCTGCGGCTC
ATGGAGATGCTGCTGCCGTACCTCGACCAGCACCGCTTCGCGGCCGGCGATATNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGCCTGGCATCTGCGGCAGCAGTGGGAC
GTGCCGCGGACGCACGCGTACTACGTGCCGCCCGGCGCCGTGCGGACGGCCGCGCCGCTG
CTGCTCATGGCGGCGACGCGCGACCCCGTGACGCCGTATGCGGCGGCGCGCGCGGCGCTC
&gt;CMM_00662
GCCGTACTCTCCCAGAACGACTTGGCCTCTGCCCGTACCCTCTTTAAAGACAACCTCAAC
CTGACGCCCTATATTGCCTCGACCGAGTGCAGCGGCGTGTGGGCGCGCCGNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGGGCCGCCGGACGAGGAGCGCGGCATGGTC
GAGGTCGGGTACGGGATCGACCCGGCGTGCCGGCGGCGGGGACACGCGCGGGCGGCGCTG
&gt;CMM_00942
CTCAACCTGCGCGACGCCGGCGCCGTGGCGGGCAGCGCGATCCCCGCCGGGCGCGTGTAC
CGCTGCGGCACGCTCGAGTACGCGGCCGCCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNCTCGCCGACTTTGCCGAGGCCGGGGCGTCGCCGCCTGGCGCACGCAGTAC
CTCCACGTCGCGCTGGCGTATGCGCCCACGTTCCGCGCCGTCCTGGAGCATGTGCGCGAC</pre>
<p>只取了一小部分数据。</p>
<h4>分析：</h4>
<ul>
<li>1，CMM_开头的是该序列的ID<br />
2，序列有几行。所以要去掉换行符，先变成一行。这样才能得出正确的位置。</li>
</ul>
<h3>代码例子：temp.pl</h3>
<pre>$/ = "&gt;";

print "id\tstart\tend\tlen\n";  #先输出Title
while(&lt;&gt;){
	if($_ =~ /(CMM.*?)\s(.*)&gt;/ms){ #第一个括号匹配ID。第二个匹配序列
		$id = $1;
		$seq = $2;
		$seq =~ s/\s//g; #把序列里的换行去掉。变成一列
		while ($seq =~ m/(N+)/g) { #匹配一个N或以上的字符
			$len = length($1); #返回这段匹配的长度
			$end = pos($seq); #用pos函数返回该匹配的终止位置
			$start = $end - $len + 1; #计算出起始位置
			print "$id\t$start\t$end\t$len\n"; #输出结果
		}
	}
}</pre>
<pre>运行 <span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span> temp.pl seq.fasta &gt;output</pre>
<p>输出output文件。</p>
<p>~完。</p>
<div class="similarity"><h3>有点相关的文章</h3><ul><li><a href="http://liucheng.name/1205/">Perl处理Fasta序列的又一实例</a> (0.535)</li><li><a href="http://liucheng.name/1236/">用Perl抓取网页和提交表格</a> (0.535)</li><li><a href="http://liucheng.name/1286/">用perl统计一个六种类型的数据</a> (0.535)</li><li><a href="http://liucheng.name/935/">两种办法批量去掉重复数据</a> (0.500)</li><li><a href="http://liucheng.name/1055/">Linux下大文件的排序和去重复</a> (0.500)</li><li><a href="http://liucheng.name/868/">Perl:FastQ与FastA格式的相互转换</a> (RANDOM - 0.035)</li></ul></div><!-- Mix --><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="收到《Perl语言编程（第三版）》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F859%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1215716.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">收到《Perl语言编程（第三版）》</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="PHP 正则表达式" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F115%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">PHP 正则表达式</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl grep函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1251%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl grep函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl abs函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F998%2F&from=http%3A%2F%2Fliucheng.name%2F1285%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl abs函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://liucheng.name/1285/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Perl grep函数</title>
		<link>http://liucheng.name/1251/</link>
		<comments>http://liucheng.name/1251/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 04:21:46 +0000</pubDate>
		<dc:creator>柳城</dc:creator>
				<category><![CDATA[Biocompute]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://liucheng.name/1251/</guid>
		<description><![CDATA[Perl grep函数从LIST中提取符合EXPR的值。grep函数是比较常用，也比较好用的一个函数。我在shell里是经常用grep的。Perl grep函数在标量环境中，返回为真的次数。在列表环境中，返回EXPR为真的元素的列表。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl abs函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F998%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl abs函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl 5.10版的新特性与下载" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F867%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl 5.10版的新特性与下载</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chomp函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1113%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chomp函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl处理Fasta序列的又一实例" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1205%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl处理Fasta序列的又一实例</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>学习<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="Perl" target="_blank">Perl</a></span>语言编程中……</p>
<h3>介绍:</h3>
<pre><strong><span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/grep/" title="查看 grep 中的全部文章" target="_blank">grep</a></span> (EXPR, LIST)</strong></pre>
<p>Perl grep函数从LIST中提取符合EXPR的值。grep函数是比较常用，也比较好用的一个函数。我在shell里是经常用grep的。Perl grep函数在标量环境中，返回为真的次数。在列表环境中，返回EXPR为真的元素的列表。<span id="more-1251"></span></p>
<h3>例子：</h3>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="perl">perl</a></span>

@list = (1,"Test", 0, "foo", 20 );

@has_digit = grep ( /\d/, @list );

print "@has_digit\n";

结果如下：

1 0 20</pre>
<p>再来，抓取非真的元素：</p>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>

@list = (1,"Test", 0, "foo", 20 );

@has_digit = grep ( !/\d/, @list );  #!非真

print "@has_digit\n";

结果如下：

Test foo</pre>
<p><strong>试一下在标量环境下返回的结果：</strong></p>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>

@list = (1,"Test", 0, "foo", 20 );

$has_digit = grep ( /\d/, @list );

print "$has_digit\n";

结果如下：

3  # 输出次数</pre>
<p>Perl grep函数 完~</p>
<div class="similarity"><h3>有点相关的文章</h3><ul><li><a href="http://liucheng.name/477/">如何用perl处理测序文件</a> (1.000)</li><li><a href="http://liucheng.name/496/">perl常用的内置特殊变量</a> (1.000)</li><li><a href="http://liucheng.name/497/">perl:使用system函数</a> (1.000)</li><li><a href="http://liucheng.name/786/">用Perl下载NCBI的Blast库（Blastdb）</a> (1.000)</li><li><a href="http://liucheng.name/849/">用Perl创建UTF-8的文件</a> (1.000)</li><li><a href="http://liucheng.name/1113/">Perl chomp函数</a> (RANDOM - 0.500)</li></ul></div><!-- Mix --><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl abs函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F998%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl abs函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl 5.10版的新特性与下载" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F867%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl 5.10版的新特性与下载</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chomp函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1113%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chomp函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl处理Fasta序列的又一实例" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1205%2F&from=http%3A%2F%2Fliucheng.name%2F1251%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl处理Fasta序列的又一实例</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://liucheng.name/1251/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>用Perl抓取网页和提交表格</title>
		<link>http://liucheng.name/1236/</link>
		<comments>http://liucheng.name/1236/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 06:20:24 +0000</pubDate>
		<dc:creator>柳城</dc:creator>
				<category><![CDATA[数据分析]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://liucheng.name/?p=1236</guid>
		<description><![CDATA[这里简单介绍一下用Perl来实现抓好取网页的源代码，以及用POST的方法来提交表格，并返回结果。难的讲不来，讲讲简单的。use LWP::Simple;use LWP::UserAgent;
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="收到《Perl语言编程（第三版）》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F859%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1215716.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">收到《Perl语言编程（第三版）》</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chmod函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1112%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chmod函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="perl:使用system函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F497%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">perl:使用system函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chdir函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1101%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chdir函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl处理Fasta序列的又一实例" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1205%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl处理Fasta序列的又一实例</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>这里简单介绍一下用<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="Perl" target="_blank">Perl</a></span>来实现抓好取网页的源代码，以及用POST的方法来提交表格，并返回结果。难的讲不来，讲讲简单的。</p>
<p>这里讲到的Perl模块有：</p>
<pre>use LWP::Simple;</pre>
<pre>use LWP::UserAgent;</pre>
<p>用<strong><span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>doc</strong>查看详细的用法。<span id="more-1236"></span></p>
<h3>1，用<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="perl">perl</a></span>抓取网页</h3>
<p>如果只是要拿到某个网页，那使用 LWP::Simple 里的函数是最简单的。通过调用<strong> get($url) </strong>函数，就可以得到相关网址的内容。</p>
<pre>my $url = 'http://freshair.npr.org/dayFA.cfm?todayDate=current'

use LWP::Simple;
my $content = get $url;
die "Couldn't get $url" unless defined $content;

#  $content 里是网页内容，下面是对此内容作些分析：

if($content =~ m/jazz/i) {
print "They're talking about jazz today on Fresh Air!\n";
} else {
print "Fresh Air is apparently jazzless today.\n";
}</pre>
<p>非常简单易懂。拿网页内容是容易的，难的是用正则过滤需要的内容。</p>
<h3>2，通过 POST提交表格</h3>
<p>部分HTML表格使用HTML POST 向服务器提交数据，在这里你可以这样：</p>
<pre>$response = $browser-&gt;post( $url,
   [
     formkey1 =&gt; value1,
     formkey2 =&gt; value2,
     ...
   ],
 );</pre>
<p>实例分析：例如在(<a href="http://www.enzim.hu/hmmtop/html/submit.html">http://www.enzim.hu/hmmtop/html/submit.html</a>)提交一段<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/entrez/" title="序列" target="_blank">序列</a></span>并返回结果，用<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>来实现。代码如下：</p>
<pre>#!/usr/bin/perl

use LWP::UserAgent;
my $browser = LWP::UserAgent-&gt;new;
$protein = "MSSSTPFDPYALSEHDEERPQNVQSKSRTAELQAEIDDTVGIMRDNINKVAERGERLTSI";
my $SUSUI_URL = "http://www.enzim.hu/hmmtop/server/hmmtop.cgi";
my $response = $browser-&gt;post( $SUSUI_URL,    [ 'if' =&gt; $protein, ]  );

if ($response-&gt;is_success) {
	print $response-&gt;content;
} else {
	print "Bad luck this time\n";
}</pre>
<p>通过分析<a href="http://www.enzim.hu/hmmtop/html/submit.html">http://www.enzim.hu/hmmtop/html/submit.html</a>的页面可知，这个要提交的input只有一个，就是<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/" title="柳城">name</a></span>="if"。$protein就是要提交的序列。$response-&gt;content就是返回结果。</p>
<div class="similarity"><h3>有点相关的文章</h3><ul><li><a href="http://liucheng.name/1205/">Perl处理Fasta序列的又一实例</a> (1.000)</li><li><a href="http://liucheng.name/1285/">用perl匹配字符串并返回该匹配的位置</a> (1.000)</li><li><a href="http://liucheng.name/1286/">用perl统计一个六种类型的数据</a> (1.000)</li><li><a href="http://liucheng.name/477/">如何用perl处理测序文件</a> (0.500)</li><li><a href="http://liucheng.name/496/">perl常用的内置特殊变量</a> (0.500)</li><li><a href="http://liucheng.name/1153/">Perl chr函数</a> (RANDOM - 0.500)</li></ul></div><!-- Mix --><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="收到《Perl语言编程（第三版）》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F859%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2010/12/10/1215716.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">收到《Perl语言编程（第三版）》</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chmod函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1112%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chmod函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="perl:使用system函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F497%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">perl:使用system函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chdir函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1101%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chdir函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl处理Fasta序列的又一实例" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1205%2F&from=http%3A%2F%2Fliucheng.name%2F1236%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl处理Fasta序列的又一实例</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://liucheng.name/1236/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Perl split函数</title>
		<link>http://liucheng.name/1218/</link>
		<comments>http://liucheng.name/1218/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 05:22:56 +0000</pubDate>
		<dc:creator>柳城</dc:creator>
				<category><![CDATA[Biocompute]]></category>
		<category><![CDATA[explode]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[split]]></category>

		<guid isPermaLink="false">http://liucheng.name/?p=1218</guid>
		<description><![CDATA[Perl split函数扫描字符串中EXPR给出的分隔符，并把该字符串劈成一个子字符串列表。简单地意思就是把字符串，按照PATTERN里的分隔符来分隔，返回一个数组。Perl split函数相当于PHP的explode函数。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Perl chomp函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1113%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chomp函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chop函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1116%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chop函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用perl统计一个六种类型的数据" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1286%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用perl统计一个六种类型的数据</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl:用File::Basename来获取文件名" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F851%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl:用File::Basename来获取文件名</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>学习<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="Perl" target="_blank">Perl</a></span>语言编程中……</p>
<h3>介绍:</h3>
<p><strong><span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/split/" title="查看 split 中的全部文章" target="_blank">split</a></span> /PATTERN/, EXPR</strong><br />
<strong>split /PATTERN/</strong><br />
<strong>split</strong></p>
<p><strong></strong>Perl split函数扫描字符串中EXPR给出的分隔符，并把该字符串劈成一个子字符串列表。简单地意思就是把字符串，按照/PATTERN/里的分隔符来分隔，返回一个数组。/PATTERN/可以是分隔符（逗号空格等），也可以是正则表达式。<span id="more-1218"></span></p>
<p>如果后面指定LIMIT，如：</p>
<p><strong>split /PATTERN/, EXPR, LIMIT</strong></p>
<p>LIMIT参数只分裂字符串的一部分。Perl split函数相当于PHP的<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/explode/" title="查看 explode 中的全部文章" target="_blank">explode</a></span>函数。</p>
<h3>例子Example</h3>
<p><em><strong>例如试试下面的例子：</strong></em></p>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="perl">perl</a></span> -w

@fields = split(/:/, "1:2:3:4:5");
print "Field values are: @fields\n";

#It will produce following result:
#Field values are: 1 2 3 4 5</pre>
<p>Perl split函数是非常常用的一个函数。</p>
<p><em><strong>一个更加酷的例子如下：</strong></em>把字符串分割为独立的字符。</p>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span> -w

print join ':', split / */, 'hi there';

#result:
#h:i:t:h:e:r:e</pre>
<p>Perl split函数完。</p>
<div class="similarity"><h3>有点相关的文章</h3><ul><li><a href="http://liucheng.name/477/">如何用perl处理测序文件</a> (1.000)</li><li><a href="http://liucheng.name/496/">perl常用的内置特殊变量</a> (1.000)</li><li><a href="http://liucheng.name/497/">perl:使用system函数</a> (1.000)</li><li><a href="http://liucheng.name/786/">用Perl下载NCBI的Blast库（Blastdb）</a> (1.000)</li><li><a href="http://liucheng.name/849/">用Perl创建UTF-8的文件</a> (1.000)</li><li><a href="http://liucheng.name/935/">两种办法批量去掉重复数据</a> (RANDOM - 0.500)</li></ul></div><!-- Mix --><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Perl chomp函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1113%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chomp函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl chop函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1116%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl chop函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用perl统计一个六种类型的数据" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1286%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用perl统计一个六种类型的数据</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl:用File::Basename来获取文件名" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F851%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl:用File::Basename来获取文件名</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1218%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://liucheng.name/1218/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Perl处理Fasta序列的又一实例</title>
		<link>http://liucheng.name/1205/</link>
		<comments>http://liucheng.name/1205/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 01:41:12 +0000</pubDate>
		<dc:creator>柳城</dc:creator>
				<category><![CDATA[数据分析]]></category>
		<category><![CDATA[Fasta]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://liucheng.name/?p=1205</guid>
		<description><![CDATA[今天再来分享一小段Perl脚本，其实是比较简单的。主要是用来处理Fasta格式的序列。分割fasta文件的perl脚本，我需要把一个fasta文件按两条序列一组分成若干个fasta文件。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Perl:FastQ与FastA格式的相互转换" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F868%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl:FastQ与FastA格式的相互转换</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速提取序列的Perl脚本" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1202%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速提取序列的Perl脚本</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何用perl处理测序文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F477%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何用perl处理测序文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Fasta格式的详细说明" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F770%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Fasta格式的详细说明</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl abs函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F998%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl abs函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>今天再来分享一小段<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="Perl" target="_blank">Perl</a></span>脚本，其实是比较简单的。主要是用来处理<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/770/" title="Fasta" target="_blank">Fasta</a></span>格式的<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/entrez/" title="序列" target="_blank">序列</a></span>。</p>
<h4>网友niche Says:</h4>
<blockquote><p>你好，你有没有分割fasta文件的<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="perl">perl</a></span>脚本，我需要把一个fasta文件按两条序列一组分成若干个fasta文件，谢谢！</p></blockquote>
<p>如果不懂fasta文件，可以再看一下<strong>解释</strong>：<span id="more-1205"></span><br />
或是查看: <a href="http://liucheng.name/770/" target="_blank">Fasta格式的详细说明</a></p>
<pre>&gt;cel-miR-1 MIMAT0000003 Caenorhabditis elegans miR-1
UGGAAUGUAAAGAAGUAUGUA
&gt;cel-miR-2 MIMAT0000004 Caenorhabditis elegans miR-2
UAUCACAGCCAGCUUUGAUGUGCUAUCACAGCCAGCUUUG
UAUCACAGCCAGCUUUGAUGUGC
……</pre>
<p>其中标识符就是大于号'&gt;'。按两个为一组分成若干个文件。大意上是这样。</p>
<h3>分割fasta文件</h3>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>

#fasta2.pl
#Usage:<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span> fasta2.pl in_fasta out_file

open(IN,"&lt;$ARGV[0]");
$i = 0;
$j = 1;
while(&lt;IN&gt;){
    if(/^&gt;/){
        $i++;
    }
    if($i == 3){
        $j++;
        $i = 1;
    }
    open(OUT,"&gt;&gt;$ARGV[1]_$j");
    print OUT $_;
}</pre>
<p><strong>注：</strong> in_fasta是指要处理的fasta文件。</p>
<p>           out_file是指输出的文件。（如命名为out, 则生成的文件名为out_1, out_2, out_3等）</p>
<p>主要是利用循环嘛，第一步是按大于号'&gt;'来统计个数。再用$j来循环输出文件名。</p>
<div class="similarity"><h3>有点相关的文章</h3><ul><li><a href="http://liucheng.name/1236/">用Perl抓取网页和提交表格</a> (0.565)</li><li><a href="http://liucheng.name/1285/">用perl匹配字符串并返回该匹配的位置</a> (0.565)</li><li><a href="http://liucheng.name/1286/">用perl统计一个六种类型的数据</a> (0.565)</li><li><a href="http://liucheng.name/868/">Perl:FastQ与FastA格式的相互转换</a> (0.500)</li><li><a href="http://liucheng.name/935/">两种办法批量去掉重复数据</a> (0.500)</li><li><a href="http://liucheng.name/850/">有着一千七百多万个url的sitemap文件 </a> (RANDOM - 0.065)</li></ul></div><!-- Mix --><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Perl:FastQ与FastA格式的相互转换" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F868%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl:FastQ与FastA格式的相互转换</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速提取序列的Perl脚本" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1202%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速提取序列的Perl脚本</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何用perl处理测序文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F477%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何用perl处理测序文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Fasta格式的详细说明" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F770%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Fasta格式的详细说明</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl abs函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F998%2F&from=http%3A%2F%2Fliucheng.name%2F1205%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl abs函数</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://liucheng.name/1205/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>快速提取序列的Perl脚本</title>
		<link>http://liucheng.name/1202/</link>
		<comments>http://liucheng.name/1202/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 06:05:17 +0000</pubDate>
		<dc:creator>柳城</dc:creator>
				<category><![CDATA[Biocompute]]></category>
		<category><![CDATA[Fasta]]></category>
		<category><![CDATA[GenBank]]></category>
		<category><![CDATA[miRbase]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://liucheng.name/?p=1202</guid>
		<description><![CDATA[有接触过miRbase数据库的.....这样就实现了从Fasta格式的文件中提取序列的目的，如果你再稍微改改，类似GenBank格式的也是可以提取的。还有好多，只要有唯一分隔符的都可以，不一一列出。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Perl处理Fasta序列的又一实例" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1205%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl处理Fasta序列的又一实例</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用Perl打印序列" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1418%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl打印序列</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl:FastQ与FastA格式的相互转换" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F868%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl:FastQ与FastA格式的相互转换</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何用perl处理测序文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F477%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何用perl处理测序文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>是这么回事的，整理一下一些有用的提问。感谢大家的提问。</p>
<h3>网友sun：</h3>
<blockquote><p>我从<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/mirbase/" title="查看 miRbase 中的全部文章" target="_blank">miRbase</a></span>数据库下载到了,matrue.fa,即里面有测出来的物种的成熟miRNA,里面有human 我想用<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="perl">perl</a></span>把human的提出来另外存到一个文件.这是其中人的一条的<br />
&gt;hsa-miR-96 MIMAT0000095 Homo sapiens miR-96<br />
UUUGGCACUAGCACAUUUUUGCU<br />
怎么把所有的都提出来.<br />
ps:正则表达式不是这个$s=~/^&gt;hsa/期待你的回信.</p></blockquote>
<p><span id="more-1202"></span>有接触过miRbase数据库的，都知道miRNA的命名Human是用hsa开头，Mouse是用mmu开头，Rat是用rno开头。</p>
<h3>解释一下</h3>
<p>忘了大伙对<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/770/" title="Fasta" target="_blank">Fasta</a></span>格式可能有不明白的，我来稍微解释一下上面的话。比如有一个文件：matrue.fa。里面存放的内容的格式是这样子的：</p>
<pre>&gt;hsa-miR-96
UUUGGCACUAGCACAUUUUUGCU
&gt;mmu-miR-96
AAAGGCACUAGCACUCGAUCGA
&gt;rno-miR-85
UAGUCUGCAUGUUGCACAGUGUA</pre>
<p>上面只是举一个为例子，数据都是批量的。想要取出以hsa命名开头的数据，取出来的结果是：</p>
<pre>&gt;hsa-miR-96
UUUGGCACUAGCACAUUUUUGCU
……</pre>
<p> </p>
<p>这样子就有了下面的<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="Perl" target="_blank">Perl</a></span>脚本：</p>
<h3>提取<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/fasta/" title="查看 Fasta 中的全部文章" target="_blank">Fasta</a></span><span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/entrez/" title="序列" target="_blank">序列</a></span>的Perl脚本</h3>
<pre>#!/usr/bin/<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/perl/" title="查看 perl 中的全部文章" target="_blank">perl</a></span>
$/ = '&gt;';
print '&gt;';

while(&lt;&gt;){
    print if(/hsa-/);
}</pre>
<p>这样就实现了从Fasta格式的文件中提取序列的目的，如果你再稍微改改，类似<span class='wp_keywordlink_affiliate'><a href="http://liucheng.name/tag/genbank/" title="查看 GenBank 中的全部文章" target="_blank">GenBank</a></span>格式的也是可以提取的。还有好多，只要有唯一分隔符的都可以，不一一列出。</p>
<h4>提醒一下：</h4>
<pre>$/ = '&gt;';</pre>
<p>强大之处是用了这句，自行慢慢体会。</p>
<div class="similarity"><h3>有点相关的文章</h3><ul><li><a href="http://liucheng.name/868/">Perl:FastQ与FastA格式的相互转换</a> (0.849)</li><li><a href="http://liucheng.name/531/">Bioperl:把Genbank格式的序列转换为基因结构图</a> (0.652)</li><li><a href="http://liucheng.name/477/">如何用perl处理测序文件</a> (0.545)</li><li><a href="http://liucheng.name/496/">perl常用的内置特殊变量</a> (0.545)</li><li><a href="http://liucheng.name/497/">perl:使用system函数</a> (0.545)</li><li><a href="http://liucheng.name/567/">如何用COBALT构建本地的多序列比对（Linux系统）</a> (RANDOM - 0.500)</li></ul></div><!-- Mix --><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Perl处理Fasta序列的又一实例" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1205%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl处理Fasta序列的又一实例</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用Perl打印序列" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1418%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl打印序列</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Perl:FastQ与FastA格式的相互转换" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F868%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Perl:FastQ与FastA格式的相互转换</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="如何用perl处理测序文件" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F477%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">如何用perl处理测序文件</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="用Perl抓取网页和提交表格" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fliucheng.name%2F1236%2F&from=http%3A%2F%2Fliucheng.name%2F1202%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">用Perl抓取网页和提交表格</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://liucheng.name/1202/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

