473,324 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to add multiple lists to a script to count number of residues

6
#!/usr/bin/python
import os
d={}
path=os.getcwd()
print path
list_of_filenames=os.listdir(os.path.join(path, 'newfiles'))
print list_of_filenames
residue=[]
for f in list_of_filenames:
f1=open(os.path.join(path, 'newfiles', f)).readlines()
d[f]=0
for line in f1:
if line.startswith('ATOM'):
res_number=line[22:26]
if res_number not in residue and line[17:20]!='HOH':
residue.append(res_number)
d[f]+=1
else:
continue
else:
continue
print(len(residue))
print(d)


Herewith I attach a txt file of my sample input.
in that file
column 1 represents ATOM or HETATM
column 2 represents atom number
column 3 represents atom type
column 4 represents name of the residue
column 5 represents the type of the chain
column 6 represents residue number

My question is how many residues are in this file?

It's complicated to find it because of even atom number changes in every line, residue number stands as a constant. Because in one residue there are different atoms.
Another thing is both in chain A and chain B, ALA is residue 542, but in chain A there is no 543rd residue, but in chain B there is 543rd residue. Therefore newly addition from chain B is only 543rd residue, otherwise values will be repeated.
I want to count number of residues of the file except water (HOH) molecules ?

So how can I count number of residues in this file?
Mar 15 '17 #1
2 1170
dwblas
626 Expert 512MB
Didn't you already do this, i.e. count all in all files, in a previous post that asked how to count each file individually?
Mar 15 '17 #2
iromi
6
@dwblas yes I got some answers. but they are unbelievable. So I think there is a problem with my codes. i.e repetition of values when counting.
So I need to know how to modify these codes. Please if you know the method can you help me ?
Mar 16 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: vic | last post by:
Hello, Dean Try this: select distinct c1, c2 into #tmp_1 from t1 select count(*) as cnt from #tmp_1 drop table #tmp_1 With best regards.
0
by: DataFreakFromUtah | last post by:
Hello! No question here, just a procedure for the archive. Search critera: count records imported count data imported count number of rows imported count number of records imported record import...
1
by: Girish Sahani | last post by:
hello ppl, Consider a list like . Here 'a','b','c' are objects and 1,3,4,2 are their instance ids and they are unique e.g. a.1 and b.1 cannot exist together. From this list i want to generate...
1
by: tranky | last post by:
hi, only one information,please... how to count number of anonymous online users? I use ASP.NET 2.0 thank u tranky
5
by: isabelle | last post by:
hi, every body.. I have two program I couldn’t solve them So, can any body help me. please!! 1-Write a program that accepts a character and count number of occurrences in a file. The file...
11
by: Mack | last post by:
Hi all, I want to write a program to count number of bits set in a number. The condition is we should not loop through each bit to find whether its set or not. Thanks in advance, -Mukesh
2
by: mfaisalwarraich | last post by:
Hi Everybody, I am using the following code to get the recordset of an external database. Dim dbPatients As Database Dim rsCountPatients As Recordset ' to count number of...
5
by: jambonjamasb | last post by:
I am wanting to create a report that summarises the number of items within a date range. For example I have a FIELD called System_Change. This is a drop down COMBOBOX that uses words like unix,...
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
2
by: raknunna | last post by:
Hi, Please provide a query to find "count(*number) of grants in a role. we have a role ALPHA_ROLE and I just want count of only select grants existing in the role. Can someone help. Thanks in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.