2019-08-21 gffread----gff、gtf格式转换

三代数据分析,用Minimap2分析出结果,生成了gff文件,想继续用为了想用到MatchAnno去,但是MatchAnno需求是gtf文件,所以想找大家都推荐的cufflinks中的脚本gffread来做。寻找过程中发现gffread有官网直接下载
http://ccb.jhu.edu/software/stringtie/gff.shtml
http://www.bioinfo-scrounger.com/archives/293参考 gffcompare和gffread
然后
conda install gffread
也直接支持下载,类似的还有gffcompare,可以用来compare, merge, annotate and estimate accuracy of one or more GFF files,并且这个软件是基于cuffcompare开发的,所以gffcompare很多输入和输出文件都与cuffcompare相同
http://cole-trapnell-lab.github.io/cufflinks/cuffcompare/

gffread主要用途:

  1. gff 2 gtf
    gffread gencode.vM13.annotation.gff3 -T -o tmp.gtf
  2. gtf 2 gff
    gffread gencode.vM13.annotation.gtf -o tmp.gff3
  3. 从参考基因组提取转录本
    gffread -w transcripts.fa -g mm10.fa stringtie_merged.gtf

帮助文件

gffread v0.11.4. Usage:
gffread <input_gff> [-g <genomic_seqs_fasta> | <dir>][-s <seq_info.fsize>]
 [-o <outfile>] [-t <trackname>] [-r [[<strand>]<chr>:]<start>..<end> [-R]]
 [-CTVNJMKQAFPGUBHZWTOLE] [-w <exons.fa>] [-x <cds.fa>] [-y <tr_cds.fa>]
 [-i <maxintron>] [--bed] [--table <attrlist>] [--sort-by <refseq_list.txt>]
Filter, convert or cluster GFF/GTF/BED records, extract the sequence of
 transcripts (exon or CDS) and more.
 By default (i.e. without -O) only transcripts are processed, discarding any
 other non-transcript features. Default output is a simplified GFF3 with only
 the basic attributes.
 <input_gff> is a GFF file, use '-' for stdin

Options:
 -i   discard transcripts having an intron larger than <maxintron>
 -l   discard transcripts shorter than <minlen> bases
 -r   only show transcripts overlapping coordinate range <start>..<end>
      (on chromosome/contig <chr>, strand <strand> if provided)
 -R   for -r option, discard all transcripts that are not fully
      contained within the given range
 -U   discard single-exon transcripts
 -C   coding only: discard mRNAs that have no CDS features
 --nc non-coding only: discard mRNAs that have CDS features
 --ignore-locus : discard locus features and attributes found in the input
 -A   use the description field from <seq_info.fsize> and add it
      as the value for a 'descr' attribute to the GFF record
 -s   <seq_info.fsize> is a tab-delimited file providing this info
      for each of the mapped sequences:
      <seq-name> <seq-length> <seq-description>
      (useful for -A option with mRNA/EST/protein mappings)
Sorting: (by default, chromosomes are kept in the order they were found)
 --sort-alpha : chromosomes (reference sequences) are sorted alphabetically
 --sort-by : sort the reference sequences by the order in which their
      names are given in the <refseq.lst> file
Misc options:
 -F   preserve all GFF attributes (for non-exon features)
 --keep-exon-attrs : for -F option, do not attempt to reduce redundant
      exon/CDS attributes
 -G   do not keep exon attributes, move them to the transcript feature
      (for GFF3 output)
 --keep-genes : in transcript-only mode (default), also preserve gene records
 --keep-comments: for GFF3 input/output, try to preserve comments
 -O   process other non-transcript GFF records (by default non-transcript
      records are ignored)
 -V   discard any mRNAs with CDS having in-frame stop codons (requires -g)
 -H   for -V option, check and adjust the starting CDS phase
      if the original phase leads to a translation with an
      in-frame stop codon
 -B   for -V option, single-exon transcripts are also checked on the
      opposite strand (requires -g)
 -P   add transcript level GFF attributes about the coding status of each
      transcript, including partialness or in-frame stop codons (requires -g)
 --add-hasCDS : add a "hasCDS" attribute with value "true" for transcripts
      that have CDS features
 --adj-stop stop codon adjustment: enables -P and performs automatic
      adjustment of the CDS stop coordinate if premature or downstream
 -N   discard multi-exon mRNAs that have any intron with a non-canonical
      splice site consensus (i.e. not GT-AG, GC-AG or AT-AC)
 -J   discard any mRNAs that either lack initial START codon
      or the terminal STOP codon, or have an in-frame stop codon
      (i.e. only print mRNAs with a complete CDS)
 --no-pseudo: filter out records matching the 'pseudo' keyword
 --in-bed: input should be parsed as BED format (automatic if the input
           filename ends with .bed*)
 --in-tlf: input GFF-like one-line-per-transcript format without exon/CDS
           features (see --tlf option below); automatic if the input
           filename ends with .tlf)
Clustering:
 -M/--merge : cluster the input transcripts into loci, discarding
      "duplicated" transcripts (those with the same exact introns
      and fully contained or equal boundaries)
 -d <dupinfo> : for -M option, write duplication info to file <dupinfo>
 --cluster-only: same as -M/--merge but without discarding any of the
      "duplicate" transcripts, only create "locus" features
 -K   for -M option: also discard as redundant the shorter, fully contained
       transcripts (intron chains matching a part of the container)
 -Q   for -M option, no longer require boundary containment when assessing
      redundancy (can be combined with -K); only introns have to match for
      multi-exon transcripts, and >=80% overlap for single-exon transcripts
 -Y   for -M option, enforce -Q but also discard overlapping single-exon
      transcripts, even on the opposite strand (can be combined with -K)

Output options:
 --force-exons: make sure that the lowest level GFF features are considered
       "exon" features
 --gene2exon: for single-line genes not parenting any transcripts, add an
       exon feature spanning the entire gene (treat it as a transcript)
 --t-adopt:  try to find a parent gene overlapping/containing a transcript
       that does not have any explicit gene Parent
 -D    decode url encoded characters within attributes
 -Z    merge very close exons into a single exon (when intron size<4)
 -g   full path to a multi-fasta file with the genomic sequences
      for all input mappings, OR a directory with single-fasta files
      (one per genomic sequence, with file names matching sequence names)
 -w    write a fasta file with spliced exons for each GFF transcript
 -x    write a fasta file with spliced CDS for each GFF transcript
 -y    write a protein fasta file with the translation of CDS for each record
 -W    for -w and -x options, write in the FASTA defline the exon
       coordinates projected onto the spliced sequence;
       for -y option, write transcript attributes in the FASTA defline
 -S    for -y option, use '*' instead of '.' as stop codon translation
 -L    Ensembl GTF to GFF3 conversion (implies -F; should be used with -m)
 -m    <chr_replace> is a name mapping table for converting reference
       sequence names, having this 2-column format:
       <original_ref_ID> <new_ref_ID>
       WARNING: all GFF records on reference sequences whose original IDs
       are not found in the 1st column of this table will be discarded!
 -t    use <trackname> in the 2nd column of each GFF/GTF output line
 -o    write the records into <outfile> instead of stdout
 -T    main output will be GTF instead of GFF3
 --bed output records in BED format instead of default GFF3
 --tlf output "transcript line format" which is like GFF
       but exons, CDS features and related data are stored as GFF
       attributes in the transcript feature line, like this:
         exoncount=N;exons=<exons>;CDSphase=<N>;CDS=<CDScoords>
       <exons> is a comma-delimited list of exon_start-exon_end coordinates;
       <CDScoords> is CDS_start:CDS_end coordinates or a list like <exons>
 --table output a simple tab delimited format instead of GFF, with columns
       having the values of GFF attributes given in <attrlist>; special
       pseudo-attributes (prefixed by @) are recognized:
       @chr, @start, @end, @strand, @numexons, @exons, @cds, @covlen, @cdslen
 -v,-E expose (warn about) duplicate transcript IDs and other potential
       problems with the given GFF/GTF records

另外的gff转gtf的方法

26 #把gmap产生的GFF文件转换为Gtf文件
27 (1)
28 cd /zs32_2/Linglhuang/Alzheimer_final_confident
29 grep -E "mRNA|exon" AD_rep_uniqueM.fa.gff | cut -d ';' -f 1,2 > AD_rep_uniqueM.R.gff
30 sed -i 's/mRNA/transcript/;s/ID=/gene_id /;s/Name=/transcript_id /g' AD_rep_uniqueM.R.gff
31 sed -i 's/[.][0-9]*[.]mrna1.exon[0-9]*//' AD_rep_uniqueM.R.gff
32 sed -i 's/[.][0-9]*[.]mrna1//' AD_rep_uniqueM.R.gff
33 sed -i 's/PB/"PB/g;s/;/"; /' AD_rep_uniqueM.R.gff
34 sed -i 's/$/";/' AD_rep_uniqueM.R.gff
35 sed -i 's/Gmapindexhg19-2017/PacBio/g' AD_rep_uniqueM.R.gff
36 awk 'BEGIN{FS="\t"}{printf "%s\t%s\t%s\t%s\t%s\t.\t%s\t%s\t%s\n",$1,$2,$3,$4,$5,$7,$8,$9}' AD_rep_uniqueM.R.gff > AD_rep_uniqueM.gtf
37 
38 (2)#gffread
39 cd /zs32_2/Linglhuang/ALL_datasets/AD
40 /opt/tools/seq-analysis/cufflinks-2.2.1.Linux_x86_64/gffread AD_rep.gff -T -o AD_rep.R2.gff
41 sed 's/.mrna1//;s/[.][0-9]*[.]path1//;s/ gene_name "PB[.][0-9]*[.][0-9]*";//' AD_rep.R2.gff > AD_rep2.gtf
42 sed -i 's/Gmapindexhg19-2017/PacBio/g' AD_rep2.gtf
43 awk 'BEGIN{FS="\t"}{printf "%s\t%s\t%s\t%s\t%s\t.\t%s\t%s\t%s\n",$1,$2,$3,$4,$5,$7,$8,$9}' AD_rep2.gtf > Isoseq_rep2.gtf
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,772评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,458评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,610评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,640评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,657评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,590评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,962评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,631评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,870评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,611评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,704评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,386评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,969评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,944评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,179评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,742评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,440评论 2 342

推荐阅读更多精彩内容