ncbi的genome,gene序列轉換和gb2gtf——鏈特異性轉錄組
ncbi下載的資料不一定符合鏈特異性轉錄組的格式,寫個小指令碼進行處理一下:
#!perl use warnings; use strict; die qq/ perl $0 <type> <outprefix> <file1> [<file2> ...] type: "gtf", "gene" and "genome". Note: "genome" need gtf.list of "gtf", and gtf.list must be the end option of <file...>. / if(@ARGV < 3); my $t = shift @ARGV; my $out = shift @ARGV; my $py = "gbk2gtf.py"; if($t eq "gtf") { my @gtf; foreach(@ARGV) { system "cat $_ | python $py > $_.tmp"; push @gtf, "$_.tmp"; } system "cat @gtf > $out.gtf"; system "cut -f 1 $out.gtf | sort | uniq > gtf.list"; system "rm *.tmp -rf"; }elsif($t eq "gene"){ my @gene; foreach my $f(@ARGV) { open FF, $f or die $!; open OUT, "> $f.tmp" or die $!; while(<FF>) { next if(/^\n/); chomp; if(/^>/) { my ($id) = $_ =~ /locus_tag=(\w+)/; print OUT ">$1\n"; }else{ print OUT "$_\n"; } } close FF; close OUT; push @gene, "$f.tmp"; } system "cat @gene > $out.gene.fa"; system "rm *.tmp -rf"; }elsif($t eq "genome"){ my $gtf = pop @ARGV; my %hash; my @genome; open GTF, $gtf or die $!; while(<GTF>) { chomp; $hash{$_} = 0; } close GTF; foreach my $f(@ARGV) { open FF, $f or die $!; open OUT, "> $f.tmp" or die $!; while(<FF>) { chomp; if(/^>/) { foreach my $k(keys %hash) { if(/$k/) { print OUT ">$k\n"; last; }else{ next; } } }else{ print OUT "$_\n"; } } close FF; close OUT; push @genome, "$f.tmp"; } system "cat @genome > $out.genome.fa"; system "rm *.tmp -rf"; my @cl = `fastalength $out.genome.fa`; open OO, ">contig.length" or die $!; foreach my $c(@cl) { chomp($c); my @tmp = split /\s+/, $c; print OO "$tmp[1]\t$tmp[0]\n"; } close OO; }else{ die "please choose correct type: \"gtf\", \"gene\" and \"genome\"."; }
#!/usr/bin/env python """ Convert genbank to gtf. USAGE: cat file.gb | gb2gtf.py > file.gtf NOTE: It's designed to work with gb files coming from GenBank. gene is used as gene_id and transcript_id (locus_tag if gene not present). Only entries having types in allowedTypes = ['gene','CDS','tRNA','tmRNA','rRNA','ncRNA'] are stored in GTF. Need to include exon processing. No frame info is processed. Need to be included in order to process genes having introns! AUTHOR: Leszek Pryszcz
[email protected] Version 0.1 """ import os, sys from datetime import datetime from Bio import SeqIO def gb2gtf( source='gb2gtf',allowedTypes=set(['gene','CDS','tRNA','tmRNA','rRNA','ncRNA']) ): """ """ handle = sys.stdin for gb in SeqIO.parse( handle,'gb' ): acc = gb.id #gb.name #gb.description # # skipped = 0 skippedTypes = set() for f in gb.features: #process only gene and CDS entries if f.type not in allowedTypes: skipped += 1 skippedTypes.add( f.type ) continue #generate comments field if 'locus_tag' in f.qualifiers: #use locul tag as gene_id/transcript_id gene_id = transcript_id = f.qualifiers['locus_tag'][0] else: sys.stderr.write( "Error: Neither `gene` nor `locus_tag` found for entry: %s\n" % '; '.join( str(f).split('\n') ) ) continue comments = 'gene_id "%s"; transcript_id "%s"' % ( gene_id,transcript_id ) if 'gene' in f.qualifiers: comments += '; gene_id "%s"' % f.qualifiers['gene'][0] if 'protein_id' in f.qualifiers: comments += '; protein_id "%s"' % f.qualifiers['protein_id'][0] #add external IDs if 'db_xref' in f.qualifiers: for extData in f.qualifiers['db_xref']: comments += '; db_xref "%s"' % extData #code strand as +/- (in genbank 1 or -1) if int(f.strand)>0: strand = '+' else: strand = '-' #define gb """ seqname - The name of the sequence. Must be a chromosome or scaffold. source - The program that generated this feature. feature - The name of this type of feature. Some examples of standard feature types are "CDS", "start_codon", "stop_codon", and "exon". start - The starting position of the feature in the sequence. The first base is numbered 1. end - The ending position of the feature (inclusive). score - A score between 0 and 1000. If the track line useScore attribute is set to 1 for this annotation data set, the score value will determine the level of gray in which this feature is displayed (higher numbers = darker gray). If there is no score value, enter ".". strand - Valid entries include '+', '-', or '.' (for don't know/don't care). frame - If the feature is a coding exon, frame should be a number between 0-2 that represents the reading frame of the first base. If the feature is not a coding exon, the value should be '.'. comments - gene_id "Em:U62317.C22.6.mRNA"; transcript_id "Em:U62317.C22.6.mRNA"; exon_number 1 """ gtf = '%s\t%s\t%s\t%s\t%s\t.\t%s\t.\t%s' % ( acc,source,f.type,f.location.start.position+1,f.location.end.position,strand,comments ) #f.frame, print gtf sys.stderr.write( "%s\tSkipped %s entries having types: %s.\n" % ( gb.id,skipped,', '.join(skippedTypes) ) ) if __name__=='__main__': t0=datetime.now() gb2gtf() dt=datetime.now()-t0 sys.stderr.write( "#Time elapsed: %s\n" % dt )
相關推薦
ncbi的genome,gene序列轉換和gb2gtf——鏈特異性轉錄組
ncbi下載的資料不一定符合鏈特異性轉錄組的格式,寫個小指令碼進行處理一下: #!perl use warnings; use strict; die qq/ perl $0 <type> <outprefix> <file1> [
pdf轉word轉換器線上版,文件轉換和處理都在這裡了
線上PDF轉換器可以做些什麼工作呢?PDF線上轉換器是一種可以轉換各種常見辦公文件的線上轉換平臺,支援一站式解決日常工作中絕大部分的文件轉換需求。除此之外,線上迅捷PDF轉換器還提供PDF文件處理,編輯、文字線上翻譯、OCR識別、流程圖製作等高頻使用的辦公服務。 在日常工作中很多檔案的傳輸
python面試題,通過交換a,b中的元素,使[序列a和]與[序列b和]之間的差最小
sumb = sum(lstb) d = abs(suma-sumb) if d == 0: return d bExchange = False for indexa, ia in enumerate(lsta): i
IAR資料定位方法 ,定義序列號和要儲存的資料時會用到
資料定位方法如下三種 1、__no_init char alpha @ 0x0200; 2、#pragma location=0x0202 const int beta; 3、const int gamma @ 0x0204 = 3; 或; 1、__no_init int alpha @ "MYS
前端【JS】,深入理解原型和原型鏈
對於原型和原型鏈,相信有很多夥伴都說的上來一些,但有具體講不清楚。但面試的時候又經常會碰到面試官的死亡的追問,我們慢慢來梳理這方面的知識! 要理解原型和原型鏈的關係,我們首先需要了解幾個概念;1、什麼是建構函式?2、建構函式與普通函式有什麼區別? 3、原型鏈的頂端是什麼? 4、prototype、__prot
CAD技巧,CAD圖紙轉換PDF要怎麽轉
預覽 cde process 分享圖片 方法 想要 就是 ad轉換 轉換器 CAD技巧,CAD圖紙轉換PDF要怎麽轉?在日常的工作中,最常見的就是CAD圖紙,但是CAD圖紙的格式是dwg格式的,為了更好的查看,我們就需要進行圖紙格式的轉換工作,拿在CAD轉換文件格式的過程中
讓PIP源使用國內映象,提升下載速度和安裝成功率【轉】
對於Python開發使用者來講,PIP安裝軟體包是家常便飯。但國外的源下載速度實在太慢,浪費時間。而且經常出現下載後安裝出錯問題。所以把PIP安裝源替換成國內映象,可以大幅提升下載速度,還可以提高安裝成功率。 國內源: 新版ubuntu要求使用https源,要注意。 清華:https://pypi.tu
120分的轉錄組試題和答案
120分的轉錄組試題和答案 這個答案之前出過三份,最近整理了一份文字版,方便觀看,還請大家多多補充。 120分的轉錄組試題(第一份答案) 120分的轉錄組試題(第二份答案) 120分的轉錄組試題(第三份答案) 一、理論題目 1、說出至少5種高
HISAT2,StringTie,Ballgown處理轉錄組資料
HISAT2,StringTie,Ballgown處理轉錄組資料 本文總閱讀量次2017-05-26 HISAT2,StringTie,Ballgown處理轉錄組資料思路如下: 資料質控 將RNA-seq的測序reads使用hisat2比對 samtools將sa
微生物組學研究手段概覽2——巨集基因組和巨集轉錄組
原創: 林二狗 宇宙實驗媛 巨集基因組 巨集基因組測序是將環境總DNA提取出來,隨機打斷成300/500bp的小片段,然後在片段兩端加入通用引物進行PCR擴增測序,然後對測序資料進行質控,再將高質量序列拼接,根據資料庫
IO流(File類,IO流的分類,位元組流和字元流,轉換流,緩衝流,物件序列化)
1.File類 File類可以在程式中 操作檔案和目錄。File類是通過建立File類物件,在呼叫File類的物件來進行相關操作的。 示例: --------------------- 本文來自 dajiahuooo 的CSDN 部落格 ,全文地址請點選:https://blog.csdn.net/
javascript 對象屬性的添加,刪除,json對象和字符串轉換方法等
star font style strong 字符串轉換 定義 obj tarray def 1:動態添加 對象屬性 var obj = new Object(); console.log (obj.username); obj.username = "haha"; con
python基礎之繼承組合應用、對象序列化和反序列化,選課系統綜合示例
sel 初始 否則 通用 __init__ period 類型 反序列化 信息 繼承+組合應用示例 1 class Date: #定義時間類,包含姓名、年、月、日,用於返回生日 2 def __init__(self,name,year,mon,day):
磁盤分區,文件系統,軟鏈接和硬鏈接,內存和進程管理
日誌 sha 文件的 清理 directory 終端 參數 概念 映射關系 (一)磁盤分區 1.硬盤邏輯上劃分為:塊--磁道--磁柱--分區; 2.分區分類:主分區,擴展分區,邏輯分區 3.命令: sdb---scsi接口的第2個磁盤,路徑為/dev/sdb /dev/sr
[微軟]有兩個序列a,b,大小都為n,序列元素的值任意整數,無序; 要求:通過交換a,b中的元素,使[序列a元素的和]與[序列b元素的和]之間的差最小_利用排列組合思路解決_python版
+= 求和 ever tro 解決 turn 運行 main lis (原題出自微軟公司面試題)問題如下:有兩個序列a,b,大小都為n,序列元素的值任意整數,無序;要求:通過交換a,b中的元素,使[序列a元素的和]與[序列b元素的和]之間的差最小。例如:a=[100,99,
為什麽用快慢指針找鏈表的環,快指針和慢指針一定會相遇
為什麽 鏈接 來源 獲得 快慢指針 聯系 著作權 什麽 相對 https://www.zhihu.com/question/23208893 首先相遇不是操場跑圈,快的能追上慢的,這還用問嗎,肯定能追上。而樓主問的是一個人是跳1個格子,另一個跳2個格子,會不會每次要
python學習第四天,列表生產式,匿名函數,生成器,內置函數,叠代器,裝飾器,json和pickle的序列化和反序列化
數據 其他 imp 函數名 fun pro serializa and cal 列表生成式,生產器 #列表生成式,可以是代碼更復雜 a = [i for i in range(10)] #這裏的i,可以使用函數來裝飾 print(a) #生產器:就是數據在調用的時候才有
Serializable 指示一個類可以序列化;ICloneable支持克隆,即用與現有實例相同的值創建類的新實例(接口);ISerializable允許對象控制其自己的序列化和反序列化過程(接口)
att 文本 所有 可能 成員 強制 void inter 適用於 Serializable : 序列化是指將對象實例的狀態存儲到存儲媒體的過程。在此過程中,先將對象的公共字段和私有字段以及類的名稱(包括類所在的程序集)轉換為字節流,然後再把字節流寫入數據流。在隨後對對象進
logger模塊使用和序列化,反序列化
dir RR sys.path pre utf 給他 inf 編寫 根目錄 再將之前我們首先需要了解一下軟件開發目錄的規範: 開發基本目錄 2.定制程序入口 1、要在start.py處要把絕對路徑寫出來 import sys,os # 應該把項目的根目錄添加到環境
用AI和區塊鏈對付PS,我們的目標是沒有照騙
vertical 合同 機器 停止 提高 高速 TP top 應對 照片是真實世界的反映嗎?或許從照相技術發明的初衷來說,應該是這樣的。不過現實情況卻是,在拍照技術被發明不久後,利用照片沖印技術進行照片修繕和造假的情況就已經出現了。等到了數碼照片時代,Adobe這樣的圖像處