new user needs help!

D

drjekil

I am totally new in biopython and its my first program.so may be i am asking
stupid question.
I am working with a text filelooks like this:
#NAME AA TOPO ACCESS DSSP STRIDE Z-COORD
1lghB A i 79.8 H H -24.58
1lghB V i 79.6 H H -22.06
1lghB H i 71.9 H H -19.94
i need to compare those lines which has a Z-COORED value between 10 to 22
and presents in the following way
True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets
represents amino acids)
1 1:1 2:0 3:0 and so on for rest of the amino acids.
IF PRESENT IN THAT RANGE
IF not PRESENT IN THAT RANGE then
-1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding
amino acid for that line.say here,for 2nd line it will be 16:1.
true will represent 1,false -1.
i have to cheek all the lins in the file and print it.
u have to tell simply otherwise i cant understand even,so stupid am i!
I will be really greatful!Thanks in advance
 
M

Mike Driscoll

I am totally new in biopython and its my first program.so may be i am asking
stupid question.
I am working with a text filelooks like this:
#NAME AA TOPO ACCESS DSSP STRIDE Z-COORD
1lghB A i 79.8 H H -24.58
1lghB V i 79.6 H H -22.06
1lghB H i 71.9 H H -19.94
i need to compare those lines which has a Z-COORED value between 10 to 22
and presents in the following way
True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets
represents amino acids)
1 1:1 2:0 3:0 and so on for rest of the amino acids.
IF PRESENT IN THAT RANGE
IF not PRESENT IN THAT RANGE then
-1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding
amino acid for that line.say here,for 2nd line it will be 16:1.
true will represent 1,false -1.
i have to cheek all the lins in the file and print it.
u have to tell simply otherwise i cant understand even,so stupid am i!
I will be really greatful!Thanks in advance

To read the file, do something like this:

<code>

f = open('path/to/filename')
for line in f.readlines():
# do something
print line

</code>

See http://docs.python.org/lib/bltin-file-objects.html for more
information.

You'll want to look at using "if" statements to do the various
conditions and you'll probably need to use string slicing/splitting to
get the correct part of the line to do the comparison.

So, something like

<code>

f = open('path/to/filename')
for line in f.readlines():
parts = line.split()
zcoord = parts[-1]
if zcoord > 10 and zcoord < 22:
# do something
pass
print line

</code>

Resources:

http://docs.python.org/ref/if.html
http://www.ibiblio.org/g2swap/byteofpython/read/if-statement.html
http://docs.python.org/lib/string-methods.html
http://www.diveintopython.org/native_data_types/joining_lists.html

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

new user needs help! 0
Help please 8
Help with code 0
Pygame animation help!!!! 0
Help with code plsss 0
Help Needed with VBA please help 0
Can't solve problems! please Help 0
Need help with this script 4

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top