I have a big fasta.dataset
file containing half a million proteins (1.0 GB). I have four lines for each protein code:
- line 1:the protein code
- line 2: protein length in amino acids
- line 3: amino acid sequence
- line 4: secondary structure
Now, I am trying to open and read it in python (Biopython), and it does not work:
filename = 'pdb.fasta_qual.dataset'
sequences = SeqIO.parse ( filename,'fasta')
for record in sequences:
example = record
break
print(example)
How can I read it in python and loop through the file to look at line 3 for each protein to count the sequence length and distribution?
here is the first 5 lines of my file: which my file contains 500,000 proteins for each one has a 4 lines (name ,len of protein in amino acid,the seq represents by letters which what I would to calculate,the secondary structure)
4LGTD
247
M S E K L Q K V L A R A G H G T
. . E E H H H H H H H T T S S .
I want to open and read the file and loop through line 3 for each protein to calculate the length of the sequences and plot a histogram ! to check the distribution. ,,,
The output i am expecting is :
The len for the first seq is =
The len for the second seq is =
Until
the len of the last sequence which is number (500.000)=
And then i can plot a histogram for the len of the sequences ,,,
NOTE: I have opened and read the file's info by Linux, but I could not by python.
fasta.dataset
file; maybe 3-4 protein entries so we can see what we are working with since what you describe is not fasta; ii) show us the exact output you would want to see from that example input; iii) show us the code you wrote so we don't need to start from 0; iv) explain exactly how it "did not work"; v) tell us what operating system you are working with. Note that since this is not fasta, I doubt there is any reason to use biopython. $\endgroup${}
button). $\endgroup$247
? I ask you again, for the third time, please show us the output you are expecting. And does it have to be in python? I mean, all you want here isawk 'NR%4==2' file
, is that enough or do you absolutely need a whole python script? $\endgroup$