You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

how_many_samples.py 1.4KB

4 vuotta sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import pandas as pd
  2. import sys, argparse, os
  3. from operator import itemgetter
  4. parser = argparse.ArgumentParser(description="This script is to get how many samples")
  5. parser.add_argument('-sample', '--sample', type=str, help='quartet_sample', required=True)
  6. parser.add_argument('-rep', '--rep', type=str, help='quartet_rep', required=True)
  7. args = parser.parse_args()
  8. # Rename input:
  9. sample = args.sample
  10. rep = args.rep
  11. quartet_sample = pd.read_table(sample,header=None)
  12. quartet_sample = list(quartet_sample[0])
  13. quartet_rep = pd.read_table(rep.header=None)
  14. quartet_rep = quartet_rep[0]
  15. #tags
  16. sister_tag = 'false'
  17. quartet_tag = 'false'
  18. quartet_rep_unique = list(set(quartet_rep))
  19. single_rep = [i for i in range(len(quartet_rep)) if quartet_rep[i] == quartet_rep_unique[0]]
  20. single_batch_sample = itemgetter(*single_rep)(quartet_sample)
  21. num = len(single_batch_sample)
  22. if num == 1:
  23. sister_tag = 'false'
  24. quartet_tag = 'false'
  25. elif num == 2:
  26. if set(single_batch_sample) == set(['LCL5','LCL6']):
  27. sister_tag = 'true'
  28. quartet_tag = 'false'
  29. elif num == 3:
  30. if ('LCL5' in single_batch_sample) and ('LCL6' in single_batch_sample):
  31. sister_tag = 'true'
  32. quartet_tag = 'false'
  33. elif num == 4:
  34. if set(single_batch_sample) == set(['LCL5','LCL6','LCL7','LCL8']):
  35. sister_tag = 'false'
  36. quartet_tag = 'true'
  37. sister_outfile = open('sister_tag','w')
  38. quartet_outfile = open('quartet_tag','w')
  39. sister_outfile.write(sister_tag)
  40. quartet_outfile.write(quartet_tag)