On Nov 4, 2012, at 14:15 , Henry Maddocks <hmaddocks / me.com> wrote:

>=20
> On 5/11/2012, at 10:35 AM, Marcelo Laia <marcelolaia / gmail.com> wrote:
>=20
> It's telling you what the problem is.
>=20
>> # search for xac + hypothetical
>> xac =3D serv.bfind("T00084 hypothetical")
>> # get the IDS into an array
>> ids =3D xac.map { |gene| $1 if gene =3D~/^(.*?)\s+/ }
>> # retrieve fasta and print
>> ids.each { |id| puts serv.bget("-f -n 1 #{id}") }
>> -----CODE END HERE--------
>>=20
>=20
>> /home/marcelo/bin/scripts/get_fasta4:10:in `<main>': undefined method
>> `map' for #<String:0x87a9f38> (NoMethodError)
>=20
>=20
> xac is a String which doesn't have a method 'map'. 'map' expects an =
Array.

#map is a member of Enumerable, not just Array. String used to be =
Enumerable in 1.8-, but it isn't in 1.9+

10000 % irb
>> String.ancestors
=3D> [String, Enumerable, Comparable, Object, Kernel]
10001 % irb19
>> String.ancestors
=3D> [String, Comparable, Object, Kernel, BasicObject]

> You can either force xac to be an Array=85
>=20
> ids =3D Array(xac).map { |gene| $1 if gene =3D~/^(.*?)\s+/ }

xac.lines.map is clearer.

There should probably also be a #compact since the regexp could =
potentially not match.