BioMedInfo 板


LINE

小的是perl新手 以下是參考用perl找到CDS的程式碼 將start_hash的location改為end end_hash的location改為start 想請問如何修改才能得到所需的intergenic region 謝謝~ #!/usr/bin/perl use strict; use warnings; use Getopt::Long; use File::Basename; use Bio::SeqIO; my $in_file; my $out_dir; my $id_tag; my $print_aa; my $print_nt; my $print_gg; my $print_loc; my $verbose; my $debug; GetOptions( "in_file=s" => \$in_file, "out_dir=s" => \$out_dir, "id_tag=s" => \$id_tag, "print_aa=i" => \$print_aa, "print_nt=i" => \$print_nt, "print_gg=i" => \$print_gg, "print_loc=i" => \$print_loc, "verbose=i" => \$verbose, "debug=i" => \$debug ); $id_tag = $id_tag ? $id_tag : 'protein_id'; system "mkdir -p $out_dir" unless -e $out_dir; my $file_id; if ( $in_file =~ m/.*\/(\S+?)\./ ) { $file_id = $1; } else { die "error parsing file_id from $in_file\n"; } my $out_file = $out_dir . $file_id . '.out'; open OUT, ">$out_file" or die "Can't open output file $out_file\n"; my $err_file = $out_dir . $file_id . '.err'; open ERR, ">$err_file" or die "Can't open output file $err_file\n"; if ($print_aa) { my $aa_out = $out_dir . $file_id . '.aa.fasta'; open AA, ">$aa_out" or die "Can't open output file $aa_out\n"; } if ($print_nt) { my $nt_out = $out_dir . $file_id . '.nt.fasta'; open NT, ">$nt_out" or die "Can't open output file $nt_out\n"; } if ($print_gg) { my $gg_out = $out_dir . $file_id . '.gg'; open GG, ">$gg_out" or die "Can't open output file $gg_out\n"; } if ($print_loc) { my $loc_out = $out_dir . $file_id . '.igr.location'; open LOC, ">$loc_out" or die "Can't open output file $loc_out\n"; } my $seqio_object = Bio::SeqIO->new( -format => "genbank", -file => "$in_file" ); my $seq_name; my $count_seq = 0; my $count_cds_total = 0; my $count_non_coding_total = 0; print GG "$file_id\: "; while ( my $seq_object = $seqio_object->next_seq ) { my $accession = $seq_object->accession_number; $count_seq++; my %nt_seq_hash; # key = seq_name, value = nt_seq my %aa_seq_hash; # key = seq_name, value = aa_seq my %start_hash; # key = seq_name, value = start my %end_hash; # key = seq_name, value = end my %strand_hash; # key = seq_name, value = strand my $count_igr_in = 0; my $count_igr_out = 0; for my $feat_object ( $seq_object->get_SeqFeatures ) { if ( $feat_object->primary_tag eq 'CDS' ) { # ignore pseudo genes next if ( $feat_object->has_tag("pseudo") ); $count_igr_in++; if ( $feat_object->has_tag($id_tag) ) { for my $value ( $feat_object->get_tag_values($id_tag) ) { $seq_name = $value; } if ( $id_tag eq 'protein_id' && $seq_name =~ m/(\S+)\./ ) { $seq_name = $1; } $count_igr_out++; $start_hash{$seq_name} = $feat_object->location->end; $end_hash{$seq_name} = $feat_object->location->start; $strand_hash{$seq_name} = $feat_object->location->strand; $nt_seq_hash{$seq_name} = $feat_object->spliced_seq->seq; if ( $feat_object->has_tag("translation") ) { for my $value ( $feat_object->get_tag_values("translation") ) { $aa_seq_hash{$seq_name} = $value; } } else { print ERR "$file_id: $accession: $seq_name: no translation!\ n"; } } else { print ERR "$file_id: $accession: no $id_tag!\n"; } } } my $count_order = 0; foreach $seq_name ( sort { $start_hash{$a} $start_hash{$b} } keys %start_hash ) { $count_order++; print AA ">$seq_name\n$aa_seq_hash{$seq_name}\n" if ($print_aa); print NT ">$seq_name\n$nt_seq_hash{$seq_name}\n" if ($print_nt); print GG " $seq_name" if ($print_gg); print LOC "$seq_name\t$accession\t$count_order\t", "$start_hash{$seq_name}\t$end_hash{$seq_name}\t", "$strand_hash{$seq_name}\n" if ($print_loc); } print OUT "$file_id: $accession: count_igr_out = $count_igr_out\n"; if ( $count_igr_in != $count_igr_out ) { print ERR "$file_id: $accession: count_igr_in = $count_igr_in ", "!= count_igr_out = $count_igr_out!\n"; } $count_igr_total += $count_igr_out; } # while $seq_object print OUT "$file_id: count_seq = $count_seq, count_igr_total = $count_igr_total\ n"; print GG "\n" if ($print_gg); close OUT; close ERR; close AA if ($print_aa); close NT if ($print_nt); close GG if ($print_gg); close LOC if ($print_loc); exit(0); --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.226.136.153
1F:→ jjhgk:意思是$nt_seq_hash{$seq_name}不是你要的IGR嗎? 07/31 10:26
2F:→ lambking:恩恩 想請問$feat_object->primary_tag eq 'CDS' 07/31 19:07
3F:→ lambking:是指 讀入CDS片段嗎? 07/31 19:09
4F:→ Godkin:這指的是找出當中被標上CDS標籤的部份 07/31 19:44
5F:→ jjhgk:不知道你是不是想藉由找出cds的位置來取得non-cds的序列, 07/31 21:14
6F:→ jjhgk:是的話你可能要用其他method取得序列,並確定基因上下游關係 07/31 21:18
7F:→ lambking:請問 若是想從Genbank所取得的序列 直接找出intergenic 07/31 21:52
8F:→ lambking:region 該如何下手呢? 謝謝~ 07/31 21:53







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Gossiping站內搜尋

TOP