Skip to content

Instantly share code, notes, and snippets.

@asalt
Created June 17, 2015 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asalt/ce7b01e06691805bc747 to your computer and use it in GitHub Desktop.
Save asalt/ce7b01e06691805bc747 to your computer and use it in GitHub Desktop.
Count and use uniques
from collections import Counter
# construct counter to count the number of occurances of each fasta
cnt = Counter()
with inputfile as f:
for line in f:
linesplit = line.split('\t')
cnt[linesplit[fasta_pos]] += 1 #establish counter, count occurrances of each fasta file
with inputfile as f:
for line in f:
linesplit = line.split('\t')
if cnt[linesplit[fasta_pos]] == 1: #look at your counter, look at how many times the fasta occurs
outfile.write(......)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment