Guest User

Untitled

a guest
Dec 13th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. path = "/Users/rmadupuri/GitHub/datahub/public"
  5.  
  6. all_studies = os.listdir(path)
  7. tcga_studies = list()
  8. for studies in all_studies:
  9. if os.path.isdir(path+"/"+studies):
  10. if re.search(r'_tcga$',studies): # For Provisional studies
  11. tcga_studies.append(studies)
  12. if "_tcga_pub" in studies: # For published studies
  13. tcga_studies.append(studies)
  14.  
  15. for st in tcga_studies:
  16. files = os.listdir(path+"/"+st)
  17. if "meta_RNA_Seq_v2_expression_median.txt" in files:
  18. data = str()
  19. with open(path+"/"+st+"/meta_RNA_Seq_v2_expression_median.txt",'r') as f:
  20. for line in f:
  21. if line.startswith("profile_description"):
  22. data += "profile_description: mRNA gene expression (RNA Seq V2 RSEM)\n"
  23. else:
  24. data += line
  25. os.remove(path+"/"+st+"/meta_RNA_Seq_v2_expression_median.txt")
  26. f= open(path+"/"+st+"/meta_RNA_Seq_v2_expression_median.txt","w+")
  27. f.write(data)
  28. f.close()
Add Comment
Please, Sign In to add comment