class RDF::VCF::Record
VCF
file record.
This is a user-friendly wrapper for the HTSJDK implementation.
@see github.com/samtools/htsjdk @see samtools.github.io/htsjdk/javadoc/htsjdk/htsjdk/variant/variantcontext/VariantContext.html
Constants
- FALDO
- VAR_BASE_URI
Public Class Methods
new(variant_context, reader)
click to toggle source
@param [VariantContext] variant_context
# File lib/rdf/vcf/record.rb, line 26 def initialize(variant_context, reader) @vcf = variant_context @reader = reader end
Public Instance Methods
attributes()
click to toggle source
@return [Hash{String => String}]
# File lib/rdf/vcf/record.rb, line 64 def attributes @vcf.getAttributes end
chromosome()
click to toggle source
@return [String]
# File lib/rdf/vcf/record.rb, line 50 def chromosome @vcf.getChr end
file_date()
click to toggle source
@return [String]
# File lib/rdf/vcf/record.rb, line 76 def file_date @reader.file_date end
get_alleles(&block)
click to toggle source
# File lib/rdf/vcf/record.rb, line 93 def get_alleles(&block) @vcf.getAlleles.each do |allele| block.call(allele) end end
get_alternate_alleles(&block)
click to toggle source
# File lib/rdf/vcf/record.rb, line 99 def get_alternate_alleles(&block) @vcf.getAlternateAlleles.each do |allele| block.call(allele) end end
get_phred_scaled_qual()
click to toggle source
@return [Double]
# File lib/rdf/vcf/record.rb, line 118 def get_phred_scaled_qual @vcf.getPhredScaledQual end
get_reference_allele()
click to toggle source
@return [String]
# File lib/rdf/vcf/record.rb, line 106 def get_reference_allele @vcf.getReference.getBaseString end
id()
click to toggle source
@return [String]
# File lib/rdf/vcf/record.rb, line 33 def id @id ||= case (id = @vcf.getID) when '.' label = "%s:%s:%s-%s" % ['', @vcf.getChr, @vcf.getStart, @vcf.getEnd] # TODO: species ::Digest::MD5.hexdigest(label) else id end end
ref_base_uri()
click to toggle source
@return [URI]
# File lib/rdf/vcf/record.rb, line 88 def ref_base_uri @reader.ref_base_uri end
reference()
click to toggle source
@return [String]
# File lib/rdf/vcf/record.rb, line 70 def reference @reader.reference end
source()
click to toggle source
@return [String]
# File lib/rdf/vcf/record.rb, line 82 def source @reader.source end
start()
click to toggle source
# File lib/rdf/vcf/record.rb, line 54 def start @vcf.getStart end
stop()
click to toggle source
# File lib/rdf/vcf/record.rb, line 58 def stop @vcf.getEnd end
to_rdf()
click to toggle source
@return [RDF::Graph]
# File lib/rdf/vcf/record.rb, line 124 def to_rdf var_uri = RDF::URI(self.uri) RDF::Graph.new do |graph| graph << [var_uri, RDF::DC.identifier, self.id] graph << [var_uri, RDF::RDFS.label, self.id] graph << [self.ref_base_uri,DC.identifier,self.id] faldoRegion = ref_base_uri+":#{self.start}-#{self.stop}:1" graph << [var_uri,FALDO.location,faldoRegion] graph << [faldoRegion,RDFS.label,"#{self.id}:#{self.start}-#{self.stop}:1"] graph << [faldoRegion,RDF.type,FALDO.Region] graph << [faldoRegion,FALDO.begin,self.ref_base_uri+":#{self.start}:1"] graph << [faldoRegion,FALDO.end,self.ref_base_uri+":#{self.stop}:1"] graph << [faldoRegion,FALDO.reference,self.ref_base_uri] if self.start == self.stop faldoExactPosition = self.ref_base_uri+":#{self.start}:1" graph << [faldoExactPosition,RDF.type,"faldo:ExactPosition"] graph << [faldoExactPosition,RDF.type,"faldo:ForwardStrandPosition"] graph << [faldoExactPosition,FALDO.position,self.start] graph << [faldoExactPosition,FALDO.reference,self.ref_base_uri] end # TODO check if there are multiple alleles and iterate over them # TODO what happends if there is an insertion? refAlleleURI = var_uri+"\##{get_reference_allele}" graph << [var_uri,var_uri+":has_allele",refAlleleURI] graph << [refAlleleURI,RDFS.label,"#{self.id} allele #{get_reference_allele}"] graph << [refAlleleURI,RDF.type,var_uri+":reference_allele"] self.get_alternate_alleles do |altAllele| altAlleleURI = var_uri+"\##{altAllele.getBaseString}" graph << [var_uri,var_uri+":has_allele",altAlleleURI] graph << [altAlleleURI,RDFS.label,"#{self.id} allele #{altAllele.getBaseString}"] graph << [altAlleleURI, RDF.type, var_uri+":ancestral_allele"] end graph << [var_uri,URI(VAR_BASE_URI % "/vcf/quality"), RDF::Literal(get_phred_scaled_qual)] @vcf.attributes.each do |k, v| graph << [var_uri, RDF::URI( VAR_BASE_URI % "vcf/attribute\##{k}"), v] if v end end #new graph end
uri()
click to toggle source
@return [String]
# File lib/rdf/vcf/record.rb, line 44 def uri @uri ||= VAR_BASE_URI % self.id end