Skip to content

Instantly share code, notes, and snippets.

@meso-cacase
Created February 22, 2016 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meso-cacase/b175636519125a033908 to your computer and use it in GitHub Desktop.
Save meso-cacase/b175636519125a033908 to your computer and use it in GitHub Desktop.
GGRNAをつかいプローブIDと遺伝子の対応表を作成
#!/usr/bin/perl
use warnings ;
use strict ;
use LWP::Simple ;
while (<>){
chomp ;
# ProbeIDを標準入力から取得
my $probeid = $_ ;
$probeid =~ s/(^\s+|\s+$)//g ; # 前後のスペースを除去
# print "ProbeID : $probeid\n" ;
# ProbeIDを塩基配列に変換
# 例:http://probe.dbcls.jp/1552311_a_at.txt
# print "Get : http://probe.dbcls.jp/$probeid.txt\n" ;
my $seq = get("http://probe.dbcls.jp/$probeid.txt") ;
# print "Result :\n$seq\n" ;
# GGRNAでヒトRefSeq RNAに対してプローブ配列検索
$seq =~ s/^\s*/seq:/ ;
$seq =~ s/\s+$// ;
$seq =~ s/\s+/+seq:/g ;
# print "Get : http://ggrna.dbcls.jp/hs/$seq.txt\n" ;
my $gene = get("http://ggrna.dbcls.jp/hs/$seq.txt") ;
# print "Result :\n$gene\n" ;
# SymbolおよびGeneIDを出力
my @gene = split("\n", $gene) ;
@gene = grep !/^\#/, @gene ; # ヒット以外の情報を除去
foreach (@gene){
chomp ;
my $symbol = (split /\t/)[4] // '' ;
my $geneid = (split /\t/)[6] // '' ;
$_ = "$symbol $geneid" ;
}
foreach (unique_map(@gene)){
print "$probeid $_\n" ;
}
}
exit ;
# ====================
sub unique_map {
my @array = @_ ;
my %hash = map {$_, 1} @array ;
return keys %hash ;
}
# ====================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment