Sha256: 2539a5f67543ab4127f3a8475c37c722cb9d85e37b09ce04de109918d560e1d3

Contents?: true

Size: 1.41 KB

Versions: 20

Compression:

Stored size: 1.41 KB

Contents

module Bio::PolyploidTools
  
  class ChromosomeArm
    attr_accessor :name
    attr_reader :genes
    attr_reader :loaded_entries
    attr_reader :fasta_db

    def initialize(name, path_to_fasta)
      @name = name
      @fasta_db = Bio::DB::Fasta::FastaFile.new({:fasta=>path_to_fasta})
      #$stderr.puts "Loading entries for #{name}"
      
      @genes = Hash.new
    end
    
    def fetch_contig(contig_id)
      
      @fasta_db.load_fai_entries unless @loaded_entries
      @loaded_entries = true
      entry = fasta_db.index.region_for_entry(contig_id)
     # puts entry
      @fasta_db.fetch_sequence(entry.get_full_region)
    end
    #Loads all the chromosome arms in a folder. 
    #The current version requires that all the references end with .fa, and start with XXX_*.fa
    #Where XXX is the chromosome name
    def self.load_from_folder(path_to_contigs)
      chromosomeArms = Hash.new
      
      Dir.foreach(path_to_contigs) do |filename |
        
        if  File.fnmatch("*.fa", filename)
          
          parsed = /^(?<arm>\d\w+)/.match(filename)
         
          target="#{path_to_contigs}/#{filename}"
          
         
         
         # fasta_file = Bio::DB::Fasta::FastaFile.new(target)
          #fasta_file.load_fai_entries
          arm = ChromosomeArm.new(parsed[:arm], target)
          chromosomeArms[arm.name] = arm
        end
      end
      return chromosomeArms
    end
    
  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bio-polyploid-tools-0.7.3 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.7.2 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.7.1 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.7.0 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.6.1 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.6.0 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.5.2 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.5.1 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.5.0 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.4.7 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.4.6 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.4.5 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.4.4 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.4.3 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.4.2 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.4.1 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.4.0 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.3.3 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.3.1 lib/bio/PolyploidTools/ChromosomeArm.rb
bio-polyploid-tools-0.2.3 lib/bio/PolyploidTools/ChromosomeArm.rb