2007년 3월 29일 목요일
2007년 3월 28일 수요일
2007년 3월 25일 일요일
Excel로 전환
한글 테스트 해봐야 함
#!/usr/bin/perl -w # # Parse ace file and extract read names of destined contig # # Written by Suk Namgoong # use strict; use Spreadsheet::WriteExcel; my $usage = "aceprimer.pl <ace file name>"; my $acefilename = shift or die $usage; my $workbook = Spreadsheet::WriteExcel->new($acefilename.".xls"); my ($contigfound, $fofname, $readname, $ctstart); my $worksheet1 = $workbook->add_worksheet("forward"); my $worksheet2 = $workbook->add_worksheet("reverse"); my $format = $workbook->add_format(); $format->set_bold(); $format->set_bg_color(18); $format->set_pattern(1); my $align = $workbook->add_format(); $align->set_align('center'); my $align2 = $workbook->add_format(); $align2->set_align('vjustify'); $contigfound = 0; my %primerhash = (); # # Parse Ace File and put start postion and length of each reads into hash (%read_start and %read length)) # $worksheet1->write(0,0,"Experiment ID", $format); $worksheet1->write(0,1,"Contig Name", $format); $worksheet1->write(0,2,"Primer Name", $format); $worksheet1->write(0,3 ,"Sequence", $format); $worksheet1->write(0,4,"Tm", $format); $worksheet1->write(0,5,"Comment", $align2); $worksheet2->write(0,0,"Experiment ID", $format); $worksheet2->write(0,1,"Contig Name", $format); $worksheet2->write(0,2,"Primer Name", $format); $worksheet2->write(0,3,"Sequence", $format); $worksheet2->write(0,4,"Tm", $format); $worksheet2->write(0,5,"Comment", $align2); my $frow = 1; my $rrow = 1; my $col = 0; my $exp_no = 1; $ctstart = 0; open (FILEHANDLE, "<$acefilename"); my ($contigname, $primername, $sequence, $comment, $oligostart, $oligoend, $meltingTemp); while (my $readline = <FILEHANDLE>) { chomp($readline); if ($readline =~ m/^CT{/) { $ctstart = 1; $comment = ""; next; } if ($ctstart eq 1 ) { if ($readline =~ m/^(\S+) oligo consed (\S+) (\S+)/) { $contigname = $1; $oligostart = $2; $oligoend = $3; $ctstart = 2; next; } else { $ctstart = 0; next; } } if ($ctstart eq 2) { if ($readline =~ m/^(\S+) (\S+) (\S+)/) { $primername = $1; $sequence = $2; $meltingTemp = $3; $ctstart = 3; next; } } if ($ctstart eq 3) { if ($readline =~ m/^COMMENT{/) { $ctstart = 4; next; } } if ($ctstart eq 4) { if ($readline =~ m/}$/) { $ctstart = 0; if (exists($primerhash{$comment})) { $worksheet2->write($frow,0,$primerhash{$comment}); $worksheet2->write($frow,1,$contigname); $worksheet2->write($frow,2,$primername); $worksheet2->write($frow,3,$sequence); $worksheet2->write($frow,4,$meltingTemp,$align); $worksheet2->write($frow,5,$comment, $align2); $frow++; } else { $primerhash{$comment} = $exp_no; $worksheet1->write($rrow,0,$exp_no); $worksheet1->write($rrow,1,$contigname); $worksheet1->write($rrow,2,$primername); $worksheet1->write($rrow,3,$sequence); $worksheet1->write($rrow,4,$meltingTemp,$align); $worksheet1->write($rrow,5,$comment, $align2); $exp_no++; $rrow++; } next; } else { $comment = $comment.$readline; next; } } } close FILEHANDLE;
2007년 3월 23일 금요일
new HTTP::Request POST sample
my $req = new HTTP::Request POST => $url;
# $req->content_type('application/x-www-form-urlencoded');
$req->content($cstr);
my $res = $ua->request($req);
print "\n--after login action----------------------------------\n";
print $res->content;
2007년 3월 20일 화요일
[매칭관련] php에서 [] 사이의 내용 가져오기
<?php
$html = "123123123[12345][00001][11111]12312312";
preg_match_all("|[\[](\d{5})[\]]|U", $html, $matches);
for ($i=0; $i< count($matches[0]); $i++) {
echo "matched: " . $matches[0][$i] . "\n";
echo "part 1: " . $matches[1][$i] . "\n\n";
$packs .= $matches[1][$i].",";
}
echo $packs;
?>
결과--------------------------------
matched: [12345]
part 1: 12345
matched: [00001]
part 1: 00001
matched: [11111]
part 1: 11111
샘플 2
<?
$string = "타입과색상;CMT0025댄디PK/블랙M(3000원)./(3000원)";
preg_match_all("|[\(](.*)[원\)]|U", $string, $matches);
for( $i=0; $i < count($matches[1]); $i++ )
{
$total = $total + $matches[1][0];
}
echo "total: $total\n";
?>
~
total: 6000