Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This seems more like something that can be done easily using a simple <b>SQL Query</b>. Especially as you get your files in a database table format. I couldn't comment on your question, to ask you more about it as I don't have enough reputation to do so. </p> <p>So I'm assuming that you get your data from a table. Not that you can't solve this problem in Perl. But I strongly recommend using the database to do such calculation when fetching the data file, as that seems much easier. And I am not sure why you chose to do it in Perl, especially when you have lots of such fields in a file and you wanted to do such operations on all of them. And you could still use Perl to interact with your database when solving your problem via an SQL Query.</p> <p>So my proposed solution in SQL, if the data is collected from a database is: Write an SQL statement involving a GROUP BY on the GENE and feature field and aggregate the size column. If your table looked exactly like what you described, let us call it GeneInformation table and you loaded your data file to the SQL database (SQLLite maybe) then your select query would be:</p> <pre><code>SELECT gene, feature, SUM(size) FROM GeneInformation GROUP BY gene, feature; </code></pre> <p>That should give you a list of genes, features and their corresponding total sizes . <br /><b>If SQL solution is completely impossible for you then I will talk about the Perl solution. </b> I noticed that the Perl solutions are based on the assumption that a particular gene's values would appear consecutively in the file. If that is the case then I would like to up vote <a href="https://stackoverflow.com/users/1521179/amon">amon</a>'s answer (which I can't do at the moment).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload