Mercurial > repos > abims-sbr > pogs
comparison scripts/pogs.py @ 10:1a728cb1da31 draft
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit b7a3030ea134b5dfad89b1a869db659d72d1145c
| author | abims-sbr |
|---|---|
| date | Wed, 28 Feb 2018 10:37:38 -0500 |
| parents | b19ed7395dcc |
| children |
comparison
equal
deleted
inserted
replaced
| 9:a76e4758dc44 | 10:1a728cb1da31 |
|---|---|
| 9 - A minimal number of species per group has to be set. | 9 - A minimal number of species per group has to be set. |
| 10 | 10 |
| 11 BETA VERSION | 11 BETA VERSION |
| 12 """ | 12 """ |
| 13 | 13 |
| 14 import os, argparse | 14 import os, argparse, itertools |
| 15 import numpy as np | 15 import numpy as np |
| 16 import pandas as pd | 16 import pandas as pd |
| 17 | 17 |
| 18 """ Definition of a locus : header + sequence + a tag """ | 18 """ Definition of a locus : header + sequence + a tag """ |
| 19 class Locus: | 19 class Locus: |
| 57 """ Reads an output file from the 'Pairwise' tool (AdaptSearch suite) and returns its content into a list | 57 """ Reads an output file from the 'Pairwise' tool (AdaptSearch suite) and returns its content into a list |
| 58 Returns a list of sets (2 items per set) """ | 58 Returns a list of sets (2 items per set) """ |
| 59 def getPairwiseCouple(pairwiseFile): | 59 def getPairwiseCouple(pairwiseFile): |
| 60 list_pairwises_2sp = [] | 60 list_pairwises_2sp = [] |
| 61 with open(pairwiseFile, "r") as file: | 61 with open(pairwiseFile, "r") as file: |
| 62 while (1): # Ugly ! | 62 for name, sequence, name2, sequence2 in itertools.izip_longest(*[file]*4): |
| 63 name, sequence, name2, sequence2 = file.readline(), file.readline(), file.readline(), file.readline() | |
| 64 if not name: break # Use assert ? | |
| 65 # One locus every two lines (one pairwise couple = 4 lines) : header + sequence | 63 # One locus every two lines (one pairwise couple = 4 lines) : header + sequence |
| 66 locus1 = Locus(name, sequence) | 64 locus1 = Locus(name, sequence) |
| 67 locus2 = Locus(name2, sequence2) | 65 locus2 = Locus(name2, sequence2) |
| 68 group = set([]) | 66 group = set([]) |
| 69 group.add(locus1) | 67 group.add(locus1) |
