Created
          April 3, 2012 15:25 
        
      - 
      
- 
        Save michaelbarton/2292903 to your computer and use it in GitHub Desktop. 
    Update GFF records for tRNAs from identifiers in a different fasta file
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env ruby | |
| require 'bio' | |
| trnas = Bio::FlatFile.auto('genes.fna'). | |
| map(&:definition). | |
| grep(/tRNA_..._.../). | |
| map{|i| /^(?<id>\d+).+tRNA_(?<amino_acid>...)_(?<codon>...)/.match(i)}. | |
| inject(Hash.new){|h,i| h[i[:id]] = {:amino_acid => i[:amino_acid], :codon => i[:codon]}; h} | |
| a,b = Bio::GFF::GFF3.new(File.read('assembly/annotations.gff')). | |
| records.partition{|i| trnas[i.id] } | |
| a.map! do |i| | |
| i.attributes = { | |
| 'feature_type' => 'tRNA', | |
| 'Note' => 'Codon: ' + trnas[i.id][:codon], | |
| 'product' => 'tRNA-' + trnas[i.id][:amino_acid], | |
| 'ID' => i.id} | |
| i | |
| end | |
| puts a + b | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment