Dear python community, <div><br></div><div>I have a file where I store sequences that each have a header. The structure of the file is as such:</div><div><br></div><div>&gt;sp|(some code) =&gt;1st header</div><div>ATTTTGGCGG</div>
<div>MNKPLOI</div><div>.....</div><div>.....</div><div><br></div><div>&gt;sp|(some code) =&gt; 2nd header </div><div>AAAAAA </div><div>GGGG ...</div><div>.........</div><div><br></div><div>......</div><div><br></div><div>
I am looking to implement a logical structure that would allow me to group each of the sequences (spread on multiple lines) into a single string. So instead of having the letters spread on multiple lines I would be able to have &#39;ATTTTGGCGGMNKP....&#39; as a single string that could be indexed. </div>
<div> </div><div>This snipped is good for isolating the sequences (=stripping headers and skipping blank lines) but how could I concatenate each sequence in order to get one string per sequence? </div><div><br></div><div>
<div>&gt;&gt;&gt; for line in align_file:</div><div>...     if line.startswith(&#39;&gt;sp&#39;):</div><div>...             continue</div><div>...     elif not line.strip():</div><div>...             continue</div><div>...     else:</div>
<div>...             print line</div></div><div><br></div><div>(... is just OS X terminal notation, nothing programmatic) </div><div><br></div><div>Many thanks in advance. </div><div><br></div><div>S. </div>