EC2 Default User commited on
Commit
23dc9d7
1 Parent(s): d36ac0a

Add cdr coordinates

Browse files
oas-paired-sequence-data.py CHANGED
@@ -36,13 +36,19 @@ _FEATURES = datasets.Features(
36
  {
37
  "pair_id": datasets.Value("string"),
38
  "sequence_alignment_aa_heavy": datasets.Value("string"),
39
- "cdr1_aa_heavy": datasets.Value("string"),
40
- "cdr2_aa_heavy": datasets.Value("string"),
41
- "cdr3_aa_heavy": datasets.Value("string"),
42
  "sequence_alignment_aa_light": datasets.Value("string"),
43
- "cdr1_aa_light": datasets.Value("string"),
44
- "cdr2_aa_light": datasets.Value("string"),
45
- "cdr3_aa_light": datasets.Value("string"),
 
 
 
 
 
 
 
 
 
46
  }
47
  )
48
 
@@ -93,12 +99,18 @@ class OasPairedSequenceData(datasets.GeneratorBasedBuilder):
93
  yield key, {
94
  "pair_id": row[0],
95
  "sequence_alignment_aa_heavy": row[1],
96
- "cdr1_aa_heavy": row[2],
97
- "cdr2_aa_heavy": row[3],
98
- "cdr3_aa_heavy": row[4],
99
- "sequence_alignment_aa_light": row[5],
100
- "cdr1_aa_light": row[6],
101
- "cdr2_aa_light": row[7],
102
- "cdr3_aa_light": row[8],
 
 
 
 
 
 
103
  }
104
 
 
36
  {
37
  "pair_id": datasets.Value("string"),
38
  "sequence_alignment_aa_heavy": datasets.Value("string"),
 
 
 
39
  "sequence_alignment_aa_light": datasets.Value("string"),
40
+ "cdr1_aa_heavy_start": datasets.Value("int16"),
41
+ "cdr1_aa_heavy_end": datasets.Value("int16"),
42
+ "cdr1_aa_light_start": datasets.Value("int16"),
43
+ "cdr1_aa_light_end": datasets.Value("int16"),
44
+ "cdr2_aa_heavy_start": datasets.Value("int16"),
45
+ "cdr2_aa_heavy_end": datasets.Value("int16"),
46
+ "cdr2_aa_light_start": datasets.Value("int16"),
47
+ "cdr2_aa_light_end": datasets.Value("int16"),
48
+ "cdr3_aa_heavy_start": datasets.Value("int16"),
49
+ "cdr3_aa_heavy_end": datasets.Value("int16"),
50
+ "cdr3_aa_light_start": datasets.Value("int16"),
51
+ "cdr3_aa_light_end": datasets.Value("int16"),
52
  }
53
  )
54
 
 
99
  yield key, {
100
  "pair_id": row[0],
101
  "sequence_alignment_aa_heavy": row[1],
102
+ "sequence_alignment_aa_light": row[2],
103
+ "cdr1_aa_heavy_start": row[3],
104
+ "cdr1_aa_heavy_end": row[4],
105
+ "cdr1_aa_light_start": row[5],
106
+ "cdr1_aa_light_end": row[6],
107
+ "cdr2_aa_heavy_start": row[7],
108
+ "cdr2_aa_heavy_end": row[8],
109
+ "cdr2_aa_light_start": row[9],
110
+ "cdr2_aa_light_end": row[10],
111
+ "cdr3_aa_heavy_start": row[11],
112
+ "cdr3_aa_heavy_end": row[12],
113
+ "cdr3_aa_light_start": row[13],
114
+ "cdr3_aa_light_end": row[14],
115
  }
116
 
src/download_and_process_data.py CHANGED
@@ -7,6 +7,7 @@ output_path = os.getcwd()
7
 
8
  species_list = ["human", "rat_SD", "mouse_BALB_c", "mouse_C57BL_6"]
9
 
 
10
  for species in species_list:
11
  print(f"Downloading {species} files")
12
  list_of_df = []
@@ -34,6 +35,32 @@ for species in species_list:
34
  "cdr3_aa_light",
35
  ]
36
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  run_data.insert(
38
  0, "pair_id", run_id + "_" + run_data.reset_index().index.map(str)
39
  )
@@ -42,7 +69,7 @@ for species in species_list:
42
  print(f"{species} output summary:")
43
  print(species_df.head())
44
  print(species_df.shape)
45
- output_file_name = os.path.join(output_path, species + ".csv")
46
  print(f"Creating {output_file_name}")
47
- species_df.to_csv(output_file_name, index=False)
48
 
 
7
 
8
  species_list = ["human", "rat_SD", "mouse_BALB_c", "mouse_C57BL_6"]
9
 
10
+
11
  for species in species_list:
12
  print(f"Downloading {species} files")
13
  list_of_df = []
 
35
  "cdr3_aa_light",
36
  ]
37
  ]
38
+ run_data = run_data.dropna()
39
+
40
+ def calc_cdr_coordinates(row):
41
+ for i in range(1, 4):
42
+ for j in ["heavy", "light"]:
43
+ row[f"cdr{i}_aa_{j}_start"] = row[
44
+ f"sequence_alignment_aa_{j}"
45
+ ].find(row[f"cdr{i}_aa_{j}"])
46
+ row[f"cdr{i}_aa_{j}_end"] = row[f"cdr{i}_aa_{j}_start"] + len(
47
+ row[f"cdr{i}_aa_{j}"]
48
+ )
49
+ return row
50
+
51
+ run_data = run_data.apply(calc_cdr_coordinates, axis=1)
52
+
53
+ run_data = run_data.drop(
54
+ columns=[
55
+ "cdr1_aa_heavy",
56
+ "cdr2_aa_heavy",
57
+ "cdr3_aa_heavy",
58
+ "cdr1_aa_light",
59
+ "cdr2_aa_light",
60
+ "cdr3_aa_light",
61
+ ]
62
+ )
63
+
64
  run_data.insert(
65
  0, "pair_id", run_id + "_" + run_data.reset_index().index.map(str)
66
  )
 
69
  print(f"{species} output summary:")
70
  print(species_df.head())
71
  print(species_df.shape)
72
+ output_file_name = os.path.join(output_path, species + ".zip")
73
  print(f"Creating {output_file_name}")
74
+ species_df.to_csv(output_file_name, index=False, compression="zip")
75