fatmacankara commited on
Commit
d629d2c
1 Parent(s): 1c889af

Update code/add_alignment.py

Browse files
Files changed (1) hide show
  1. code/add_alignment.py +15 -26
code/add_alignment.py CHANGED
@@ -28,32 +28,21 @@ def convert_non_standard_amino_acids(sequence):
28
  return converted_sequence
29
  def do_alignment(identifier, uniprotSequence, pdbSequence, alignment_path):
30
  print(f'Aligning Datapoint: {identifier}')
31
- print(pdbSequence)
32
- print('uniprot Seq')
33
- print(uniprotSequence)
34
- #if len(pdbSequence) >= 1:
35
- #f = open(Path(alignment_path / f'{identifier}_alignment.txt'),"w")
36
- uniprotSequence = convert_non_standard_amino_acids(uniprotSequence)
37
- pdbSequence = convert_non_standard_amino_acids(pdbSequence)
38
- aligner.mode = 'local'
39
- print('1')
40
- aligner.substitution_matrix = substitution_matrices.load("BLOSUM62")
41
- print('2')
42
- aligner.open_gap_score = -11
43
- print('3')
44
- aligner.extend_gap_score = -1
45
- print('4')
46
- print(aligner.align(uniprotSequence, pdbSequence))
47
- alignments = aligner.align(uniprotSequence, pdbSequence)
48
- alignments = (list(alignments))
49
- alignment_list = []
50
- for alignment in alignments:
51
- #f.write(str(alignment))
52
- #f.write('\n')
53
- #f.write('\n')
54
- alignment = (str(alignment).strip().split('\n'))
55
- alignment = [''.join(['.' if m == ' ' else m for m in x]) for x in alignment]
56
- alignment_list.append(alignment)
57
  print(alignment_list)
58
  return alignment_list
59
 
 
28
  return converted_sequence
29
  def do_alignment(identifier, uniprotSequence, pdbSequence, alignment_path):
30
  print(f'Aligning Datapoint: {identifier}')
31
+ if len(pdbSequence) >= 1:
32
+ uniprotSequence = convert_non_standard_amino_acids(uniprotSequence)
33
+ pdbSequence = convert_non_standard_amino_acids(pdbSequence)
34
+ aligner.mode = 'local'
35
+ aligner.substitution_matrix = substitution_matrices.load("BLOSUM62")
36
+ aligner.open_gap_score = -11
37
+ aligner.extend_gap_score = -1
38
+ alignments = aligner.align(uniprotSequence, pdbSequence)
39
+ alignments = (list(alignments))
40
+ alignment_list = []
41
+ for alignment in alignments:
42
+ alignment = (str(alignment).strip().split('\n'))
43
+ alignment = [''.join(['.' if m == ' ' else m for m in x]) for x in alignment]
44
+ alignment_list.append(alignment)
45
+ print('ALIGNMENT LIST')
 
 
 
 
 
 
 
 
 
 
 
46
  print(alignment_list)
47
  return alignment_list
48