<?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>小生这厢有礼了(BioFaceBook Personal Blog) &#187; perl</title>
	<atom:link href="https://www.biofacebook.com/?feed=rss2&#038;tag=perl" rel="self" type="application/rss+xml" />
	<link>https://www.biofacebook.com</link>
	<description>记录生物信息学点滴足迹（NGS,Genome,Meta,Linux)</description>
	<lastBuildDate>Sun, 23 Aug 2020 03:28:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Merging separate sequence and quality files to FASTQ</title>
		<link>https://www.biofacebook.com/?p=245</link>
		<comments>https://www.biofacebook.com/?p=245#comments</comments>
		<pubDate>Thu, 07 Jun 2012 06:51:29 +0000</pubDate>
		<dc:creator><![CDATA[szypanther]]></dc:creator>
				<category><![CDATA[二代测序]]></category>
		<category><![CDATA[脚本语言]]></category>
		<category><![CDATA[NGS]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.biofacebook.com/?p=245</guid>
		<description><![CDATA[#!/usr/bin/perl -w use strict; use Bio::SeqIO; use Bio::Seq::Quality; use Getopt::Long; die "pass a fasta and a fasta-quality file\n" unless @ARGV; my ($seq_infile,$qual_infile) = (scalar @ARGV == 1) ?($ARGV[0], "$ARGV[0].qual") : @ARGV; ## Create input objects for both a seq (fasta) and qual file my $in_seq_obj = Bio::SeqIO-&#62;new( -file =&#62; $seq_infile, -format =&#62; 'fasta', ); my [...]]]></description>
				<content:encoded><![CDATA[<pre>#!/usr/bin/perl -w

use strict;

use Bio::SeqIO;
use Bio::Seq::Quality;

use Getopt::Long;

<a href="http://perldoc.perl.org/functions/die.html">die</a> "pass a fasta and a fasta-quality file\n"
  unless @ARGV;

my ($seq_infile,$qual_infile)
  = (<a href="http://perldoc.perl.org/functions/scalar.html">scalar</a> @ARGV == 1) ?($ARGV[0], "$ARGV[0].qual") : @ARGV;

## Create input objects for both a seq (fasta) and qual file

my $in_seq_obj =
  Bio::SeqIO-&gt;new( -file   =&gt; $seq_infile,
		   -<a href="http://perldoc.perl.org/functions/format.html">format</a> =&gt; 'fasta',
		 );

my $in_qual_obj =
  Bio::SeqIO-&gt;new( -file   =&gt; $qual_infile,
		   -<a href="http://perldoc.perl.org/functions/format.html">format</a> =&gt; 'qual',
		 );

my $out_fastq_obj =
  Bio::SeqIO-&gt;new( -<a href="http://perldoc.perl.org/functions/format.html">format</a> =&gt; 'fastq'
		 );

while (1){
  ## create objects for both a seq and its associated qual
  my $seq_obj  = $in_seq_obj-&gt;next_seq || last;
  my $qual_obj = $in_qual_obj-&gt;next_seq;

  <a href="http://perldoc.perl.org/functions/die.html">die</a> "foo!\n"
    unless
      $seq_obj-&gt;id eq
	$qual_obj-&gt;id;

  ## Here we use seq and qual object methods feed info for new BSQ
  ## object.
  my $bsq_obj =
    Bio::Seq::Quality-&gt;
	new( -id   =&gt; $seq_obj-&gt;id,
	     -seq  =&gt; $seq_obj-&gt;seq,
	     -qual =&gt; $qual_obj-&gt;qual,
	   );

  ## and print it out.
  $out_fastq_obj-&gt;write_fastq($bsq_obj);
}</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.biofacebook.com/?feed=rss2&#038;p=245</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting FASTQ to FASTA QUAL files</title>
		<link>https://www.biofacebook.com/?p=243</link>
		<comments>https://www.biofacebook.com/?p=243#comments</comments>
		<pubDate>Thu, 07 Jun 2012 06:48:57 +0000</pubDate>
		<dc:creator><![CDATA[szypanther]]></dc:creator>
				<category><![CDATA[二代测序]]></category>
		<category><![CDATA[脚本语言]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.biofacebook.com/?p=243</guid>
		<description><![CDATA[#!/usr/bin/env perl # Convert a fastq to a fasta/qual combo using BioPerl, with some Linux commands use Bio::Perl; use Data::Dumper; use strict; use warnings; use threads; use Thread::Queue; use Getopt::Long; my $settings={}; $&#124;=1; my %numSequences; # static for a subroutine exit(main()); sub main{ die("Usage: $0 -i inputFastqFile [-n numCpus -q outputQualfile -f outputFastaFile]") if(@ARGV&#60;1); GetOptions($settings,('numCpus=s','input=s','qualOut=s','fastaOut=s')); [...]]]></description>
				<content:encoded><![CDATA[<pre>#!/usr/bin/env perl

# Convert a fastq to a fasta/qual combo using BioPerl, with some Linux commands

use Bio::Perl;
use Data::Dumper;
use strict;
use warnings;
use threads;
use Thread::Queue;
use Getopt::Long;

my $settings={};

$|=1;
my %numSequences; # static for a subroutine

<a href="http://perldoc.perl.org/functions/exit.html">exit</a>(main());

sub main{
  <a href="http://perldoc.perl.org/functions/die.html">die</a>("Usage: $0 -i inputFastqFile [-n numCpus -q outputQualfile -f outputFastaFile]") if(@ARGV&lt;1);

  GetOptions($settings,('numCpus=s','input=s','qualOut=s','fastaOut=s'));

  my $file=$$settings{input}||die("input parameter missing");
  my $outfasta=$$settings{fastaOut}||"$file.fasta";
  my $outqual=$$settings{qualOut}||"$file.qual";
  my $numCpus=$$settings{numCpus}||1;

  my @subfile=splitFastq($file,$numCpus);
  for my $f(@subfile){
    threads-&gt;create(\&amp;convert,$f,"$f.fasta","$f.qual");
  }
  $_-&gt;join for (threads-&gt;list);
  # join the sub files together
  joinFastqFiles(\@subfile,$file);

  <a href="http://perldoc.perl.org/functions/return.html">return</a> 0;
}

sub convert{
  my($file,$outfasta,$outqual)=@_;

  my $numSequences=numSequences($file);
  my $reportEvery=<a href="http://perldoc.perl.org/functions/int.html">int</a>($numSequences/100) || 1;
  <a href="http://perldoc.perl.org/functions/print.html">print</a> "$numSequences sequences to convert in $file\n";

  my $in=Bio::SeqIO-&gt;new(-file=&gt;$file,-<a href="http://perldoc.perl.org/functions/format.html">format</a>=&gt;"fastq-illumina");
  my $seqOut=Bio::SeqIO-&gt;new(-file=&gt;"&gt;$outfasta",-<a href="http://perldoc.perl.org/functions/format.html">format</a>=&gt;"fasta");
  my $qualOut=Bio::SeqIO-&gt;new(-file=&gt;"&gt;$outqual",-<a href="http://perldoc.perl.org/functions/format.html">format</a>=&gt;"qual");
  my $seqCount=0;
  my $percentDone=0;
  while(my $seq=$in-&gt;next_seq){
    $seqOut-&gt;write_seq($seq);
    $qualOut-&gt;write_seq($seq);
    $seqCount++;
    if($seqCount%$reportEvery == 0){
      $percentDone++;
      <a href="http://perldoc.perl.org/functions/print.html">print</a> "$percentDone%..";
    }
  }
  <a href="http://perldoc.perl.org/functions/print.html">print</a> "Done with subfile $file.\n";
  <a href="http://perldoc.perl.org/functions/return.html">return</a> 1;
}

sub joinFastqFiles{
  my($subfile,$outfileBasename)=@_;
  my($command,$subfasta,$subqual);

  # fasta
  $subfasta.="$_.fasta " for(@$subfile);
  $command="cat $subfasta &gt; $outfileBasename.fasta";
  <a href="http://perldoc.perl.org/functions/system.html">system</a>($command);

  # qual
  $subqual.="$_.qual " for (@$subfile);
  $command="cat $subqual &gt; $outfileBasename.qual";
  <a href="http://perldoc.perl.org/functions/system.html">system</a>($command);

  <a href="http://perldoc.perl.org/functions/return.html">return</a> 1;
} 

sub splitFastq{
  my($file,$numCpus)=@_;
  my $prefix="FQ"; # for fastq
  my $numSequences=numSequences($file);
  my $numSequencesPerFile=<a href="http://perldoc.perl.org/functions/int.html">int</a>($numSequences/$numCpus);
  my $numSequencesPerFileRemainder=$numSequences % $numCpus;
  my $numLinesPerFile=$numSequencesPerFile*4; # four lines per read; this could become incorrect if there is a really long read (not currently likely)
  <a href="http://perldoc.perl.org/functions/system.html">system</a>("rm -r tmp;mkdir tmp;");
  <a href="http://perldoc.perl.org/functions/system.html">system</a>("split -l $numLinesPerFile $file 'tmp/FQ'");

  <a href="http://perldoc.perl.org/functions/return.html">return</a> <a href="http://perldoc.perl.org/functions/glob.html">glob</a>("tmp/FQ*");
} 

# use Linux to find the number of sequences quickly, but cache the value because it is still a slow process
# This should probably changed to `wc -l`/4 but I don't have time to test the change
# TODO for anyone reading this: please change this method to wc -l divided by 4.
sub numSequences{
  my $file=<a href="http://perldoc.perl.org/functions/shift.html">shift</a>;
  <a href="http://perldoc.perl.org/functions/return.html">return</a> $numSequences{$file} if($numSequences{$file});
  my $num=`grep -c '^\@' $file`;
  <a href="http://perldoc.perl.org/functions/chomp.html">chomp</a>($num);
  $numSequences{$file}=$num;
  <a href="http://perldoc.perl.org/functions/return.html">return</a> $num;
}</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.biofacebook.com/?feed=rss2&#038;p=243</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>使用CPAN模块自动安装perl模块</title>
		<link>https://www.biofacebook.com/?p=148</link>
		<comments>https://www.biofacebook.com/?p=148#comments</comments>
		<pubDate>Mon, 14 May 2012 02:13:25 +0000</pubDate>
		<dc:creator><![CDATA[szypanther]]></dc:creator>
				<category><![CDATA[脚本语言]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.biofacebook.com/?p=148</guid>
		<description><![CDATA[ <p>命令： perl -MCPAN -e shell </p> <p>初次运行CPAN时需要做一些设置，一路回车在最后选一个最近的CPAN镜像站点。例如国内的中国自由软件库： ftp://freesoft.cgi.gov.cn/pub/languages/perl/CPAN</p> <p>获得帮助 cpan&#62;h</p> <p>列出CPAN上所有模块的列表 cpan&#62;m</p> <p>安装模块</p> <p>perl -MCPAN -e shell cpan&#62; install IO::Wrap cpan&#62; install Net::Server cpan&#62; install MIME::Words</p> <p>也可以合并成一条命令，如： perl -MCPAN -e &#8216;install Net::Server&#8217;</p> <p>退出 cpan&#62;q 如果自动安装失败，可以手动安装跳过测试： cd /root/.cpan/build/Net-Server-0.97/ perl Makefile.PL make install</p> ]]></description>
				<content:encoded><![CDATA[<div id="blog_text">
<p>命令：<br />
<strong>perl　-MCPAN　-e　shell　</strong></p>
<p>初次运行CPAN时需要做一些设置，一路回车在最后选一个最近的CPAN镜像站点。例如国内的中国自由软件库： <a href="ftp://freesoft.cgi.gov.cn/pub/">ftp://freesoft.cgi.gov.cn/pub/languages/perl/CPAN</a></p>
<p>获得帮助<br />
cpan&gt;h</p>
<p>列出CPAN上所有模块的列表<br />
cpan&gt;m</p>
<p>安装模块</p>
<p>perl -MCPAN -e shell<br />
cpan&gt; install IO::Wrap<br />
cpan&gt; install Net::Server<br />
cpan&gt; install MIME::Words</p>
<p>也可以合并成一条命令，如：<br />
perl -MCPAN -e &#8216;install Net::Server&#8217;</p>
<p>退出<br />
cpan&gt;q<br />
如果自动安装失败，可以手动安装跳过测试：<br />
cd /root/.cpan/build/Net-Server-0.97/<br />
perl Makefile.PL<br />
make install</p>
</div>
]]></content:encoded>
			<wfw:commentRss>https://www.biofacebook.com/?feed=rss2&#038;p=148</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
