Note that there are some explanatory texts on larger screens.

plurals
  1. POFor-loop to count differences in lines with python
    primarykey
    data
    text
    <p>I have a file filled with lines like this (this is just a small bit of the file):</p> <p>9 Hyphomicrobium facile Hyphomicrobiaceae<br> 9 Hyphomicrobium facile Hyphomicrobiaceae<br> 7 Mycobacterium kansasii Mycobacteriaceae<br> 7 Mycobacterium gastri Mycobacteriaceae<br> 10 Streptomyces olivaceiscleroticus Streptomycetaceae<br> 10 Streptomyces niger Streptomycetaceae<br> 1 Streptomyces geysiriensis Streptomycetaceae<br> 1 Streptomyces minutiscleroticus Streptomycetaceae<br> 0 Brucella neotomae Brucellaceae<br> 0 Brucella melitensis Brucellaceae<br> 2 Mycobacterium phocaicum Mycobacteriaceae</p> <p>The number refers to a cluster, and then it goes 'Genus' 'Species' 'Family'. What I want to do is write a program that will look through each line and report back to me: a list of the different genera in each cluster, and how many of each of those genera are in the cluster. So I'm interested in cluster number and the first 'word' in each line. </p> <p>My trouble is that I'm not sure how to get this information. I think I need to use a for-loop, starting at lines that begin with '0.'The output would be a file that looks something like:</p> <p>Cluster 0: Brucella(2) # Lists cluster, followed by genera in cluster with number, something like that.<br> Cluster 1: Streptomyces(2)<br> Cluster 2: Brucella(1)<br> etc. </p> <p>Eventually I want to do the same kind of count with the Families in each cluster, and then Genera and Species together. Any thoughts on how to start would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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