Class: Bio::Jaspar::Motif

Inherits:
Motifs::Motif
  • Object
show all
Defined in:
lib/bio-jaspar/jaspar.rb

Overview

Additional metadata information are stored if available. The metadata availability depends on the source of the JASPAR motif (a ‘pfm’ format file, a ‘jaspar’ format file or a JASPAR database).

A direct import of Bio.motifs.jaspar module in Biopython

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matrix_id, name, opts = {}) ⇒ Motif

Construct a JASPAR Motif instance



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
# File 'lib/bio-jaspar/jaspar.rb', line 43

def initialize(matrix_id, name, opts = {})
	opts = {
		:alphabet => DNA, 
		:instances => nil, 
		:counts => nil, 
		:collection => nil, 
		:tf_class => nil, 
		:tf_family => nil, 
		:species => nil, 
		:tax_group => nil, 
		:acc => nil, 
		:data_type => nil, 
		:medline => nil, 
		:pazar_id => nil, 
		:comment => nil
	}.merge(opts)

	super(opts[:alphabet], opts[:instances], opts[:counts])

	@name = name
	@matrix_id = matrix_id
	@collection = opts[:collection]
	@tf_class = opts[:tf_class]
	@tf_family = opts[:tf_family]
	@species = opts[:species]
	@tax_group = opts[:tax_group]
	@acc = opts[:acc]
	@data_type = opts[:data_type]
	@medline = opts[:medline]
	@pazar_id = opts[:pazar_id]
	@comment = opts[:comment]
end

Instance Attribute Details

#accObject

Returns the value of attribute acc.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def acc
  @acc
end

#collectionObject

Returns the value of attribute collection.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def collection
  @collection
end

#commentObject

Returns the value of attribute comment.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def comment
  @comment
end

#data_typeObject

Returns the value of attribute data_type.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def data_type
  @data_type
end

#matrix_idObject

Returns the value of attribute matrix_id.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def matrix_id
  @matrix_id
end

#medlineObject

Returns the value of attribute medline.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def medline
  @medline
end

#pazar_idObject

Returns the value of attribute pazar_id.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def pazar_id
  @pazar_id
end

#speciesObject

Returns the value of attribute species.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def species
  @species
end

#tax_groupObject

Returns the value of attribute tax_group.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def tax_group
  @tax_group
end

#tf_classObject

Returns the value of attribute tf_class.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def tf_class
  @tf_class
end

#tf_familyObject

Returns the value of attribute tf_family.



38
39
40
# File 'lib/bio-jaspar/jaspar.rb', line 38

def tf_family
  @tf_family
end

Instance Method Details

#==(other) ⇒ Object

Compare two JASPAR motifs for equality. Two motifs are equal if their matrix_ids match



150
151
152
# File 'lib/bio-jaspar/jaspar.rb', line 150

def ==(other)
	return @matrix_id == other.matrix_id
end

#base_idObject

Return the JASPAR base matrix ID



77
78
79
80
# File 'lib/bio-jaspar/jaspar.rb', line 77

def base_id
	base_id, _ = Jaspar.split_jaspar_id(@matrix_id)
	return base_id
end

#hashObject

Note: We assume the unicity of matrix IDs



144
145
146
# File 'lib/bio-jaspar/jaspar.rb', line 144

def hash
	return @matrix_id.hash
end

#to_sObject

We choose to provide only the filled metadata information.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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
136
137
138
139
# File 'lib/bio-jaspar/jaspar.rb', line 91

def to_s
	tf_name_str = "TF name\t#{@name}\n"
	matrix_id_str = "Matrix ID\t#{@matrix_id}\n"
	the_string = tf_name_str + matrix_id_str

	if @collection
		collection_str = "Collection\t#{@collection}\n"
		the_string += collection_str
	end
     if @tf_class
       tf_class_str = "TF class\t#{@tf_class}\n"
       the_string += tf_class_str
     end
     if @tf_family
       tf_family_str = "TF family\t#{@tf_family}\n"
       the_string += tf_family_str
     end
     if @species
       species_str = "Species\t#{@species.join(",")}\n"
       the_string += species_str
     end
     if @tax_group
       tax_group_str = "Taxonomic group\t#{@tax_group}\n"
       the_string += tax_group_str
     end
     if @acc
       acc_str = "Accession\t#{@acc}\n"
       the_string += acc_str
     end
     if @data_type
       data_type_str = "Data type used\t#{@data_type}\n"
       the_string += data_type_str
     end
     if @medline
       medline_str = "Medline\t#{@medline}\n"
       the_string += medline_str
     end
     if @pazar_id
       pazar_id_str = "PAZAR ID\t#{@pazar_id}\n"
       the_string += pazar_id_str
     end
     if @comment
       comment_str = "Comments\t#{@comment}\n"
       the_string += comment_str
     end
     matrix_str = "Matrix:\n#{counts}\n\n"
     the_string += matrix_str
     return the_string
end

#versionObject

Return the JASPAR matrix version



83
84
85
86
# File 'lib/bio-jaspar/jaspar.rb', line 83

def version
	_, version = Jaspar.split_jaspar_id(@matrix_id)
	return version
end