I have a script that puts the line that starts with #Solution 1 in a new file together with the name of the input file. But I want to add the piece belonging to Major from the input file. Can someone please help me to figure out how to get the piece of text?

The script now:

```
#!/usr/bin/env python3

import os

dr = "/home/nwalraven/Result_pgx/Runfolder/Runres_Aldy" outdr = "/home/nwalraven/Result_pgx/Runfolder/Aldy_res_txt" tag = ".aldy"

for f in os.listdir(dr):
    if f.endswith(tag):
        print(f)
        new_file_name = f.split('_')[0]+'.txt' # get the name of the file before the '_' and add '.txt' to it
        with open(dr+"/"+f) as file:
            for line in file.readlines():
                f
                if line.startswith("#Solution 1"):
                    with open(outdr+"/"+new_file_name,"a",newline='\n') as new_file:
                        new_file.write(f.split('.')[0] + "\n")
                        new_file.write(line + "\n")
                if line.startswith("#Solution 2"):
                    with open(outdr+"/"+new_file_name,"a",newline='\n') as new_file:
                        new_file.write(line + "\n")
                        print("Meerdere oplossingen gevonden! Check Aldy bestand" )

```

The input:

file = EMQN3-S3\_COMT.aldy

```
#Sample Gene    SolutionID  Major   Minor   Copy    Allele  Location    Type    Coverage    Effect  dbSNP   Code    Status
#Solution 1: *Met, *ValB
EMQN3-S3    COMT    1   *Met/*ValB  Met;ValB    0   Met 19950234    C>T 530 H62=    rs4633  
EMQN3-S3    COMT    1   *Met/*ValB  Met;ValB    0   Met 19951270    G>A 651 V158M   rs4680  
EMQN3-S3    COMT    1   *Met/*ValB  Met;ValB    1   ValB                            

```

file = EMQN3-S3\_CYP2B6.aldy

```
#Sample Gene    SolutionID  Major   Minor   Copy    Allele  Location    Type    Coverage    Effect  dbSNP   Code    Status
#Solution 1: *1.001, *1.001
EMQN3-S3    CYP2B6  1   *1/*1   1.001;1.001 0   1.001                           
EMQN3-S3    CYP2B6  1   *1/*1   1.001;1.001 1   1.001

```

The result it gives right now:

```
EMQN3-S3_COMT.aldy
#Solution 1: *Met, *ValB

EMQN3-S3_CYP2B6.aldy
#Solution 1: *1.001, *1.001

```

The result I need:

```
EMQN3-S3_COMT.aldy
#Solution 1: *Met/*ValB

EMQN3-S3_CYP2B6.aldy
#Solution 1: *1/*1

```