wurmlab / flo

Same species annotation lift over pipeline.
96 stars 28 forks source link

NoMethodError: undefined method `last' for nil:NilClass #4

Closed muol closed 7 years ago

muol commented 8 years ago

Hi, I receive the error above during annotation liftover with flo, and would appreciate some help. The output directory contains completed lifted.gff3 and unlifted.gff3 before rake aborts.

My system: Ubuntu 12.04 x64 Ruby 2.3.1 Bioruby 1.5.1 flo and its dependencies have been installed as described.

Thanks

Log:

... chainMergeSort run/*.chn.sorted | chainSplit run stdin -lump=1 mv run/000.chain run/combined.chn.sorted chainNet run/combined.chn.sorted run/source.sizes run/target.sizes run/combined.chn.sorted.net /dev/null Got 14 chroms in run/source.sizes, 14 in run/target.sizes Finishing nets writing run/combined.chn.sorted.net writing /dev/null netChainSubset run/combined.chn.sorted.net run/combined.chn.sorted run/liftover.chn Processing Pf3D7_14_v3 Processing Pf3D7_13_v3 Processing Pf3D7_12_v3 Processing Pf3D7_11_v3 Processing Pf3D7_10_v3 Processing Pf3D7_09_v3 Processing Pf3D7_08_v3 Processing Pf3D7_07_v3 Processing Pf3D7_06_v3 Processing Pf3D7_05_v3 Processing Pf3D7_04_v3 Processing Pf3D7_03_v3 Processing Pf3D7_02_v3 Processing Pf3D7_01_v3 mkdir PlasmoDB-29_Pfalciparum3D7_GFF_CHROMOSOME-liftover-named_assembly_pacbio2 liftOver -gff plasmodium/PlasmoDB-29_Pfalciparum3D7_GFF_CHROMOSOME.gff3 run/liftover.chn PlasmoDB-29_Pfalciparum3D7_GFF_CHROMOSOME-liftover-named_assembly_pacbio2/lifted.gff3 PlasmoDB-29_Pfalciparum3D7_GFF_CHROMOSOME-liftover-named_assembly_pacbio2/unlifted.gff3 Reading liftover chains Mapping coordinates WARNING: -gff is not recommended. Use 'ldHgGene -out=' and then 'liftOver -genePred ' rake aborted! NoMethodError: undefined method last' for nil:NilClass /home/muol/Documents/Software/flo/Rakefile:72:inblock in process_gff' /home/muol/Documents/Software/flo/Rakefile:69:in each' /home/muol/Documents/Software/flo/Rakefile:69:ingroup_by' /home/muol/Documents/Software/flo/Rakefile:69:in process_gff' /home/muol/Documents/Software/flo/Rakefile:223:inblock (2 levels) in <top (required)>' /home/muol/Documents/Software/flo/Rakefile:212:in each' /home/muol/Documents/Software/flo/Rakefile:212:inblock in <top (required)>' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:240:in block in execute' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:235:ineach' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:235:in execute' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:179:inblock in invoke_with_call_chain' /usr/local/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:172:ininvoke_with_call_chain' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:165:in invoke' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:150:ininvoke_task' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:106:in block (2 levels) in top_level' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:106:ineach' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:106:in block in top_level' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:115:inrun_with_threads' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:100:in top_level' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:78:inblock in run' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:176:in standard_exception_handling' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:75:inrun' /usr/local/lib/ruby/gems/2.3.0/gems/rake-10.4.2/bin/rake:33:in <top (required)>' /usr/local/bin/rake:23:inload' /usr/local/bin/rake:23:in `

' Tasks: TOP => default

yeban commented 8 years ago

Most likely this is because of comments in the GFF file. Can you try again after stripping comments from your GFF file:

grep -v '^#' foo.gff3 > foo_comments_stripped.gff3

Building chain file is the most time consuming step of flo. If you didn't remove the chain file created by flo at run/liftover.chn, it won't create it again.

muol commented 8 years ago

Thanks, but that didn't help. Next up I began removing all non protein coding gene features and eventually ended up with a one gene skeleton gff3, plus only the matching chromosome in source and target fastas. The error unfortunately remains.

source gff3 (tabs replaced with spaces in this post):

Chr1 test gene 29510 37126 . + . ID=gene1 Chr1 test mRNA 29510 37126 . + . ID=rna_gene1-1;Parent=gene1 Chr1 test CDS 29510 34762 . + 0 ID=cds_gene1-1;Parent=rna_gene1-1 Chr1 test CDS 35888 37126 . + 0 ID=cds_gene1-2;Parent=rna_gene1-1 Chr1 test exon 29510 34762 . + . ID=exon_gene1-1;Parent=rna_gene1-1 Chr1 test exon 35888 37126 . + . ID=exon_gene1-2;Parent=rna_gene1-1

lifted.gff3 (tabs replaced with spaces in this post):

TargetChr1 test gene 49342 56961 . + . ID=gene1 TargetChr1 test mRNA 49342 56961 . + . ID=rna_gene1-1;Parent=gene1 TargetChr1 test CDS 49342 54594 . + 0 ID=cds_gene1-1;Parent=rna_gene1-1 TargetChr1 test CDS 55723 56961 . + 0 ID=cds_gene1-2;Parent=rna_gene1-1 TargetChr1 test exon 49342 54594 . + . ID=exon_gene1-1;Parent=rna_gene1-1 TargetChr1 test exon 55723 56961 . + . ID=exon_gene1-2;Parent=rna_gene1-1

So it appears the new landmark Id and all features have been lifted, yet rake errors out with NoMethodError: undefined method `last' for nil:NilClassi in the next step.

yeban commented 8 years ago

Lift over is done by calling out to UCSC's liftOver command. After that, process_gff function (written by us) is called to ensure the output GFF3 (lifted.gff3) is valid. That is where flo is failing: process_gff knows only to process mRNA/transcript, exon, and CDS annotations. I am sorry, I realise this limitation is not documented in README.

process_gff is hardly a 15 line function. You can skip it and process lifted.gff3 yourself through a custom script instead. Please see https://github.com/wurmlab/flo#lift-over and process_gff for advice.

yeban commented 7 years ago

I have updated flo - this shouldn't be a problem now.