Assignment 3/assignment3.rb
# 4. creating a gff3 file for all repeat regions: genes as seqname and positions inside the gene
4. creating a gff3 file for all repeat regions: genes as seqname and positions inside the gene
4 . creating a gff3 file for all repeat regions : genes as seqname and positions inside the gene
def gff3_file_genes(file)
  File.open(file, 'w') do |line|
  line.puts "##gff-version 3\n"
  @all_biosequence.each do |gene, biosequence|
    biosequence.features.each do |feature|
      next unless feature.feature == "myrepeat"
      source = "BioRuby"
      qualifiers = feature.assoc
      type = qualifiers.key('CTTCTT')
      score = '.'
      strand = qualifiers['strand']
      phase = '.'
      attributes = '.'
      locations = feature.locations
      location = locations.locations
      location.each do |loc|
        start = loc.from
        finish = loc.to
        line.puts "#{gene}\t#{source}\t#{type}\t#{start}\t#{finish}\t#{score}\t#{strand}\t#{phase}\t#{attributes}\n"
      end 
    end
  end
end
end
def gff3_file_genes ( file ) File . open ( file , 'w' ) do | line | line . puts "##gff-version 3\n" @all_biosequence . each do | gene , biosequence | biosequence . features . each do | feature | next unless feature . feature == "myrepeat" source = "BioRuby" qualifiers = feature . assoc type = qualifiers . key ( 'CTTCTT' ) score = '.' strand = qualifiers [ 'strand' ] phase = '.' attributes = '.' locations = feature . locations location = locations . locations location . each do | loc | start = loc . from finish = loc . to line . puts "#{gene}\t#{source}\t#{type}\t#{start}\t#{finish}\t#{score}\t#{strand}\t#{phase}\t#{attributes}\n" end end end end end
4. creating a gff3 file for all repeat regions: genes as seqname and positions inside the gene
4 . creating a gff3 file for all repeat regions : genes as seqname and positions inside the gene
# open a file and write it line by line # The first line of a GFF3 file must be a comment that identifies the version # iterating over the hash for each key (AGI locus code) and value (Bio::Sequence object) # iterating over each Bio::Feature object # next iteration if the name of the feature is not "myrepeat" ## defining variables (each gff3 column) # source will be always BioRuby # Hash constructed from qualifier objects # type will be the key of CTTCTT value # don't care about the score # strand will be the value of 'strand' key # don't care about the phase # don't care about the attributes # creates Bio::Locations object # creates an array of Bio::Location objects # iterating over the array # start position  # end position # writting the 9 col., tab-separated format for each repeat with predefined variables 
file
<not_specific>