Integrating awk in Python

2009-01-16 Thread Alfons Nonell-Canals
Hello,
I'm developing a software package using python. I've programmed all
necessary tools but I have to use other stuff from other people. Most of
these external scripts are developed using awk.

At the beggining I thought to "translate" them and program them in
python but I prefer to avoid it because it means a lot of work and I
should do it after each new version of this external stuff. I would like
to integrate them into my python code.

I know I can call them using the system environment but it is slower
than if I call them inside the package. I know it is possible with C, do
you have experience on integrate awk into python calling these awk
scripts from python?

Thanks in advance!

Regards,
Alfons.


-- 
----
Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
alfons.non...@upf.edu - http://cgl.imim.es
Tel. +34933160528

http://alfons.elmeuportal.cat
http://www.selenocisteina.info
--
http://mail.python.org/mailman/listinfo/python-list


Install modules with no root privilegies

2008-11-24 Thread Alfons Nonell-Canals
Hello,
Install python modules in a linux computer is really easy, it is because
the module is a package of the distribution or because the python
installation is really easy. But, in both situations, you need root
privilegies.

I would like to know how to install modules only for one user, with no
root privilegies. Do you know if it is possible and easy. I would like
to add that i need some modules only for my user and incly for one
progam.

Thanks in advance!

Alfons.

-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
[EMAIL PROTECTED] - http://cgl.imim.es
Tel. +34933160528

http://alfons.elmeuportal.cat
http://www.selenocisteina.info

--
http://mail.python.org/mailman/listinfo/python-list


Idenfity numbers in variables

2008-10-20 Thread Alfons Nonell-Canals
Hello,
I have a trouble and I don't know how to solve it. I am working with
molecules and each molecule has a number of atoms. I obtain each atom
spliting the molecule.

Ok. It is fine and I have no problem with it.

The problem is when I have to work with these atoms. These atoms usually
are only a letter but, sometimes it can also contain one o more numbers.
If they contein a number I have to manipulate them separately.

If the number was allways the same I know how to identify them, for
example, 1:

atom = 'C1'

if '1' in atom:
print 'kk'

But, how can I do to identify in '1' all possibilities from 1-9, I
tried:

if '[1-9]', \d,...

Any comments, please?

Regards,

Alfons.


-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Parc de Recerca Biomèdica de Barcelona (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
[EMAIL PROTECTED] - http://cgl.imim.es

http://alfons.elmeuportal.cat
http://www.selenocisteina.info

--
http://mail.python.org/mailman/listinfo/python-list


mySQL problems

2008-10-28 Thread Alfons Nonell-Canals
Hello,
I've developed a program using python that have to connect to a mysql
server several times.

In a local machine (running the program in the same machine where the
mysql server is) I have no problems. I can run several instances of the
program at the same time with no problem.

Them problem arrives when I try to distribute the tasks to different
machines, for example, in a cluster. In this situation, the machine that
runs the python program is different than the machine that hosts the
database. 

If I run the python program only an other machine, only one run of the
program, there is no problem. But, If I run the program in different
machines, all of them connecting to the same database server, randomly,
it crash. Crash all running programs! at the same time.

The output is clear:

  File "/cgl/programs/ChemBang/config.py", line 67, in mysql
db = MySQLdb.connect(host=HOST, user="USER",
passwd="PASSWD",db="DATABASE")
  File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line
74, in Connect

  File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 170,
in __init__
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL
server on 'HOST' (110)")


It is clearly related with the connection to the mySQL server. As I
said, it only happens when there are more than one programs running in
different machines (or in the same) but conecting to a mysql server that
is in an other machine. And... it is random, sometimes happens and
sometimes no...

Any idea?

Thanks!

Regards,
Alfons.

-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
[EMAIL PROTECTED] - http://cgl.imim.es
Tel. +34933160528

http://alfons.elmeuportal.cat
http://www.selenocisteina.info

--
http://mail.python.org/mailman/listinfo/python-list


Re: mySQL problems

2008-10-28 Thread Alfons Nonell-Canals
Hi,


> Maybe there is a certain connection limit which hits if your client
> programms reconnect in random order? I saw this on some PHP web sites.
> 
> Probably some configuration adjustments and persistent connections
> could help you in this situation.

I know I can check it but I am not the admin of the server where the
mySQL server is and before to check it with the sysadmin I would like to
discard other possibilities (they ask me to do this before) :-(

> Also, was the choice of MySQL a conscious one?

Yes, the choice of MySQL is conscious because I have to manage huge
amounts of data and I already have some experience in mySQL which makes
it easier.

Regards,
Alfons.


> 
> Regards
> Tino
-- 
----
Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
[EMAIL PROTECTED] - http://cgl.imim.es
Tel. +34933160528

http://alfons.elmeuportal.cat
http://www.selenocisteina.info

--
http://mail.python.org/mailman/listinfo/python-list


Generate documentation for a Python developed software

2008-09-29 Thread Alfons Nonell-Canals
Dear all,
I have a complex program developed using Python. It contains lot of
files and classes. 

Now I have the lazy task to documentate it. I have some notes about is
class but I would like to know if there is something to auto-generate
the doucmentation with the program code. I know I will have to explain
each class and variable but, if an external software canprepare it, the
template, it will be great!

Thanks in advance!

Regards,

-- 

Alfons Nonell-Canals
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Parc de Recerca Biomèdica de Barcelona (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
[EMAIL PROTECTED] - http://cgl.imim.es

http://alfons.elmeuportal.cat
http://www.selenocisteina.info

--
http://mail.python.org/mailman/listinfo/python-list

PSP problem showing images

2009-10-27 Thread Alfons Nonell-Canals
Hello,
I have experience working with Python an dnow I would like to use it for
web development. I worked with php from several years ago and I'm trying
to move to PSP. I have no problem runing some tests, implement an small
project with psp is pretty easy. But I have only one problem, me scrips
don't show any image.

I developed a script which generates some images (is a work about
Chemistry) and returns a page with some results and these images. When I
run the script from the web browser, "all" works fine: the images are
created, some other staff is calculated and the final page with the
results is fine except the images. It does not print the images! I chech
the paths and all is fine.

With it I thought tha maybe there is something wrong in the apache's
configuration. And I'm almost sure the problem is there because the
Handler used only manages .psp documents. I add some code to not apply
the Handler to .png but... help?

Do you have any idea/experience?

Below is the configuration of the host...


ServerAdmin u...@domain.com
ServerName  www.domain.com
ServerAlias domain.com

# Indexes + Directory Root.
DirectoryIndex index.psp
DocumentRoot /path/to/the/pages

AddHandler mod_python .psp
PythonHandler mod_python.psp
PythonDebug On

Sethandler None


 


# Logfiles
ErrorLog  /var/log/apache2/domain.com-error.log
CustomLog /var/log/apache2/domain.com-access.log combined



Thanks in advance!

Regards,
Alfons.


-- 
----
Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
alfons.non...@upf.edu - http://cgl.imim.es
Tel. +34933160528
 
http://alfons.elmeuportal.cat
http://www.selenocisteina.info

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSP problem showing images

2009-10-27 Thread Alfons Nonell-Canals
Hi Lawrence,
Yes, I've tried it! I've saw the code, copyed the src path ans pasted
into the browser and it works. I think it not works only unther a psp
hostname/directory, for this reason I thought the problem is in the
apache2 (site) configuration pasted in my mail...

Thanks!
Alfons.



Lawrence D'Oliveiro wrote:
> In message , Alfons 
> Nonell-Canals wrote:
>
>   
>> I developed a script which generates some images (is a work about
>> Chemistry) and returns a page with some results and these images. When I
>> run the script from the web browser, "all" works fine: the images are
>> created, some other staff is calculated and the final page with the
>> results is fine except the images. It does not print the images! I chech
>> the paths and all is fine.
>> 
>
> Did you view source to check the URLs in the “” directives? 
> Did you try copying and pasting the image URLs directly into new 
> windows/tabs, to see if they came up or you got an error page instead?
>   

-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
alfons.non...@upf.edu - http://cgl.imim.es
Tel. +34933160528
 
http://alfons.elmeuportal.cat
http://www.selenocisteina.info

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSP problem showing images

2009-10-29 Thread Alfons Nonell-Canals
Anybody of you have any idea?

Alfons Nonell-Canals wrote:
> Hi Lawrence,
> Yes, I've tried it! I've saw the code, copyed the src path ans pasted
> into the browser and it works. I think it not works only unther a psp
> hostname/directory, for this reason I thought the problem is in the
> apache2 (site) configuration pasted in my mail...
>
> Thanks!
> Alfons.
>
>
>
> Lawrence D'Oliveiro wrote:
>   
>> In message , Alfons 
>> Nonell-Canals wrote:
>>
>>   
>> 
>>> I developed a script which generates some images (is a work about
>>> Chemistry) and returns a page with some results and these images. When I
>>> run the script from the web browser, "all" works fine: the images are
>>> created, some other staff is calculated and the final page with the
>>> results is fine except the images. It does not print the images! I chech
>>> the paths and all is fine.
>>> 
>>>   
>> Did you view source to check the URLs in the “” directives? 
>> Did you try copying and pasting the image URLs directly into new 
>> windows/tabs, to see if they came up or you got an error page instead?
>>   
>> 
>
>   

-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
alfons.non...@upf.edu - http://cgl.imim.es
Tel. +34933160528
 
http://alfons.elmeuportal.cat
http://www.selenocisteina.info

-- 
http://mail.python.org/mailman/listinfo/python-list


Combining sets/dictionaries

2009-09-22 Thread Alfons Nonell-Canals
Hello,
I have different sets/dictionaries/lists (whatever you want because I
can convert them easily) and I would like to combine them. I don't want
a consensus and something like it. I'd need to combine all elements of
the first one with the all elements of the second one and third,... the
numbers of dictionaries/sets/lists is variable as the number of elements
for each one.

For example, i have the following sets and I would like to obtain all
possible combinations...

['I', 'O', 'N', 'P', 'S', 'C']
['I', 'O', 'N', 'P', 'S', 'C']
['I', 'O', 'N', 'P', 'S', 'C']
['I', 'N', 'P', 'S', 'C']
['I', 'N', 'P', 'S', 'C']
['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
['I', 'O', 'N', 'P', 'S', 'C']
['I', 'O', 'N', 'P', 'S', 'C']
['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']

And it should be flexible because as I've said, the number of
dictionaries/lists/sets is not always the same, as the number of elements.

I don't like to ask this kid of questions but... today I'm totally lost
and I need it to close one part of a nice project...

Thanks in advance!

Best regards,
Alfons.





-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
alfons.non...@upf.edu - http://cgl.imim.es
Tel. +34933160528
 
http://alfons.elmeuportal.cat
http://www.selenocisteina.info

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combining sets/dictionaries

2009-09-22 Thread Alfons Nonell-Canals
Hello,
finally I've solved it using a "combinatorics" library which allows to
do this kind of things.

Here, here is an example:

   
http://automatthias.wordpress.com/2007/04/28/cartesian-product-of-multiple-sets/


Thanks for your suggestions.


Regards,
Alfons.

Carl Banks wrote:
> On Sep 22, 3:08 am, Alfons Nonell-Canals 
> wrote:
>   
>> Hello,
>> I have different sets/dictionaries/lists (whatever you want because I
>> can convert them easily) and I would like to combine them. I don't want
>> a consensus and something like it. I'd need to combine all elements of
>> the first one with the all elements of the second one and third,... the
>> numbers of dictionaries/sets/lists is variable as the number of elements
>> for each one.
>>
>> For example, i have the following sets and I would like to obtain all
>> possible combinations...
>>
>> ['I', 'O', 'N', 'P', 'S', 'C']
>> ['I', 'O', 'N', 'P', 'S', 'C']
>> ['I', 'O', 'N', 'P', 'S', 'C']
>> ['I', 'N', 'P', 'S', 'C']
>> ['I', 'N', 'P', 'S', 'C']
>> ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
>> ['I', 'O', 'N', 'P', 'S', 'C']
>> ['I', 'O', 'N', 'P', 'S', 'C']
>> ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
>> 
>
> This is the input.  What do you want the output to look like given
> this input?
>
> I can't really tell exactly what you mean by "all combinations", there
> are different ways to combine sequences, and it doesn't sound like you
> mean the formal mathematical definition of "combination".
>
> My best guess is that you want something like this.
>
> def all_union(seqs):
> s = set()
> for seq in seqs:
> s.update(seq)
> return s
>
>
> Carl Banks
>   

-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
alfons.non...@upf.edu - http://cgl.imim.es
Tel. +34933160528
 
http://alfons.elmeuportal.cat
http://www.selenocisteina.info

-- 
http://mail.python.org/mailman/listinfo/python-list