<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Hannah Frank</title>
    <description>The latest articles on Forem by Hannah Frank (@hannahkfrank).</description>
    <link>https://forem.com/hannahkfrank</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F60943%2F4251e3ff-0914-478f-8bce-c957b96b362e.jpg</url>
      <title>Forem: Hannah Frank</title>
      <link>https://forem.com/hannahkfrank</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hannahkfrank"/>
    <language>en</language>
    <item>
      <title>Advice on using a header in text to re-organize a large dataset</title>
      <dc:creator>Hannah Frank</dc:creator>
      <pubDate>Tue, 13 Aug 2019 22:15:46 +0000</pubDate>
      <link>https://forem.com/hannahkfrank/how-to-re-organize-hundreds-of-thousands-of-files-554g</link>
      <guid>https://forem.com/hannahkfrank/how-to-re-organize-hundreds-of-thousands-of-files-554g</guid>
      <description>&lt;p&gt;Hi Dev Community,&lt;/p&gt;

&lt;p&gt;I have over 100 files in the following structure (called a FASTA -- very familiar to those of you who spend time looking at genetic data):&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Original File 1&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&amp;gt;Gene1_id1&lt;/strong&gt;&lt;br&gt;
GATCGATCCGA&lt;br&gt;
ATGCAGTCCAG&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;gt;Gene2_id1&lt;/strong&gt;&lt;br&gt;
ATGCATGCAGC&lt;br&gt;
ACTAGGCCACG&lt;br&gt;
CCGTAGCGGAC&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;gt;Gene1_id2&lt;/strong&gt;&lt;br&gt;
TAGCTAGCAGT&lt;br&gt;
TAGCTAGCCGA&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each of these ~100 files contain ~20,000 of these genes.  The problem is that my files are organized such that &lt;code&gt;Gene1&lt;/code&gt; IDs are blended alongside &lt;code&gt;Gene2&lt;/code&gt; IDs.&lt;/p&gt;

&lt;p&gt;For my analysis, I need all of my &lt;code&gt;Gene1&lt;/code&gt; IDs organized in one place.  I will ideally end up with one file for each &lt;code&gt;GeneX&lt;/code&gt;, like so:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Desired Final &lt;code&gt;Gene1&lt;/code&gt; File&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&amp;gt;Gene1_id1&lt;/strong&gt;&lt;br&gt;
GATCGATCCGA&lt;br&gt;
ATGCAGTCCAG&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;gt;Gene1_id2&lt;/strong&gt;&lt;br&gt;
TAGCTAGCAGT&lt;br&gt;
TAGCTAGCCGA&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The length of sequence varies between genes and between individuals within genes, so I need all the lines below a header line and above the next header line to be associated with the header.&lt;/p&gt;

&lt;p&gt;My current solution has been to take each file, and then create a new file based on the header of each line.  So the first file creates three new files: one for &lt;code&gt;&amp;gt;Gene1_id1&lt;/code&gt;, one for &lt;code&gt;&amp;gt;Gene2_id1&lt;/code&gt;, and one for &lt;code&gt;Gene1_id2&lt;/code&gt;.  From there, I was planning on re-organizing to suit my needs.&lt;/p&gt;

&lt;p&gt;The problem with the above approach is that it has created ~800,000 similarly-named files which are killing my computer.  There must be a better way.&lt;/p&gt;

&lt;p&gt;Any advice on how to proceed?  Thanks!!!&lt;/p&gt;

&lt;p&gt;-Hannah&lt;/p&gt;

</description>
      <category>help</category>
      <category>bash</category>
    </item>
  </channel>
</rss>
