I am new to python and I am not in computer science. In fact I am a biologist and I ma trying to learn python. So if someone can help me, I will appreciate it.
Thanks
#!/cbi/prg/python/current/bin/python
# -*- coding: iso-8859-1 -*-
import sys
import os
from progadn import *
ab1seq = raw_input("Entrez le répertoire où sont les fichiers à analyser: ") or None
if ab1seq == None :
print "Erreur: Pas de répertoire! \n"
"\nAu revoir \n"
sys.exit()
listrep = os.listdir(ab1seq)
#print listrep
extseq=[]
for f in listrep:
if f[-4:]==".Seq":
extseq.append(f)
# print extseq
for x in extseq:
f = open(x, "r")
seq=f.read()
f.close()
s=seq
def checkDNA(seq):
"""Retourne une liste des caractères non conformes à l'IUPAC."""
junk=[]
for c in range (len(seq)):
if seq[c] not in iupac:
junk.append([seq[c],c])
#print junk
print "ATTN: Il y a le caractère %s en position %s " % (seq[c],c)
if junk == []:
indinv=range(len(seq))
indinv.reverse()
resultat=""
for i in indinv:
resultat +=comp[seq[i]]
return resultat
seq=checkDNA(seq)
print seq
#I got the following ( as you see only one file is proceed by the function even if more files is in extseq
['B1-11_win3F_B04_04.ab1.Seq']
['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq']
['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq', 'B1-18_win3F_D04_08.ab1.Seq']
['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq', 'B1-18_win3F_D04_08.ab1.Seq', 'B1-18_win3R_E04_10.ab1.Seq']
['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq', 'B1-18_win3F_D04_08.ab1.Seq', 'B1-18_win3R_E04_10.ab1.Seq', 'B1-19_win3F_F04_12.ab1.Seq']
...
['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq', 'B1-18_win3F_D04_08.ab1.Seq', 'B1-18_win3R_E04_10.ab1.Seq', 'B1-19_win3F_F04_12.ab1.Seq', 'B1-19_win3R_G04_14.ab1.Seq', 'B90_win3F_H04_16.ab1.Seq', 'B90_win3R_A05_01.ab1.Seq', 'DL2-11_win3F_H03_15.ab1.Seq', 'DL2-11_win3R_A04_02.ab1.Seq', 'DL2-12_win3F_F03_11.ab1.Seq', 'DL2-12_win3R_G03_13.ab1.Seq', 'M7757_win3F_B05_03.ab1.Seq', 'M7757_win3R_C05_05.ab1.Seq', 'M7759_win3F_D05_07.ab1.Seq', 'M7759_win3R_E05_09.ab1.Seq', 'TCR700-114_win3F_H05_15.ab1.Seq', 'TCR700-114_win3R_A06_02.ab1.Seq', 'TRC666-100_win3F_F05_11.ab1.Seq', 'TRC666-100_win3R_G05_13.ab1.Seq']
after this listing my programs proceed only the last element of this listing (TRC666-100_win3R_G05_13.ab1.Seq)
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTCCCGAAGTGTCCCAGAGCA AATAAATGGACCAAAACGTTTTTAGAATACTTGAACGTGTAATCTCATTT TAA 3 1478
<m_t...@yahoo.com> wrote: I am new to python and I am not in computer science. In fact I am a
biologist and I ma trying to learn python. So if someone can help me, I
will appreciate it. Thanks
#!/cbi/prg/python/current/bin/python # -*- coding: iso-8859-1 -*- import sys import os from progadn import *
ab1seq = raw_input("Entrez le répertoire où sont les fichiers à
analyser: ") or None if ab1seq == None : print "Erreur: Pas de répertoire! \n" "\nAu revoir \n" sys.exit()
listrep = os.listdir(ab1seq) #print listrep
extseq=[]
for f in listrep:
###### Minor -- this is better said as: if f.endswith(".Seq"): if f[-4:]==".Seq": extseq.append(f) # print extseq
for x in extseq: f = open(x, "r")
###### seq=... discards previous data and refers only to that just
read.
###### It would be simplest to process each file as it is read:
@@@@@@ seq=f.read()
@@@@@@ checkDNA(seq) seq=f.read() f.close() s=seq
def checkDNA(seq): """Retourne une liste des caractères non conformes à
l'IUPAC.""" junk=[] for c in range (len(seq)): if seq[c] not in iupac: junk.append([seq[c],c]) #print junk print "ATTN: Il y a le caractère %s en position %s " %
(seq[c],c) if junk == []: indinv=range(len(seq)) indinv.reverse() resultat="" for i in indinv: resultat +=comp[seq[i]] return resultat
seq=checkDNA(seq) print seq
##### The program segment you posted did not define "comp" or "iupac",
##### so it's a little hard to guess how it's supposed to work. It
would
##### be helpful if you gave a concise description of what you want the
##### program to do, as well as brief sample of input data.
##### I hope this helps! -- George #I got the following ( as you see only one file is proceed by the
function even if more files is in extseq ['B1-11_win3F_B04_04.ab1.Seq'] ['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq'] ['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq',
'B1-18_win3F_D04_08.ab1.Seq'] ['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq',
'B1-18_win3F_D04_08.ab1.Seq', 'B1-18_win3R_E04_10.ab1.Seq'] ['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq',
'B1-18_win3F_D04_08.ab1.Seq', 'B1-18_win3R_E04_10.ab1.Seq',
'B1-19_win3F_F04_12.ab1.Seq'] .. ['B1-11_win3F_B04_04.ab1.Seq', 'B1-11_win3R_C04_06.ab1.Seq',
'B1-18_win3F_D04_08.ab1.Seq', 'B1-18_win3R_E04_10.ab1.Seq',
'B1-19_win3F_F04_12.ab1.Seq', 'B1-19_win3R_G04_14.ab1.Seq',
'B90_win3F_H04_16.ab1.Seq', 'B90_win3R_A05_01.ab1.Seq',
'DL2-11_win3F_H03_15.ab1.Seq', 'DL2-11_win3R_A04_02.ab1.Seq',
'DL2-12_win3F_F03_11.ab1.Seq', 'DL2-12_win3R_G03_13.ab1.Seq',
'M7757_win3F_B05_03.ab1.Seq', 'M7757_win3R_C05_05.ab1.Seq',
'M7759_win3F_D05_07.ab1.Seq', 'M7759_win3R_E05_09.ab1.Seq',
'TCR700-114_win3F_H05_15.ab1.Seq', 'TCR700-114_win3R_A06_02.ab1.Seq',
'TRC666-100_win3F_F05_11.ab1.Seq', 'TRC666-100_win3R_G05_13.ab1.Seq'] after this listing my programs proceed only the last element of this
listing (TRC666-100_win3R_G05_13.ab1.Seq)
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTCCCGAAGTGTCCCAGAGCA AATAAATGGACCAAAACGTTTTTAGAATACTTGAACGTGTAATCTCATTT TAA m_****@yahoo.com wrote: #!/cbi/prg/python/current/bin/python # -*- coding: iso-8859-1 -*- import sys import os from progadn import * ... for x in extseq: f = open(x, "r") seq=f.read() f.close() s=seq
def checkDNA(seq): ...
seq=checkDNA(seq) print seq
You terminated the loop to define checkDNA.
What you want is:
...
from progadn import *
def checkDNA(seq):
...
...
for x in extseq:
f = open(x, "r")
seq=f.read()
f.close()
s=seq
seq = checkDNA(seq)
print seq
Even better might be:
...
from progadn import *
def checkDNA(seq):
...
def main():
...
for x in extseq:
f = open(x, "r")
try:
print checkDNA(f.read())
finally:
f.close()
if __name__ = '__main__':
main()
--Scott David Daniels Sc***********@Acm.Org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Olcott |
last post by:
www.halting-problem.com
|
by: David Li |
last post by:
I am having a lot of problem with following code. To start with
I have a working sets of code and the top level SystemC code looks
like this:
----------working main.cpp start here...
|
by: Ben |
last post by:
I get an error when the compilator tries to link the object files of
my program. I have the files group.h and group.c that use a struct
define in logic.h and two fonctions define in logic.c.
The...
|
by: Vadivel Kumar |
last post by:
I have some hundred files (or webpages, just for example sake) which i have
to process
for some business logic. I have to read this files and do some thing as per
the given requirement.
I...
|
by: Steven Berkovitz |
last post by:
I have several ASP.NET applications with near identical web.config files. In
one of them I am successfuly able to bind to an assembly while on others I am
not.
All of them have the following...
| |
by: Justin Fancy |
last post by:
Hi everyone,
I have a textfile which I need to read and compare dates. The text file
summarizes every time I do an update to an internet site. Sample output
is as follows:
Copying...
|
by: codemaster |
last post by:
Hi,
I am using perl in windows platform. I have a directory structure \Dir\Data\tran\Archive\TDB\Log. There are files in the TDB directory with .dat extension. I need to parse the TDB directory...
|
by: larry |
last post by:
I am in the process of recoding a rather complex DB system into PHP
and am wondering if there is an alternative way I could template my
logic so I don't have to re-dcode the logic of the various...
|
by: hutch75 |
last post by:
Hi Folks,
Wondering if my logic is bringing me down the right path..was hoping for some feedback before I spend too much time creating the source document / database to test it out.
At a high...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |