class Object
Public Instance Methods
cluster_filter(gene_array,cluster,length)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 161 def cluster_filter(gene_array,cluster,length)# Elimina contigs de cluster y gene_array que tengan etiqueta de stop y solo tengan un hsp cluster.each_with_index do |contig,i| if contig.completed=='stop' if contig.hits.first.hsps.last.s_end-contig.hits.first.hsps.last.s_beg<length && contig.hits.first.hsps.count==1 cluster[i]=nil gene_array[i]=nil end end end cluster.compact! gene_array.compact! return gene_array,cluster end
coord_prot(last_contig_hsp, current_contig_hsp)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 175 def coord_prot(last_contig_hsp, current_contig_hsp) #Devuelve la diferencia de posicion de dos contigs dados en base a su posicion en la proteina add=last_contig_hsp.q_beg-current_contig_hsp.q_beg+3*(current_contig_hsp.s_beg-last_contig_hsp.s_beg) #primera parte del sumando representa la diferencia debida a la longitud de los contigs, la segunda parte representa la diferencia de tamaño del hsp return add end
fasta_hash(path)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 180 def fasta_hash(path) parse_seqs=FastaFile.new(path) seqs={} parse_seqs.each do |contig,seq_fasta| seqs[contig]=seq_fasta end return seqs end
html_header(file,title)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 189 def html_header(file,title) file.puts '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">', '<head>', '<meta http-equiv="content-type" content="text/html;charset=UTF-8" />', '<title>'+title+'</title>', '</head>', '<body>' end
html_link(text, link)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 221 def html_link(text, link) text_linked='<a href="'+link+'">'+text.to_s+'</a>' return text_linked end
html_row(file, cells)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 213 def html_row(file, cells) #Cells muts be a array file.puts '<tr>' cells.each do |cell| file.puts "<td>#{cell}</td>" end file.puts '</tr>' end
html_table_header(file, border, headers)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 204 def html_table_header(file, border, headers) #headers es un array file.puts '<table border="'+border.to_s+'">', '<tr>' headers.each do |header| file.puts '<th>'+header+'</th>' end file.puts '</tr>' end
length2D(array)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 77 def length2D(array) # Devuelve la longitud maxima que tenga un conjunto de arrays length=0 array.each do |item| item_length=item.length if item_length>length length=item_length end end return length end
mapping(contigs,gene_array,map_path)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 3 def mapping(contigs,gene_array,map_path) #Relaciona un archivo sam con un contig, cuantifica nº lecturas por exon # Mapping #-------------------------------------------------------------- contigs.each do |contig| ruta=File.join(map_path,"#{contig.name}.sam") # Parse mapping & exon valoration #-------------------------------------------------------------- seq_map=[] n_reads=0 if File.exists?(ruta) contig.length.times do |x| seq_map << 0 end map_file=File.open(File.join(ruta), 'r') map_file.each do |line| fields=line.split if fields[0]!~/[@]/ n_reads+=1 #puts "#{fields[3]}\t#{fields[5]}" start_map=fields[3].to_i-1 end_map=start_map-1 fields[5].split(/[^\d]/).each{|e| end_map+=e.to_i} #puts "#{start_map}\t#{end_map}" #puts seq_map[start_map..end_map].inspect seq_map.each_with_index do |item,a| if a>=start_map seq_map[a]+=1 end if a>end_map break end end end end #puts seq_map.inspect # Exon valoration #----------------------------------------------------------- exon_stadistic=[] contig.hits.first.hsps.each do |hsp| exon=seq_map[hsp.q_beg-1..hsp.q_end-1] value=0 exon.each{|e| value+=e} exon_stadistic << (value*100.0/n_reads/exon.length).round(2) end #puts exon_stadistic.inspect y=contigs.index(contig) x=gene_array[y].index(1) exon_stadistic.each_with_index do |item,b| gene_array[y][x+b]=item end seq_map=[] end end #end contigs.each if $verbose puts "\nGENE ARRAY - EXON VALUATED" gene_array.each_with_index do |fila,c| print "#{contigs[c].name.center(24)} " fila.each do |item| print "#{item.to_s}\t" end puts "\n" end end contigs.each do |contig| puts '...................' contig.indices end puts "\n" end
parse_contig_index(gene_array,contigs)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 88 def parse_contig_index(gene_array,contigs) #Comprueba codones start- stop en contigs que contengan el primer o el ultimo exon exons_model=length2D(gene_array) gene_array.each_with_index do |contig,i| start=nil #Desconocido if contig.first >0 #Comprueba si el contig tiene el primer exon start=contigs[i].start_codon_search end stop=nil #desconocido #if contig.length==exons_model #Comprueba si el contig posee el ultimo exon stop=contigs[i].stop_codon_search #end if start==TRUE && stop==TRUE contigs[i].completed=TRUE elsif start==TRUE contigs[i].completed='start' elsif stop==TRUE contigs[i].completed='stop' else contigs[i].completed=FALSE end end end
sides_add(contigs,start,stop)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 137 def sides_add(contigs,start,stop) #Añade contigs con señal de stop-start si no existen en el array contigs beg=TRUE ends=TRUE contigs.each do |contig| if contig.completed=='start'||contig.completed==TRUE beg=FALSE end if contig.completed=='stop'||contig.completed==TRUE ends=FALSE end end if beg && !start.nil? b=[] b << start contigs=b.concat(contigs) end if ends && !stop.nil? e=[] e << stop contigs.concat(e) end return contigs end
sides_recovery(contigs)
click to toggle source
# File lib/gene_assembler/other_functions.rb, line 111 def sides_recovery(contigs) # Toma de un conjunto de contigs un contig con señal de stop y un contig con señal de inicio start=nil stop=nil contigs.each do |contig| if contig.completed=='start' if start.nil? start=contig else if start.hits.first.hsps.first.score<contig.hits.first.hsps.first.score start=contig end end end if contig.completed=='stop' if stop.nil? stop=contig else if stop.hits.first.hsps.first.score<contig.hits.first.hsps.first.score stop=contig end end end end return start,stop end