lib/bio/PolyploidTools/ExonContainer.rb in bio-polyploid-tools-0.7.3 vs lib/bio/PolyploidTools/ExonContainer.rb in bio-polyploid-tools-0.8.0
- old
+ new
@@ -17,19 +17,35 @@
@primer_3_min_seq_length = 50
end
def gene_models(path)
@gene_models_db = Bio::DB::Fasta::FastaFile.new({:fasta=>path})
+ @gene_models_db.index
@gene_models_path = path
end
#Returns the sequence for a region in the gene models (exon)
def gene_model_sequence(region)
- #puts region
- seq=@gene_models_db.fetch_sequence(region)
+ #puts "Region: "
+ #puts region.inspect
+ target_reg = @gene_models_db.index.region_for_entry(region.entry)
+ #puts target_reg.inspect
+ region.end = target_reg.length if region.end > target_reg.length
+ #entries[region.entry]
-
+ seq=@gene_models_db.fetch_sequence(region)
+ #puts "sequence: "
+ #This is a patch that we need to fix in biosamtools:
+ #puts seq
+ index = seq.index('>')
+ if(index )
+ index -= 1
+ #puts "Index: #{index}"
+ seq = seq.slice(0..index)
+ end
+ #puts seq
+ seq
end
#Sets the reference file for the gene models
def chromosomes(path)
@chromosomes_db = Bio::DB::Fasta::FastaFile.new({:fasta=>path})
@@ -38,14 +54,14 @@
#Retunrs the sequence for a region in the gene models (exon)
def chromosome_sequence(region)
left_pad = 0
#TODO: Padd if it goes to the right
- if(region.start < 0)
+ if(region.start < 1)
left_pad = region.start * -1
left_pad += 1
- region.start = 0
+ region.start = 1
end
str = "-" * left_pad << @chromosomes_db.fetch_sequence(region)
#str << "n" * (region.size - str.size + 1) if region.size > str.size
str
end
@@ -114,16 +130,21 @@
def print_fasta_snp_exones (file)
@missing_exons = Set.new unless @missing_exons
@snp_map.each do | gene, snp_array|
snp_array.each do |snp|
#file.puts snp.primer_fasta_string
-
+ #puts "In print_fast_np_exones"
+ #puts snp.inspect
+
begin
file.puts snp.aligned_sequences_fasta
rescue Exception=>e
@missing_exons << snp.to_s
- $stderr.puts e.to_s
+ $stderr.puts "print_fasta_snp_exones:" + snp.to_s + ":" + e.to_s
+ $stderr.puts "Local position: #{snp.local_position}"
+ $stderr.puts "Local position: #{snp.parental_sequences.to_s}"
+ $stderr.puts e.backtrace
end
end
end
end
@@ -141,11 +162,13 @@
file.puts string
added += 1
end
rescue Exception=>e
@missing_exons << snp.to_s
+ # $stderr.puts ""
- $stderr.puts e.to_s
+ $stderr.puts "print_primer_3_exons: #{e.to_s} : snp.to_s"
+ $stderr.puts e.backtrace
end
end
end
return added
end
\ No newline at end of file