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 file.Every line in that file represents one amino acid,which has some value.But i need to separate those lines which has a value between 10 to 22.how can i compare every line and separate expected lines,save it in another 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.

if you have on one line only one value for example
1
2
3

to = open("file2", "w")  #open file for write mode
fp = open("file", "r")  #open read for write mode
for line in fp.readlines():   #read file 'file' for lines
	if int(line) <= 22 and int(line) >= 10:  #if value on line is smaller as 22 and bigger as 10
		to.write(line + "\n")  # write to file 'file2'
to.close() # close file 'file2'
fp.close()  # close file 'file'

and if you have name of acid and value for example
name_of_acid 1
name_of_acid 2
you can do that like this

to = open("file2", "w")  #open file for write mode
fp = open("file", "r")  #open read for write mode
for line in fp.readlines():   #read file 'file' for lines
	if ' ' in line:
		name, value = line.split(' ')  # split current line on name of acid and value
		if int(value) <= 22 and int(value) >= 10:  #if value on line is smaller as 22 and bigger as 10
			to.write(name + ' ' + value + "\n")  # write to file 'file2'
to.close() # close file 'file2'
fp.close()  # close file 'file'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.