Top Level Namespace
Defined Under Namespace
Modules: GeneAssembler Classes: BlastTypeParser, Contig, Dataset, ExoBlastQuery, ExonerateResult, Feature, GO, GffContig, GffFrameshift, GffGo, GffHit, GffHsp, GffSNP, GffStop, Gff_dataset, Gff_parser, Hit, Hsp, Localization, Master_feature, Parser, ParserBlast, ParserExonerate, Rebuild, Report, ReportGff, SNP
Instance Method Summary collapse
-
#cluster_filter(gene_array, cluster, length) ⇒ Object
Elimina contigs de cluster y gene_array que tengan etiqueta de stop y solo tengan un hsp.
-
#coord_prot(last_contig_hsp, current_contig_hsp) ⇒ Object
Devuelve la diferencia de posicion de dos contigs dados en base a su posicion en la proteina.
- #fasta_hash(path) ⇒ Object
- #html_footer(file) ⇒ Object
- #html_header(file, title) ⇒ Object
- #html_link(text, link) ⇒ Object
-
#html_row(file, cells) ⇒ Object
Cells muts be a array.
- #html_table_footer(file) ⇒ Object
-
#html_table_header(file, border, headers) ⇒ Object
headers es un array.
-
#length2D(array) ⇒ Object
Devuelve la longitud maxima que tenga un conjunto de arrays.
-
#mapping(contigs, gene_array, map_path) ⇒ Object
Relaciona un archivo sam con un contig, cuantifica nº lecturas por exon.
-
#parse_contig_index(gene_array, contigs) ⇒ Object
Comprueba codones start- stop en contigs que contengan el primer o el ultimo exon.
-
#sides_add(contigs, start, stop) ⇒ Object
Añade contigs con señal de stop-start si no existen en el array contigs.
-
#sides_recovery(contigs) ⇒ Object
Toma de un conjunto de contigs un contig con señal de stop y un contig con señal de inicio.
Instance Method Details
#cluster_filter(gene_array, cluster, length) ⇒ Object
Elimina contigs de cluster y gene_array que tengan etiqueta de stop y solo tengan un hsp
161 162 163 164 165 166 167 168 169 170 171 172 173 |
# 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) ⇒ Object
Devuelve la diferencia de posicion de dos contigs dados en base a su posicion en la proteina
175 176 177 178 |
# 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) ⇒ Object
180 181 182 183 184 185 186 187 |
# 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_footer(file) ⇒ Object
199 200 201 202 |
# File 'lib/gene_assembler/other_functions.rb', line 199 def (file) file.puts '</body>', '</html>' end |
#html_header(file, title) ⇒ Object
189 190 191 192 193 194 195 196 197 |
# 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) ⇒ Object
221 222 223 224 |
# 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) ⇒ Object
Cells muts be a array
213 214 215 216 217 218 219 |
# 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_footer(file) ⇒ Object
226 227 228 |
# File 'lib/gene_assembler/other_functions.rb', line 226 def (file) file.puts '</table>' end |
#html_table_header(file, border, headers) ⇒ Object
headers es un array
204 205 206 207 208 209 210 211 |
# 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) ⇒ Object
Devuelve la longitud maxima que tenga un conjunto de arrays
77 78 79 80 81 82 83 84 85 86 |
# 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) ⇒ Object
Relaciona un archivo sam con un contig, cuantifica nº lecturas por exon
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# 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) ⇒ Object
Comprueba codones start- stop en contigs que contengan el primer o el ultimo exon
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# 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) ⇒ Object
Añade contigs con señal de stop-start si no existen en el array contigs
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# 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) ⇒ Object
Toma de un conjunto de contigs un contig con señal de stop y un contig con señal de inicio
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# 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 |