Assignment 3/assignment3.rb
# 5. creating a gff3 file for all repeat regions: chromosomes as seqname and positions inside the chromosome
5. creating a gff3 file for all repeat regions: chromosomes as seqname and positions inside the chromosome
5 . creating a gff3 file for all repeat regions : chromosomes as seqname and positions inside the chromosome
def gff3_file_chr(file) 
  File.open(file, 'w') do |line|
  line.puts "##gff-version 3\n"
  @all_biosequence.each do |gene, biosequence|
    start_gene = biosequence.primary_accession.split(":")[3]
    chr = biosequence.entry_id
    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_in_gene = loc.from.to_i
        start_in_chr = start_gene.to_i + start_in_gene
        finish_in_gene = loc.to.to_i
        finish_in_chr = start_gene.to_i + finish_in_gene
        line.puts "Chr#{chr}\t#{source}\t#{type}\t#{start_in_chr}\t#{finish_in_chr}\t#{score}\t#{strand}\t#{phase}\t#{attributes}\n"
      end 
    end
  end
end
end
def gff3_file_chr ( file ) File . open ( file , 'w' ) do | line | line . puts "##gff-version 3\n" @all_biosequence . each do | gene , biosequence | start_gene = biosequence . primary_accession . split ( ":" ) [ 3 ] chr = biosequence . entry_id 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_in_gene = loc . from . to_i start_in_chr = start_gene . to_i + start_in_gene finish_in_gene = loc . to . to_i finish_in_chr = start_gene . to_i + finish_in_gene line . puts "Chr#{chr}\t#{source}\t#{type}\t#{start_in_chr}\t#{finish_in_chr}\t#{score}\t#{strand}\t#{phase}\t#{attributes}\n" end end end end end
5. creating a gff3 file for all repeat regions: chromosomes as seqname and positions inside the chromosome
5 . creating a gff3 file for all repeat regions : chromosomes as seqname and positions inside the chromosome
# The first line of a GFF3 file must be a comment that identifies the version # primary_accession method gives the primary accession number (i.e. chromosome:TAIR10:3:5506931:5508414:1) # separating them by ':' and select 3 column --> start position of gene inside the chromosome  # number of chromosome  # same as before  # next iteration if the name of the feature is not "myrepeat" # start position of CTTCTT inside the gene  # start position of CTTCTT inside the chromosome # end position of CTTCTT inside the gene # start position of CTTCTT inside the chromosome
file
<not_specific>