Papa_Fubar

genesearchthing

Feb 12th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #!/usr/bin/python
  2. import sys
  3. import csv
  4. # Read in list of gene identifiers
  5. geneinfile = open('gene_ids.txt', 'r')
  6. # create list "currentgene" stripping whitespace and separating by newline, then closing file
  7. currentgene = geneinfile.read().strip().split('\n')
  8. geneinfile.close()
  9. #print (currentgene)
  10. #define function to search csv pages
  11. def expressionsearch(page):
  12. open(page, 'r')
  13. # read in values from columns 1 & 10 from expression sheet
  14. identifier = sh.col_values(0)
  15. foldex = sh.col_values(9)
  16. x = 0
  17. # uses for loop to read through "identifier" and if loop to identify presence of "clnID"
  18. for line in identifier:
  19. tissue = sheet.strip("TGAC_gene_exp_")
  20. if line == clnID:
  21. print "Gene " indentifier.pop(x) "has " foldex.pop(x) "expression in " tissue.strip(".csv")
  22. else x = x + 1
  23. # generate IDs in same format as spreadsheet
  24. for gene in currentgene:
  25. clnID = gene.strip("Ms_v2_scaf_")
  26. # commit tissue files to array and run function on genes in .txt file for all three tissues
  27. sheet = ["TGAC_gene_exp_rhizome.csv" "TGAC_gene_exp_stem.csv" "TGAC_gene_exp_leaf.csv"]
  28. for page in sheet:
  29. expressionsearch(page)
  30. close(page)
Add Comment
Please, Sign In to add comment