Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print mash results to a TSV file #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kapsakcj
Copy link

Hey Rachael, I tried out Centroid today and was curious to see "behind the curtain" for how the centroid genome is chosen from a set of genomes.

So here's a simple little PR that does the following:

  • takes the rows of Output which is tab-delimited already
  • uses .decode("utf-8") to strip off the byte encoding from each row
  • adds the rows to a file called mash-output.tsv

I'm not a pythonista, so there may be some non-best practice code 😬 , but this works for me and creates a TSV as expected:

# 5 assemblies
$ ls asms/
SAMN19774594_contigs.fasta  SAMN19774612_contigs.fasta  SAMN19774623_contigs.fasta  SAMN19774642_contigs.fasta  SAMN19774644_contigs.fasta

# run centroid on dir of assemblies
$ python3 ~/github/centroid-kapsakcj-fork/centroid.py asms/
Sketching asms/SAMN19774644_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774644_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774644_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774644_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774644_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774594_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774594_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774594_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774594_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774594_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774612_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774612_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774612_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774612_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774612_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774642_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774642_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774642_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774642_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774642_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774623_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774623_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774623_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774623_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
Sketching asms/SAMN19774623_contigs.fasta (provide sketch file made with "mash sketch" to skip)...done.
b'asms/SAMN19774594_contigs.fasta'

# show centroid out file
$ cat centroid_out.txt 
SAMN19774594_contigs.fasta

# show mash-results.tsv but with nice tabular-aware spacing
$ column -t -s $'\t' -n mash-results.tsv 
asms/SAMN19774594_contigs.fasta  asms/SAMN19774594_contigs.fasta  0            0  1000/1000
asms/SAMN19774594_contigs.fasta  asms/SAMN19774612_contigs.fasta  0.000361208  0  985/1000
asms/SAMN19774594_contigs.fasta  asms/SAMN19774623_contigs.fasta  0.00390583   0  854/1000
asms/SAMN19774594_contigs.fasta  asms/SAMN19774642_contigs.fasta  0.0023533    0  908/1000
asms/SAMN19774594_contigs.fasta  asms/SAMN19774644_contigs.fasta  0.00294054   0  887/1000
asms/SAMN19774612_contigs.fasta  asms/SAMN19774594_contigs.fasta  0.000361208  0  985/1000
asms/SAMN19774612_contigs.fasta  asms/SAMN19774612_contigs.fasta  0            0  1000/1000
asms/SAMN19774612_contigs.fasta  asms/SAMN19774623_contigs.fasta  0.00408721   0  848/1000
asms/SAMN19774612_contigs.fasta  asms/SAMN19774642_contigs.fasta  0.00210772   0  917/1000
asms/SAMN19774612_contigs.fasta  asms/SAMN19774644_contigs.fasta  0.00308338   0  882/1000
asms/SAMN19774623_contigs.fasta  asms/SAMN19774594_contigs.fasta  0.00390583   0  854/1000
asms/SAMN19774623_contigs.fasta  asms/SAMN19774612_contigs.fasta  0.00408721   0  848/1000
asms/SAMN19774623_contigs.fasta  asms/SAMN19774623_contigs.fasta  0            0  1000/1000
asms/SAMN19774623_contigs.fasta  asms/SAMN19774642_contigs.fasta  0.00433199   0  840/1000
asms/SAMN19774623_contigs.fasta  asms/SAMN19774644_contigs.fasta  0.00384578   0  856/1000
asms/SAMN19774642_contigs.fasta  asms/SAMN19774594_contigs.fasta  0.0023533    0  908/1000
asms/SAMN19774642_contigs.fasta  asms/SAMN19774612_contigs.fasta  0.00210772   0  917/1000
asms/SAMN19774642_contigs.fasta  asms/SAMN19774623_contigs.fasta  0.00433199   0  840/1000
asms/SAMN19774642_contigs.fasta  asms/SAMN19774642_contigs.fasta  0            0  1000/1000
asms/SAMN19774642_contigs.fasta  asms/SAMN19774644_contigs.fasta  0.00375609   0  859/1000
asms/SAMN19774644_contigs.fasta  asms/SAMN19774594_contigs.fasta  0.00294054   0  887/1000
asms/SAMN19774644_contigs.fasta  asms/SAMN19774612_contigs.fasta  0.00308338   0  882/1000
asms/SAMN19774644_contigs.fasta  asms/SAMN19774623_contigs.fasta  0.00384578   0  856/1000
asms/SAMN19774644_contigs.fasta  asms/SAMN19774642_contigs.fasta  0.00375609   0  859/1000
asms/SAMN19774644_contigs.fasta  asms/SAMN19774644_contigs.fasta  0            0  1000/1000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants